Repository navigation
Reimplement 5 UI functions from gynt's drafts and #327/#328, with three header commits (100%) - #406
Merged
Merged
Conversation
MapConstants names the map sizes 160, 200, 300 and 400 but not 100, which the editor also offers: the map-size switch in MenuView_MapEditorProperties_DoEveryFrame (0x0042E0D0) has cases for 100, 160, 200 and 300, with 400 as its default, and now uses MC_MAP_SIZE_100 there. A new enum value changes no code; the functions that read the map constants measure the same before and after (reccmp, one build with every user on the build list). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d are typed Three undefined4 fields of MenuTextInputState hold values whose type main already has. OptionsMenu's SubOptionsButtons handler (0x00493BD0) fills each of them when it opens the video options, and the VideoOptions render (0x00492170) tests them against that type's values: - menuCursorType (0x50) is a CursorTypeInt: copied from MouseState's cursorType, and compared with CT_ANI_CURSOR and CT_WINDOWS_LIKE_CURSOR to pick each cursor button's highlighted icon. - menuCurrentlySelectedResolution (0x28) is a ScreenResolutionEnumInt: copied from WindowAndDirectDraw's currentGameResolution (a ScreenResolutionEnumInt on main), and switched on with the SRE_ values to pick the resolution text. - menuScrollSpeedSetting (0x34) is a ScrollSpeedInt: copied from ScrollingHandler's scrollSpeedSetting_0x38 (a ScrollSpeedInt on main), and switched on with SS_SLOW, SS_FAST and SS_NORMAL to pick the scroll-speed text. These two are the only reimplemented functions that use the three fields, and both measure the same before and after (reccmp 100.0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ints skirmishTrailStartDateMonths, warchestTrailStartDateMonths, extremeTrailStartDateMonths and historicCampaignNumber were dword. The original compares them signed: MissionFinishedTransition's DoEveryFrame (0x004DC500) tests `months - <trail>StartDateMonths < monthsTaken` with jl (0x004DC6E9, 0x004DC70E, 0x004DC732) and `missionNumber1to20 > historicCampaignNumber * 5` with jle (0x004DC918), which an unsigned field could only give through (int) casts. Every other user on main measures the same after the change (reccmp, one build): playUnitSpeechEffect, incrementMissionProgress, switchToMenuView (98.7 before and after, its call target), readMapOrSavFile, HistoricCampaignSelect's handler, and HistoricCampaignIntro's and HistoricCampaignOutro's Prepare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft 86f6e30 (76.56%, "Map-size dispatch is a switch"), without its gotos and decompiler locals; the behaviour is the same. The forms the original was compiled from, each measured (quick_diff 0.9964, against 0.6978 for the draft built on main; reccmp 100.0): - the header texts' position is read into locals before the single/multiplayer branch, y first, and so are the map name's position in each of its two branches and the clicked-button texts' (inline: 0.7363, 0.8768, 0.8659, 0.9746); - the separators and map-type names write x + 140 / y + 35 at each call: reading the textX / textY locals there measured 0.7615, so a comment says the original reads the position again; - the minimap starts at the centre and each size steps back to its corner (left -= 50, top -= 50), with the centre copied after the map-size default (copied straight after top: 0.9909); - the size label's dimmed box takes the text width as a nested call, so its other arguments are pushed first. The 100 map size is MC_MAP_SIZE_100 (the MapConstants header commit). COL_BLACK's short value is passed uncast, needsRedraw takes TRUE, and the string comments stand above their calls, the TEXT_MAPEDIT entries included ("Multi-Player", "Untitled", "Flag this map as Balanced" / "Un-Balanced", "Invasion", "Economic"). The draft's field44_0xa4 is main's field_0xa4. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten from gynt's draft (ea6f9bb at 47.9%; his last reimplement commit on the file is 8725ec5 and his last style pass dd1a7c4; 0.5519 in quick_diff for the draft built on main), with early returns. reccmp 99.4, normalised 100.0: the only difference is the first tail call's target, which goes through the resolver for setScreenMenuSurfaceHeightRangeToResolution (0x0044CD30), not reimplemented yet. Behaviour fix: when the description is not from the string table, the original draws it, resets the surface height range and returns; the draft went on to draw the string-table text as well and reset twice. Forms the original was compiled from, measured (quick_diff 0.9882): the button position is read only after the three conditions; top is computed before right (right first: 0.9704); the lines work from top rather than a local for the button's y (a y local: 0.8798); x - 1 is written at each use (in a local: 0.9436). The first dimmed box and right take the x local (the same code). The parameter is never read, so it is named unused; the colour's short value is passed uncast. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewritten without gotos from gynt's draft (638ed4e at 56.76%; 0.6469 in quick_diff for the draft built on main). reccmp 100.0. The decompiler's gotos are MSVC's jump threading over plain if/else chains, so the source is written as those: the wait before leaving uses a flag that MSVC threads away; every exit after it shares the final skipStoreSKMasters = 0 (the early return does not reach it, as in the original); the record-time update and the progress step are two separate dispatches on the trail type; and each trail's step is nested, the progress incremented in both branches (as three separate ifs: quick_diff 0.6224; alive read into a local: 0.8892). The builder branch is a switch on the map type (an if/else: 0.9905). The progress steps are ++; the loop-flag stores before the two endSoundStream calls are indexed by SND_STR_SPEECH_2 and SND_STR_SPEECH_1, being endSpeechStreamsAndResetLoopFlags (0x00424700) written out inline; the trail start dates and historicCampaignNumber need no casts after the GameCore header commit; the Bink handle is compared with NULL and the wait flag is a BOOLEnum. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_General_CreateEventCallbackFunction, from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development, 4967da7, 96.8%; the file's newest commit on the draft is 446f9fa), itself rewritten from gynt's 4e09857 (95.35%). The bandits text now reads its position into `int const textY` then `textX` inside each of the two colour paths: MSVC still merges the two calls into the original's one, and the first push 0 and the " - " text's registers now land where the original has them. With the position written inside the calls it measured 96.8%. reccmp 100.0, normalised 100.0, quick_diff 157/157 at 1.0000. The parameter is textNumInGroup, as main names it in RenderScenarioButtonWithText, which gets the same value. Case 93 sets option = 2 rather than the draft's iconOffset, which holds 2 there (the same code), and a comment marks case 148's fall-through into 146. Behaviour fix kept from sourcehold#327: a crusader or arabian button that is not the current choice falls back to the default button render; gynt's draft fell through into the bandits case. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_VideoOptions_Main, from the draft sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 6325fb7, 80.4%; the file's newest commit on the draft is a552e96), itself gynt's draft (newest gynt reimplement commit on the function: a457575). Three changes: - The button rows (not pressed, pressed) each make their own text call with their own position, y then x, and the zoom and scroll-speed rows share one call after their switches. MSVC merges the button calls into the original's and puts the push 0s where the original has them; the draft's single shared call with an iVar1/yParam/color set on every path measured 0.9845 in quick_diff. - The resolution cases are written in the original's block order (800x600, 1024x600, 1024x768, 1280x1024, 1600x1200, ...): their blocks differ only in the string, so quick_diff read 1.0000 while reccmp read 81.9 until the order matched. - The first test is `button <= -10`, as the original's `cmp -10; jg`. Behaviour fix: with an unknown resolution, button -1 returns, as the original's jump-table default does (the same `return` as a button that is not -1, 0x0049261E); the draft fell into the zoom switch and drew the zoom text. reccmp 100.0, normalised 100.0, quick_diff 388/388 at 1.0000. The cursor tests use CT_WINDOWS_LIKE_CURSOR and CT_ANI_CURSOR and the scroll-speed cases SS_SLOW, SS_FAST and SS_NORMAL (the fields are typed in the MenuTextInputState header commit). `int icon = 182; if (..) icon += 2;` measured 0.9871, so the icon still starts at 0 and a comment says so. The resolution strings are string-literals.hpp pointers with their comments above the calls, the no-op (int) casts on the int button globals are gone, the parameter is button and the icon and text indices have names. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
added a commit
that referenced
this pull request
Nov 14, 2026
Main's Ghidra sync 3fe22dd has this PR's header changes, so the PR no longer changes a header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 14, 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%, with three small header commits they need. Three of the functions are rewrites of gynt's drafts, with his draft used for the reads. The other two come from our drafts #327 and #328, which started from his versions too. 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.
MapEditorProperties::MenuView_MapEditorProperties_DoEveryFrameMapEditorProperties::MenuItemRenderFunction_MapEditorProperties_MapDescriptionBoxMissionFinishedTransition::MenuView_MissionFinishedTransition_DoEveryFrameGeneral::MenuItemRenderFunction_General_CreateEventCallbackFunctionVideoOptions::MenuItemRenderFunction_VideoOptions_MainMapDescriptionBox read 100.0% in the full build described below. Built with only this round's files, it reads 99.4% raw and 100.0% normalised: the one difference is the target of its first tail call, which goes through the resolver of
setScreenMenuSurfaceHeightRangeToResolution(0x0044CD30, not reimplemented yet). So it is 100% either way by the call-target rule.Measured on main ea63a49.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), and sourcehold's reccmp (6f980a441) with--resolve-wrapped-calls --ignore-security-cookie.MenuTextInputStateheader commit, and+ xin MapDescriptionBox. Every function they touch reads the same before and after.openshc-pr-checkgives no errors, andstatus_regression.pyfinds no score below a known one.What got them to 100%
left -= 50; top -= 50). The size label's dimmed box takes the text width as a nested call, so its other arguments are pushed first.x, which the first dimmed box andrightboth use (the same code as reading the global again).default: returnis the original's jump-table default, and the first test isbutton <= -10, as the original'scmp -10; jg. The cursor tests and the scroll-speed cases use the enum names (CT_ANI_CURSOR,CT_WINDOWS_LIKE_CURSOR,SS_SLOW,SS_FAST,SS_NORMAL).Behaviour fixed compared with the drafts
returnas a button that isn't -1, at 0x0049261E). The draft fell into the zoom switch and drew the zoom text.Header changes (each in a commit of its own)
MC_MAP_SIZE_100(56222fc).MapConstantsnames the map sizes 160, 200, 300 and 400, but not the 100 the editor also offers. The map-size switch in MapEditorProperties DoEveryFrame (0x0042E0D0) has a 100 case beside 160, 200 and 300 (400 is its default), and uses the new name. A new enum value changes no code.Three
MenuTextInputStatefields get the types main already has (555f12c), instead ofundefined4. OptionsMenu's SubOptionsButtons handler (0x00493BD0) fills all three when it opens the video options, and the VideoOptions render tests each one against its type's values:menuCursorType(0x50) is aCursorTypeInt. It is copied fromMouseState's cursor type, and compared withCT_ANI_CURSORandCT_WINDOWS_LIKE_CURSORto pick each cursor button's highlighted icon.menuCurrentlySelectedResolution(0x28) is aScreenResolutionEnumInt. It is copied fromWindowAndDirectDraw::currentGameResolution, which is aScreenResolutionEnumInton main, and switched on with theSRE_values to pick the resolution text.menuScrollSpeedSetting(0x34) is aScrollSpeedInt. It is copied fromScrollingHandler::scrollSpeedSetting_0x38, which is aScrollSpeedInton main, and switched on withSS_SLOW,SS_FASTandSS_NORMALto pick the scroll-speed text.These two functions are the only reimplemented users of the three fields, and both read 100.0% before and after.
GameCore::skirmishTrailStartDateMonths,warchestTrailStartDateMonths,extremeTrailStartDateMonthsandhistoricCampaignNumberareints (e2ede57), notdwords. The original compares them signed: MissionFinishedTransition DoEveryFrame testsmonths - <trail>StartDateMonths < monthsTakenwithjl(0x004DC6E9, 0x004DC70E, 0x004DC732), andmissionNumber1to20 > historicCampaignNumber * 5withjle(0x004DC918). With unsigned fields that takes(int)casts. Main's other users read the same before and after the change, both in a build of the fields' users and in the full build: playUnitSpeechEffect, incrementMissionProgress, switchToMenuView, readMapOrSavFile, HistoricCampaignSelect's handler, and HistoricCampaignIntro's and HistoricCampaignOutro's Prepare. Main ea63a49 has no new users of these fields.The declaration check will fail and label this PR until main has these lines. Then I'll merge main in.
Two functions leave the drafts
General::MenuItemRenderFunction_General_CreateEventCallbackFunction(0x004BBA60) leaves Reimplement 7 UI::MenuItems functions (draft, below 100%) #327.VideoOptions::MenuItemRenderFunction_VideoOptions_Main(0x00492170) leaves Reimplement 24 UI::MenuItems functions from gynt's drafts (not yet 100%) #328.Each draft gets one commit that removes the
.cppand puts its status line back to main's (fba4a22 on #327, 1849424 on #328). Both drafts still compile without them.Kept as they are, measured with quick_diff
x + 140andy + 35at each calltextX/textYlocals there: 0.7615top: 0.9909topworked out beforerightrightfirst: 0.9704top, with no local for the button's yx - 1written at each usealivein a local: 0.8892isSkirmishTrail == TRUEint icon = 182; if (..) icon += 2;: 0.9871The kept forms that a reader might tidy away each have a one-line comment.
Numbers left as numbers:
textNumInGroupis a number in theTEXT_SCENARIOgroup, with no enum on main.MenuTextInputState::unknownZoomRelatedFlag01is anundefined4with no enum.What some placeholders hold
DAT_00b960f4: the map description's scroll offset in pixels. Main'sMapDescriptionScrollbarhandler moves it in steps of 14 and clamps it, andSingleplayerMapChoice_MapTableresets it to 0. The render subtracts it from the text's y.INT_00b960e4: whether the map has a name. While it is 0, MapEditorProperties showsTEXT_MAPEDITtext 24 ("Untitled") in the name row, otherwise the user's text 2. Main'sUnusedCreateSiege_SiegeThathandler sets it to TRUE.INT_00b95f68: main'sMapDescriptionBoxaction handler sets it to TRUE when the box is clicked. MapEditorProperties DoEveryFrame clears it, together withMenuTextInputState::field_0xa4, while that field is set.Other PRs
build_quiet.pyfails when cmake's configure fails) are merged. This branch sits straight on main now, soprocessMapOrientationChange.cppis no longer in its diff.🤖 Generated with Claude Code