Repository navigation
Reimplement 124 BuildingsState functions that are 100% - #274
Merged
Merged
Conversation
Field renames and the ActiveMenuTab union from the latest Ghidra sync broke seven sources; add a missing MapConstants include in two PathFindingState files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 BuildingsState functions that match the original at 100% (with --resolve-wrapped-calls), their status entries and the /GL pairs they need. The rest stay open in sourcehold#273. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@gynt this is ready for review whenever you have time. |
Contributor
|
Awesome. I just checked out the branch and indeed everything is 100%. I will go through each file now to see if the code style matches with what we currently do. |
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
reviewed
Oct 22, 2026
gynt
requested changes
Oct 22, 2026
gynt
left a comment
Contributor
There was a problem hiding this comment.
Just small things a handful of while loops to convert to for loops! Great work!!
Contributor
Author
|
Thank you! I'm churning out some more, will PR shortly. |
Contributor
|
You can also pull in half-baked stuff from any branches you can find on https://github.com/gynt/OpenSHC For this PR, you can cherry-pick the header changes: a10953c and e808f25 |
wheatGrowStateRelated holds the growth state of both wheat and hops farms. Every SwapInts caller passes int fields, so the undefined4 casts go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also clang-format include grouping in two PathFindingState files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
requested changes
Oct 22, 2026
# Conflicts: # src/OpenSHC/Map/Buildings/Building.hpp
tileRefs[36] array, BOOLEnum returns with TRUE/FALSE, field162_0x280 entrance/exit flags, getResourceSpace(int, ResourceType), upgradeBuildingsForMapVersion(int, ...), renamed field201/202, and casts dropped where MiscDisplayLayer, mapTimeInTicks and pathLinkageKeepWasUpdatedUnk are now short/int. All functions unchanged in reccmp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Oct 24, 2026
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Oct 24, 2026
tileRefs[] array indexing, farmGrowState (now short, casts dropped), field162_0x280 entrance flags, field192/201 renames, BOOLEnum returns with TRUE/FALSE, and getResourceSpace(int, ResourceType) - the same follow-ups sourcehold#274 got in 975e091, for the 41 functions of this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Oct 24, 2026
The Ghidra header sync retyped it after sourcehold#274 was last updated, so main no longer compiles this file. Return type and value follow the header; reccmp unchanged (100%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@6and8 feel free to open up more PRs! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 124
Map::Buildings::BuildingsStatefunctions from #273 that measure 100% with reccmp--resolve-wrapped-calls(struct and function resolvers enabled locally, not committed), with their status entries. The 41 that are not 100% yet stay in #273. This branch was also built and measured on its own, without those 41: all 124 are 100% there too, except thatprocessWallBuildingLosstail-callsprocessResourceLossfrom #273, so on its own only that call target differs.reimpl/BuildingsState, picked per function by compiling both versions and keeping the better match (e.g.swapOwnersOfCastle,growHops,setTileRefsForOilSmelter,updateLordLadyJesterAndGhostUnits). Some needed old field names mapped to the regenerated headers by offset.ecx/edxlive across a call to a finished callee are built with/GLtogether with that callee (cmake/compiler-flags-gl.txt).harmAppleFarmTreesOfPlayerusedtileRef1..7instead oftileRef2..9, andsetupEngineersGuildParagroundPositionsoffset from the entrance instead of the building position.The first commit fixes seven sources that no longer compile against the regenerated headers on
main(ActiveMenuTabunion,gameSuspended/musicFadeState/lastMusicChangeTimerenames, a missingMapConstants.hppinclude). #273 carries the same commit.Possible header issues (not changed here)
UT_S_TOWER/UT_S_BATTERINGRAMlook swapped:getBuildingCostreads cost entry 82 for siege towers and 83 for battering rams, soBuildingTypeorMappersEnumprobably has those two names swapped, and the disband price for each uses the other's building cost (commented in the source).Building::numberOfAnimalsis decremented when a tethered unit leaves, so it is likely an inside-unit count.setBuildingToAppleFarmonly writesrenderBlendStrength = 32.Building::tileRef1..tileRef19are separate fields, but the original walks them as one array (up to 36 entries); several functions index from&tileRef1(commented). An array would be cleaner.padding_0x280[4]holds four per-orientation entrance flags: they are cleared with one dword store and the twohas...FlagForOrientationfunctions read them.updateAllBuildingsSnoozedStateclears dwords over twoshortfields (the imported version works around it).getResourceSpacedeclares its second parameterint*, but it is aResourceTypevalue (the imported version casts it).TileMapState::MiscDisplayLayerisushort[]in the header, but the original treats its elements as signedshort: it masks them withand word ptr [..], imm8(66 83, sign-extended 8-bit immediate), which MSVC only emits for a signed element;ushortgives66 81with a 16-bit immediate.rebuildTileLogicLayerForGatesAndWallsworks around it with a commented*(short*)&cast.Cheat sheet candidates
if/else ifwith identical bodies.this->need hoisting intoconstlocals, since our stores may alias the global (determinePeasantSitPosition35% -> 97%).do/while(rebuildTileLogicLayerForKeeps).and word ptr, imm8(66 83) on an array element means the element is signedshort.harmAppleFarmTreesOfPlayer).updatePathLinkageTileMap).Built with the bundled MSVC1400-SP1 under Wine on Linux.
🤖 Generated with Claude Code