Skip to content

Reimplement 33 UI::MenuItems functions: gynt's finished backlog, part 1 (100%) - #381

Merged
gynt merged 47 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-gynt-backlog-MenuItems-1
Nov 10, 2026
Merged

gynt merged 47 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-gynt-backlog-MenuItems-1

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

These are 33 of gynt's finished MenuItems functions: the first half of his MenuItems backlog. He OK'd landing them on Discord on 2026-11-09: "Yes you can make a PR for them and check they still build. Cleaning up the backlog, love it". The other 32 are in #382, and #379 (MenuViews) and #380 (MenuModals, DisplayElements and Rendering) carry the rest.

Each of these functions read 100% on his fork but was never in a PR. Each one comes in as a commit authored by him: his file as it stands at the last commit that touched it, where its status line reads 100%. The body names the branch and the commit, and the table at the end lists them. What main needed on top follows in our own commits, which credit him as co-author.

Measured on today's main (9528350) with the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a). Struct and function resolvers were enabled locally (not committed), and reccmp is sourcehold's, run with --resolve-wrapped-calls --ignore-security-cookie.

  • Result: a full build reads 32 of the 33 at 100.0% raw. MenuItemActionHandler_BuildMenu_CurrentlySelectedTroops (0x004393C0) reads 96.3% raw and 100% normalized: of its two tail calls to recountUnitsInSelection (0x00535240), the first one's target differs, because that function's resolver is still off. Its status line says so.
  • Checks: openshc-pr-check gives no errors, and status_regression.py finds no status line that got worse.
  • None of it has been run in game.

Our commits on top of his

  1. Main's names and types since gynt's base. These were found from the compiler errors and fixed by offset with refactor_struct_fields.py:
    • field1030_0x54a5c → SelectionSlotUnitTypes, field12_0x30 → pendingGameSpeedLevel, field42_0x9c → field_0x9c, field47_0x1355c → eventListScrollOffset;
    • CustomScenarios_Main's 9 becomes MMT_LOAD_MAP, now that activateLoadOrSaveMapUI takes a MenuModalType.
  2. The style rules:
    • decimals, compound assignments and truth tests;
    • no imported plate comments, and declarations at first use;
    • the decompiler's locals named and param_N given main's names (button, row, unused, scrollbarEvent for the scrollbar handlers);
    • colours by name, and countof loops where the original has a loop;
    • unneeded casts and unused includes dropped;
    • comma operators in conditions written as statements with early returns.
  3. Enum names for the numbers:
    • StatusMenuButtons now uses the BuildingsAndStatusMenuTabType names. gynt's code wrote the tab values with building enums: BT_OXTETHER is 4, the granary tab, and BT_KEEPDOOR_LEFT is 71, the status overview.
    • DateYearBox uses TAIT_UNKNOWN_10 to _15 where Ghidra had OR-ed two TAIT values together.
    • TextInputDisplay and ProviderTableRows use the TAIT names.

Header changes (each in a commit of its own)

Main's Ghidra sync (6c1e0bd) brought these header lines, and main (d5d965d) is merged in, with our code following main's spellings (TAIT_UNKNOWN for text index 4, INT_00b9840c), so the declaration check passes now.

  • GameCommandType gets GCT_UNKNOWN_33 and GCT_UNKNOWN_37 (b3917f1). The originals do push 0x21 / push 0x25 before call 0x489100 (queueCommand), in WorkshopWeaponSelection (0x00465200) and DrawbridgeOpenClose (0x00465360).
  • SoundEffectID gets SEID_UNKNOWN_0x8C and SEID_UNKNOWN_0x8E (191ff07). GatehouseOpenClose (0x00465480) does push 0x8c / push 0x8e before call 0x449c40. They sit next to GATEHOUSE_CLOSE/OPEN (141/143), so they may be the other gatehouse sounds.
  • TextArrayIndexType gets TAIT_UNKNOWN_13 (d21f2af). DateYearBox (0x004B8990) does cmp dword ptr [0x1652740], 0xd and push 0xd; call 0x469790.

The sibling MenuItems PR adds other values to the same two headers (GCT 96, SEID 0x104/0x105), and #379/#380 add TAIT_UNKNOWN_4. All of them merge cleanly in any order.

Kept as they are, with the reason

  • The outpost size and delay sliders keep their pointer local. Writing straight into the field changes the code (quick_diff 0.8723 → 0.4719), and each file says so in one line. TaxSlider takes the direct form, which compiles identically.
  • CurrentlySelectedTroops keeps its two tail calls. The original has two separate jumps to 0x535240 (at 0x4393FE and 0x43942D), which the early-return shape reproduces.
  • TextInputDisplay's != TRUE: the original does cmp dword [0x1FE7E28], 1 at 0x47CC62.
  • uint color; without a value in ModemTableRows and FindingNetworkSessions_TableRows is the shape of main's ProviderTableRows render: a preset colour overridden in one branch costs two instructions.
  • (int) on MapPropertiesState::total: the field is undefined4, and the original compares it signed.
  • CustomScenarios_Main writes the single-player map choice's tab as a plain 1. BASMTT_BARRACKS_OR_MPMENU_MODEM would be the wrong name there; main's openUnusedHelpTextEditorDialog also writes 1.
  • The scrollbar handlers' case labels 1-6 stay numbers, as in main's five scrollbar handlers: there's no enum for the scrollbar events.
  • TaxSlider's case 1 falls through into case 4, as the original's does. A comment says so.

Header changes we didn't make (suggestions)

  • MapPropertiesState::total → int, which would drop the cast above.
  • HorizontalSlider's declaration: thumbXPos, sliderValue, thumbWidth, BOOLEnum isDragged, as NewInvasion.hpp has it. SoundOptions.hpp has the same stale names.
  • SetTutorialBuildingActionState's second parameter is declared BuildingType, but it is passed a rations value and a tab.
  • The six GameCore::*Producible_logic fields (0x160-0x174) are in DisableWeapon's button order and only hold 0/1, so they could be BOOLEnum, maybe as an int[6].
  • pendingGameSpeedLevel, DAT_GameCommandParam1/2 and DAT_MapMissionType → int.

Names to offer

  • outpostRelatedUnk2 is the outpost size (0-5), and outpostRelatedUnk3 its delay (0-24000).
  • INT_00b96120 looks like the last building menu: the only value main writes to it is 4, the granary tab.
  • renderUpDownButtonUnk's first argument is "is down": -1 passes 0.
  • Modem/ProviderScrollbarUnk are the scrollbars of the modem and provider lists.
  • For field_0x9c and INT_00b95b64, no better name is known.

The 33 functions

Function, address, and gynt's branch and commit it comes from
Function Address gynt's branch, commit
MenuItemActionHandler_BuildMenu_CurrentlySelectedTroops 0x004393C0 reimpl/UI-MenuItems d91f623
MenuItemActionHandler_BuildingAndStatusMenu_ChangeRations 0x00465820 reimpl/UI-MenuItems cea5c3a
MenuItemActionHandler_BuildingAndStatusMenu_DrawbridgeOpenClose 0x00465360 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_BuildingAndStatusMenu_GatehouseOpenClose 0x00465480 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_BuildingAndStatusMenu_OutpostSliderDelay 0x00466810 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_BuildingAndStatusMenu_OutpostSliderSize 0x00466730 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods 0x004659E0 archive/UI-MenuViews-development-second-pass 637c6b0
MenuItemActionHandler_BuildingAndStatusMenu_StatusMenuButtons 0x0043E490 archive/UI-MenuViews-development-second-pass 71eb42a
MenuItemActionHandler_BuildingAndStatusMenu_TaxSlider 0x00465560 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_BuildingAndStatusMenu_WorkshopWeaponSelection 0x00465200 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_ChooseNetworkServiceProvider_ModemScrollbarUnk 0x0047D070 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_ChooseNetworkServiceProvider_ProviderScrollbarUnk 0x0047CA80 reimpl/UI-MenuItems 01ff313
MenuItemActionHandler_ChooseNetworkServiceProvider_ProviderTableRows 0x00487200 reimpl/UI-MenuItems ea82c21
MenuItemActionHandler_CrusadeEndscreen_Main 0x004D9230 archive/UI-MenuViews-development-second-pass a389f84
MenuItemActionHandler_CustomScenarios_Main 0x00440770 archive/UI-MenuViews-development-second-pass a389f84
MenuItemActionHandler_DisableWeapon_Main 0x004BB740 archive/UI-MenuViews-development-second-pass dd14331
MenuItemActionHandler_EditScenario_DateYearBox 0x004B8990 archive/UI-MenuViews-development-second-pass a389f84
MenuItemActionHandler_EditScenario_Scrollbar 0x004B8A50 reimpl/UI-MenuItems 1a21a7a
MenuItemActionHandler_GameplayOptions_SpeedSlider 0x00491FD0 reimpl/UI-MenuItems 456c6b3
MenuItemActionHandler_General_MessageScrollbar 0x004BAD70 reimpl/UI-MenuItems 92974fe
MenuItemActionHandler_General_TextInputDisplay 0x0047CC10 archive/UI-MenuViews-development-second-pass c52ccd4
MenuItemActionHandler_GreatestLord_Main 0x004B1990 archive/UI-MenuViews-development-second-pass a389f84
MenuItemRenderFunction_BuildMenu_MiniMapInteraction 0x00434300 reimpl/UI-MenuItems-100 0a7d992
MenuItemRenderFunction_BuildingAndStatusMenu_ArmyStatusReturn 0x0043FCB0 reimpl/UI-MenuItems 48d3995
MenuItemRenderFunction_BuildingAndStatusMenu_DisableFoodType 0x0043FBF0 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemRenderFunction_BuildingAndStatusMenu_HorizontalSlider 0x00465630 reimpl/UI-MenuItems b43b87b
MenuItemRenderFunction_BuildingAndStatusMenu_StatusMainMenuButtons 0x0043E4E0 reimpl/UI-MenuItems 9bea797
MenuItemRenderFunction_BuildingAndStatusMenu_TaxArrowButtons 0x004657B0 reimpl/UI-MenuItems-100 0a7d992
MenuItemRenderFunction_Chat_TauntButtons 0x0047FFE0 reimpl/UI-MenuItems acd19e6
MenuItemRenderFunction_ChooseNetworkServiceProvider_ModemTableRows 0x0047D100 archive/UI-MenuViews-development-second-pass 637c6b0
MenuItemRenderFunction_FindingNetworkSessions_TableRows 0x0047D410 archive/UI-MenuViews-development-second-pass 637c6b0
MenuItemRenderFunction_General_MessageScrollbarUpDown 0x004BAE80 reimpl/UI-MenuItems-100 0a7d992
MenuItemRenderFunction_General_Scrollbar 0x004BAE30 archive/UI-MenuViews-development-second-pass 81e1041

Other PRs:

🤖 Generated with Claude Code

gynt and others added 30 commits November 9, 2026 10:58
MenuItemRenderFunction_BuildMenu_MiniMapInteraction, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at 0a7d992 (2026-10-25), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildMenu_CurrentlySelectedTroops, gynt's work as it stands on his fork's reimpl/UI-MenuItems at d91f623 (2026-10-08), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_StatusMenuButtons, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 71eb42a (2026-10-10), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_StatusMainMenuButtons, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 9bea797 (2026-10-09), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_DisableFoodType, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_ArmyStatusReturn, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 48d3995 (2026-10-08), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_CustomScenarios_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at a389f84 (2026-10-04), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_WorkshopWeaponSelection, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at 0a7d992 (2026-10-25), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_DrawbridgeOpenClose, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at 0a7d992 (2026-10-25), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_GatehouseOpenClose, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at 0a7d992 (2026-10-25), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_TaxSlider, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_HorizontalSlider, gynt's work as it stands on his fork's reimpl/UI-MenuItems at b43b87b (2026-10-09), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_BuildingAndStatusMenu_TaxArrowButtons, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at 0a7d992 (2026-10-25), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_ChangeRations, gynt's work as it stands on his fork's reimpl/UI-MenuItems at cea5c3a (2026-10-08), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 637c6b0 (2026-10-06), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_OutpostSliderSize, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_BuildingAndStatusMenu_OutpostSliderDelay, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_ChooseNetworkServiceProvider_ProviderScrollbarUnk, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 01ff313 (2026-10-08), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_General_TextInputDisplay, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at c52ccd4 (2026-10-06), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_ChooseNetworkServiceProvider_ModemScrollbarUnk, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_ChooseNetworkServiceProvider_ModemTableRows, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 637c6b0 (2026-10-06), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_FindingNetworkSessions_TableRows, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 637c6b0 (2026-10-06), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_Chat_TauntButtons, gynt's work as it stands on his fork's reimpl/UI-MenuItems at acd19e6 (2026-10-10), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_ChooseNetworkServiceProvider_ProviderTableRows, gynt's work as it stands on his fork's reimpl/UI-MenuItems at ea82c21 (2026-10-10), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_GameplayOptions_SpeedSlider, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 456c6b3 (2026-10-08), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_GreatestLord_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at a389f84 (2026-10-04), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_EditScenario_DateYearBox, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at a389f84 (2026-10-04), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_EditScenario_Scrollbar, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 1a21a7a (2026-10-10), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_General_MessageScrollbar, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 92974fe (2026-10-10), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemRenderFunction_General_Scrollbar, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at 81e1041 (2026-10-03), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt and others added 15 commits November 9, 2026 10:58
MenuItemActionHandler_DisableWeapon_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at dd14331 (2026-10-06), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_CrusadeEndscreen_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at a389f84 (2026-10-04), where its status line reads 100%.
Taken over unchanged; main's later renames and the style rules follow in commits of their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt's drafts were written against an older main. Main's Ghidra syncs have renamed or retyped what these files use, so
they would not compile as they stand. Renamed by tools/reimplementation-helper/batch/refactor_struct_fields.py from
the compiler errors, by offset: field1030_0x54a5c -> SelectionSlotUnitTypes, field12_0x30 -> pendingGameSpeedLevel,
field42_0x9c -> field_0x9c, field47_0x1355c -> eventListScrollOffset. In CustomScenarios_Main the 9 passed to
activateLoadOrSaveMapUI is written as MMT_LOAD_MAP, now that it takes a MenuModalType. No logic changes.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… truth tests, no using lines

The style fixer's pass over the lines the batch adds, then clang-format: hexadecimal constants as decimals,
x = x + n as x += n, + -n as - n, == FALSE / != FALSE on BOOL values as truth tests, and the decompiler's using
declarations dropped (the names are written qualified). The code is unchanged: quick_diff gives the same output for
every file before and after.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/reimplementation-helper/batch/strip_noise_comments.py drops the decompiler's block comments above each
// FUNCTION: line (the WARNING: Enum and decompilerscript plates). The code is unchanged: quick_diff gives the same
output for every file before and after.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, loops

The rest of the checker's ERRORs on the batch, file by file: the decompiler's iVar / sVar / psVar / piVar / BVar
locals get names that say what they hold and are declared where first assigned; the block comment in
ProviderTableRows becomes // lines; text colours are written by their ColorsEnum names (COL_CCFAFF, COL_C2F0EB);
ArmyStatusReturn's BOOLEnum stores are TRUE / FALSE; the nine copies of one statement in CustomScenarios_Main and
HorizontalSlider's if / do-while pair become for loops, which MSVC unrolls or lays out the same. quick_diff gives the
same output for every file before and after, but for the jump table's label number in CustomScenarios_Main's
listing, whose loops add labels (its .text and .rdata compare identical).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The for loops of the previous commit in CustomScenarios_Main count to countof(the array) instead of 9 and step with
++i, as main's other loops do. The code is unchanged: quick_diff gives the same output (but for the listing's label
numbers).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NKNOWN_37

MenuItemActionHandler_BuildingAndStatusMenu_WorkshopWeaponSelection (0x00465200) queues command 33 (push 0x21;
call 0x489100, queueCommand) with the selected workshop's building ID, the weapon and the building's uid, and
MenuItemActionHandler_BuildingAndStatusMenu_DrawbridgeOpenClose (0x00465360) queues command 37 (push 0x25) with the
selected drawbridge's building ID, open or close, and its uid. The enum had 31, 34, 36 and 38 but not 33 or 37; they
get the placeholder name form of GCT_UNKNOWN_40.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ID_UNKNOWN_0x8E

MenuItemActionHandler_BuildingAndStatusMenu_GatehouseOpenClose (0x00465480) plays sound effect 140 (push 0x8c;
call 0x449c40, setUpSFXToPlayUnk) when the gatehouse button passes 10, and 142 (push 0x8e) when it passes 11. The
enum had 137, 141 and 143 but not 140 or 142; they get the same placeholder name form as their neighbours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_EditScenario_DateYearBox (0x004B8990) compares UserTextHandler::textArrayIndex with 13
(cmp dword ptr [0x1652740], 0xd) for its sixth box and, when it differs, passes 13 to resetToTextIndex (push 0xd;
call 0x469790), as it does with 10, 11, 12, 14 and 15 for the other boxes. The enum had 12 and 14 but not 13; it
gets the placeholder name form of TAIT_UNKNOWN_12.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…des over the batch

These come from the review of the branch, and none of them changes the generated code:
- StatusMenuButtons compares and stores menu tabs, not buildings: BT_OXTETHER and BT_KEEPDOOR_LEFT (4 and 71) are
  BASMTT_GRANARY_OR_MPMENU_TCPIP and BASMTT_STATUS_OVERVIEW, the 71 and 75 it tests are BASMTT_STATUS_OVERVIEW
  and BASMTT_STATUS_FOOD, and the 4 in INT_00b96120 is the granary tab, the only value main's
  RenderBuildingMenu_Granary writes there. StatusMainMenuButtons' tabType - 71 is tabType - BASMTT_STATUS_OVERVIEW,
  and SelectBuySellGoods' tab 57 is BASMTT_MARKETPLACE_TRADE.
- DateYearBox's TAIT_EIGHT | TAIT_SEVEN style ORs were Ghidra splitting a plain index into flags: they are
  TAIT_UNKNOWN_15, 10, 11, 13 and 14, the (TextArrayIndexTypeInt)12 cast is TAIT_UNKNOWN_12, and the same names go
  into its resetToTextIndex calls, as main's TextBoxLike writes them.
- Number casts become enum names: GCT_UNKNOWN_33, GCT_UNKNOWN_37, SEID_UNKNOWN_0x8C and SEID_UNKNOWN_0x8E, and
  their using lines go.
- The last decompiler locals go: ChangeRations tests Tutorial_IsActionAllowed directly and stores timeGetTime()
  straight into timeTaxesOrRationsChange, and SelectBuySellGoods tests isResourceTypeTradeable directly, so their
  BOOLEnum includes and using lines go too.
- param_N gets main's names: button for the menu buttons, row for the table rows, unused where the parameter is
  not read, unused and scrollbarEvent for the scrollbar and slider handlers, unused and sliderValue for the
  scrollbar renders, and rations, openOrClose, resourceType, tabType, action, taunt, box and field where the value
  says what it is. HorizontalSlider's thumb position is added to DAT_ButtonX, so it is thumbXPos.
- ModemTableRows and FindingNetworkSessions_TableRows lose Ghidra's comma operator in the colour test: they return
  early for rows past the end and set the colour in both arms of an if / else, as main's
  ProviderTableRows render does.
- Casts that restated a field's own type go: DAT_ButtonX/Y/W/H, MapPropertiesState::offset, eventListScrollOffset,
  the (int) on the short outpost fields and the (uint) on the row == index argument, and the inner (int) of
  (BuildingType)((int)x). (int)total in MessageScrollbar stays: total is undefined4, so the compare would be
  unsigned without it.
- The colour 0 in StatusMainMenuButtons and TaxArrowButtons is COL_000000, minimapClickEnabled and
  FindingNetworkSessions' keepXOffset get TRUE / FALSE, and BOOLEnum.hpp is dropped from the 9 files that never
  name BOOLEnum (TaxArrowButtons' unused BGR24.hpp too).
- ProviderTableRows' two-line sparse-switch comment is one line.

quick_diff gives the same output for every file before and after, and each function's body in the /FA listing,
with the globals' offsets, compares identical.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d early returns over the batch

These come from the second review of the branch, and none of them changes the generated code:
- ProviderTableRows' comment said the original tests the TCPIP arm first. It tests the modem arm first and only
  lays the TCPIP arm out first, so the comment now says that. The handler returns early for rows past the end, as
  its two row-render twins do.
- resetToTextIndex gets the TAIT names its callers compare with: TAIT_FIVE__NUMERIC_DOT, TAIT_SIX__NUMERIC_ONLY,
  TAIT_SEVEN__NUMERIC_ONLY and TAIT_ZERO in TextInputDisplay, and the first and third in ProviderTableRows.
  TextInputDisplay's != TRUE gets the reason its render twin gives.
- HorizontalSlider's thumb size is thumbWidth now that the position is thumbXPos, and isDragged is a BOOLEnum, as in
  main's horizontal sliders.
- The modem, provider and event scrollbars say how many rows fit in their list, and the provider and event ones step
  with --x / ++x, as MessageScrollbar does.
- Constants move to the right of their comparisons (x > 0, action >= 0), and the decompiler's parentheses go from
  ArmyStatusReturn, MiniMapInteraction, SpeedSlider, GreatestLord, StatusMenuButtons and TextInputDisplay.
- DisableWeapon toggles with ^= 1. DisableFoodType's render tests isFoodTypeBanned for truth and names its offsets
  iconOffsetX and iconOffsetY.
- StatusMainMenuButtons passes its five constant arguments directly, so its BGR24 and BOOLEnum includes and using
  lines go. It and TaxArrowButtons name the text position textX and textY.
- ModemTableRows and FindingNetworkSessions_TableRows both declare the colour as uint, with main's ProviderTableRows
  render line on why it is set in both branches. ModemTableRows' BGR24 include and using line go.
- TaxSlider writes taxesSliderUI directly instead of through a pointer local, says that case 1 falls through into
  case 4, and returns from case 6 as from case 5. The outpost sliders keep their pointer and say why: written
  directly, quick_diff drops from 0.8723 to 0.4719. Both now name buildingID, delay / delayField and size / sizeField
  alike.
- CurrentlySelectedTroops says what its 20 is.
- CustomScenarios stores a plain 1 as the map choice's tab, as main's openUnusedHelpTextEditorDialog does:
  BASMTT_BARRACKS_OR_MPMENU_MODEM names a building menu and multiplayer menu tab, which means nothing there.

quick_diff gives the same output for every file before and after, and each function's body in the /FA listing,
with the globals' offsets, compares identical.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CurrentlySelectedTroops keeps 100.0% (reccmp: 96.3% raw, 100% normalized), as main's 0x004C01B0 and 0x004C0860
lines do, and the remark now names what is left. It ends both arms with a tail jump to recountUnitsInSelection
(0x00535240), at 0x004393FE for slots below 20 and at 0x0043942D for the rest. That function is still Pending, so
reccmp has no name for it and shows both jumps as displacements; ours both read as the second jump's, so only the
first one differs.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The three scrollbar handlers whose case 5 stores and returns (ProviderScrollbarUnk, EditScenario_Scrollbar,
General_MessageScrollbar) get the line main's BuildingAvailability_Scrollbar has for that shape.
CustomScenarios_Main includes MenuModalType.hpp for the MMT_LOAD_MAP it passes, as main's other MenuItems files do.
ProviderTableRows loses an empty `default: break;` at the end of its switch, and CurrentlySelectedTroops' comment
names its parameter. Comments only, apart from the include and the default: quick_diff output is identical for
every changed file.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"while its resolver is off", as main's 0x004C01B0 and 0x004C0860 lines say it: recountUnitsInSelection (0x00535240)
is pending and its function resolver is false on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's Ghidra sync 6c1e0bd brought this branch's header changes; main's versions are kept.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 9, 2026
@gynt
gynt added this pull request to the merge queue Nov 10, 2026
Merged via the queue into sourcehold:main with commit 694f606 Nov 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants