Repository navigation
Conversation
…cehold#526 with /GL The nine /GL entries from sourcehold#526 for the functions this PR carries (hasAdjacentCellWithField24Or25, isAttackStagingCandidateCell, floodFillZoneProximityFromCell, floodFillCasDisFromSignpost, updateSection1034Info, floodFillField13FromCell, floodFillField20FromCell, updateWildlife, updateTreeStage), plus main's getValueFrom0UpTo3ForTreeTypeAndTreeStage as in sourcehold#526: updateTreeStage calls it, and LTCG must see both sides for the caller to match. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
|
Style guide reading (advisory, posted once) 29 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 11 of the 11 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 8 — Let the compiler unroll
Rule 9 — Prefer
Rule 14 — The shape of a file
Rule 18 — Use the name, not the number
Rule 24 — Declare variables upon first use
|
…eState functions The class's own .func.hpp as the first include (Map.func.hpp and duplicate includes dropped); countof instead of the grid, BFS queue, rock array and direction bounds (40, 39, 1600, 4000, 8); the BFS while loops as for loops; self-increments; TreeType names for the shrub range in updateTreeStage and LogicHelpers::L_TREE instead of 0x1000; the debug-view labels from string-literals.hpp; param_1/param_2 named cellX/cellY; BOOLEnum returns tested directly; unused usings dropped; namespace closing comments. Re-measured on 40cbb1c with a full build and reccmp: all eleven stay at 100.0/100.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
- updateSection1034Info leaves this PR: it only matches through a volatile read of its pass counter. Its status line goes back to main's, and its /GL entry goes too. - The /GL entries of hasAdjacentCellWithField24Or25, isAttackStagingCandidateCell, floodFillZoneProximityFromCell and floodFillCasDisFromSignpost are dropped: without updateSection1034Info they are not needed (all still 100%). - updateTreeStage stores Trees::TS_TO_BE_REMOVED instead of 3; floodFillCasDisFromSignpost divides by MC_MAP_SECTOR_SIZE; a comment restating createRock's loop is removed. Re-measured on 592a17d with a full build and reccmp: all ten functions 100.0/100.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
|
Forms in this PR that are kept only for the match, and header types that look wrong:
|
TreeState.hpp/TreeStateShort.hpp become TreeStateEnum.hpp/TreeStateEnumShort.hpp, the types TreeStateEnum/TreeStateEnumShort, and the values TSE_UNUSED, TSE_SPAWNED, TSE_ALIVE, TSE_TO_BE_REMOVED and TSE_STATIC. Tree.hpp's state field and updateTreeStage follow. This frees the TS_ prefix for the TribeState enum in sourcehold#555 (TS_FREE, TS_ACTIVE, TS_EMPTY). A rename only: updateTreeStage compiles and its quick_diff output is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's TreeState enum is renamed to TreeStateEnum with TSE_ values in sourcehold#549, which frees TS_ again, so the tribe states return to TS_FREE, TS_ACTIVE and TS_EMPTY. A rename only; quick_diff output for createTribe and removeUnitFromTribe is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This aligns the enum with sourcehold#555, which carries the same two files byte for byte, so the two PRs do not conflict. TS_ becomes free once sourcehold#549 renames TreeState to TreeStateEnum (TSE_). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This aligns the enum with sourcehold#554, which carries the same two files byte for byte, so the two PRs do not conflict: - Map/Enums is main's folder for these headers; Map/Units/Enums does not exist on main. - TS_FREE becomes TS_UNUSED and TS_EMPTY becomes TS_DISBANDED. - TS_ is free once sourcehold#549 renames TreeState to TreeStateEnum (TSE_). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's upstream Ghidra sync (0701799) renames TreeState to TreeStateEnum. TreeStateEnum.hpp, TreeStateEnumShort.hpp and Tree.hpp are taken from main, so this branch no longer changes them. Main keeps the TS_ value names, so updateTreeStage goes back to Trees::TS_TO_BE_REMOVED. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
These files are byte-identical to the ones in sourcehold#554 and sourcehold#555: TS_UNUSED = 0, TS_ACTIVE = 2, TS_DISBANDED = 3. The TS_ prefix relies on sourcehold#549 renaming TreeState's values to TSE_. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's upstream Ghidra sync (c1b50c4) renames the TreeStateEnum values to TSE_; updateTreeStage follows with Trees::TSE_TO_BE_REMOVED. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
| namespace Map { | ||
|
|
||
| // FUNCTION: STRONGHOLDCRUSADER 0x004F2140 | ||
| int LandscapeState::createRock(undefined4 x, undefined4 y, int rockType, undefined4 size, undefined4 orientation) |
There was a problem hiding this comment.
Typed them: createRock(int x, int y, RockType rockType, int size, int orientation) (0633805). The original reads x and y as dwords (mov edi, dword ptr [esp+..]), so they are int, not short. Still 100%.
| this->rocks[rockID].orientation = (short)orientation; | ||
| this->rocks[rockID].unknownGMID = (short)DAT_OrganismDefinedData::instance.Rock_field0xe[rockType]; | ||
| DAT_CurrentRockID::instance = rockID; | ||
| (*DAT_OrganismDefinedData::instance.RockTypeFunctions[this->rocks[rockID].type])(); |
There was a problem hiding this comment.
Typing wrong? Can a function ptr not be directly called? I may remember wrong, though.
There was a problem hiding this comment.
Yes, it can be called directly; the typedef was fine. It is now RockTypeFunctions[this->rocks[rockID].type](); (0633805), and the code is identical.
| this->rocks[rockID].size = (short)size; | ||
| this->rocks[rockID].y = (ushort)y; | ||
| this->rocks[rockID].one = 1; | ||
| this->rocks[rockID].type = (short)rockType; | ||
| this->rocks[rockID].x = (ushort)x; | ||
| this->rocks[rockID].tile | ||
| = (int)(short)(ushort)x + DAT_ViewportRenderState::instance.translationMatrix[(short)(ushort)y].addXgetTile; | ||
| this->rocks[rockID].orientation = (short)orientation; | ||
| this->rocks[rockID].unknownGMID = (short)DAT_OrganismDefinedData::instance.Rock_field0xe[rockType]; |
There was a problem hiding this comment.
All casts are gone (0633805). The tile now reads the stored short fields (rocks[id].x + translationMatrix[rocks[id].y]), which gives the original movsx code. short x, short y parameters scored 94.1 / 91.7 because MSVC then loads words (mov di, word ptr) where the original loads dwords, so the parameters are int.
| return; | ||
| } | ||
| } | ||
| if ((this->trees[treeID].rng1 & 0x3fU) != rng) { |
There was a problem hiding this comment.
What does this value mean?
There was a problem hiding this comment.
updateTrees draws a random slot 0-63 every eighth tick and passes it in. A tree only advances when the low 6 bits of its rng1 match, so stage updates are spread over the trees. I renamed the parameter rng → stageSlot and added a one-line comment (bb64bd5).
| MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func::updatePathLinkagesInAllEightDirections, | ||
| DAT_PathFindingState::ptr)(this->trees[newTreeID].yPosition, this->trees[newTreeID].tile); | ||
| DAT_GameState::instance.mapAndTime.newOrganisms++; | ||
| DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; |
There was a problem hiding this comment.
Toggle? So boolean-like?
There was a problem hiding this comment.
Yes: it is a dirty flag. About 20 writers set it to 1, and updateSeparateAreaTileMap (0x4995E0) tests it and clears it to 0. It is now set with TRUE (bb64bd5). Making the field a BOOLEnum would need edits in those ~20 main files, so I left the field type alone.
| MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, | ||
| DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, | ||
| y + row * 10 + 9, COL_BLUE::instance.shortValue); | ||
| } else if (areaColour == 1) { |
There was a problem hiding this comment.
Do this color indexes relate to something?
There was a problem hiding this comment.
No. separateAreaID & 7 just cycles 8 colours, so neighbouring areas get different colours; 0 means no area (blue). It does not index anything else, so there is no enum for it.
| DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, | ||
| y + row * 10 + 9, COL_VERY_DARK_GREY::instance.shortValue); | ||
| } | ||
| } else if (this->DAT_DebugDataMapDataDisplayType == 1) { |
There was a problem hiding this comment.
Yes. I added Map/Enums/DebugDataMapDataDisplayType (DDMDDT_CONNECT = 0 … DDMDDT_SLINK = 9, named after the caption each mode prints) and made the field DebugDataMapDataDisplayTypeInt (803c7b2). Still 100%.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Every removed cast was checked one at a time: the file's /FA listing is identical without it and no new warning appears. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
updateTreeStage compares it as a signed word against the short stageRelated1 (0x4F39D7: cmp dx, word ptr [esi+0x90]; jl), so the (short) cast at the use site goes away. updateTreeStage is the only reimplemented user; it stays at 100%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
(undefined4, undefined4, int, undefined4, undefined4) becomes (int x, int y, RockType rockType, int size, int orientation). The original reads x and y as dwords (mov edi/ecx, dword ptr [esp+..]), so they are ints; short parameters make MSVC load words instead. rockType indexes the per-type tables. The tile is computed from the stored short fields, which drops the (short) casts, and the callback is called directly. createRock has no reimplemented callers; it stays at 100%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
WildlifeState::DAT_DebugDataMapDataDisplayType selects which wildlife grid layer renderDebugDataMapData draws; each value 0 to 9 prints its own caption (Connect, Chimps, Farmland, Humans, Mankind, Deer, Route, Panic, Siege, Slink). The field becomes DebugDataMapDataDisplayTypeInt (int), so no user changes codegen; renderDebugDataMapData compares against the DDMDDT_ names and stays at 100%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
updateTrees draws one random slot (0 to 63) every eighth tick and passes it in; a tree advances only when the low six bits of its rng1 match, so the parameter is renamed from rng to stageSlot (also in the header) and a one-line comment explains the 0x3f mask. toggleUpdateSeparateAreaTileMap is a dirty flag (set to 1 by its writers, tested and cleared by updateSeparateAreaTileMap), so it is set with TRUE. Stays at 100%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Cpp-Linter Report
|
This PR carries the finished part of draft PR #526 (
reimpl/landscape-wildlife-development): 10 of its 17 functions, all at 100%. No function where only register allocation differs qualified.Measured on
origin/main(592a17d, merged in): I built the DLL with exactly these 10 files in the build list, plus three files that are already on main and that they call (copyData,getValueFrom0UpTo3ForTreeTypeAndTreeStage,GetIfDisplayElementStateNotZero). The struct resolvers and the function resolvers of those files were switched on, then I ran reccmp. All 10 came out at 100.0, normalized 100.0.Re-measured after merging
origin/mainc1b50c4 (the upstream Ghidra syncs). The build list held all 29WildlifeStateandLandscapeStatesources on the branch, with both resolver sets on. All 29 are at 100.0 / normalized 100.0, including these 10.LandscapeState::createRockLandscapeState::updateTreeStageWildlifeState::renderDebugDataMapDataWildlifeState::floodFillField13FromCellWildlifeState::floodFillField20FromCellWildlifeState::hasAdjacentCellWithField24Or25WildlifeState::isAttackStagingCandidateCellWildlifeState::floodFillZoneProximityFromCellWildlifeState::floodFillCasDisFromSignpostWildlifeState::updateWildlifeStyle:
REIMPLEMENTATION_STYLE_GUIDE.md, and the class's own.func.hppis the first include.countofreplaces the grid, BFS-queue, rock-array and direction bounds.MC_MAP_SECTOR_SIZE,Trees::TSE_TO_BE_REMOVED, theTT_SHRUB_*range andLogicHelpers::L_TREEreplace numbers.string-literals.hpp.param_Nparameters are named.Header changes (one commit each, made for review comments):
Tree::stageRelated2:undefined2→short. The stage comparison is a signed word compare, and the cast goes away.LandscapeState::createRock(int x, int y, RockType rockType, int size, int orientation), previouslyundefined4s.Map/Enums/DebugDataMapDataDisplayType(DDMDDT_CONNECT…DDMDDT_SLINK) with anIntvariant.WildlifeState::DAT_DebugDataMapDataDisplayTypeuses it.updateTreeStage's second parameter is renamedrng→stageSlot.TreeStateEnum(withTSE_values) andTreeStateEnumShortcome from main. Re-measured after these changes (mergedorigin/main33cdd1f): all 29WildlifeState/LandscapeStatesources on the branch are at 100.0 / 100.0./GL entries (
cmake/compiler-flags-gl.txt):updateWildlifeand its calleesfloodFillField13FromCell/floodFillField20FromCell;updateTreeStageand main's existinggetValueFrom0UpTo3ForTreeTypeAndTreeStage, which it calls. LTCG has to see both sides of each call.Every other file matches without /GL. No function-visibility entries.
Left in #526:
updateSection1034Infois at 100% in the draft, but only through avolatileread of its pass counter. It goes to a separate PR for match-driven forms.createTree(89.6): stores to tree fields are in a different order.spawnCrowFromNearbyTree(98.3),buildRallyPointPathForTribe(98.0),findAndSetNewRallyPointForDeerAndLions(96.1) andupdateWildlifeGrid(87.5): the original has extra unthreadedjmpblocks.updateNofFpoints(77.5): the map base is folded into the induction variable.Overlap with open PRs: #292 carries six of these files, each a different version from the one here:
floodFillCasDisFromSignpost,floodFillField13FromCell,floodFillField20FromCell,floodFillZoneProximityFromCell,hasAdjacentCellWithField24Or25andisAttackStagingCandidateCell. Whichever PR is merged second will conflict on those files.There is one commit per function, each setting
status/addresses-SHC-3BB0A8C1.txtto100.0% | Reimplemented, plusstyle:/review:commits and the header commits above.Draft PR #526 stays open for the remaining functions.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp