2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2016, 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
33 * Markus Armbruster, 2016
45 #include "prototypes.h"
50 prepare_sects(int etu)
56 /* Process all the fallout. */
58 if (!player->simulation) {
59 /* First, we determine which sectors to process fallout in */
60 for (n = 0; NULL != (sp = getsectid(n)); n++)
61 sp->sct_updated = sp->sct_fallout != 0;
62 /* Next, we process the fallout there */
63 for (n = 0; NULL != (sp = getsectid(n)); n++)
66 /* Next, we spread the fallout */
67 for (n = 0; NULL != (sp = getsectid(n)); n++)
69 spread_fallout(sp, etu);
70 /* Next, we decay the fallout */
71 for (n = 0; NULL != (sp = getsectid(n)); n++)
73 decay_fallout(sp, etu);
76 for (n = 0; NULL != (sp = getsectid(n)); n++) {
79 if (sp->sct_type == SCT_WATER)
81 if (getnatp(sp->sct_own)->nat_stat == STAT_SANCT)
85 * When running the test suite, reseed PRNG for each sector
86 * with its UID, to keep results stable even when the number
87 * of PRNs consumed changes.
89 if (running_test_suite)
90 seed_prng(sp->sct_uid);
96 if (sp->sct_type == SCT_BANK)
99 for (n = 0; NULL != (np = getnatp(n)); n++) {
100 upd_slmilcosts(etu, np->nat_cnum);
101 pay_reserve(np, etu);
106 tax(struct sctstr *sp, int etu)
108 struct budget *budget = &nat_budget[sp->sct_own];
109 double civ_tax, uw_tax, mil_pay;
111 civ_tax = sp->sct_item[I_CIVIL] * etu * money_civ * sp->sct_effic / 100;
112 if (sp->sct_own == sp->sct_oldown)
113 budget->oldowned_civs += sp->sct_item[I_CIVIL];
115 civ_tax /= 4; /* captured civs pay less */
116 budget->civ.count += sp->sct_item[I_CIVIL];
117 budget->civ.money += civ_tax;
118 budget->money += civ_tax;
120 uw_tax = sp->sct_item[I_UW] * etu * money_uw * sp->sct_effic / 100;
121 budget->uw.count += sp->sct_item[I_UW];
122 budget->uw.money += uw_tax;
123 budget->money += uw_tax;
125 mil_pay = sp->sct_item[I_MILIT] * etu * money_mil;
126 budget->mil.count += sp->sct_item[I_MILIT];
127 budget->mil.money += mil_pay;
128 budget->money += mil_pay;
132 upd_slmilcosts(int etu, natid n)
141 for (i = 0; (sp = getshipp(i)); i++) {
142 if (!sp->shp_own || sp->shp_own != n)
144 mil += sp->shp_item[I_MILIT];
147 for (i = 0; (lp = getlandp(i)); i++) {
148 if (!lp->lnd_own || lp->lnd_own != n)
150 mil += lp->lnd_item[I_MILIT];
153 mil_pay = mil * etu * money_mil;
154 nat_budget[n].mil.count += mil;
155 nat_budget[n].mil.money += mil_pay;
156 nat_budget[n].money += mil_pay;
160 bank_income(struct sctstr *sp, int etu)
164 income = sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100;
165 nat_budget[sp->sct_own].bars.count += sp->sct_item[I_BAR];
166 nat_budget[sp->sct_own].bars.money += income;
167 nat_budget[sp->sct_own].money += income;
171 pay_reserve(struct natstr *np, int etu)
173 double pay = np->nat_reserve * money_res * etu;
175 nat_budget[np->nat_cnum].mil.money += pay;
176 nat_budget[np->nat_cnum].money += pay;