update: Use a scratch sctstr for unit repair simulation
If player->simulation, shiprepair(), planerepair(), landrepair() must use the bp map, and must not change game state. Copy the sector to a scratch buffer, update it from the bp map, work on the sector normally, then write back to the bp map. This is simpler and safer. Since get_materials() loses its connection to the bp map, move its declaration out of budg.h. While there, drop an ancient debugging logerror() from landrepair(). Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
66edd2baca
commit
199b1498c8
7 changed files with 56 additions and 52 deletions
|
@ -132,6 +132,21 @@ bp_set_from_sect(struct bp *bp, struct sctstr *sp)
|
|||
bp_put_avail(bp, sp, sp->sct_avail);
|
||||
}
|
||||
|
||||
/* Copy the values tracked in @bp for sector @sp back to @sp. */
|
||||
void
|
||||
bp_to_sect(struct bp *bp, struct sctstr *sp)
|
||||
{
|
||||
i_type i;
|
||||
enum bp_item_idx idx;
|
||||
|
||||
for (i = I_NONE + 1; i <= I_MAX; i++) {
|
||||
idx = bud_key[i];
|
||||
if (idx >= 0)
|
||||
sp->sct_item[i] = bp[sp->sct_uid].bp_item[idx];
|
||||
}
|
||||
sp->sct_avail = bp[sp->sct_uid].bp_avail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a new bp map.
|
||||
* Caller should pass it to free() when done with it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue