Repository navigation
UI: the confirmation dialog's answer handler at 100% - #442
Open
kotijekriv wants to merge 1 commit into
Open
kotijekriv wants to merge 1 commit into
kotijekriv wants to merge 1 commit into
Conversation
General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk, rewritten from the original's listing. gynt's draft is the file on his fork's reimpl/UI-MenuItems-development (first in 4e57118, newest commit on it b3069fd); his status line has no number for it. Our draft (791f92c, then d79d89d; 64.2% in the draft PR sourcehold#328) was his code with a mechanical pass and strcat for the map name's extension. The function answers the two buttons of a confirmation dialog: 22 carries out what the dialog asks (DAT_MenuOptionsActionParameter), 23 declines it. Every path ends in resetMouseState2 except a multiplayer game's return to its lobby. 22 is one switch over the question (-7, 7, 9, 30, 43, 44, 47, 49, 1000, 2000 and a default), dispatched through a compare tree, the byte table at 0x00495084 and the jump table at 0x00495070. One behaviour fix. Question -7 is asked by the scenario description's handler (it stores -7 into DAT_MenuOptionsActionParameter). The draft, like gynt's text, first tested the question with `< 44` on the field as the header types it (undefined4, unsigned) and compiled to an unsigned compare. So -7 never reached its case: it took the other side and ended in the default, and "yes" only closed the dialog. The original compares signed (jg at 0x004949E2) and has -7 in the jump table: it puts the player colours back to their defaults and then runs 7's and 1000's code, which for -7 ends in the single-player map choice. The fix comes from having one switch over all questions; the (int) makes its dispatch the original's. What decided the match, each measured with one thing changed (reccmp in the narrow build described below; the variants were built on the text before its last edits, which do not change the listing): - The switch is on (int) of the field. On the field as it is: 71.4% (26.0% normalized). Main has the same cast on the same field in MenuModalRenderFunction_YesNoDialog (0x00493390). - resetMouseState2 is called once, after the outer switch, and every path leaves by break. The original has a copy of it at every path's end and only the conditional jumps (button neither 22 nor 23, three trail tests) go to the last one. With `reset; return;` written out in every path, which also means the leaving code has to stand after the inner switch (two changes in this variant): 83.7% (71.5%). - The leaving code (7, 1000 and, after the colours, -7) stands inside `case 7: case 1000:`. The compiler puts its first test at 7's place and the rest after the last case, as in the original. - In that code the multiplayer exit tests the field and the local for the game mode is read after the test. Read before it, the game mode and the constant 1 swap esi and edi in the whole function: 95.8% (89.7%). Without a local: 85.4% (85.1%). - Case 30 is one if / else with one break after it. The currentModalDialog test at the end of the leaving code shares the call of clearAnyOtherModalDialogs with 43 (jne at 0x00495056 to 0x00494B4A); with a break in 30's first arm it shares 30's: 99.8% (95.2%). - Case 49 closes the dialog itself and default does the same in its own two lines. With 49 falling into a default written right after it, the compiler folds default's code into 2000's equal end, and default's three jumps and its table entry land after 2000's code (the original has them after 49's, 0x00494D78): 99.2% (95.2%). - In 44 the trail part is `if (isSkirmishTrail == TRUE) { the three trail tests }` with the lobby restore after it; the draft had `!= TRUE` with the restore first: 87.0% (73.5%). The original compares with 1 there (cmp with edi at 0x00494C2C); as a truth test: 99.6% (90.9%). - The menu to return to is chosen by nested if / else in the original's order, with switchToMenuView written in every arm; the compiler shares the call itself (pushes in the arms, one call at 0x00495046). The two mission select views as one call with ?: read 92.8% (79.3%). These compile to the same listing, and the plainer form stands: the three trail tests as one if / else-if chain with one break; `case 22` before `case 23`; gameMode_2 read from the field in 44; the inner cases in ascending order with default last (the compare tree decides where their code goes); no braces around case 22; Game::GameModeInt for the local; FALSE for field_0x6c; and the backup map's name as the string-macros.hpp macro, because the file uses a macro for strcat's inline copy and must not include string-literals.hpp beside it. Measured in a narrow build on main 3458fea of this file with the two finished functions it refers to in the sources list, their resolvers on: RenderLoadAndSaveBar (0x00493690), whose address it stores, and resetMouseState2 (0x004689D0), which every path but the multiplayer exit tail-calls. reccmp 100.0, normalized 100.0, and both of them stay at 100.0. Without resetMouseState2's file in the list the function reads 97.2% (100.0% normalized): each tail jump then shows as a trampoline. The draft read 58.3 (65.7 normalized) in the same build without resetMouseState2. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 21, 2026
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 function at 100%, moved out of our open draft #328, from gynt's draft. No header changes. One behaviour fix against the draft (below).
MenuItems::General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnkOur draft was gynt's code with a mechanical pass; his file is on his fork's reimpl/UI-MenuItems-development, and his status line has no number for it. In the narrow build described below (without
resetMouseState2in the build) the draft read 58.3% (65.7% normalised).Measured
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).RenderLoadAndSaveBar(0x00493690), whose address it stores, andresetMouseState2(0x004689D0), which every path but the multiplayer exit tail-calls. 100.0 raw and normalised for all three.resetMouseState2's file in the build the function reads 97.2 (100.0 normalised): each tail jump then shows as a trampoline on our side.tools/). The new function reads 100.0 raw and normalised there too, with no diff entry.string-macros.hpp. Each gives the same listing, and the narrow build above is of this head.The behaviour fix
The function switches over the open dialog's question,
DAT_MenuOptionsActionParameter. Question -7 is the scenario description's "back to the map choice?" in the builder, asked when a game is suspended (MenuItemActionHandler_ScenarioDescription_Main, buttons 12 and 13). With no suspended game that handler resets the colours and opens the single-player map choice itself, which is what "yes" now does too. The draft, like gynt's text, first tested the question with< 44on the field as the header types it (undefined4, unsigned), and that compiled to an unsigned compare. So -7 never reached itscase -7:inside that branch: it took the other side and ended in the default, and "yes" only closed the dialog.The original compares signed (
jgat 0x004949E2) and has -7 in its jump table: it puts the player colours back to their defaults and then runs 7's and 1000's code, which for -7 ends in the single-player map choice. The fix comes from having oneswitchover all questions; the(int)makes its dispatch the original's.What got it to 100%
The function answers the two buttons of a confirmation dialog: 22 carries out what the dialog asks, 23 declines it. Every path ends in
resetMouseState2, except a multiplayer game's return to its lobby. Button 22 is oneswitchover the question (-7, 7, 9, 30, 43, 44, 47, 49, 1000, 2000 and a default); its largest part leaves the running game (7, 1000 and, after the colours, -7).The drafts had the decompiler's shape: range tests around a partial
switch, nine gotos to five labels, andresetMouseState2(); return;written out in every path. The function is written from the original's listing now, without gotos. What decided the match, each measured with one thing changed (the variants were built before the last edits, which do not change the listing):switchis on(int)of the field. On the field as it is, the dispatch is unsigned and has no table entry for -7: 71.4% (26.0% normalised).resetMouseState2is called once, after the outerswitch, and every path leaves bybreak. The original has a copy of the call at every path's end, and only its conditional jumps go to the last copy. WithresetMouseState2(); return;written out in every path the compiler merges equal ends across cases: 83.7% (71.5%). That variant changes two things: the leaving code then has to stand after the innerswitch.case 7: case 1000:) the multiplayer exit tests the field, and the local for the game mode is read after the test. Read before it, the game mode and the constant 1 swapesiandedithrough the whole function: 95.8% (89.7%). Without a local: 85.4% (85.1%).if/elsewith onebreakafter it. ThecurrentModalDialogtest at the end of the leaving code shares the call ofclearAnyOtherModalDialogswith case 43 (jneat 0x00495056); with abreakin 30's first arm it shares 30's call: 99.8% (95.2%).defaultdoes the same in its own two lines. With 49 falling into adefaultwritten right after it, the compiler foldsdefault's code into 2000's equal end, anddefault's three jumps and its table entry land after 2000's code instead of after 49's: 99.2% (95.2%).if (isSkirmishTrail == TRUE) { the three trail tests }with the lobby restore after it. The draft had!= TRUEwith the restore first: 87.0% (73.5%).if/elsein the original's order, withswitchToMenuViewwritten in every arm. The compiler shares the call itself. The two mission select views as one call with?:: 92.8% (79.3%).Several other choices gave the same listing, and we took the plainer form: the three trail tests as one
if/else ifchain with onebreak,case 22beforecase 23,gameMode_2read from the field in 44, the inner cases in ascending order withdefaultlast, and no braces aroundcase 22.One string rule: the file copies ".map" inline with
strcat, which needs the macro fromstring-macros.hpp. So it does not includestring-literals.hpp, and the backup map's name is the macroSTR_AUTOBACKUPMAPtoo (the draft mixed the two headers). Same listing.Things in the file that look odd and are the original's
isSkirmishTrail == TRUEin 44. The original compares with 1 there (cmpwith the 1 inediat 0x00494C2C); the same field is tested for truth in the leaving code (0x00494F6F). As a truth test in 44: 99.6% (90.9%). A comment says so.resetMouseState2is called twice on two paths: 44 calls it first (0x00494BAA) and the leaving code calls it afterdisconnectDPlay(0x00494E0F), and both end in it like every path.resetMouseState2: it tail-callsinitMultiplayerLobbyState(0x00494A89).Header findings (nothing changed here)
MenuTextInputState::DAT_MenuOptionsActionParameterisundefined4, and one of its values is -7. Main already has the same(int)cast on it inMenuModalRenderFunction_YesNoDialog(0x00493390). Retyping the field tointwould drop both casts; none of its other uses on main depends on the sign. This PR keeps the cast because it changes no headers.strcat's scan loop. It can never be reimplemented on its own.GameCore::field_0x6cis 0 or 1 only, aBOOLEnumcandidate. When it is set, this function loadsauto_backup_map.mapand returns to the map editor's properties view, then clears it. The map editor's play test sets it (button 31 of the properties view). A lead for a name: the game is a test of the map being edited.The checker's 5 CHECKs
DAT_MenuOptionsActionParameterin theswitchYesNoDialoghas the same cast, and a retype tointwould drop both, but this PR changes no headersisSkirmishTrail == TRUEfield_0x6c(two findings)🤖 Generated with Claude Code