Repository navigation
Reimplement 11 Map::Units functions from gynt's units branch (100%) - #390
Merged
Merged
Conversation
DetachLadderman, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). Taken unchanged (the build fix 43a17df had nothing to rename here). What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FindFirstOpponentWithKeep, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). The build fix 43a17df follows main's headers: PlayerData::keep becomes buildingEntryInfos[BEIE_KEEP], with BuildingEntryInfoEnum.hpp included; nothing else changed. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IncrementAndOptionalUpdateAVValueRelated, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). Taken unchanged (the build fix 43a17df had nothing to rename here). What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PlayStockpileIsFullWarning, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). Taken unchanged (the build fix 43a17df had nothing to rename here). What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetRestingForUnit, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). The build fix 43a17df follows main's headers: Unit::field166_0x2fe becomes field_0x2fe; nothing else changed. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetStateToFreetimeWalking, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 100.0% (Reimplemented); the file was last changed in 974c32f (2026-11-02, "style(map-units): own-namespace include first, and clang-format"). The build fix 43a17df follows main's headers: Unit::field166_0x2fe becomes field_0x2fe, and the function returns BOOLEnum as main's Units.hpp declares it (with BOOLEnum.hpp included); nothing else changed. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ComputeGoodsProduced, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 78.0% (idiv vs magic division); the file was last changed in c933f79 (2026-11-02, "Adopt the Wilps Map/Units bodies that measure better here (sourcehold#286)"). The body is Wilps's, from reimpl/Wilps-2026-10-18, which gynt adopted in d914edf and merged in c933f79 (sourcehold#286). Taken unchanged (the build fix 43a17df had nothing to rename here). With main's headers and both resolver sets on it now reads reccmp 100.0%. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PlayArmoryIsFullWarning, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 80.4% (loop precheck scheduling); the file was last changed in c933f79 (2026-11-02, "Adopt the Wilps Map/Units bodies that measure better here (sourcehold#286)"). The body is Wilps's, from reimpl/Wilps-2026-10-18, which gynt adopted in d914edf and merged in c933f79 (sourcehold#286). Taken unchanged (the build fix 43a17df had nothing to rename here). With main's headers and both resolver sets on it now reads reccmp 100.0%. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WarnIfPlayersGranaryIsFull, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 80.4% (loop precheck scheduling); the file was last changed in c933f79 (2026-11-02, "Adopt the Wilps Map/Units bodies that measure better here (sourcehold#286)"). The body is Wilps's, from reimpl/Wilps-2026-10-18, which gynt adopted in d914edf and merged in c933f79 (sourcehold#286). Taken unchanged (the build fix 43a17df had nothing to rename here). With main's headers and both resolver sets on it now reads reccmp 100.0%. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UpdateBurningAnimal1, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 0.0% (Pending); the file was last changed in c933f79 (2026-11-02, "Adopt the Wilps Map/Units bodies that measure better here (sourcehold#286)"). It was first reimplemented in 7abe46b ("reimplement UpdateBurningAnimal1 100%") and tidied by gynt in bef36eb. Taken unchanged (the build fix 43a17df had nothing to rename here). With main's headers and both resolver sets on it now reads reccmp 100.0%. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UpdateBurningAnimal2, gynt's version as it stands on his fork's reimpl/map-units-updatefunctions at 48b79a2 (his draft sourcehold#204), where its status line reads 0.0% (Pending); the file was last changed in c933f79 (2026-11-02, "Adopt the Wilps Map/Units bodies that measure better here (sourcehold#286)"). It was first reimplemented in c4fba5a ("reimplement UpdateBurningAnimal2 100%") and tidied by gynt in bef36eb. Taken unchanged (the build fix 43a17df had nothing to rename here). With main's headers and both resolver sets on it now reads reccmp 100.0%. What main needs on top follows in our own commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions openshc-pr-fix.py's mechanical pass over the eleven files: boost, updateAV and restedEnough are tested for truth instead of against FALSE, and UpdateBurningAnimal1 and 2 lose their unused using declarations (UnitLogicState, UnitState). quick_diff is the same for all eleven. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::SetRestingForUnit (0x00549B30) stores 2 in a unit's destinationNeeded twice (mov word ptr [esi + 0x13888C0], 2 at 0x00549BB7 and 0x00549C09: the units array at 0x0138854C plus the field's 0x374), when no building is found and when the unit has rested enough. The enum has no value between DNE_DESTINATION_NEEDED (1) and DNE_FLETCHER_SPECIFIC_COUNTDOWN (5); named in the DNE_UNKNOWN_<n> form. Used in place of (DestinationNeededEnum)2; code generation is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::SetStateToFreetimeWalking (0x00530CF0) and Units::ConsiderHavingABreakNowUnk (0x00530C40) put a unit into state 121, the resting state (mov word ptr [ecx + 0x138880C], 0x79 at 0x00530D43 and 0x00530CD2: the units array at 0x0138854C plus state at 0x2C0). The enum goes from US_STONE_DEATH_03 (116) to US_APPEAR (122); named in the US_UNKNOWN_<n> form. Used in place of (UnitState)121; code generation is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unit::workTimer, workRelatedA, workRelatedB and workRelatedC (+0x2E8 to +0x2F4) are one int[4] indexed by Unit::working (0 to 3): Units::IncrementAndOptionalUpdateAVValueRelated (0x00530B40) adds 1 to the current one with add dword ptr [eax*4 + 0x1388834], 1 at 0x00530B5C (eax holding unitID * 292 plus working, in dwords; the units array is at 0x0138854C), sums all four into av and clears the next one the same way. Nothing on main uses the four names, and on this branch only that function does. This round's style commit then indexes workTimers there; code generation is the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omments - SetRestingForUnit stores DNE_UNKNOWN_2 and SetStateToFreetimeWalking US_UNKNOWN_121 (header commits) in place of the casts; SetRestingForUnit tests hasUnitReachedDestination for truth, and SetStateToFreetimeWalking returns FALSE / TRUE and calls its third parameter substateCount (the count of substates it wraps around). - IncrementAndOptionalUpdateAVValueRelated indexes workTimers (header commit) instead of (&workTimer)[i], with countof for the four; its count stays zeroed before the early return (after it: quick_diff 0.9811 -> 0.9057). - ComputeGoodsProduced keeps its divisor variable (a literal 100: quick_diff 0.9737 -> 0.7561) and its * 100 / 100 (without: 0.4058), each with a one-line comment, and its plate comment is a // line in the body. - UpdateBurningAnimal1 and 2 lose the imported plate comment, store US_STATE_2Unk for 2, and name their two locals without the leading underscore, the animation bound on the right of the comparison. - const for the locals assigned once (tile, currentPlayer twice, bonusPercentage, now), and PlayStockpileIsFullWarning's comment on its return value says what the code does. quick_diff is the same for all eleven. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::PlayStockpileIsFullWarning (0x00530EB0) was declared to return uint, but nothing uses a result: no file on main calls it, the six callers in the decompilation throw eax away, and its two siblings, PlayArmoryIsFullWarning and WarnIfPlayersGranaryIsFull, are void. What eax holds at its end is the quotient of the last % 5000. It is void in Units.hpp and in its resolver's signature in Units.func.hpp. With the body written like its siblings, quick_diff output is identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- PlayStockpileIsFullWarning is written like its two siblings: void, an early return, and no quotient kept for eax. - The three warnings' static guards use main's form (`!(guard & TRUE)`, `guard |= TRUE`), as in PlayJokeVideoBasedOnCurrentTimeAndPlayTime, so their BOOLEnum casts, usings and includes go. - buildingID for the building loops and SetRestingForUnit's building, activeTimerCount for the count of active timers, and a truth test for shouldFindNewGoodThing. - ComputeGoodsProduced drops its (short) casts (the fields are short) and its plate example, and its boost comment says every mode but solitary. - SetRestingForUnit says why idle is tested against target twice. - IncrementAndOptionalUpdateAVValueRelated loses a comment that repeated what the array says. - A blank line before the namespaces close in both BurningAnimal files, as in the other nine. quick_diff output is identical for all 11 files, with -s. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 10, 2026
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.
Eleven Map::Units functions at 100%, the first from gynt's units branch
reimpl/map-units-updatefunctions(his draft #204), which he offered us on Discord on 2026-11-10. All 11 are his code. Each function is one commit authored by him: his file as on his branch at 48b79a2, with only the renames that main's headers need since his last merge. Our changes are separate commits on top.Units::DetachLaddermanUnits::FindFirstOpponentWithKeepUnits::IncrementAndOptionalUpdateAVValueRelatedUnits::PlayStockpileIsFullWarningUnits::SetRestingForUnitUnits::SetStateToFreetimeWalkingUnits::ComputeGoodsProducedUnits::PlayArmoryIsFullWarningUnits::WarnIfPlayersGranaryIsFullUnits::UpdateBurningAnimal1Units::UpdateBurningAnimal2The last five read 100% on today's main with his code unchanged. The headers his branch builds against have moved on since his status was written.
Where the code comes from:
Measured on main 847c77b.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.!(guard & TRUE),guard |= TRUE),buildingIDnames, no(short)casts.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score below a known one.Header changes (each in a commit of its own)
gynt's Ghidra sync 2bd620b brought all four to main. Main (39ed817) is merged in (6662533), so these commits now match main, and the "Declaration/type change validation" check passes. The 11 files' quick_diff output is identical before and after the merge.
Each is kept separate so the header change stands alone. Two of them (the work timers and the void return) don't build on their own; the style commits after them change the code to match.
DestinationNeededEnumgetsDNE_UNKNOWN_2(c9bd78b). SetRestingForUnit stores 2 at 0x00549BB7 and 0x00549C09.UnitStategetsUS_UNKNOWN_121(24ce8db). It is stored at 0x00530D43 (SetStateToFreetimeWalking) and 0x00530CD2 (ConsiderHavingABreakNowUnk, which comes in a later PR), and it is the resting state.Unit'sworkTimer,workRelatedA,workRelatedBandworkRelatedCbecome oneint workTimers[4]at 0x2E8 (85955cb). IncrementAndOptionalUpdateAVValueRelated indexes it by the unit'sworkingvalue at 0x00530B5C. No file on main uses the four names, and the struct's layout is unchanged.PlayStockpileIsFullWarningreturnsvoid, inUnits.hppand in its resolver's signature (e9cbc59).uint, but no file on main calls it, and the six callers in the decompilation ignore the result.void.eaxholds at its end is only the quotient left over from the last% 5000.Kept as they are, measured with quick_diff (each has a one-line comment)
* 100 / 100Proposed, not changed here
US_UNKNOWN_121could be named as the resting state.Unit::field_0x2feis the flag main's CheckUnitProductionPaused (0x00530D50) tests with== 1. SetRestingForUnit sets it to 1 when the unit's resting animation starts, and to 0 when the unit gets up.productionPausedUnkwould fit.DAT_UnitHasBecomeIdleisundefined4, but it is only ever stored 1 or tested!= 0, so it could beBOOLEnum. So could SetStateToFreetimeWalking'sshouldFindNewGoodThing.(DestinationNeededEnum)2and(UnitState)121uses, in 18 files (for example UpdateAppleFarmer, UpdateArmorer and ConsiderHavingABreakNowUnk). They take the new names in later rounds.substateCountin the.cppand stillparam_3inUnits.hpp.Other PRs
🤖 Generated with Claude Code