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>
9 lines
210 B
Text
9 lines
210 B
Text
budget
|
|
| BUG: fb#100 won't actually starve
|
|
| Note: f1#100 not actually built (plague kills off mil)
|
|
| TODO is it accurate?
|
|
neweff * ?newd#-
|
|
production *
|
|
| TODO is it accurate?
|
|
starvation
|
|
| TODO is it accurate?
|