Repository navigation
Reimplement 6 UI::MenuItems text button renders at 100% - #345
Merged
Merged
Conversation
Finished from gynt's draft on his fork (reimpl/UI-MenuItems, 84.8%), which no longer compiled on main: the GameCore field at 0x118 is isNameEntryActive there now. The original stores DAT_ButtonUnknownZero = 1 before it tests anything, returns on the hidden button (8, "OK", while a title is set, and 25, "Change Your Title, Lord?", while one is typed in; isNameEntryActive is 1 when a title is already set, so its name reads the other way round) and stores 0 otherwise, so the source does the same, without the decompiler's goto. Each path makes its own call and computes the text position itself: the compiler merges the two calls into the original's one (a ternary colour compiles branch-free instead: quick_diff 0.6966) and hoists the identical position above the branch the way the original does, which puts the first push 0 where the original has it. The position computed once above the `if` measured 97.7%, as it did in GameOptionsTextButton (0x004934F0); a comment says so. quick_diff 0.8478 (the renamed draft, 48 instructions against 44) -> 44/44 with only quick_diff's own artefacts left: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. `== TRUE` stays: the original tests for 1 and then for 0 (a truthiness test: 100.0% -> 85.4%), and every other reader of the field compares it with 1; a comment says so. DAT_ButtonUnknownZero takes TRUE and FALSE (a BOOLEnum on main). The parameter is button, as the menu's handler calls it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (98.4%, the same code). The draft read SEC_MercRecruitable[troopIndex - 7], a negative index; the address is barracksRecruitability.array.barracksRecruitability[troopIndex], as the handler for the same screen reads it. Early returns, `troopIndex >= 0 && troopIndex <= 7` instead of the unsigned cast, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 98.4%; a comment says so. Moved here from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 8f88cf1). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is troopIndex, as the handler for the same screen calls it. A comment says index 2 is the spearmen, whose button is drawn 8 pixels further left. The flag is tested for truthiness (it is only ever 0 or 1; the same code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (98.2%, the same code), the same way as the euro troops render: early returns, both bounds spelled out, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 98.2%; a comment says so. Moved here from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 4581585). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is troopIndex, as the handler for the same screen calls it. The flag is tested for truthiness (it is only ever 0 or 1; the same code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (97.9%, the same code): early returns, the button texts from cr.tex ("Continue", "Exit",
"Skip"), no casts (the counters it compares, DAT_00df5558 and DAT_00df555c, are ints on main), COL_CCFAFF. The text
position is computed in each path: the compiler hoists the identical computation above the branch the way the original
does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it
measured 97.9%; a comment says so. Moved here from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 36d0a96).
quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the
original's side, and ret / ret 0. The parameter is button, as the handler for the same box calls it. `>> 1` stays: the
original halves without the sign fix-up (`/ 2`: 100.0% -> 93.9%), as its comment says. DAT_00df5560 is tested for
truthiness, as main's handler for the same box does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (97.7%, the same code): no TextAlignment local, an early return, COL_CCFAFF, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 97.7%; a comment says so. Moved here from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 8d25a1f). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is textIndex: it is only the text's index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (97.3%, the same code): early returns, COL_CCFAFF, decimal numbers, no casts. The text position is computed in each path: the compiler hoists the identical computation above the branch the way the original does, which schedules the first push 0 where the original has it. Computed once above the `if`, as on the draft, it measured 97.3%; a comment says so. Moved here from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 197b9d4). quick_diff is left with its own artefacts only: the two colour immediates, which it prints as globals on the original's side, and ret / ret 0. The parameter is buttonID: the button's ID, which is also its text's index. A comment says what 68 is: "Send", hidden while a map is being transferred. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
gynt
approved these changes
Nov 6, 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.
Six UI::MenuItems render functions at 100%, each with its status line: the buttons of the troop-disabling screens (European and Arabian), the tutorial box, the title entry at the game's start, the map transfer screen and the old menus' title buttons.
Five of them were in our draft #327, which drops them in the same push; UnusedSetName_ButtonsUnk continues gynt's draft on his fork. All six had one blocker left, the first
push 0scheduled late; computing the text position inside each path fixed it. Every commit body says what changed against the draft and why. No header changes.Other PRs: the ready #342, #343 (the fix for main's 15 files), #344 and #346, and the drafts #313, #318, #321, #327 and #328.
Built on top of
main(57d3334) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). The branch was built clean on its own, with the struct and function resolvers enabled locally (not committed), using sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie. None of it has been run in game.It went through the same checks as #344: a fresh-eyes review of every file (behaviour checked against the original's disassembly, texts against cr.tex; its points applied and measured),
openshc-pr-checkwith no errors, main'sstyle_lint.pywith nothing to report, andstatus_regression.py, which finds nothing below a known score on main or any fork.Behaviour compared with the drafts
None of the six changes behaviour; each does what its draft did and what the original does.
SEC_MercRecruitable[param_1 + -7]is the same address asbarracksRecruitability.array.barracksRecruitability[troopIndex]; the branch names it the way main's handler for the same screen does, without the negative index.DAT_ButtonUnknownZero = 1only on the hidden path, behind agoto; the branch stores it before the tests, as the original does (0x0042675D). The final value is the same on every path.MenuItemRenderFunction_UnusedSetName_ButtonsUnkMenuItemRenderFunction_DisableEuroTroops_MainMenuItemRenderFunction_DisableArabTroops_MainMenuItemRenderFunction_TutorialBox_MainMenuItemRenderFunction_EnterTitleOnGameStart_ButtonMenuItemRenderFunction_SendReceiveMap_MainKept as they are, and why
Each was measured; a one-line comment in the code says why.
if: DisableArab 98.2%, DisableEuro 98.4%, EnterTitle 97.7%, SendReceiveMap 97.3%, TutorialBox 97.9%, UnusedSetName 97.7%). ThetextX/textYlocals stay too: the position written straight into each call measures DisableArab 68.4%, DisableEuro 73.0%, EnterTitle 58.1%, SendReceiveMap 59.0%, TutorialBox 71.2%, UnusedSetName 65.2%.== TRUE, since the original tests for 1 and then for 0, and every other reader of the field compares it with 1 (a truthiness test: 100.0% -> 85.4%).>> 1, because the original halves without the sign fix-up (/ 2: 100.0% -> 93.9%).troopIndex >= 0 && troopIndex <= 7follows the original'sja 7, which lets 7 through, one past both 7-entry arrays (barracksRecruitability[7]isSEC_MercRecruitable[0],SEC_MercRecruitable[7]isSEC_XbowProducible_save). Both menus only pass 0-6 and -3, so it never happens. DisableEuro restoresDAT_ButtonXfor the spearmen only on the disabled path, as the original does (0x004BB594 returns before theadd).Proposed, not changed here
Commands::M_MAPPER_BARRACKS_EURO(86) andM_MAPPER_BARRACKS_ARAB(87) have their names swapped (also in Reimplement 5 UI::MenuItems building menu and options functions at 100% #344):convertBuildingTypeToCommandBuildingTypemapsBT_MERCENARYPOSTto 86, and the original's BuildingAvailability jump table sends 86 to modal 0x75 (MMT_DISABLE_ARAB_TROOPS), whose menu items are this PR's DisableArab handler and render; 87 goes to 0x73 and the barracks. The MMT names, the menu names and this PR's names are right.aiPlaceAIVBuildingandshouldNotBuild...use both mapper names, so they are worth a look.GameCore::isNameEntryActivereads inverted (as in Reimplement 5 UI::MenuItems SaveLoadMap and Unused functions at 100% #341): it is 1 when a title already exists (GameStartEnterName_Prepare stores 1 for a non-empty name), and the text box and "OK" are hidden then. Something likeisTitleSet?DAT_00df5540is the step transition (0 none, 1 fade in, 2 fade out, fromInitTutorialStepTransition),DAT_00df5558the step's current action,DAT_00df555cthe step's action count (TutorialStepActionCount[step]), andDAT_00df5560whether the player has done what the action asks (only ever 0 or 1, aBOOLEnumcandidate).DAT_ButtonUnknownZerois 1 for a button that is hidden (here) or greyed out (NetworkSessions "Host"/"Join" without a modem): something likeDAT_ButtonInactiveUnk?🤖 Generated with Claude Code