Canonicalize custody outcomes and enforce operation-specific work phases

This commit is contained in:
faumaray committed 2026-12-02 23:34:58 +03:00
1 parent 67fba6e3df
commit 120db6cfa0
5 files changed
+247 -9

No files matched your search

+7 -1
View File
@@ -1711,7 +1711,13 @@ void World::finish_production(Agent& agent) {
for (const auto& stack : original_store.items) if (stack.type == material.type) consumed_id = stack.id;
for (const auto& store : stores) if (store.id == material.storage_id) remaining = store.item_count(material.type);
}
receipt->result.effects[receipt->result.effect_count++] = {owner, consumed_id, material.type, remaining};
// Several source lines can have merged into one physical site stack.
// Record its final outcome once, retaining the first material order.
const auto end = receipt->result.effects.begin() + receipt->result.effect_count;
const bool recorded = std::any_of(receipt->result.effects.begin(), end, [&](const auto& effect) {
return effect.owner == owner && effect.stack == consumed_id && effect.item == material.type;
});
if (!recorded) receipt->result.effects[receipt->result.effect_count++] = {owner, consumed_id, material.type, remaining};
}
if (output_id) {
receipt->result.effects[receipt->result.effect_count++] = {carpentry ? StockOwner{OwnerKind::Resident, agent.id} :