From bee3ec3f982fd27a437d21ab68fc002f48867f0e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 15:50:47 +0100 Subject: [PATCH 1/5] reimplement: SHC_3BB0A8C1_0x004909E0 100.0% Reimplemented MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons, from the draft #328 (reimpl/UI-MenuItems-3-development-2, 306a61abc, 79.4%), itself gynt's draft (1674e0f22, 72.84%; his newest reimplementation commit on the file is 8725ec523, his last style pass dd1a7c48c). gynt's: the switch over the actions, the scroll and host cases and the session handling. The join case is rewritten without the decompiler's gotos and hand-unrolled string loops: the typed address is stored only when it is not empty (`strlen(...) != 0`), not already listed (a found flag over the four entries), in the first empty slot (a stored flag, `strlen(...) == 0`, then strcpy), or else after shifting the list up. MSVC threads both flags away and inlines strlen and strcpy into the original's loops, including its `sub eax, edx` length tests that the draft's pointer compare did not give. The host case copies the player name with strcpy. reccmp 99.2, normalised 100.0: the only differences are tail-jump targets to resetMouseState2 (0x004689D0, on main with its resolver off), so 100% by the call-target rule. The original jumps to it three times (0x00490C73, 0x00490D4A, 0x00490D81); reccmp reads two of ours as different targets. quick_diff 0.9850; its other hunk is the original's `npad` jump before the shift loop. The parameter is action, the session result is tested inline, the index step is a plain increment, the two flags are BOOLEnum and the array bounds are written with countof (all measured identical). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...r_ChooseNetworkServiceProvider_Buttons.cpp | 171 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp new file mode 100644 index 0000000000..1ea1130174 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp @@ -0,0 +1,171 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + +#include "../ChooseNetworkServiceProvider.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004909E0 + void ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons( + ChooseNetworkServiceProviderButtonActions action, ...) + { + // the cases in the original's block order + switch (action) { + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_NEXT_IP_ADDRESSUnk: + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, DAT_UserTextHandlerState::ptr)( + 5, DAT_GameSynchronyState::instance.ipRelatedArray[DAT_GameSynchronyState::instance.ipArrayIndex]); + ++DAT_GameSynchronyState::instance.ipArrayIndex; + if (DAT_GameSynchronyState::instance.ipArrayIndex + >= countof(DAT_GameSynchronyState::instance.ipRelatedArray)) { + DAT_GameSynchronyState::instance.ipArrayIndex = 0; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_GAMESPY_ARCADEUnk: + if (DAT_GameSynchronyState::instance.gameSpyArcadeAvailable != 0) { + DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; + DAT_GameSynchronyState::instance.openOnClose = TRUE; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_DOWNUnk: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset + < DAT_GameSynchronyState::instance.scrollBarItemCount - 4) { + ++DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_UPUnk: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset > 0) { + --DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_JOIN_GAME: + DAT_GameSynchronyState::instance.isHost = FALSE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + // remember a new address: in the first empty slot, or at the end after dropping the oldest + if (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_GRANARY_OR_MPMENU_TCPIP + && strlen(MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5)) + != 0) { + OpenSHC::WindowsHelper::Enums::BOOLEnum known = FALSE; + for (int entry = 0; entry < countof(DAT_GameSynchronyState::instance.ipRelatedArray); ++entry) { + if (MACRO_CALL(OpenSHC::OS_Func::__stricmp)( + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5), + DAT_GameSynchronyState::instance.ipRelatedArray[entry]) + == 0) { + known = TRUE; + break; + } + } + if (!known) { + OpenSHC::WindowsHelper::Enums::BOOLEnum stored = FALSE; + for (int slot = 0; slot < countof(DAT_GameSynchronyState::instance.ipRelatedArray); ++slot) { + if (strlen(DAT_GameSynchronyState::instance.ipRelatedArray[slot]) == 0) { + strcpy(DAT_GameSynchronyState::instance.ipRelatedArray[slot], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5)); + stored = TRUE; + break; + } + } + if (!stored) { + // memcpy and memset compile to the original's dword moves + for (int row = 0; row < countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1; + ++row) { + memcpy(DAT_GameSynchronyState::instance.ipRelatedArray[row], + DAT_GameSynchronyState::instance.ipRelatedArray[row + 1], + sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[row])); + } + memset(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1], + 0, + sizeof(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1])); + strcpy(DAT_GameSynchronyState::instance + .ipRelatedArray[countof(DAT_GameSynchronyState::instance.ipRelatedArray) - 1], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5)); + } + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE) + >= 0) { + DAT_GameSynchronyState::instance.unkEnumerationRelatedBool = false; + DAT_GameSynchronyState::instance.scrollBarIndex = -1; + DAT_GameSynchronyState::instance.scrollBarItemOffset = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::restartDPlaySessionEnumeration, + DAT_GameSynchronyState::ptr)(FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_FINDING_NETWORK_SESSIONS, FALSE); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_HOST_GAME: + DAT_GameSynchronyState::instance.isHost = TRUE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE) + >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + DAT_GameSynchronyState::instance.field_0x106ee4 = 1; + 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_LOBBY_MENU, 0); + MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); + Menu_LobbyMenu::instance.thousand = 0; + MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); + strcpy(DAT_GameSynchronyState::instance.DAT_PlayerNames[1], + MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(0)); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::waitForMultiplayerHost, + DAT_GameSynchronyState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT: + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT_ALTUnk: + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.kickedAtTime = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 826f7fa80e..c49575a81a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23383,7 +23383,7 @@ SHC_3BB0A8C1_0x00490690 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004909E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004909E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490C20 | 0.0% | Pending From 25cbd1b3e47238cbfc8097ff5cece5740897f71e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:50:45 +0100 Subject: [PATCH 2/5] reimplement: SHC_3BB0A8C1_0x0042D640 100.0% Reimplemented From #328 (reimpl/UI-MenuItems-3-development-2, 031cb7d21, 75.1%), itself gynt's draft (f3cef40b2, 72.67%; his last style pass dd1a7c48c). Rewritten from the original's asm as one switch: MSVC splits it the original's way, -1100, -1000 and -101 compared one by one and -100..77 through the jump table, with the cases in the original's block order (2, -101, 65, 66, 67, 68, 76, 69, 74, 77, -10, -11, -100). No gotos; the back button's two menu views are two calls MSVC merges. Behaviour fixes against the binary: - start game (65 / -1100) sets the difficulty to 1 for mission types 0 and 3 and then still launches the game (0x0042D71D falls into 0x0042D727); the draft returned without launching; - the description's scroll down (-101) adds 14 and clamps to the limit, returning when already there; the draft always overwrote the offset with the limit; - the start game guard returns when the scroll offset plus the relative selection is negative (`js` at 0x0042D709); the draft's guard was inverted; - the draft's extra DAT_StopHandlingMenuItems stores are gone (the original stores it once, at the top). reccmp 99.7, normalised 100.0: the only difference is a tail jump's target through a resolver, so 100% by the call-target rule. The start-game test reads the scroll offset through DAT_GameSynchronyState::ptr and the relative selection through instance: MSVC then loads the relative selection first, as the original does (the same fields both through instance, in either order, a local or `0 >`, all kept the opposite load order, 99.1). A comment says why. quick_diff 134/134 (its other hunks are the timeGetTime import and resolver tail calls). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 167 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp new file mode 100644 index 0000000000..85d7902a24 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,167 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.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_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DWORD_00b95b1c.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042D640 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + DAT_StopHandlingMenuItems::instance = 0; + // the cases in the original's block order + switch (button) { + case -1000: + case 2: + // back + if (DAT_MapMissionType::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 10000); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 10000); + } + DWORD_00b95b1c::instance = timeGetTime(); + DAT_00b960dc::instance = 1; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case -101: { + // map description scroll down + int const limit = INT_00b95b74::instance - 204; + if (DAT_00b960f4::instance >= limit) { + return; + } + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + return; + } + case -1100: + case 65: + // start the game + // the offset through ptr: that way the relative selection is read first, for the match + if (DAT_GameSynchronyState::ptr->DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + < 0) { + return; + } + if (DAT_MapMissionType::instance == 0 || DAT_MapMissionType::instance == 3) { + DAT_GameState::instance.mapAndTime.difficulty = 1; + } + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSinglePlayerGameUnk)(0); + return; + case 66: + // castle builder and landscape mode + if (DAT_MapMissionType::instance != 0) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 0; + } + return; + case 67: + // mission type 1 + if (DAT_MapMissionType::instance != 1) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 1; + } + return; + case 68: + // siege mode + if (DAT_MapMissionType::instance != 2) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_MapMissionType::instance = 2; + } + return; + case 76: + // mission type 3 + if (DAT_MapMissionType::instance != 3) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 3; + } + return; + case 69: + // difficulty + if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance != 0) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (DAT_GameState::instance.mapAndTime.difficulty >= 4) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( + DAT_GameState::instance.mapAndTime.difficulty); + } + return; + case 74: + // advanced siege, for the defender + if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance == 2 + && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) { + DAT_SH1_SiegeAdvancedMode::instance ^= 1; + } + return; + case 77: + // "Attacking" or "Defending" + if (DAT_MapMissionType::instance == 2 && DAT_GameCore::instance.mapU4Int1_2 == 0) { + if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { + DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; + return; + } + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_SH1_SiegeAdvancedMode::instance = 0; + } + return; + case -10: + // map list scroll up + 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); + } + return; + case -11: + // map list scroll down + 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); + } + return; + case -100: + // map description scroll up + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + } + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c49575a81a..6817e89577 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7865,7 +7865,7 @@ SHC_3BB0A8C1_0x0042D632 | 0.0% | Pending SHC_3BB0A8C1_0x0042D633 | 0.0% | Pending -SHC_3BB0A8C1_0x0042D640 | 0.0% | Pending +SHC_3BB0A8C1_0x0042D640 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042D8B0 | 0.0% | Pending From 945f483e55ac48e8914a172ed2a74c00678a6e99 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 00:40:36 +0100 Subject: [PATCH 3/5] reimplement: SHC_3BB0A8C1_0x00424F50 100.0% Reimplemented MenuItemRenderFunction_MainMenu_Main, rewritten without gotos from the original's code, with gynt's draft (f2e9ae2e7 at 81.39% on his fork's reimpl/UI-MenuItems-development; his last style pass on the file is dd1a7c48c; quick_diff 0.9159 on main) for the reads. reccmp 100.0, quick_diff 162/162 at 1.0000. The decompiler's gotos are one if/else: a button that is not hovered and is not one of 5-9 draws its button and goes straight to the text, and every other button runs the button-5 hover sound, the GM index choice, the draw and the hover tracking. Each text that has a hovered and a not-hovered state is drawn by two calls that are the same, one per state, with the position read into `int const textY` then `textX` in each: MSVC keeps the two calls apart and merges only what they share, as in the original (one shared call: 0.9154; the button text alone split: 0.9938). The not-hovered call comes first. Behaviour fix: with the GM-index flag set, buttons 1, 2, 3 and 9 now go on to draw the button and its text after choosing GM index 353, as the original does; the draft returned there. The sound IDs are SEID_UNKNOWN_0xFB and SEID_UNKNOWN_0x92 (the draft or'ed two unrelated enum values that add up to them), the Multiplayer test compares with DD7_LOADED, and the colours are COL_7F7F7F and COL_C2F0EB. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_MainMenu_Main.cpp | 144 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp new file mode 100644 index 0000000000..ebd1a1c4ce --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MainMenu/MenuItemRenderFunction_MainMenu_Main.cpp @@ -0,0 +1,144 @@ +#include "../MainMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/DirectDrawStatus.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/BOOL_WasInteracting.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_GameCore.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00424F50 + void MainMenu::MenuItemRenderFunction_MainMenu_Main(int button, ...) + { + if (DAT_UnknownGFXIndex::instance == 1) { + return; + } + if (button != 5 && !DAT_ButtonCurrentlyInteracting::instance && button != 6 && button != 7 && button != 8 + && button != 9) { + // a button that is no longer hovered stops being the last one hovered + if (button == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag + && (button == 1 || button == 2 || button == 3)) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + if (button == 5) { + if (DAT_ButtonCurrentlyInteracting::instance && !BOOL_WasInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFB); + } + BOOL_WasInteracting::instance = DAT_ButtonCurrentlyInteracting::instance; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag + && (button == 1 || button == 2 || button == 3 || button == 9)) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + if (button < 10) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonOnScreenMenu)(); + } + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + // the hover sound plays once, when the pointer moves onto another button + if ((button < 5 || button == 9) && DAT_ButtonCurrentlyInteracting::instance) { + if (INT_00b95abc::instance != button) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = button; + } + } + if (button < 5) { + if (button == 4 && DAT_GameCore::instance.directDrawStatus < OpenSHC::Rendering::Enums::DD7_LOADED) { + // "Multiplayer", greyed out + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 29, DAT_ButtonX::instance + 30, + DAT_ButtonY::instance + 15, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, 0, + 16, FALSE); + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + // one call per hover state, the two the same, each reading y before x, for the match + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, button + 25), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, button + 25), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } + } + if (button == 9) { + // two calls that are the same, one per hover state: the split is only for the match + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + // "Custom Scenarios" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 30), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } else { + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + // "Custom Scenarios" + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 30), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); + } + } else if (button >= 5) { + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 1, + DAT_ButtonX::instance - 85, DAT_ButtonY::instance - 28, OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, + 2, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6817e89577..820327e724 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6685,7 +6685,7 @@ SHC_3BB0A8C1_0x00424CD0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00424DA0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00424F50 | 0.0% | Pending +SHC_3BB0A8C1_0x00424F50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004251A0 | 100.0% | Reimplemented From 0800b913672818f9751cec043ed9396e03cededd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 00:50:31 +0100 Subject: [PATCH 4/5] reimplement: SHC_3BB0A8C1_0x00495860 100.0% Reimplemented MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main, rewritten without gotos from the original's code, with gynt's draft for the reads (9d44bf452 at 80.93%, after his 85b6360c7, 2490ef5a4 and f03fca795; the file's newest commit on his fork's reimpl/UI-MenuItems-development is 8725ec523; quick_diff 0.8768 on main). The fields, the vote counting and the five buttons' actions were already his. reccmp 98.2, normalised 100.0: the only differences are the resetMouseState2 tail jumps, which go through its resolver. quick_diff 102/102 at 0.9608, for the same reason and the timeGetTime import call. One switch over the five buttons, every path ending in resetMouseState2. Button 1 ends the game. Button 2 counts the occupied player slots and starts a quit vote when someone else is there, with the empty slots and the asking player's own as yes votes. Buttons 4 and 5 send a no or a yes, and button 3 closes the dialog. The two loops over slots 1-8 compile to the same code as the eight lines written out. Behaviour fix: button 2 now does what the original does in both of its cases. With nobody else in the game it ends the game at once (the count test jumps into button 1's code), and after starting a vote it stops there. The draft fell through into button 4 in both cases and sent a no vote. Button 2 repeats button 1's code for the first case, written after button 1, so that MSVC merges the two as in the original (button 2 falling into a following button 1 put the blocks in the other order: 0.8922). The vote command is GCT_UNKNOWN_91 (the draft or'ed two unrelated enum values that add up to it). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...Handler_OnlineVoteQuitAndQuitGame_Main.cpp | 89 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp new file mode 100644 index 0000000000..4662a2b4a2 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main.cpp @@ -0,0 +1,89 @@ +#include "../OnlineVoteQuitAndQuitGame.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00495860 + void OnlineVoteQuitAndQuitGame::MenuItemActionHandler_OnlineVoteQuitAndQuitGame_Main(int button, ...) + { + // the cases in the original's block order + switch (button) { + case 1: + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL( + OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)( + 22); + break; + case 2: { + // a vote needs someone else to answer it + int playerCount = 0; + for (int slot = 1; slot < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++slot) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + playerCount++; + } + } + if (playerCount > 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_91); + DAT_GameSynchronyState::instance.quitGameVoteRelated = 2; + // the empty slots count as yes votes, and so does the player asking + for (int slot = 1; slot < countof(DAT_GameSynchronyState::instance.quitGameVoteArray); ++slot) { + DAT_GameSynchronyState::instance.quitGameVoteArray[slot] + = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] == -1; + } + DAT_GameSynchronyState::instance + .quitGameVoteArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] = 1; + DAT_GameSynchronyState::instance.quitGameVoteRequestTime = timeGetTime(); + break; + } + // alone in the game, the player quits at once, as with button 1: the code is repeated here rather + // than falling into case 1, for the match + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL( + OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)( + 22); + break; + } + case 4: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_QUIT_GAME_VOTE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + case 5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_QUIT_GAME_VOTE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + case 3: + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + break; + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 820327e724..50e6e17a0d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -24217,7 +24217,7 @@ SHC_3BB0A8C1_0x00495800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00495840 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00495860 | 0.0% | Pending +SHC_3BB0A8C1_0x00495860 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00495A14 | 0.0% | Pending From 32a918436d24ce2a000215b033f7b5f35ad8ce99 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 00:50:32 +0100 Subject: [PATCH 5/5] reimplement: SHC_3BB0A8C1_0x00427740 100.0% Reimplemented MenuItemRenderFunction_LobbyMenu_MapSelectHeader, rewritten from the original's code with gynt's draft for the reads (305b2b1eb at 74.80% on his fork's reimpl/UI-MenuItems; on reimpl/UI-MenuItems-development his newest reimplement commit on the file is 8725ec523 and the newest commit 50849804c; quick_diff 0.8160 on main). The columns' text numbers and offsets were already his. reccmp 100.0, quick_diff 63/63 at 1.0000. The header cell picks its text and x offset per column, draws the cell background and its title, brighter while hovered. Forms that match, measured with quick_diff: - one call per hover state rather than a colour ternary (the ternary compiles branch-free: 0.8661); - the fade and y read into locals before the branch, and x read into a local in each branch. The offset then keeps the original's register, where one x local before the branch swaps the offset and the text index (0.8254); - the text index and offset initialised before the dialog tests (after them, the two swap registers). The fade keeps the original's (strength - 32) * 32 / 32 + 32, with a comment that it comes back to the strength itself. The parameter is the column, the early returns replace the draft's nested condition, and the colours are COL_C2F0EB and COL_CCFAFF. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nderFunction_LobbyMenu_MapSelectHeader.cpp | 78 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp new file mode 100644 index 0000000000..0c95af1046 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_MapSelectHeader.cpp @@ -0,0 +1,78 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.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_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00427740 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_MapSelectHeader(int column, ...) + { + // both set before the dialog tests, for the match: set after them, the two swap registers + int textNumInGroup = -1; + int xOffset = 0; + if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + // the cases in the original's block order + switch (column) { + case 2: + // "Bl" + textNumInGroup = 410; + xOffset = 2; + break; + case 1: + // "No" + textNumInGroup = 61; + xOffset = 2; + break; + case 0: + // "Name" + textNumInGroup = 62; + xOffset = 8; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, 1, DAT_ButtonBackgroundBlendStrength::instance); + // the fade written the long way round, for the match; it comes back to the blend strength itself + int const blendStrength = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32; + int const textY = DAT_ButtonY::instance + 5; + // x read in each branch: one read before the branch swaps two registers + if (!DAT_ButtonCurrentlyInteracting::instance) { + int const textX = DAT_ButtonX::instance + xOffset; + 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_XPLAY_WAITING_ROOM, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, + blendStrength); + } else { + int const textX = DAT_ButtonX::instance + xOffset; + 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_XPLAY_WAITING_ROOM, textNumInGroup), + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, + blendStrength); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 50e6e17a0d..3a97b43162 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6817,7 +6817,7 @@ SHC_3BB0A8C1_0x004274F0 | 0.0% | Pending SHC_3BB0A8C1_0x004276F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00427740 | 0.0% | Pending +SHC_3BB0A8C1_0x00427740 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00427810 | 0.0% | Pending