From 50e92ca40e473b268a5f64acf3d2502246840b09 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 13:18:54 +0100 Subject: [PATCH 01/17] reimplement: SHC_3BB0A8C1_0x004BBF40 100.0% Reimplemented Moved here unchanged from the draft #328 (reimpl/UI-MenuItems-3-development-2, 13fbfea13). It was 100% before the header sync a9401a727 and 92.3% on #328's base 72b27322e, where MSVC stopped sharing the tails of its two number calls. On main 57d333434 it compiles to the original's 100 instructions again, with the shared tail. quick_diff is left with its own artefacts only: the jump-table spelling, the colour immediates, the picture table's address written as its base less 14, and ret / ret 0. reccmp: 99.2% raw and 100% normalized, where only the picture table's address differs (reccmp shows it as an offset into DAT_GMImageHeaders), which the project records as 100%. Co-Authored-By: Claude Opus 5.5 --- ...temRenderFunction_TriggerInvasion_Main.cpp | 134 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp new file mode 100644 index 0000000000..4e75fe37b9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp @@ -0,0 +1,134 @@ +#include "../TriggerInvasion.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BBF40 + void TriggerInvasion::MenuItemRenderFunction_TriggerInvasion_Main(int unitType, ...) + { + // the unit's picture in army_units.gm1, counted from 1 + int imageID = 0; + switch (unitType) { + case 0: + imageID = 1; + break; + case 1: + imageID = 2; + break; + case 2: + imageID = 3; + break; + case 3: + imageID = 4; + break; + case 4: + imageID = 5; + break; + case 5: + imageID = 6; + break; + case 6: + imageID = 7; + break; + case 7: + imageID = 8; + break; + case 8: + imageID = 9; + break; + case 9: + imageID = 12; + break; + case 10: + imageID = 13; + break; + case 11: + imageID = 15; + break; + case 12: + imageID = 14; + break; + case 13: + imageID = 16; + break; + case 14: + imageID = 11; + break; + case 15: + imageID = 10; + break; + case 16: + imageID = 17; + break; + case 17: + imageID = 18; + break; + case 18: + imageID = 19; + break; + case 19: + imageID = 20; + break; + case 20: + imageID = 21; + break; + case 21: + imageID = 22; + break; + case 22: + imageID = 23; + break; + case 23: + imageID = 24; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const unitCount = DAT_MapPropertiesState::instance.invasionEventContent.unitCountsPerUnitType[unitType]; + if (unitCount != 0) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + // the unit's picture, its middle at y + 15 + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, DAT_ButtonX::instance, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] + .height + / 2 + + 15); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d195ecb365..dd70a9841a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29831,7 +29831,7 @@ SHC_3BB0A8C1_0x004BBF30 | 0.0% | Pending SHC_3BB0A8C1_0x004BBF34 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBF40 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBF40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC0A8 | 0.0% | Pending From 181b559c2853f7ab368318122fa48eb08561c4d9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 16:04:15 +0100 Subject: [PATCH 02/17] headers: MenuItemActionHandler_InGameMenu_Scrolling takes no parameters The original ends with push 1 / call RecordTutorialPlayerAction / pop ecx (0x00434200 to 0x00434207). Declared (int, ...), our function tail-calls through its own argument slot instead (mov [esp + 4], 1 / jmp), which MSVC can only do when the function has a named parameter. Only the menu tables refer to it (six dwords, no call), and like WaitingForHost_ConnectToLobby it never reads an argument. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/MenuItems/InGameMenu.func.hpp | 2 +- src/OpenSHC/UI/MenuItems/InGameMenu.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu.func.hpp b/src/OpenSHC/UI/MenuItems/InGameMenu.func.hpp index 84ea8d524b..d149ccc962 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu.func.hpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu.func.hpp @@ -26,7 +26,7 @@ namespace UI { &OpenSHC::UI::MenuItems::InGameMenu::MenuItemActionHandler_InGameMenu_ViewToKeeps) MenuItemActionHandler_InGameMenu_ViewToKeeps; - MACRO_FUNCTION_RESOLVER(void(__cdecl*)(int param_1, ...), false, Address::SHC_3BB0A8C1_0x00434120, + MACRO_FUNCTION_RESOLVER(void(__cdecl*)(), false, Address::SHC_3BB0A8C1_0x00434120, &OpenSHC::UI::MenuItems::InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling) MenuItemActionHandler_InGameMenu_Scrolling; diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu.hpp b/src/OpenSHC/UI/MenuItems/InGameMenu.hpp index 6455785591..bbce3f3bd2 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu.hpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu.hpp @@ -19,7 +19,7 @@ namespace UI { void __cdecl MenuItemActionHandler_InGameMenu_ViewToKeeps(int param_1, ...); - void __cdecl MenuItemActionHandler_InGameMenu_Scrolling(int param_1, ...); + void __cdecl MenuItemActionHandler_InGameMenu_Scrolling(); void __cdecl MenuItemActionHandler_InGameMenu_MiniMapInteraction(int param_1, ...); From 15723109362d09084a187a2b22e594f398e68206 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 16:29:09 +0100 Subject: [PATCH 03/17] headers: SoundEffectID values 254 to 256 as SEID_UNKNOWN_ LobbyMenu_SkirmishTypeAndBalance plays them when the balance changes: 256 at either end (buttons 10 and 14), 255 one step from even (11 and 13) and 254 at even (12); the pushes are at 0x0042A888, 0x0042A8A1 and 0x0042A8B5. The draft wrote them as (SoundEffectID)0x100 and as SEID_UNIT_DAMAGE3 | SEID_PEOPLE_ARE_COMING_TO_THE_CASTLE (248 | 7) and SEID_UNIT_DAMAGE3 | SEID_ARROW_KILL (248 | 6). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SoundEffectID.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp index 46fa12b534..79f4314fdb 100644 --- a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp +++ b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp @@ -206,6 +206,9 @@ namespace Audio { SEID_UNIT_DAMAGE4 = 249, // 0x000000F9 SEID_UNKNOWN_0xFB = 251, // 0x000000FB SEID_UNKNOWN_0xFD = 253, // 0x000000FD + SEID_UNKNOWN_0xFE = 254, // 0x000000FE + SEID_UNKNOWN_0xFF = 255, // 0x000000FF + SEID_UNKNOWN_0x100 = 256, // 0x00000100 SEID_UNKNOWN_0x101 = 257 // 0x00000101 } SoundEffectID; From af487f073d6b29836503e84fb73532c16aefe01e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:05 +0100 Subject: [PATCH 04/17] reimplement: SHC_3BB0A8C1_0x0042A840 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. On main's headers it compiles to the original's 41 instructions, and quick_diff differs only in its own ret / ret 0. The style pass names the parameter and the button ranges, and the three sound effects by the names the previous commit adds. Co-Authored-By: Claude Opus 5.5 --- ...ndler_LobbyMenu_SkirmishTypeAndBalance.cpp | 57 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp new file mode 100644 index 0000000000..52ae78e4df --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance.cpp @@ -0,0 +1,57 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042A840 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_SkirmishTypeAndBalance(int button, ...) + { + if (DAT_00b960dc::instance != 0) { + return; + } + // only the host changes the game type and the balance + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + // button 4 draws the balance bar and button 20 the game type panel: clicking them changes nothing + if (button == 4 || button == 20) { + return; + } + // buttons 1 to 3 pick the game type + if (button >= 1 && button <= 3) { + DAT_GameSynchronyState::instance.skirmishGameIntensityType = button; + } + // the balance buttons start at 10 and set balance 1 from there, 3 (button 12) being even + if (button >= 10) { + DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = button - 9; + // 256 at either end, 255 one step from even, 254 at even + if (button == 10 || button == 14) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x100); + } + if (button == 11 || button == 13) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFF); + } + if (button == 12) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFE); + } + } + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index dd70a9841a..a8569a5ce0 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6937,7 +6937,7 @@ SHC_3BB0A8C1_0x0042A474 | 0.0% | Pending SHC_3BB0A8C1_0x0042A480 | 0.0% | Pending -SHC_3BB0A8C1_0x0042A840 | 0.0% | Pending +SHC_3BB0A8C1_0x0042A840 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042A8E0 | 0.0% | Pending From 8a87286732e8bd18206d146345d28635503956dd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:05 +0100 Subject: [PATCH 05/17] reimplement: SHC_3BB0A8C1_0x004D99F0 100.0% Reimplemented From gynt's fork branch reimpl/UI-MenuItems-100, 97.6% there. Rewritten without the decompiler's gotos, it keeps the original's 85 instructions. quick_diff's differences are its own: ret / ret 0, and the tail jump to MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface at 0x004D9A4F, which our listing writes as jmp trampoline<4603888> (0x00463FF0) and quick_diff does not count as a function. Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_RankingGames_Main.cpp | 88 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp new file mode 100644 index 0000000000..37699c3188 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/RankingGames/MenuItemRenderFunction_RankingGames_Main.cpp @@ -0,0 +1,88 @@ +#include "../RankingGames.func.hpp" + +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_00ed27a0.hpp" +#include "OpenSHC/Globals/DAT_00ed3124.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D99F0 + void RankingGames::MenuItemRenderFunction_RankingGames_Main(int button, ...) + { + // buttons -10 and -11 scroll the list up and down: pictures 85 and 81, the next one when hovered + if (button == -10 || button == -11) { + int picture = 81; + if (button == -10) { + picture = 85; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + ++picture; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, picture, DAT_ButtonX::instance, DAT_ButtonY::instance); + // a frame from one pixel above and left of the arrow to 20 pixels below and right of it + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance - 1, DAT_ButtonY::instance - 1, + DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + return; + } + // buttons 0 to 7 are the rows, which draw nothing here + if (button < 8) { + return; + } + // the column headers are 20 to 31; any other button draws its own picture + if (button >= 20 && button <= 31) { + // button 20 clears the hovered header, and the hovered one stores itself + if (button == 20) { + DAT_00ed27a0::instance = 0; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_00ed27a0::instance = button; + } + // headers 20 to 29 sort by columns 1 to 10; 30 and 31 toggle DAT_00ed3124 to 1 and 2 and back to 0: the + // header in use draws the picture two after its own + if ((button < 30 && button - 19 == DAT_MissionDefinedData::instance.sortColumn) + || (button == 30 && DAT_00ed3124::instance == 1) || (button == 31 && DAT_00ed3124::instance == 2)) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int const picture + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4 + + 2; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + picture, DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance = picture; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a8569a5ce0..88b9b2a10c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36031,7 +36031,7 @@ SHC_3BB0A8C1_0x004D9700 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9730 | 0.0% | Pending -SHC_3BB0A8C1_0x004D99F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D99F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9B30 | 0.0% | Pending From 9904af358db64476df97285eb85a5eadf1b04b69 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:05 +0100 Subject: [PATCH 06/17] reimplement: SHC_3BB0A8C1_0x00442C30 100.0% Reimplemented Moved from the draft #318 (reimpl/batch2-development 49a51e7ca), 92.6% there. The search for a siege unit now sets a flag and leaves the loop, so its exit jumps past the clearing as the original's does (jg at 0x00442DE3 to 0x00442E64) instead of testing p == end after the loop: quick_diff 0.9753 -> 0.9807. A goto, a flag over the pointer loop and a flag over an index loop all measure the same; the index loop reads best. What is left is quick_diff's own: the security cookie, the timeGetTime import call, ret / ret 0, and the 11 bytes of alignment before the copy loop at 0x00442EA5, which the original's assembler wrote as a jmp over the filler. The style pass replaces the pointer loops with index loops over the 21 counts and returns early for maps that are not sieges. Clean alone build: reccmp 98.9% raw and 100% normalized. The two raw differences are one address, the end of the siege search loops (cmp eax, 0x00B95B1C, one past DAT_SiegeInformationArray), which reccmp resolves to the next global in the original and to our array's end in the DLL; the project records that as 100%. Co-Authored-By: Claude Opus 5.5 --- ...Handler_SingleplayerMapChoice_MapTable.cpp | 144 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp new file mode 100644 index 0000000000..2c6229ca5f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp @@ -0,0 +1,144 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_SiegeInformationArray.hpp" +#include "OpenSHC/Globals/DAT_SiegeRemainingPoints.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00442C30 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_MapTable(int row, ...) + { + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row + >= DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + return; + } + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = row; + DWORD const currentTime = timeGetTime(); + // a second click on the same map within 500 ms starts the game (button 65 of the map choice menu) + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + == DAT_MenuTextInputState::instance.lastClickedListIndex + && (int)(currentTime - DAT_MenuTextInputState::instance.lastListClickTime) < 500) { + DAT_MouseState::instance.waitCursorToggle = 1; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetCursorDependingOnProgramState)(); + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands)(65); + } + if (DAT_MouseState::instance.leftClickStart) { + DAT_MenuTextInputState::instance.lastClickedListIndex + = DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + DAT_MenuTextInputState::instance.lastListClickTime = currentTime; + } + char fileName[1008]; + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset])); + // ".map" + strcat(fileName, S__MAP_005A2294); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + OpenSHC::IO::FRT_MAPS, fileName); + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapHeader, FilePackagerObj::ptr)(TRUE); + // the description's height and scroll position: mode 1 measures the text 413 pixels wide without drawing + INT_00b95b74::instance = 0; + DAT_00b960f4::instance = 0; + if (DAT_GameCore::instance.mapDescUseStringTable == 0) { + INT_00b95b74::instance = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + DAT_GameCore::instance.mapDescription, 0, 0, 413, 0, 0, 1); + } else if (DAT_GameCore::instance.mapDescUseStringTableIndex != 0) { + INT_00b95b74::instance = MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[19])( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.mapDescUseStringTableIndex), + 0, 0, 413, 0, 0, 1); + } + // map type 2 is siege (button 68) + if (DAT_MapMissionType::instance != 2) { + return; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::ClearSiegeInformationArray2)(); + // section 1059 holds the map's siege army + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapHeaderSectionByID, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray, 1059); + // the siege army's 21 unit counts as one array (nested [7][3] searches: quick_diff 0.9807 -> 0.8696) + int* const siegeUnits = &DAT_SiegeInformationArray::instance[0][0]; + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + // an army with no units yet starts empty, with 2000 points + BOOLEnum hasUnits = FALSE; + for (int unit = 0; unit < 21; ++unit) { + if (siegeUnits[unit] > 0) { + hasUnits = TRUE; + break; + } + } + if (!hasUnits) { + for (int unit = 0; unit < 21; ++unit) { + siegeUnits[unit] = 0; + } + DAT_SiegeRemainingPoints::instance = 2000; + } + // advanced mode, player slot 2, difficulty 1 + DAT_SH1_SiegeAdvancedMode::instance = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; + DAT_GameState::instance.mapAndTime.difficulty = 1; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeUnitsComputation)(1); + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)(1); + return; + } + // an army with no units yet gets 70% of the map's own, with no points left + for (int unit = 0; unit < 21; ++unit) { + if (siegeUnits[unit] > 0) { + return; + } + } + // SEC_SiegeInformation (SiegeUnitCounts) is read as 20 ints + int const* const mapUnits = (int const*)&DAT_MapPropertiesState::instance.SEC_SiegeInformation; + for (int unit = 0; unit < 20; ++unit) { + siegeUnits[unit] = mapUnits[unit] * 7 / 10; + } + // slot 10 takes 70% of the tunnelers, over the loop's value + siegeUnits[10] = DAT_MapPropertiesState::instance.SEC_Section1067.tunnelersCount * 7 / 10; + DAT_SiegeRemainingPoints::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeUnitsComputation)(1); + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( + DAT_GameState::instance.mapAndTime.difficulty); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 88b9b2a10c..fec27b1379 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14135,7 +14135,7 @@ SHC_3BB0A8C1_0x00442C2C | 0.0% | Pending SHC_3BB0A8C1_0x00442C2D | 0.0% | Pending -SHC_3BB0A8C1_0x00442C30 | 0.0% | Pending +SHC_3BB0A8C1_0x00442C30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00442E90 | 0.0% | Pending From 463995c20c8291983967d84a0799b4690fac6a3a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:06 +0100 Subject: [PATCH 07/17] reimplement: SHC_3BB0A8C1_0x0047E420 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR #254, closed), 74.1% there. The label is drawn in two calls with the same colour, one per hover state, and the position goes through two locals computed before them: MSVC then merges the two calls but for the text ID's push (the jne at 0x0047E45D). One call is quick_diff 0.8136, the position inside each arm 0.5479, this form 0.9375, which leaves only the colour immediate and ret / ret 0. Co-Authored-By: Claude Opus 5.5 --- ...emRenderFunction_WaitingForHost_Button.cpp | 45 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp diff --git a/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp b/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp new file mode 100644 index 0000000000..10d1fe75fc --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/WaitingForHost/MenuItemRenderFunction_WaitingForHost_Button.cpp @@ -0,0 +1,45 @@ +#include "../WaitingForHost.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047E420 + void WaitingForHost::MenuItemRenderFunction_WaitingForHost_Button(int button, ...) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the label, centred 6 pixels below the button's top + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + // the same colour hovered or not, in two calls (one call: quick_diff 0.9375 -> 0.8136) + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 17, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index fec27b1379..ceb787ea3a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22365,7 +22365,7 @@ SHC_3BB0A8C1_0x0047E3A0 | 0.0% | Pending SHC_3BB0A8C1_0x0047E3E0 | 0.0% | Pending -SHC_3BB0A8C1_0x0047E420 | 0.0% | Pending +SHC_3BB0A8C1_0x0047E420 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047E490 | 100.0% | Reimplemented From 9af1b9a06e2a17f4f19fd6ca30191219fc15c3c1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:06 +0100 Subject: [PATCH 08/17] reimplement: SHC_3BB0A8C1_0x00434120 100.0% Reimplemented Moved from the draft #327 (reimpl/UI-MenuItems-3-development c1c152bf9), 89.9% there. With the header taking no parameters (previous commit) the closing RecordTutorialPlayerAction(1) is a call again rather than a tail call: quick_diff 0.9343 -> 0.9710, left with the jump-table spelling and ret / ret 0. The comments now say what -1000 does, and that the frame-rate formula makes up for only part of the slowdown. Co-Authored-By: Claude Opus 5.5 --- ...ItemActionHandler_InGameMenu_Scrolling.cpp | 85 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp new file mode 100644 index 0000000000..dbb8aa10ef --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp @@ -0,0 +1,85 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/ScrollingHandler.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" + +#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00434120 + void InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling() + { + if (!MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_DEBUG_NUMBERS)) { + // element state -1000 updates the frame rate below without drawing the debug numbers + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::RenderDebugNumbersDisplayElement)(0, 0, -1000); + } + if (DAT_MouseState::instance.selectionBoxMode != 0) { + return; + } + if (DAT_MouseState::instance.rightClickState) { + return; + } + int scrollDistance = MACRO_CALL_MEMBER( + OpenSHC::UI::ScrollingHandler_Func::getScrollDistanceBaseUnk, DAT_ScrollingHandler::ptr)(); + if (scrollDistance == 0) { + return; + } + // below the game speed's frame rate the step grows by speed / ((speed + frame rate) / 2), making up for + // part of the slowdown + if (DAT_CurrentFramerate::instance < DAT_GameCore::instance.gameSpeedLevel + && DAT_CurrentFramerate::instance != 0) { + scrollDistance = DAT_GameCore::instance.gameSpeedLevel * scrollDistance + / ((DAT_GameCore::instance.gameSpeedLevel - DAT_CurrentFramerate::instance) / 2 + + DAT_CurrentFramerate::instance); + } + switch (DAT_ScrollingHandler::instance.scrollDirection_0x4) { + case OpenSHC::UI::SD_UP: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step right + case OpenSHC::UI::SD_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step left + case OpenSHC::UI::SD_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + } + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + // tutorial action 1: the player scrolled the view + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(1); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ceb787ea3a..77ec30ae1c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11115,7 +11115,7 @@ SHC_3BB0A8C1_0x00433D00 | 0.0% | Pending SHC_3BB0A8C1_0x00433DA0 | 0.0% | Pending -SHC_3BB0A8C1_0x00434120 | 0.0% | Pending +SHC_3BB0A8C1_0x00434120 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004341E1 | 0.0% | Pending From 4b5ead50d91ca025e74a3c40d3ea1b13500584ea Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:06 +0100 Subject: [PATCH 09/17] reimplement: SHC_3BB0A8C1_0x00442F40 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR #254, closed), 77.4% there. The cases now come in the original's order, 1, 2/3, 4, 7, 5, 6, as in LobbyMenu_MapSelectScrollbar on main: the original lays the blocks out in that order (case 7's store at 0x00442FDA sits between case 4 and case 5). quick_diff then differs only in its own jump-table spelling and ret / ret 0. The style pass names the parameters as the LobbyMenu scrollbar does and writes - 13 and ++ / --. Co-Authored-By: Claude Opus 5.5 --- ...andler_SingleplayerMapChoice_Scrollbar.cpp | 67 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp new file mode 100644 index 0000000000..db2d21ed8c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_Scrollbar.cpp @@ -0,0 +1,67 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00442F40 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_Scrollbar( + int unused, int scrollbarEvent, int* minValue, int* maxValue, int* currentValue) + { + switch (scrollbarEvent) { + case 1: + // the list shows 13 rows + *minValue = 0; + *maxValue = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13; + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + case 2: + case 3: + // unlike 5 and 6, the selected row is chosen again before the offset changes + if (*currentValue != DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = *currentValue; + return; + case 4: + if (*currentValue != DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + *maxValue = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13; + return; + case 7: + // a click on the track pages by 12 of the 13 rows + *currentValue = 12; + return; + case 5: + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset > 0) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + case 6: + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + *currentValue = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 77ec30ae1c..64592e5904 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14141,7 +14141,7 @@ SHC_3BB0A8C1_0x00442E90 | 0.0% | Pending SHC_3BB0A8C1_0x00442EB0 | 0.0% | Pending -SHC_3BB0A8C1_0x00442F40 | 0.0% | Pending +SHC_3BB0A8C1_0x00442F40 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00443048 | 0.0% | Pending From 26e26d41221ed6972a184a1146c30fc709a96f46 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:32:06 +0100 Subject: [PATCH 10/17] reimplement: SHC_3BB0A8C1_0x0047CCA0 100.0% Reimplemented From gynt's reimpl/UI-MenuItems (PR #254, closed), 73.6% there, after main's renames (isNameEntryActive). Each case now computes the text's position, fetches the text and draws it itself: MSVC merges the copies of cases 0 to 3 into one tail but for the push of the text's index, as the original has push 5 / push 6 / push 7 / push 0 before its shared tail at 0x0047CDE7; case 4 keeps its own call and the surface reset. With one call after the switch the index goes through a register (quick_diff 0.9365); this form is 0.9664, which leaves the jump-table spelling, the colour immediates and ret / ret 0. The cursor's bottom is written DAT_ButtonY + DAT_ButtonH - 4, the order of the original's lea (0.9030 -> 0.9365 by itself). == TRUE stays: the original compares with 1, and a truthiness test is 0.9365. Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_General_TextInputDisplay.cpp | 126 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp new file mode 100644 index 0000000000..2b762e5409 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_TextInputDisplay.cpp @@ -0,0 +1,126 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0047CCA0 + void General::MenuItemRenderFunction_General_TextInputDisplay(int field, ...) + { + // == TRUE: the original compares with 1 (a truthiness test: quick_diff 0.9664 -> 0.9365); field 3, the + // title box, is hidden while a title is set + if (field == 3 && DAT_GameCore::instance.isNameEntryActive == TRUE) { + return; + } + int const cursorX = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // the cursor at the typing position, then the text 6 pixels in from the corner + // the text in each case, merged but for the index (one call after the switch: quick_diff 0.9664 -> 0.9365) + switch (field) { + case 0: { + // fields 0 and 1 show the cursor only while their text is the one being typed + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_FIVE__NUMERIC_DOT); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 1: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 2: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_SEVEN__NUMERIC_ONLY); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 3: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + break; + } + case 4: { + // outside the main menu this field is drawn on the map's surface + if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_MAIN_MENU) { + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 3, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_ZERO); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + DAT_PencilRenderCore::instance.surfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + break; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 64592e5904..56e1579739 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -22281,7 +22281,7 @@ SHC_3BB0A8C1_0x0047CC8C | 0.0% | Pending SHC_3BB0A8C1_0x0047CC90 | 0.0% | Pending -SHC_3BB0A8C1_0x0047CCA0 | 0.0% | Pending +SHC_3BB0A8C1_0x0047CCA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0047CEC4 | 0.0% | Pending From 0bc6102e8c6dbba33558a27ac5b1c33bad8135ff Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:07 +0100 Subject: [PATCH 11/17] headers: DAT_SH1_SiegeAdvancedMode is a BOOLEnum It was undefined4. Every store is 0 or 1: the toggle xor [0x00B960C8], 1 at 0x0042D81F, 0 at 0x0042D855 (edx, 0 in that handler) and 0x00448DC2 (ebx), 1 at 0x00442E66; the decompilation agrees (SingleplayerMapChoice's MapTable stores 1, ButtonsAndHands toggles it and stores 0, SingleplayerMapChoice_Prepare stores 0), and every read compares with 0 (spawnQueuedReinforcementWaves, LaunchSinglePlayerGameUnk). A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. Its one user in the code, this PR's MenuItemActionHandler_SingleplayerMapChoice_MapTable (0x00442C30), stores 1 and compiles the same (quick_diff 0.9807 before and after); main has none. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp b/src/OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp index 8bf0e83d87..0e9c78a802 100644 --- a/src/OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp +++ b/src/OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00B960C8 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B960C8) DAT_SH1_SiegeAdvancedMode; +using OpenSHC::WindowsHelper::Enums::BOOLEnum; + +MACRO_STRUCT_RESOLVER(BOOLEnum, false, Address::SHC_3BB0A8C1_0x00B960C8) DAT_SH1_SiegeAdvancedMode; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B960C8); From d4c1b5e6ba13364db91a7a796c38091793cc2948 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:07 +0100 Subject: [PATCH 12/17] headers: DAT_StoredGameMode is a GameModeInt It was undefined4. Its one store, at 0x004D972A (MenuView_RankingGames_Prepare), copies GameSynchronyState.currentGameMode (0x0191DD80, a GameModeInt), and its one read, in MenuItemActionHandler_RankingGames_Main, copies it back. Both are on main and compile the same; the copy no longer converts between unsigned and int. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_StoredGameMode.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_StoredGameMode.hpp b/src/OpenSHC/Globals/DAT_StoredGameMode.hpp index f5103830b2..abfe107546 100644 --- a/src/OpenSHC/Globals/DAT_StoredGameMode.hpp +++ b/src/OpenSHC/Globals/DAT_StoredGameMode.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/Game/GameModeInt.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00EB9B58 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00EB9B58) DAT_StoredGameMode; +using OpenSHC::Game::GameModeInt; + +MACRO_STRUCT_RESOLVER(GameModeInt, false, Address::SHC_3BB0A8C1_0x00EB9B58) DAT_StoredGameMode; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EB9B58); From 18f83c2699a43a0d1f50b2bfb5cf801186077663 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:07 +0100 Subject: [PATCH 13/17] headers: DAT_SkirmishTrailRelated1 is an int It was undefined4. It is a count that can go below 0: MenuView_CrusadeMap_Prepare (0x004D8CB0) stores 3 (0x004D8D48), decrements it once per mission skipped with the chicken and stores the result (0x004D8DD5), then clamps it at 0 with a signed test (cmp edx, edi / jge at 0x004D8DDB); 0x004D8F3B subtracts from it in memory. Main's user, MenuItemRenderFunction_General_CrusadeMapAndEndscreen, tests it with a signed > 0 through an (int) cast, which the next commit drops; it compiles the same. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp b/src/OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp index 0e91c059e4..ad72b101c5 100644 --- a/src/OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp +++ b/src/OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00ED27C0 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED27C0) DAT_SkirmishTrailRelated1; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00ED27C0) DAT_SkirmishTrailRelated1; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED27C0); From b78dc7ce6ffffcf63d5f9f7ebf41b7765505b1a6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:07 +0100 Subject: [PATCH 14/17] headers: MissionDefinedData.descending is a BOOLEnum It was undefined4. MenuItemActionHandler_RankingGames_Main (0x004D9730) is its only writer: it stores 1 at 0x004D995F when a new column is picked and 1 - descending at 0x004D9970 / 0x004D9976 when the same column is picked again, so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Game/MissionDefinedData.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/Game/MissionDefinedData.hpp b/src/OpenSHC/Game/MissionDefinedData.hpp index a54ff9d3dc..06c39857be 100644 --- a/src/OpenSHC/Game/MissionDefinedData.hpp +++ b/src/OpenSHC/Game/MissionDefinedData.hpp @@ -9,11 +9,13 @@ #pragma once #include "OpenSHC/Game/CampaignInfoStruct1.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" namespace OpenSHC { namespace Game { using OpenSHC::Game::CampaignInfoStruct1; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; #pragma pack(push, 1) // SIZE: 0x000016C4 @@ -53,7 +55,7 @@ namespace Game { int SkirmishTrailIconOffsets[50]; // 0x00000F2C length: 200 int SkirmishTrailMissionRenderData[50][4]; // 0x00000FF4 length: 800 int field37_0x1314[22]; // 0x00001314 length: 88 - undefined4 descending; // 0x0000136C length: 4 + BOOLEnum descending; // 0x0000136C length: 4 int field39_0x1370; // 0x00001370 length: 4 undefined1 padding_0x1374[8]; // 0x00001374 length: 8 int HistoryBookEdgeSpriteIDs[50]; // 0x0000137C length: 200 From 67b91e0c19f787599ee3b726e8d5158dddf3516f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:07 +0100 Subject: [PATCH 15/17] headers: TileMapState.wallDragButtonUp is a BOOLEnum It was undefined4. Its only store, in MenuItemActionHandler_InGameMenu_TriggerPlaceWallCommand at 0x0043803E, writes the result of a sete (0x00438034), so it only holds 0 and 1. A linear sweep of the exe's code finds every absolute reference; reads and writes through a pointer to the struct are not covered by that, and the decompilation shows none. The handler is on main and compiles the same. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/TileMapState.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/TileMapState.hpp b/src/OpenSHC/Map/TileMapState.hpp index 80bedcbab0..1169b1ff1b 100644 --- a/src/OpenSHC/Map/TileMapState.hpp +++ b/src/OpenSHC/Map/TileMapState.hpp @@ -165,7 +165,7 @@ namespace Map { undefined4 buildingPlacementProperty_6; // 0x00554974 length: 4 undefined4 buildingPlacementProperty_7; // 0x00554978 length: 4 undefined1 padding_0x55497c[4]; // 0x0055497C length: 4 - undefined4 wallDragButtonUp; // 0x00554980 length: 4 + BOOLEnum wallDragButtonUp; // 0x00554980 length: 4 int constructionTileCount; // 0x00554984 length: 4 int DAT_WallTileCountCurrentDrag; // 0x00554988 length: 4 undefined4 buildingX; // 0x0055498C length: 4 From df6428eda4b8a0607fd550bc6036170723a9d6eb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:08 +0100 Subject: [PATCH 16/17] CrusadeMapAndEndscreen: drop the (int) cast DAT_SkirmishTrailRelated1 no longer needs DAT_SkirmishTrailRelated1 is an int since the commit before this one, so the signed > 0 test needs no cast. It compiles the same. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp index e255516201..a298a7327b 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CrusadeMapAndEndscreen.cpp @@ -40,7 +40,7 @@ namespace UI { int const textY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 583; int const textX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400; // one call per caption, merged but for the index (an index local: quick_diff 0.9464 -> 0.8468) - if ((int)DAT_SkirmishTrailRelated1::instance > 0) { + if (DAT_SkirmishTrailRelated1::instance > 0) { // "Skip Current Mission" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, From 9b3d5a01a350a90eb33acbb66b18aff35e5b858f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:26:25 +0100 Subject: [PATCH 17/17] SingleplayerMapChoice_MapTable: store TRUE in DAT_SH1_SiegeAdvancedMode The global is a BOOLEnum since the header commit before this one. Same code (quick_diff 0.9807 before and after). Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp index 2c6229ca5f..659be5a7df 100644 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTable.cpp @@ -113,7 +113,7 @@ namespace UI { DAT_SiegeRemainingPoints::instance = 2000; } // advanced mode, player slot 2, difficulty 1 - DAT_SH1_SiegeAdvancedMode::instance = 1; + DAT_SH1_SiegeAdvancedMode::instance = TRUE; DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; DAT_GameState::instance.mapAndTime.difficulty = 1; MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeUnitsComputation)(1);