Repository navigation
Reimplement 5 scenario and map editor menu functions at 100% - #352
Merged
Merged
Conversation
MenuItemRenderFunction_TraderSettings, from our draft on the fork branch reimpl/UI-MenuItems-3-development (88.0% there, in sourcehold#327). Each goods row shows the good's picture and "On" or "Off" (greyed out by blending when off); below 1000 are the dialog's own buttons, 1100 is the "Trader 1" header box and the rest is the goods list box. The "On" and "Off" texts take their position as locals, y then x (in the call: quick_diff 0.9570 -> 0.8865; x first: 0.9140), the draft's register blocker. The four kinds of button are one if/else-if chain with a single RT_MAP_GAME store at the end, which MSVC duplicates into each tail as the original has it (ties with the seven early returns). The parameter is button and the goods index row, as in main's TraderSettings handler; the shadow colours are COL_003E66 and COL_000000; partial pitch's picture is pitch's, with a comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_EditorMapTypeQuickChange_Main, from our draft on the fork branch reimpl/UI-MenuItems-3-development (94.5% there, in sourcehold#327). The editor's quick buttons set the map lock state (0 to 2), the map type (3 to 6, unless the map has an event that needs another), single or multiplayer (10, 11), or the map size (20 to 23, MC_MAP_SIZE_*), which resets the map and everything that depends on its size. The parameter is button, as in main's render function of this menu. The map size chain has no else, as in the original: button is 20 to 23 in that case, and the original's unreachable else reads mapSize unset, which MSVC keeps in the parameter's stack slot (`mov eax, [esp + 8]` at 0x004ABF39). An else keeping button measures reccmp 94.5% (the draft); reassigning the parameter instead of a mapSize local: reccmp 89.5%. The sizes are compared in turn (a switch: reccmp 85.5%). For the PR text: an uninitialised read, but only on a path no caller can reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_EditScenario_EventAndInvasionList, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 79.5% in sourcehold#328). One row of the scenario editor's event list: the selection is clamped to the list, the row's background, the event's month and year, and then by its kind an invasion ("Invasion", its unit count and the repeat) or an event (its name and the repeat). The draft returned when an event's text index went past 155. The original adds 21 there and goes on (the event names have 21 other texts after the 28th), so events of those kinds lost their name and repeat in the draft. Both kinds end in "Month" or "Months" written out in each case, with one ")" after the switch: MSVC merges the two if/else copies into the original's one tail (a flag set in both cases and one if after the switch: quick_diff 0.9831 -> 0.7973). The month goes into a local first (in the call: 0.9831 -> 0.9155) and the event name takes its position as y then x locals (0.9696); without them the scratch registers rotate and the copies don't merge. The event index is written out at each use because the original re-reads eventListScrollOffset after every call (an eventID local: 0.6609). The colour is set in each branch (a default overridden: reccmp 100.0% -> 99.3%, which quick_diff can't see: it shows both colour constants as one token). quick_diff's 0.9831 is all artifacts (colour immediates, ret). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sumUnitCounts (0x004B8000) adds up the unit counts of the current event, stores the sum at this+0x14548 and leaves it in eax. EditScenario's TextBoxLike render (0x004BF1D0) pushes that eax straight into renderNumberToScreen2 for box 101, so the function returns the sum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
indexStored (0x00013580) picks the starting good, unit or popularity that the scenario editor's text box edits. EditScenario's TextBoxLike render (0x004BF1D0) compares it signed (cmp eax, 0x14 / jge at 0x004BF37C and cmp eax, 0x1e / jge at 0x004BF3AF), so the field is an int, not undefined4. Main's two users, EditScenario's EventAndInvasionList handler and the TraderSettings handler, stay at 100% with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scenario editor's starting units sit at MapPropertiesState+0xEC, right after SEC_StartingResources. EditScenario's TextBoxLike render (0x004BF1D0) stores box 3's typed value for indexStored 20 to 29 at [indexStored*4 + 0x016538F4] (0x004BF3C9, 0x004BF3F5), which is element indexStored - 20 of the 20 ints at +0xEC, and sumUnitPoints (0x004B7FA0) adds them up from +0xEC. As an array the code indexes it inside its bounds instead of past the end of SEC_StartingResources. The units are in SiegeUnitCounts' order (archers first). No .cpp on main reads the field; MapAndTimeState::siegeInformation keeps SiegeUnitCounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EditScenario's TextBoxLike render (0x004BF1D0) compares the user text handler's textArrayIndex with 10, 12 and 14 (0x004BF281, 0x004BF331, 0x004BF426, 0x004BF47E) and reads those text slots, next to 11 and 15, which the enum already names TAIT_UNKNOWN_11 and TAIT_UNKNOWN_15. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_EditScenario_TextBoxLike, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 81.2% in sourcehold#328). The scenario editor's text boxes: boxes 0 to 7 show a text slot of the user text handler, with the cursor when that slot is being typed into; box 3 stores the typed starting good, siege unit or popularity, box 7 an event condition value; 100 to 102 show unit totals. Each box renders its own text, as in the original: MSVC merges the identical endings, so each case keeps its own y, x and slot push before the shared getTextArrayPointer call (one call after the switch: quick_diff 0.9606 -> 0.9356). The y, x and text locals stay (positions in the call: 0.8724; the text in the call: 0.8459). The totals are read into locals before their render calls, as the original calls the sum first. quick_diff's 0.9606 is all artifacts (colour immediates, ret, the jump table). Box 3 with indexStored 20 to 29 stores into the siege units (SEC_SiegeInformation[indexStored - 20]); the draft wrote SEC_StartingResources[indexStored + 5], past the end of that array, which lands on the same address. reccmp reads 99.1%: only the call target of atol differs (the CRT's against the game's copy at 0x00583628), as in main's NewEvent handler, whose status line has the same remark. It needs the four header commits before it: sumUnitCounts returns int, indexStored is an int, SEC_SiegeInformation is an int[20], and TAIT_UNKNOWN_10/12/14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DAT_00eb0b24 (0x00EB0B24) is a counter that ScenarioDescription's Main handler (0x004D8570, button -4) steps and wraps against INT_00ed27c4: mov eax, [0x00EB0B24] / add eax, 1 / cmp eax, [0x00ED27C4] / jl at 0x004D89B2. The compare is signed, so the global is an int, not undefined4. Nothing on main uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_ScenarioDescription_Main, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 64.5% in sourcehold#328). The mission briefing's buttons: 10 starts the mission (the map and its lord unless in the builder, then the build menu), 12 and 13 go back to the map choice in the builder, 11 goes back to the mission select (or asks first while a game is suspended), 6, 8 and 9 switch the help pages (9 opens mission<N>.hlp), -1 steps the difficulty, -2 views the briefing, -3 asks to restart the mission and -4 goes to the next description page. Three behaviour fixes against the draft, all from the binary: a mission number of 0 or less becomes 1 and the mission still starts (the draft returned), the difficulty wraps from 3 to 0 and is still stored (the draft returned), and -1 doesn't fall into -2 (the draft set DAT_00ed27bc there). Three more of the same kind: 11 with DAT_00ed27bc set clears it and returns, 11 outside a campaign mission returns after switching the menu, and 12 or 13 in the builder with a game suspended returns after the yes/no dialog (the draft fell through in all three). 12 and 13 fall into 11 outside the builder, as in the original. The build menu tab is BMTT_CASTLE (10; the draft had BASMTT_HUNTERSHUT, the same value in the building menu's enum) and the landscaping tab 231, as main's hideOrUnhideUI writes it. Needs the DAT_00eb0b24 header commit before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
Main's Ghidra sync took in this branch's five header changes (sumUnitCounts int, indexStored int, SEC_SiegeInformation[20], TAIT_UNKNOWN_10/12/14) and renamed DAT_00eb0b24 to INT_00eb0b24. The two conflicts, Globals/INT_00eb0b24.hpp and Map/MapPropertiesState.hpp, take main's version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Ghidra header sync 8125c61 renamed the global DAT_00eb0b24 to INT_00eb0b24 (it took in this branch's own int retype, so the merge above drops that header commit's file in favour of main's). The ScenarioDescription render (0x004D8570) still includes and names it in the old form, so it no longer compiles on main's headers. This follows 8125c61, as sourcehold#350 did for INT_00ed3120: the include and the name become INT_00eb0b24, and clang-format re-sorts the include lines. The type is int either way, so the generated code is the same and the function keeps its 100% status line. Globals: DAT_00eb0b24 -> INT_00eb0b24 (8125c61) - UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp 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 scenario description's "briefing is open" flag only ever holds 0 or 1. Its three stores in the exe: 1 at
0x004D895F ("View Briefing", -2), 0 at 0x004D8788 (11, esi, which ScenarioDescription_Main zeroes there) and 0 at
0x004DD2CD (esi, the same register that resets the page index to 0 at 0x004DD2B7). Its readers compare it with 1 or
with a zero register (0x004D8296, 0x004D877F, 0x004DD42D, 0x004DD6F4). BOOLEnum is a typedef of int, so the size and
every access stay the same. Its only user on main and in this PR is ScenarioDescription_Main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DAT_00ed27bc is a BOOLEnum since the header commit before this one; the two stores (11 closing the briefing, -2 opening it) use its names. The same code (reccmp 100.0%). 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>
gynt's header sync (eef6f66) renamed DAT_00ed27bc to INT_00ed27bc, an int; this branch had typed it a BOOLEnum (8f6a96a), and the merge before takes main's. It is tested against 1 and set to 1 and 0, so TRUE and FALSE become 1 and 0. reccmp 100.0%. 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 scenario and map editor menu functions at 100%, each with its status line: the trader settings list, the editor's map type quick buttons, the scenario editor's event list and text boxes, and the mission briefing's buttons.
Two come from our draft #327 (TraderSettings, EditorMapTypeQuickChange) and three from our draft #328, which held gynt's drafts from his fork's
reimpl/UI-MenuItems-development; both drafts drop them in the same push. Every commit body says what changed against the draft and why. No header change is left: gynt's Ghidra sync eef6f66 renamedDAT_00ed27bctoINT_00ed27bcand typed itintrather than this PR'sBOOLEnum(8f6a96a), and this PR follows main: main is merged in, and ScenarioDescription_Main usesINT_00ed27bcand stores 1 and 0 (deb3e4f). Its first five header changes are on main since gynt's sync 8125c61 (below), main is merged in, and ScenarioDescription uses the renamedINT_00eb0b24(1be9d7d, as #350).Other PRs: the ready #348, #349, #353, #354 and #355, and the drafts #313, #318, #321, #327 and #328.
Built on top of
main(da1fef5) 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. It merges cleanly with today's main. None of it has been run in game.It went through the same checks as #351: a fresh-eyes review of every file (behaviour checked against the original's disassembly; its points applied and measured),
openshc-pr-checkwith no errors, andstatus_regression.py, which finds nothing below a known score on main or any fork.Header changes
Update: main has this field as
int INT_00ed27bcsince eef6f66; the evidence below is kept for the record.DAT_00ed27bcis aBOOLEnum(8f6a96a): the scenario description's "briefing is open" flag. Its three stores in the exe are 1 at 0x004D895F ("View Briefing", -2), 0 at 0x004D8788 (11) and 0 at 0x004DD2CD; its readers compare it with 1 or with a zeroed register (0x004D8296, 0x004D877F, 0x004DD42D, 0x004DD6F4). Its only user on main and here is ScenarioDescription_Main, which now storesFALSE/TRUE(3dcc305).On main since 8125c61:
int MapPropertiesState::sumUnitCounts()(be8277d): 0x004B8000 stores the sum atthis + 0x14548and leaves it in eax (retat 0x004B803A); TextBoxLike pushes that eax straight intorenderNumberToScreen2for box 101 (0x004BF609).int MapPropertiesState::indexStored(6b266f8): TextBoxLike compares it signed (cmp eax, 0x14/jgeat 0x004BF37C,cmp eax, 0x1e/jgeat 0x004BF3AF). Main's two users, the EventAndInvasionList handler (stores 0) and the TraderSettings handler (an array index), compile the same and stay at 100%.int MapPropertiesState::SEC_SiegeInformation[20](a16459a): the scenario editor's starting units sit at+0xEC, right afterSEC_StartingResources. TextBoxLike's box 3 stores the typed value forindexStored20 to 29 at[indexStored*4 + 0x016538F4](0x004BF3C9, 0x004BF3F5), which is elementindexStored - 20of the 20 ints at+0xEC, and sumUnitPoints (0x004B7FA0) adds them up from there. Without the array, the code indexedSEC_StartingResources[indexStored + 5], past the end of thatint[25](the same address). The units are inSiegeUnitCounts' order. No.cppon main reads the field.TAIT_UNKNOWN_10,_12and_14inTextArrayIndexType(1246843): TextBoxLike compares the user text handler'stextArrayIndexwith 10, 12 and 14 (0x004BF281, 0x004BF331, 0x004BF426, 0x004BF47E) and reads those slots, next to the already named 11 and 15.int DAT_00eb0b24(a50024f): ScenarioDescription's button -4 steps it and wraps it againstINT_00ed27c4with a signed compare (jlat 0x004D89B2). Nothing on main uses it.Behaviour fixed compared with the drafts
cmp eax, 0x9b/jle/add eax, 0x15at 0x004B8D1C-0x004B8D23), so events from type 28 on ("Turn Off Repeating Invasions", "Fire!", ...) lost their name and repeat in the list.DAT_00ed27bc(0x004D8935, 0x004D894F);DAT_00ed27bcset clears it and returns (0x004D8788-0x004D879D), instead of also closing the help and switching menus;switchToMenuView(39)(0x004D87DF-0x004D87F5), instead of opening the 1000 yes/no dialog;MenuItemRenderFunction_TraderSettingsMenuItemActionHandler_EditorMapTypeQuickChange_MainMenuItemRenderFunction_EditScenario_EventAndInvasionListMenuItemRenderFunction_EditScenario_TextBoxLikeatoldiffers (the CRT's against the game's copy at 0x00583628), as main's NewEvent handler; its status line has the same remark.MenuItemActionHandler_ScenarioDescription_MainKept as they are, and why
Each was measured; a one-line comment in the code says why. quick_diff's baselines below 1.0 here are its own artifacts (colour immediates,
ret, the jump table).!= FALSEon the hover store, as the original normalises it (setneat 0x004C109E).else, as in the original: there the button is always 20 to 23, and the original's unreachableelsereadsmapSizeunset, which MSVC keeps in the parameter's stack slot (mov eax, [esp + 8]at 0x004ABF39). Anelsekeeping the button measures reccmp 94.5% (the draft's), reassigning the parameter 89.5%, and a switch 85.5%. SomapSizeis read uninitialised on a path no caller can reach.eventListScrollOffsetafter every call (aneventIDlocal: 0.6609). The colour is set in each branch (a default overridden: reccmp 100.0% -> 99.3%).textlocals stay (the call inside the render call: 0.8459; positions in the call: 0.8724).Proposed, not changed here
MissionAestheticsDefinedData::field_0x345c[22]: the resource type of each row of the editor's goods lists (the trader rows, and the starting goods forindexStoredbelow 20), e.g.goodsListResourceOrder.DAT_00eb0b24/INT_00ed27c4: the scenario description's current page and page count (-4 "Next" steps and wraps it, 0x004DD2B7 resets them to 0 and 1, the "Next" button only shows from 2 pages on).DAT_00ed27bc: the briefing is open (-2 "View Briefing" sets it to 1, 11 clears it, and while it is 1 the render hides every button but 12); itsBOOLEnumtype is in this PR now.DAT_00ed2798: which description page is shown, 0, 2 or 3 from buttons 6, 8 and 9 (9 opens mission.hlp).IngameScenarioEventItemContent::repeat(+0x0A) andrepeatMonths(+0x0B) look swapped: +0x0A is printed just before "Month(s)" and picks between them, so it holds the months; +0x0B is printed first and is the count.s_brace_open_005a2774(")") ands_brace_close_005a2778("(") have their names swapped; the code uses them by content.sumUnitCountssums the current invasion's 25 unit counts; a name with "Invasion" in it would say so.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_TraderSettingsMenuItemActionHandler_EditorMapTypeQuickChange_MainMenuItemRenderFunction_EditScenario_EventAndInvasionListMenuItemRenderFunction_EditScenario_TextBoxLikeMenuItemActionHandler_ScenarioDescription_Main🤖 Generated with Claude Code