Skip to content

bugfix(saveload): Restore dock approach position reached flags on load - #3117

Draft
bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/dockupdate-approach-position-reached
Draft

bugfix(saveload): Restore dock approach position reached flags on load#3117
bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/dockupdate-approach-position-reached

Conversation

@bobtista

@bobtista bobtista commented Aug 12, 2026

Copy link
Copy Markdown

DockUpdate::xfer reads each m_approachPositionReached entry into a local Bool and passes its address to xferBool. BoolVector is std::vector<bool>, whose operator[] returns a proxy rather than a reference, so on load the value is written into the local and discarded and the vector keeps the false entries left by resize(). m_approachPositionOwners is restored correctly, so after loading the dock still holds its approach slots while every reached flag reads false.

Now the unpacked value is written back into the vector after the xfer, so the reached flags survive a save and load. This does not change the save layout, so existing saves still load.

Measured on MD_CHI01 by saving on the frame a docker reaches its approach position and loading the save back, logging the dock module's state on both sides of the xfer. reached is the m_approachPositionReached bit vector and owners the matching m_approachPositionOwners entries, for the supply centre holding docker 602:

reached owners
saved 1000000000 602,0,0,0,0,0,0,0,0,0
after load, before 0000000000 602,0,0,0,0,0,0,0,0,0
after load, after 1000000000 602,0,0,0,0,0,0,0,0,0

The docker keeps its reserved slot across the load either way; before the fix its reached flag is lost, and after the fix the flags round-trip unchanged.

On the observed consequence: the queue recovers on its own. onApproachReached fires from AIDockApproachState::onExit, and a restored docker re-enters that state and re-sets its own flag, so the dock resumes without the fix. Loading a skirmish save holding four supply centres, with queues up to four deep and every reached flag cleared, the first re-approach landed 30 logic frames (about one second) after the load and the docks then ran normally for the rest of the run. The same held for the single-docker case on MD_CHI01. So this is a state round-trip fix — the loaded game briefly disagrees with the game that was saved — rather than a fix for a stalled queue.

Todo:

  • Verify on MD_CHI01: save on the frame a docker reaches its approach position, load, confirm the reached flags are restored
  • Verify a multi-docker queue: load a save with queues several deep and confirm the flags are restored rather than rebuilt by re-approach
  • Replicate to Generals

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.

Dock approach reached flags are not restored when loading a save

1 participant