Skip to content

Reimplement 40 UI::MenuModals, DisplayElements and Rendering functions: gynt's finished backlog (100%) - #380

Merged
gynt merged 58 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-gynt-backlog-ModalsDisplayRendering
Nov 10, 2026
Merged

gynt merged 58 commits into
sourcehold:mainfrom
kotijekriv:reimpl/UI-gynt-backlog-ModalsDisplayRendering

Conversation

@kotijekriv

@kotijekriv kotijekriv commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

This PR lands 40 more of gynt's finished UI functions (21 MenuModals, 11 DisplayElements, 8 Rendering), as he OK'd 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"). It's the sibling of #379 (MenuViews).

Each function read 100% on his fork but was never in a PR. Each comes in as a commit authored by him: his file as it stands at the last commit that touched it on his fork, 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). The setup:

  • the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a);
  • struct and function resolvers enabled locally (not committed);
  • sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie.

A full build reads 39 of the 40 at 100.0% raw. RenderStartingGoodDisplayElement reads 99.2% raw / 100% normalized; see below. openshc-pr-check gives no errors, and status_regression.py finds no status line that dropped. None of it has been run in game.

Our commits on top of his

  1. Main's names. Five files didn't compile against today's headers:

    • field76_0xbe8;
    • GMTotalPicturesProcessed → GMFirstPictureIndex;
    • DAT_MenuLoadGameRelativeSelection* → menuLoadGameRelativeSelection*;
    • field44_0xa0;
    • PTR_ARRAY_00c9a510/00d7d250 → TGX_RepeatRunHandlers/TGX_StreamRunHandlers.

    Two functions needed small changes to stay at 100% on main:

    • YesNoDialog switches on DAT_MenuOptionsActionParameter through (int). Main's field is undefined4 where gynt's branch had int; without the cast it reads 65.5%.
    • RenderCurrentMenuView's two final stores are swapped (97.2% the other way).
  2. The style fixer's pass, then colour names, NULL, and doubled includes dropped.

  3. String pointers from string-literals.hpp, each with its text in a // "…" comment above it.

  4. Names. The decompiler's locals and gynt's underscore locals are named and declared at first use, and the arguments are written in the calls.

  5. Text groups by their eTextSections names (TEXT_SCENARIO, TEXT_GAME_OPTIONS, and so on). The sprite IDs are GM_BODY_LORD/GM_BODY_ARABIC_LORD, and the loop bound uses countof.

  6. Early returns or continues in nine functions. Also:

    • YesNoDialog stores currentMenu->zero once;
    • RenderDisplayElementsUnk's x test is a switch, like its y test;
    • else if chains where one value is tested several times;
    • RenderCurrentMenuView calls menuView->prepare() etc. and loses the imported Ghidra comments.
  7. RenderStartingGoodDisplayElement.

    • No more gotos.
    • A for over the 25 goods, and 204 + scrollIconIndex % 6.
    • The icon sizes are read as DAT_GMImageHeaders.imh[...].width/.height, in place of the read past the end of PTR_ARRAY_Unknown_UnitGMHeights.
  8. Pointer arithmetic.

    • drawGfxOnFlaggedSurface adds to the buffer pointer, as main's renderGfxTgxWithBlending does.
    • transformGmColorTable's palette walk is a for.
    • RenderPlayerPingUnkDisplayElement22's lag walk is a for with the pointer set before it. That form compiles exactly like the while; declaring the pointer in the for header moves one add (quick_diff 0.9595 → 0.9480).
  9. Namespaces. The DisplayElements files use main's namespace DisplayElements { … } form.

RenderStartingGoodDisplayElement at 99.2% raw. Its only two differing lines are the data address of the icon-size reads:

  • imh[i - 1] folds to DAT_GMImageHeaders - 16.
  • In the original's layout that is PTR_ARRAY_Unknown_UnitGMHeights[28], the address the game uses.
  • With the struct resolvers on, it lands just before our copy of the headers, so reccmp names a different symbol.

Main records the same imh[… - 1] form at 100% in MenuItemRenderFunction_NewInvasion_UnitButtons, MenuItemRenderFunction_TriggerInvasion_Main and getWidthOfText, and the status line here says 100.0% the same way. Gynt's pun reads 100.0 raw, if that's preferred; it's a one-line change.

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.

  • TextArrayIndexType gets TAIT_UNKNOWN_4 (6e938c5). MenuModalRenderFunction_Chat resets the user text handler to 4. This is the same line as in Reimplement 47 UI::MenuViews functions: gynt's finished backlog (100%) #379, so the two merge in either order.
  • GameSynchronyState::connectionInfoExpanded is a BOOLEnum (16bb3e0). It was undefined4.
    • Every write in the binary stores 0 or 1: mov dword ptr [0x01A26A18], 0 at 0x0048FC80, and two stores from registers holding 1 and 0 in RenderSomeMultiplayerInfoUnkDisplayElement19.
    • Of its two reads, 0x004B00A2 compares it with zero, and 0x004AFE24 uses the 0/1 value in the box height ((x × 3 + 12) × 16).
    • No .cpp on main uses it. Its only user here writes TRUE/FALSE and tests it by truthiness.

Kept as they are, measured with quick_diff

Function What stays The cleaner form
RenderSomeMultiplayerInfoUnkDisplayElement19 the nested if (isHost) an early if (!isHost) return: 0.9516 → 0.9183
RenderPlayerPingUnkDisplayElement22 an int* over the lag entries an indexed for or a ConnectionLagInfo* walk: 0.9595 → 0.9364
MenuModalRenderFunction_AiLordSelect the second <= 8 test yPos += 76 in the else: 0.9412 → 0.9185
MenuModalRenderFunction_Chat the currentText local inlined: 0.9588 → 0.9223
RenderAndPlayKeepAndGranaryPlacementInfoDisplayElement the three text calls as they are all inline: 0.9620 → 0.8481; all through text: 0.7407
MenuModalRenderFunction_ReceiveMapFrom the second width / 4 reusing left: 0.9851 → 0.5496
MenuModalRenderFunction_DebugDataAivStateUnk the colour set in both branches, three reads of the placement fit one override: 0.9697 → 0.8265; one const local: 0.6458
  • The two (int) casts in RenderSomeMultiplayerInfoUnkDisplayElement19: the original divides currentPacketTotalSize and resyncTransferTotalSize signed, but the header has them as undefined4.
  • YesNoDialog's numeric case labels: DAT_MenuOptionsActionParameter has no enum. The values are the TEXT_GAME_OPTIONS number of the button that opened the dialog: 7 "Quit Mission", 9 "Exit Crusader", 44 "Restart Mission", and also 30/43/47/49. -7 and 1000 come from ScenarioDescription, and 2000 is the receive-map case.
  • The style-lint bot's two findings, 0xfc00 and 0x3e0 in transformGmColorTable, are RGB555 channel masks used with &. Hex with & is gynt's rule (Reimplement 32 rendering and UI rendering functions at 100% #311).
  • Also as the original does:
    • the Yes/No hit boxes are 150 wide while the drawn buttons are 100;
    • RenderPlayerPing22 calls timeGetTime() and drops the result;
    • RenderStartingGood reads the player slot a second time after its text calls.

Header changes we didn't make (suggestions)

  • MenuTextInputState::DAT_MenuOptionsActionParameter → int, which would drop YesNoDialog's cast. All 12 of main's users only store to it.
  • currentPacketTotalSize/resyncTransferTotalSize → int, which would drop MP19's casts.
  • DAT_CurrentlyRenderedSpriteID → eGM.
  • drawLoadingBarUnk(GmID currentGmId, int barLengthUnk) really takes (int progress, int progressMax); main's callers cast int progress values to GmID.
  • GMFileHeaderColorpalette::colorPalette (short[10][256]) holds RGB555 colours. As RGB15 it would drop transformGm's (ushort*).
  • savedListOffset/Selection/SortOrder1-3 look like a struct [3].
  • DEID_PLAYER_PING_Unk_19 has the value 22.

What some placeholders hold

  • field_0xbe8: a millisecond timestamp compared with lastAutoSaveTime; the difference / 60000 is the minutes since the last save.
  • DAT_00df42b0: a 0/1 toggle flipped every 500 ms.
  • invasionEventContent.field_0xa0: the selected event's TEXT_SCENARIO text number. 148 shows 146's text with an icon.
  • someCount45: the goods popup's state (1 starting goods, 2 captured goods).
  • someCount47: the icon's scroll position.
  • selectedLordTypeUnk: 0 for the European lord, otherwise the Arabic one.
  • mapSendingByteBufferAddress[9]: the bytes transferred per player, not an address.
  • hInstanceUnk_0xa8: the HINSTANCE passed to createCrusaderWindow.
  • windowRenderTimeUnk_0x1e0: when the window was set up.

The 40 functions

Function, address, and gynt's branch and commit it comes from
Function Address gynt's branch, commit
Destructor_TextureRenderCore 0x0044C7E0 archive/UI-MenuViews-development-second-pass 32939bb
MenuModalRenderFunctionMenuModal_DeleteGameRecord 0x004D9CC0 reimpl/UI-MenuModals 6d5d3fb
MenuModalRenderFunction_AiLordSelect 0x004B19E0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_Allies 0x004AC6E0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_BuildingAvailability 0x004ABBA0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_Chat 0x004ABD20 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_DebugDataAivStateUnk 0x004AF4C0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_IdentityOptions 0x00491AC0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_LoadMap 0x00494210 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_NewEventCondition 0x004ABA20 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_OnlineVoteQuitGame 0x004937E0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_OverlaySlider 0x004AA440 archive/UI-MenuViews-development-second-pass 32939bb
MenuModalRenderFunction_ReceiveMapFrom 0x004AC4C0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_SaveMap 0x004931A0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_SendMapTo 0x004AC310 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_TacticalPowerBar 0x004D9DB0 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_TriggerEventSlider 0x004AC280 archive/UI-MenuViews-development-second-pass 32939bb
MenuModalRenderFunction_UnusedChooseMessageBox 0x004AB460 archive/UI-MenuViews-development-second-pass 32939bb
MenuModalRenderFunction_UnusedCreateMessageEvent 0x004AB680 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_UnusedCreateTimedMessageEvent 0x004AB570 reimpl/UI-MenuModals-100 25e0f9f
MenuModalRenderFunction_VideoOptions 0x00492120 archive/UI-MenuViews-development-second-pass 32939bb
MenuModalRenderFunction_YesNoDialog 0x00493390 reimpl/UI-MenuModals-100 25e0f9f
RenderAndPlayKeepAndGranaryPlacementInfoDisplayElement 0x004B1C30 reimpl/UI-DisplayElements-pr-100 f87b2f2
RenderBottomLeftDateDisplayElement 0x00433D00 reimpl/UI-DisplayElements-pr 140bef0
RenderConnectAndPathLinkageInfoTextDisplayElement 0x00433BC0 archive/UI-MenuViews-development-second-pass 32939bb
RenderCurrentMenuView 0x004F6210 archive/UI-MenuViews-development-second-pass 32939bb
RenderDisplayElementsUnk 0x004AF700 reimpl/UI-DisplayElements-pr-100 f87b2f2
RenderGamePausedTextDisplayElement 0x004B1E60 reimpl/UI-DisplayElements-pr 140bef0
RenderGameSpeedTextDisplayElement 0x004B07C0 reimpl/UI-DisplayElements-pr 140bef0
RenderMissionWinDefeatBannerDisplayElement 0x004AFDA0 reimpl/UI-DisplayElements-pr-100 f87b2f2
RenderPeopleLeftToPlaceDisplayElement 0x004B0AC0 reimpl/UI-DisplayElements-pr 140bef0
RenderPlayerPingUnkDisplayElement22 0x004B1D30 reimpl/UI-DisplayElements-pr-100 f87b2f2
RenderSomeMultiplayerInfoUnkDisplayElement19 0x004AFE10 reimpl/UI-DisplayElements-pr-100 f87b2f2
RenderStartingGoodDisplayElement 0x00433DA0 reimpl/UI-DisplayElements-pr-development fbc092e
adaptGmColorsToRGB565IfRequired 0x00455930 archive/UI-MenuViews-development-second-pass 32939bb
clearSomeMemory 0x0044CC30 archive/UI-MenuViews-development-second-pass 32939bb
createCrusaderWindow 0x0046FF50 reimpl/UI-Rendering-100 11cb30e
drawGfxOnFlaggedSurface 0x004558E0 archive/UI-MenuViews-development-second-pass 32939bb
drawLoadingBarUnk 0x0044C850 archive/UI-MenuViews-development-second-pass 32939bb
transformGmColorTableFromRGB555To565IfRequired 0x0044C8F0 archive/UI-MenuViews-development-second-pass 32939bb

Other PRs:

🤖 Generated with Claude Code

gynt and others added 30 commits November 9, 2026 14:37
RenderAndPlayKeepAndGranaryPlacementInfoDisplayElement, gynt's version as it stands on his fork's
reimpl/UI-DisplayElements-pr-100 at f87b2f2 (2026-10-27), where its status line reads 100.0%; that commit is also
the last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderBottomLeftDateDisplayElement, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr at
140bef0 (2026-10-03), where its status line reads 100.0%; the file was last changed in 5cda263 (2026-10-02,
"reimplement: SHC_3BB0A8C1_0x00433D00 100.0% Reimplemented"). Taken unchanged; what main needs on top follows in
our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderConnectAndPathLinkageInfoTextDisplayElement, gynt's version as it stands on his fork's
archive/UI-MenuViews-development-second-pass at 32939bb (2026-10-25), where its status line reads 100.0%; the
file was last changed in a389f84 (2026-10-04, "style: drop the redundant OpenSHC:: prefix, as origin/main does").
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderDisplayElementsUnk, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr-100 at f87b2f2
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderGamePausedTextDisplayElement, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr at
140bef0 (2026-10-03), where its status line reads 100.0%; the file was last changed in 1877b09 (2026-10-02,
"reimplement: SHC_3BB0A8C1_0x004B1E60 100.0% Reimplemented"). Taken unchanged; what main needs on top follows in
our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderGameSpeedTextDisplayElement, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr at
140bef0 (2026-10-03), where its status line reads 100.0%; the file was last changed in d9c4bcb (2026-10-02,
"reimplement: SHC_3BB0A8C1_0x004B07C0 100.0% Reimplemented"). Taken unchanged; what main needs on top follows in
our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderMissionWinDefeatBannerDisplayElement, gynt's version as it stands on his fork's
reimpl/UI-DisplayElements-pr-100 at f87b2f2 (2026-10-27), where its status line reads 100.0%; that commit is also
the last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderPeopleLeftToPlaceDisplayElement, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr at
140bef0 (2026-10-03), where its status line reads 100.0%; the file was last changed in c286c13 (2026-10-02,
"reimplement: SHC_3BB0A8C1_0x004B0AC0 100.0% Reimplemented"). Taken unchanged; what main needs on top follows in
our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderPlayerPingUnkDisplayElement22, gynt's version as it stands on his fork's reimpl/UI-DisplayElements-pr-100 at
f87b2f2 (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderSomeMultiplayerInfoUnkDisplayElement19, gynt's version as it stands on his fork's
reimpl/UI-DisplayElements-pr-100 at f87b2f2 (2026-10-27), where its status line reads 100.0%; that commit is also
the last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RenderStartingGoodDisplayElement, gynt's version as it stands on his fork's
reimpl/UI-DisplayElements-pr-development at fbc092e (2026-11-04), where its status line reads 100.0%; that commit
is also the last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_AiLordSelect, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_Allies, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at 25e0f9f
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_BuildingAvailability, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_Chat, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at 25e0f9f
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_DebugDataAivStateUnk, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunctionMenuModal_DeleteGameRecord, gynt's version as it stands on his fork's reimpl/UI-MenuModals
at 6d5d3fb (2026-11-02), where its status line reads 100.0%; the file was last changed in d817410 (2026-10-03,
"reimplement: SHC_3BB0A8C1_0x004D9CC0 100.0% Reimplemented"). Taken unchanged; what main needs on top follows in
our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_IdentityOptions, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_LoadMap, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at 25e0f9f
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_NewEventCondition, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_OnlineVoteQuitGame, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_OverlaySlider, gynt's version as it stands on his fork's
archive/UI-MenuViews-development-second-pass at 32939bb (2026-10-25), where its status line reads 100.0%; the
file was last changed in 637c6b0 (2026-10-06, "style: write BOOLEnum FALSE-comparisons as truth tests"). Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_ReceiveMapFrom, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_SaveMap, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at 25e0f9f
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_SendMapTo, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at 25e0f9f
(2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file. Taken
unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_TacticalPowerBar, gynt's version as it stands on his fork's reimpl/UI-MenuModals-100 at
25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the last one to change the file.
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_TriggerEventSlider, gynt's version as it stands on his fork's
archive/UI-MenuViews-development-second-pass at 32939bb (2026-10-25), where its status line reads 100.0%; the
file was last changed in cf563c2 (2026-10-10, "style: declare 605 locals at their first use"). Taken unchanged;
what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_UnusedChooseMessageBox, gynt's version as it stands on his fork's
archive/UI-MenuViews-development-second-pass at 32939bb (2026-10-25), where its status line reads 100.0%; the
file was last changed in a389f84 (2026-10-04, "style: drop the redundant OpenSHC:: prefix, as origin/main does").
Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_UnusedCreateMessageEvent, gynt's version as it stands on his fork's
reimpl/UI-MenuModals-100 at 25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the
last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_UnusedCreateTimedMessageEvent, gynt's version as it stands on his fork's
reimpl/UI-MenuModals-100 at 25e0f9f (2026-10-27), where its status line reads 100.0%; that commit is also the
last one to change the file. Taken unchanged; what main needs on top follows in our own commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotijekriv and others added 13 commits November 9, 2026 17:33
…L, doubled includes

Mechanical fixes over 35 of gynt's files: text colours written as numbers use their ColorsEnum names (COL_C2F0EB,
COL_CCFAFF, COL_B8EEFB, COL_0080FF), the "added by script" block comments become // "text" lines and other block
comments // lines, the decompilerscript plate comments and the trailing return;s go, (T*)0x0 is NULL, and the
nine includes of a file's own .func.hpp under its full path (next to "../X.func.hpp") are dropped. quick_diff
identical for every file.

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

Main's declare_at_use.py over the 40 files: in six of them the decompiler's leading declarations move down to the
first assignment (style guide 24), and declarations nothing uses go. quick_diff identical for every file.

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

The four files of gynt's that wrote file names and texts as literals use main's s_ pointers (style guide 12), each
for the address the original pushes. RenderSomeMultiplayerInfoUnkDisplayElement19 loses the decompiler's argument
locals (two runs of them were dead stores), names the title's y, the autosave line's y, the minutes since the last
save and the cancel button's left edge, and tests isMouseInsideBox directly;
RenderAndPlayKeepAndGranaryPlacementInfoDisplayElement names the text and its measured height and width, writes its
numbers in decimal and its colour as COL_CCFAFF. quick_diff identical for every file.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…piler's argument locals

The title's y, the shared x of both texts and the message's y are named; the other arguments are written in the
calls, the colour is COL_CCFAFF, and the time is now. quick_diff identical (0.9245).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two gotos go: the death and team checks are an if of their own ahead of one test for the victory and defeat
timers (the original's second solitary test stays in that test), and the jump to the drawing loop was to the next
line. The start goods are counted by one for-loop over startResources (MSVC unrolls it by five, as the hand-walked
pointer did, without its [-1]), and the drawing loop is a for over the good and its picture. quick_diff identical
(0.9735).

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ead of the decompiler's locals

In RenderGameSpeedTextDisplayElement, RenderGamePausedTextDisplayElement, RenderPeopleLeftToPlaceDisplayElement,
RenderBottomLeftDateDisplayElement and MenuModalRenderFunctionMenuModal_DeleteGameRecord the locals the decompiler
made for each argument (alignment, colours, font size, the shadow flag, positions) are written in the calls, and
unused ones go; DeleteGameRecord keeps its centred x, which the original computes before the text call.
RenderDisplayElementsUnk declares its two positions where it computes them (inlining them there lost: quick_diff
0.9605 -> 0.7947). quick_diff identical for every file.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in nine files, one goto

Nine more files of gynt's: MenuModalRenderFunction_Chat names its title position and the cursor's x;
RenderCurrentMenuView walks menuView in its for; MenuModalRenderFunction_TriggerEventSlider sets its icon in each
branch in place of the goto (the compiler shares the store again); RenderPlayerPingUnkDisplayElement22 names the
player and the lag pointer and ends that pointer at connectionLagInfoArray[9].average2 rather than instance +
0x7ac48 (an indexed for loses, measured in its comment); clearSomeMemory passes the arrays with sizeof counts;
transformGmColorTableFromRGB555To565IfRequired keeps its pointer do-while under names (a for loses, measured in its
comment); MenuModalRenderFunction_OverlaySlider and createCrusaderWindow test their calls directly;
MenuModalRenderFunction_DebugDataAivStateUnk counts aivIndex in a for, picks its colour (COL_0000FF or COL_C2F0EB)
in an if/else and names the placement fit. quick_diff identical for every file.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The usings the earlier passes left unused go (the fixer, 11 files); MenuModalRenderFunction_SendMapTo loops over
playerID with indexed player names, transfer states, colours and buffer counts in place of the walked pointers and
byte offsets (and no instance + 0x109daa end); the remaining text colours are COL_CCFAFF and COL_FFFFFF; and the
defeat banner's box is written in decimal. quick_diff identical for every file.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MenuModalRenderFunction_Chat (0x004ABD20) tests the user text handler's index against 4 and resets it to 4 (push 4
before resetToTextIndex), which the enum leaves out between TAIT_THREE__FILTER_A and TAIT_FIVE__NUMERIC_DOT;
TheRedDaemon asked for such values on sourcehold#300. Used in the next commit; code generation is the same.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nts, names, early returns

Across the 40 files:
- the (ushort) casts on the COL_ shortValues dropped (shortValue is already a ushort);
- the unused BOOLEnum and BGR24 includes dropped (TRUE/FALSE are Windows macros; the colour parameters' headers
  bring BGR24 themselves);
- a // "text" comment above each statement that passes an s_ string pointer;
- the underscore locals named and declared at first use (RenderDisplayElementsUnk, RenderBottomLeftDate,
  drawLoadingBarUnk, adaptGmColorsToRGB565IfRequired); RenderBottomLeftDate passes FALSE and COL_000000 instead of
  reusing the zero it had just tested;
- decimal for the hex numbers the fixer leaves alone because they look like masks (font sizes, offsets, a case
  label, a 30 ms interval);
- the text groups of drawHeaderTextBanner by their eTextSections names, in twelve of its fifteen calls;
- TAIT_UNKNOWN_4 for the chat's text index (the header commit before this one);
- truth tests on the BOOLEnum mouse fields, and casts dropped where the value already has the type
  (DAT_InsultTextIndex, the menu's y, BGR24 colours passed as uint);
- DebugDataAivStateUnk's loop bound as countof(DAT_AIVPlacementFit::instance);
- an early return for the first test of RenderBottomLeftDate, and in adaptGmColorsToRGB565IfRequired and
  transformGmColorTableFromRGB555To565IfRequired (each ties with the nested form).
Every function is quick_diff-identical to before, and all 40 are 100% in a full reccmp build.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every write in the binary stores 0 or 1 (mov dword ptr [0x01A26A18], 0 at 0x0048FC80, and in
RenderSomeMultiplayerInfoUnkDisplayElement19 the stores at 0x004B0134 and 0x004B0324 from registers holding 1 and 0),
and of its two reads 0x004B00A2 compares it with zero while 0x004AFE24 uses the 0/1 value in the box height
((x * 3 + 12) * 16). No .cpp on main uses it; the next commit's
RenderSomeMultiplayerInfoUnkDisplayElement19 is its only user and writes TRUE/FALSE. Code generation is the same.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… image sizes, early returns

- Text comments in the right branch (Victory/Defeat, Sending/Receiving game state, auto save on/off) and the ones
  that were missing (Starting/Captured goods, the keep and granary prompts, the AI lord hint); the fixer's leftover
  in PeopleLeftToPlace and the speech lines nobody can check go.
- The last bare text groups (TriggerEventSlider, UnusedChooseMessageBox, VideoOptions) by their eTextSections names;
  Chat's two (int) casts on getCurrentFontSize go; `!= false` on the tactical-powers bool is a truth test.
- RenderStartingGood reads the icons' sizes as DAT_GMImageHeaders.imh[...].width/.height (main's TraderSettings
  form) in place of the pun past PTR_ARRAY_Unknown_UnitGMHeights; its heading and label arguments are in the calls
  (the label's position stays named, which keeps the original's registers), one playerSlotID plus the second read
  the original makes after the text calls, an else-if for the popup state, `+= 2`, `204 + scrollIconIndex % 6`,
  and a for over the 25 goods with a continue. startGoodsCount stays above the early returns, where the original
  zeroes it.
- connectionInfoExpanded (previous commit) is tested and stored as TRUE/FALSE, and its clicks are
  `if (leftClickStart) { ... } return;`.
- Early returns or continues in RenderBottomLeftDate (both tests), NewEventCondition, DebugDataAivStateUnk,
  SendMapTo, RenderDisplayElementsUnk, RenderCurrentMenuView, createCrusaderWindow and drawLoadingBarUnk;
  ConnectAndPathLinkage tests its second tile type with else if; YesNoDialog stores
  currentMenu->zero once; RenderDisplayElementsUnk's x test is a switch like its y test; adaptGmColors uses an
  else-if chain; TriggerEventSlider tests the event number twice in declaration order; transformGmColorTable's
  pointer walk is a for (countof for the palette size), so its do-while and the measured comment go.
- drawGfxOnFlaggedSurface adds to the buffer pointer, as main's renderGfxTgxWithBlending does, with its comment.
- RenderCurrentMenuView loses the imported Ghidra comments and calls through menuView->prepare() etc.
- The DisplayElements files use main's `namespace DisplayElements { ... }` form; names (secondsLeft, centerX,
  autoSaveY, rgb555), GM_BODY_LORD and GM_BODY_ARABIC_LORD for the sprite IDs, redundant casts and some redundant
parentheses go.
Kept, measured: RenderSomeMultiplayerInfoUnkDisplayElement19's nested if (isHost) (an early `if (!isHost)` return:
quick_diff 0.9516 -> 0.9183), the lag
walk as an int* (an indexed for or a ConnectionLagInfo* walk: 0.9595 -> 0.9364), AiLordSelect's second test
(0.9412 -> 0.9185), Chat's currentText local (0.9588 -> 0.9223), the keep and granary text calls as they are (all
inline 0.9620 -> 0.8481, all through text 0.7407), ReceiveMapFrom's second width / 4 (reusing left 0.9851 -> 0.5496),
DebugDataAivStateUnk's colour set in both branches (one override: 0.9697 -> 0.8265) and its three reads of the
placement fit (one const local: 0.6458).
Every other change is quick_diff-identical. Full build: 39 functions reccmp 100.0; RenderStartingGood reads 99.2,
and its two differing lines are the size reads' data address alone. imh[i - 1] folds to DAT_GMImageHeaders - 16,
which in the original's layout is PTR_ARRAY_Unknown_UnitGMHeights[28] (the address the game uses) and with the
struct resolvers on lands just before our DAT_GMImageHeaders. Main records the same imh[... - 1] form at 100% in
MenuItemRenderFunction_NewInvasion_UnitButtons, MenuItemRenderFunction_TriggerInvasion_Main and getWidthOfText.

Co-authored-by: Gynt <gynt@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a for, two comments

RenderPlayerPingUnkDisplayElement22's while over the lag entries is a for now, with the pointer still set before
yPosition, as the original orders the two: quick_diff output identical to the while. With the pointer declared in
the for's header, MSVC moves one add ahead (0.9595 -> 0.9480), so the header leaves the init out. Its comment says
why the pointer is compared as int (the original's jl). Two comments lose an escaped apostrophe.

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 1 of the 40 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
18 Use the name, not the number 2
Where

Rule 18 — Use the name, not the number

  • src/OpenSHC/UI/Rendering/TextureRenderCore/transformGmColorTableFromRGB555To565IfRequired.cpp:23 — hex constant 0xFC00; use a name, or decimal
  • src/OpenSHC/UI/Rendering/TextureRenderCore/transformGmColorTableFromRGB555To565IfRequired.cpp:23 — hex constant 0x3E0; use a name, or decimal

kotijekriv and others added 2 commits November 10, 2026 00:42
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>
… sync (TAIT_UNKNOWN, INT_00b9840c)

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 fcf49a4 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