update: Drop redundant bp map updates and functions
produce_sect() updates the bp map several times. This is wasteful: since only ship, plane and land unit building reads it, bp map writes before the last one are never read. Update it just once for every sector. The update for sectors that are stopped or whose owner is broke is the only remaining use of bp_put_items(). Since available work must still be unchanged there, we can replace it by bp_set_from_sect(). bp_get_item(), bp_put_item(), bp_get_items(), bp_get_avail() and bp_put_avail() are now unused. Drop them. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
199b1498c8
commit
5b0fd1171d
3 changed files with 8 additions and 64 deletions
|
@ -270,10 +270,11 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2])
|
|||
}
|
||||
|
||||
work = do_feed(sp, np, etu, 0);
|
||||
bp_put_items(bp, sp);
|
||||
|
||||
if (sp->sct_off || np->nat_money < 0)
|
||||
if (sp->sct_off || np->nat_money < 0) {
|
||||
bp_set_from_sect(bp, sp);
|
||||
continue;
|
||||
}
|
||||
|
||||
sp->sct_avail = work;
|
||||
amount = 0;
|
||||
|
@ -290,7 +291,6 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2])
|
|||
if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) &&
|
||||
np->nat_money >= 0) {
|
||||
cost = buildeff(sp);
|
||||
bp_put_items(bp, sp);
|
||||
p_sect[SCT_EFFIC][0]++;
|
||||
p_sect[SCT_EFFIC][1] += cost;
|
||||
if (!player->simulation)
|
||||
|
@ -303,7 +303,6 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2])
|
|||
p_sect[sp->sct_type][1] += ecost;
|
||||
if (!player->simulation)
|
||||
np->nat_money -= ecost;
|
||||
bp_put_items(bp, sp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -313,10 +312,9 @@ produce_sect(struct natstr *np, int etu, struct bp *bp, int p_sect[][2])
|
|||
if (sp->sct_effic >= 60) {
|
||||
if (np->nat_money >= 0 && dchr[sp->sct_type].d_prd >= 0)
|
||||
amount = produce(np, sp, &pcost);
|
||||
bp_put_items(bp, sp);
|
||||
}
|
||||
|
||||
bp_put_avail(bp, sp, sp->sct_avail);
|
||||
bp_set_from_sect(bp, sp);
|
||||
p_sect[sp->sct_type][0] += amount;
|
||||
p_sect[sp->sct_type][1] += pcost;
|
||||
if (!player->simulation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue