update: Fix income and level use after revolt or revert to deity
prepare_sects() caches the sector owner's getnatp() across guerrilla(), do_plague() and populace(). This is wrong, because the owner may change. The mistake can be traced back all the way back to BSD Empire 1.1. If the sector revolts or reverts to deity, the ex-owner still receives taxes and bank interest. The update test demonstrates this bug. If the sector revolts, we use the ex-owner's instead of the owner's tech and research for plague, and we use the ex-owners happiness and required happiness instead of the owner's for loyalty update and civil unrest. Change do_plague() and populace() to call getnatp() themselves. Call it in prepare_sects() only after we're done messing with the sector owner. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
1e8d290e57
commit
fdde783278
7 changed files with 22 additions and 22 deletions
|
@ -30,6 +30,7 @@
|
|||
* Dave Pare, 1986
|
||||
* Thomas Ruschak, 1992
|
||||
* Steve McClure, 1997
|
||||
* Markus Armbruster, 2016
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -76,6 +77,8 @@ prepare_sects(int etu, struct bp *bp)
|
|||
|
||||
if (sp->sct_type == SCT_WATER)
|
||||
continue;
|
||||
if (getnatp(sp->sct_own)->nat_stat == STAT_SANCT)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* When running the test suite, reseed PRNG for each sector
|
||||
|
@ -86,17 +89,14 @@ prepare_sects(int etu, struct bp *bp)
|
|||
seed_prng(sp->sct_uid);
|
||||
|
||||
bp_set_from_sect(bp, sp);
|
||||
guerrilla(sp);
|
||||
do_plague(sp, etu);
|
||||
populace(sp, etu);
|
||||
np = getnatp(sp->sct_own);
|
||||
|
||||
if (np->nat_stat != STAT_SANCT) {
|
||||
guerrilla(sp);
|
||||
do_plague(sp, np, etu);
|
||||
populace(np, sp, etu);
|
||||
tax(sp, etu, &pops[sp->sct_own], &civ_tax, &uw_tax, &mil_pay);
|
||||
np->nat_money += civ_tax + uw_tax + mil_pay;
|
||||
if (sp->sct_type == SCT_BANK)
|
||||
np->nat_money += bank_income(sp, etu);
|
||||
}
|
||||
tax(sp, etu, &pops[sp->sct_own], &civ_tax, &uw_tax, &mil_pay);
|
||||
np->nat_money += civ_tax + uw_tax + mil_pay;
|
||||
if (sp->sct_type == SCT_BANK)
|
||||
np->nat_money += bank_income(sp, etu);
|
||||
}
|
||||
for (n = 0; NULL != (np = getnatp(n)); n++) {
|
||||
np->nat_money += upd_slmilcosts(np->nat_cnum, etu);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue