From 7d987aef591a5f6ed54133bec5a0c2c69bc013ae Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:45:22 +0100 Subject: [PATCH 1/7] headers: declare Helpers::InitTutorialState (0x004BC6F0) 0x004BC6F0 is in the address list as a function but no header declares it, so its one caller, the main menu's tutorial button (MenuItemActionHandler_MainMenu_Main, 0x004251A0, tail jump at 0x00425458), could only inline it. It reads no arguments and ends in a tail jump to ResetTutorialActionTrackers (0x004BC6C0), so it is void __cdecl(): it calls InitTutorialStepTransition(1), resets the tutorial state at 0xDF554C-0xDF5564 and 0xDF556C and fills INT_ARRAY_00df5598 with each step's start. It sits among the other tutorial helpers in UI/Helpers, so it goes there, after ResetTutorialActionTrackers. The name is a proposal: Ghidra has none. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Helpers.func.hpp | 4 ++++ src/OpenSHC/UI/Helpers.hpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/OpenSHC/UI/Helpers.func.hpp b/src/OpenSHC/UI/Helpers.func.hpp index 2259bf26f0..bd983d4c20 100644 --- a/src/OpenSHC/UI/Helpers.func.hpp +++ b/src/OpenSHC/UI/Helpers.func.hpp @@ -194,6 +194,10 @@ namespace UI { &OpenSHC::UI::Helpers::ResetTutorialActionTrackers) ResetTutorialActionTrackers; + MACRO_FUNCTION_RESOLVER( + void(__cdecl*)(), false, Address::SHC_3BB0A8C1_0x004BC6F0, &OpenSHC::UI::Helpers::InitTutorialState) + InitTutorialState; + MACRO_FUNCTION_RESOLVER(void(__cdecl*)(), false, Address::SHC_3BB0A8C1_0x004BC770, &OpenSHC::UI::Helpers::SetTutorialHintActiveWithTimestamp) SetTutorialHintActiveWithTimestamp; diff --git a/src/OpenSHC/UI/Helpers.hpp b/src/OpenSHC/UI/Helpers.hpp index 65d6a1f2e4..e881488cff 100644 --- a/src/OpenSHC/UI/Helpers.hpp +++ b/src/OpenSHC/UI/Helpers.hpp @@ -109,6 +109,8 @@ namespace UI { void __cdecl ResetTutorialActionTrackers(); + void __cdecl InitTutorialState(); + void __cdecl SetTutorialHintActiveWithTimestamp(); void __cdecl UpdateTutorialStepAndProgress(); From 244b909cb91378772548825f294aa0b6940aed7e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:45:28 +0100 Subject: [PATCH 2/7] reimplement: SHC_3BB0A8C1_0x004BC6F0 100.0% Reimplemented InitTutorialState starts the tutorial's step tracking: InitTutorialStepTransition(1), the first step's action count into DAT_00df555c, the restriction flag and current step cleared, the fixed values 32 and 36, and for each of the 32 steps where it starts in INT_ARRAY_00df5598, two past the previous start plus the previous step's action count, then ResetTutorialActionTrackers. Needs the header commit that declares it. Written from the original's instructions; gynt's draft of the main menu's handler (c9bfdf1f3, 8725ec523 on his fork) had the same body inlined there, which is where the reads come from. The form the original needs: the running start incremented before its store and the step's count added after it (the store as start + 1 and the step as + 2: quick_diff 0.4091, a different register for the zero). Also: countof for the 32 steps. quick_diff leaves only the tail call's form. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Helpers/InitTutorialState.cpp | 41 ++++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/Helpers/InitTutorialState.cpp diff --git a/src/OpenSHC/UI/Helpers/InitTutorialState.cpp b/src/OpenSHC/UI/Helpers/InitTutorialState.cpp new file mode 100644 index 0000000000..1adfaf3426 --- /dev/null +++ b/src/OpenSHC/UI/Helpers/InitTutorialState.cpp @@ -0,0 +1,41 @@ +#include "../Helpers.func.hpp" + +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df555c.hpp" +#include "OpenSHC/Globals/DAT_00df5560.hpp" +#include "OpenSHC/Globals/DAT_00df556c.hpp" +#include "OpenSHC/Globals/DAT_DisableTutorialRestrictions.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" +#include "OpenSHC/Globals/INT_00df5554.hpp" +#include "OpenSHC/Globals/INT_00df5564.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00df5598.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BC6F0 + void Helpers::InitTutorialState() + { + // The main menu's tutorial button calls this once the tutorial map is loaded + MACRO_CALL(OpenSHC::UI::Helpers_Func::InitTutorialStepTransition)(1); + DAT_00df555c::instance = DAT_MissionAestheticsDefinedData::instance.TutorialStepActionCount[0]; + DAT_DisableTutorialRestrictions::instance = FALSE; + DAT_TutorialCurrentStep::instance = 0; + INT_00df5554::instance = 32; + DAT_00df5558::instance = 0; + DAT_00df5560::instance = 0; + INT_00df5564::instance = 0; + DAT_00df556c::instance = 36; + // Where each step starts: two past the previous start, plus the previous step's action count + int start = 1; + for (int step = 0; step < countof(INT_ARRAY_00df5598::instance); ++step) { + ++start; + INT_ARRAY_00df5598::instance[step] = start; + start += DAT_MissionAestheticsDefinedData::instance.TutorialStepActionCount[step] + 1; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetTutorialActionTrackers)(); + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ed989c9a21..ecb5fb7510 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30093,7 +30093,7 @@ SHC_3BB0A8C1_0x004BC690 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC6C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BC6F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BC6F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC770 | 100.0% | Reimplemented From 01f9583f2526a545a70847dc7f427f5f3d8aa29d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:48:15 +0100 Subject: [PATCH 3/7] reimplement: SHC_3BB0A8C1_0x004251A0 100.0% Reimplemented MenuItemActionHandler_MainMenu_Main handles the main menu's buttons: 1 the historical campaigns, 2 the crusades, 3 the castle builder, 4 multiplayer (only once DirectDraw is loaded), 5 quit, 6 the tutorial, 7 the credits, 8 the options, 9 the custom scenarios. From gynt's draft (c9bfdf1f3 on his fork's reimpl/UI-MenuItems-development, 67.12% there; his batch pass 8725ec523 left its status line at 71.7%). Needs the header commit that declares InitTutorialState: the tutorial button ends in a tail call to it, where the draft had its body inlined. The form the original needs: the menu switch and the player colour reset written out in both case 3 and case 4, each returning, so that MSVC jumps from case 3 into case 4's copy as the original does (one copy after the switch on a view variable: quick_diff 0.7756, with ebx zeroed before the dispatch). Also: the colour reset as a countof loop (MSVC unrolls it into the original's nine copies), s_Crusader_tutorial_map_005a1ff8 for the string macro, DD7_LOADED for 1792 without the cast, INT_00b95954, button for param_1, no unused usings or includes. quick_diff leaves the jump table's symbol, ret / ret 0 and the tail call's form. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_MainMenu_Main.cpp | 169 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp new file mode 100644 index 0000000000..f30b381a83 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp @@ -0,0 +1,169 @@ +#include "../MainMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/Enums/DirectDrawStatus.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/INT_00b95954.hpp" +#include "OpenSHC/Globals/INT_00b95b64.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004251A0 + void MainMenu::MenuItemActionHandler_MainMenu_Main(int button, ...) + { + switch (button) { + case 1: + // historical campaigns + DAT_GameCore::instance.gameSuspended = 0; + DAT_GameState::instance.mapAndTime.difficulty = DAT_GameCore::instance.missionDifficulty; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_CAMPAIGN_SELECT, 0); + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + return; + case 2: + // crusader + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SELECT_CRUSADE, 0); + return; + case 3: + // castle builder (the tail is written out in case 4 too: MSVC jumps from here into that copy) + DAT_GameCore::instance.missionNumber1to20 = 0; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_BUILDERUnk; + DAT_GameCore::instance.xbowProducible_logic = 1; + DAT_GameCore::instance.pikeProducible_logic = 1; + DAT_GameCore::instance.swordProducible_logic = 1; + DAT_GameCore::instance.bowProducible_logic = 1; + DAT_GameCore::instance.spearProducible_logic = 1; + DAT_GameCore::instance.maceProducible_logic = 1; + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::resetTeams, DAT_GameState::ptr)(); + DAT_MapMissionType::instance = 0; + INT_00b95b64::instance = 1; + DAT_GameCore::instance.standaloneFilename[0] = '\0'; + DAT_GameState::instance.mapAndTime.difficulty = DAT_GameCore::instance.missionDifficulty_0; + DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE, 0); + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + return; + case 4: + // multiplayer + if (DAT_GameCore::instance.directDrawStatus < OpenSHC::Rendering::Enums::DD7_LOADED) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::clearEntry, DAT_UserTextHandlerState::ptr)(5); + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::clearEntry, DAT_UserTextHandlerState::ptr)(6); + DAT_GameSynchronyState::instance.nextModalDialog + = OpenSHC::UI::Enums::MMT_CHOOSE_NETWORK_SERVICE_PROVIDER; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + DAT_GameSynchronyState::instance.ipArrayIndex = 0; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER; + DAT_GameCore::instance.xbowProducible_logic = 1; + DAT_GameCore::instance.pikeProducible_logic = 1; + DAT_GameCore::instance.swordProducible_logic = 1; + DAT_GameCore::instance.bowProducible_logic = 1; + DAT_GameCore::instance.spearProducible_logic = 1; + DAT_GameCore::instance.maceProducible_logic = 1; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MP_CONNECTION, 0); + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + return; + case 9: + // custom scenarios + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_EDITOR; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + return; + case 6: + // tutorial + DAT_GameCore::instance.missionNumber1to20 = 30; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_CRUSADER_TUTORIAL; + DAT_GameCore::instance.xbowProducible_logic = 0; + DAT_GameCore::instance.pikeProducible_logic = 0; + DAT_GameCore::instance.swordProducible_logic = 0; + DAT_GameCore::instance.bowProducible_logic = 0; + DAT_GameCore::instance.spearProducible_logic = 0; + DAT_GameCore::instance.maceProducible_logic = 0; + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::resetTeams, DAT_GameState::ptr)(); + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::loadMap, DAT_MapPropertiesState::ptr)( + // "Crusader_tutorial.map" + (char*)s_Crusader_tutorial_map_005a1ff8); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = OpenSHC::UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearModalDialog2to6, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_TUTORIAL_BOX, FALSE); + MACRO_CALL(OpenSHC::UI::Helpers_Func::InitTutorialState)(); + return; + case 8: + // options + DAT_GameSynchronyState::instance.currentPlayerSlotID = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_MAIN_MENU_OPTIONS); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x101); + return; + case 5: + // quit + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 9; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, DAT_BinkControlState::ptr)(0); + return; + case 7: + // credits + INT_00b95954::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CREDITS, 0); + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ecb5fb7510..f96da66bab 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6687,7 +6687,7 @@ SHC_3BB0A8C1_0x00424DA0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00424F50 | 0.0% | Pending -SHC_3BB0A8C1_0x004251A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004251A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004254D0 | 0.0% | Pending From f8a5ed43a51c49e3b1118484da1a82b285e4ab12 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:48:16 +0100 Subject: [PATCH 4/7] reimplement: SHC_3BB0A8C1_0x00449290 100.0% Reimplemented MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader sorts the map list when a column header is clicked: 0 copies the order kept in DAT_ArrayOfMapIndices2, backwards after the first click (fileListSortOrder 0 / 1), 1 bubble sorts by the file times (2 / 3), 2 by arrayOfMapEndInt2 (lobbyMapSortOrder 5 / 6); then the map table is refreshed and lastClickedListIndex cleared. Written from the original's instructions, with gynt's draft (755f04034 on his fork's reimpl/UI-MenuItems, 64.54% there; then his batch pass 8725ec523) for the reads. No header change: main's arrayOfMapEndInt2[500] at 0xB0 is the array the draft indexed through DAT_ArrayOfMapU3EndInt2, and DAT_ArrayOfMapIndices2 is read with - 1, as its three other users on main do. The forms the original needs: the next entry read before the current one in the sort loops (the other order swaps eax and ecx: quick_diff 0.8151 -> 0.9358), and the forward copy as a guarded do-while (as a for loop MSVC makes it rep movsd). Also: no decompiler locals, the sort passes as for loops on the swap count, column for param_1. quick_diff leaves ret / ret 0 and the jumps over the loops' alignment padding, which their npad hides. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...r_SingleplayerMapChoice_MapTableHeader.cpp | 122 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp new file mode 100644 index 0000000000..30ec8b490d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp @@ -0,0 +1,122 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00449290 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader(int column, ...) + { + // A click on a column header sorts the map list by that column, and a second click reverses the order + switch (column) { + case 0: { + // Name: the order kept in DAT_ArrayOfMapIndices2 (read with - 1, as its other users do), backwards + // after the first click + if (DAT_MenuTextInputState::instance.fileListSortOrder == 0) { + for (int i = 0; i < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; ++i) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices2[DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber + - 2 - i]; + } + DAT_MenuTextInputState::instance.fileListSortOrder = 1; + break; + } + int i = 0; + if (i < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + // A guarded do-while: as a for loop MSVC turns the copy into rep movsd + do { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices2[i - 1]; + ++i; + } while (i < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber); + } + DAT_MenuTextInputState::instance.fileListSortOrder = 0; + break; + } + case 1: { + // Date: a bubble sort on the file times, newest first after the first click + int const last = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_MenuTextInputState::instance.fileListSortOrder == 2) { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < last; ++i) { + int const nextMapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + int const mapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + if (DAT_ResourceManager::instance.mapFileTimes[mapIndex] + > DAT_ResourceManager::instance.mapFileTimes[nextMapIndex]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = nextMapIndex; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = mapIndex; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 3; + break; + } + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < last; ++i) { + int const nextMapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + int const mapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + if (DAT_ResourceManager::instance.mapFileTimes[mapIndex] + < DAT_ResourceManager::instance.mapFileTimes[nextMapIndex]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = nextMapIndex; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = mapIndex; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 2; + break; + } + case 2: { + // The third column: a bubble sort on arrayOfMapEndInt2, with its own order flag + int const last = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 5) { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < last; ++i) { + int const nextMapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + int const mapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + if (DAT_MenuTextInputState::instance.arrayOfMapEndInt2[mapIndex] + < DAT_MenuTextInputState::instance.arrayOfMapEndInt2[nextMapIndex]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = nextMapIndex; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = mapIndex; + ++swaps; + } + } + } + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 6; + break; + } + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < last; ++i) { + int const nextMapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + int const mapIndex = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + if (DAT_MenuTextInputState::instance.arrayOfMapEndInt2[mapIndex] + > DAT_MenuTextInputState::instance.arrayOfMapEndInt2[nextMapIndex]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = nextMapIndex; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = mapIndex; + ++swaps; + } + } + } + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; + break; + } + } + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + DAT_MenuTextInputState::instance.lastClickedListIndex = -1; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f96da66bab..423576220e 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16391,7 +16391,7 @@ SHC_3BB0A8C1_0x0044927C | 0.0% | Pending SHC_3BB0A8C1_0x00449280 | 0.0% | Pending -SHC_3BB0A8C1_0x00449290 | 0.0% | Pending +SHC_3BB0A8C1_0x00449290 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004492E0 | 0.0% | Pending From fa05971a4d870b76aefad30a94fb1adffc2ecc36 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:53:18 +0100 Subject: [PATCH 5/7] reimplement: SHC_3BB0A8C1_0x0042AC90 100.0% Reimplemented LobbyMenu::MenuItemRenderFunction_LobbyMenu_ChatBox, from gynt's draft (557a0e2dc, 54.49%, on his fork's reimpl/UI-MenuItems; 53.8% in 8725ec523 on reimpl/UI-MenuItems-development), rewritten from the binary. Button -3 draws the chat messages, -2 the line being typed with its cursor, -1 the player's own name and the others the waiting room's texts. The branches are nested in the original's block order (early returns for -3 and -2 measure lower), and the waiting room's text comes before the -1 name, as the original lays them out. The y position is written in both calls, so MSVC shares their pushes as the original does, and the -2 branch reads the blend strength again after its calls. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_LobbyMenu_ChatBox.cpp | 103 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp new file mode 100644 index 0000000000..c6ac570aa6 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp @@ -0,0 +1,103 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042AC90 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_ChatBox(int buttonID, ...) + { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE + && DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_SEND_MAP_TO + && DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_RECEIVE_MAP_FROM + && MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + int const blend = DAT_ButtonBackgroundBlendStrength::instance - 32; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // nested in the original's block order (early returns for -3 and -2 measure lower) + if (buttonID != -3) { + if (buttonID != -2) { + // the waiting room's texts, and for -1 the player's own name + if (buttonID != -1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, buttonID, + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE, + blend * 32 / 32 + 32); + return; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance + .DAT_PlayerNames[DAT_GameSynchronyState::instance.currentPlayerSlotID], + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_00A2FF, OpenSHC::Rendering::Colors::COL_003E66, 17, FALSE, + blend * 32 / 32 + 32); + return; + } + // -2: the line being typed, with the cursor behind it + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance + 2, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance - 2, + blend * 16 / 32 + 32); + int const cursorX + = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, + DAT_UserTextHandlerState::ptr)(); + if (DAT_00b960dc::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 6 + cursorX, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonH::instance + DAT_ButtonY::instance - 2, + COL_DARK_LIME::instance.shortValue); + } + // the blend strength is read again after the calls, as the original does + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, + DAT_TextManagerObject::ptr)(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getCurrentText, + DAT_UserTextHandlerState::ptr)(), + DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_FFFFFF, OpenSHC::Rendering::Colors::COL_000000, 19, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // -3: the chat messages + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + blend * 16 / 32 + 32); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::renderChatMessageList, + DAT_GameSynchronyState::ptr)(DAT_ButtonX::instance + 8, + DAT_ButtonH::instance + DAT_ButtonY::instance - 31, DAT_GameSynchronyState::instance.chatScrollOffset); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 423576220e..81df443748 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6979,7 +6979,7 @@ SHC_3BB0A8C1_0x0042AC60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042AC70 | 0.0% | Pending -SHC_3BB0A8C1_0x0042AC90 | 0.0% | Pending +SHC_3BB0A8C1_0x0042AC90 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042AE90 | 0.0% | Pending From 13ac790958d758847ed8d8459c46800a1e0d2396 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 22:53:18 +0100 Subject: [PATCH 6/7] reimplement: SHC_3BB0A8C1_0x0042B4C0 100.0% Reimplemented LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectTable, from gynt's draft (5467a25fa, 56.44%, on his fork's reimpl/UI-MenuItems-development), rewritten from the binary. The draft drew the map's name twice when the second icon shows; the original draws it once, beside that icon (150 wide) or 20 pixels further left (170 wide), both less the first icon's 20 when it shows (iconsWidth). The file name is fetched into a local before the text call, as the original's call order has it (as an argument, &descriptionGroup is pushed first), and DAT_ButtonUnknownZero is set from a flag for the round table and the two AI lord selects (a guest stores TRUE, then FALSE), which gives the original's shared store. reccmp 100.0%. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_LobbyMenu_MapSelectTable.cpp | 148 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp new file mode 100644 index 0000000000..53b00d568c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp @@ -0,0 +1,148 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Global.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042B4C0 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectTable(int row, ...) + { + if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + // set for the host while the round table or an AI lord select is open; a guest stores TRUE, then FALSE + bool const aiSetupOpen + = DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT; + if (aiSetupOpen) { + DAT_ButtonUnknownZero::instance = TRUE; + } + if (!aiSetupOpen || !DAT_GameSynchronyState::instance.isHost) { + DAT_ButtonUnknownZero::instance = FALSE; + } + // for a guest, -1 marks another map than the host's and 1 the host's map + int hostMap = 0; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (!DAT_GameSynchronyState::instance.isHost) { + hostMap = -1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber + && MACRO_CALL(OpenSHC::OS_Func::__stricmp)( + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + row]), + DAT_GameSynchronyState::instance.mapName) + == 0) { + hostMap = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(TRUE, row, DAT_ButtonBackgroundBlendStrength::instance); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, row, DAT_ButtonBackgroundBlendStrength::instance); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(row == DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected, + row, DAT_ButtonBackgroundBlendStrength::instance); + } + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row + >= DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + return; + } + int iconsWidth = 0; + uint color; + if (DAT_GameSynchronyState::instance.unknownMapRelatedReceivedDataArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]] + <= 0) { + color = OpenSHC::Rendering::Colors::COL_7F7F7F; + } else if ((row == DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + || DAT_ButtonCurrentlyInteracting::instance || hostMap == 1) + && hostMap >= 0) { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } else { + color = OpenSHC::Rendering::Colors::COL_C2F0EB; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]], + DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + if (DAT_GameSynchronyState::instance.mapBalanceArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]] + != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 210, + DAT_ButtonX::instance + 24, DAT_ButtonY::instance + 5, DAT_ButtonBackgroundBlendStrength::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + iconsWidth = 20; + } + int descriptionGroup; + if (DAT_GameSynchronyState::instance.mapU4Int0_2Array[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]] + != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 394, + DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 5, + DAT_ButtonBackgroundBlendStrength::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // the file name first: as an argument, &descriptionGroup would be pushed before the call + char* const fileName = MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, DAT_ResourceManager::ptr)( + DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]); + char* const name + = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(fileName, &descriptionGroup); + DAT_TextManagerObject::instance.field_0x30 = 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + name, DAT_ButtonX::instance + 44 + iconsWidth, DAT_ButtonY::instance + 3, 150 - iconsWidth, color, + 18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + char* const fileName + = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]); + char* const name + = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(fileName, &descriptionGroup); + DAT_TextManagerObject::instance.field_0x30 = 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + name, DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 3, 170 - iconsWidth, color, 18, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 81df443748..ca2a50b016 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7419,7 +7419,7 @@ SHC_3BB0A8C1_0x0042B460 | 0.0% | Pending SHC_3BB0A8C1_0x0042B470 | 0.0% | Pending -SHC_3BB0A8C1_0x0042B4C0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042B4C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042B7B0 | 100.0% | Reimplemented From 00e12363198c246df10b561471a81c292231aece Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 10 Nov 2026 00:32:37 +0100 Subject: [PATCH 7/7] UI round: measured comments, a BOOLEnum flag, names after main's siblings - LobbyMenu MapSelectTable: the AI-setup flag is a BOOLEnum, and the file and map names are loadedName and mapName, as main's SingleplayerMapChoice_MapTable names them. The three kept shapes give their measurements: no flag 0.9607, descriptionGroup at each call 0.9649, the file name as an argument 0.9518 (against 0.9781). - LobbyMenu ChatBox: the nesting (early returns 0.6184) and the blend strength read again (the blend local 0.8803, against 0.9671) in main's one-line form. - SingleplayerMapChoice MapTableHeader: the do-while gives its measurement (a for or a while loop: 0.9283, against 0.9738), and the name sort's comment no longer explains the - 1. - MainMenu: the shared tail's comment in main's form (one copy after the switch: 0.7756, against 0.9500). quick_diff output is identical for all four files. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_LobbyMenu_ChatBox.cpp | 4 +-- ...enderFunction_LobbyMenu_MapSelectTable.cpp | 27 ++++++++++--------- .../MenuItemActionHandler_MainMenu_Main.cpp | 2 +- ...r_SingleplayerMapChoice_MapTableHeader.cpp | 5 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp index c6ac570aa6..a27aa59c92 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_ChatBox.cpp @@ -44,7 +44,7 @@ namespace UI { } int const blend = DAT_ButtonBackgroundBlendStrength::instance - 32; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - // nested in the original's block order (early returns for -3 and -2 measure lower) + // Nested, not early returns (early returns: quick_diff 0.9671 -> 0.6184) if (buttonID != -3) { if (buttonID != -2) { // the waiting room's texts, and for -1 the player's own name @@ -79,7 +79,7 @@ namespace UI { DAT_ButtonX::instance + 7 + cursorX, DAT_ButtonH::instance + DAT_ButtonY::instance - 2, COL_DARK_LIME::instance.shortValue); } - // the blend strength is read again after the calls, as the original does + // the blend strength read again after the calls (the blend local: quick_diff 0.9671 -> 0.8803) MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getCurrentText, DAT_UserTextHandlerState::ptr)(), diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp index 53b00d568c..f3200233fd 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectTable.cpp @@ -36,8 +36,8 @@ namespace UI { if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { return; } - // set for the host while the round table or an AI lord select is open; a guest stores TRUE, then FALSE - bool const aiSetupOpen + // TRUE for the host while an AI setup dialog is open (no flag: quick_diff 0.9781 -> 0.9607) + BOOLEnum const aiSetupOpen = DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE || DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT @@ -108,6 +108,7 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; iconsWidth = 20; } + // declared once for both calls (at each call: quick_diff 0.9781 -> 0.9649) int descriptionGroup; if (DAT_GameSynchronyState::instance.mapU4Int0_2Array[DAT_MenuTextInputState::instance .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]] @@ -118,29 +119,29 @@ namespace UI { DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 5, DAT_ButtonBackgroundBlendStrength::instance); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - // the file name first: as an argument, &descriptionGroup would be pushed before the call - char* const fileName = MACRO_CALL_MEMBER( + // The file name in a local (as an argument: quick_diff 0.9781 -> 0.9518) + char* const loadedName = MACRO_CALL_MEMBER( OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, DAT_ResourceManager::ptr)( DAT_MenuTextInputState::instance .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]); - char* const name - = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(fileName, &descriptionGroup); + char* const mapName + = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(loadedName, &descriptionGroup); DAT_TextManagerObject::instance.field_0x30 = 1; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( - name, DAT_ButtonX::instance + 44 + iconsWidth, DAT_ButtonY::instance + 3, 150 - iconsWidth, color, - 18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + mapName, DAT_ButtonX::instance + 44 + iconsWidth, DAT_ButtonY::instance + 3, 150 - iconsWidth, + color, 18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); return; } - char* const fileName + char* const loadedName = MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + row]); - char* const name - = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(fileName, &descriptionGroup); + char* const mapName + = MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)(loadedName, &descriptionGroup); DAT_TextManagerObject::instance.field_0x30 = 1; MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( - name, DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 3, 170 - iconsWidth, color, 18, - (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + mapName, DAT_ButtonX::instance + 24 + iconsWidth, DAT_ButtonY::instance + 3, 170 - iconsWidth, color, + 18, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); } } diff --git a/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp index f30b381a83..534109bdba 100644 --- a/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemActionHandler_MainMenu_Main.cpp @@ -59,7 +59,7 @@ namespace UI { OpenSHC::UI::Enums::MVT_SELECT_CRUSADE, 0); return; case 3: - // castle builder (the tail is written out in case 4 too: MSVC jumps from here into that copy) + // castle builder; the tail in each case (one copy after the switch: quick_diff 0.9500 -> 0.7756) DAT_GameCore::instance.missionNumber1to20 = 0; DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_BUILDERUnk; DAT_GameCore::instance.xbowProducible_logic = 1; diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp index 30ec8b490d..c98811fc7c 100644 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_MapTableHeader.cpp @@ -14,8 +14,7 @@ namespace UI { // A click on a column header sorts the map list by that column, and a second click reverses the order switch (column) { case 0: { - // Name: the order kept in DAT_ArrayOfMapIndices2 (read with - 1, as its other users do), backwards - // after the first click + // Name: the order kept in DAT_ArrayOfMapIndices2, backwards after the first click if (DAT_MenuTextInputState::instance.fileListSortOrder == 0) { for (int i = 0; i < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; ++i) { DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] @@ -28,7 +27,7 @@ namespace UI { } int i = 0; if (i < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { - // A guarded do-while: as a for loop MSVC turns the copy into rep movsd + // A guarded do-while (a for or a while loop: quick_diff 0.9738 -> 0.9283) do { DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices2[i - 1];