Repository navigation
Reimplement 24 UI::MenuItems functions from gynt's drafts (not yet 100%) - #328
Draft
kotijekriv wants to merge 70 commits into
Draft
kotijekriv wants to merge 70 commits into
kotijekriv wants to merge 70 commits into
Conversation
Used by the drafts in the companion development PRs: LobbyscreenStartButtonClick and CrusadeMap_Main play sound 253 when they switch to the rankings screen. The LobbyscreenStartButtonClick draft wrote it as SEID_UNIT_DAMAGE3 | SEID_ARROW_SHOOT (248 | 5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lobby's keep-position drag keeps the dragged player's position in DAT_00b95960 (-1 for none, compared signed: cmp/jl at 0x00442A29) and its slot index in DAT_00b95f64 (an array index). DAT_00b95b74 is the map description's height, used signed in the scroll limit. General_MenuMiniMap reads DAT_00b95960 here; the other users are drafts in the companion PRs (LobbyscreenStartButtonClick, MapEditorProperties_MainButtons, SingleplayerMapChoice_ButtonsAndHands). On main, DisplayMapDescriptionAndAllocatePlayersToSlots stores to DAT_00b95b74 and compiles to the same instructions with the int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al pass; structure gynt's draft. Compiles at a521bf7 again (GameModeInt include). The map-name extension is a strcat with the string-macros.hpp literal (the draft's hand-made scan and strcpy into the end), and auto_backup_map.map is STR_AutoBackupMap; quick_diff 0.6907 -> 0.7065. The rest is the mechanical pass. Both PlayerSlotUnitColor copies are for loops (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: the menu tabs to switch to are ActiveMenuTab structs now (.tabType). auto_backup_map.map is STR_AutoBackupMap; the rest is the mechanical pass (identical code). The player IDs are set by a for loop (identical code). Re-measured on main 06d4938, where sourcehold#319 and sourcehold#322 reimplement callees of this function: 50.6% -> 53.2% (same code as before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: the byte the draft wrote through units[0x9bb].field_0x3e3 (a field the header no longer has) is addressed from that unit's start + 0x3e3, the same address; the target is not really in a unit, see the PR text. The rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BuildMenu_UnitActionButtons' render function tests the selected unit's type against -1 (no unit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InGameMenu_PeasantBuildAndRightClickMenuSelection compares the active build-menu tab with 49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It copies the text it is given into the active text slot and does not write to it (0x00472C30), so its parameter is const. EditScenario_BaseMenuButtons passes the string pointer for "", which is const; readUserConfig on main passes a char* and compiles to the same code (quick_diff identical). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again: getResourceSpace takes a ResourceType now (the draft passed (int*)(int)x). Gold is RT_GOLD; the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass; the no-unit test uses UT_NONE (header commit). quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again (InGameEventUnionVersion using). The %d and empty strings are their string-literals.hpp pointers (copyIntoTextArray takes a char const* now, header commit), the starting resources are indexed by RT_GOLD / RT_PARTIALPITCH; the rest is the mechanical pass. The new event's condition stores name their fields (conditions[k].subType and .enabled) instead of byte offsets, identical code; conditions 5-7 stay written out, since a for loop loses the match (quick_diff 0.6452 -> 0.5879). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pass; structure gynt's draft. Compiles at a521bf7 again (AlphaAndButtonSurface's processBuildingClickBonus and selectUnitAndOpenStatusMenu were renamed). Tab 49 is BMTT_UNKNOWN_49 (header commit); the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. The group maximum and the group count are for loops and the copy of the saved groups is a memcpy (67.4% -> 71.2% in the combined build). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass; no pending token is HTT_NONE (header commit), and the character tests compare with 32 without a HelpTextToken cast. quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SelectCrusade_Main clears the menu tab to switch to with 0 (no tab), and MissionEndscreen_Main stores 0 into the active tab. The ChooseNetworkServiceProvider_Buttons draft in the companion development PR uses it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The PlayerSlotUnitColor copy is a for loop (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The cost tests are for loops (identical code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… are ints The map editor compares the active brush and the affect type signed (jle at 0x00431563 and 0x004315E3, jge at 0x004317D3) and halves the brush with sar. switchToMenuView on main and InGameMenu_MainButtons here compile to the same code (quick_diff identical); the other users are drafts in the companion development PRs (MapEditorLandscaping_GeneralButtons, MapEditorLandscaping_QueueCommandCallback). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 8, 2026
* reimplement: SHC_3BB0A8C1_0x004BBF40 100.0% Reimplemented Moved here unchanged from the draft sourcehold#328 (reimpl/UI-MenuItems-3-development-2, 13fbfea). It was 100% before the header sync a9401a7 and 92.3% on sourcehold#328's base 72b2732, where MSVC stopped sharing the tails of its two number calls. On main 57d3334 it compiles to the original's 100 instructions again, with the shared tail. quick_diff is left with its own artefacts only: the jump-table spelling, the colour immediates, the picture table's address written as its base less 14, and ret / ret 0. reccmp: 99.2% raw and 100% normalized, where only the picture table's address differs (reccmp shows it as an offset into DAT_GMImageHeaders), which the project records as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuItemActionHandler_InGameMenu_Scrolling takes no parameters The original ends with push 1 / call RecordTutorialPlayerAction / pop ecx (0x00434200 to 0x00434207). Declared (int, ...), our function tail-calls through its own argument slot instead (mov [esp + 4], 1 / jmp), which MSVC can only do when the function has a named parameter. Only the menu tables refer to it (six dwords, no call), and like WaitingForHost_ConnectToLobby it never reads an argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: SoundEffectID values 254 to 256 as SEID_UNKNOWN_<hex> LobbyMenu_SkirmishTypeAndBalance plays them when the balance changes: 256 at either end (buttons 10 and 14), 255 one step from even (11 and 13) and 254 at even (12); the pushes are at 0x0042A888, 0x0042A8A1 and 0x0042A8B5. The draft wrote them as (SoundEffectID)0x100 and as SEID_UNIT_DAMAGE3 | SEID_PEOPLE_ARE_COMING_TO_THE_CASTLE (248 | 7) and SEID_UNIT_DAMAGE3 | SEID_ARROW_KILL (248 | 6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0042A840 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. On main's headers it compiles to the original's 41 instructions, and quick_diff differs only in its own ret / ret 0. The style pass names the parameter and the button ranges, and the three sound effects by the names the previous commit adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004D99F0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. Rewritten without the decompiler's gotos, it keeps the original's 85 instructions. quick_diff's differences are its own: ret / ret 0, and the tail jump to MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface at 0x004D9A4F, which our listing writes as jmp trampoline<4603888> (0x00463FF0) and quick_diff does not count as a function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00442C30 100.0% Reimplemented Moved from the draft sourcehold#318 (reimpl/batch2-development 49a51e7), 92.6% there. The search for a siege unit now sets a flag and leaves the loop, so its exit jumps past the clearing as the original's does (jg at 0x00442DE3 to 0x00442E64) instead of testing p == end after the loop: quick_diff 0.9753 -> 0.9807. A goto, a flag over the pointer loop and a flag over an index loop all measure the same; the index loop reads best. What is left is quick_diff's own: the security cookie, the timeGetTime import call, ret / ret 0, and the 11 bytes of alignment before the copy loop at 0x00442EA5, which the original's assembler wrote as a jmp over the filler. The style pass replaces the pointer loops with index loops over the 21 counts and returns early for maps that are not sieges. Clean alone build: reccmp 98.9% raw and 100% normalized. The two raw differences are one address, the end of the siege search loops (cmp eax, 0x00B95B1C, one past DAT_SiegeInformationArray), which reccmp resolves to the next global in the original and to our array's end in the DLL; the project records that as 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0047E420 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 74.1% there. The label is drawn in two calls with the same colour, one per hover state, and the position goes through two locals computed before them: MSVC then merges the two calls but for the text ID's push (the jne at 0x0047E45D). One call is quick_diff 0.8136, the position inside each arm 0.5479, this form 0.9375, which leaves only the colour immediate and ret / ret 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00434120 100.0% Reimplemented Moved from the draft sourcehold#327 (reimpl/UI-MenuItems-3-development c1c152b), 89.9% there. With the header taking no parameters (previous commit) the closing RecordTutorialPlayerAction(1) is a call again rather than a tail call: quick_diff 0.9343 -> 0.9710, left with the jump-table spelling and ret / ret 0. The comments now say what -1000 does, and that the frame-rate formula makes up for only part of the slowdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x00442F40 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 77.4% there. The cases now come in the original's order, 1, 2/3, 4, 7, 5, 6, as in LobbyMenu_MapSelectScrollbar on main: the original lays the blocks out in that order (case 7's store at 0x00442FDA sits between case 4 and case 5). quick_diff then differs only in its own jump-table spelling and ret / ret 0. The style pass names the parameters as the LobbyMenu scrollbar does and writes - 13 and ++ / --. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x0047CCA0 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR sourcehold#254, closed), 73.6% there, after main's renames (isNameEntryActive). Each case now computes the text's position, fetches the text and draws it itself: MSVC merges the copies of cases 0 to 3 into one tail but for the push of the text's index, as the original has push 5 / push 6 / push 7 / push 0 before its shared tail at 0x0047CDE7; case 4 keeps its own call and the surface reset. With one call after the switch the index goes through a register (quick_diff 0.9365); this form is 0.9664, which leaves the jump-table spelling, the colour immediates and ret / ret 0. The cursor's bottom is written DAT_ButtonY + DAT_ButtonH - 4, the order of the original's lea (0.9030 -> 0.9365 by itself). == TRUE stays: the original compares with 1, and a truthiness test is 0.9365. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_SH1_SiegeAdvancedMode is a BOOLEnum It was undefined4. Every store is 0 or 1: the toggle xor [0x00B960C8], 1 at 0x0042D81F, 0 at 0x0042D855 (edx, 0 in that handler) and 0x00448DC2 (ebx), 1 at 0x00442E66; the decompilation agrees (SingleplayerMapChoice's MapTable stores 1, ButtonsAndHands toggles it and stores 0, SingleplayerMapChoice_Prepare stores 0), and every read compares with 0 (spawnQueuedReinforcementWaves, LaunchSinglePlayerGameUnk). A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. Its one user in the code, this PR's MenuItemActionHandler_SingleplayerMapChoice_MapTable (0x00442C30), stores 1 and compiles the same (quick_diff 0.9807 before and after); main has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_StoredGameMode is a GameModeInt It was undefined4. Its one store, at 0x004D972A (MenuView_RankingGames_Prepare), copies GameSynchronyState.currentGameMode (0x0191DD80, a GameModeInt), and its one read, in MenuItemActionHandler_RankingGames_Main, copies it back. Both are on main and compile the same; the copy no longer converts between unsigned and int. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: DAT_SkirmishTrailRelated1 is an int It was undefined4. It is a count that can go below 0: MenuView_CrusadeMap_Prepare (0x004D8CB0) stores 3 (0x004D8D48), decrements it once per mission skipped with the chicken and stores the result (0x004D8DD5), then clamps it at 0 with a signed test (cmp edx, edi / jge at 0x004D8DDB); 0x004D8F3B subtracts from it in memory. Main's user, MenuItemRenderFunction_General_CrusadeMapAndEndscreen, tests it with a signed > 0 through an (int) cast, which the next commit drops; it compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MissionDefinedData.descending is a BOOLEnum It was undefined4. MenuItemActionHandler_RankingGames_Main (0x004D9730) is its only writer: it stores 1 at 0x004D995F when a new column is picked and 1 - descending at 0x004D9970 / 0x004D9976 when the same column is picked again, so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: TileMapState.wallDragButtonUp is a BOOLEnum It was undefined4. Its only store, in MenuItemActionHandler_InGameMenu_TriggerPlaceWallCommand at 0x0043803E, writes the result of a sete (0x00438034), so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * CrusadeMapAndEndscreen: drop the (int) cast DAT_SkirmishTrailRelated1 no longer needs DAT_SkirmishTrailRelated1 is an int since the commit before this one, so the signed > 0 test needs no cast. It compiles the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * SingleplayerMapChoice_MapTable: store TRUE in DAT_SH1_SiegeAdvancedMode The global is a BOOLEnum since the header commit before this one. Same code (quick_diff 0.9807 before and after). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 8, 2026
…old#352) * reimplement: SHC_3BB0A8C1_0x004C1070 100.0% Reimplemented 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> * reimplement: SHC_3BB0A8C1_0x004ABEB0 100.0% Reimplemented 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> * reimplement: SHC_3BB0A8C1_0x004B8BF0 100.0% Reimplemented 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> * headers: MapPropertiesState::sumUnitCounts returns int 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> * headers: MapPropertiesState::indexStored is an int 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> * headers: MapPropertiesState::SEC_SiegeInformation is an int[20] 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> * headers: TextArrayIndexType gets TAIT_UNKNOWN_10, _12 and _14 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> * reimplement: SHC_3BB0A8C1_0x004BF1D0 100.0% Reimplemented 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> * headers: DAT_00eb0b24 is an int 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> * reimplement: SHC_3BB0A8C1_0x004D8570 100.0% Reimplemented 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> * fix: ScenarioDescription_Main after the INT_00eb0b24 rename 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> * headers: DAT_00ed27bc is a BOOLEnum 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> * style: ScenarioDescription_Main stores FALSE / TRUE into DAT_00ed27bc 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> * MenuItemActionHandler_ScenarioDescription_Main: use main's INT_00ed27bc 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> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
6and8
pushed a commit
to 6and8/OpenSHC
that referenced
this pull request
Nov 8, 2026
…ehold#354) * headers: IngameScenarioEventItemContent::allOrAnyCondition is a short The scenario event's all/any switch at +0x08 of the content (+0x18 of the event) is read and written as one word everywhere in the exe: initializeScenarioEvent sets it with mov word ptr [ecx + 0x18], 1 at 0x004B77B8; createScenarioEventForNextMonth and createChainedMissionOutcomeEvents clear it with mov word ptr [.. + 0x5C8], 0 at 0x004BDA3A, 0x004BDC16, 0x004BDD06 and 0x004BDDF8; the NewEventCondition handler toggles it with xor word ptr [eax + 0x01653E20], 1 at 0x004B965E; the NewEventCondition render (0x004C01B0) tests it with cmp word ptr [eax + 0x01653E20], 0 at 0x004C0296, and the in-game event check in 0x004C35B0 with cmp word ptr [ebp + 0x5C8], 0 at 0x004C37E7. Nothing touches +0x09 on its own, so the byte pair allOrAnyCondition / magic is one short (0 is "Any of these", 1 "All of these"). Nothing on main uses either field. gynt's open sourcehold#293 already writes the pair as one word (*(short*)&...allOrAnyCondition = 0 in createScenarioEventForNextMonth.cpp and three times in createChainedMissionOutcomeEvents.cpp) and still compiles with the short, where the cast becomes a no-op. The unused ScenarioEventItem.hpp keeps its old byte pair (and conditions[39]); it is left as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004C01B0 100.0% Reimplemented MenuItemRenderFunction_NewEventCondition_Main, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 72.8% in sourcehold#328). The new-event-condition menu: -1 shows the event's month, 104 and 126 pick the button text from the event's all/any switch ("Any of these" / "All of these") and the current condition ("Active" / "Inactive"), 106 to 125 and 190 to 209 are the 40 condition rows (name, option text and value, grey when off; 209, "Win Timer", first checks whether any of ten conditions is on), 1000 to 2002 are the value boxes of the current condition, and everything else is a plain scenario button. The rows go through the condition structs (conditions[slot].enabled / subType / value) and the named tables (EventConditionMaxValue, EventConditionParamKind, EventConditionValueScale, EventConditionOptionTextOffsets) instead of the draft's pointer arithmetic and unknown3 offsets. The parameter is button, as in main's other render functions; enabled and allOrAnyCondition (0/1 only) are tested by truthiness; the literal text numbers and ParamKind 1/2 have comments. Kept forms: textNumber is copied from button before the 5000 check (copied after the check: quick_diff 0.9440 -> 0.8940); case 2000 comes before 1000 and every box case tests !interacting first, so the box blocks are shared as in the original (in turn: 0.9109; interacting first: 0.8223); the four box cases stay separate, as the original has four entry blocks. The month button's x is X + W / 2 (W / 2 + X, as in 2002: reccmp 99.7% -> 99.3%), and it keeps one call per colour (one call with a colour local: quick_diff 0.9440 -> 0.9237). Case 209's ten condition tests are written out (a loop over 4 to 7: 0.8543; over 20 to 22: 0.8708). default: is now the last label (a tie). quick_diff's 0.9440 is all artifacts (colour immediates, ret, jump tables, the tail calls' target). reccmp reads 99.7%: only the targets of two RenderScenarioButtonWithText tail calls differ (normalized 100.0%). Needs the allOrAnyCondition header commit before it. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004B8220 100.0% Reimplemented MenuItemActionHandler_EditScenario_BaseMenuButtons, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 73.5% in sourcehold#328). The scenario editor's main buttons: 3 goes back to the map's properties with the typed start year, 38 opens the trader settings, 41 the attacking force (siege map) or the starting goods, 79 the starting popularity slider, -1 steps the start month, 42 and 43 add a new invasion or event, 168 and 169 the attacking force's gold and partial pitch sliders, 171 the building availability, and 61, 166 and 167 the scenario's gold, rations and taxes (with the extra options on). Against the draft: no gotos (the shared slider tail and the "not on a siege map" block come from MSVC merging the identical endings), the new event through scenarioEvents[currentEventID] instead of a pointer local, the attacking force's text through SEC_SiegeInformation[indexStored - 20] instead of SEC_StartingResources[indexStored + 5] past the array's end (the same address; the original reloads indexStored after the call), and the text slots by their TAIT names. Same behaviour. 43 formats the event's year and never uses it, as the original does at 0x004B86E5: a fixme line says so. The slider titles ("Popularity", "Starting Gold", "Starting Pitch", "Gold") and the attacking force's rows starting at 20 have comments; each of 41, 42 and 43 has its own text buffer, and 166 no longer has a return of its own (both ties). Kept forms: in 168, 169 and 61 textGroup is set before textIndex, so their tail is shared as in the original (textIndex first: quick_diff 0.9573 -> 0.9197). The new event's subType stores are written out (a for loop over 5 to 7: 0.9001). quick_diff's 0.9573 is all artifacts (the cookie symbol, ret, the jump table). reccmp reads 98.8%: only the atol call target and the slider callbacks' addresses differ (we push the SumUnitPoints / RestoreScenarioGold resolvers' trampolines where the original pushes the functions). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004C0860 100.0% Reimplemented MenuItemRenderFunction_NewEventAction_Main, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 62.3% in sourcehold#328). The new-event-action menu: 37 to 40 are scenario buttons (38 to 40 show "Select Message", each only for its message action: Lose & Message 27, Win & Message 26, Message 2, otherwise hidden through DAT_ButtonUnknownZero); 128 to 155 and 177 to 187 are the action rows for event types 0 to 38: the current type's row is highlighted with its value (or "%" and the value for 178) and counts down the slider popup, the others are drawn plain; 146 and 148 show an icon after " - ", and 148 "Archers" is drawn with 146's text, "Bandits". It fixes three bugs of the draft: 38 to 40 drew "Select Message" and then hid it (the break led to DAT_ButtonUnknownZero = 1); 178's highlighted row fell into the plain draw and was hidden; the plain rows with an icon (146, 148) were hidden after drawing. This version returns where the original does. The parameter is button, as in main's other render functions. Kept forms: the row's text is copied from button before selectedButton, the copy the original keeps in the parameter's stack slot for the value switch at the end (selectedButton first: quick_diff 0.9184 -> 0.9143; decrementing a copy of the parameter instead: 0.2490). The not-highlighted row has the same draw on both sides of the hover test (one draw without the test: 0.7731), and iconOffset is declared at the top (at its first use in the rows' block: 0.8907). quick_diff's 0.9184 is all artifacts (colour immediates, ret, jump tables, the tail calls' target). reccmp reads 99.3%: only the targets of three RenderScenarioButtonWithText tail calls differ (normalized 100.0%). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004266E0 100.0% Reimplemented MenuModalRenderFunction_UnusedSetName, gynt's code from his fork, branch reimpl/UI-MenuModals-100 (97.9% "asm differs" there). Unchanged, it measures reccmp 100.0% here, with today's headers, the resolvers on and --ignore-security-cookie. This commit only restyles it: his reused iVar1 = (width + -400) / 2 becomes int const margin = (width - 400) / 2 and (x - iVar1) + width becomes x - margin + width; the text's position goes straight into the call (y + 15, width / 2 + x; a tie with locals); decimal constants, COL_CCFAFF, line comments in place of the script's block comments, a comment on the 400 pixel title box; the five unused using-declarations and the BOOLEnum.hpp include are dropped and BGR24.hpp becomes ColorsEnum.hpp. Same generated code (quick_diff and reccmp unchanged). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: SHC_3BB0A8C1_0x004ABAB0 100.0% Reimplemented MenuModalRenderFunction_NewEventAction, gynt's code from his fork, branch reimpl/UI-MenuModals-100 (97.7% "asm differs" there). Unchanged, it measures reccmp 100.0% here, with today's headers, the resolvers on and --ignore-security-cookie. This commit only restyles it: his seven decompiler temporaries (xParam, iVar2, TVar3, BVar4, iVar5, iVar6, BVar7) go, with the constants and both labels' positions passed straight into the calls (a tie with locals), so the case needs no block; TEXT_SCENARIO for the banner's group; decimal case labels and constants; COL_CCFAFF; line comments in place of the script's block comments; the four unused using-declarations and the BOOLEnum.hpp include are dropped and BGR24.hpp becomes ColorsEnum.hpp. Same generated code (quick_diff and reccmp unchanged). Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: ScenarioEventType enum for the scenario event types IngameScenarioEventItemContent::ScenarioEventType holds 0 to 38. The game names each type by a text of the scenario group (cr.tex group 199): the new-event-action menu (0x004C0860) draws type t's row with text 128 + t for 0 to 27 and 149 + t for 28 to 38 (rows 128-155 and 177-187, compared with item - 128 against ScenarioEventType), and the new-event dialog (0x004AB790) prints ScenarioEventType + 128, + 21 above 155. The enum takes its names from those texts: 0 Win, 1 Lose, 2 Message, ... 26 Win & Message, 27 Lose & Message, 28 Turn Off Repeating Invasions, 29 Theft from granary, 30 Fire!. Text 138 repeats "Message" for type 10 (SET_MESSAGE_10); types 31 to 38 only have placeholder texts ("Action 32" ..) and are SET_UNKNOWN_31 .. 38. The field stays an int, so nothing on main compiles differently; the new-event-action menu uses the names for its message types 27, 26 and 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: ScenarioEventConditionIndex enum for the 40 event conditions The 40 entries of IngameScenarioEventItemContent::conditions have fixed meanings, and the exe uses the index both as an array index and in loops: MissionAestheticsDefinedData's EventConditionMaxValue, EventConditionParamKind and EventConditionValueScale are [40] tables indexed by it, the new-event dialog (0x004AB790) loops over all 40, and the new-event-condition menu (0x004C01B0) maps its rows 106-125 and 190-209 to conditions 0 to 39. So an enum for the index fits, not a struct. The names are the texts the game shows for them (cr.tex group 199, text 106 + i for 0 to 19 and 170 + i for 20 to 39): 0 Auto-Stop, 1 Population, ... 22 Maximum Cruelty, 23 Maximum Pleasantness, 39 Win Timer. Text 123 repeats "Weapons Acquired" for 17 (SECI_WEAPONS_ACQUIRED_17); 24 to 38 only have placeholder texts ("Event Condition 24" ..) and are SECI_UNKNOWN_24 .. 38. Nothing on main uses the conditions array by a literal index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MapPropertiesState::flag is a BOOLEnum MapPropertiesState::flag (+0x13578) only ever holds 0 or 1: the exe's only store is the 1 in the scenario editor's new-event button (mov dword ptr [..+0x13578], 1 at 0x004B86CA in 0x004B8220), and its three readers test it against 0 (0x004BA57E, 0x004BFE3F, 0x004BFF1D). BOOLEnum is a typedef of int, so the size and every access stay the same. No function on main uses the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setSliderParameters takes int* and a void() callback setSliderParameters (0x004AA480) stores its destination into MenuModalComposition::destination, which the header already types int* (mov [ecx + 0x58], eax at 0x004AA512), and its callback into sliderCallbackFunction. Every caller in the exe passes the address of an int (MapPropertiesState::SEC_StartingPopularity, SEC_StartingResources[...], DAT_CopyOfScenarioGold) and a no-argument __cdecl function (Helpers::SumUnitPoints 0x004B8200, Helpers::RestoreScenarioGold 0x004B8210). The signature becomes (int minimum, int maximum, int value, int* destination, void(__cdecl* callbackFunction)()), here and in its resolver, and the scenario editor's four calls lose their (undefined*) / (void*) casts. Main has no other caller; the drafts in sourcehold#327 and batch4-development that call it with the old casts will need the same edit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * reimplement: three functions use the new header names TheRedDaemon's review of sourcehold#354: the proven proposals become header changes (the commits before this one), and the functions use them. NewEventCondition_Main and NewEventAction_Main name the conditions by ScenarioEventConditionIndex and the event types by ScenarioEventType; BaseMenuButtons passes the slider destinations as int* and its callbacks without casts (setSliderParameters takes int* and void(__cdecl*)()), and stores TRUE in MapPropertiesState::flag. Same generated code: reccmp as before (99.7 / 98.8 / 99.3). The status remarks now say when the differences show: with the RenderScenarioButtonWithText (0x004BA910), SumUnitPoints (0x004B8200) and RestoreScenarioGold (0x004B8210) resolvers on, NewEventCondition_Main and NewEventAction_Main read 100.0% raw, and BaseMenuButtons 99.5% raw, where only its three atol calls differ (our CRT's atol against the game's copy). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setSliderParameters takes a NoArgCallback* 7e208ed typed its callback void(__cdecl*)(); main already has that type as Util::FunctionTypes::NoArgCallback, so the parameter uses it, here and in the resolver. It is not a SliderActionHandler (void(int, int, int*, int*, int*)). The modal stores the callback in sliderCallbackFunction (+0x60), and the exe reads that field in three functions only (five reads), each right after activateModalDialog(MMT_NONE, FALSE), and calls it with no arguments: call eax with nothing pushed for it and no add esp after at 0x004B0F90 and 0x004B0FF2 (MenuItemActionHandler_OverlaySlider_Deselect, 0x004B0F70) and at 0x004B1020 and 0x004B1082 (MenuItemActionHandler_UnusedWinCondition_DeselectUnk, 0x004B1000), and a tail jmp eax at 0x004B10C0 (MenuItemActionHandler_UnusedWinCondition_Options, 0x004B1090, on main, which calls it as (void (*)())). The overlay slider's own SliderActionHandler is MenuItemActionHandler_OverlaySlider_Slider (0x004AA600, the MIT_SLIDER item at 0x005ED588); it writes the value through destination and destination2 and never reads +0x60. OverlaySlider_Deselect is the handler of the item before it (0x005ED538). 7e208ed named only the scenario editor's two callbacks. The exe calls setSliderParameters 14 times, from MenuItemActionHandler_General_AdvancedGameOptions (0x00429A40, four calls), MenuItemActionHandler_EditScenario_BaseMenuButtons (0x004B8220, four), MenuItemActionHandler_NewInvasion_UnitButtons (0x004B9110), MenuItemActionHandler_NewEventAction_Main (0x004B9C00), MenuItemActionHandler_SiegeAttackingForceAndStartGoods_Main (0x004BA5C0, three) and MenuItemActionHandler_TriggerInvasion_Main (0x004BBD90), and passes six different callbacks. All six read no stack argument and end in a plain ret, and main's resolvers already declare each void(__cdecl*)(): Synchrony::Commands::QueueChangeGameIntensityOrBalance (0x00429630, three calls), UI::Helpers::CallbackSetMultiplayerSpeedLevel (0x00429650, one), Global::DoNothing (0x00469F10, two), UI::Helpers::SumUnitPoints (0x004B8200, six; a tail jmp to a thiscall at 0x004B7FA0 that reads only ecx), UI::Helpers::RestoreScenarioGold (0x004B8210, one) and UI::Helpers::CaptureCurrentTimeToUnknownTime01 (0x004B9610, one). The two sibling setters are called once each, with two of the same callbacks: setSliderParameters2 (0x004B9762) with CaptureCurrentTimeToUnknownTime01 and setModalSliderParameters (0x00429C48) with QueueChangeGameIntensityOrBalance. The callers compile unchanged. The header commits of this series don't build on their own; measured in one alone build with all of them and the commit that updates the users (the last one before the merge of main): setSliderParameters2 (0x004AA540) and MenuItemActionHandler_UnusedWinCondition_Options (0x004B1090) read reccmp 100.0%, and MenuItemActionHandler_EditScenario_BaseMenuButtons (0x004B8220) reads 98.8% raw, as before (only the atol call and the callback trampolines differ, so it stays recorded at 100%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setSliderParameters2 takes a NoArgCallback* Its callbackFunction was undefined*. setSliderParameters2 (0x004AA540) stores it in sliderCallbackFunction (mov [ecx + 0x60], edx at 0x004AA5F0), which the exe calls with no arguments (see the commit before), and its one caller, MenuItemActionHandler_NewEventCondition_Main (call at 0x004B9762), passes UI::Helpers::CaptureCurrentTimeToUnknownTime01 (0x004B9610), a void(__cdecl*)() in main's resolver. So the parameter becomes a NoArgCallback*, here and in the resolver. This commit is header-only, as AGENTS.md asks: main's setSliderParameters2.cpp takes the new type in its own signature in the last commit of this series, and the build needs that commit; it then reads reccmp 100.0%. Main has no caller; the 0x004B9620 draft on reimpl/UI-MenuItems-3-development-2 casts its argument to undefined* and will need the cast dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setSliderParameters2 takes a short* destination destination was a dword. setSliderParameters2 (0x004AA540) stores it in destination2 (mov [ecx + 0x5c], eax at 0x004AA5D2) and clears destination. destination2 is a short*, and the overlay slider's handler (0x004AA600) writes through it with word stores only (mov word ptr [edx], cx at 0x004AA71C, [ecx], dx at 0x004AA736 and [ecx], ax at 0x004AA762), where it writes through destination with dword stores. The one caller, MenuItemActionHandler_NewEventCondition_Main (call at 0x004B9762), passes the address of a short: it pushes lea eax, [eax*4 + 0x1653e24] as destination and, as value, what it reads from there with movsx eax, word ptr [eax]. So the parameter becomes a short*, here and in the resolver, and setSliderParameters2.cpp's (short*) cast goes in the commit that updates the users. Main has no caller; the 0x004B9620 draft on reimpl/UI-MenuItems-3-development-2 already holds it in a short* local and can drop its (dword) cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setModalSliderParameters' last parameter is a NoArgCallback* param_6 was undefined*. setModalSliderParameters (0x004AA930) stores it in sliderCallbackFunction (mov edx, [esp + 0x18]; mov [ecx + 0x60], edx at 0x004AA956 and 0x004AA964), which the exe calls with no arguments, and its one caller, MenuItemActionHandler_General_AdvancedGameOptions (call at 0x00429C48, on DAT_MenuModalComposition1), passes Synchrony::Commands::QueueChangeGameIntensityOrBalance (0x00429630), a void(__cdecl*)() in main's resolver. So param_6 becomes a NoArgCallback*, here and in the resolver; the name stays Ghidra's. Main has no implementation or caller. gynt's 100% setModalSliderParameters on origin/reimpl/UI-Core (e31bef6, sourcehold#256) defines it with undefined* param_5, undefined* param_6, so his definition will need NoArgCallback* param_6 (and int* param_5, the next commit) to match this declaration (C2511 otherwise), as setSliderParameters2.cpp does in the last commit here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::setModalSliderParameters' param_5 is an int* param_5 was undefined*. setModalSliderParameters (0x004AA930) stores it in destination (mov edx, [esp + 0x14]; mov [ecx + 0x58], edx at 0x004AA94F and 0x004AA953), and param_4 in sliderValue. destination is an int*, and the overlay slider's handler (0x004AA600) writes through it with dword stores only (mov [edx], ecx at 0x004AA6E3, [ecx], edx at 0x004AA6F8 and [esi], eax at 0x004AA755). The one caller, MenuItemActionHandler_General_AdvancedGameOptions (call at 0x00429C48), passes 0x01A24658 as param_5 and, as param_4, the dword it reads from there (mov eax, [0x1a24658]). So param_5 becomes an int*, here and in the resolver; the name stays Ghidra's. Main has no implementation or caller. gynt's e31bef6 stores it as this->destination = (int*)param_5; with this commit and the one before, his definition changes once for both parameters, and the cast can go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * headers: MenuModalComposition::sliderCallbackFunction is a NoArgCallback* It was pointer (void*). The exe writes it only in the three setters (mov [ecx + 0x60], edx at 0x004AA530 in setSliderParameters, 0x004AA5F0 in setSliderParameters2, 0x004AA964 in setModalSliderParameters), whose callback parameters are NoArgCallback* since the commits before, and reads it only at 0x004B0F87, 0x004B0FE9, 0x004B1017, 0x004B1079 and 0x004B10B7, each a NULL test and then a call or tail jump with no arguments (see the first commit of this series). There is no other access to either instance's +0x60 (absolute 0x01FE7CF0 for DAT_MenuModalComposition1, 0x024036D8 for DAT_MenuModalComposition2). In the next commit main's setSliderParameters2.cpp takes the typed parameters in its signature and MenuItemActionHandler_UnusedWinCondition_Options drops its (void (*)()) cast. Measured with the commits before and the next one, in one alone build: setSliderParameters2 (0x004AA540) and MenuItemActionHandler_UnusedWinCondition_Options (0x004B1090) read reccmp 100.0%, and MenuItemActionHandler_EditScenario_BaseMenuButtons (0x004B8220) reads 98.8% raw, as before (only the atol call and the callback trampolines differ, so it stays recorded at 100%). gynt's OverlaySlider_Deselect (a2803eb, 100%, on his fork's reimpl/UI-MenuItems-development) compares the field with (undefined*)0x0, which will need to become NULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * MenuModalComposition: setSliderParameters2 and UnusedWinCondition_Options use the typed parameters setSliderParameters2 (0x004AA540) takes short* destination and NoArgCallback* callbackFunction in its definition, as the header has since the commits before; the header commits are header-only, so this one makes the branch build again. destination goes into destination2 without its (short*) cast. MenuItemActionHandler_UnusedWinCondition_Options (0x004B1090) calls sliderCallbackFunction, a NoArgCallback* since the commit before, without its (void (*)()) cast; its first include is the relative ../Unused.func.hpp, as the checker asks of a touched file, and the unused using lines for MenuModalType and BOOLEnum go with the BOOLEnum.hpp include (MMT_NONE is written out in full and FALSE is the Windows macro). quick_diff unchanged; reccmp 100.0% for both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * NewEventAction: the event type switch uses ScenarioEventType's names gynt on sourcehold#354: the cases of MenuModalRenderFunction_NewEventAction's switch over the event's ScenarioEventType were numbers. They are now SET_TRAVELING_FAIR, SET_PLAGUE ... SET_ARCHERS, SET_THEFT_FROM_GRANARY and SET_FIRE (5, 11-20, 29, 30). The other switches in this branch are over button numbers (TEXT_SCENARIO text numbers, no enum yet) and stay numbers; its comparisons with an event type or a condition index already use the names. Codegen unchanged: quick_diff 0.9107 before and after, reccmp 100.0%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gynt <gynt@users.noreply.github.com>
gynt asked on sourcehold#354 why the case labels do not use the enum names. Where the switched value has an enum on main this draft now uses it: MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons's switch on a player's currentAIArray entry names its ten cases by AITypeA (the European lords, AITA_RAT ... AITA_ABBOT), and MenuItemActionHandler_Roundtable_Main's two tests of it compare with AITA_RAT and AITA_SULTAN (the genie's "Not the rodent" line is the rat's); MenuItemRenderFunction_VideoOptions_Main's switch on menuCurrentlySelectedResolution names its 15 cases by ScreenResolutionEnum, each matching the text it draws (SRE_800x600 ... SRE_1024x600). The other switches here are on button numbers, GM picture indices, key codes and fields with no enum, so they keep their numbers. The code is unchanged: quick_diff gives the same output for all three files before and after. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_NewEventCondition_Main: main's 3a1c7f7 (merged in e274e50) types setSliderParameters2's last parameter NoArgCallback*, so the callback is passed as MACRO_CALL(...) as main's EditScenario calls do, without the (undefined*) cast. MenuItemActionHandler_MapEditorProperties_MainButtons: main's MapPropertiesState declares SEC_SiegeInformation as int[20] (it was a SiegeUnitCounts when the draft was written), so the 20 copies into siegeInformation index it by SiegeUnitCounts' field order; the field each one fills is named on the left. The file had stopped compiling with an earlier main merge on this branch. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons tests a player's currentAIArray entry against 0 in three places, next to the switch on the same field that already names its cases by AITypeA. Those three tests now compare with AITA_NULL (0 on main), so every use of the field reads the same way. The code is unchanged: quick_diff gives the same output before and after. Co-authored-by: Gynt <gynt@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
The button rows each making their own text call, y then x, and the resolution cases in the original's block order take the function from 80.4% to 100.0%, so it moves to the round 11 PR (reimpl/UI-B-round11-100, 028d761). This draft drops it, and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ChooseNetworkServiceProvider's Buttons handler (0x004909E0) goes from 79.4% to 100.0% with its join case written without gotos (strlen tests, a found flag and a stored flag, strcpy), and SingleplayerMapChoice's ButtonsAndHands handler (0x0042D640) from 75.1% to 100.0% as one switch in the original's block order. Both move to the round 12 PR (reimpl/UI-B-round12-100, bee3ec3 and 25cbd1b). This draft drops their .cpp files, and their status lines go back to main's. Main has neither function, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 14, 2026
CrusadeMap's Main handler (0x004D8EC0) goes from 35.2% here to 100.0% in the round 13 PR (reimpl/UI-B-round13-100, cf7b873), rewritten from the binary with two fixes this draft needed too: two trails tested the click's y the wrong way round, and two mission searches went one mission too far. It also has one cleanup: a click wrote back all three trails' progress, where the original stores only the trail being played. This draft drops its .cpp file, and its status line goes back to main's. Main doesn't have the function, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's Ghidra sync (1b36c0a) renamed ViewportState's field at 0x0C from mouseTile to mouseFlatTile. PeasantBuildAndRightClickMenuSelection (0x00434350) and MapEditorLandscaping's QueueCommandCallback (0x00443A30) use the new name. quick_diff on main e086ba7, where neither compiled before: 0.7911 and 0.3184. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DAT_ButtonUnknownZero is a BOOLEnum; the 92 stores of 1 and 0 in seven drafts are written TRUE and FALSE. Same value, same instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Twenty-four of gynt's UI::MenuItems drafts from his fork (
reimpl/UI-MenuItemsand-development), brought onto currentmainso others can continue from them:NULL.memcpy/memsetwhere that compiles the same or better. Three stay written out, each with one comment line saying why.The code is otherwise gynt's, and its behaviour was not checked against the binary again; every commit body says what changed. Every score is at or above the best on his and 6and8's branches (column "Best before"). Two went up: ChooseNetworkServiceProvider_Buttons (77.5 to 79.4, a
memcpyper row of stored IP addresses) and the Roundtable handler (67.4 to 71.2, its loops and amemcpy). Four moved when #319 and #322 put functions they call into main, and their status lines say so: BuySell 83.8, EditScenario_TextBoxLike 81.2, SingleplayerMapChoice_ButtonsAndHands 75.1 and MapEditorProperties_MainButtons 53.2. BuySell has since been rewritten from the binary's control flow: 93.3%, with three behaviour fixes (below). Seven drafts that measure lower here than on his branches were left out; one of them, LobbyMenu_NonBoxedButtons, went from 76.8 to 73.9 with those callees.This is the batch's second draft, with 25 files. The ready PRs: #329 and #330 (merged), #331, #332, #333, #334, #335 (BarracksWeaponAvailability went there at 100%) and #338 (EditScenario_BaseMenuButtons' render went there); the other draft is #327 (7 functions below 100%).
Built on top of
main(6306080, since merged with 72b2732 and its header sync) with the bundled MSVC1400-SP1 against the SteamStronghold Crusader.exe(3bb0a8c1…5387ac5a), resolvers enabled locally (not committed), sourcehold's reccmp with--resolve-wrapped-calls --ignore-security-cookie; the scores are from a combined build. None of it has been run in game. Decompiler names (iVar1) are left as they were.Header changes, each in a commit of its own (gynt, 2026-11-05: they stay in the PR until main has them), with the drafts that use them. Main's Ghidra sync a9401a7 took in the others (for -1 it chose
UT_INVALID, withUT_NONEas 0; the three ints asINT_00b95960/INT_00b95f64/INT_00b95b74;BASMTT_NONE; TileMapState's ints;DAT_AlliesCount; the colours), main 72b2732 is merged in, and the drafts use main's names (activateLoadOrSaveMapUInow getsMMT_LOAD_MAP/MMT_SAVE_MAP).SoundEffectIDgetsSEID_UNKNOWN_0xFBandSEID_UNKNOWN_0xFD(251 and 253), the same lines as in Reimplement 7 UI::MenuItems functions (draft, below 100%) #327.BuildMenuTabTypegetsBMTT_UNKNOWN_49.ChooseNetworkServiceProviderButtonActionsgets the negative actions its handler takes: -1 and -2 scroll the provider list, -10 is GameSpy Arcade, -1000 the next stored IP address, -10000 leaves like EXIT (named by what the handler does, with the Unk suffix).UserTextHandler::copyIntoTextArraytakes achar const*: it copies the text and doesn't write to it (0x00472C30).readUserConfigon main compiles to the same code.Moved out: TriggerInvasion_Main (0x004BBF40), which came here from #333 at 92.3%, measures 100% again on current main with no source change, so it is in the ready #349. EditScenario_EventAndInvasionList, EditScenario_TextBoxLike and ScenarioDescription_Main, rewritten from the binary, are at 100% in the ready #352, with three behaviour fixes and the header changes they needed. NewEventCondition_Main, NewEventAction_Main and EditScenario_BaseMenuButtons, rewritten from the binary, are at 100% in the ready #354 (NewEventAction_Main with three behaviour fixes).
MenuItemRenderFunction_Allies_MainMenuItemActionHandler_AlliesSendAndRequestGoods_MainMenuItemRenderFunction_AlliesSendAndRequestGoods_MainMenuItemRenderFunction_BuildMenu_UnitActionButtonsMenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHandsRT_PARTIALPITCH/RT_PITCH. Behaviour fixes: after selecting the next good (button 3) the draft fell through into the buy/sell code; after the no-armory and armory-full warnings it went on to the next check or the command; after the not-enough-goods warning it still queued the sell command. Left: register choice in the shared tail and the sell branch.MenuItemActionHandler_ChooseNetworkServiceProvider_ButtonsMenuItemActionHandler_CrusadeMap_MainMenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnkMenuItemRenderFunction_General_AdvancedGameOptionsMenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelectionMenuItemRenderFunction_InGameMenu_MainButtonsMenuItemActionHandler_LobbyMenu_MapSelectHeaderMenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtonsMenuItemActionHandler_MapEditorLandscaping_QueueCommandCallbackMenuItemActionHandler_MapEditorProperties_MainButtonsMenuItemActionHandler_NewEventCondition_MainMenuItemActionHandler_Roundtable_MainMenuItemRenderFunction_ScenarioDescription_MainMenuItemRenderFunction_SiegeAttackingForceAndStartGoods_MainMenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHandsMenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHandsMenuItemActionHandler_TextEditor_TextInputRelatedUnkMenuItemActionHandler_VideoOptions_MainMenuItemRenderFunction_VideoOptions_Main🤖 Generated with Claude Code