Repository navigation
UI: the GM file loader and the lobby's map sort at 100% - #439
Open
kotijekriv wants to merge 2 commits into
Open
kotijekriv wants to merge 2 commits into
kotijekriv wants to merge 2 commits into
Conversation
TextureRenderCore::loadGMFile. gynt's drafts: 071726e at 77.8% on sourcehold's reimpl/UI-Rendering, and 84.5% in the status line of his fork's reimpl/UI-Rendering-development (63cc49f); the newest commit on the file, 15e5712, is on his fork's reimpl/UI-MenuItems-development. Our draft d29d51d (93.1%, in the draft PR sourcehold#363) was written from the original's instructions with his draft for the reads. What was left was the loop's test whether a picture shares another one's data. The original tests the flag first (0x00455B70). With the flag set it reads the colour byte once, into cl, and tests it twice: zero copies the picture, bit 2 (value 4) takes the previous picture's offset, anything else the alternative picture's (0x00455B82 to 0x00455B9A). Without the flag it tests bit 2 in memory and runs on into the same blocks (0x00455B9C). The draft had one condition, (flag && colour != 0) || (colour & 4): with it the compiler tested bit 2 again behind the zero test and based the header pointer on the colour byte. Written as the listing has it: - The flag's two arms, each with its own sharing and its own copying. The compiler merges the two copies of the copying and lets the second arm run into the first arm's stores, as the original does. With the copying written once the match is lost: behind the draft's one test quick_diff reads 0.9326, behind a flag variable or a continue 0.70 to 0.77. - The colour byte in a local in the flag's arm. Without it the rest is the same, but the copying adds its source address the other way round (0.9610 against 0.9714). Measured: quick_diff 0.9714 with 192 instructions against 193, also with the stack slots kept. What still differs there is not in the code: four calls through the import table, the jmp over the padding in front of the loop (0x00455B66), and the previous offset's address, which the original's listing shows folded (0x00D0BA0C). reccmp 100.0% (normalized 100.0%) alone, data resolvers and its own resolver on. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader, rewritten from the original's listing. gynt's drafts: 7a1fcbd at 32.66% on his fork's reimpl/UI-MenuItems, and d0d28fd at 45.93% ("comparison operand order") on his fork's reimpl/UI-MenuItems-development, whose status line records 45.9%; the newest commit on the file, dd1a7c4, is on that branch too. Our draft c792435 (46.3%, in the draft PR sourcehold#328) was his code with a mechanical pass. The function sorts the lobby's map list by name, by players or by balance: on a click on a column or, with a negative argument, by a stored order again. The drafts had the decompiler's text, with seven iVar and two uVar locals. Written out with names, six things decide the match: - The non-negative arm stands first. The original falls through into the modal checks and jumps away for a negative argument (jl at 0x00440A64). - A stored order is compared after it is negated (neg eax at 0x00440B29, then cmp eax, 1 and so on). In each arm the source sets the column in front of the order. The listing loads the order's value first, then the column, and stores the order last (mov ecx, 4; mov eax, 2; mov [order], ecx, from 0x00440B5E); with the order set first in the source the match is lost. - In every bubble pass the second index is taken in front of the first, as the name sort's listing has it (0x00440D10). With the first one first the match is lost. - The players' sort reads the list's length in its loop condition each time (0x00440C8F); the other two sorts take it once. - The players' sort counts its seven tries in the parameter's own slot (mov dword ptr [esp + 0x18], 7 at 0x00440C29), which is why the argument is copied at the top (0x00440A57). A local for the tries loses the match. - The search for the chosen map is a plain for loop over the list that handles the hit inside (0x00440DC0 to 0x00440DFD). The drafts' while loop with a second test of the length has four instructions more. The sorts' repeat-until-nothing-swapped loops are for loops (for (int swaps = 1; swaps != 0;)), which compile to the same code as do-while loops. Measured: quick_diff 0.9766 with 253 instructions against 259. The six lines are the original's jmp over the padding in front of its loops, which our listing shows as padding; the rest is how the two listings print two constants and the tail call. reccmp 100.0% (normalized 100.0%) alone, data resolvers and its own resolver on. Not run in game. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
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.
Two functions at 100%, moved out of our open drafts #363 and #328, both from gynt's drafts. No header changes.
Rendering::TextureRenderCore::loadGMFileMenuItems::LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeaderMeasured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. The struct resolvers and the function resolvers are enabled locally (not committed); in the full build 0x004314E0 (MapEditorLandscaping_GeneralButtonshandler) is left out and its resolver stays off, as in main's baseline.tools/). Both functions read 100.0 raw and normalised, with no diff entry.openshc-pr-checkgives 0 ERROR and 13 CHECK (below).openshc-pr-fixfinds nothing to change.What got them to 100%
loadGMFile (0x004559B0)
What was left was the loop's test whether a picture shares another one's data.
cl, and tests it twice: zero copies the picture, bit 2 (value 4) takes the previous picture's offset, anything else the alternative picture's (0x00455B82 to 0x00455B9A). Without the flag it tests bit 2 in memory and runs on into the same blocks (0x00455B9C).(flag && colour != 0) || (colour & 4). With it the compiler tested bit 2 again behind the zero test and based the header pointer on the colour byte.continue0.70 to 0.77. The copying is nine lines with two calls, so the file has them twice; the comment above says why.One thing reviewers should know. That last operand order follows the function's locals in a way the source does not show: a second local (a name for the
"gm1"string) flipped it back. We checked that it is not the translation unit's symbol count: with 0 to 63 extra declarations in front of the function the code stays the same.The lobby's map sort (0x00440A50)
The function sorts the lobby's map list by name, by players or by balance: on a click on a column or, with a negative argument, by a stored order again. The draft was the decompiler's text with seven
iVarand twouVarlocals. It is written from the original's listing now. Six things decide the match:jlat 0x00440A64).neg eaxat 0x00440B29, thencmp eax, 1and so on). In each arm the source sets the column in front of the order. The listing loads the order's value first, then the column, and stores the order last (mov ecx, 4; mov eax, 2; mov [order], ecx, from 0x00440B5E); with the order set first in the source the match is lost.mov dword ptr [esp + 0x18], 7at 0x00440C29), which is why the argument is copied at the top (0x00440A57). A local for the tries loses the match.forloop over the list that handles the hit inside (0x00440DC0 to 0x00440DFD). The draft'swhileloop with a second test of the length has four instructions more.The sorts' repeat-until-nothing-swapped loops are
forloops (for (int swaps = 1; swaps != 0;)), which compile to the same code asdo-whileloops.No behaviour differs from the drafts, as far as we can tell. One test in the search can never be true,
if (found < 0)withfoundcounting up from 0, but the original has it (test esi, esi; jgeat 0x00440E05), so it stays.The checker's 13 CHECKs
All are in the map sort's file.
param_1(8 findings on 7 lines)for (param_1 = 7; param_1 > 0;)has no counter of its own in the headerlobbyMapSortOrderundefined4; one signed compare needs the cast. No header change herecaselabels are numbersDAT_00b960dcandINT_00b95ab8MenuView_SingleplayerMapChoice_DoEveryFrameits sign picks the fade's direction (the step itself comes from the time). The second is set to 1 before the map table's handler runs, and we don't know more about it🤖 Generated with Claude Code