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. isClearToAdvance never returns true and DockUpdate::update never finds a position to promote to m_activeDocker, and the flags are only set by onApproachReached, which fires from AIDockApproachState::onExit and will not fire again for a unit that is already waiting.

Now the unpacked value is written back into the vector after the xfer, so the reached flags survive a save and load and the queue keeps running. 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, which is the state that stalls the queue; after the fix the flags round-trip unchanged.

Todo:

  • Verify on MD_CHI01: save on the frame a docker reaches its approach position, load, confirm the reached flags are restored
  • 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.

Units queued at a dock never dock again after loading a save

1 participant