Skip to content

Reimplement stockpile footprint cleanup (native byte match) - #217

Open
Krarilotus wants to merge 2 commits into
sourcehold:mainfrom
Krarilotus:reimplement/stockpile-footprint-cleanup
Open

Reimplement stockpile footprint cleanup (native byte match)#217
Krarilotus wants to merge 2 commits into
sourcehold:mainfrom
Krarilotus:reimplement/stockpile-footprint-cleanup

Conversation

@Krarilotus

@KrarilotusKrarilotus commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

TL;DR: This recreates the original game's cleanup when a stockpile is removed, keeping its behavior unchanged. The compiled function matches the original machine code, and all 32 automated comparison tests passed.

Reimplements TileMapState::clearStockpileFootprintTiles at 0x004FAF70, preserving native stockpile demolition behavior: clear the nine walkable tiles' 0x102 logic bits, restore default height, honor each referenced building's noRubble branch, and clear AlphaGFXLayer after reading that reference.

Uses existing global resolvers and the receiver's map layers. Generated headers, resolver flags and default source lists are unchanged. The source can be selected with the existing local-development source list workflow.

Validation:

  • VS2005 SP1 (14.00.50727.762), x86 DLL-mode /O2 /Ob1 compilation passes.
  • All 325 function bytes match original Crusader 1.41 after resolving eight global-symbol relocations.
  • The included verification script checks the executable hash and exact machine code, then runs 32 randomized full-TileMapState differential emulation cases. Both rubble branches, zero/nonzero building indices, relocated receivers, stack cleanup and callee-saved registers pass.
  • Fresh full RelWithDebInfo OpenSHC.dll build passes. Linked reccmp reports 100% at 0x004FAF70; the soft status entry now records that result. A current Windows SDK manifest tool replaces the crashing legacy mt.exe locally. No DLL deployment or live gameplay test was performed.

The wiki describes vanilla footprint cleanup and related placement behavior. Build-process instructions and the extension-specific investigation have been removed from that page.

Sign up for freeto 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

@Krarilotus