Repository navigation
Reimplement UpdateShield, UpdateHunter, UpdateAppleFarmer, UpdateJester and UpdateSlave from gynt's units branch (100%, three with OPENSHC_FUNCTION_VISIBILITY_UNITS on) - #537
Merged
Conversation
Units::UpdateShield at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: f791380 at 49.29%, cf15f54 at 52.39%, 6565c1b, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.0% there, on main 1f87a13). What the match needed, against the draft: - The state it starts in is picked by an if / return pair, as in main's UpdateBatteringRam (sub / neg / sbb / and at 0x0053C382); the draft had a ternary. - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The scan for engineers tests its six conditions as six `if (...) { continue; }` statements, the counts are cleared with memset, the distances compare with the engineer first, and the tests read `> 16` and `< 1`, as the original compares. The tick test reads `^ 8` where the draft had `^ 0xfffffff8`, the same value under `& 15`. - The AI check's loop and the two blocks that send the engineer to work are loops of one over manningEngineerRef and engineerIDs[9][1]: the first is a loop in the original too (0x0053C4C3), the others make it compute the unit's offset anew (0x0053C4D9, 0x0053C744), the start of a loop the compiler unrolled. Written out with index 0 (the first as a do / while (0), as its tests break out of it), they read 0.7650, 0.9848 and 0.9913 in quick_diff, against 0.9978. - The search for the capturing owner is a for loop from 1 to 8 with a found flag, the source form that matches (the binary has no flag: the loop at 0x0053C6A7 returns at its end, 0x0053C6B4), and, the last step, it has a local of its own that is copied behind the capture, as in main's UpdateBatteringRam, where the parked text searched in the local that holds the shield's owner. With it the scan's bound stays in ebx (loaded at 0x0053C57F, compared at 0x0053C682): 0.9859 -> 0.9978 in quick_diff with the /GL callees in the unit (the one line left, 0xffff against -0x1, is the same instruction). The bound read as the global itself instead of through a local came first (0.9827 -> 0.9859). - createTribe gets the owner of units[searched], where searched is the counter the scan left behind (0x0053C70F); the draft passed the shield's own owner. The same call is in main's UpdateBatteringRam, and so is the next one: addUnitToTribe gets the tribe as unitID and the shield as tribeID (0x0053C736), with a fixme for each. compiler-flags-gl.txt gets UpdateShield.cpp only: the two callees it has to see are on main's list already (quick_diff 0.5457 without hasUnitReachedDestination, 0.8707 without deselectUnit, 0.5152 without both). On main, this round's text pass: main's name for state 108, BOOLEnum calls by truthiness, `++`, `const` on locals, the fade countdown without its cast, UpdateBatteringRam's names and comments for the scan and its if / return pair for the first state. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them. 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::UpdateHunter, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 76bb533 at 48.51%, 9f9546f at 52.15%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (95.3% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry in this branch's last commit; 96.3% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns; the shooting state keeps its closing return. - The shooting state has the "look for another deer, or go home" block once in the arrow part, behind a flag the arrow sets, and once behind it (0x0054FF45, 0x0054FF71). The draft had it twice in the arrow part. The flag, arrowFired, is the source form that matches: the binary has none, four tests jump to 0x0054FF45. - The early exits go the original's way round: the other hunter's uid test, "the deer is gone" and "the deer is within 20" first when chasing, the walk to the post with the failed setDestinationForUnit as the else arm. - The substate set when the hunter gets back to his post is (mapTimeInTicks & 1) + 2 with no cast (0x00550529), and the two height sums of the shot have the terrain height first. What the option is for: the original knows ten of its callees and treats two, updateBuildingSignpostCounter and getResourceCountThatCanBeDeposited, as opaque (it reads the slot again behind them). Both are on main's /GL list, so the default build sees their bodies: quick_diff reads 0.9857 with all /GL callees in the unit, 0.9991 with the ten only, where the one line left, 0xff against -0x1, is the same instruction. With the option on the two are in other wrapper units. compiler-flags-gl.txt gets UpdateHunter.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names (UnitState_Hunter) for the hunter's states 0 to 11 and 106, through state.hunter (as main's UpdatePitchman and UpdateWheatFarmer do for theirs), and for the resting state (USH_RESTING_7); 108 to 111, 113 and 121 keep the shared US_ names; DNE_UNKNOWN_2 and RT_MEAT; BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, the fade step stored as -2, no `(char)` on the frame tables and the fade countdown, unused `using` lines dropped, and the local for the slot in front of commitUnitLocation dropped. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 96.3 / 86.9. 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::UpdateAppleFarmer, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 69e0814 at 43.32%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.1% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry as this branch's last commit leaves it; 94.6% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - The branches of four states the original's way round, read off it one basic block at a time: going to the workplace and waiting for a tree (the call that works first), the granary walk (its failure path written out), the deposit (one local for getResourceCountThatCanBeDeposited's result). - The last steps: every access reads the unit through DAT_CurrentUnitSlotID::instance (our parked text still indexed some through the draft's `unitID` and one state through a local for the slot, across a setDestinationForUnit call, which is not a named callee and stays opaque), and the waiting state stores the slot into the orchard's workers[] before it reads the frame, as main's UpdateDairyFarmer does. In quick_diff with the group's callees in the unit 0.9899 -> 0.9984 (the one line left, 0xff against -0x1, is the same instruction). Only together: 0.9844 without the second step, 0.9891 with the state's local kept. What the option is for: the original reads the slot again behind getResourceCountThatCanBeDeposited, which is on main's /GL list, so the default build sees its body and keeps the register (quick_diff 0.9820 with it, 0.9984 without). compiler-flags-gl.txt gets UpdateAppleFarmer.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names for states 108 and 121 and for DNE_UNKNOWN_2, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown, the unused `using` lines and one unused include dropped, USAF_WAITING_1 for the resting state and the farmer's own state type for the local. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 94.6 / 89.6. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Units::UpdateJester at 100%, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 146023d at 42.00%, 93b5ce0 at 50.14%, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (94.1% there). What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The states are one if / else-if chain whose arms fall out of it, where the draft had a block per state that returns, and the first death state tests "the animation is over" first. - gfxBase is declared at the function's top (with a comment): the original zeroes a register for it in the first block and keeps the owner in the frame (0x0056E1C7). - The random roll is read once into an int local and compared twice (0x0056E336). The text stores the wandering state in two arms; the original has the store once (0x0056E3AF) and so has ours, the compiler merges the two arms (one arm for both cases loses the match: quick_diff 0.9950 and 0.9894 against 0.9986). - The last steps, on this main: two locals our parked text had for the slot are gone, one around changeDestinationByAmount in the walk-up state and one in front of commitUnitLocation in the fade state. With the callees' bodies visible they cost (quick_diff with the /GL callees in the unit 0.9612 -> 0.9936 -> 0.9958). And the walk-up state tests `movementSpeed < 1`, a compare with the constant 1 the original holds in bp, where the draft had `<= 0`, the same values (0.9958 -> 0.9986; the one line left, 0xff against -0x1, is the same instruction). compiler-flags-gl.txt gets UpdateJester.cpp only: the eight callees it has to see are on main's list already (quick_diff without each: checkIfCitizenUnitIsAliveBasedOnState 0.8217, changeDestinationByAmount 0.8870, hasUnitReachedDestination 0.9627, makeUnitStopWalkingByClearingPathProgressState 0.9859, hasTunnelerNotFinishedDigging 0.9944, commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9958 each; 0.5465 without any). On main, this round's text pass: main's names for states 2, 3 and 108, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, decimal constants, the fade step stored as -2, no `(char)` on the frame tables and the fade countdown and no `(byte)` on the random number, unused `using` lines and one unused include dropped. The quick_diff listing is the same before and after it. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. It reads 100.0 / 100.0 in all of them. 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::UpdateSlave, from Gynt's draft on sourcehold's reimpl/map-units-updatefunctions (his commits on the file: 1f2f3bf at 43.44%, cfa098f at 49.88%, 6565c1b, 8ca7861 (the file again, whole) and the style commit 974c32f), through the forms on our development branches, where its history is (87.4% there). 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on, with its entry as this branch's last commit leaves it; 91.7% in the default build, so the status line carries that number, as UpdatePitchman's does. What the match needed, against the draft: - Every access reads the unit through DAT_CurrentUnitSlotID::instance; the draft's local copy `int unitID` is gone. - The fill-moat branch counts the moat's countdown down first, then sets the targeting type, on every path (in the source, the path where setXYBasedOnMoatID returns 0 has the two the other way round, as main's UpdateEngineer does; the other order loses the match, quick_diff 0.9710 against 0.9792). The moving state tests "delay running" first; its moat branch and the digging walk go the original's way round. - The last steps, on this main (quick_diff with the group's callees in the unit, each on the one before): - the parked text's local for the slot across changeDestinationByAmount is gone, the dig state's two frame arms are the other way round, and the unit on the dig tile is read once into a local, as in main's UpdatePikeman (0.9555 -> 0.9654); - state 0 ends in a chain of three arms whose last two store the same state, as in main's UpdateEngineer: the original branches on 400 only (0x00571EFD), a two-way if / else and an early return for the 400 arm become a setcc instead (0.9683), and 0.9654 -> 0.9764 for the chain on the earlier text. The 96 of the middle arm is UpdateEngineer's number, by analogy; the original has no 96 here. - the moat's owner is read through a local for returnOwnedMoatAtTile's result (0.9764 -> 0.9792). What is left of the 0.9792 is how quick_diff spells constants, two-global sums and the timeGetTime import. - `(int)` on the tick sum in front of `% 40`: the original divides signed (cdq, idiv), as in main's UpdatePikeman; the draft's remainder is unsigned, which differs once the sum passes 2^31. What the option is for: getBuildingFlammabilityFactor is on main's /GL list, so the default build sees its body, and the original treats it as opaque (quick_diff 0.9284 with it, 0.9792 without). compiler-flags-gl.txt gets UpdateSlave.cpp, as it has UpdatePitchman.cpp. On main, this round's text pass: main's names for states 2, 104, 105, 108 and 124 and for CD_UNSPECIFIED and L_MOAT, BOOLEnum calls by truthiness, `++` / `--`, `const` on locals, no `(char)` on the frame tables and the fade countdown and no `(short)` where main's UpdatePikeman has none, the string's text above its pointer, one unused include dropped, CD_SOUTH for the rally's facing, an else-if and one else less around the two returns. The quick_diff listing is the same before and after it. The compares with -1 (0.9693 with >= 0), the two closing stores of the dig state written on both paths (0.9622 when written once), and the US_APPEAR stores of the sheet offset and the speed in both arms (0.9759 to 0.9782 hoisted) are measured, with comments in the text. Measured with real builds (bundled MSVC1400-SP1, function and data resolvers on locally, reccmp raw / normalised), on main 830fbd5: the small build of this branch's head (503 files, 513 functions: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the five units, the fourteen of sourcehold#515, sourcehold#516, sourcehold#518 and sourcehold#533 and UpdatePriest with their callee closures (UpdateSlave's without playVictory2BikFromPlayerToPlayer's, which doesn't link in a small build), two callers of standUpIfSeated and every file of a function-visibility group that touches them), once with OPENSHC_FUNCTION_VISIBILITY_UNITS off and once with it on, BUILD_OK both. The full builds (3,041 files, 3,059 functions: every .cpp but main's three that don't compile, once off and once on) were made before the last text edits; quick_diff gives the same listing of every file before and after them. With the option on it reads 100.0 / 100.0, with it off 91.7 / 66.3. 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>
…, UpdateAppleFarmer, UpdateJester and UpdateSlave New entries for UpdateShield, UpdateHunter and UpdateJester; UpdateAppleFarmer's and UpdateSlave's, which main had before the files existed, each name two more callees. All name only callees that are already members of the group that holds hasUnitReachedDestination, so the five units join that group's wrapper unit and nothing else moves: no other function sees a body it didn't see before or loses one. Each caller-callee pair is measured as sourcehold#491's were (quick_diff, the unit's file with the callee files pasted in front of it, against the unit alone). The callees tried are the group's members that the unit calls directly or through another member it calls; one is named when leaving it out lowers the ratio, and the named set reads what the whole set reads: - UpdateShield 0.5152 alone, 0.9978 with its two: without hasUnitReachedDestination 0.5457, deselectUnit 0.8707. - UpdateHunter 0.4887 alone, 0.9991 with its ten: without IncrementAndOptionalUpdateAVValueRelated 0.6953, checkIfCitizenUnitIsAliveBasedOnState 0.9004, hasUnitReachedDestination 0.9201, ComputeGoodsProduced 0.9840, SetStateToFreetimeWalking 0.9880, UpdateWorker_ConsiderTakingABreakUnk and ConsiderHavingABreakNowUnk 0.9907 each, commitUnitLocation, setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs 0.9929 each. Not named: makeUnitStopWalkingByClearingPathProgressState (no change). - UpdateAppleFarmer 0.5793 alone, 0.9984 with its seven: without checkIfCitizenUnitIsAliveBasedOnState 0.8558, IncrementAndOptionalUpdateAVValueRelated 0.8580, ComputeGoodsProduced 0.8918, hasUnitReachedDestination 0.9408, SetStateToFreetimeWalking 0.9891; new in the entry, UpdateWorker_ConsiderTakingABreakUnk and ConsiderHavingABreakNowUnk, 0.9713 each. Not named: makeUnitStopWalkingByClearingPathProgressState (no change). - UpdateJester 0.5465 alone, 0.9986 with its eight: the numbers are in its commit. - UpdateSlave 0.5410 alone, 0.9792 with its three: without hasUnitReachedDestination 0.5245; new in the entry, xyAreValid 0.9173 and changeDestinationByAmount 0.9764. On top of the named callees, each /GL callee outside the group that the unit calls was tried one at a time, without its own callees: only updateBuildingSignpostCounter (UpdateHunter 0.9933), getResourceCountThatCanBeDeposited (UpdateHunter 0.9915, UpdateAppleFarmer 0.9820) and getBuildingFlammabilityFactor (UpdateSlave 0.9284) change a ratio, and all lower it. Full build of every file with the option on (3,041 files, 3,059 functions, BUILD_OK, 0 failures), against main 830fbd5's tree built the same way (3,036 files, 3,054 functions): nothing on main reads differently, and the five units read 100.0 / 100.0. It was made before the last text edits of the five units; quick_diff gives the same listing of every file before and after them. The generator makes 25 wrapper units holding 160 source files (155 on main): the five units join the group that holds hasUnitReachedDestination, and no other file changes group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Dec 1, 2026
This was referenced Dec 1, 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.
Five more Map::Units update functions, from gynt's units branch
reimpl/map-units-updatefunctions(his draft #204). UpdateShield and UpdateJester read 100.0% in the default build. UpdateHunter, UpdateAppleFarmer and UpdateSlave read 100.0% with main's function-visibility option on, as UpdatePitchman and UpdateEngineer (#514) and UpdateDairyFarmer (#513) do, and 96.3%, 94.6% and 91.7% in the default build: each has to see some callees' bodies and must not see one (UpdateHunter: two,getResourceCountThatCanBeDepositedandupdateBuildingSignpostCounter) that main's/GLlist shows it. Their status lines carry the default build's number with the remark main uses for such units. With the option on all five read 100.0%. Each commit cites the commits of gynt's that measured the file and those that only touched its text (8ca7861, 2026-10-27, adds all five files whole; 6565c1b touches only UpdateShield and UpdateSlave), lists our steps on it, and credits him as co-author. All five went through our development branches; Claude Fable 5.2 worked on four of them (not UpdateAppleFarmer), and those commits keep its co-author line. One more commit adds the entries tocmake/function-visibility.txt;cmake/compiler-flags-gl.txtgains five lines, one per unit, in the units' own commits. No header change.Units::UpdateShieldUnits::UpdateHunterUnits::UpdateAppleFarmerUnits::UpdateJesterUnits::UpdateSlaveRaw / normalised where two numbers stand. "Before" is the status of gynt's last measured commit on each file; his later commits on them (6565c1b on UpdateShield and UpdateSlave only, 8ca7861, 974c32f) were not measured.
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 (a86aceb03) with--resolve-wrapped-calls --ignore-security-cookie. Normalised is main'sreccmp_report.pyfigure, which ignores call and tail-jump targets and resolver addresses.quick_difflisting, so nothing in them is expected to change): every.cppof this branch on main 830fbd5 but the 3 in the note under Other PRs, all function and data resolvers on, built once with the option off and once with it on: 3,041 files and 3,059 functions, BUILD_OK and 0 failures each, against main 830fbd5 built the same way (3,036 files, 3,054 functions; its option-on build is the one made for cmake: function-visibility.txt entries for UpdatePriest, UpdatePeasant and UpdateMiller #535, on the same tree).cmake/function-visibility-units.pymakes 25 wrapper units holding 160 source files (155 on main): the five units join the group that holdshasUnitReachedDestination, and no other file changes group.UI::Menu::handleMenuItems(97.9%, 100.0% in main's build) andConstructor_Menu(98.4%, 100.0%). Their code is unchanged: reccmp names the constant 0x11000000 they compare with after whatever of ours lands at that address, here a resolver's initialiser, so they flip with the image layout (in Reimplement UpdatePeasant and UpdateMiller from gynt's units branch, under /GL (100%) #533's builds they flipped the other way). The five read as in the table. Average over all functions of the build, raw: 99.34% here, 99.35% on main./GLfile of main, every.cppthat readsUnit::disappearFadeAlphaCountdown, the five units, the fourteen of 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, Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518 and Reimplement UpdatePeasant and UpdateMiller from gynt's units branch, under /GL (100%) #533 and UpdatePriest with their callee closures, UpdateSlave's withoutplayVictory2BikFromPlayerToPlayer's, which doesn't link in a small build, two callers ofstandUpIfSeated, and every file of a function-visibility group that touches them), 0 failures in both modes. The five read as in the table, and the fourteen and UpdatePriest read 100.0% / 100.0% in both modes.quick_diff(the group's callees pasted in front of the unit, resolvers as a real build has them) gives the same listing for each file before and after every edit, the last ones included.style_lint.py): nothing to fix automatically, no errors and 60 notes, all of the kinds below.What got them to 100%
The text started from his drafts; each commit lists what changed, with the original's addresses. The last steps, on this main, are:
changeDestinationByAmountandcommitUnitLocation, UpdateSlave aroundchangeDestinationByAmount: callees our build sees now, and with the bodies visible the plainDAT_CurrentUnitSlotID::instancereads higher (UpdateJester 0.9612 -> 0.9958 inquick_diff, with its commit; UpdateSlave's went in the same step as the next form, 0.9555 -> 0.9654). UpdateAppleFarmer's spanned asetDestinationForUnitcall, which is not among its named callees and stays opaque, so that is no such case: the global everywhere reads 0.9984, with that local kept 0.9891. UpdateHunter's was neutral and went too.movementSpeed < 1and the local for UpdateSlave's moat index were read off the listing.The option and the entries
getResourceCountThatCanBeDeposited, UpdateHunter also behindupdateBuildingSignpostCounter, and UpdateSlave treatsgetBuildingFlammabilityFactoras opaque. All three callees are on main's/GLlist, so the default build sees their bodies. With the option on, the first two are in wrapper units of their own callers and the third is a/GLfile that a unit in a wrapper doesn't see.hasUnitReachedDestination(UpdateShield 2, UpdateHunter 10, UpdateJester 8). Main's entries for UpdateAppleFarmer and UpdateSlave, which the generator skipped while the files didn't exist, name two more each (ConsiderHavingABreakNowUnk,UpdateWorker_ConsiderTakingABreakUnk;xyAreValid,changeDestinationByAmount). So five units join that group's wrapper unit, and no other function sees a body it didn't see before or loses one. The commit gives what each named callee reads when left out, and which others were tried.Kept as they are
int dx;/int dy;without a value and twofor (; ...)loops (UpdateShield), as in main's UpdateBatteringRam:createTribereads the scan's counter after the loop (the original passes the owner ofunits[maxUnitCount], not the new owner; afixme:says so), and the new owner is used after its search.addUnitToTribe(newTribe, <slot>)there passes the tribe asunitIDand the shield astribeID, as the original does (0x0053C736); afixme:says so, as in UpdateBatteringRam.(char)onengineerManningSiegeStateRef_checkType(UpdateHunter, UpdateJester, UpdateSlave twice): the field holds the fade step, so the tests read it signed. It 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, Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518 and Reimplement UpdatePeasant and UpdateMiller from gynt's units branch, under /GL (100%) #533.(short)stores of the slot, of building, tree and unit indices and ofComputeGoodsProduced's result into short fields, as main's unit functions write them.(int)on the tick sum in UpdateSlave's% 40, as in main's UpdatePikeman: the original divides signed.intcalls compared with 0 (buildingIsAccessible,updateBuildingSignpostCounter,findNearestShootableDeer,setXYBasedOnMoatID,getBuildingFlammabilityFactor), and the two-byte flags andDAT_UnitHasBecomeIdle(undefined4) compared with 0, as main does.advanceMoatDigProgressandremoveMoatare compared with 1 in UpdateSlave, as in UpdatePikeman, with a comment.moat > -1(UpdateSlave, twice), as in UpdateEngineer: the original compares with -1, and>= 0loses the match.USH_WAITING_8:> 1where it enters,>= 2where it leaves): made the same, either way, the listing differs (0.9767 and 0.9960 against 0.9991).BOOLEnum/boolfields and locals:animationCycleNumberHasJustIncremented,isMatchingSpeed, and the localsarrowFired(UpdateHunter) andfound(UpdateShield).arrowFiredandfoundare not flags in the binary (four tests jump to 0x0054FF45; the loop at 0x0053C6A7 returns at its end), they are the source form that matches.UnitState_Hunternames throughstate.hunter, and the resting state isUSH_RESTING_7, as in UpdatePitchman and UpdateWheatFarmer; 108, 109, 110, 111, 113 and 121, which that enum doesn't name, keep theirUS_names.Unit::field_0x2ac,field_0x32d,field_0x37e,field_0x3bc,field_0x3f4,field_0x58), for which we have nothing better yet.Unit::field_0x58is ashort; the checker's BOOLEnum hint for it comes from another struct.Differences from the draft
For all five we compared the operators and literals of every test against a number with gynt's drafts; line by line we read only UpdateShield and UpdateSlave. These differ, as the original has it:
units[searched].ownertocreateTribeas its owner argument (0x0053C70F), the draft the shield's own owner; and it tests^ 8where the draft had^ 0xfffffff8, the same value under& 15.% 40is a signed remainder (cdq, idiv); the draft's was unsigned.The rest are the same tests written the other way round with their arms exchanged, BOOLEnum calls tested by truthiness, hex constants in decimal,
<= 0as< 1,> 1as>= 2, and UpdateSlave's extra> 96arm, which stores what the arm below it stores.Names on main these files show (follow-ups, not changed here)
UpdateHunter calls
BuildingsState::setBuildingToAppleFarmfor the hunter's post in his fade state, so that function is not only the apple farm's.The frame tables (UnitPropertiesDefinedData) by the state that reads each; renaming them is a header change, so they stay as they are here:
field_0x3984/field_0x3a1c/field_0x3a9c/field_0x3b5cfield_0x3c6c/field_0x3c94USH_WAITING_8(substates 0 / 1)field_0x3d08/field_0x3d2cfield_0x4f40field_0x5ec0field_0x5ee4/field_0x5f08/field_0x5f34field_0x5ee4is his melee attack toofield_0x1dd0/field_0x1df8field_0x2538fixme_integerArraySlave5/fixme_integerArraySlave6US_STATE_2Unk(odd / even slot)field_0x764/field_0x824/field_0x7c4US_DEATH_01/US_DEATH_03/ the three stone deaths)Other PRs
getBuildingResourceAmountByUid) add entries elsewhere incmake/function-visibility.txt; Reimplement UpdateTanner, UpdateArmorer, UpdatePoleTurner, UpdateFletcher, UpdateBlacksmith and UpdateWoodcutter from gynt's units branch, 100% with OPENSHC_FUNCTION_VISIBILITY_UNITS on #536 also adds lines at the end ofcmake/compiler-flags-gl.txt, where this one does, so the second of the two to merge needs a small merge there. Keep all the lines.findBestAttackTileByPathCost,resetTileAndClearMoat,TransformAndRenderPercentage). The builds above left them out, with their resolvers off. This PR doesn't touch them.🤖 Generated with Claude Code