Repository navigation
Reimplement UnitsState::setDestinationForUnit at 100%, from gynt's text on main - #547
Merged
Merged
Conversation
UnitsState::setDestinationForUnit from 71.1% / 68.9% (option off; 71.3% / 67.3% on) to 100%. The text is gynt's, on main since sourcehold#238 (8fa4bea). His commits on it, newest first: f3c6879 (71.3%), eb81a28, 86bd3a0, 154d302, f601aa4, 305507f. The status line still had 64.2% from 154d302; his later commits did not update it. Five edits: - The map test is a flag (`_onMap`), tested once. The original falls through into its exit after the third test and goes on with `jne 0x0053D439`; with one `||` condition MSVC jumps to the exit with `je` and puts it out of line. - In the two climb branches (under `climbIsIllegal != 0`, and under `allAssassinsUnk == 0 && reusePathingInfo == 0`) the register call and its -1 exit stand inside `if (climbDataID != 0)`, with the `climbDataID == 0` exit as its `else`. The original has one despawn block, at the first branch's -1 exit (0x0053D635), and the other exits jump into it; with the `climbDataID == 0` exits first in the text MSVC puts that block at the end of the function. - The last test is inverted (`<= 0` becomes `> 0`): the success stores come first, inside `if (_pathPlanSize > 0)`, and the despawn exit after them. With the exit first in the text its unitID load took edx and stayed a stub of its own (`push edx; jmp`); the original's exit jumps into the first branch's block (`jle 0x0053D635`). In the success block the ladder exit's x and y are stored after the destination tile, as in the first success block. - All seven despawn exits clear climbIsIllegal before allAssassinsUnk. Main's text had the other order in all seven; the original's shared block stores climbIsIllegal first (0x0053D63E). quick_diff can't see the order of two global stores, so only the real build showed it. - The file is off the /GL list: the original loads ecx again before every call, and with /GL MSVC drops the load before fillMemory_ByteValue (0x0053D729) because it sees that copyData keeps ecx. No behaviour change against main's text: the map test is the same condition by De Morgan, the inverted tests keep each branch's code, and the swapped stores write different fields before the same call or return. quick_diff: 0.7747 on main's text, 1.0000 with the edits (270 instructions as the original). Fewer edits stay below: the inverted test alone 0.8191, with the flag 0.8885, with the if / else but no flag 0.9234. After the builds: gynt's three block comments are // lines, and one // line each says why the flag, the two else exits and the inverted last test are needed. The file compiled alone gives the same object as the built text's (every section but .debug$*: same bytes and relocations). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 1 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 24 — Declare variables upon first use
|
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.
Brings
UnitsState::setDestinationForUnit(0x0053D3D0), merged below 100% in #238, to 100%. The body is gynt's; the commit says what changed and credits him as co-author. It reads 100.0% / 100.0% (reccmp raw / normalised) withOPENSHC_FUNCTION_VISIBILITY_UNITSoff and on. The file comes offcmake/compiler-flags-gl.txt. No header change. The status line still had 64.2% from gynt's 154d302 (his later commits did not update it); it now says 100.0%.setDestinationForUnitif/else, the last test inverted, the despawn exits' store order, off the/GLlistWhat matched it
Five edits. The first three are measured in
quick_diff(0.7747 on main's text, 316 instructions against the original's 270; 1.0000 with them, 270 instructions)._onMap), tested once. The original falls through into its exit after the third test and goes on withjne 0x0053D439; with the test as one||condition MSVC jumps to the exit withjeand puts it out of line.if/else. In the two climb branches (underclimbIsIllegal != 0, and underallAssassinsUnk == 0 && reusePathingInfo == 0) the register call and its-1exit stand insideif (climbDataID != 0), and theclimbDataID == 0exit is itselse. The original has one despawn block, at the first branch's-1exit (0x0053D635), and the other exits jump into it; with theclimbDataID == 0exits first in the text MSVC puts that block at the end of the function.<= 0becomes> 0). The success stores come first, insideif (_pathPlanSize > 0), and the despawn exit after them. With the exit first, itsunitIDload took edx and stayed a stub of its own (push edx; jmp); in the original it jumps into the first branch's block (jle 0x0053D635). In the success block the ladder exit's x and y are now stored after the destination tile, as in the first success block; main's text stores the y before it.climbIsIllegalbeforeallAssassinsUnk. Main's text had the other order in all seven; the original's shared block storesclimbIsIllegalfirst (0x0053D63E).quick_diffcan't see the order of two global stores, so only the real build showed it./GLlist. The original loads ecx again before every call. With the file on the/GLlist MSVC sees thatcopyData, on the list too, keeps ecx, and drops the load beforefillMemory_ByteValue(0x0053D729).computeLadderClimbPath, which makes the same two calls and reads 100% on main, is not on the list either.The first real build of the first three edits (option off, the file still on the list, main's store order) read 98.9% / 95.9%, with exactly the last two differences; with all five the function reads 100%.
Fewer edits stay below 100% in
quick_diff: the inverted test alone on main's text reads 0.8191, with the flag 0.8885, with theif/elsebut no flag 0.9234.No behaviour change against main's text: the map test is the same condition by De Morgan, the inverted tests keep each branch's code, and the swapped stores write different fields before the same call or return.
Kept as they are
//lines) and the order of the stores in the first success block. One//line each above the flag, the twoelseexits and the inverted last test says why the plainer form loses the match._pathPlanSizeis assigned in both arms and read after them, so declaring it where it is first assigned meansint const _pathPlanSize = reusePathingInfo != 0 ? … : …;with aMACRO_CALL_MEMBERcall in each arm. That compiles to the same object code (file compiled alone and compared), but the guide prefersif/elseover?:(SG 23), so main's form stays._onMapis abool;reusePathingInfo, the counts and the fields areints compared with0.this->units[unitID]throughout, as on main.Measured
Setup: the bundled MSVC1400-SP1 against the Steam
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. The full builds are of main 40cbb1c and of this branch on it. The small builds are of main 643f78b and of this branch on that, before it was rebased onto 40cbb1c, which changes onlyNeighbourFlagsGlobalAsm.hpp(theMACRO_ASM_JZ_NEARmacro and its comment); no file insrcincludes that header.prepareProjectileTarget.cppcompiles, and leaving outfindBestAttackTileByPathCostandresetTileAndClearMoat(they don't compile on main until Reimplement 66 TroopValueState functions at 100% #501 and Reimplement 67 Map::TileMapState functions (batch 2) #396) andTransformAndRenderPercentage(on our list from before Reimplement 59 TextManager and UserTextHandler functions at 100% #509): 3,102 files, BUILD_OK, 3,120 functions compared. OnlysetDestinationForUnitreads differently, 71.1% / 68.9% -> 100.0% / 100.0%, besideshandleMenuItemsandConstructor_Menu(97.9% / 91.4% and 98.4% / 95.2% on main, 100.0% / 100.0% here), which go between these two readings from one build to another with their files unchanged; we have seen it in most of our full builds since 2026-11-29. The branch built was b02b1a376c; the head differs from it in comments only./GLfile of main, every.cppthat callssetDestinationForUnit,updateUnitsoracquireShootTarget, the callee closures and every file of a function-visibility group that touches them; main'sprepareProjectileTarget.cppleft out: main's header declares itvoidsince d134c77 while the.cppstill returnsint, and our Reimplement UnitsState::prepareProjectileTarget at 100%, from gynt's text on main (one header line each in two files) #540 changes the.cpp): BUILD_OK and 0 failures in all four.setDestinationForUnitreads differently, 71.1% / 68.9% -> 100.0% / 100.0% (602 compared).setDestinationForUnitreads differently, 71.3% / 67.3% -> 100.0% / 100.0% (602 compared).//lines and the four lines on the plainer forms were added. The file compiled alone gives the same object as the built text (every section but.debug$*: same bytes and relocations, in the same order)._pathPlanSize(SG 24); answered under "Kept as they are".Other PRs
No open PR touches
setDestinationForUnit.cpp. Every open PR that changescmake/compiler-flags-gl.txtor the status file merges with this branch exactly as it merges with main (git merge-treeagainst both): ours (#536, #540, #544 and the drafts #313, #327 and #328) cleanly, and those that already conflict with main incompiler-flags-gl.txt(#234, #241, #275, #501, #527, #528 and #529) in the same files and no others. #540 (prepareProjectileTarget) is why that file is left out of the small builds above.🤖 Generated with Claude Code