put the block stock where the blocks are
The global building block stock lived on Simulation while being factory data through and through: placement spends it, deconstruction refunds it, and blocks delivered to the HQ by belt add to it. Every system that credited it therefore held a std::function back into Simulation to do so -- BuildingSystem and DeconstructionSystem each carried one, and the arena and three test fixtures had to pass a stub. It moves into FactoryState, seeded by makeFactoryState from world.starting_building_blocks, and both callbacks are gone: the HQ's belt intake and the deconstruction refund now credit the state they are already holding. BuildingSystem::deconstruct stops returning a refund for its caller to remember to credit. It had grown asymmetric -- the queued path credits itself through DeconstructionSystem while the instant path handed a number back -- so it now credits the site's full cost directly and returns void. Checksum order is untouched: Simulation still folds the stock at exactly the point it always did, reading it from the state. The arena no longer discards refunds into a no-op sink; nothing there reads the stock either way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -57,15 +57,26 @@ struct FactoryState
|
||||
// derived from config and Simulation's expansion count, which is folded already.
|
||||
// Seeded from config by BuildingSystem's constructor.
|
||||
int asteroidWidth_tiles = 0;
|
||||
|
||||
// The global building block stock (REQ-HQ-STARTING-BLOCKS, REQ-HQ-BELT-INPUT):
|
||||
// what placement spends, what deconstruction refunds, and what blocks delivered to
|
||||
// the HQ add to. Factory data, so it lives with the factory rather than being
|
||||
// reached through a callback by every system that credits it.
|
||||
//
|
||||
// Folded into the checksum by Simulation, in the place it has always occupied
|
||||
// (docs/replay_design.md).
|
||||
int buildingBlocksStock = 0;
|
||||
};
|
||||
|
||||
// A fresh factory for a new run: nothing built, and the asteroid bound seeded from
|
||||
// config. Every owner of a FactoryState creates it this way — the bound has no
|
||||
// sensible default without the config, so a default-constructed state would refuse
|
||||
// every placement on the asteroid.
|
||||
// A fresh factory for a new run: nothing built, the asteroid bound and the starting
|
||||
// block stock seeded from config. Every owner of a FactoryState creates it this way —
|
||||
// the bound has no sensible default without the config, so a default-constructed state
|
||||
// would refuse every placement on the asteroid, and the player would start with nothing
|
||||
// to build from.
|
||||
inline FactoryState makeFactoryState(const GameConfig& config)
|
||||
{
|
||||
FactoryState state;
|
||||
state.asteroidWidth_tiles = config.world.regions.asteroidWidth_tiles;
|
||||
state.asteroidWidth_tiles = config.world.regions.asteroidWidth_tiles;
|
||||
state.buildingBlocksStock = config.world.startingBuildingBlocks;
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user