Repository navigation
Reimplement 5 UI functions from gynt's drafts and #328 (100%) - #407
Merged
Merged
Conversation
MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons, from the draft sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 306a61a, 79.4%), itself gynt's draft (1674e0f, 72.84%; his newest reimplementation commit on the file is 8725ec5, his last style pass dd1a7c4). gynt's: the switch over the actions, the scroll and host cases and the session handling. The join case is rewritten without the decompiler's gotos and hand-unrolled string loops: the typed address is stored only when it is not empty (`strlen(...) != 0`), not already listed (a found flag over the four entries), in the first empty slot (a stored flag, `strlen(...) == 0`, then strcpy), or else after shifting the list up. MSVC threads both flags away and inlines strlen and strcpy into the original's loops, including its `sub eax, edx` length tests that the draft's pointer compare did not give. The host case copies the player name with strcpy. reccmp 99.2, normalised 100.0: the only differences are tail-jump targets to resetMouseState2 (0x004689D0, on main with its resolver off), so 100% by the call-target rule. The original jumps to it three times (0x00490C73, 0x00490D4A, 0x00490D81); reccmp reads two of ours as different targets. quick_diff 0.9850; its other hunk is the original's `npad` jump before the shift loop. The parameter is action, the session result is tested inline, the index step is a plain increment, the two flags are BOOLEnum and the array bounds are written with countof (all measured identical). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 031cb7d, 75.1%), itself gynt's draft (f3cef40, 72.67%; his last style pass dd1a7c4). Rewritten from the original's asm as one switch: MSVC splits it the original's way, -1100, -1000 and -101 compared one by one and -100..77 through the jump table, with the cases in the original's block order (2, -101, 65, 66, 67, 68, 76, 69, 74, 77, -10, -11, -100). No gotos; the back button's two menu views are two calls MSVC merges. Behaviour fixes against the binary: - start game (65 / -1100) sets the difficulty to 1 for mission types 0 and 3 and then still launches the game (0x0042D71D falls into 0x0042D727); the draft returned without launching; - the description's scroll down (-101) adds 14 and clamps to the limit, returning when already there; the draft always overwrote the offset with the limit; - the start game guard returns when the scroll offset plus the relative selection is negative (`js` at 0x0042D709); the draft's guard was inverted; - the draft's extra DAT_StopHandlingMenuItems stores are gone (the original stores it once, at the top). reccmp 99.7, normalised 100.0: the only difference is a tail jump's target through a resolver, so 100% by the call-target rule. The start-game test reads the scroll offset through DAT_GameSynchronyState::ptr and the relative selection through instance: MSVC then loads the relative selection first, as the original does (the same fields both through instance, in either order, a local or `0 >`, all kept the opposite load order, 99.1). A comment says why. quick_diff 134/134 (its other hunks are the timeGetTime import and resolver tail calls). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_MainMenu_Main, rewritten without gotos from the original's code, with gynt's draft (f2e9ae2 at 81.39% on his fork's reimpl/UI-MenuItems-development; his last style pass on the file is dd1a7c4; quick_diff 0.9159 on main) for the reads. reccmp 100.0, quick_diff 162/162 at 1.0000. The decompiler's gotos are one if/else: a button that is not hovered and is not one of 5-9 draws its button and goes straight to the text, and every other button runs the button-5 hover sound, the GM index choice, the draw and the hover tracking. Each text that has a hovered and a not-hovered state is drawn by two calls that are the same, one per state, with the position read into `int const textY` then `textX` in each: MSVC keeps the two calls apart and merges only what they share, as in the original (one shared call: 0.9154; the button text alone split: 0.9938). The not-hovered call comes first. Behaviour fix: with the GM-index flag set, buttons 1, 2, 3 and 9 now go on to draw the button and its text after choosing GM index 353, as the original does; the draft returned there. The sound IDs are SEID_UNKNOWN_0xFB and SEID_UNKNOWN_0x92 (the draft or'ed two unrelated enum values that add up to them), the Multiplayer test compares with DD7_LOADED, and the colours are COL_7F7F7F and COL_C2F0EB. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main, rewritten without gotos from the original's code, with gynt's draft for the reads (9d44bf4 at 80.93%, after his 85b6360, 2490ef5 and f03fca7; the file's newest commit on his fork's reimpl/UI-MenuItems-development is 8725ec5; quick_diff 0.8768 on main). The fields, the vote counting and the five buttons' actions were already his. reccmp 98.2, normalised 100.0: the only differences are the resetMouseState2 tail jumps, which go through its resolver. quick_diff 102/102 at 0.9608, for the same reason and the timeGetTime import call. One switch over the five buttons, every path ending in resetMouseState2. Button 1 ends the game. Button 2 counts the occupied player slots and starts a quit vote when someone else is there, with the empty slots and the asking player's own as yes votes. Buttons 4 and 5 send a no or a yes, and button 3 closes the dialog. The two loops over slots 1-8 compile to the same code as the eight lines written out. Behaviour fix: button 2 now does what the original does in both of its cases. With nobody else in the game it ends the game at once (the count test jumps into button 1's code), and after starting a vote it stops there. The draft fell through into button 4 in both cases and sent a no vote. Button 2 repeats button 1's code for the first case, written after button 1, so that MSVC merges the two as in the original (button 2 falling into a following button 1 put the blocks in the other order: 0.8922). The vote command is GCT_UNKNOWN_91 (the draft or'ed two unrelated enum values that add up to it). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_LobbyMenu_MapSelectHeader, rewritten from the original's code with gynt's draft for the reads (305b2b1 at 74.80% on his fork's reimpl/UI-MenuItems; on reimpl/UI-MenuItems-development his newest reimplement commit on the file is 8725ec5 and the newest commit 5084980; quick_diff 0.8160 on main). The columns' text numbers and offsets were already his. reccmp 100.0, quick_diff 63/63 at 1.0000. The header cell picks its text and x offset per column, draws the cell background and its title, brighter while hovered. Forms that match, measured with quick_diff: - one call per hover state rather than a colour ternary (the ternary compiles branch-free: 0.8661); - the fade and y read into locals before the branch, and x read into a local in each branch. The offset then keeps the original's register, where one x local before the branch swaps the offset and the text index (0.8254); - the text index and offset initialised before the dialog tests (after them, the two swap registers). The fade keeps the original's (strength - 32) * 32 / 32 + 32, with a comment that it comes back to the strength itself. The parameter is the column, the early returns replace the draft's nested condition, and the colours are COL_C2F0EB and COL_CCFAFF. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 14, 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 UI functions at 100%, with no header changes. Three of them are rewrites of gynt's drafts, with his draft used for the reads. The other two come from our draft #328, which started from his versions too. Each commit cites the drafts it builds on and credits him as co-author. All five are part of the rest of UI that gynt OK'd on 2026-11-09.
ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_ButtonsSinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHandsMainMenu::MenuItemRenderFunction_MainMenu_MainOnlineVoteQuitAndQuitGame::MenuItemActionHandler_OnlineVoteQuitAndQuitGame_MainLobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectHeaderAll five read 100.0%, raw and normalised, in the full build described below. Built with only this round's five files, three of them read just under 100% raw and 100.0% normalised: ChooseNetworkServiceProvider's Buttons 99.2%, SingleplayerMapChoice's ButtonsAndHands 99.7% and OnlineVoteQuit 98.2%. In each the only difference is the target of a tail jump that goes through a resolver, so they are 100% either way by the call-target rule. In the first and the last that is
resetMouseState2(0x004689D0), which is on main with its resolver off. ChooseNetworkServiceProvider's Buttons jumps to it three times, and reccmp reads two of ours as different targets.Measured.
Setup: the bundled MSVC1400-SP1 against the Steam
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed), and sourcehold's reccmp (6f980a441) with--resolve-wrapped-calls --ignore-security-cookie.Full build, before the last small fixes and the rebase: all 2,351 source files of main 1d819b7 with this branch merged in, against a full build of main alone as the baseline (2,346 files). All five read 100.0% raw. Of the 2,364 functions measured on main, 2,362 read exactly the same with this branch and none read lower. Two read higher,
UI::Menu::Constructor_Menu(98.4% to 100.0%) andUI::Menu::handleMenuItems(97.9% to 100.0%), and that is reccmp, not the code: both compare with the constant0x11000000, and in main's DLL a symbol happens to sit at that address, so reccmp names the constant after it. With this branch the DLL's layout moves and the constant reads as a constant again. Neither file changes.Since then: the branch now sits on main 72c6a2e, which has Reimplement 7 UI functions from gynt's drafts, and DAT_ButtonBlendStrength as an int (100%) #400 and Reimplement 5 UI functions from gynt's drafts and #327/#328, with three header commits (100%) #406; the rebase changed none of the five files. The branch also changed in small ways:
BOOLEnum, and its index wrap, shift loop and last slot usecountof(ipRelatedArray), as its two search loops already did. Both compile to the same code.TEXT_XPLAY_WAITING_ROOM).blendStrength, and the comments on the kept shapes say why each shape stays.usingand some stray blank lines are gone.All five were measured again after these changes, with only this branch's five files built, and read as above.
Checks:
openshc-pr-checkgives no errors.Not run in game.
What got them to 100%
strlen(...) != 0), isn't already in the list (a found flag over the four entries), in the first empty slot (a stored flag, thenstrcpy), or else at the end after the list moves up one. MSVC threads both flags away and inlinesstrlenandstrcpyinto the original's loops, including itssub eax, edxlength tests, which the draft's pointer compare didn't give. The host case copies the player name withstrcpytoo.DAT_GameSynchronyState::ptrand the relative selection throughinstance: MSVC then loads the relative selection first, as the original does. A comment in the code says why.textYthentextXin each. MSVC keeps the two calls apart and merges only what they share, as the original does. The not-hovered call comes first.resetMouseState2once after it. Button 2 repeats button 1's code for the case where nobody else is in the game, written after button 1, so MSVC merges the two into the original's jump. The two loops over player slots 1 to 8 compile to the same code as the eight lines written out.Behaviour fixed compared with the drafts
jsat 0x0042D709). The draft's test was the wrong way round: it launched only when that sum was below -1.DAT_StopHandlingMenuItemsstores are gone. The original stores it once, at the top.SEID_UNKNOWN_0xFBandSEID_UNKNOWN_0x92(MainMenu's sounds) andGCT_UNKNOWN_91(the vote command). The code is the same.Two functions leave #328
ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons(0x004909E0)SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands(0x0042D640)#328 gets one commit that removes both
.cppfiles and puts their status lines back to main's (b379b2c). #328 still compiles without them. No other open draft of ours has any of the five.Kept as they are, measured with quick_diff
ptr, the relative selection throughinstanceinstancein either order, a local, or0 >: all 99.1% in reccmptextYthentextXbefore each of the four text calls (eight locals)(strength - 32) * 32 / 32 + 32Most of these have a one-line comment in the code that says why.
Numbers left as numbers:
caselabels in the OnlineVoteQuit and SingleplayerMapChoice handlers and in MapSelectHeader: they are the menu's button numbers and MapSelectHeader's table column, with no enum on main.DAT_MapMissionTypevalues (0 to 3): the global is anundefined4with no enum.What some placeholders hold
DAT_00b960f4: the map description's scroll offset in pixels (as in Reimplement 5 UI functions from gynt's drafts and #327/#328, with three header commits (100%) #406). ButtonsAndHands moves it in steps of 14 and clamps it atINT_00b95b74 - 204.INT_00b95abc: the main menu's last hovered button. The render sets it to the hovered button (1 to 4, or 9), plays the hover sound only when it changes, and puts it back to -1 when that button is no longer hovered.Other PRs
🤖 Generated with Claude Code