From 8c65fbc2be42cae42c48272f4be07d61d125d8a2 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 14 Jan 2007 10:07:37 +0000 Subject: [PATCH] (produce_sect): Use bp_put_items() after calls that may update vec[]. This is more robust than using bp_put_item() for those elements of vec[] that the call may change. The old code missed some changes: upd_buildeff() changing population when tearing down a big city, enlist(), and produce(). The first two should have been harmless, the last one made budget mispredict repairs when required materials were produced in the same update. --- src/lib/update/sect.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/update/sect.c b/src/lib/update/sect.c index 810cd544..05bbec75 100644 --- a/src/lib/update/sect.c +++ b/src/lib/update/sect.c @@ -312,9 +312,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) bp_enable_cachepath(); sctwork = do_feed(sp, np, vec, &work, etu); - bp_put_item(bp, sp, I_CIVIL, vec[I_CIVIL]); - bp_put_item(bp, sp, I_UW, vec[I_UW]); - bp_put_item(bp, sp, I_MILIT, vec[I_MILIT]); + bp_put_items(bp, sp, vec); bp_disable_cachepath(); bp_clear_cachepath(); @@ -332,8 +330,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) np->nat_money > 0) { neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork, &cost); - bp_put_item(bp, sp, I_LCM, vec[I_LCM]); - bp_put_item(bp, sp, I_HCM, vec[I_HCM]); + bp_put_items(bp, sp, vec); p_sect[SCT_EFFIC][0]++; p_sect[SCT_EFFIC][1] += cost; if (!player->simulation) { @@ -349,6 +346,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) p_sect[desig][1] += ecost; if (!player->simulation) np->nat_money -= ecost; + bp_put_items(bp, sp, vec); } /* @@ -359,6 +357,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2]) if (np->nat_money > 0 && dchr[desig].d_prd >= 0) work -= produce(np, sp, vec, work, desig, neweff, &pcost, &amount); + bp_put_items(bp, sp, vec); } bp_put_avail(bp, sp, work);