Repository navigation
Reimplement 5 UI menu dialog, minimap and progress bar functions at 100% - #348
Merged
Merged
Conversation
MenuItemRenderFunction_UnusedEconomicMissionSelect_MissionSelect, from gynt's draft on his fork's branch reimpl/UI-MenuItems (43.5% there). A mission not reached yet is an empty cell; the selected one shows its number and name; the others the same in two colours, one call per colour, as in the original (one renderText2 with a colour local, gynt's draft: quick_diff 0.9302 -> 0.6615). DAT_ButtonUnknownZero is set to TRUE/FALSE. Shape: the selected mission's name position as locals, y then x (in the call: quick_diff 0.9302 -> 0.7608; x first: 0.8992); the other missions' number position and value worked out in each branch (once, before the hover test: 0.9302 -> 0.8760; any order of the three ties inside the branches). A comment says what the button holds: minus the mission number, shown as mission - 32 and named by entry mission - 11 of TEXT_MISSION_NAMES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The five fields after currentModalDialog (+0x60..+0x70) are the stack of dialogs below the current one, and the original moves them as an array: popModalDialog shifts them down one and activateModalDialogAndClearText pushes the current dialog on top, each a loop the compiler unrolled (0x00493900, 0x004916C0). Written as five named fields neither function matches (quick_diff 0.8788 and 0.7742). Now previousModalDialogs[5], most recent first. main's clearModalDialog2to6 is the only .cpp on main that names the fields; the next commit moves it over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's MenuTextInputState::clearModalDialog2to6 (0x00491730) named the five fields the previous commit makes one array. It now clears previousModalDialogs in one loop (countof, to MMT_NO_MENU, which is 0) and compiles to the same code (reccmp 100.0%). Its first include is now the class's .func.hpp, as its siblings have it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuTextInputState::popModalDialog, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (93.9% there, also in sourcehold#313). The previous dialog comes off the stack, the rest move down one (a loop over previousModalDialogs; written out per element: quick_diff 0.9394 -> 0.8788), and it becomes the current dialog. The save-map dialog gets its file list and text input back; an empty stack clears every other dialog. Guarded, not an early return (an early return for the empty stack: 0.9394 -> 0.8788). resetToTextIndex takes TAIT_TWO__FILTER_A; the last index is countof(previousModalDialogs) - 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuTextInputState::activateModalDialogAndClearText, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (90.3% there, also in sourcehold#313). With no dialog open it saves the text array index and clears the text; a dialog that isn't already current is pushed onto the stack, counting down over previousModalDialogs from countof(previousModalDialogs) - 1 (written out per element: quick_diff 1.0000 -> 0.7742; i != 0 as the bound: 0.5312), and activated. The draft's pointer over ¤tModalDialog is gone, and so is the imported plate comment. The text array index is saved through the global, as the original does (this->: quick_diff 1.0000 -> 0.9355). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MinimapViewState::convertMinimapClickToTileXY, from our draft on kotijekriv's fork branch reimpl/UI-Core-development (87.1% there, also in sourcehold#313). The mouse position on the minimap becomes a screen point, looked up in the current orientation's screenPointToTileNumber table (80400 entries apart, as main's ViewportBasedTileNumber writes them), and the tile is split into x and y; with clicks disabled both are -1. Orientation 0 sets the offset again, as main's renderPreviewAtMouseLocation does (without that arm: quick_diff 1.0000 -> 0.8714; it was the draft's register swap). Guarded, not an early return (an early return when disabled: 1.0000 -> 0.9000). Computing the offset from the orientation instead: 0.5507. The redundant (short) cast on the short table is gone; 0x191 is 401. The flag is a truthiness test. The Y term and the offset stay up front (Y inline: 1.0000 -> 0.7770; the offset declared at first use: 0.6714); comments say why the +6 / -6 both stay and that the out parameters hold the screen point until the tile is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rendering::RenderLoadAndSaveBar, from our draft on kotijekriv's fork branch reimpl/UI-Rendering-development (85.7% there, also in sourcehold#313). At most every 30 ms it draws the progress bar, in game on the map surface and flipped, in the menus on the menu surface and blitted. The blit mode is 2 on the siege tent's tower and shield tabs unless the building and status menu is open, else 1: one store of 1 for both paths, as in main's WinMain (there a comma expression, here a siegeTowerOrShieldTab local; an if/else with a store each: quick_diff 0.9459 -> 0.8742, and MSVC then keeps 1 in edi, the draft's blocker). The 30 ms, the per-mille progress (300 pixels wide when full) and the 15-pixel height have a comment each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
…nto reimpl/batch15-100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its only stores in the exe are 1 at 0x004B49C8 (ebp, set to 1 at 0x004B4813) and 0 in GameCore's initialiser (mov [eax + 0x58], ecx at 0x0046B21D, ecx zeroed at 0x0046B1F2); its readers compare it with a zero register (0x004269FC, 0x00426D4C). BOOLEnum is a typedef of int, so the size and every access stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its only stores in the exe are 1 at 0x00434328 (eax, set to 1 at 0x00434319 on both paths) and 0 at 0x0043432E; no MinimapViewState method writes it through this. BOOLEnum is a typedef of int, so the size and every access stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpp-linter checks whole changed files: the BOOLEnum include added in 65c0847 sorts with the project includes. Whitespace and include order only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge of eef6f66 left the BOOLEnum using-declaration twice: the sync added its own when it took minimapClickEnabled's BOOLEnum from this PR. The header is now the same as main's, so the PR no longer changes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
gynt
approved these changes
Nov 7, 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 UI functions at 100%, each with its status line: the menu dialog stack's push and pop (
activateModalDialogAndClearText,popModalDialog), the minimap click (convertMinimapClickToTileXY), the load/save progress bar (RenderLoadAndSaveBar) and an old menu's mission select render.Four come from our draft #313, which drops them in the same push; the mission select continues gynt's draft on his fork. Every commit body says what changed against the draft and why. No header change is left: gynt's Ghidra sync eef6f66 took this PR's two header changes (below) into main, and main is merged in (614ef85). Its first header change, the array, is on main since gynt's sync 8125c61 (below), and main is merged in. That sync leaves main's own
clearModalDialog2to6.cppnamingmodalDialog_2..6, so it no longer compiles; this PR's fe606002c moves it to the array, so merging this mends main.Other PRs: the ready #349 and #352, and the drafts #313, #318, #321, #327 and #328.
Built on top of
main(7621d4f) with the bundled MSVC1400-SP1, natively on Windows, against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a). The branch was built and measured 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 #346: a fresh-eyes review of every file (behaviour checked against the original's disassembly; its points applied and measured),
openshc-pr-check, andstatus_regression.py, which finds nothing below a known score on main or any fork.Header changes
Update: both are on main since eef6f66. 222e50c drops the BOOLEnum using-declaration that the merge left twice in
MinimapViewState.hpp, so the header is the same as main's. Main's ownclearModalDialog2to6.cppstill doesn't compile there until this PR lands (fe606002c below); the other files the sync broke are in #368.GameCore::unlockAllHistoricalCampaignsis aBOOLEnum(334c1ef): its only stores in the exe are 1 (0x004B49C8, from a register set to 1 before) and 0 (GameCore's initialiser, 0x0046B21D); its readers compare it with 0.MinimapViewState::minimapClickEnabledis aBOOLEnum(65c0847): its only stores are 1 at 0x00434328 (the register is 1 on both paths into it) and 0 at 0x0043432E, and none of MinimapViewState's own methods writes it.All six of main's users of the two fields still measure 100.0%.
On main since 8125c61:
MenuTextInputState'smodalDialog_2..6are one arraymodalDialog_2..6(+0x60..+0x70) becomeMenuModalTypeInt previousModalDialogs[5]: the dialogs belowcurrentModalDialog, most recent first (commit b93f85653). All four functions that touch them treat them as one run:Written as loops over the array, the push and the pop match; written as five named fields they don't (quick_diff 0.7742 and 0.8788; the #313 drafts reached reccmp 90.3% and 93.9%).
currentModalDialogstays a field of its own: 17 files on main name it, and neither loop's range includes it. Layout: 0x60 + 20 = 0x74 =fileListEntryCount, and the size assert is unchanged.Main's only user is
clearModalDialog2to6, moved to acountofloop over the array in the next commit (fe606002c, same code, still 100%). b93f85653 alone doesn't build because of that; they're kept apart so the header is in a commit of its own.Off main, these drafts name the old fields and need the same move when they land:
Constructor_MenuTextInputState.cpp,activateModalDialogAndClearText.cppandpopModalDialog.cppon sourcehold'sreimpl/UI-Coreand on gynt'sdevelopment,reimpl/UI-Core-development,reimpl/UI-MenuItems-development,reimpl/UI-Rendering-developmentandreimpl/UI-MenuItems-100(6and8'sreimpl/UI-Coretoo). This PR replaces the activate and pop drafts; the constructor's fiveMMT_NO_MENUstores become a loop overpreviousModalDialogs.Behaviour fixed compared with gynt's drafts
His drafts of three of these (on
development,reimpl/UI-Core-developmentandreimpl/UI-Rendering-development) lose a return the original has; our #313 drafts had them, and here each is a guarded if/else:popModalDialog: after reactivating the previous dialog it fell intoclearAnyOtherModalDialogsand closed it again; the original returns (pop esi; retat 0x00493969).convertMinimapClickToTileXY: the computed tile was always overwritten with -1/-1; the original returns (ret 8at 0x004B525D).RenderLoadAndSaveBar: in game it also drew the bar on the menu surface and blitted it after the flip; the original returns (retat 0x0049375A).activateModalDialogAndClearTextpopModalDialogconvertMinimapClickToTileXYRenderLoadAndSaveBarMenuItemRenderFunction_UnusedEconomicMissionSelect_MissionSelectKept as they are, and why
All five are reccmp 100%. quick_diff compiles without LTCG, so some kept forms read below 1.0 there (0x00426D30 0.9302, 0x00493900 0.9394, 0x00493690 0.9459); the numbers below are from that baseline. A one-line comment in the code says why.
DAT_SomeTextArrayIndexis written through the global, as the exe writes the absolute address (this->: 1.0000 -> 0.9355); the push as a loop (written out: 0.7742).siegeTowerOrShieldTablocal, as main's WinMain has one store (there a comma expression); an if/else with a store each measures 0.9459 -> 0.8742, because MSVC then keeps 1 in edi, which held the draft at 85.7%.Proposed, not changed here
MenuTextInputState::clearModalDialog2to6->clearPreviousModalDialogs, now that the fields are an array.MinimapViewState::convertMinimapClickToTileXY(int* param_1, int* param_2)->(int* tileX, int* tileY); the .cpp already uses those names.Rendering::RenderLoadAndSaveBar(int progressValueUnk)->progressPerMille: callers passsize * 1000 / total(writeMapOrSaveFile, readMapOrSavFile) or 50.UserTextHandler::allowUserTextInputmay be aBOOLEnumtoo, but it has more than 20 stores, many of them from registers we haven't all traced to 0 or 1 yet, so it isn't changed here.WindowAndDirectDraw::pendingBltModeholds 1 or 2 (here and in WinMain); an enum could name the two values.gynt's other commits on these functions
Each commit body names the commits it continues. gynt has more on the same functions on his fork, and they are credited here too: his best-scoring commit on the address and his newest one on the file, where the body doesn't name them. Where one of them is at 100%, his version already matched the original, and a fix this text describes for that function was only against the earlier draft it names.
MenuItemRenderFunction_UnusedEconomicMissionSelect_MissionSelectpopModalDialogactivateModalDialogAndClearTextconvertMinimapClickToTileXYRenderLoadAndSaveBar🤖 Generated with Claude Code