Repository navigation
Reimplement 5 UI functions from gynt's drafts (100%) - #386
Merged
Merged
Conversation
0x004BC6F0 is in the address list as a function but no header declares it, so its one caller, the main menu's tutorial button (MenuItemActionHandler_MainMenu_Main, 0x004251A0, tail jump at 0x00425458), could only inline it. It reads no arguments and ends in a tail jump to ResetTutorialActionTrackers (0x004BC6C0), so it is void __cdecl(): it calls InitTutorialStepTransition(1), resets the tutorial state at 0xDF554C-0xDF5564 and 0xDF556C and fills INT_ARRAY_00df5598 with each step's start. It sits among the other tutorial helpers in UI/Helpers, so it goes there, after ResetTutorialActionTrackers. The name is a proposal: Ghidra has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InitTutorialState starts the tutorial's step tracking: InitTutorialStepTransition(1), the first step's action count into DAT_00df555c, the restriction flag and current step cleared, the fixed values 32 and 36, and for each of the 32 steps where it starts in INT_ARRAY_00df5598, two past the previous start plus the previous step's action count, then ResetTutorialActionTrackers. Needs the header commit that declares it. Written from the original's instructions; gynt's draft of the main menu's handler (c9bfdf1, 8725ec5 on his fork) had the same body inlined there, which is where the reads come from. The form the original needs: the running start incremented before its store and the step's count added after it (the store as start + 1 and the step as + 2: quick_diff 0.4091, a different register for the zero). Also: countof for the 32 steps. quick_diff leaves only the tail call's form. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_MainMenu_Main handles the main menu's buttons: 1 the historical campaigns, 2 the crusades, 3 the castle builder, 4 multiplayer (only once DirectDraw is loaded), 5 quit, 6 the tutorial, 7 the credits, 8 the options, 9 the custom scenarios. From gynt's draft (c9bfdf1 on his fork's reimpl/UI-MenuItems-development, 67.12% there; his batch pass 8725ec5 left its status line at 71.7%). Needs the header commit that declares InitTutorialState: the tutorial button ends in a tail call to it, where the draft had its body inlined. The form the original needs: the menu switch and the player colour reset written out in both case 3 and case 4, each returning, so that MSVC jumps from case 3 into case 4's copy as the original does (one copy after the switch on a view variable: quick_diff 0.7756, with ebx zeroed before the dispatch). Also: the colour reset as a countof loop (MSVC unrolls it into the original's nine copies), s_Crusader_tutorial_map_005a1ff8 for the string macro, DD7_LOADED for 1792 without the cast, INT_00b95954, button for param_1, no unused usings or includes. quick_diff leaves the jump table's symbol, ret / ret 0 and the tail call's form. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader sorts the map list when a column header is clicked: 0 copies the order kept in DAT_ArrayOfMapIndices2, backwards after the first click (fileListSortOrder 0 / 1), 1 bubble sorts by the file times (2 / 3), 2 by arrayOfMapEndInt2 (lobbyMapSortOrder 5 / 6); then the map table is refreshed and lastClickedListIndex cleared. Written from the original's instructions, with gynt's draft (755f040 on his fork's reimpl/UI-MenuItems, 64.54% there; then his batch pass 8725ec5) for the reads. No header change: main's arrayOfMapEndInt2[500] at 0xB0 is the array the draft indexed through DAT_ArrayOfMapU3EndInt2, and DAT_ArrayOfMapIndices2 is read with - 1, as its three other users on main do. The forms the original needs: the next entry read before the current one in the sort loops (the other order swaps eax and ecx: quick_diff 0.8151 -> 0.9358), and the forward copy as a guarded do-while (as a for loop MSVC makes it rep movsd). Also: no decompiler locals, the sort passes as for loops on the swap count, column for param_1. quick_diff leaves ret / ret 0 and the jumps over the loops' alignment padding, which their npad hides. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LobbyMenu::MenuItemRenderFunction_LobbyMenu_ChatBox, from gynt's draft (557a0e2, 54.49%, on his fork's reimpl/UI-MenuItems; 53.8% in 8725ec5 on reimpl/UI-MenuItems-development), rewritten from the binary. Button -3 draws the chat messages, -2 the line being typed with its cursor, -1 the player's own name and the others the waiting room's texts. The branches are nested in the original's block order (early returns for -3 and -2 measure lower), and the waiting room's text comes before the -1 name, as the original lays them out. The y position is written in both calls, so MSVC shares their pushes as the original does, and the -2 branch reads the blend strength again after its calls. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectTable, from gynt's draft (5467a25, 56.44%, on his fork's reimpl/UI-MenuItems-development), rewritten from the binary. The draft drew the map's name twice when the second icon shows; the original draws it once, beside that icon (150 wide) or 20 pixels further left (170 wide), both less the first icon's 20 when it shows (iconsWidth). The file name is fetched into a local before the text call, as the original's call order has it (as an argument, &descriptionGroup is pushed first), and DAT_ButtonUnknownZero is set from a flag for the round table and the two AI lord selects (a guest stores TRUE, then FALSE), which gives the original's shared store. reccmp 100.0%. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ings - LobbyMenu MapSelectTable: the AI-setup flag is a BOOLEnum, and the file and map names are loadedName and mapName, as main's SingleplayerMapChoice_MapTable names them. The three kept shapes give their measurements: no flag 0.9607, descriptionGroup at each call 0.9649, the file name as an argument 0.9518 (against 0.9781). - LobbyMenu ChatBox: the nesting (early returns 0.6184) and the blend strength read again (the blend local 0.8803, against 0.9671) in main's one-line form. - SingleplayerMapChoice MapTableHeader: the do-while gives its measurement (a for or a while loop: 0.9283, against 0.9738), and the name sort's comment no longer explains the - 1. - MainMenu: the shared tail's comment in main's form (one copy after the switch: 0.7756, against 0.9500). quick_diff output is identical for all four files. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Style guide reading (advisory, posted once) 1 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 1 of the 5 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 9 — Prefer
|
Main's Ghidra sync 6c1e0bd brought this branch's header changes; main's versions are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 10, 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%: four from gynt's drafts (below 100%), and one new function that one of them tail-calls. 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.
MenuItemActionHandler_MainMenu_MainHelpers::InitTutorialState(new)MenuItemActionHandler_SingleplayerMapChoice_MapTableHeaderMenuItemRenderFunction_LobbyMenu_ChatBoxMenuItemRenderFunction_LobbyMenu_MapSelectTableMeasured on today's main (b6d9688).
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie.booltoBOOLEnum. quick_diff output is identical for every file it touches.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score below a known one.Behaviour fixed compared with the drafts
LobbyMenu MapSelectTable draws the map's name once, with one text call per path, each followed by a return:
When the second icon showed, gynt's draft fell through and drew the name twice.
MainMenu's tutorial button tail-calls
InitTutorialState(jmp 0x004BC6F0at 0x00425458) instead of carrying its body inlined.Header change (in a commit of its own)
gynt's Ghidra sync 2bd620b brought this line to main. Main (39ed817) is merged in (60802f9), so the commit now matches main, and the "Declaration/type change validation" check passes. The five files' quick_diff output is identical before and after the merge.
Helpers::InitTutorialState()is declared, with its resolver off (7d987ae).void __cdecl().Kept as they are, measured with quick_diff (each has a one-line comment)
descriptionGroupdeclared once for both callsThe style-lint bot will post on the do-while; its comment gives the numbers above.
Other notes:
DAT_ArrayOfMapIndices2[i - 1], as main's three other users do. Ati = 0that is the address the original reads (0x011275F8), which suggests the header's array starts 4 bytes earlier than declared. It could be fixed in the header; the code is left as main's users have it.'\0'in MainMenu stores into thechar[1001]file name (rule 26).DAT_00df55xx,INT_00df55xx,DAT_00b960dc,INT_00b95b64,INT_00b95954) have no Ghidra names yet; main's siblings use the same ones.Other PRs
🤖 Generated with Claude Code