Skip to content

Reimplement 32 UI::MenuItems functions: gynt's finished backlog, part 2 (100%) - #382

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

gynt merged 46 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-gynt-backlog-MenuItems-2

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

This PR lands 32 MenuItems functions, the second half of gynt's 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 first 33 are in #381; #379 (MenuViews) and #380 (MenuModals, DisplayElements, Rendering) carry the rest of the backlog.

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, with his file as it stands at the last commit that touched it, where its status line reads 100%. The commit body names the branch and 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):

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), with resolvers enabled locally (not committed) and sourcehold's reccmp run with --resolve-wrapped-calls --ignore-security-cookie.
  • Result: a full build reads all 32 at 100.0% raw.
  • Checks: openshc-pr-check finds no errors, and status_regression.py finds no status line that got worse.
  • None of it has been run in game.

Fixes to gynt's code

  • SaveMap_TableContent (0x004932A0) drops gynt's - 1 when indexing the map list. In his base, DAT_MapSelectionPreloadMapIndexMapping sat at 0x880 and the array at 0x884. Main merged them into one int DAT_ArrayOfMapIndices[501] at 0x880, four bytes earlier, so gynt's [i - 1] is main's [i]. With the - 1 it reads 92.9% on main; without it, 100%. Main's other users (SaveLoadMap_Buttons, SetupPreviewMinimapDataUnk) index it the same way.
  • InGameMenu_MapEventIconUnk wrote spawnMomentX[eventIndex + 19] and spawnMomentY[eventIndex + 19], which run past each 20-entry array into the next one. It now writes spawnMomentY[eventIndex - 1] and spawnMoment[eventIndex - 1]: the same addresses, as main's clearOldSpawnMoment writes them. The listing is identical.
  • UnusedSomeMissionStartUnk_General stored its build menu tab through .tabType = BASMTT_HUNTERSHUT. It now writes .buildMenuTab = BMTT_CASTLE, as main's hideOrUnhideUI does. Both values are 10.

Our other commits on top of his

  • Main's names and types since gynt's base: 13 files, renamed by offset with refactor_struct_fields.py and by hand where a type changed, such as (undefined*)0x0 → NULL now that the callbacks are NoArgCallback*.
  • The style rules:
    • decimals, compound assignments, truth tests, and no plate comments;
    • declarations at first use, and param_N given main's names (button, row, unused, scrollbarEvent, sliderValue);
    • comma operators in conditions written as statements with early returns;
    • unneeded casts dropped, including the casts on sliderCallbackFunction, which is already a NoArgCallback*;
    • no assembly in comments, and no Yoda conditions;
    • the decompiler's parentheses removed.
  • Enum names: SEID_UNKNOWN_0x100 (already on main) for the tactical-power sound 256, and the TAIT names for resetToTextIndex.
  • UnusedCreateMessageEvent's message arm stores data.message.messageID, which sits at the same offset 0 of InGameEventUnion as the other arm's data.scenario.actionData. That's a reading of the union, not a finding.

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_96 (1563658): IdentityOptions_Confirm (0x00493D30) does push 0x60; call 0x489100 (queueCommand) when button 17 is confirmed outside GM_SOLITARY.
  • SoundEffectID gets SEID_UNKNOWN_0x104 and SEID_UNKNOWN_0x105 (43e6ffc): TacticalPowerBar_Main (0x004DA050) does push 0x104 for tactical powers 2, 3, 4, 6, 13 and 16, and push 0x105 for power 7, each followed by call 0x449C40. 0x101 was the enum's last value, so its line gains a comma.

The sibling MenuItems PR adds other values to the same two headers (GCT 33/37, SEID 0x8C/0x8E). The two merge cleanly in either order.

Kept as they are, with the reason

  • The two gotos in HistoricMissionSelect_General and UnusedEconomicMissionSelect_General stay. The original shares the tail with case 13, and writing it out twice adds 9 and 7 instructions; each goto has a one-line comment saying so. The style-lint bot will post on both when this opens.
  • difficulty >= 4 stays. > 3 takes quick_diff from 0.9111 to 0.8667; main's ScenarioDescription writes > 3.
  • These casts stay, because they change signedness or type: (int)mbr_0x928, (int)total, (TextAlignment)DAT_ButtonW and (int)(clickTime - lastListClickTime).
  • The button IDs, scrollbar events, tactical power types and 231 stay numbers: main has no enum for them either (hideOrUnhideUI writes 231 bare too).
  • Behaviour the original has, kept as is:
    • UnusedWinCondition hit-tests DAT_MenuModalComposition2's rectangle while it closes Composition1.
    • The LobbyMenu MapDescScrollbar render sets RT_SCREEN_MENU and never restores RT_MAP_GAME, unlike the other three scrollbars.
    • SaveLoadMap_Scrollbar's case 5 stores and returns, with main's line from BuildingAvailability_Scrollbar.

Header changes we didn't make (suggestions)

  • AIMessageQueue::mbr_0x928 (dword) holds negative values → int. Main's users are playNextStoredAIMessage and playVideoOverMap.
  • MapPropertiesState::total → int (two of the casts above).
  • TextManager::textColor (dword) → BGR24.
  • MiniMapDefinedData::cachedKeepEnclosed stores a BOOLEnum.
  • UserTextHandler::allowUserTextInput: main stores only 0 and 1 to it.
  • renderTextToScreen's (0x474250) 4th parameter is TextAlignment, but the old title buttons pass DAT_ButtonW there. Is it a width?
  • TileMapState::shiftRelated0or3 is set to 5 here, so the name is wrong.

Names to offer

  • DAT_00b960f4 looks like the map description's scroll offset (main's MapDescriptionScrollbar steps it by 14).
  • INT_00b95b74 looks like the map description's text height (main assigns it renderMultilineTextUnk's result).
  • For DAT_00b96100, DAT_00b960dc, INT_00b95f68, field_0x74 and field39_0x1370, no better name is known.

The 32 functions

Function, address, and gynt's branch and commit it comes from
Function Address gynt's branch, commit
MenuItemActionHandler_HistoricCampaignSelect_Main 0x00425720 archive/UI-MenuViews-development-second-pass b3069fd
MenuItemActionHandler_HistoricMissionSelect_General 0x00426B80 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_IdentityOptions_Confirm 0x00493D30 archive/UI-MenuViews-development-second-pass a389f84
MenuItemActionHandler_IdentityOptions_LordIcons 0x00491CE0 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_InGameMenu_MapEventIconUnk 0x004B6530 reimpl/UI-MenuItems 8a77b61
MenuItemActionHandler_LoadMap_TableContent 0x004948C0 reimpl/UI-MenuItems 0d89dce
MenuItemActionHandler_LobbyMenu_MapDescScrollbar 0x00428980 archive/UI-MenuViews-development-second-pass cf563c2
MenuItemActionHandler_LobbyMenu_MapSelectTable 0x0042B470 reimpl/UI-MenuItems bb50b3f
MenuItemActionHandler_MapEditorProperties_MapDescriptionBox 0x0042EDF0 archive/UI-MenuViews-development-second-pass 71eb42a
MenuItemActionHandler_NewInvasion_RepeatSlider 0x004B94A0 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemActionHandler_NewMapMaptype_Buttons 0x0042F2B0 archive/UI-MenuViews-development-second-pass a389f84
MenuItemActionHandler_OptionsMenu_SubOptionsButtons 0x00493BD0 reimpl/UI-MenuItems cdeb8de
MenuItemActionHandler_OverlaySlider_Deselect 0x004B0F70 reimpl/UI-MenuItems-100 de6f8e0
MenuItemActionHandler_SaveLoadMap_Scrollbar 0x00492BA0 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_SaveMap_TableContent 0x004932A0 reimpl/UI-MenuItems 6d85b5f
MenuItemActionHandler_TacticalPowerBar_Main 0x004DA050 reimpl/UI-MenuItems 846f2c8
MenuItemActionHandler_Unknown27CampaignUnk_Main 0x004D6F20 reimpl/UI-MenuItems d39ef7e
MenuItemActionHandler_UnusedChooseMessageBox_Unknown 0x004BF720 reimpl/UI-MenuItems 05f58da
MenuItemActionHandler_UnusedCreateMessageEvent_Unknown 0x004BA560 reimpl/UI-MenuItems-100 de6f8e0
MenuItemActionHandler_UnusedEconomicGametypeSelect_Main 0x00425C20 archive/UI-MenuViews-development-second-pass b3069fd
MenuItemActionHandler_UnusedEconomicMissionSelect_General 0x00426ED0 reimpl/UI-MenuItems-100 0a7d992
MenuItemActionHandler_UnusedSomeMissionStartUnk_General 0x00427080 reimpl/UI-MenuItems 9b61ac2
MenuItemActionHandler_UnusedWinCondition_DeselectUnk 0x004B1000 reimpl/UI-MenuItems-100 de6f8e0
MenuItemActionHandler_WaitingForHost_Button 0x0047E3E0 archive/UI-MenuViews-development-second-pass a389f84
MenuItemRenderFunction_InGameMenu_BikMessagePlayerShield 0x004B65F0 archive/UI-MenuViews-development-second-pass dd14331
MenuItemRenderFunction_InGameMenu_KeepEnclosedSymbol 0x004B65A0 reimpl/UI-MenuItems ff59286
MenuItemRenderFunction_LobbyMenu_MapDescScrollbar 0x00428A60 archive/UI-MenuViews-development-second-pass cf563c2
MenuItemRenderFunction_MapEditorProperties_MapDescriptionScrollbar 0x0042EF80 archive/UI-MenuViews-development-second-pass dd14331
MenuItemRenderFunction_RankingGames_Scrollbar 0x004D9C10 reimpl/UI-MenuItems-100 0a7d992
MenuItemRenderFunction_SingleplayerMapChoice_Scrollbar 0x0042DC60 archive/UI-MenuViews-development-second-pass 81e1041
MenuItemRenderFunction_UnusedOldTitleMenu_ContinueButton 0x0042DEB0 reimpl/UI-MenuItems-100 de6f8e0
MenuItemRenderFunction_UnusedOldTitleMenu_TestMapButton 0x0042DF40 reimpl/UI-MenuItems-100 de6f8e0

Other PRs:

🤖 Generated with Claude Code

gynt and others added 30 commits November 9, 2026 10:58
MenuItemActionHandler_HistoricCampaignSelect_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at b3069fd (2026-10-07), 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_UnusedEconomicGametypeSelect_Main, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at b3069fd (2026-10-07), 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_HistoricMissionSelect_General, 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_UnusedEconomicMissionSelect_General, 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_UnusedSomeMissionStartUnk_General, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 9b61ac2 (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_LobbyMenu_MapDescScrollbar, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at cf563c2 (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_LobbyMenu_MapDescScrollbar, gynt's work as it stands on his fork's archive/UI-MenuViews-development-second-pass at cf563c2 (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_LobbyMenu_MapSelectTable, gynt's work as it stands on his fork's reimpl/UI-MenuItems at bb50b3f (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_SingleplayerMapChoice_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>
MenuItemRenderFunction_UnusedOldTitleMenu_ContinueButton, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at de6f8e0 (2026-10-27), 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_UnusedOldTitleMenu_TestMapButton, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at de6f8e0 (2026-10-27), 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_MapEditorProperties_MapDescriptionBox, 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_MapEditorProperties_MapDescriptionScrollbar, 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_NewMapMaptype_Buttons, 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_WaitingForHost_Button, 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_IdentityOptions_LordIcons, 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_SaveLoadMap_Scrollbar, 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_SaveMap_TableContent, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 6d85b5f (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_OptionsMenu_SubOptionsButtons, gynt's work as it stands on his fork's reimpl/UI-MenuItems at cdeb8de (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>
MenuItemActionHandler_IdentityOptions_Confirm, 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_LoadMap_TableContent, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 0d89dce (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_OverlaySlider_Deselect, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at de6f8e0 (2026-10-27), 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_UnusedWinCondition_DeselectUnk, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at de6f8e0 (2026-10-27), 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_InGameMenu_MapEventIconUnk, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 8a77b61 (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_InGameMenu_KeepEnclosedSymbol, gynt's work as it stands on his fork's reimpl/UI-MenuItems at ff59286 (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>
MenuItemRenderFunction_InGameMenu_BikMessagePlayerShield, 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_NewInvasion_RepeatSlider, 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_UnusedCreateMessageEvent_Unknown, gynt's work as it stands on his fork's reimpl/UI-MenuItems-100 at de6f8e0 (2026-10-27), 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_UnusedChooseMessageBox_Unknown, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 05f58da (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_Unknown27CampaignUnk_Main, gynt's work as it stands on his fork's reimpl/UI-MenuItems at d39ef7e (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>
gynt and others added 14 commits November 9, 2026 10:59
MenuItemActionHandler_TacticalPowerBar_Main, gynt's work as it stands on his fork's reimpl/UI-MenuItems at 846f2c8 (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>
…iles

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, and by hand where a type changed: (undefined*)0x0 -> NULL; 0xe7 -> buildMenuTab;
DAT_00b95b74 -> INT_00b95b74; DAT_MenuLoadGameRelativeSelectionIndex -> menuLoadGameRelativeSelectionIndex;
DAT_MenuLoadGameRelativeSelectionOffset -> menuLoadGameRelativeSelectionOffset; field12_0x30 -> pendingGameSpeedLevel;
field14_0x38 -> pendingSettingBubbleHelp; field15_0x3c -> pendingUnusedOption1; field178_0x5549ec ->
activeTacticalPower; field20_0x44 -> pendingStreamVolume0; field21_0x48 -> pendingStreamVolume1; field22_0x4c ->
pendingStreamVolume3; field26_0x74 -> field_0x74; field32_0x74 -> fileListEntryCount; field38_0x8c ->
lastClickedListIndex; field39_0x90 -> lastListClickTime; field91_0x2bc -> cachedKeepEnclosed; unknownAlwaysZero03 ->
showTextMessageInsteadOfEdit. buildMenuTab = 231 writes the 0xe7 into the ActiveMenuTab field as main's
hideOrUnhideUI does; NULL is the (undefined*)0x0 the callback pointers are compared with, now that they are
NoArgCallback*. 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), and declare_at_use.py moves the declarations that
were still at the top of four functions (MapEventIconUnk, BikMessagePlayerShield, LoadMap_TableContent,
UnusedChooseMessageBox_Unknown) down to their first assignment. 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>
…ours by name, loops

The rest of the checker's ERRORs on the batch, file by file: the decompiler's iVar / dVar / pcVar / BVar / DVar
locals get names that say what they hold and are declared where first assigned; block comments inside the bodies
become // lines, and NewInvasion_RepeatSlider's, which only repeated the field name, goes; the old title menu's text
colour is written by its ColorsEnum name (COL_0000FF) and its two button captions by their string pointers; BOOLEnum
stores are TRUE / FALSE; MapDescriptionBox clears its buffer with sizeof the buffer; runs of nine copies of one
statement and MapEventIconUnk'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 the
listing of three files whose loops add labels (HistoricCampaignSelect_Main, NewMapMaptype_Buttons,
UnusedEconomicGametypeSelect_Main; their .text and .rdata compare identical). UnusedEconomicGametypeSelect_Main's goto
to a bare return becomes that return. Two gotos stay, in HistoricMissionSelect_General and
UnusedEconomicMissionSelect_General, with their labels named: the label has two predecessors, and writing the shared
tail out twice costs 9 and 7 instructions.

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

The for loops of the previous commit count to countof(the array) instead of 9 and step with ++i, as main's other
loops do, and the goto that stays in HistoricMissionSelect_General gets the one-line reason its sibling has. 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>
gynt wrote DAT_ArrayOfMapIndices[offset + row - 1] against a header where DAT_MapSelectionPreloadMapIndexMapping sat
at 0x880 of MenuTextInputState and the array began at 0x884. Main has merged the two into one int[501] at 0x880, four
bytes earlier, so gynt's [i - 1] is main's [i], and with the - 1 kept the function read the element before the one
the original reads (reccmp on main: 92.9%, [eax*4 + instance+2172] against the original's +2176). Without it the
function is 100.0% raw and normalized again. The batch has no other user of the array.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuItemActionHandler_IdentityOptions_Confirm (0x00493D30) queues command 96 (push 0x60; call 0x489100,
queueCommand) when the identity options are confirmed outside GM_SOLITARY. The enum had 95 and 98 but not 96; it gets
the placeholder name form of GCT_UNKNOWN_98.

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

MenuItemActionHandler_TacticalPowerBar_Main (0x004DA050) plays sound effect 260 (push 0x104; call 0x449c40,
setUpSFXToPlayUnk) when tactical power 2, 3, 4, 6, 13 or 16 is picked, and 261 (push 0x105) for power 7. The enum
ended at 257; they get the same placeholder name form as SEID_UNKNOWN_0x100 and SEID_UNKNOWN_0x101, and 0x101's line
gains a comma.

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

The loop that drops the first spawn moment wrote spawnMomentX[i + 19] and spawnMomentY[i + 19], past the end of the
20-element X and Y arrays. Those are the addresses of spawnMomentY[i - 1] and spawnMoment[i - 1] (X at 0x61B04, Y at
0x61B54, spawnMoment at 0x61BA4 in MinimapViewState), so they are written that way, as main's clearOldSpawnMoment
does. The code is unchanged: quick_diff and the listing give the same instructions and the same offsets
(instance+400208 and +400288) before and after.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buildmenuMenuTabToSwitchTo is an ActiveMenuTab union; the draft stored the 10 through its tabType member as
BASMTT_HUNTERSHUT. It is the build menu's tab, so it is written through buildMenuTab as BMTT_CASTLE (also 10), as
main's hideOrUnhideUI writes the same field. Same offset, same value: quick_diff and the listing are unchanged.

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

These come from the review of the branch, and none of them changes the generated code:
- param_N gets main's names: button for the menu buttons (tacticalPower for TacticalPowerBar_Main, whose value
  becomes activeTacticalPower), row for the table rows, unused where the parameter is not read, unused and
  scrollbarEvent for the scrollbar handlers, unused and sliderValue for the scrollbar renders, and descBoxIndexUnk
  for LobbyMenu_MapDescScrollbar, which picks 204 or 110 by it.
- The last decompiler locals: DVar1 in LoadMap_TableContent is clickTime, and the BVar1 of the LobbyMenu
  MapDescScrollbar render goes: it returns when AModalDialogIsActiveButIsNotQuitting is set and stores
  RT_SCREEN_MENU by name (MSVC still stores the zero it tested).
- Ghidra's comma operators inside if conditions become statements with early returns or nested ifs:
  TacticalPowerBar_Main (whose barLevel is now declared where it is assigned), MapDescriptionBox,
  OverlaySlider_Deselect, UnusedWinCondition_DeselectUnk, LordIcons and UnusedCreateMessageEvent.
- Casts that restated a field's own type go: DAT_ButtonX/Y/W/H, DAT_ButtonBackgroundBlendStrength,
  menuLoadGameRelativeSelectionOffset, fileListEntryCount, DAT_MapSelectionScrollOffset/TotalNumber, spawnMomentY,
  spawnMomentCount, MapPropertiesState::offset, (ushort) on the COL_*.shortValue arguments, (BGR24)((int)textColor),
  (int)((int)(shieldIndex + 469)) and the function pointer casts on sliderCallbackFunction. The ones that change
  signedness or type stay: (int)mbr_0x928, (int)total, (TextAlignment)DAT_ButtonW and
  (int)(clickTime - lastListClickTime).
- Number casts become enum names: GCT_UNKNOWN_96, SEID_UNKNOWN_0x100, SEID_UNKNOWN_0x104 and SEID_UNKNOWN_0x105,
  and their using lines go. The old title menu's textColor = 0 is COL_000000, and its BGR24 include and using
  line go with the (BGR24)((int)textColor) cast they served.
- BOOLEnum.hpp is dropped from the 8 files that never name BOOLEnum, and BOOLEnum values are tested by truth and
  stored as TRUE / FALSE where these lines touch them.
- The three sparse-switch comments are one line each, and the comments on the two gotos that stay give what
  writing the shared tail out twice costs: 9 instructions in HistoricMissionSelect_General, 7 in
  UnusedEconomicMissionSelect_General.

quick_diff gives the same output for every file before and after, but for the jump table's label numbers in
TacticalPowerBar_Main's listing; 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>
…y returns over the batch

These come from the second review of the branch, and none of them changes the generated code:
- The old title menu's ContinueButton and TestMapButton lose their two lines of assembly over a plain if / else, as
  main's ExitButton has it.
- HistoricMissionSelect_General and UnusedEconomicMissionSelect_General test difficulty >= 4 and
  (int)(clickTime - lastListClickTime) >= 500 with the constant on the right. The assembly comment over the first
  becomes one line saying why it is not > 3 (> 3 takes quick_diff from 0.9111 to 0.8667). Cases 18 and 20 lose the
  braces they did not need; the default keeps its own for clickTime, and the goto still lands where it did.
- The decompiler's parentheses go: (DAT_00b96100 - button) - 1, the if ((a == x) && (b == y)) tests in
  HistoricMissionSelect_General, UnusedEconomicMissionSelect_General, UnusedSomeMissionStartUnk_General,
  NewMapMaptype_Buttons and LoadMap_TableContent, and the nested ones in MapDescriptionScrollbar and
  Unknown27CampaignUnk_Main.
- SaveLoadMap_Scrollbar tests the offset with > 0, steps it with --x / ++x, and its case 5 gets main's line from
  BuildingAvailability_Scrollbar on why it stores and returns.
- UnusedCreateMessageEvent_Unknown's second arm stores data.message.messageID, which sits at the same offset 0 of
  InGameEventUnion as the first arm's data.scenario.actionData, so the two arms no longer look like one store written twice.
- LobbyMenu_MapDescScrollbar returns early instead of wrapping its body, OptionsMenu_SubOptionsButtons returns from
  its two arms that broke out of the switch, and UnusedEconomicGametypeSelect_Main loses its empty case 4.
- resetToTextIndex gets TAIT names, as main's callers write them: TAIT_NINE__FILTER_B in IdentityOptions_Confirm and
  MapDescriptionBox, TAIT_ZERO in OptionsMenu_SubOptionsButtons.

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>
In HistoricMissionSelect_General and UnusedEconomicMissionSelect_General, in main's one-line form. Comment only.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the declaration/type change This requires changes to the generated/exported types or definitions. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Style guide reading (advisory, posted once)

2 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 2 of the 32 reimplemented .cpp file(s) in this PR.

The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.

rule what it asks hits
20 Keep nesting low; no goto 2
Where

Rule 20 — Keep nesting low; no goto

  • src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemActionHandler_HistoricMissionSelect_General.cpp:39 — goto; check how many predecessors the target has first
  • src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedEconomicMissionSelect_General.cpp:38 — goto; check how many predecessors the target has first

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 68c481f 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