update: Drop unnecessary "not simulation" guards

Since changing *sp is safe now, we can update sp->sct_work,
sp->sct_loyal, sp->sct-che unconditionally in do_feed(), and likewise
sp->sct_item and sp's resource in produce().

Output of budget in smoke test and update test changes slightly,
because it now executes more code, and the PRNs this consumes affect
random rounding.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-03 23:09:56 +02:00
parent 157892b449
commit 1c0ff91e62
3 changed files with 20 additions and 23 deletions

View file

@ -91,8 +91,8 @@ do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
if (starved > 25) if (starved > 25)
nreport(sp->sct_own, N_DIE_FAMINE, 0, 1); nreport(sp->sct_own, N_DIE_FAMINE, 0, 1);
} }
sp->sct_loyal += roll(8) + 1;
} }
sp->sct_loyal += roll(8) + 1;
sctwork = 0; sctwork = 0;
} else { } else {
sctwork = sp->sct_work; sctwork = sp->sct_work;
@ -109,8 +109,7 @@ do_feed(struct sctstr *sp, struct natstr *np, int *workp, int etu)
maxworkers)); maxworkers));
/* FIXME restores work charged for growfood() */ /* FIXME restores work charged for growfood() */
/* age che */ /* age che */
if (!player->simulation) sp->sct_che = age_people(sp->sct_che, etu);
sp->sct_che = age_people(sp->sct_che, etu);
} }
if (manna) if (manna)
/* Take away food we conjured up */ /* Take away food we conjured up */

View file

@ -138,19 +138,17 @@ produce(struct natstr *np, struct sctstr *sp, int work,
/* /*
* Reset produced amount by commodity production ratio * Reset produced amount by commodity production ratio
*/ */
if (!player->simulation) { materials_charge(product, sp->sct_item, material_consume);
materials_charge(product, sp->sct_item, material_consume); if (resource && product->p_nrdep != 0) {
if (resource && product->p_nrdep != 0) { /*
/* * lower natural resource in sector depending on
* lower natural resource in sector depending on * amount produced
* amount produced */
*/ val = *resource - roundavg(product->p_nrdep *
val = *resource - roundavg(product->p_nrdep * material_consume / 100.0);
material_consume / 100.0); if (val < 0)
if (val < 0) val = 0;
val = 0; *resource = val;
*resource = val;
}
} }
*amount = actual; *amount = actual;
*cost = product->p_cost * material_consume; *cost = product->p_cost * material_consume;

View file

@ -23,9 +23,9 @@
Play#1 input budget Play#1 input budget
Play#1 command budget Play#1 command budget
Play#1 output Play#1 1 Sector Type Production Cost Play#1 output Play#1 1 Sector Type Production Cost
Play#1 output Play#1 1 uranium mine 318 rad 740 Play#1 output Play#1 1 uranium mine 317 rad 740
Play#1 output Play#1 1 park 78 happy 702 Play#1 output Play#1 1 park 78 happy 702
Play#1 output Play#1 1 defense plant 13 guns 420 Play#1 output Play#1 1 defense plant 12 guns 420
Play#1 output Play#1 1 shell industry 156 shells 528 Play#1 output Play#1 1 shell industry 156 shells 528
Play#1 output Play#1 1 technical center 5 tech 2700 Play#1 output Play#1 1 technical center 5 tech 2700
Play#1 output Play#1 1 research lab 6 medical 900 Play#1 output Play#1 1 research lab 6 medical 900
@ -33,21 +33,21 @@
Play#1 output Play#1 1 bank 41 bars 410 Play#1 output Play#1 1 bank 41 bars 410
Play#1 output Play#1 1 refinery 2581 petrol 291 Play#1 output Play#1 1 refinery 2581 petrol 291
Play#1 output Play#1 1 enlistment center 75 mil 225 Play#1 output Play#1 1 enlistment center 75 mil 225
Play#1 output Play#1 1 Ship building 12 ships 1531 Play#1 output Play#1 1 Ship building 13 ships 1536
Play#1 output Play#1 1 Ship maintenance 32 ships 2202 Play#1 output Play#1 1 Ship maintenance 32 ships 2202
Play#1 output Play#1 1 Plane building 13 planes 1932 Play#1 output Play#1 1 Plane building 13 planes 1936
Play#1 output Play#1 1 Plane maintenance 20 planes 1004 Play#1 output Play#1 1 Plane maintenance 20 planes 1004
Play#1 output Play#1 1 Unit building 6 units 2300 Play#1 output Play#1 1 Unit building 6 units 2300
Play#1 output Play#1 1 Unit maintenance 16 units 510 Play#1 output Play#1 1 Unit maintenance 16 units 510
Play#1 output Play#1 1 Sector building 40 sectors 773 Play#1 output Play#1 1 Sector building 40 sectors 773
Play#1 output Play#1 1 Sector maintenance 2 sectors 120 Play#1 output Play#1 1 Sector maintenance 2 sectors 120
Play#1 output Play#1 1 Military payroll 1155 mil, 0 res 5777 Play#1 output Play#1 1 Military payroll 1155 mil, 0 res 5777
Play#1 output Play#1 1 Total expenses.....................................................24667 Play#1 output Play#1 1 Total expenses.....................................................24676
Play#1 output Play#1 1 Income from taxes 26911 civs, 9007 uws +12625 Play#1 output Play#1 1 Income from taxes 26911 civs, 9007 uws +12625
Play#1 output Play#1 1 Total income......................................................+12625 Play#1 output Play#1 1 Total income......................................................+12625
Play#1 output Play#1 1 Balance forward 25000 Play#1 output Play#1 1 Balance forward 25000
Play#1 output Play#1 1 Estimated delta -12042 Play#1 output Play#1 1 Estimated delta -12051
Play#1 output Play#1 1 Estimated new treasury.............................................12958 Play#1 output Play#1 1 Estimated new treasury.............................................12949
Play#1 output Play#1 6 0 99 Play#1 output Play#1 6 0 99
Play#1 input neweff * ?newd#- Play#1 input neweff * ?newd#-
Play#1 command neweff Play#1 command neweff