Repository navigation
One more UI::MenuItems function at 100%: LobbyMenu SkirmishTypeAndBalance - #462
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
LobbyMenu::MenuItemRenderFunction_LobbyMenu_SkirmishTypeAndBalance, from Gynt's draft (5f8890a at 75.21% on his fork's reimpl/UI-MenuItems-development; 41.8% at f45fb61 on his closed sourcehold#254's reimpl/UI-MenuItems, 50.17% at ed70d66 and 63.07% at 04a1f23 on his fork). The drafts are the decompiler's output and have the original's control flow. One test is changed against the 75.21% text: the trail test is isSkirmishTrail == TRUE again, as the original compares the flag with 1 (0x0042A6D4) and as his other copies have it (his 75.21% commit had changed it to a truth test for the match; the store in both arms below makes == TRUE match). Rewritten against the original instructions: - returns per button, and a flag for the three AI setup dialogs in front, as MapSelectTable has it; - the arguments of the panel's first text (blend, y, x, the game type's index) are locals in the order they are pushed: the original holds all four at once (from 0x0042A580); written into the nested call, the type was loaded first (quick_diff 0.9730 to 0.9932); - in the pressed draw the draw target is set back in both arms of the test that follows it. The original keeps 0 and 1 in ebx and ebp through the function. With the target set back once, in front of the test, and the trail test as == TRUE, the two get each other's register and every line that uses them differs; with a truth test the registers are right and the test's two lines are left (99.3%). Set back in both arms, the compiler joins the two stores in front of the branch itself (0x0042A813, the same instructions as one store there), and the registers are the original's. As far as we can tell, it chooses them while the stores are still in the arms; - the gold is StartGoldPerFairnessLevel[type - 1][balance - 1][0] and [1] (the 75.21% text's field451_0x53bb4[(balance + type * 5) * 2 + 12] and + 13, the same addresses), times 3 on the extreme trail; - (int)skirmishCurrentAdvantageBalance: the original compares it signed (the field is undefined4 in the header). No line for cmake/compiler-flags-gl.txt: the file reads 100.0% off the /GL list, and 100.0% on it too. reccmp in a build of main's whole /GL list (the 133 files that exist) and this file, off the list, with every resolver of those files on: 144 functions, average 99.56. The function 100.0% raw and normalised, no differing line, and the same with the file on the list. The same build without the file has 143 functions, and each of them reads the same. Both builds had the file as committed but for its comments (two worded differently, the others not yet written); quick_diff gives the same 296 instructions, line for line, for that text and for this one. The sources are main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off. 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.
One more function at 100%, with no header changes and no line for
cmake/compiler-flags-gl.txt. No change of control flow against the drafts, and one changed test (below).LobbyMenu::MenuItemRenderFunction_LobbyMenu_SkirmishTypeAndBalancedraws the skirmish settings of the lobby: the three game type buttons ("Normal Game", "Crusader Game", "Deathmatch Game"), the chosen one pressed; the balance bar with its marker; and the panel with the game type's name, "Human Advantage" or "Computer Advantage" beside an uneven balance, and each side's starting gold. It is from gynt's draft on his fork'sreimpl/UI-MenuItems-development, and the commit credits him as co-author.LobbyMenu::MenuItemRenderFunction_LobbyMenu_SkirmishTypeAndBalance/GLlist and on itMeasured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie./GLlist and with 0x004314E0 (theMapEditorLandscaping_GeneralButtonshandler) left out and its resolver off, as in main's baseline: 0 failed of 2,424 compile steps, 99.58 over 2,440 functions, against 99.58 over 2,439 for main alone (built at f489b72; 3458fea only adds files undertools/, and cmake: optional wrapper units built from function-visibility.txt #399 and cmake: function-visibility.txt, which callers must see which callees' bodies #398 add the optional function-visibility units, off by default).MenuItemRenderFunction_LobbyMenu_SkirmishTypeAndBalancereads 100.0 raw and normalised there too, with no diff entry. Every main function reads exactly what it read before (unrounded 99.5761 against 99.5759 raw, 99.5494 against 99.5492 normalised; 2,323 against 2,322 functions at 100.0 raw)./GLlist that exist on main, and the file, off the list: 144 functions, average 99.56. The function reads 100.0% raw and normalised, with no diff entries. The same build without the file has 143 functions, and each of them reads the same. That build, and the one with the file on the list (below), had the file as committed but for its comments (two worded differently, the others not yet written); quick_diff gives the same 296 instructions, line for line, for that text and for this one. The sources were main's at 3458fea; main's two commits since (02fab42, 812d149) add cmake files only, with the new option off.Against the drafts
Read against the original, gynt's drafts have its control flow: the same stores in the same order in front of the buttons, the same draws per button, and the unpressed draw after the pressed one only when the game type changed during it. Two tests differ in some of them:
gameMode_2is skirmish,isSkirmishTrailis 1 and the trail is the extreme one (cmp [isSkirmishTrail], ebpat 0x0042A6D4, whereebpholds 1). His 75.21% text (5f8890a, "truth test, not == TRUE"; the same test at the branch's head 405b988, after his style passes dd1a7c4 and 5084980) testsisSkirmishTrail != FALSE. That commit took his status line from 61.7% (8725ec5) to 75.21%: as far as we can tell, with== TRUEthe 0 and the 1 trade registers through the function (see "What got it to 100%"). All his other copies have== TRUE. The two differ only if the flag holds a value other than 0 and 1. Here it is== TRUEagain, and the store in both arms of the retest (below) gives the two their registers back.jgeat 0x0042A5E6,jleat 0x0042A634).skirmishCurrentAdvantageBalanceisundefined4(unsigned) in the header, and the copies at 41.8% and 50.17% and the one on his reimpl/Wilps-2026-10-18 (8ca7861) compare it as it is; his 63.07% and 75.21% texts have the(int)cast, as this one has. The two differ only for a balance of 2^31 or more.Everything else in the drafts computes the original's values: the positions, pictures, colours and font sizes, and the gold. His 75.21% text reads the gold as
field451_0x53bb4[(balance + type * 5) * 2 + 12]and+ 13; on main the same two addresses areStartGoldPerFairnessLevel[type - 1][balance - 1][0]and[1].What got it to 100%
The drafts are the decompiler's output: one nested condition with assignments inside it for the stores in front, and the buttons nested in each other. The function is rewritten against the original instructions, in three steps on our dev branch (not public): 95.4% (read with the file on the
/GLlist; quick_diff, which compiles it off the list, gave 0.9730), then 99.3% and 100.0% off the list.MapSelectTableon main has it (0x0042B4C0):DAT_ButtonUnknownZeroends up set for a guest, and for the host while the round table or one of the two AI lord selects is open; otherwise it is cleared. A guest'sDAT_ButtonCurrentlyInteractingis cleared too.eax,ecx,edxandesi, from 0x0042A580). Written into the nested call, the type was loaded first andeaxreused.== TRUEabove). The original keeps 0 and 1 inebxandebpthrough the whole function (0x0042A49D, 0x0042A495). With the trail test as== TRUEand the target set back once, in front of the test, the compiler gives the two each other's register, and every line that uses them differs (quick_diff 0.9054; the instructions are otherwise the same 296). With the trail test as a truth test the registers are right, and the test itself is the two lines that are left (99.3%). The original reads the game type again behind the pressed draw and has both stores between that compare and its branch (0x0042A807 to 0x0042A819). Written asif (still this type) { target back; return; } target back;, the compiler joins the two stores in front of the branch itself, which gives the same instructions as one store there, and the registers are the original's. As far as we can tell, it chooses the two registers while the stores are still in the arms. Measured besides: the picture store in both arms too gives the same listing, and so do the arms the other way round; without thereturnin the arm, with the old secondif, it is 297 instructions. The drafts already have the test with the store in its arm (the decompiler shows it there), and one more store in front of it.StartGoldPerFairnessLevel[type - 1][balance - 1][0]and[1], times a multiplier that starts at 1 and becomes 3 (see above).quick_diff reads 1.0000: 296 instructions against 296.
No line for
cmake/compiler-flags-gl.txt/GLlist, and 100.0% on it too (the same build with the line added). So it needs no line.cmake/function-visibility.txt(cmake: function-visibility.txt, which callers must see which callees' bodies #398) either: of its callees, the manifest lists onlyRenderCurrentButtonToScreenMenuWithBlendingUnk, as the caller ofgetPictureNumberInGm.Kept as they are
isSkirmishTrail == TRUE(one CHECK): the original compares the flag with 1, and a comment says so.(int)casts on the balance (two CHECKs): the field isundefined4in the header (see the header finding below); retyping it is left out so this PR stays header-free.(strength - 32) * 32 / 32 + 32, is written out at nine of the ten draws (the first text has it in a local, see above): the original computes it at each one. A comment in the code says that it comes back to the blend strength itself.< 3and> 3, not anelse: the original reads the balance again behind the "Human Advantage" text (0x0042A62E).buttonID < 20 && buttonID >= 10in this order: the original tests 20 first (0x0042A4D3).buttonIDand its values are plain numbers: it is the menu item's number, and no enum on main names these buttons. Each block has a comment that says what it draws, with the texts' names from the game type group (0 to 2 "Normal Game", "Crusader Game", "Deathmatch Game"; 3 "Human Advantage"; 4 "Computer Advantage").Header finding (nothing changed here)
GameSynchronyState::skirmishCurrentAdvantageBalanceisundefined4, but the original uses it asint(jgeat 0x0042A5E6,jleat 0x0042A634). Asint, the two casts here would go. Its other users on main do not depend on the sign:GameStateStructures::calculateTaxIncomeForPlayercompares it with 1, 2, 4 and 5, and the click handler (0x0042A840) storesbutton - 9for the buttons from 10 on, so it runs from 1. 3 is the even balance; below 3 favours the human side and above 3 the computer side. The gold table bears that out: the normal game's pairs are 8000 / 2000, 4000 / 2000, 2000 / 2000, 2000 / 4000 and 2000 / 8000.What some placeholders hold
DAT_ButtonUnknownZero: set here for a button that is not live in the current state (an AI setup dialog is open, or the player is a guest). gynt's reimpl/Wilps-2026-10-18 has it asDAT_ButtonDisabled.Other PRs
🤖 Generated with Claude Code