From 1d1afa83d213a9a2e50c5ddb5a24bc2c35c3d0a6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 14:30:09 +0100 Subject: [PATCH 1/7] reimplement: SHC_3BB0A8C1_0x00442640 100.0% Reimplemented LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick, from gynt's draft (c0a2f526c at 40.85% on his fork's development; c88d7a213 at 40.8% on upstream's reimpl/UI-MenuItems; f53ef94be to d81f02ff1, 54.93% to 69.03%, his fork's reimpl/UI-MenuItems; a4fb7c279 of 2026-10-28 on his fork's reimpl/Wilps-2026-10-18; 99cb9058a at 80.53%, 35aef556d at 80.71% and dd1a7c48c of 2026-11-02, his newest commit on the file, on his fork's reimpl/UI-MenuItems-development) and our cb601a074 and 1918de9f5 in draft #327 (90.7%). 90.3% -> 100.0% on main 3458fea34: - case 4 sets the draw buffer back once, after the if / else that launches the game: the original pops three registers before that store in the skirmish arm (pop esi / pop ebp / pop ebx / mov / pop edi / ret); - the two keep-position loops read keepPositions[position].x where they use it, with no local, which gives lea ebp, [eax + edi + 572] with x as the base (a local gave [edi + eax + 572]); - the map index. Case 4 writes its two sums as DAT_MapSelectionScrollOffset + DAT_MapSelectionRelativeSelected, and case 105 takes its index through a local that is declared before the switch. That gives both cases the original's two loads and add (0x0044284E: edx, eax, add eax, edx; 0x00442AD8: ecx, edx, add edx, ecx). The three sums are coupled: of 32 combinations (each case's sum written out, as a block-scope local or as this local, in both operand orders) only this one and its twin with case 105's operands swapped match. A block-scope local in case 105 swaps case 4's loads, which is why the declaration stands before the switch, with one comment line. The local starts at 0, which nothing reads: declared without a value, style rule 24 asks for it in case 105, and the code is the same either way. quick_diff reads 0.9956: its two lines are a tail jump it prints as a label and the jmp over the first loop's alignment padding; it cannot see the load order, since it prints both fields as [G]. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- ..._LobbyMenu_LobbyscreenStartButtonClick.cpp | 292 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp new file mode 100644 index 0000000000..d623e40635 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp @@ -0,0 +1,292 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.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_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b95960.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" +#include "OpenSHC/Globals/INT_00b95f64.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00442640 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick(int action, ...) + { + if (DAT_00b960dc::instance != 0) { + return; + } + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + // case 105's index, declared here: declared in its case, the two loads of case 4's sum swap + int mapIndex = 0; + switch (action) { + case -1: + // chat scroll up + if (DAT_GameSynchronyState::instance.chatScrollOffset < 15) { + ++DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case -2: + // chat scroll down + if (DAT_GameSynchronyState::instance.chatScrollOffset > 0) { + --DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case 1: + // load game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2) { + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::loadOrSaveGame, DAT_MenuTextInputState::ptr)(9); + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + break; + case 2: + // leave the lobby + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + if (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) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + } else { + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)(22); + if (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) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + } + } + break; + case -20: + case 3: + // ready button + if (DAT_GameSynchronyState::instance.flag_0x7aad8 + && DAT_GameSynchronyState::instance.DAT_TwoIfNotHost == 2) { + DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] ^= 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + } + if (DAT_GameSynchronyState::instance.isHost + && DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + } + break; + case 4: + // start the game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2 + && DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + >= 0 + && DAT_GameSynchronyState::instance + .unknownMapRelatedReceivedDataArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected]] + > 0) { + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::setTimeBasedSeed, SEC_RNG::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TRIGGER_LOBBY_PLAYER_INFORMATION_REFRESH); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_GameCore::instance.isSkirmishTrail = FALSE; + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSkirmishGame)(0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_START_MULTIPLAYER_GAME); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + break; + case -10: + // map list scroll up + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset > 0) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -11: + // map list scroll down + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 8) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -100: + // map description scroll up + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < -19) { + DAT_00b960f4::instance = -19; + } + break; + case -101: { + // map description scroll down + int const limit = INT_00b95b74::instance - 114; + if (DAT_00b960f4::instance < limit) { + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + } + break; + } + case -200: + // pick up the keep position under the mouse + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { + if (DAT_GameCore::instance.keepPositions[position].x < 0 + || DAT_MouseState::instance.screenSpaceX < DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 572 + || DAT_MouseState::instance.screenSpaceX > DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 595) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + INT_00b95960::instance = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + INT_00b95f64::instance = position; + return; + } + break; + case -201: + // drop it on the keep position under the mouse: swap the two players' positions + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + if (INT_00b95960::instance >= 0) { + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { + if (DAT_GameCore::instance.keepPositions[position].x < 0 + || DAT_MouseState::instance.screenSpaceX < DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 572 + || DAT_MouseState::instance.screenSpaceX > DAT_GameCore::instance.keepPositions[position].x + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 595) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + int const dragged + = DAT_GameSynchronyState::instance.playerPositionsArray[INT_00b95f64::instance]; + DAT_GameSynchronyState::instance.playerPositionsArray[INT_00b95f64::instance] + = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + DAT_GameSynchronyState::instance.playerPositionsArray[position] = dragged; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + break; + } + } + INT_00b95960::instance = -1; + break; + case 105: + mapIndex = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[mapIndex]; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_103); + break; + case 413: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..20fde2b22c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13693,7 +13693,7 @@ SHC_3BB0A8C1_0x00442230 | 0.0% | Pending SHC_3BB0A8C1_0x00442300 | 0.0% | Pending -SHC_3BB0A8C1_0x00442640 | 0.0% | Pending +SHC_3BB0A8C1_0x00442640 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004429C0 | 0.0% | Pending From cd3bf5707c42617b1183b007b7ae7f4a992268ea Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 14:08:00 +0100 Subject: [PATCH 2/7] reimplement: SHC_3BB0A8C1_0x00492DE0 100.0% Reimplemented SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader, rewritten from the binary with gynt's draft for the names (f788afb14 at 17.2% on upstream's reimpl/UI-MenuItems; 54e57c4e1 and 21d4dcf9a at 47.81% and 49.40% on his fork's reimpl/UI-MenuItems; 8725ec523 at 49.4% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file). reccmp 100.0 (normalized 100.0) on main 3458fea34 with the data and its own function resolver on; the draft reads 47.8 there. The array index changed with the header. gynt's draft uses DAT_ArrayOfMapIndices[i - 1] and [i], which was right on his branch, where the array is declared at offset 0x884. Main's sync 12854bcf4 (2026-11-04) moved the declared start to 0x880, so the original's 0x01126E28 and 0x01126E2C are [i] and [i + 1] here. - The order store is in each arm and previewedListIndex = -1 is written once after the if / else. MSVC copies that store into both arms, after the last pop, as the original has it; only the order store sits between the pops. Written in each arm, it keeps -1 in ebx and pushes ebx at the top, and the first sort's two loops lose their alignment padding. - The swap reads the moved element into a local inside the if. With both elements in locals before the test they land in each other's registers. - fileListEntryCount is read in the loop condition: the original reloads it after each swap's stores. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...mActionHandler_SaveLoadMap_TableHeader.cpp | 95 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp diff --git a/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp new file mode 100644 index 0000000000..230d9826e9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp @@ -0,0 +1,95 @@ +#include "../SaveLoadMap.func.hpp" + +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00492DE0 + void SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader(int button, ...) + { + // the header's arrows, -1 to -4, choose the column and the order the sort below turns round + if (button < 0) { + button = -1 - button; + switch (button) { + case 0: + DAT_MenuTextInputState::instance.fileListSortOrder = 1; + break; + case 1: + DAT_MenuTextInputState::instance.fileListSortOrder = 0; + button = 0; + break; + case 2: + DAT_MenuTextInputState::instance.fileListSortOrder = 3; + button = 1; + break; + case 3: + DAT_MenuTextInputState::instance.fileListSortOrder = 2; + button = 1; + break; + } + } + switch (button) { + case 1: + // by the file's time: a bubble sort, one way or the other + if (DAT_MenuTextInputState::instance.fileListSortOrder == 2) { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount - 1; ++i) { + if (DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]] + > DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]]) { + int const moved = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = moved; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 3; + } else { + for (int swaps = 1; swaps != 0;) { + swaps = 0; + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount - 1; ++i) { + if (DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]] + < DAT_ResourceManager::instance + .mapFileTimes[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]]) { + int const moved = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i + 1] = moved; + ++swaps; + } + } + } + DAT_MenuTextInputState::instance.fileListSortOrder = 2; + } + DAT_MenuTextInputState::instance.previewedListIndex = -1; + return; + case 0: + // by name: the list as it was read, or the other way round + if (DAT_MenuTextInputState::instance.fileListSortOrder == 0) { + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] + = DAT_MenuTextInputState::instance.fileListEntryCount - i - 1; + } + DAT_MenuTextInputState::instance.fileListSortOrder = 1; + } else { + for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = i; + } + DAT_MenuTextInputState::instance.fileListSortOrder = 0; + } + DAT_MenuTextInputState::instance.previewedListIndex = -1; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 20fde2b22c..a7061eafaa 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23525,7 +23525,7 @@ SHC_3BB0A8C1_0x00492C60 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492C90 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00492DE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00492DE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492E70 | 0.0% | Pending From 2ee45e587ecd86a728a39b3c0fe5662eb6b5a009 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 14:10:34 +0100 Subject: [PATCH 3/7] reimplement: SHC_3BB0A8C1_0x004269E0 100.0% Reimplemented HistoricMissionSelect::MenuItemRenderFunction_HistoricMissionSelect_MissionRows, rewritten from the binary with gynt's draft for the names (298b3af4e at 20.6% on upstream's reimpl/UI-MenuItems; 633d78492 at 41.41% on his fork's reimpl/UI-MenuItems; 626fd6817 at 44.53% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file). reccmp 100.0 (normalized 100.0) on main 3458fea34 with the data and its own function resolver on; the draft reads 45.3 there. Behaviour: a mission not reached yet is drawn as a greyed cell and the function returns (0x00426A53). The draft went on and drew the number and the name over it. - The number and the name are written in each of the three arms, and DAT_ButtonUnknownZero = FALSE once after them: MSVC hoists the arms' common pushes and shares the tail, as the original has it. - The number's position is written out in each arm; with locals for it the two loads come in the other order. - In the selected arm the name's position and index are read into locals before the nested call, Y, X, then the index, which gives the original's registers for that call. - The locked test compares (int)(DAT_00b96100 - row - 1): the global is an undefined4, and the original's jle is signed. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...tion_HistoricMissionSelect_MissionRows.cpp | 89 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp diff --git a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp new file mode 100644 index 0000000000..20df47dbd0 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp @@ -0,0 +1,89 @@ +#include "../HistoricMissionSelect.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.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/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_00b95b2c.hpp" +#include "OpenSHC/Globals/DAT_00b96100.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_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004269E0 + void HistoricMissionSelect::MenuItemRenderFunction_HistoricMissionSelect_MissionRows(int row, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU + && DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + // a mission not reached yet is drawn greyed, with no text + if (!DAT_GameCore::instance.unlockAllHistoricalCampaigns + && (int)(DAT_00b96100::instance - row - 1) + > (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[DAT_00b95b2c::instance]) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(FALSE, row, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, DAT_PencilRenderCore::ptr)( + DAT_00b96100::instance - row - 1 == DAT_GameCore::instance.missionNumber1to20, row, 0); + int const number = -row; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // written in each arm: MSVC then hoists the calls' common pushes, as the original has them + if (number == DAT_GameCore::instance.missionNumber1to20) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + // read before the nested call, in the order the original loads them + int const nameY = DAT_ButtonY::instance + 5; + int const nameX = DAT_ButtonX::instance + 30; + int const mission = DAT_00b96100::instance - row - 1; + 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_MISSION_NAMES, mission), + nameX, nameY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + } else if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE); + } + DAT_ButtonUnknownZero::instance = FALSE; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a7061eafaa..f343067b9a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6781,7 +6781,7 @@ SHC_3BB0A8C1_0x00426830 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004268C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004269E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004269E0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00426B80 | 100.0% | Reimplemented From e7d2efcdce28a429401d6994ab61ef737e68c16f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 23:22:37 +0100 Subject: [PATCH 4/7] headers: DAT_00b96100, DAT_00b95b2c and the file list's sort order are ints, and a FileListSortOrder enum DAT_00b96100 is the first mission of the historic campaign the mission list shows (1, 6, 11 or 16), and DAT_00b95b2c is that campaign's index (0 to 3). MenuView_HistoricMissionSelect_Prepare (0x00426830) picks the campaign from missionNumber1to20 and stores the index and index * 5 + 1 (0x00426879 / 0x0042687E and the two other arms). The mission rows compare DAT_00b96100 - row - 1 with that campaign's progress signed (jle at 0x00426A22), so DAT_00b96100 is an int, and DAT_00b95b2c, an index from 0 to 3, is one with it. Their data.asm symbols follow in the next commit. MenuTextInputState::fileListSortOrder holds one of four orders of the load / save file list, and the three savedListSortOrder fields hold copies of it; all four are now int. The values get names in a new FileListSortOrder enum: 0 by name, A to Z, as discoverMapFiles sorts the list, 1 Z to A, 2 by file time newest first, 3 oldest first. The table header's four sorts end in those values (0x00492FA2, 0x00492F69, 0x00492F25, 0x00492EB5). Only the table header includes the enum: included by MenuTextInputState.hpp, which many files include, its declarations swap two registers in LobbyscreenStartButtonClick and LaunchSinglePlayerGameUnk. Header changes only. The users on main 48f7e946cc and on this branch compile to the same code. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00b95b2c.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b96100.hpp | 4 ++-- src/OpenSHC/UI/Enums/FileListSortOrder.hpp | 26 ++++++++++++++++++++++ src/OpenSHC/UI/MenuTextInputState.hpp | 8 +++---- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/OpenSHC/UI/Enums/FileListSortOrder.hpp diff --git a/src/OpenSHC/Globals/DAT_00b95b2c.hpp b/src/OpenSHC/Globals/DAT_00b95b2c.hpp index 96d898002d..c2cf28655f 100644 --- a/src/OpenSHC/Globals/DAT_00b95b2c.hpp +++ b/src/OpenSHC/Globals/DAT_00b95b2c.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B95B2C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B95B2C) DAT_00b95b2c; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B95B2C) DAT_00b95b2c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B95B2C); diff --git a/src/OpenSHC/Globals/DAT_00b96100.hpp b/src/OpenSHC/Globals/DAT_00b96100.hpp index 97d5ff4230..d1f6436655 100644 --- a/src/OpenSHC/Globals/DAT_00b96100.hpp +++ b/src/OpenSHC/Globals/DAT_00b96100.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B96100 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B96100) DAT_00b96100; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B96100) DAT_00b96100; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B96100); diff --git a/src/OpenSHC/UI/Enums/FileListSortOrder.hpp b/src/OpenSHC/UI/Enums/FileListSortOrder.hpp new file mode 100644 index 0000000000..a57e75846a --- /dev/null +++ b/src/OpenSHC/UI/Enums/FileListSortOrder.hpp @@ -0,0 +1,26 @@ +/** + THIS FILE IS AUTO GENERATED + Communicate changes to the dev team (e.g. via a Pull Request). + Changes get lost otherwise. + + path: 'OpenSHC/UI/Enums/FileListSortOrder.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace UI { + namespace Enums { + typedef enum FileListSortOrder { + + FLSO_BY_NAME = 0, // 0x00000000 + FLSO_BY_NAME_REVERSED = 1, // 0x00000001 + FLSO_BY_TIME_NEWEST_FIRST = 2, // 0x00000002 + FLSO_BY_TIME_OLDEST_FIRST = 3 // 0x00000003 + + } FileListSortOrder; + + static_assert_cpp98_obj(sizeof(FileListSortOrder) == 4, FileListSortOrder); + } // namespace Enums +} // namespace UI +} // namespace OpenSHC diff --git a/src/OpenSHC/UI/MenuTextInputState.hpp b/src/OpenSHC/UI/MenuTextInputState.hpp index 7ec4b5b4fb..cf2134ee2c 100644 --- a/src/OpenSHC/UI/MenuTextInputState.hpp +++ b/src/OpenSHC/UI/MenuTextInputState.hpp @@ -31,13 +31,13 @@ namespace UI { undefined4 fileListContext; // 0x00000000 length: 4 undefined4 savedListOffset1; // 0x00000004 length: 4 undefined4 savedListSelection1; // 0x00000008 length: 4 - undefined4 savedListSortOrder1; // 0x0000000C length: 4 + int savedListSortOrder1; // 0x0000000C length: 4 undefined4 savedListOffset2; // 0x00000010 length: 4 undefined4 savedListSelection2; // 0x00000014 length: 4 - undefined4 savedListSortOrder2; // 0x00000018 length: 4 + int savedListSortOrder2; // 0x00000018 length: 4 undefined4 savedListOffset3; // 0x0000001C length: 4 undefined4 savedListSelection3; // 0x00000020 length: 4 - undefined4 savedListSortOrder3; // 0x00000024 length: 4 + int savedListSortOrder3; // 0x00000024 length: 4 ScreenResolutionEnumInt menuCurrentlySelectedResolution; // 0x00000028 length: 4 undefined4 unknownZoomRelatedFlag01; // 0x0000002C length: 4 undefined4 pendingGameSpeedLevel; // 0x00000030 length: 4 @@ -55,7 +55,7 @@ namespace UI { MenuModalTypeInt currentModalDialog; // 0x0000005C length: 4 MenuModalTypeInt previousModalDialogs[5]; // 0x00000060 length: 20 int fileListEntryCount; // 0x00000074 length: 4 - undefined4 fileListSortOrder; // 0x00000078 length: 4 + int fileListSortOrder; // 0x00000078 length: 4 int menuLoadGameRelativeSelectionIndex; // 0x0000007C length: 4 int menuLoadGameRelativeSelectionOffset; // 0x00000080 length: 4 int fileListVisibleRowCount; // 0x00000084 length: 4 From 0ccba1af74ece08c1897e694a198b1b55fb08944 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 23:22:37 +0100 Subject: [PATCH 5/7] data: DAT_00b96100's and DAT_00b95b2c's symbols as ints data.asm names the instances at 0x00B96100 and 0x00B95B2C with the int type (H instead of I), as it does for main's other int globals, to go with the header commit before it. The Extern symbol's name carries the type, so a build with their struct resolvers off links only with both commits. Co-Authored-By: Claude Opus 5.5 --- src/symbols/data.asm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/symbols/data.asm b/src/symbols/data.asm index 8d6b5ce1eb..ede51948b8 100644 --- a/src/symbols/data.asm +++ b/src/symbols/data.asm @@ -1209,7 +1209,7 @@ PUBLIC ?instance@?$Extern@H$0LJFKLM@@StructResolver@@2HA PUBLIC ?instance@?$Extern@K$0LJFLBM@@StructResolver@@2KA -PUBLIC ?instance@?$Extern@I$0LJFLCM@@StructResolver@@2IA +PUBLIC ?instance@?$Extern@H$0LJFLCM@@StructResolver@@2HA PUBLIC ?instance@?$Extern@H$0LJFLDE@@StructResolver@@2HA @@ -1255,7 +1255,7 @@ PUBLIC ?instance@?$Extern@I$0LJGAPI@@StructResolver@@2IA PUBLIC ?instance@?$Extern@H$0LJGAPM@@StructResolver@@2HA -PUBLIC ?instance@?$Extern@I$0LJGBAA@@StructResolver@@2IA +PUBLIC ?instance@?$Extern@H$0LJGBAA@@StructResolver@@2HA PUBLIC ?instance@?$Extern@I$0LJGBAI@@StructResolver@@2IA @@ -2896,7 +2896,7 @@ _TEXT SEGMENT ?instance@?$Extern@K$0LJFLBM@@StructResolver@@2KA EQU 00B95B1Ch -?instance@?$Extern@I$0LJFLCM@@StructResolver@@2IA EQU 00B95B2Ch +?instance@?$Extern@H$0LJFLCM@@StructResolver@@2HA EQU 00B95B2Ch ?instance@?$Extern@H$0LJFLDE@@StructResolver@@2HA EQU 00B95B34h @@ -2942,7 +2942,7 @@ _TEXT SEGMENT ?instance@?$Extern@H$0LJGAPM@@StructResolver@@2HA EQU 00B960FCh -?instance@?$Extern@I$0LJGBAA@@StructResolver@@2IA EQU 00B96100h +?instance@?$Extern@H$0LJGBAA@@StructResolver@@2HA EQU 00B96100h ?instance@?$Extern@I$0LJGBAI@@StructResolver@@2IA EQU 00B96108h From c757ee182594a3b290eb6206bd835b1aeb52cfa6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 23:22:37 +0100 Subject: [PATCH 6/7] MissionRows and SaveLoadMap's table header use the new types and names MissionRows tests DAT_00b96100, now an int, without a cast. The table header writes its sort orders as FileListSortOrder names, and its first switch's labels too: that switch is on -1 - button, the order the handler ends in. The listings are the same: narrow builds of this branch's files and of every user of the two globals and the four fields read 100.0 raw and normalised, with no diff line, before and after, and so do a full build of the branch merged with main 48f7e946cc and narrow builds of these two files in their final form. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...tion_HistoricMissionSelect_MissionRows.cpp | 2 +- ...mActionHandler_SaveLoadMap_TableHeader.cpp | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp index 20df47dbd0..280a919ec4 100644 --- a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp +++ b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp @@ -32,7 +32,7 @@ namespace UI { && DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { // a mission not reached yet is drawn greyed, with no text if (!DAT_GameCore::instance.unlockAllHistoricalCampaigns - && (int)(DAT_00b96100::instance - row - 1) + && DAT_00b96100::instance - row - 1 > (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[DAT_00b95b2c::instance]) { DAT_ButtonCurrentlyInteracting::instance = FALSE; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue diff --git a/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp index 230d9826e9..aafb1b061a 100644 --- a/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp +++ b/src/OpenSHC/UI/MenuItems/SaveLoadMap/MenuItemActionHandler_SaveLoadMap_TableHeader.cpp @@ -1,5 +1,7 @@ #include "../SaveLoadMap.func.hpp" +#include "OpenSHC/UI/Enums/FileListSortOrder.hpp" + #include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" #include "OpenSHC/Globals/DAT_ResourceManager.hpp" @@ -10,23 +12,23 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x00492DE0 void SaveLoadMap::MenuItemActionHandler_SaveLoadMap_TableHeader(int button, ...) { - // the header's arrows, -1 to -4, choose the column and the order the sort below turns round + // the arrows, -1 to -4: -1 - button is the order the sort ends in, so its opposite is set first if (button < 0) { button = -1 - button; switch (button) { - case 0: - DAT_MenuTextInputState::instance.fileListSortOrder = 1; + case OpenSHC::UI::Enums::FLSO_BY_NAME: + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_NAME_REVERSED; break; - case 1: - DAT_MenuTextInputState::instance.fileListSortOrder = 0; + case OpenSHC::UI::Enums::FLSO_BY_NAME_REVERSED: + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_NAME; button = 0; break; - case 2: - DAT_MenuTextInputState::instance.fileListSortOrder = 3; + case OpenSHC::UI::Enums::FLSO_BY_TIME_NEWEST_FIRST: + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_TIME_OLDEST_FIRST; button = 1; break; - case 3: - DAT_MenuTextInputState::instance.fileListSortOrder = 2; + case OpenSHC::UI::Enums::FLSO_BY_TIME_OLDEST_FIRST: + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_TIME_NEWEST_FIRST; button = 1; break; } @@ -34,7 +36,8 @@ namespace UI { switch (button) { case 1: // by the file's time: a bubble sort, one way or the other - if (DAT_MenuTextInputState::instance.fileListSortOrder == 2) { + if (DAT_MenuTextInputState::instance.fileListSortOrder + == OpenSHC::UI::Enums::FLSO_BY_TIME_NEWEST_FIRST) { for (int swaps = 1; swaps != 0;) { swaps = 0; for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount - 1; ++i) { @@ -50,7 +53,7 @@ namespace UI { } } } - DAT_MenuTextInputState::instance.fileListSortOrder = 3; + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_TIME_OLDEST_FIRST; } else { for (int swaps = 1; swaps != 0;) { swaps = 0; @@ -67,23 +70,23 @@ namespace UI { } } } - DAT_MenuTextInputState::instance.fileListSortOrder = 2; + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_TIME_NEWEST_FIRST; } DAT_MenuTextInputState::instance.previewedListIndex = -1; return; case 0: // by name: the list as it was read, or the other way round - if (DAT_MenuTextInputState::instance.fileListSortOrder == 0) { + if (DAT_MenuTextInputState::instance.fileListSortOrder == OpenSHC::UI::Enums::FLSO_BY_NAME) { for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = DAT_MenuTextInputState::instance.fileListEntryCount - i - 1; } - DAT_MenuTextInputState::instance.fileListSortOrder = 1; + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_NAME_REVERSED; } else { for (int i = 0; i < DAT_MenuTextInputState::instance.fileListEntryCount; ++i) { DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[i] = i; } - DAT_MenuTextInputState::instance.fileListSortOrder = 0; + DAT_MenuTextInputState::instance.fileListSortOrder = OpenSHC::UI::Enums::FLSO_BY_NAME; } DAT_MenuTextInputState::instance.previewedListIndex = -1; return; From ac932fcd89e81104af65d583bc3d0935199de1ac Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 24 Nov 2026 19:00:14 +0100 Subject: [PATCH 7/7] HistoricMissionSelect uses the two globals' new names Main's header sync named DAT_00b95b2c and DAT_00b96100 INT_00b95b2c and INT_00b96100. The mission rows, and main's General handler and Prepare view, include the new headers and use the new names. Main's two files have not compiled since the sync without this. The code is otherwise the same. Co-Authored-By: Claude Opus 5.5 --- ...tionHandler_HistoricMissionSelect_General.cpp | 4 ++-- ...unction_HistoricMissionSelect_MissionRows.cpp | 16 ++++++++-------- .../MenuView_HistoricMissionSelect_Prepare.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemActionHandler_HistoricMissionSelect_General.cpp b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemActionHandler_HistoricMissionSelect_General.cpp index 34b34f7a2c..b29410492b 100644 --- a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemActionHandler_HistoricMissionSelect_General.cpp +++ b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemActionHandler_HistoricMissionSelect_General.cpp @@ -6,11 +6,11 @@ #include "OpenSHC/UI/Enums/MenuViewType.hpp" #include "OpenSHC/Globals/BOOL_CurrentMenuClickState.hpp" -#include "OpenSHC/Globals/DAT_00b96100.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" #include "OpenSHC/Globals/DAT_GameState.hpp" #include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" #include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/INT_00b96100.hpp" namespace OpenSHC { namespace UI { @@ -25,7 +25,7 @@ namespace UI { switch (button) { default: { BOOL_CurrentMenuClickState::instance = FALSE; - DAT_GameCore::instance.missionNumber1to20 = DAT_00b96100::instance - button - 1; + DAT_GameCore::instance.missionNumber1to20 = INT_00b96100::instance - button - 1; DWORD const clickTime = timeGetTime(); if (DAT_GameCore::instance.missionNumber1to20 != DAT_MenuTextInputState::instance.lastClickedListIndex diff --git a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp index 280a919ec4..8790070475 100644 --- a/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp +++ b/src/OpenSHC/UI/MenuItems/HistoricMissionSelect/MenuItemRenderFunction_HistoricMissionSelect_MissionRows.cpp @@ -8,8 +8,6 @@ #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/Globals/DAT_00b95b2c.hpp" -#include "OpenSHC/Globals/DAT_00b96100.hpp" #include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" #include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" #include "OpenSHC/Globals/DAT_ButtonX.hpp" @@ -20,6 +18,8 @@ #include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/INT_00b95b2c.hpp" +#include "OpenSHC/Globals/INT_00b96100.hpp" namespace OpenSHC { namespace UI { @@ -32,8 +32,8 @@ namespace UI { && DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { // a mission not reached yet is drawn greyed, with no text if (!DAT_GameCore::instance.unlockAllHistoricalCampaigns - && DAT_00b96100::instance - row - 1 - > (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[DAT_00b95b2c::instance]) { + && INT_00b96100::instance - row - 1 + > (&DAT_GameCore::instance.scenarioProgress.progressCallToArms)[INT_00b95b2c::instance]) { DAT_ButtonCurrentlyInteracting::instance = FALSE; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; @@ -47,7 +47,7 @@ namespace UI { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, DAT_PencilRenderCore::ptr)( - DAT_00b96100::instance - row - 1 == DAT_GameCore::instance.missionNumber1to20, row, 0); + INT_00b96100::instance - row - 1 == DAT_GameCore::instance.missionNumber1to20, row, 0); int const number = -row; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; // written in each arm: MSVC then hoists the calls' common pushes, as the original has them @@ -58,7 +58,7 @@ namespace UI { // read before the nested call, in the order the original loads them int const nameY = DAT_ButtonY::instance + 5; int const nameX = DAT_ButtonX::instance + 30; - int const mission = DAT_00b96100::instance - row - 1; + int const mission = INT_00b96100::instance - row - 1; 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_MISSION_NAMES, mission), @@ -68,7 +68,7 @@ namespace UI { DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, INT_00b96100::instance - row - 1, DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 19, FALSE); } else { @@ -76,7 +76,7 @@ namespace UI { DAT_TextManagerObject::ptr)(number, DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, DAT_00b96100::instance - row - 1, + OpenSHC::DE::SHCDE::TEXT_MISSION_NAMES, INT_00b96100::instance - row - 1, DAT_ButtonX::instance + 30, DAT_ButtonY::instance + 5, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE); } diff --git a/src/OpenSHC/UI/MenuViews/HistoricMissionSelect/MenuView_HistoricMissionSelect_Prepare.cpp b/src/OpenSHC/UI/MenuViews/HistoricMissionSelect/MenuView_HistoricMissionSelect_Prepare.cpp index 0044bd9269..b7803a93bf 100644 --- a/src/OpenSHC/UI/MenuViews/HistoricMissionSelect/MenuView_HistoricMissionSelect_Prepare.cpp +++ b/src/OpenSHC/UI/MenuViews/HistoricMissionSelect/MenuView_HistoricMissionSelect_Prepare.cpp @@ -4,11 +4,11 @@ #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" #include "OpenSHC/string-literals.hpp" -#include "OpenSHC/Globals/DAT_00b95b2c.hpp" -#include "OpenSHC/Globals/DAT_00b96100.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" #include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" #include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/INT_00b95b2c.hpp" +#include "OpenSHC/Globals/INT_00b96100.hpp" namespace OpenSHC { namespace UI { @@ -37,8 +37,8 @@ namespace UI { } else { chapter = 3; } - DAT_00b95b2c::instance = chapter; - DAT_00b96100::instance = chapter * 5 + 1; + INT_00b95b2c::instance = chapter; + INT_00b96100::instance = chapter * 5 + 1; } }