update: Don't use materials and work destroyed by che or plague
Update code shared with budget uses the bp map instead of the sector, so that budget can track materials and work available in sectors for ship, plane and land unit building without updating the sector file. Unfortunately, the bp map can become stale during the update. prepare_sects() doesn't update the bp map for sea sectors, unlike budget's calc_all(). Instead, we rely on calloc()'s initialization. Works, but is a bit unclean. prepare_sects() updates the bp map after fallout, but neglects to update it for any of the later sector updates (steps 1b to 1f in info Update-sequence). Che can destroy materials and available work, and the plague can kill military. The bp map stays out of date until produce_sect() updates it again. Since we deal with sector production and countries in increasing order of country number, foreign ships, planes and land units owned by countries with lesser numbers get built before their sector produces. Building uses the stale bp map then, and can use materials and available work destroyed by che or the plague. The update test demonstrates the former case. For stopped sectors or when the owner is broke, produce_sect() updates only materials in the bp map, not available work. Nothing builds in a stopped sector, but allies may build in your sectors even when you're broke. They can use available work destroyed by che then. Screwed up when Empire 3 made the update code work for budget. Note that budget bypasses the flawed code: it prepares its bp map itself instead of calling prepare_sects(). Rather than fixing prepare_sects(), use a null bp map for the update: writes become no-ops, and reads read from the underlying sector. Not only does this remove the possibility of the bp map going stale during the update, it saves a bit of memory, too. calloc()'s initialization is now dead. Switch to malloc(). Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
2bdb601833
commit
66edd2baca
8 changed files with 29 additions and 29 deletions
|
@ -63,7 +63,6 @@ read 0
|
|||
| 95 +50% own airfield
|
||||
| 97 +50% own airfield
|
||||
| 100 allied airfield where plague killed off mil
|
||||
| BUG: builds anyway
|
||||
| land unit building
|
||||
| 60 stopped
|
||||
| 61 friendly hq
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue