Repository navigation
UI: three more functions at 100%: the scenario description's buttons, the map click handler and the name entry's prepare - #434
Open
kotijekriv wants to merge 4 commits into
Conversation
ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main, from gynt's draft (38ce297 at 28.99% on his fork's development; his newest commit on the file is e63ae30 on reimpl/UI-MenuItems-development) by way of my draft in the open draft PR (a8b3225, 95.0%, "block order of the last tests"). reccmp 100.0 (normalized 100.0) on main 3458fea with the data on. The last difference was which copy of the `button == 13` test and the economic-mode tests the compiler keeps. The original has them once, behind the else arm's `button == 12` test (0x004D8543), and the other arm jumps there. My draft wrote the whole test in each arm as one condition, and MSVC then kept the earlier arm's copy and dropped the re-tests of 12 and 13 that the original makes. Written as the original has it, the arms only do their own tests and fall out, and the economic-mode test stands once behind both: the later copy survives and the re-tests stay. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection, from gynt's drafts (b62cbe6 at 67.13% on his fork's reimpl/UI-MenuItems-development is his newest scored one; 8ca7861 on reimpl/Wilps-2026-10-18 is the newest commit on the file) by way of my draft in the open draft PR (f1f198c, 90.6%, "block placement at the end"). reccmp 100.0 (normalized 100.0) on main 3458fea with the data on. Two changes took it from 90.6 to 100: - The left-click arm with a mapper command. The original tests the command in line (0x00434699) and has the arm's code, which ends in returns, behind the function's last return (0x004347BE). `else if (command != NULL) { ... }` moved the test out of line with the code. Written as `else if (command == NULL) { } else { ... }` the code is an else arm that returns, which MSVC lays out behind the next return, and the test stays where it is. That alone gave 99.7: the plain returns then share the earlier return block, as in the original. - The second selectUnitAndOpenStatusMenu call, for the unit that was under the mouse before. The original tests the first call's result with `test eax, eax` and the second's with `cmp eax, ebp` (ebp holds zero), so the second result went through a variable: `BOOLEnum selectedLast = FALSE; if (...) selectedLast = call; if (selectedLast) return;`. One variable for both calls turns the first test into a `cmp` too. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
GameStartEnterName::MenuView_GameStartEnterName_Prepare, from gynt's draft (ac76223 at 82.52% on his fork's reimpl/UI-MenuViews-development) by way of my draft in the open draft PR (c5b5fe6, 98.2%, "stack slots of the name buffer and the cookie"). reccmp 100.0 (normalized 100.0) on main 3458fea with the data on. The last difference was the frame: the name buffer sat at [esp + 0xc] where the original has it at [esp + 0x10], under the same cookie. Two things in the draft cancelled out in the frame's size but not in its layout: - the name buffer is 250 bytes, not 256 (250 is also the size of the game's player name entries); - the length test is strlen, with which MSVC's frame is four bytes larger. The draft had a hand-written loop instead, because with the 256-byte buffer strlen made the frame four bytes too large. With both, the frame is 0x10c bytes with the buffer four bytes up, as in the original. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The empty arm for "no mapper command" in MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection
(0x00434350) is what keeps the command test in line. Its comment said "an else-if on the command loses the match",
which reads oddly on an arm that is itself an else-if on the command. It now names the form that loses the match:
`else if (command != M_MAPPER_NULL) { ... }` without the empty arm. Comment only: reccmp still reads 100.0
(normalized 100.0).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 20, 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.
Three UI functions at 100%, moved out of our open drafts #328 (two) and #356 (one), all from gynt's drafts. No header changes.
ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_MainInGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelectionGameStartEnterName::MenuView_GameStartEnterName_PrepareMeasured.
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/). All three functions read 100.0 raw and normalised.Constructor_MenuView_GameStartEnterName(0x0059A700) went from 90.0 to 100.0. It pushes the prepare function's address (0x00440560), which now resolves to the reimplementation. Its status line says "100.0% | Reimplemented (counted: only the pushed callback address is unnamed in the original)" since Reimplement 176 static initializers and GetStringBasedOnHardcodedMaps #405; the remark in brackets no longer applies. This PR leaves that line as it is.openshc-pr-checkgives 0 ERROR and 25 CHECK, all placeholder names (below).openshc-pr-fixfinds nothing to change.Behaviour fixed compared with gynt's drafts
These fixes were made in the draft PRs and checked against the binary. They are listed here because the drafts' texts no longer carry these functions.
storeXYAndResetMouseState(tail jump at 0x00434609). The draft called it and went on into the click handling.setupMouseTileXY(tail jump at 0x004347E5). The draft called it and went on into the selection code.frontend_combat3.tgx, reset the text and open the name dialog. Its name buffer was 256 bytes where the original's is 250; that changes the frame, not what the function does.What got them to 100%
MenuItemRenderFunction_ScenarioDescription_Main
button == 13test and the economic-mode tests once, behind the else arm'sbutton == 12test (0x004D8543), and the other arm jumps there.MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection
else if (command != NULL) { ... }moved the test out of line together with the code. Written aselse if (command == NULL) { } else { ... }, the code is an else arm that returns: MSVC lays that out behind the next return and leaves the test where it is. The empty arm has a comment saying why. The plain returns then share the earlier return block, as in the original.selectUnitAndOpenStatusMenucall (99.7 to 100). The original tests the first call's result withtest eax, eaxand the second's withcmp eax, ebp, whereebpholds zero. That is how MSVC tests a variable, not a call's result, so the second result goes through a local:BOOLEnum selectedLast = FALSE; if (...) selectedLast = call; if (selectedLast) return;. One local for both calls turns the first test into acmptoo.MenuView_GameStartEnterName_Prepare
[esp + 0xc]where the original has it at[esp + 0x10], under the same security cookie.strlen, with which MSVC's frame is four bytes larger; the draft had a hand-written loop instead, because with the 256-byte bufferstrlenmade the frame four bytes too large.UserTextHandler::textArray[16][250], which the name is copied from, andDAT_PlayerNames[9][250].The first two findings are about which of two identical code tails MSVC keeps, and where it lays out an arm that returns. They may help with other functions whose only gap is block placement.
The checker's 25 CHECKs
All 25 are placeholder names that Ghidra has no better name for.
DAT_00b960f8,INT_00b960f0GameCore::field_0x15cMouseState::field_0x198,field_0x19cViewportState::field_0x0,field_0x34INT_00ed27bc,DAT_00ed2798,INT_00ed27c4🤖 Generated with Claude Code