Skip to content

Announce only accepted goods, and leave mixed mode fully on reload - #8

Merged
kramsey458 merged 1 commit into
mainfrom
claude/reviewer-follow-ups
Sep 22, 2026
Merged

kramsey458 merged 1 commit into
mainfrom
claude/reviewer-follow-ups

Conversation

@kramsey458

Copy link
Copy Markdown
Collaborator

Summary

This fixes two of the three follow-ups the v1.1.0 reviewers flagged. The third belongs to the BeaverBuddies forks (see below).

  • Unknown good in a saved allocation (from Supply mode skips goods with no unreserved stock (MS5); explain blocked Apply (MS6) #5's review). Leaving mixed mode announced every allocated good. A saved allocation can name a good the game no longer knows, for example after a goods mod is removed. Announcing that good goes Inventory.OnDisallowedGoodsChanged → InventoryChanged → InventoryRegistry.UpdateRegistries → _inventoriesWithCapacity[good], which throws KeyNotFoundException (confirmed by decompiling 1.1.2.4). Now only goods the building accepts are announced. The game already limits any other good to 0 (Inventory.LimitedAmount takes the minimum with the inventory's own allowed goods), so nothing else needs to hear about it.
  • Load path (from Copy Settings: delivery guard when leaving mixed mode, replay checks, optional null-source keep #3's review). A mixed building reloaded without an allocation (the map editor's undo) cleared its shares without announcing its goods, so the game's room caches kept the old limits. A redraw already queued then met null shares and Fail()ed, which disabled mixed visuals for that building for the rest of the session.
    • Load now announces the goods of the old and new allocation whenever a mixed building is reloaded, the same way Deactivate does. That also returns its visuals to the native pile through MixedAllocationVisualPatch.
    • MixedContentsRenderer.Render now releases the sections instead of failing when the building is no longer mixed.
    • A normal save load still announces nothing, because a building is never mixed before its own load.

Other unknown-good paths checked: Apply announces only Inventory.InputGoods; Obtain filters on HasUnreservedCapacity, which checks Takes first; Supply skips goods with no stock (#5). The renderer's GetGood on an unknown good still falls back to native visuals with a warning. That fallback is visual-only and unchanged here.

Tests

visual-tests/AnnouncementTests.cs runs the built mod's StorageState against the game's own SingleGoodAllower and Inventory, created without Unity. It records every good announced through DisallowedGoodsChanged and checks five cases: leave, reload without an allocation, reload with another allocation, a normal save load, and a load without an allocation. Every announcement must run as the mod's own change (InternalChange).

  • Fails on main: Leaving mixed mode announces the allocated goods the building accepts, and no good the game does not know; announced [Log, Gone], expected [Log].
  • Mutation (Load without the announcement): A mixed building reloaded without an allocation announces its formerly allocated goods, as Deactivate does; announced [], expected [Log].
  • Passes: full build.ps1 green with 0 warnings; 19,115 allocation assertions; 4/4 loading modes; ReplayChecks scans 61 mod methods; 76/76 site checks.

The renderer guard needs Unity, so it is only checked in game.

Co-op impact

Simulation changes only on paths that used to throw (unknown good) or that are reached only through the map editor's undo. The wire and save formats are unchanged, and the LateGamePerformance contract (LimitPatch, SavePatch) is untouched.

Proposed CHANGELOG lines

  • A saved allocation that still names a good from a removed mod no longer throws when the building leaves mixed storage.
  • In the map editor, undo that removes a building's allocation now updates the game's hauling caches and the building's visuals right away.

Needs in-game testing

  • Hand-edit a save so a warehouse's MixedStorage.Allocation is 1|Berries=5000;NoSuchGood=5000. Load it, then Copy Settings from a normal Berries warehouse onto it. Expected: no exception in Player.log; the building becomes a normal Berries warehouse.
  • In the map editor, Apply an allocation to a warehouse, then undo. Expected: the split pile disappears at once and no Mixed visuals unavailable warning appears.

Not in this PR: BeaverBuddies prefix order (from #7's review)

The forks' event-recording prefixes (ReplayEvent.DoPrefix and similar, about 109 bool prefixes in the Stability Fork) run at default priority, so today they run before MixedStorage's Priority.Last prefixes. Changing that needs changes in both BeaverBuddies repos, so it is left for a separate decision.

🤖 Generated with Claude Code

Two follow-ups from the v1.1.0 reviews.

A saved allocation can name a good the game no longer knows, for example
after a goods mod is removed. Leaving mixed mode announced every allocated
good, and announcing an unknown good reaches
InventoryRegistry._inventoriesWithCapacity[good], which throws. Now only
goods the building accepts are announced; the game limits any other good
to 0 whatever the allocation says (Inventory.LimitedAmount), so nothing
else needs to hear about it.

A mixed building reloaded without an allocation (the map editor's undo)
cleared its shares without announcing its goods, so the game's caches kept
the old limits. A redraw already queued then met null shares and disabled
mixed visuals for that building for the session. Load now announces the
goods of the old and new allocation when a mixed building is reloaded,
like Deactivate. That sends its visuals back to the native pile. A queued
redraw that finds no allocation now releases the sections instead of
failing. A normal save load still announces nothing: a building is never
mixed before its own load.

visual-tests/AnnouncementTests.cs runs StorageState against the game's own
SingleGoodAllower and Inventory, created without Unity, and records every
announced good. It fails on main with "announced [Log, Gone], expected
[Log]", and fails on a Load that does not announce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kramsey458
kramsey458 merged commit d740662 into main Sep 22, 2026
1 check passed
kramsey458 added a commit that referenced this pull request Sep 22, 2026
Bump the version in Directory.Build.props and the manifest to 1.1.1, point
the README at the v1.1.1 download, and list PR #8 in the changelog: a saved
allocation naming a removed good no longer throws when the building leaves
mixed storage, and the map editor's undo that removes an allocation updates
the game's caches and the building's visuals. README, developer notes and
the website say the changes have not been played in game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant