budget: Fix treasury tracking
The update simply updates each nation's nat_money as it goes. Works. Except it doesn't update when it runs on behalf of budget. But it still checks nat_money to determine whether the nation is solvent. These checks are all broken. Leads to massive mispredictions when you'd go broke or solvent during a real update. Track money unconditionally in nat_budget[].money. Delay update of nat_money until prod_nat(). Replace separate money[] by new nat_budget[].start_money. Closes bug#235. Remaining difference between budget and update in the update test: * #1: budget mispredicts plane #100 gets built (to be fixed) * #2: budget shows ship, plane and land unit maintenance when broke, but update damages them instead (correct) * #2: sector -14,0 converts, quadrupling its taxes (correct) * #4 & #5: bank with dust and bars taken over by che (correct) * #4: plague deaths (correct) Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
058268595f
commit
10789a0365
14 changed files with 78 additions and 99 deletions
|
@ -151,9 +151,10 @@ calc_all(void)
|
|||
int etu = etu_per_update;
|
||||
|
||||
memset(nat_budget, 0, sizeof(nat_budget));
|
||||
|
||||
np = getnatp(player->cnum);
|
||||
budget->start_money = budget->money = np->nat_money;
|
||||
bp = bp_alloc();
|
||||
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||
bp_set_from_sect(bp, sp);
|
||||
if (sp->sct_own == player->cnum) {
|
||||
|
@ -180,6 +181,9 @@ calc_all(void)
|
|||
prod_plane(etu, player->cnum, bp, 1);
|
||||
prod_land(etu, player->cnum, bp, 1);
|
||||
|
||||
if (CANT_HAPPEN(np->nat_money != budget->start_money))
|
||||
np->nat_money = budget->start_money;
|
||||
|
||||
free(bp);
|
||||
return budget;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue