Skip to content

Reimpl/tile map state - #242

Draft
gynt wants to merge 276 commits into
mainfrom
reimpl/TileMapState
Draft

gynt wants to merge 276 commits into
mainfrom
reimpl/TileMapState

Conversation

@gynt

@gynt gynt commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

gynt added 30 commits September 28, 2026 00:49
gynt and others added 7 commits October 6, 2026 21:14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Their sources are unchanged; the percentages moved because caller and callee
are now built with /GL (see the compiler-flags-gl.txt commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	AGENTS.md
#	IMPLEMENTATION_CHEAT_SHEET.md
#	cmake/compiler-flags-gl.txt
#	src/OpenSHC/Map/Buildings/Building.hpp
#	src/OpenSHC/Map/TerrainDefinedData.hpp
#	src/OpenSHC/Map/TileMapState/clearMoatData.cpp
#	src/OpenSHC/Map/TileMapState/forceFullTileMapRedraw.cpp
#	src/OpenSHC/Map/TileMapState/getUnownedMoatCount.cpp
#	src/OpenSHC/Map/TileMapState/processDamageToBuildingThunk.cpp
#	src/OpenSHC/Map/TileMapState/processEntityDamageToBuildingCollateralThunk.cpp
#	src/OpenSHC/Map/TileMapState/processMapOrientationChange.cpp
#	src/OpenSHC/Map/TileMapState/recountTotalOwnedMoats.cpp
#	src/OpenSHC/Map/TileMapState/resetMoatArray.cpp
#	src/OpenSHC/Map/TileMapState/resetPitchDitchArray.cpp
#	src/OpenSHC/Map/TileMapState/setMapRotation.cpp
#	src/OpenSHC/Map/TileMapState/setMoatOwnerForAllMatching.cpp
#	src/OpenSHC/Map/TileMapState/setMoatVisualStateAtTile.cpp
#	src/OpenSHC/Map/TileMapState/spreadBrazierPlacementAlgorithm.cpp
#	src/OpenSHC/Map/TileMapState/spreadFlagPlacementAlgorithm.cpp
#	src/OpenSHC/Map/TileMapState/toggleFlatView.cpp
#	src/OpenSHC/Map/TileMapState/updateBuildingPlacementRotationPreview.cpp
#	src/OpenSHC/Map/TileMapState/updateMoatCountdownTimers.cpp
#	tools/mcp/openshcmcp.py
#	tools/reimplementation-helper/batch/README.md
#	tools/reimplementation-helper/batch/common.py
#	tools/reimplementation-helper/batch/declare_at_use.py
#	tools/reimplementation-helper/batch/diff_jcc.py
#	tools/reimplementation-helper/batch/quick_diff.py
…main

This branch was 141 commits behind main and did not compile at all against
main's regenerated headers, so it had never been measured. 179 of its 186
TileMapState sources now build, link and score.

Merging main conflicted on 17 TileMapState sources that main has since gained
independently, plus the docs, tools and two headers; all of those took main's
side. The branch still contributes 169 sources main does not have, so it is
not superseded.

TerrainDefinedData.hpp is the one file where taking main's side was wrong, and
it is resolved by hand instead. Main guesses `unkXYOffsets_0x384[8]`,
`field132_0x3c4[8]` and `padding_0x404[64]` over 0x384..0x444; the branch had
researched the same 192 bytes as `keepOutbuildingOffsets_0x384[3][4]` and
`keepOutbuildingOffsets_0x3e4[3][4]`, which is what placeKeep and
demolishBuildingsInKeepsConstructionFootprint index as [variant][group]. The
researched pair is restored over main's three, same span, and
sizeof(TerrainDefinedData) stays 14252. Main's own gains in that header
(ConstructionSpriteRotationTable, MacroLayerScanOffsets) are kept.

The bulk of the work is stale generated field names. Main's Ghidra
regenerations renamed or renumbered fields that the branch still referenced,
e.g. field80_0x554894 -> editorRockType, unknownTime_0x5549bc ->
cursorAnimationTime, field84_0x5548a4 -> screenSouthEastDirection,
field151_0x554998 -> placementOnWall. These were resolved mechanically: the
offset is encoded in the old identifier, so each was rewritten to whatever the
header now declares at that same offset, and only where the offset resolved to
exactly one field. field889_0x2be0 needed the array form - it is 4 bytes into
attackedByPlayerArrayUnk[10][8] at 0x2BDC, so [0][1].

Three other classes of breakage:
- clearBuildingTilesAndTrees walked Building* through the tileRefs int array
  (`_pTileRef = &_pTileRef->tileRefs[1]`), which stopped being an lvalue of
  that type once Building became a real struct. It now walks int*, same
  arithmetic. It also needed explicit Logic1.hpp usings for the L_* flags that
  used to arrive transitively.
- Six place* sources passed a default-constructed TextMessageBLLookupStructUnion
  to setBottomLeftTextDisplayText, whose param_4 is now int; that is 0.
- Seven sources are still raw decompiler output (`._0_2_`, `::constant`,
  in_EAX) and are left out of the build list rather than guessed at:
  placeApplefarm, placeBarracks, placeBuilding, placeDairyfarm, placeDrawbridge,
  placeHopfarm, placeWheatfarm. They need real reimplementation, not a rename.

Files that clang-format flagged were formatted; 20 of them were already
non-conformant at HEAD, so part of that churn predates this change.

First measurement, reimplemented data and all 179 resolvers enabled: BUILD_OK,
avg 73.07 over 179, with 142 functions below 100. That is the real starting
point for this branch - no match work is attempted here, because none was
possible until it built.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Fzi11pcBU1Y7Y4oanrZQL
@gynt
gynt force-pushed the reimpl/TileMapState branch from fdecdc4 to 41e98d0 Compare October 23, 2026 09:56
gynt and others added 22 commits October 23, 2026 13:20
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
… tile

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
… bogu

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…re an

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…store

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
… tile

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…store

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…store

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…as 67

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…as 42

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…d rea

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
… read

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…d rea

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
… read

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…d rea

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r
…ocals

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVYWDtHk2xzvq9hszJRS9r

This branch has not been deployed

No deployments
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