2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * prepare.c: Perform prelimiary updates of sectors
30 * Known contributors to this file:
32 * Thomas Ruschak, 1992
55 extern float levels[MAXNOC][4];
58 prepare_sects(int etu, int *bp)
61 register struct sctstr *sp;
63 int n, civ_tax, uw_tax, mil_pay;
65 memset(levels, 0, sizeof(levels));
67 /* Process all the fallout. */
69 if (!player->simulation) {
70 /* First, we determine which sectors to process fallout in */
71 for (n = 0; NULL != (sp = getsectid(n)); n++) {
72 if (getvar(V_FALLOUT, (s_char *)sp, EF_SECTOR))
77 /* Next, we process the fallout there */
78 for (n = 0; NULL != (sp = getsectid(n)); n++)
81 /* Next, we spread the fallout */
82 for (n = 0; NULL != (sp = getsectid(n)); n++)
84 spread_fallout(sp, etu);
85 /* Next, we decay the fallout */
86 for (n = 0; NULL != (sp = getsectid(n)); n++)
87 if (getvar(V_FALLOUT, (s_char *)sp, EF_SECTOR))
88 decay_fallout(sp, etu);
91 for (n = 0; NULL != (sp = getsectid(n)); n++) {
94 if (sp->sct_type == SCT_WATER)
96 fill_update_array(bp, sp);
97 np = getnatp(sp->sct_own);
100 if (np->nat_stat & STAT_SANCT)
101 logerror("Prepare.c: country in sanctuary skipped production");
104 if (!(np->nat_stat & STAT_SANCT)) {
106 do_plague(sp, np, etu);
107 tax(sp, np, etu, &pops[sp->sct_own], &civ_tax, &uw_tax,
109 np->nat_money += civ_tax + uw_tax + mil_pay;
110 if (sp->sct_type == SCT_BANK)
111 np->nat_money += bank_income(sp, etu);
114 for (n = 0; NULL != (np = getnatp(n)); n++) {
115 np->nat_money += upd_slmilcosts(np->nat_cnum, etu);
120 tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
121 int *uw_tax, int *mil_pay)
128 if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
131 if (!player->simulation)
132 populace(np, sp, vec, etu);
133 *civ_tax = (int)(0.5 + vec[I_CIVIL] * sp->sct_effic *
134 etu * money_civ / 100);
136 * captured civs only pay 1/4 taxes
138 if (sp->sct_own != sp->sct_oldown)
139 *civ_tax = *civ_tax / 4;
140 *uw_tax = (int)(0.5 + vec[I_UW] * sp->sct_effic *
141 etu * money_uw / 100);
142 *mil_pay = vec[I_MILIT] * etu * money_mil;
145 * only non-captured civs add to census for nation
147 if (sp->sct_oldown == sp->sct_own)
148 *pop += vec[I_CIVIL];
152 upd_slmilcosts(natid n, int etu)
161 for (i = 0; NULL != (sp = getshipp(i)); i++) {
162 if (!sp->shp_own || sp->shp_own != n)
164 if ((mil = getvar(V_MILIT, (s_char *)sp, EF_SHIP)) > 0)
167 for (i = 0; NULL != (lp = getlandp(i)); i++) {
168 if (!lp->lnd_own || lp->lnd_own != n)
170 if ((mil = getvar(V_MILIT, (s_char *)lp, EF_LAND)) > 0)
173 mil_pay = totalmil * etu * money_mil;
178 bank_income(struct sctstr *sp, int etu)
182 if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
185 return (int)(vec[I_BAR] * etu * bankint * sp->sct_effic / 100);