Repository navigation
Reimplement UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher, UpdateBlacksmith and UpdateWoodcutter from gynt's units branch, 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on - #536
Merged
gynt merged 12 commits intoDec 4, 2026
Conversation
Unit.hpp, offset 0x3EF: `undefined1` -> `char`, the size and the name stay. The original reads the field signed, in both functions that read it: movsx edx, byte ptr [unit + 0x138893b] at 0x0054DCEB (UpdateFletcher) and at 0x0055764F (UpdatePoleTurner). 0x0138893B is the field in unit 0 of DAT_UnitsState (0x01387F38 + 0x614 + 0x3EF). The other four instructions of the game with that address store into it, in the same two functions: 0x0054D9B0, 0x0054E2DC, 0x005573EB and 0x00557BC4. No .cpp on main names the field. UpdateFletcher and UpdatePoleTurner, two of the unit commits behind this one, read it without a cast; their object code is the same with the old type and a `(char)` cast (compiled as quick_diff does, alone and with their entry's callees in front). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own file The definition in getBuildingResourceAmountByUid.cpp (0x00409330) gets `inline`; nothing else changes. BuildingsState.hpp and every other file stay as they are, so no other unit's declarations change. Why: several unit updates of the original (UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher, UpdateBlacksmith, UpdateWoodcutter) see the getter's body: behind a call of it they know that it writes no global (no slot reload), but not which registers it keeps, and load `this` again for the next BuildingsState call (mov ecx, 0xf98520 at 0x0055A1CC in UpdateTanner, 0x00558E8E and 0x005591B2 in UpdateArmorer, 0x0054DF14 in UpdateFletcher). An `inline` body that is not expanded gives exactly that; a plain visible body gives neither reload, an opaque one both. The units see the body through cmake/function-visibility.txt: their group's wrapper unit #includes this .cpp. UpdateFletcher also has the getter's test in place at 0x0054DADF, beside the call at 0x0054DF08. Our compiler does not expand a call there even with `inline` (14 instructions more), so that file writes the test out, and it is no evidence for this form. quick_diff, each unit with the callees of its entry in front of it, `inline` against a plain definition: UpdateTanner 0.999 against 0.9984; UpdateArmorer 0.9987 against 0.9974; UpdatePoleTurner 0.9988 against 0.9982; UpdateFletcher 0.9989 against 0.9983; UpdateBlacksmith 0.9988 against 0.9982; UpdateWoodcutter 0.9991 against 0.9987. Default build: the getter's .cpp includes BuildingsState.func.hpp, where MACRO_FUNCTION_RESOLVER instantiates the getter's resolver; where that counts as implemented it refers to the function, so the function is emitted from this file. OPEN_SHC_IMPLEMENTED(x) (src/precomp/CompileMacros.h) is true in the EXE whatever the flag, and the flag in the DLL. The builds below are of the DLL with the resolvers on locally: the function is emitted, the build links, and it reads 100.0 / 100.0 in both modes. With the flag off, as committed, nothing in the DLL's object refers to it and it is not emitted, where a plain definition is (this file compiled alone, DLL and EXE defines, flag off and on). The EXE was not built, nor the DLL with that flag off. The file is on cmake/compiler-flags-gl.txt, so the getter's callers on that list see its body in the default build: the reason for a full option-off build. With the option on, UpdateIronMine, UpdateInnkeeper, UpdateMiller and UpdateEngineer, whose entries name the getter, saw a plain body until now and see an inline one now, and read the same. Measured in full builds of this branch (3,042 files / 3,060 functions, 0 failures) against main built the same way (3,036 / 3,054; option on 830fbd5; option off e62246a, because 830fbd5 only adds 24 lines to cmake/function-visibility.txt, which that build does not read): every caller of the getter on main reads the same in both modes: UpdateIronMine, UpdateInnkeeper, UpdateMiller, getWorkerBlockingStateIfStuck 100.0, UpdateQuarry 98.8 off / 87.6 on, UpdateEngineer 85.0 off / 100.0 on. placeDefensiveStructureTile and planToBuyWhenLowOnResourceAndSnoozeBuildings, the two functions watched for this change, stay at 100.0 in both modes. The only other differences are Menu::Constructor_Menu and Menu::handleMenuItems, the 0x11000000 image-layout flip: 100.0 / 100.0 with the option on and 98.4 / 97.9 with it off in the branch's builds, the other way round in main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdateWoodcutter, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 80b1513 at 37.90%, 55009cd at 42.93%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. Every access reads the unit through DAT_CurrentUnitSlotID::instance and the draft's local copy of the slot is gone: the original keeps the global in a register and loads it again only behind a call that may change it. The rest is the order of arms, read off the block layout against the original's: - Walking to the tree: "another woodcutter stands on this tile" is the then-arm and the tree tests the else-arm. The two failures of the climb-point branch each have their own copy of the give-up code (the original reloads the slot in front of stores both paths share, 0x0054C9FC), and the failed setDestinationForUnit is the else arm of its test, so the compiler lays it out behind the state's last return. - Felling: the orientation is turned in the global itself, += 2 and -= 8 at 8 and above; the original stores it after each step (0x0054CB16). The small tree's sound comes first (stage <= 1), and the branch that fells the tree closes itself with its own copy of the state 3 lines, so the first arm jumps forward into the second arm's call, as in the original. - Chopping: the chop count test is <= 3, the constant the original compares with (0x0054CDFB). The substate when the woodcutter is done is (mapTimeInTicks & 1) + 2 with no cast: the original computes it in a full register from one byte load (0x0054D497). - The last death code stands in front of the remaining states, under the alive test, with the idle arm of its frame test first, as the original has it. - The other arm swaps came from a search that keeps a change when quick_diff's ratio rises. Visibility, as in UpdateTanner and UpdateArmorer: the original treats updateBuildingSignpostCounter as opaque here, and getBuildingResourceAmountByUid (0x00409330) as an inline body that is not expanded. Text pass (after the changes above), the same listing in quick_diff before and after: states by UnitState_Woodcutter's names (state.woodcutter, as UpdateWheatFarmer uses its own), CD_UNSPECIFIED for 15, hex constants as decimal, the file-scope using lines gone, the (char) casts on the fade countdown and the frame tables dropped (char in main's headers), ++ / -- for the steps of one, the BOOLEnum calls tested by truthiness, const on the locals that are never reassigned; unitTypeSpecificRestingState by the state's name, CD_SOUTH and CD_UPPER_LIMIT for the orientation's 4 and 8, the tree tests as an else-if chain, const on the stockpile local of the leaving state, the comment on the other woodcutter at its test, one line on the two locals at the top. Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 95.6 / 83.4 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdateFletcher, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 7ec4ed1 at 41.41%, e832e45 at 31.26%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. The places where the original's listing settled the form: 1. State 1 (fetching wood): the wood test is the body of getBuildingResourceAmountByUid inline, with the no-wood arm first: jne at 0x0054DAE5 to 0x0054DAF3, cmp at 0x0054DAE7, jg at 0x0054DAED to the wood arm at 0x0054DBC3. Written as a local with the getter's meaning and tested with <= 0 it comes out so: int wood = buildings[target].uid == targetUID ? buildings[target].resources[2] : 0; if (wood <= 0) { ...; return; } `uid != targetUID || resources[2] <= 0` does not (the compiler lays the arms out as for && again), and a call of the getter is not expanded there by our compiler, even with the getter `inline` (890 instructions against 876, quick_diff with the entry's callees in front). 2. In the no-wood arm the test of setWorkplaceBuildingEntryAsTarget has the found arm first (je at 0x0054DB92 to the ULS_REMOVE store at 0x0054DBAF). 3. State 0: the test of setDestinationForUnit has the success arm first (je at 0x0054DA56 to 0x0054DA72), and the accessibility test has the accessible arm first with the stand-up store in its else. The original jumps for that else from 0x0054DA02 into state 1's `state = bp` at 0x0054DB67: the compiler merged the two tails, bp is 8 in state 0 and 1 in state 1. 4. State 2: the workshop's wood on the left of the compare (cmp [mem], reg at 0x0054DCF8, jl at 0x0054DCFE). Visibility, as in UpdateTanner and UpdateArmorer: the original treats updateBuildingSignpostCounter as opaque here. Behind the call of getBuildingResourceAmountByUid (0x00409330) at 0x0054DF08 it loads `this` again (mov ecx, 0xf98520 at 0x0054DF14) but not the slot, which is what an `inline` body that is not expanded gives. The test in place at 0x0054DADF is that of the getter too, but our compiler does not expand a call there even with the getter `inline` (point 1), so the file writes it out. Text pass (after the changes above), the same listing in quick_diff before and after: states by UnitState_Fletcher's names (state.fletcher, as UpdateWheatFarmer uses its own), the wood test as an if, the (char) casts on the fade countdown and the frame tables dropped (char in main's headers), ++ / -- for the steps of one (destinationNeeded included), the BOOLEnum calls tested by truthiness, const on the locals that are never reassigned, whys above the three ternaries; unitTypeSpecificRestingState by the state's name, the two wood amounts as ternaries (a comparison plus 2 before), no else behind a return in state 0, no cast on poleturner_spearOrPike (a char since the header commit). Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 73.6 / 73.1 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdatePoleTurner, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 3f9d400 at 44.16%, 29624ac at 48.41%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. The places where the original's listing settled the form: 1. State 6 (turning the pole): the workshop local is declared behind the tick test, and the first arm passes the field itself. The original reads the workplace id once between the compare and the branch (movsx eax at 0x0055783C, behind cmp ax, 0x1e at 0x00557838 and in front of jge at 0x00557843): both arms read it and the compiler hoists the common read. Declared in front of the test, ours read it early and spilled it early. This also put the constant 2 of the function's first store back into eax, a hunk far away. 2. State 3: the workshop's wood on the left of the compare (cmp [mem], reg at 0x0055765C, jl at 0x00557662). 3. State 3: producedItemTypeNext = producedItemType written first in its block. The original loads the type at the block's start (0x00557664) and stores it at its end (0x0055769A), behind the unit's six stores: the compiler moves the store of a copy between two fields of the other global, not the load. Written last, the load came last too and in another register. UpdateFletcher's text already had this order. Visibility, as in UpdateTanner and UpdateArmorer: the original treats updateBuildingSignpostCounter as opaque here, and getBuildingResourceAmountByUid (0x00409330) as an inline body that is not expanded. Text pass (after the changes above), the same listing in quick_diff before and after: states by main's names, the (char) casts on the fade countdown and the frame tables dropped (char in main's headers), engineerManningSiegeStateRef_checkType set to -2, ++ / -- for the steps of one, the BOOLEnum calls tested by truthiness, const on the locals that are never reassigned, whys above the three ternaries; unitTypeSpecificRestingState by the state's name, the two wood amounts as ternaries (a comparison plus 1 before), the three death states in UpdateArmorer's idle-flag form (each stored ULS_REMOVE, set the flag and returned in its last-frame block before), no cast on poleturner_spearOrPike (a char since the header commit). Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 81.0 / 80.2 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdateBlacksmith, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: a2d2adb at 51.11%, 823c707 at 56.13%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. Every access reads the unit through DAT_CurrentUnitSlotID::instance and the draft's local copy of the slot is gone: the original keeps the global in a register and loads it again only behind a call that may change it. The rest is the order of arms, read off the block layout against the original's: - Taking iron, with iron in the stockpile: the rest of the state is nested under "the workplace is reachable", the walk home with the fade-out arm first and the iron taken behind it, REMOVE last; the original has REMOVE at the end of the state and both failed workplace tests jump to it. Without iron, the reachable stockpile comes first and the way home behind it. This decides which of two identical copies survives: this state and the one that sends him for iron both end in "go to the stockpile" and "go home", and in the original each keeps one copy and jumps to the other state for the other. - Forging: the "fewer than 30 ticks" exit first (cmp 30, jge over it, signpost 3, return) and the work behind it. - The other arm swaps (eight) came from a search that keeps a change when quick_diff's ratio rises. Visibility, as in UpdateTanner and UpdateArmorer: the original treats updateBuildingSignpostCounter as opaque here, and getBuildingResourceAmountByUid (0x00409330) as an inline body that is not expanded. Text pass (after the changes above), the same listing in quick_diff before and after: states by main's names, hex constants as decimal, the file-scope using lines gone, the (char) casts on the fade countdown and the frame tables dropped (char in main's headers), ++ / -- for the steps of one, the BOOLEnum calls tested by truthiness, const on the locals that are never reassigned, whys above the two ternaries; unitTypeSpecificRestingState by the state's name. Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 93.1 / 82.9 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdateArmorer, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 40dc871 at 26.82%, 27d6978 at 30.95%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. 1. The two death states in the idle-flag idiom, the flag first as the original stores it: if (frame <= 0) { DAT_UnitHasBecomeIdle = 1; gfxNumber = K; } else { gfxNumber = frame + N; } if (DAT_UnitHasBecomeIdle) { logicalState = ULS_REMOVE; } The draft had the last-frame block store logicalState itself and return, with a second store behind the flag test. That made three uses of the constant 3 on the path from the state 3 compare to US_DEATH_01, so the compiler kept 3 in ecx there, and US_DEATH_01's tail differed from the alive-check arm's and was not merged into it. The original has immediates (cmp dx, 3 at 0x00558F9E; mov word ptr [...], 3 at 0x005597CC, 0x0055982E and 0x0055984F) and one shared tail: US_DEATH_01 jumps from 0x005597DD to 0x0055983F. 2. The fade countdown without `(char)` casts (a char in main's header), the calls that return BOOLEnum tested by truthiness, the `x += 1` steps as `x++`, state numbers by their names where UnitState has one. Visibility. Two callees decide the rest, as in UpdateTanner: - updateBuildingSignpostCounter: the original treats it as opaque; UpdateBadBuildingGallows and UpdateBadBuildingDungeon need its body, so this unit's entry does not name it; - getBuildingResourceAmountByUid (0x00409330): behind it the original loads `this` again for the next BuildingsState call (mov ecx, 0xf98520 at 0x00558E8E and at 0x005591B2) while it keeps the unit's offset across it, which is what an `inline` body that is not expanded gives (the same as in UpdateTanner). Text pass (after the changes above), the same listing in quick_diff before and after: engineerManningSiegeStateRef_checkType set to -2, the (char) casts on the frame tables dropped (char in main's header), const on the locals that are never reassigned; unitTypeSpecificRestingState by the state's name, no else behind a return (twice), the comment of state 5 corrected. Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 90.3 / 82.7 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…N_VISIBILITY_UNITS on Units::UpdateTanner, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his draft PR 204; his commits on the file: 714f582 at 37.28%, d9f2f81 at 44.92%, then 974c32f's clang-format), through the forms on our development branches. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, its entry in cmake/function-visibility.txt and getBuildingResourceAmountByUid defined inline in its own file (the commit before the units) it reads 100.0 / 100.0 (reccmp raw / normalised). The text started from his drafts; what changed is listed below. 1. State 9: the cow's ID is an int local, read once, for the test against 0 and for the index. The original reads it once as an int (movsx; cmp eax, ebp; je; imul); the draft read the field twice and tested it as a short. 2. US_DEATH_01 has the last frame first (animationFrame <= 0), as US_DEATH_03, and the states are one if / else-if / else chain whose arms fall out: the else parts of the death states fall out to one place and the later copy is kept, as in UpdateMinerIronFetcher and UpdateMiller. Either change alone does not pay. 3. The fade countdown without `(char)` casts (a char in main's header), the calls that return BOOLEnum tested by truthiness, state numbers by their names where UnitState has one, the orientation against CD_UNSPECIFIED. Visibility. Two callees decide the rest, each in its own way: - updateBuildingSignpostCounter: the original reads the slot and loads `this` again behind it, as an opaque call. UpdateBadBuildingGallows and UpdateBadBuildingDungeon need its body, so it stays on their side of the manifest, and this unit's entry does not name it. - getBuildingResourceAmountByUid (0x00409330): behind it the original keeps the unit's offset in esi (0x0055A216), so it knew the callee writes no globals, but loads `this` again for addResourceToStockpile (mov ecx, 0xf98520 at 0x0055A1CC), so it did not know the callee leaves ecx alone. A plain body visible gives neither reload, an opaque one both; an `inline` body that is not expanded gives exactly this (found on UpdateWoodcutter and UpdateBlacksmith first; the same here and for UpdateArmorer, UpdatePoleTurner and UpdateFletcher). Text pass (after the changes above), the same listing in quick_diff before and after: engineerManningSiegeStateRef_checkType set to -2, the (char) casts on the frame tables dropped (char in main's header), const on the locals that are never reassigned, a why above the ternary; unitTypeSpecificRestingState by the state's name, CD_UPPER_LIMIT for the facing direction's 8. Measured with real builds of this branch on main 830fbd5 (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), each with OPENSHC_FUNCTION_VISIBILITY_UNITS on and off, 0 failures: a small build (458 files, 468 functions: every /GL file of the branch, every .cpp that names Unit::disappearFadeAlphaCountdown or getBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0 down their call trees, and every file of a function-visibility group that touches one of these) and a full build (3,042 files, 3,060 functions). On: 100.0 / 100.0 in both. Off: 92.9 / 83.6 in both. The status line carries the default build's raw number. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the getter UpdateWoodcutter, UpdateFletcher, UpdatePoleTurner, UpdateBlacksmith, UpdateArmorer and UpdateTanner need the bodies of the callees below in the unit they are compiled with; each entry names them at the unit's address, the callees in address order. Every name is already a member of the group that holds hasUnitReachedDestination (the getter through UpdateInnkeeper's, UpdateIronMine's, UpdateEngineer's and UpdateMiller's entries), so the units join that group and no other function leaves the /GL list or sees a body it did not see before. The generator makes 25 wrapper units holding 161 source files (155 on main 830fbd5); the six units are the only new members. No entry names updateBuildingSignpostCounter: the original treats it as opaque in these units, and it stays in the group of UpdateBadBuildingGallows and UpdateBadBuildingDungeon. Each pair measured with quick_diff, the unit compiled with the callee files in front of it (the getter inline) against the unit alone: - UpdateWoodcutter: 0.5923 alone, 0.9991 with the 11 listed. Left out, getBuildingResourceAmountByUid 0.9855; setupUnitSharingTileIDs 0.9965; IncrementAndOptionalUpdateAVValueRelated 0.8172; ConsiderHavingABreakNowUnk 0.9943; SetStateToFreetimeWalking 0.9881; ComputeGoodsProduced 0.9824; checkIfCitizenUnitIsAliveBasedOnState 0.7976; hasUnitReachedDestination 0.9413; setupUnitSharingCurrentTilePosition 0.9965; UpdateWorker_ConsiderTakingABreakUnk 0.9943; commitUnitLocation 0.9965. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState. - UpdateFletcher: 0.5603 alone, 0.9989 with the 10 listed. Left out, getBuildingResourceAmountByUid 0.9167; setupUnitSharingTileIDs 0.9145; IncrementAndOptionalUpdateAVValueRelated 0.8571; ConsiderHavingABreakNowUnk 0.9863; SetStateToFreetimeWalking 0.9897; ComputeGoodsProduced 0.9897; checkIfCitizenUnitIsAliveBasedOnState 0.7894; hasUnitReachedDestination 0.9092; setupUnitSharingCurrentTilePosition 0.9145; commitUnitLocation 0.9145. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState. - UpdatePoleTurner: 0.4075 alone, 0.9988 with the 11 listed. Left out, getBuildingResourceAmountByUid 0.906; setupUnitSharingTileIDs 0.9964; IncrementAndOptionalUpdateAVValueRelated 0.6766; ConsiderHavingABreakNowUnk 0.9644; SetStateToFreetimeWalking 0.7738; ComputeGoodsProduced 0.9391; checkIfCitizenUnitIsAliveBasedOnState 0.8337; hasUnitReachedDestination 0.9686; setupUnitSharingCurrentTilePosition 0.9964; UpdateWorker_ConsiderTakingABreakUnk 0.9798; commitUnitLocation 0.9964. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState. - UpdateBlacksmith: 0.559 alone, 0.9988 with the 11 listed. Left out, getBuildingResourceAmountByUid 0.9917; setupUnitSharingTileIDs 0.9066; IncrementAndOptionalUpdateAVValueRelated 0.8793; ConsiderHavingABreakNowUnk 0.9781; SetStateToFreetimeWalking 0.9864; ComputeGoodsProduced 0.9799; checkIfCitizenUnitIsAliveBasedOnState 0.9751; hasUnitReachedDestination 0.8958; setupUnitSharingCurrentTilePosition 0.9066; UpdateWorker_ConsiderTakingABreakUnk 0.9935; commitUnitLocation 0.9066. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState. - UpdateArmorer: 0.6458 alone, 0.9987 with the 11 listed. Left out, getBuildingResourceAmountByUid 0.9911; setupUnitSharingTileIDs 0.9898; IncrementAndOptionalUpdateAVValueRelated 0.9572; ConsiderHavingABreakNowUnk 0.9701; SetStateToFreetimeWalking 0.9853; ComputeGoodsProduced 0.9598; checkIfCitizenUnitIsAliveBasedOnState 0.8056; hasUnitReachedDestination 0.9185; setupUnitSharingCurrentTilePosition 0.9898; UpdateWorker_ConsiderTakingABreakUnk 0.9866; commitUnitLocation 0.9898. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState. - UpdateTanner: 0.4693 alone, 0.999 with the 9 listed. Left out, getBuildingResourceAmountByUid 0.9896; IncrementAndOptionalUpdateAVValueRelated 0.7855; ConsiderHavingABreakNowUnk 0.9302; SetStateToFreetimeWalking 0.9537; ComputeGoodsProduced 0.9661; checkIfCitizenUnitIsAliveBasedOnState 0.7215; hasUnitReachedDestination 0.7577; changeDestinationByAmount 0.9943; UpdateWorker_ConsiderTakingABreakUnk 0.9573. Not named, leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState, setupUnitSharingTileIDs, setupUnitSharingCurrentTilePosition, commitUnitLocation. Real builds: small and full, as in the unit commits. With the option on the six units read 100.0 / 100.0 and nothing on main 830fbd5 reads differently except the image-layout flip of Menu::Constructor_Menu and Menu::handleMenuItems (98.4 / 97.9 to 100.0, higher). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 3 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 3 of the 7 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 23 — Prefer if-else over ternary
|
The only conflict was the end of cmake/compiler-flags-gl.txt, where both sides added lines; both are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 2, 2026
Merged
…-inline-100 # Conflicts: # cmake/compiler-flags-gl.txt
This was referenced Dec 3, 2026
The only conflict was the end of cmake/compiler-flags-gl.txt, where both sides added lines; both are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
reviewed
Dec 4, 2026
gynt
previously approved these changes
Dec 4, 2026
gynt
approved these changes
Dec 4, 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.
Six more Map::Units update functions from gynt's units branch
reimpl/map-units-updatefunctions(his draft #204), the workshop units that callBuildingsState::getBuildingResourceAmountByUid. Each reads 100.0% raw and normalised with main's function-visibility option on, and less in the default build (see the table). To get there the getter's definition becomesinline, in its own.cpponly, and each unit gets an entry incmake/function-visibility.txt. One header field gets its type (Unit::poleturner_spearOrPike, below). Each unit commit cites gynt's commits on the file and credits him as co-author; the text work began on other development branches of ours, written with Claude Fable 5.2, and the unit commits keep that co-author line.Units::UpdateWoodcutterUnits::UpdateFletcherUnits::UpdatePoleTurnerUnits::UpdateBlacksmithUnits::UpdateArmorerUnits::UpdateTanner"Before" is gynt's own status number on the file (main's status file has 0.0%, Pending, for all six). The default build's numbers are raw / normalised. The status lines carry the default build's raw number with the remark
100.0 with OPENSHC_FUNCTION_VISIBILITY_UNITS on, as main's UpdatePitchman, UpdateEngineer and UpdateDairyFarmer have.Header change
Unit::poleturner_spearOrPike(Unit.hpp, offset 0x3EF):undefined1tochar, in a commit of its own in front of the units. The original reads it signed in both functions that read it:movsx edx, byte ptr [unit + 0x138893b]at 0x0054DCEB (UpdateFletcher) and 0x0055764F (UpdatePoleTurner). The other four instructions of the game with that address are stores of the same two functions (0x0054D9B0, 0x0054E2DC, 0x005573EB, 0x00557BC4). No.cppon main names the field. The size and the name stay (Reimpl/map units updatefunctions #204 uses the name).The getter, and why
inlinegetBuildingResourceAmountByUid(0x00409330) and see its body: behind the call they know that it writes no global (the slot is not read again), but not which registers it keeps, so they loadthisagain for the nextBuildingsStatecall (UpdateTanner at 0x0055A1CC, UpdateArmorer at 0x00558E8E and 0x005591B2, UpdateFletcher at 0x0054DF14). Aninlinedefinition that is not expanded gives exactly that; a plain visible body gives neither reload, an opaque one both. The numbers are in thequick_diffline below.inline(890 instructions against the original's 876), so the file writes the test out.inlinein front of the definition ingetBuildingResourceAmountByUid.cpp, and one comment line.BuildingsState.hppstays as it is. With the option on, the units' group#includes this.cppin its wrapper unit, so the units see the inline body. Files outside the group see what they see today. (An inline body inBuildingsState.hppwould show it to every unit that includes that header; not measured here.).cppincludesBuildingsState.func.hpp, whereMACRO_FUNCTION_RESOLVERinstantiates the getter's resolver. Where that counts as implemented it refers to the function, so the function is emitted from its own file.OPEN_SHC_IMPLEMENTED(x)(src/precomp/CompileMacros.h) istruein the EXE whatever the flag, and the flag in the DLL. The builds below are of the DLL with the resolvers on locally: the function is emitted, the build links, and it reads 100.0% / 100.0%. With its flag off, as committed, nothing in the DLL refers to it and it is not emitted, where a plain definition is (seen by compiling this one file with the DLL's and the EXE's defines, flag off and on). So a DLL built with that resolver off has no 0x00409330 for reccmp to compare; with the resolver on, asenable_local_functions.pysets it, it is there. The EXE was not built, nor the DLL with that flag off. If you want the function emitted there too,inlinewould have to come from a define that only the wrapper units get; not tried, because it adds something toCMakeLists.txtand the generator.cmake/compiler-flags-gl.txt, so its callers on that list see its body in the default build: that is why the full option-off build was made. With the option on, UpdateIronMine, UpdateInnkeeper, UpdateMiller and UpdateEngineer saw a plain body through their entries until now and see an inline one now. All of the getter's callers on main read the same as on main in both modes (the list in Measured).quick_diff, each unit with the callees of its entry in front of it,inlineagainst a plain definition: UpdateTanner 0.999 against 0.9984, UpdateArmorer 0.9987 against 0.9974, UpdatePoleTurner 0.9988 against 0.9982, UpdateFletcher 0.9989 against 0.9983, UpdateBlacksmith 0.9988 against 0.9982, UpdateWoodcutter 0.9991 against 0.9987.The entries
#includes its members (without/GL), and the members leave the/GLlist. All callees the six entries name are already in the group that holdshasUnitReachedDestination(the getter through the entries of UpdateIronMine, UpdateInnkeeper, UpdateEngineer and UpdateMiller), so the six join that group and nothing else moves: no other function leaves the/GLlist, and no other function sees a body it didn't see before.cmake/function-visibility-units.pymakes 25 wrapper units holding 161 source files on this branch, 155 on main 830fbd5: the six units are the only new members.updateBuildingSignpostCounter. The original treats it as opaque in these units;UpdateBadBuildingGallowsandUpdateBadBuildingDungeonneed its body, and their group keeps it.Measured
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed: the data resolvers withtools/reimplementation-control/enable_reimplemented_data.py, the function resolver of every.cppin the build withtools/reimplementation-helper/batch/enable_local_functions.py), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie./GLfile of the branch (the six units included), every.cppthat namesUnit::disappearFadeAlphaCountdownorgetBuildingResourceAmountByUid, the callees of UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher and UpdateBlacksmith that read 100.0% down their call trees, and every file of a function-visibility group that touches one of these: 458 files, 468 functions, 0 failures. Option on: all six 100.0% / 100.0%, as UpdateMiller, UpdatePeasant, UpdatePriest, UpdatePitchman, UpdateEngineer, UpdateDairyFarmer, UpdateInnkeeper and UpdateIronMine. Option off: the six as in the table, the getter 100.0%..cppof main but the three in the note below, all function and data resolvers on, 3,042 files and 3,060 functions on this branch, 3,036 and 3,054 on main, 0 failures. Option on: the branch against main 830fbd5. Option off: the branch on 830fbd5 against main e62246a, because 830fbd5 only adds 24 lines tocmake/function-visibility.txt, which that build doesn't read.UI::Menu::Constructor_Menu(98.4% to 100.0%) andUI::Menu::handleMenuItems(97.9% to 100.0%). Average 99.24% for the branch, 99.24% for main.placeDefensiveStructureTile100.0% / 100.0%,planToBuyWhenLowOnResourceAndSnoozeBuildings100.0% / 100.0%,UpdateIronMine100.0% / 100.0%,UpdateInnkeeper100.0% / 100.0%,UpdateDairyFarm97.9% / 97.9%,UpdatePitchman94.1% / 100.0%,UpdateEngineer85.0% / 100.0%,UpdateMiller100.0% / 100.0%,UpdatePeasant100.0% / 100.0%,getWorkerBlockingStateIfStuck100.0% / 100.0%,UpdateQuarry98.8% / 87.6%,getBuildingResourceAmountByUid100.0% / 100.0%.quick_diffgives the same listing for each file before and after every edit; each commit lists its edits. The last ones were also compared as object code, byte for byte, with the unit alone and with its entry's callees in front of it: the same.style_lint.py) and the status lines: nothing to fix automatically, no errors and 97 notes, all of the kinds below.findBestAttackTileByPathCost,resetTileAndClearMoat,TransformAndRenderPercentage). All the builds above left them out, with their resolvers off. This PR doesn't touch them.What got them to 100%
All six started from gynt's drafts and went through our development branches. The text started from his drafts; each commit lists what changed. In short: every access to the unit goes through
DAT_CurrentUnitSlotID::instance(UpdateWoodcutter, UpdateBlacksmith); arms and early exits stand in the original's order in all six; UpdateTanner's death states fall out of one if / else-if chain and its state 9 reads the cow's ID once; UpdateArmorer's death states use the idle-flag form; UpdatePoleTurner and UpdateFletcher write the copyproducedItemTypeNext = producedItemTypewhere its load stands; UpdateFletcher's wood test is the getter's test written out, because the original has it in place there.Kept as they are
(char)onUnit::engineerManningSiegeStateRef_checkType(UpdateTanner, UpdateArmorer, UpdatePoleTurner): the field holds the signed fade step and is abytein the header (as in Reimplement UpdateCamel, UpdateLady, UpdateMother and UpdateFireEater from gynt's units branch, under /GL (100%) #515, Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516 and Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518).(short)stores intotargetID_OR_targetBuildingID,resourceToDeposit, the cow's slot andworkplaceBuildingTilePosition, as main's unit functions write them.(ResourceType)onproducedItemTypeNext, aResourceTypeShortpassed to aResourceTypeparameter.animationCycleNumberHasJustIncrementedis aBOOLEnum;buildingIsAccessible,canBuildingStoreTheAmount,getArmoryWithSpaceLeftandupdateBuildingSignpostCounterreturnint(oruint) and the flagsisDisappearingUnk,goToRallyPointandkilledFlagUnkare two-byteshortfields, where a four-byteBOOLEnumwould not fit the layout;DAT_UnitHasBecomeIdleis anundefined4, compared with 0 as on main.US_STATE_3Unkin UpdateFletcher's call of ConsiderHavingABreakNowUnk: the parameter is aUnitState,USF_GOING_TO_WORKPLACE(the same 3) would need a cast.treeandwoodcuttersHutat the top: the original reads both in front of the state tests (0x0054C722, 0x0054C729); declared at their first uses, or the field written out, the code differs.cachedState, notstate(0x0055A216): the original has it.updateTickTrackeronly inside the resource test (0x00557AB4), and drops the goods when setDestinationForUnit fails (0x00557CD3): the original has both.resourceToDeposit = 0twice in UpdatePoleTurner's idle state (0x005572E6, 0x00557367) and in UpdateTanner's idle and slaughtering states (0x00559997, 0x00559A97; 0x00559EF8, 0x00559F4C): the original has it.field_0x2ac = 1(0x0055A233 to 0x0055A247), unlike the other five units': the original has none.destinationNeeded > 1in UpdateFletcher (0x0054DD7D, 0x0054DDC4), as main's UpdateOx has it.field_0x58(Unit::field_0x58is ashort, the hint comes fromSoundEffectsHelperData1), casts on fields we list here, and the header change (above).Names on main these files show (follow-ups, not changed here)
Unit::poleturner_spearOrPikeis the amount of wood the weapon needs: 1 for a spear and 2 for a pike (UpdatePoleTurner), 2 for a bow and 3 for a crossbow (UpdateFletcher).Building::field_0x2d4on the woodcutter's hut gets the length of the path to the tree (UpdateWoodcutter).RT_PARTIALSTONE(5) holds the hides in the tanner's workshop (UpdateTanner).Frames_Shared_UnitClimbingUp.drunkardis also the tanner's melee table.US_JESTER_ROAM_TOfor the fade state andUS_AIM_WEAPONUnkfor a finished piece.UnitPropertiesDefinedDataby the state that reads them:field_0x5480,field_0x54a8,field_0x54e0,field_0x550c,field_0x5544(tanner, idle substates 102 to 105 and the rest),field_0x558c(slaughtering);field_0x55c4/field_0x5674(armorer, idle substate 0 / other);field_0x56fc,field_0x5748,field_0x577c,field_0x57fc(pole turner, idle 102 / 103 / 104 / other);field_0x41e4,field_0x4208,field_0x4234,field_0x4260(fletcher, idle substates);field_0x40b4/field_0x4144(blacksmith, idle),field_0x419c(melee);field_0x3ff4(woodcutter felling),field_0x4020/field_0x404c(chopping),field_0x3d70tofield_0x3f5c(resting),field_0x4070(melee);field_0x6d4(worker death frames, armorer and pole turner).Left out
Other PRs
bool) touch none of these files.🤖 Generated with Claude Code