Skip to content

reimpl/BuildingsState - #234

Draft
gynt wants to merge 216 commits into
mainfrom
reimpl/BuildingsState
Draft

gynt wants to merge 216 commits into
mainfrom
reimpl/BuildingsState

Conversation

@gynt

@gynt gynt commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

gynt added 30 commits September 24, 2026 06:45
gynt and others added 29 commits September 24, 2026 10:06
…erHasBurningBuilding

The original keeps DAT_CountOfBuildingsNeedPeasants in a register over the call
to playerHasBurningBuilding, which requires knowledge of the callee body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	cmake/compiler-flags-gl.txt
#	src/OpenSHC/Map/Buildings/Building.hpp
#	src/OpenSHC/Map/Buildings/BuildingsState.func.hpp
#	src/OpenSHC/Map/Buildings/BuildingsState.hpp
…t main

152 commits behind main and uncompilable against its regenerated headers, so
this branch had never been measured. All 165 sources now build, link and
score, with none excluded. The merge conflicted on four files, all resolved to
main's side.

Stale generated field names, resolved by offset against this branch's own
pre-merge headers rather than guessed:
- tileRefN -> tileRefs[N-1] (0x1C8, step 4), insideUnitIDN -> insideUnitID[N-1]
  (0x2E0, step 2), insideUnitUIDN -> insideUnitUID[N-1] (0x2E8, step 4);
  scalars that main has since collapsed into arrays.
- wheatGrowStateRelated -> farmGrowState (0x258).
- padding_0x2a5[0] -> maxOccupants (0x2A5, char).
- padding_0x280 -> field162_0x280: array to array at the same offset and
  length, so no index is added. It is read as four per-orientation entrance
  flags, which is what bool[4] now says.
- engineersAssemblyPoints -> specialBuildingAssemblyPoints: the old
  XYPairShort[2] at 0x39A4 is the head of the new XYPairShort[5] at the same
  address, so indexed uses carry over unchanged.
  tunnelersGuildAssemblyPointX/Y (0x39AC/0x39AE) -> [2].x/[2].y and
  cathedralAssemblyPointX/Y (0x39B0/0x39B2) -> [3].x/[3].y.

20 definitions had signatures that no longer matched the header. Types are
taken from the header, which is authoritative after a regeneration, while
parameter names are kept from the .cpp because its body uses them. Mostly
undefined4/uint -> BOOLEnum; also getResourceSpace's int* -> ResourceType, and
`PlayerID`/`PackagedFileMagicNum` parameters back to the `int` the header
declares.

Three leftovers: processResourceGain passed a stale (int*) cast to
getResourceSpace, now that it takes ResourceType; swapOwnersOfCastle casts 120
arguments to (undefined4*) for IO::SwapInts, which now takes (int*, int*).

Tooling note for the next branch. The project's refactor_struct_fields.py does
the offset-encoded renames, but it builds its solution list eagerly, so one
field name without an offset in it aborts every other fix in the same log;
feeding it only the C2039 lines whose names carry an offset lets it finish, and
the named leftovers resolve by looking the name up in the branch's pre-merge
header for its byte offset. Driving the loop from syntax_check.py (/Zs) instead
of a full build turns each pass from minutes into seconds.

First measurement, reimplemented data and all 165 resolvers enabled: BUILD_OK,
avg 87.02 over 165, 70 functions below 100. No match work is attempted here -
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/BuildingsState branch from 49b0e3a to 7f6c5c2 Compare October 23, 2026 09:56

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