2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * prepare.c: Perform prelimiary updates of sectors
29 * Known contributors to this file:
31 * Thomas Ruschak, 1992
46 prepare_sects(int etu, struct bp *bp)
50 int n, civ_tax, uw_tax, mil_pay;
52 memset(levels, 0, sizeof(levels));
54 /* Process all the fallout. */
56 if (!player->simulation) {
57 /* First, we determine which sectors to process fallout in */
58 for (n = 0; NULL != (sp = getsectid(n)); n++)
59 sp->sct_updated = sp->sct_fallout != 0;
60 /* Next, we process the fallout there */
61 for (n = 0; NULL != (sp = getsectid(n)); n++)
64 /* Next, we spread the fallout */
65 for (n = 0; NULL != (sp = getsectid(n)); n++)
67 spread_fallout(sp, etu);
68 /* Next, we decay the fallout */
69 for (n = 0; NULL != (sp = getsectid(n)); n++)
71 decay_fallout(sp, etu);
74 for (n = 0; NULL != (sp = getsectid(n)); n++) {
77 if (sp->sct_type == SCT_WATER)
79 bp_set_from_sect(bp, sp);
80 np = getnatp(sp->sct_own);
82 if (np->nat_stat != STAT_SANCT) {
84 do_plague(sp, np, etu);
85 tax(sp, np, etu, &pops[sp->sct_own], &civ_tax, &uw_tax,
87 np->nat_money += civ_tax + uw_tax + mil_pay;
88 if (sp->sct_type == SCT_BANK)
89 np->nat_money += bank_income(sp, etu);
92 for (n = 0; NULL != (np = getnatp(n)); n++) {
93 np->nat_money += upd_slmilcosts(np->nat_cnum, etu);
98 tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
99 int *uw_tax, int *mil_pay)
105 if (!player->simulation)
106 populace(np, sp, etu);
107 *civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
108 etu * money_civ / 100);
110 * captured civs only pay 1/4 taxes
112 if (sp->sct_own != sp->sct_oldown)
113 *civ_tax = *civ_tax / 4;
114 *uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic *
115 etu * money_uw / 100);
116 *mil_pay = sp->sct_item[I_MILIT] * etu * money_mil;
119 * only non-captured civs add to census for nation
121 if (sp->sct_oldown == sp->sct_own)
122 *pop += sp->sct_item[I_CIVIL];
126 upd_slmilcosts(natid n, int etu)
135 for (i = 0; NULL != (sp = getshipp(i)); i++) {
136 if (!sp->shp_own || sp->shp_own != n)
138 if ((mil = sp->shp_item[I_MILIT]) > 0)
141 for (i = 0; NULL != (lp = getlandp(i)); i++) {
142 if (!lp->lnd_own || lp->lnd_own != n)
144 if ((mil = lp->lnd_item[I_MILIT]) > 0)
147 mil_pay = totalmil * etu * money_mil;
152 bank_income(struct sctstr *sp, int etu)
154 return (int)(sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100);