From eda1f150219665f7ef0529f2b199b83832ef1dee Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:04 +0100 Subject: [PATCH 01/16] reimplement: SHC_3BB0A8C1_0x004D5370 100.0% | Reimplemented Skirmish::SkirmishLeaderboard_DeleteEntry. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../SkirmishLeaderboard_DeleteEntry.cpp | 29 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp diff --git a/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp b/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp new file mode 100644 index 0000000000..3a077a66ea --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp @@ -0,0 +1,29 @@ +#include "../Skirmish.func.hpp" + +#include "OpenSHC/IO.func.hpp" + +#include "OpenSHC/Globals/DAT_SkMasters2Data.hpp" + +namespace OpenSHC { +namespace Game { + + /* + Removes the skirmish leaderboard entry at the given index by shifting all later entries down by one, + decrementing the count and saving the table to disk (SkMasters2). + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004D5370 + void Skirmish::SkirmishLeaderboard_DeleteEntry(int index) + { + if (index < 0 || index >= DAT_SkMasters2Data::instance.count) { + return; + } + // close the gap by moving every later entry up one + for (int i = index; i < DAT_SkMasters2Data::instance.count - 1; i++) { + DAT_SkMasters2Data::instance.entries[i] = DAT_SkMasters2Data::instance.entries[i + 1]; + } + DAT_SkMasters2Data::instance.count--; + MACRO_CALL(IO_Func::WriteSkMasters2)(); + } + +} // namespace Game +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b31ea5fc2b..8949983360 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35567,7 +35567,7 @@ SHC_3BB0A8C1_0x004D5180 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D52A0 | 0.0% | Pending -SHC_3BB0A8C1_0x004D5370 | 0.0% | Pending +SHC_3BB0A8C1_0x004D5370 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D53A0 | 0.0% | Pending From d2054becf6eeff59f2ce51f706b94cc8aabccc48 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:04 +0100 Subject: [PATCH 02/16] reimplement: SHC_3BB0A8C1_0x004D52A0 100.0% | Reimplemented Skirmish::StoreGameIntoSKMasters. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. The shift loop keeps `<= countof - 1`: with `< countof` MSVC compares against 250 with jge, the original against 249 with jg. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../Game/Skirmish/StoreGameIntoSKMasters.cpp | 53 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp diff --git a/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp b/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp new file mode 100644 index 0000000000..66ce116bdb --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp @@ -0,0 +1,53 @@ +#include "../Skirmish.func.hpp" + +#include "OpenSHC/IO.func.hpp" + +#include "OpenSHC/Globals/DAT_SkMasterDataEntry.hpp" +#include "OpenSHC/Globals/DAT_SkMasters2Data.hpp" + +namespace OpenSHC { +namespace Game { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D52A0 + void Skirmish::StoreGameIntoSKMasters(int score) + { + if (!MACRO_CALL(Game::Skirmish_Func::StoreCurrentGameIntoTemporarySKMasterEntry)(score)) { + return; + } + int count = DAT_SkMasters2Data::instance.count; + int insertIndex = -1; + if (count <= 0) { + insertIndex = 0; + } + if (count < countof(DAT_SkMasters2Data::instance.entries)) { + insertIndex = count; + } + if (insertIndex != 0) { + // the table is sorted by score, best first + for (int i = 0; i < count; i++) { + if (DAT_SkMasterDataEntry::instance.skMasterScore + > DAT_SkMasters2Data::instance.entries[i].skMasterScore) { + insertIndex = i; + break; + } + } + if (insertIndex == -1) { + return; + } + } + // shift the later entries down one; the last one falls off a full table + for (; count > insertIndex; count--) { + // `<= countof - 1`, not `< countof`: the original compares against 249 + if (count <= countof(DAT_SkMasters2Data::instance.entries) - 1) { + DAT_SkMasters2Data::instance.entries[count] = DAT_SkMasters2Data::instance.entries[count - 1]; + } + } + DAT_SkMasters2Data::instance.entries[insertIndex] = DAT_SkMasterDataEntry::instance; + if (DAT_SkMasters2Data::instance.count < countof(DAT_SkMasters2Data::instance.entries)) { + DAT_SkMasters2Data::instance.count++; + } + MACRO_CALL(IO_Func::WriteSkMasters2)(); + } + +} // namespace Game +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8949983360..3979d6cc00 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35565,7 +35565,7 @@ SHC_3BB0A8C1_0x004D5010 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D5180 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D52A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D52A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D5370 | 100.0% | Reimplemented From 81807a0d685d527e52899d6fc4a2ab3cc2754573 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:05 +0100 Subject: [PATCH 03/16] reimplement: SHC_3BB0A8C1_0x004D9400 100.0% | Reimplemented (counted: only the labels of two array[-1] addresses differ) Skirmish::Skirmish_PrepareLeaderboardView. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 99.1 / 97.6. The only differences are the symbol names reccmp gives two addresses just before an array (INT_ARRAY_00eb0e48 and INT_ARRAY_00ed2be0 indexed from -1): I::instance and I::instance in the original, a resolver instance and a resolver initializer in ours. Instructions, operands and offsets are the same. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../Skirmish_PrepareLeaderboardView.cpp | 132 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp diff --git a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp new file mode 100644 index 0000000000..b8c0695f38 --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp @@ -0,0 +1,132 @@ +#include "../Skirmish.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" + +#include "OpenSHC/Globals/DAT_00ed3124.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SkMasters2Data.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/INT_00eb9b60.hpp" +#include "OpenSHC/Globals/INT_00ed2bdc.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00eb0e48.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00eb96d8.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed27f0.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed2be0.hpp" + +namespace OpenSHC { +namespace Game { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D9400 + void Skirmish::Skirmish_PrepareLeaderboardView() + { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + INT_ARRAY_00eb0e48::instance[i] = 1; + } + // filter 1 hides the custom maps (no trail mission score), filter 2 the trail missions + if (DAT_00ed3124::instance == 1) { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (!DAT_SkMasters2Data::instance.entries[i].score) { + INT_ARRAY_00eb0e48::instance[i] = 0; + } + } + } else if (DAT_00ed3124::instance == 2) { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (DAT_SkMasters2Data::instance.entries[i].score) { + INT_ARRAY_00eb0e48::instance[i] = 0; + } + } + } + // columns 0 and 1 keep the stored order, forwards or backwards + if (DAT_MissionDefinedData::instance.sortColumn <= 1) { + INT_00eb9b60::instance = 0; + if (DAT_MissionDefinedData::instance.descending == 1) { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + INT_ARRAY_00eb96d8::instance[INT_00eb9b60::instance] = i; + INT_00eb9b60::instance++; + } + } + } else if (!DAT_MissionDefinedData::instance.descending) { + for (int k = 0; k < DAT_SkMasters2Data::instance.count; k++) { + int const i = DAT_SkMasters2Data::instance.count - 1 - k; + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + INT_ARRAY_00eb96d8::instance[INT_00eb9b60::instance] = i; + INT_00eb9b60::instance++; + } + } + } + return; + } + // date + if (DAT_MissionDefinedData::instance.sortColumn == 4) { + INT_00eb9b60::instance = 0; + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; + INT_ARRAY_00ed2be0::instance[INT_00eb9b60::instance] + = ((DAT_SkMasters2Data::instance.entries[i].localTimeYear - 2000) * 16 + + DAT_SkMasters2Data::instance.entries[i].localTimeMonth) + * 32 + + DAT_SkMasters2Data::instance.entries[i].localTimeDay; + INT_00eb9b60::instance++; + } + } + MACRO_CALL(Game::Skirmish_Func::Skirmish_SortAIOpponentOrder)(DAT_MissionDefinedData::instance.descending); + return; + } + // mission: trail missions by score, custom maps by the first two letters of their name + if (DAT_MissionDefinedData::instance.sortColumn == 2) { + INT_00eb9b60::instance = 0; + if (DAT_00ed3124::instance == 1) { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; + INT_ARRAY_00ed2be0::instance[INT_00eb9b60::instance] + = 80 - DAT_SkMasters2Data::instance.entries[i].score; + INT_00eb9b60::instance++; + } + } + } else { + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + OpenSHC::IO::SkMasterDataEntry& entry = DAT_SkMasters2Data::instance.entries[i]; + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + if (entry.score) { + strcpy(entry.mapName, + MACRO_CALL_MEMBER(Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(DE::SHCDE::TEXT_TRAIL_NAMES_CRU, entry.score)); + } + byte first = entry.mapName[0]; + if (first >= 'A' && first <= 'Z') { + first += 'a' - 'A'; + } + byte second = entry.mapName[1]; + if (second >= 'A' && second <= 'Z') { + second += 'a' - 'A'; + } + INT_ARRAY_00ed2be0::instance[INT_00eb9b60::instance] = -1 - first * 256 - second; + INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; + INT_00eb9b60::instance++; + } + } + } + MACRO_CALL(Game::Skirmish_Func::Skirmish_SortAIOpponentOrder)(DAT_MissionDefinedData::instance.descending); + return; + } + // duration + if (DAT_MissionDefinedData::instance.sortColumn == 3) { + INT_00eb9b60::instance = 0; + for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { + if (INT_ARRAY_00eb0e48::instance[i] != 0) { + INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; + INT_ARRAY_00ed2be0::instance[INT_00eb9b60::instance] + = -1 - DAT_SkMasters2Data::instance.entries[i].gameDurationInMinutes; + INT_00eb9b60::instance++; + } + } + MACRO_CALL(Game::Skirmish_Func::Skirmish_SortAIOpponentOrder)(DAT_MissionDefinedData::instance.descending); + } + } + +} // namespace Game +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3979d6cc00..4ad285a267 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36023,7 +36023,7 @@ SHC_3BB0A8C1_0x004D9270 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D9290 | 100.0% | Reimplemented (counted: only memset/_stricmp call labels and the instance[i - 1] address label differ) -SHC_3BB0A8C1_0x004D9400 | 0.0% | Pending +SHC_3BB0A8C1_0x004D9400 | 100.0% | Reimplemented (counted: only the labels of two array[-1] addresses differ) SHC_3BB0A8C1_0x004D9520 | 0.0% | Pending From 05f23bd989eee3d5801b72459ad4992ad5c01210 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:05 +0100 Subject: [PATCH 04/16] reimplement: SHC_3BB0A8C1_0x004BD800 100.0% | Reimplemented Game::Tutorial_IsActionAllowed. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp | 100 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp diff --git a/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp b/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp new file mode 100644 index 0000000000..c30b65ac0c --- /dev/null +++ b/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp @@ -0,0 +1,100 @@ +#include "../Game.func.hpp" + +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df5560.hpp" +#include "OpenSHC/Globals/DAT_00df5590.hpp" +#include "OpenSHC/Globals/DAT_DisableTutorialRestrictions.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" + +namespace OpenSHC { + +using WindowsHelper::Enums::BOOLEnum; + +/* + Tells whether the tutorial allows an action at its current step. Everything is allowed when the tutorial + restrictions are off. Action types 3 and 4 change the rations and the taxes; the tutorial step decides which + setting the player has to pick. No enums exist yet for the action types and their parameters. + */ +// FUNCTION: STRONGHOLDCRUSADER 0x004BD800 +BOOLEnum Game::Tutorial_IsActionAllowed(undefined4 actionType, int actionParam) +{ + if (DAT_DisableTutorialRestrictions::instance) { + return TRUE; + } + switch (actionType) { + case 1: + if (DAT_TutorialCurrentStep::instance == 2) { + if (DAT_00df5558::instance < 2 && actionParam == 40) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 5) { + if (DAT_00df5558::instance == 0 && actionParam == 19) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 17) { + if (actionParam == 3 && DAT_00df5560::instance == 0) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 21) { + if (actionParam == 7) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 24) { + if (actionParam == 1) { + return TRUE; + } + } + return FALSE; + case 2: + if (DAT_TutorialCurrentStep::instance == 2) { + if (DAT_00df5558::instance < 2 && actionParam == 40) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 5) { + if (DAT_00df5558::instance == 0 && actionParam == 19 && DAT_00df5560::instance == 0) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 17) { + // the global is unsigned, the original compares it signed + if (actionParam == 3 && (int)DAT_00df5590::instance < 4) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 21) { + if (actionParam == 7 && (int)DAT_00df5590::instance < 4) { + return TRUE; + } + } else if (DAT_TutorialCurrentStep::instance == 24) { + if (actionParam == 1 && DAT_00df5560::instance == 0) { + return TRUE; + } + } + return FALSE; + case 3: + if (DAT_TutorialCurrentStep::instance != 8) { + return FALSE; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID].rationsSetting + == 4 + && actionParam != 4) { + return FALSE; + } + break; + case 4: + if (DAT_TutorialCurrentStep::instance != 10) { + return FALSE; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID].taxesSetting + == 7 + && actionParam != 7) { + return FALSE; + } + break; + } + return TRUE; +} + +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4ad285a267..712cf00015 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30243,7 +30243,7 @@ SHC_3BB0A8C1_0x004BD7F0 | 0.0% | Pending SHC_3BB0A8C1_0x004BD7F4 | 0.0% | Pending -SHC_3BB0A8C1_0x004BD800 | 0.0% | Pending +SHC_3BB0A8C1_0x004BD800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BD970 | 0.0% | Pending From 9e44feb58f0c0d75042d9ae2073e699f10a6bf31 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:29 +0100 Subject: [PATCH 05/16] reimplement: SHC_3BB0A8C1_0x004BC110 100.0% | Reimplemented MapPropertiesState::adjustEventMonthAndYearForSection1047. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../adjustEventMonthAndYearForSection1047.cpp | 41 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp diff --git a/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp b/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp new file mode 100644 index 0000000000..4a103c9e98 --- /dev/null +++ b/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp @@ -0,0 +1,41 @@ +#include "../MapPropertiesState.func.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BC110 + void MapPropertiesState::adjustEventMonthAndYearForSection1047() + { + DAT_GameState::instance.mapAndTime.militaryCampaignStage = 0; + DAT_GameState::instance.mapAndTime.monthCopy = (short)DAT_GameState::instance.mapAndTime.month; + DAT_GameState::instance.mapAndTime.field3183_0x27dc = 0; + DAT_GameState::instance.mapAndTime.militaryCampaignFlags = 0; + DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + if (DAT_GameCore::instance.missionNumber1to20 == 17) { + DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 1); + } else if (DAT_GameCore::instance.missionNumber1to20 == 18) { + DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 1); + // fixme: unlike the other missions, mission 18 skips the month wrap below + return; + } else if (DAT_GameCore::instance.missionNumber1to20 == 19) { + DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 6); + } else if (DAT_GameCore::instance.missionNumber1to20 == 20) { + DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 3); + } else { + return; + } + if (DAT_GameState::instance.mapAndTime.month >= 12) { + DAT_GameState::instance.mapAndTime.month -= 12; + DAT_GameState::instance.mapAndTime.year++; + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 712cf00015..4e2633789b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29881,7 +29881,7 @@ SHC_3BB0A8C1_0x004BC100 | 0.0% | Pending SHC_3BB0A8C1_0x004BC104 | 0.0% | Pending -SHC_3BB0A8C1_0x004BC110 | 0.0% | Pending +SHC_3BB0A8C1_0x004BC110 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BC1C0 | 100.0% | Pending From 0ca22f51f4af4ef9381e3e9d7895e9746776d755 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:30 +0100 Subject: [PATCH 06/16] reimplement: SHC_3BB0A8C1_0x004C6820 100.0% | Reimplemented MapPropertiesState::loadMapSiegeHeaderForMissionIndex. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 87.0 / 100.0. The raw difference is only the relative offsets of the four tail jumps to loadMapSiegeHeaderSections (0x004C3110). The header declares the mission number as char*; the file keeps that type and says so in a fixme. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../loadMapSiegeHeaderForMissionIndex.cpp | 40 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp diff --git a/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp b/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp new file mode 100644 index 0000000000..4e116f8ced --- /dev/null +++ b/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp @@ -0,0 +1,40 @@ +#include "../MapPropertiesState.func.hpp" + +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + /* + Loads the siege header sections of the map for a 1-based mission number (1-20). The map names are a list of + char* that starts at MissionAestheticsDefinedData.field_0x3c. Does nothing when the number is out of range. + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004C6820 + void MapPropertiesState::loadMapSiegeHeaderForMissionIndex(char* missionNumber) + { + // fixme: the header declares the mission number as char*, it is an int + missionNumber--; + // the original tests each group of five missions on its own, with the same call in every branch + if ((int)missionNumber < 5) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderSections, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[(int)missionNumber]); + return; + } + if ((int)missionNumber < 10) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderSections, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[(int)missionNumber]); + return; + } + if ((int)missionNumber < 15) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderSections, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[(int)missionNumber]); + return; + } + if ((int)missionNumber < 20) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderSections, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[(int)missionNumber]); + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4e2633789b..dfb19db03b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -34143,7 +34143,7 @@ SHC_3BB0A8C1_0x004C62A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C62C0 | 0.0% | Pending -SHC_3BB0A8C1_0x004C6820 | 0.0% | Pending +SHC_3BB0A8C1_0x004C6820 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C6880 | 0.0% | Pending From e97106201fea2f42c75de9c6dfaba0a6217e298b Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:30 +0100 Subject: [PATCH 07/16] reimplement: SHC_3BB0A8C1_0x004C6880 100.0% | Reimplemented MapPropertiesState::loadMissionMapAndSetLord. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../loadMissionMapAndSetLord.cpp | 38 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp diff --git a/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp b/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp new file mode 100644 index 0000000000..93675daa38 --- /dev/null +++ b/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp @@ -0,0 +1,38 @@ +#include "../MapPropertiesState.func.hpp" + +#include "OpenSHC/Map/Units/UnitsState.func.hpp" + +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" + +namespace OpenSHC { +namespace Map { + + /* + Loads the map of a 1-based mission number (1-20), then sets up the lord for that mission. The map names are a + list of char* that starts at MissionAestheticsDefinedData.field_0x3c. + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004C6880 + void MapPropertiesState::loadMissionMapAndSetLord(int missionNumber) + { + missionNumber--; + // the original tests each group of five missions on its own, with the same call in every branch + if (missionNumber < 5) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMap, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[missionNumber]); + } else if (missionNumber < 10) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMap, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[missionNumber]); + } else if (missionNumber < 15) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMap, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[missionNumber]); + } else if (missionNumber < 20) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMap, this)( + (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[missionNumber]); + } + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::setMissionNumberSpecificLord, DAT_UnitsState::ptr)( + missionNumber + 1); + } + +} // namespace Map +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index dfb19db03b..b7981dbb10 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -34145,7 +34145,7 @@ SHC_3BB0A8C1_0x004C62C0 | 0.0% | Pending SHC_3BB0A8C1_0x004C6820 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004C6880 | 0.0% | Pending +SHC_3BB0A8C1_0x004C6880 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C68D0 | 0.0% | Pending From 524a69d344573338ec4ecd380fc6e91321eaa666 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 15:46:31 +0100 Subject: [PATCH 08/16] reimplement: SHC_3BB0A8C1_0x004C6B20 100.0% | Reimplemented Synchrony::LoadSkirmishCampaignData. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 46f21c5b9 with a full build of the eight files of this PR and reccmp: 100.0 / 100.0. The two string copies are strcpy, the clear of the player names uses sizeof, and the Ghidra locals are named. Three loops stay do-while: as for-loops MSVC compiles the slot reset to a different loop and unrolls the two team loops, which the original does not. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../Synchrony/LoadSkirmishCampaignData.cpp | 97 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp diff --git a/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp b/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp new file mode 100644 index 0000000000..75f1b9c289 --- /dev/null +++ b/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp @@ -0,0 +1,97 @@ +#include "../Synchrony.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/CampaignTrailMission.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/CHAR_ARRAY_00eb0ab0.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_SkirmishDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +namespace OpenSHC { + +using Game::CampaignTrailMission; + +// FUNCTION: STRONGHOLDCRUSADER 0x004C6B20 +void Synchrony::LoadSkirmishCampaignData(int missionID) +{ + CampaignTrailMission* mission = &DAT_SkirmishDefinedData::instance.SkirmishTrailMissions[missionID]; + if (DAT_GameCore::instance.currentTrailType == Game::TT_EXTREME) { + mission = &DAT_SkirmishDefinedData::instance.ExtremeTrailMissions[missionID]; + } else if (DAT_GameCore::instance.currentTrailType == Game::TT_WARCHEST) { + mission = &DAT_SkirmishDefinedData::instance.WarchestTrailMissions[missionID]; + } + strcpy(CHAR_ARRAY_00eb0ab0::instance, (char*)mission->mapNameAddress); + MACRO_CALL(OS_Func::_memset)( + DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); + // do-while: a for-loop here compiles to a different loop than the original + int player = 0; + do { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] = -1; + DAT_GameSynchronyState::instance.currentAIArray[player] = 0; + DAT_GameSynchronyState::instance.aiVariationArray[player] = -1; + player++; + } while (player < countof(DAT_GameSynchronyState::instance.currentAIArray)); + strcpy(DAT_GameSynchronyState::instance.DAT_PlayerNames[1], + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); + DAT_GameSynchronyState::instance.isHost = TRUE; + DAT_GameSynchronyState::instance.currentGameMode = Game::GM_SKIRMISH_SINGLE_PLAYER; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + // the mission lists the AI of every player after the first, which is the human + for (int i = 1; i < mission->numberOfPlayers; i++) { + DAT_GameSynchronyState::instance.currentAIArray[i + 1] = (&mission->player1AI)[i]; + MACRO_CALL(Synchrony_Func::ResetAiVariationArrayValue)(i + 1); + } + MACRO_CALL(Synchrony_Func::SetAIPlayerNickNames)(); + int const players = mission->numberOfPlayers; + for (int i = 0; i < 8; i++) { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i + 1] = (char)(&mission->team1)[i]; + if (i >= players) { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i + 1] = -1; + } + } + // players in a group play as that team; the others each get a team of their own after the highest group + // do-while: a for-loop here is unrolled by the compiler, the original is not + int highestTeam = 0; + int playerID = 1; + do { + char const group = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID]; + DAT_GameState::instance.mapAndTime.playerGroupArray[playerID] = group; + if (group > 0) { + DAT_GameState::instance.mapAndTime.playerTeams[playerID] = group; + if (group > highestTeam) { + highestTeam = group; + } + } + playerID++; + } while (playerID < 9); + playerID = 1; + do { + if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID] == 0) { + highestTeam++; + DAT_GameState::instance.mapAndTime.playerTeams[playerID] = highestTeam; + } + playerID++; + } while (playerID < 9); + DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = mission->fairness; + DAT_GameSynchronyState::instance.skirmishGameIntensityType = mission->startLevels; + memset(DAT_GameSynchronyState::instance.playerPositionsArray, -10, + sizeof(DAT_GameSynchronyState::instance.playerPositionsArray)); + // position N of the map goes to the player that lists it + for (int i = 0; i < 8; i++) { + if ((&mission->position1)[i] != 0) { + DAT_GameSynchronyState::instance.playerPositionsArray[(&mission->position1)[i] - 1] = (char)i; + } + } +} + +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b7981dbb10..98e31de74a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -34149,7 +34149,7 @@ SHC_3BB0A8C1_0x004C6880 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C68D0 | 0.0% | Pending -SHC_3BB0A8C1_0x004C6B20 | 0.0% | Pending +SHC_3BB0A8C1_0x004C6B20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C6B90 | 0.0% | Pending From ef64ff885d9e1cf70fbae801e7813d7747b54067 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 16:02:52 +0100 Subject: [PATCH 09/16] reimplement: SHC_3BB0A8C1_0x00490060 99.3% | Register allocation differs SkirmishLobbySetupStructure::restoreSkirmishLobbySetup. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 592a17d94 with a full build of the ten files of this PR (plus IO/ResourceManager/paths.cpp as a callee for the link) and reccmp: 99.3 / 95.2. The only difference is the operand order of one byte store, mov byte ptr [eax + esi], dl in the original against [esi + eax] in ours: the same address, so no change in behaviour. The two unrolled copy loops are for-loops with countof; MSVC unrolls them as the original. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../restoreSkirmishLobbySetup.cpp | 59 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp diff --git a/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp b/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp new file mode 100644 index 0000000000..3b93dafa85 --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp @@ -0,0 +1,59 @@ +#include "../SkirmishLobbySetupStructure.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/INT_00b960b0.hpp" + +namespace OpenSHC { +namespace Game { + namespace Skirmish { + + /* + Copies the skirmish lobby settings that were saved in this structure back into the synchrony state and the + game core, then lets the synchrony state reorder the teams and positions. + */ + // FUNCTION: STRONGHOLDCRUSADER 0x00490060 + void SkirmishLobbySetupStructure::restoreSkirmishLobbySetup() + { + DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes = this->mapu4int2; + this->mbr_0x4 = DAT_GameState::instance.mapAndTime.skirmishFogOfWar; + strcpy(DAT_GameSynchronyState::instance.mapName, this->mapName); + for (int i = 0; i < countof(this->currentAIArray); i++) { + DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[i] = this->roundTableOrderArray[i]; + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i] = this->playerGroupArray[i]; + DAT_GameSynchronyState::instance.currentAIArray[i] = this->currentAIArray[i]; + DAT_GameSynchronyState::instance.aiVariationArray[i] = this->aiVariationArray[i]; + } + DAT_GameSynchronyState::instance.playerPositionsArray[0] = this->slot1Position; + DAT_GameSynchronyState::instance.playerPositionsArray[1] = this->slot2Position; + DAT_GameSynchronyState::instance.playerPositionsArray[2] = this->slot3Position; + DAT_GameSynchronyState::instance.playerPositionsArray[3] = this->slot4Position; + DAT_GameSynchronyState::instance.playerPositionsArray[4] = this->slot5Position; + DAT_GameSynchronyState::instance.playerPositionsArray[5] = this->slot6Position; + DAT_GameSynchronyState::instance.playerPositionsArray[6] = this->slot7Position; + DAT_GameSynchronyState::instance.playerPositionsArray[7] = this->slot8Position; + DAT_GameSynchronyState::instance.currentPlayerSlotID = this->currentPlayerSlotID; + DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = this->currentAdvantageBalance; + DAT_GameSynchronyState::instance.skirmishGameIntensityType = this->currentAdvantageGroup; + DAT_GameSynchronyState::instance.skirmishTechLevel = this->mbr_0x80; + for (int i = 0; i < countof(this->playerLordTypeArray); i++) { + DAT_GameCore::instance.selectedLordTypes[i] = this->playerLordTypeArray[i]; + } + DAT_GameCore::instance.field_0x2340 = this->mbr_0xf0; + DAT_GameCore::instance.selectedLordTypeUnk = this->selectedLordType; + DAT_GameSynchronyState::instance.skirmishDefaultPopularity = this->popularity; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = this->mapSelectionRelativeSelected; + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = this->mapSelectionScrollOffset; + DAT_GameSynchronyState::instance.lobbyMapSortOrder = this->mbr_0xfc; + INT_00b960b0::instance = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + MACRO_CALL_MEMBER( + Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, DAT_GameSynchronyState::ptr)(); + } + + } // namespace Skirmish +} // namespace Game +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 98e31de74a..b8365dca35 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23369,7 +23369,7 @@ SHC_3BB0A8C1_0x0048FCB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0048FFD0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00490060 | 0.0% | Pending +SHC_3BB0A8C1_0x00490060 | 99.3% | Register allocation differs SHC_3BB0A8C1_0x00490080 | 0.0% | Pending From 0f55507f2dcf91e601a09e129dfb198394969bd1 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 16:02:53 +0100 Subject: [PATCH 10/16] reimplement: SHC_3BB0A8C1_0x004968A0 93.1% | Register allocation differs MenuTextInputState::loadOrSaveGame. Text from draft #525 (reimpl/mission-skirmish-flow), with the style pass from REIMPLEMENTATION_STYLE_GUIDE.md. Measured on main 592a17d94 with a full build of the ten files of this PR (plus IO/ResourceManager/paths.cpp as a callee for the link) and reccmp: 93.1 / 93.5. The original keeps the constant 16 in ebp and uses it for both std::string capacity checks and the fileListVisibleRowCount store; ours uses the immediate each time. The rest follows from that: the longer immediate encodings shift the relative jump offsets, the loop's alignment filler is a jmp over padding instead of lea esp, [esp], and the call and handler targets differ only as labels. No change in behaviour. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../UI/MenuTextInputState/loadOrSaveGame.cpp | 121 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp diff --git a/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp b/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp new file mode 100644 index 0000000000..bb94ab5e56 --- /dev/null +++ b/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp @@ -0,0 +1,121 @@ +#include "../MenuTextInputState.func.hpp" + +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuItems/SaveLoadMap.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_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/INT_00b95b64.hpp" +#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" + +namespace OpenSHC { +namespace UI { + + /* + Opens the load (action 9) or save (action 10) dialog: lists the saved games (*.sav, or *.msv in multiplayer), + resets the list view and restores the last selection of that dialog. No enum exists yet for the actions. + */ + // FUNCTION: STRONGHOLDCRUSADER 0x004968A0 + void MenuTextInputState::loadOrSaveGame(int action) + { + if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.saveRelated == 1 && action == 10) { + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, this)(); + return; + } + DAT_MouseState::instance.waitCursorToggle = 1; + MACRO_CALL(UI::Helpers_Func::SetCursorDependingOnProgramState)(); + MACRO_CALL(OS_Func::_memset)( + DAT_MinimapViewState::instance.loadedMiniMap, 0, sizeof(DAT_MinimapViewState::instance.loadedMiniMap)); + INT_00b95b64::instance = 1; + if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER) { + std::string savesPath(DAT_ResourceManager::instance.paths_getSavesPath(true)); + savesPath.append("*.msv", 5); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::discoverMapFiles, DAT_ResourceManager::ptr)(savesPath.c_str()); + this->fileListEntryCount = DAT_ResourceManager::instance.mapFileCounter; + for (int i = 0; i < DAT_ResourceManager::instance.mapFileCounter; i++) { + this->DAT_ArrayOfMapIndices[i] = i; + // fixme: the original writes one entry before index i, so i = 0 writes the field before the array + this->DAT_ArrayOfMapIndices2[i - 1] = 1; + if (action != 10) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = i; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + (Commands::GameCommandType)(Commands::GCT_LOAD_MAP_HEADER + | Commands::GCT_MULTIPLAYER_INITIATE_ANNOUNCE_HOST)); + } + } + } else { + std::string savesPath(DAT_ResourceManager::instance.paths_getSavesPath(true)); + savesPath.append("*.sav", 5); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::discoverMapFiles, DAT_ResourceManager::ptr)(savesPath.c_str()); + this->fileListEntryCount = DAT_ResourceManager::instance.mapFileCounter; + for (int i = 0; i < DAT_ResourceManager::instance.mapFileCounter; i++) { + this->DAT_ArrayOfMapIndices[i] = i; + } + } + DAT_MouseState::instance.waitCursorToggle = 0; + this->fileListSortOrder = 0; + this->menuLoadGameRelativeSelectionOffset = 0; + if (!this->fileListEntryCount) { + this->menuLoadGameRelativeSelectionIndex = -1; + } else { + this->menuLoadGameRelativeSelectionIndex = 0; + } + this->lastListClickTime = 0; + this->lastClickedListIndex = -1; + this->DAT_ArrayOfMapU3EndInt2 = 0; + this->previewedListIndex = -1; + this->fileListVisibleRowCount = 16; + if (action == 9) { + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, this)( + UI::Enums::MMT_LOAD_MAP); + this->fileListContext = 1; + // restore where the list was left, unless that is past its end now + if (this->menuLoadGameRelativeSelectionIndex != -1) { + this->menuLoadGameRelativeSelectionIndex = this->savedListSelection1; + this->menuLoadGameRelativeSelectionOffset = this->savedListOffset1; + this->fileListSortOrder = this->savedListSortOrder1; + if (this->menuLoadGameRelativeSelectionOffset + this->menuLoadGameRelativeSelectionIndex + >= this->fileListEntryCount) { + this->menuLoadGameRelativeSelectionIndex = 0; + this->menuLoadGameRelativeSelectionOffset = 0; + } + } + } else { + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, this)( + UI::Enums::MMT_SAVE_MAP); + DAT_UserTextHandlerState::instance.allowUserTextInput = 0; + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(2); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::moveCursorToEnd, DAT_UserTextHandlerState::ptr)(); + DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + this->fileListContext = 3; + // restore where the list was left, unless that is past its end now + if (this->menuLoadGameRelativeSelectionIndex != -1) { + this->menuLoadGameRelativeSelectionIndex = this->savedListSelection2; + this->menuLoadGameRelativeSelectionOffset = this->savedListOffset2; + this->fileListSortOrder = this->savedListSortOrder2; + if (this->menuLoadGameRelativeSelectionOffset + this->menuLoadGameRelativeSelectionIndex + >= this->fileListEntryCount) { + this->menuLoadGameRelativeSelectionOffset = 0; + this->menuLoadGameRelativeSelectionIndex = 0; + } + } + } + MACRO_CALL(UI::MenuItems::SaveLoadMap_Func::MenuItemActionHandler_SaveLoadMap_TableHeader)( + -1 - this->fileListSortOrder); + } + +} // namespace UI +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b8365dca35..a623de930a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -24233,7 +24233,7 @@ SHC_3BB0A8C1_0x00495A30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00496400 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004968A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004968A0 | 93.1% | Register allocation differs SHC_3BB0A8C1_0x00496B80 | 100.0% | Reimplemented From 357a5cd5899720a183e6f559c10818e93a633af6 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:12:02 +0100 Subject: [PATCH 11/16] enum: add Game::Skirmish::Enums::LeaderboardFilter The filter of the skirmish rankings (DAT_00ed3124 while the rankings are open). The values follow the buttons that set them in MenuItemActionHandler_RankingGames_Main: 1 is "Crusader Trail Only", 2 is "Custom Games Only", 0 is "All Games". Used by Skirmish_PrepareLeaderboardView. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../Game/Skirmish/Enums/LeaderboardFilter.hpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp new file mode 100644 index 0000000000..90e8c1c120 --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp @@ -0,0 +1,27 @@ +/** + THIS FILE IS AUTO GENERATED + Communicate changes to the dev team (e.g. via a Pull Request). + Changes get lost otherwise. + + path: 'OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace Game { + namespace Skirmish { + namespace Enums { + typedef enum LeaderboardFilter { + + LF_ALL_GAMES = 0, // 0x00000000 + LF_CRUSADER_TRAIL_ONLY = 1, // 0x00000001 + LF_CUSTOM_GAMES_ONLY = 2 // 0x00000002 + + } LeaderboardFilter; + + static_assert_cpp98_obj(sizeof(LeaderboardFilter) == 4, LeaderboardFilter); + } // namespace Enums + } // namespace Skirmish +} // namespace Game +} // namespace OpenSHC From 0b5f1d552a47c3ee5e867fc9cd0f9d2decf1b2b9 Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:12:02 +0100 Subject: [PATCH 12/16] enum: add Game::Skirmish::Enums::LeaderboardSortColumn The sort column of the skirmish rankings (MissionDefinedData.sortColumn). Skirmish_PrepareLeaderboardView sorts column 2 by mission, 3 by game duration and 4 by date. Columns 0 and 1 both keep the stored order (by score), so they stay unknown for now. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../Skirmish/Enums/LeaderboardSortColumn.hpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp new file mode 100644 index 0000000000..9a31f6e4ae --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp @@ -0,0 +1,29 @@ +/** + THIS FILE IS AUTO GENERATED + Communicate changes to the dev team (e.g. via a Pull Request). + Changes get lost otherwise. + + path: 'OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace Game { + namespace Skirmish { + namespace Enums { + typedef enum LeaderboardSortColumn { + + LSC_UNKNOWN_0 = 0, // 0x00000000 + LSC_UNKNOWN_1 = 1, // 0x00000001 + LSC_MISSION = 2, // 0x00000002 + LSC_DURATION = 3, // 0x00000003 + LSC_DATE = 4 // 0x00000004 + + } LeaderboardSortColumn; + + static_assert_cpp98_obj(sizeof(LeaderboardSortColumn) == 4, LeaderboardSortColumn); + } // namespace Enums + } // namespace Skirmish +} // namespace Game +} // namespace OpenSHC From 319d2a99aa35773b6914ff697524d2d1e67d645f Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:12:02 +0100 Subject: [PATCH 13/16] enum: add Game::Enums::TutorialActionType The action type that Tutorial_IsActionAllowed checks. Its callers on main pass 1 when a building is selected in the toolbar (with the building type), 3 when the rations change and 4 when the taxes change. 2 also takes a building type, but none of its callers is reimplemented yet. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- src/OpenSHC/Game/Enums/TutorialActionType.hpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/OpenSHC/Game/Enums/TutorialActionType.hpp diff --git a/src/OpenSHC/Game/Enums/TutorialActionType.hpp b/src/OpenSHC/Game/Enums/TutorialActionType.hpp new file mode 100644 index 0000000000..0c3bf8df1b --- /dev/null +++ b/src/OpenSHC/Game/Enums/TutorialActionType.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/Game/Enums/TutorialActionType.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace Game { + namespace Enums { + typedef enum TutorialActionType { + + TAT_SELECT_BUILDING = 1, // 0x00000001 + TAT_UNKNOWN_2 = 2, // 0x00000002 + TAT_CHANGE_RATIONS = 3, // 0x00000003 + TAT_CHANGE_TAXES = 4 // 0x00000004 + + } TutorialActionType; + + static_assert_cpp98_obj(sizeof(TutorialActionType) == 4, TutorialActionType); + } // namespace Enums +} // namespace Game +} // namespace OpenSHC From 15c1aeb2b87e654e716aa92a5567336e228f530c Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:12:03 +0100 Subject: [PATCH 14/16] review: pre-review pass for TheRedDaemon - Enum values instead of numbers: LeaderboardFilter and LeaderboardSortColumn in Skirmish_PrepareLeaderboardView, TutorialActionType and BuildingType in Tutorial_IsActionAllowed, MenuModalType (MMT_LOAD_MAP / MMT_SAVE_MAP) for loadOrSaveGame's action. - TRUE/FALSE for 0/1 fields, and descending == TRUE for the BOOLEnum. - countof bounds in LoadSkirmishCampaignData, and its narrowing casts are gone. - The (short) casts in adjustEventMonthAndYearForSection1047 are gone. - loadOrSaveGame: the save patterns come from string-macros.hpp with +=, and the queued command is (GameCommandType)50 instead of an OR of two unrelated values. - #pragma warning(disable : 4996) for strcpy at the top of the three files that use it. - Unused includes (INT_00ed2bdc, MSVC_SecurityCookie) removed. - The code comments that explained forms kept for the match are gone; the PR thread explains them now. A comment that restated the code is gone too, and so is a speculative fixme on mission 18. Re-measured with a full build and reccmp on main 592a17d94: no score changes. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- .../SkirmishLeaderboard_DeleteEntry.cpp | 1 - .../restoreSkirmishLobbySetup.cpp | 3 ++ .../Skirmish_PrepareLeaderboardView.cpp | 26 +++++++------- .../Game/Skirmish/StoreGameIntoSKMasters.cpp | 1 - src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp | 36 ++++++++++--------- .../adjustEventMonthAndYearForSection1047.cpp | 21 ++++++----- .../loadMapSiegeHeaderForMissionIndex.cpp | 1 - .../loadMissionMapAndSetLord.cpp | 1 - .../Synchrony/LoadSkirmishCampaignData.cpp | 20 +++++------ .../UI/MenuTextInputState/loadOrSaveGame.cpp | 27 +++++++------- 10 files changed, 69 insertions(+), 68 deletions(-) diff --git a/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp b/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp index 3a077a66ea..b2633a8373 100644 --- a/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp +++ b/src/OpenSHC/Game/Skirmish/SkirmishLeaderboard_DeleteEntry.cpp @@ -17,7 +17,6 @@ namespace Game { if (index < 0 || index >= DAT_SkMasters2Data::instance.count) { return; } - // close the gap by moving every later entry up one for (int i = index; i < DAT_SkMasters2Data::instance.count - 1; i++) { DAT_SkMasters2Data::instance.entries[i] = DAT_SkMasters2Data::instance.entries[i + 1]; } diff --git a/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp b/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp index 3b93dafa85..46c0acaf24 100644 --- a/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp +++ b/src/OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure/restoreSkirmishLobbySetup.cpp @@ -1,3 +1,6 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + #include "../SkirmishLobbySetupStructure.func.hpp" #include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" diff --git a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp index b8c0695f38..e71e1cec26 100644 --- a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp +++ b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp @@ -1,14 +1,18 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + #include "../Skirmish.func.hpp" #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp" +#include "OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp" #include "OpenSHC/Globals/DAT_00ed3124.hpp" #include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" #include "OpenSHC/Globals/DAT_SkMasters2Data.hpp" #include "OpenSHC/Globals/DAT_TextManagerObject.hpp" #include "OpenSHC/Globals/INT_00eb9b60.hpp" -#include "OpenSHC/Globals/INT_00ed2bdc.hpp" #include "OpenSHC/Globals/INT_ARRAY_00eb0e48.hpp" #include "OpenSHC/Globals/INT_ARRAY_00eb96d8.hpp" #include "OpenSHC/Globals/INT_ARRAY_00ed27f0.hpp" @@ -23,14 +27,14 @@ namespace Game { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { INT_ARRAY_00eb0e48::instance[i] = 1; } - // filter 1 hides the custom maps (no trail mission score), filter 2 the trail missions - if (DAT_00ed3124::instance == 1) { + // custom games have no trail mission (score 0) + if (DAT_00ed3124::instance == Skirmish::Enums::LF_CRUSADER_TRAIL_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (!DAT_SkMasters2Data::instance.entries[i].score) { INT_ARRAY_00eb0e48::instance[i] = 0; } } - } else if (DAT_00ed3124::instance == 2) { + } else if (DAT_00ed3124::instance == Skirmish::Enums::LF_CUSTOM_GAMES_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (DAT_SkMasters2Data::instance.entries[i].score) { INT_ARRAY_00eb0e48::instance[i] = 0; @@ -38,9 +42,9 @@ namespace Game { } } // columns 0 and 1 keep the stored order, forwards or backwards - if (DAT_MissionDefinedData::instance.sortColumn <= 1) { + if (DAT_MissionDefinedData::instance.sortColumn <= Skirmish::Enums::LSC_UNKNOWN_1) { INT_00eb9b60::instance = 0; - if (DAT_MissionDefinedData::instance.descending == 1) { + if (DAT_MissionDefinedData::instance.descending == TRUE) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { INT_ARRAY_00eb96d8::instance[INT_00eb9b60::instance] = i; @@ -58,8 +62,7 @@ namespace Game { } return; } - // date - if (DAT_MissionDefinedData::instance.sortColumn == 4) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_DATE) { INT_00eb9b60::instance = 0; for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { @@ -76,9 +79,9 @@ namespace Game { return; } // mission: trail missions by score, custom maps by the first two letters of their name - if (DAT_MissionDefinedData::instance.sortColumn == 2) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_MISSION) { INT_00eb9b60::instance = 0; - if (DAT_00ed3124::instance == 1) { + if (DAT_00ed3124::instance == Skirmish::Enums::LF_CRUSADER_TRAIL_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; @@ -113,8 +116,7 @@ namespace Game { MACRO_CALL(Game::Skirmish_Func::Skirmish_SortAIOpponentOrder)(DAT_MissionDefinedData::instance.descending); return; } - // duration - if (DAT_MissionDefinedData::instance.sortColumn == 3) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_DURATION) { INT_00eb9b60::instance = 0; for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { diff --git a/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp b/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp index 66ce116bdb..e29ff56924 100644 --- a/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp +++ b/src/OpenSHC/Game/Skirmish/StoreGameIntoSKMasters.cpp @@ -37,7 +37,6 @@ namespace Game { } // shift the later entries down one; the last one falls off a full table for (; count > insertIndex; count--) { - // `<= countof - 1`, not `< countof`: the original compares against 249 if (count <= countof(DAT_SkMasters2Data::instance.entries) - 1) { DAT_SkMasters2Data::instance.entries[count] = DAT_SkMasters2Data::instance.entries[count - 1]; } diff --git a/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp b/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp index c30b65ac0c..b09039ee05 100644 --- a/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp +++ b/src/OpenSHC/Game/Tutorial_IsActionAllowed.cpp @@ -1,5 +1,7 @@ #include "../Game.func.hpp" +#include "OpenSHC/Game/Enums/TutorialActionType.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_00df5558.hpp" @@ -16,8 +18,8 @@ using WindowsHelper::Enums::BOOLEnum; /* Tells whether the tutorial allows an action at its current step. Everything is allowed when the tutorial - restrictions are off. Action types 3 and 4 change the rations and the taxes; the tutorial step decides which - setting the player has to pick. No enums exist yet for the action types and their parameters. + restrictions are off. For the building actions the parameter is a building type, for the rations and taxes actions + the new setting. */ // FUNCTION: STRONGHOLDCRUSADER 0x004BD800 BOOLEnum Game::Tutorial_IsActionAllowed(undefined4 actionType, int actionParam) @@ -26,54 +28,54 @@ BOOLEnum Game::Tutorial_IsActionAllowed(undefined4 actionType, int actionParam) return TRUE; } switch (actionType) { - case 1: + case Enums::TAT_SELECT_BUILDING: if (DAT_TutorialCurrentStep::instance == 2) { - if (DAT_00df5558::instance < 2 && actionParam == 40) { + if (DAT_00df5558::instance < 2 && actionParam == Map::Buildings::BT_MANORHOUSE) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 5) { - if (DAT_00df5558::instance == 0 && actionParam == 19) { + if (DAT_00df5558::instance == 0 && actionParam == Map::Buildings::BT_GRANARY) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 17) { - if (actionParam == 3 && DAT_00df5560::instance == 0) { + if (actionParam == Map::Buildings::BT_WOODCUTTERSHUT && DAT_00df5560::instance == 0) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 21) { - if (actionParam == 7) { + if (actionParam == Map::Buildings::BT_HUNTERSHUT) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 24) { - if (actionParam == 1) { + if (actionParam == Map::Buildings::BT_HOVEL) { return TRUE; } } return FALSE; - case 2: + case Enums::TAT_UNKNOWN_2: if (DAT_TutorialCurrentStep::instance == 2) { - if (DAT_00df5558::instance < 2 && actionParam == 40) { + if (DAT_00df5558::instance < 2 && actionParam == Map::Buildings::BT_MANORHOUSE) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 5) { - if (DAT_00df5558::instance == 0 && actionParam == 19 && DAT_00df5560::instance == 0) { + if (DAT_00df5558::instance == 0 && actionParam == Map::Buildings::BT_GRANARY + && DAT_00df5560::instance == 0) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 17) { - // the global is unsigned, the original compares it signed - if (actionParam == 3 && (int)DAT_00df5590::instance < 4) { + if (actionParam == Map::Buildings::BT_WOODCUTTERSHUT && (int)DAT_00df5590::instance < 4) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 21) { - if (actionParam == 7 && (int)DAT_00df5590::instance < 4) { + if (actionParam == Map::Buildings::BT_HUNTERSHUT && (int)DAT_00df5590::instance < 4) { return TRUE; } } else if (DAT_TutorialCurrentStep::instance == 24) { - if (actionParam == 1 && DAT_00df5560::instance == 0) { + if (actionParam == Map::Buildings::BT_HOVEL && DAT_00df5560::instance == 0) { return TRUE; } } return FALSE; - case 3: + case Enums::TAT_CHANGE_RATIONS: if (DAT_TutorialCurrentStep::instance != 8) { return FALSE; } @@ -83,7 +85,7 @@ BOOLEnum Game::Tutorial_IsActionAllowed(undefined4 actionType, int actionParam) return FALSE; } break; - case 4: + case Enums::TAT_CHANGE_TAXES: if (DAT_TutorialCurrentStep::instance != 10) { return FALSE; } diff --git a/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp b/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp index 4a103c9e98..8f9a08723c 100644 --- a/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp +++ b/src/OpenSHC/Map/MapPropertiesState/adjustEventMonthAndYearForSection1047.cpp @@ -10,24 +10,23 @@ namespace Map { void MapPropertiesState::adjustEventMonthAndYearForSection1047() { DAT_GameState::instance.mapAndTime.militaryCampaignStage = 0; - DAT_GameState::instance.mapAndTime.monthCopy = (short)DAT_GameState::instance.mapAndTime.month; + DAT_GameState::instance.mapAndTime.monthCopy = DAT_GameState::instance.mapAndTime.month; DAT_GameState::instance.mapAndTime.field3183_0x27dc = 0; DAT_GameState::instance.mapAndTime.militaryCampaignFlags = 0; - DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.yearCopy = DAT_GameState::instance.mapAndTime.year; if (DAT_GameCore::instance.missionNumber1to20 == 17) { - DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; - DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 1); + DAT_GameState::instance.mapAndTime.yearCopy = DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = DAT_GameState::instance.mapAndTime.month + 1; } else if (DAT_GameCore::instance.missionNumber1to20 == 18) { - DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; - DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 1); - // fixme: unlike the other missions, mission 18 skips the month wrap below + DAT_GameState::instance.mapAndTime.yearCopy = DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = DAT_GameState::instance.mapAndTime.month + 1; return; } else if (DAT_GameCore::instance.missionNumber1to20 == 19) { - DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; - DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 6); + DAT_GameState::instance.mapAndTime.yearCopy = DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = DAT_GameState::instance.mapAndTime.month + 6; } else if (DAT_GameCore::instance.missionNumber1to20 == 20) { - DAT_GameState::instance.mapAndTime.yearCopy = (short)DAT_GameState::instance.mapAndTime.year; - DAT_GameState::instance.mapAndTime.monthCopy = (short)(DAT_GameState::instance.mapAndTime.month + 3); + DAT_GameState::instance.mapAndTime.yearCopy = DAT_GameState::instance.mapAndTime.year; + DAT_GameState::instance.mapAndTime.monthCopy = DAT_GameState::instance.mapAndTime.month + 3; } else { return; } diff --git a/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp b/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp index 4e116f8ced..5660d4d238 100644 --- a/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp +++ b/src/OpenSHC/Map/MapPropertiesState/loadMapSiegeHeaderForMissionIndex.cpp @@ -14,7 +14,6 @@ namespace Map { { // fixme: the header declares the mission number as char*, it is an int missionNumber--; - // the original tests each group of five missions on its own, with the same call in every branch if ((int)missionNumber < 5) { MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMapSiegeHeaderSections, this)( (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[(int)missionNumber]); diff --git a/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp b/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp index 93675daa38..674ebf71f8 100644 --- a/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp +++ b/src/OpenSHC/Map/MapPropertiesState/loadMissionMapAndSetLord.cpp @@ -16,7 +16,6 @@ namespace Map { void MapPropertiesState::loadMissionMapAndSetLord(int missionNumber) { missionNumber--; - // the original tests each group of five missions on its own, with the same call in every branch if (missionNumber < 5) { MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::loadMap, this)( (char*)(&DAT_MissionAestheticsDefinedData::instance.field_0x3c)[missionNumber]); diff --git a/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp b/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp index 75f1b9c289..bb532049c9 100644 --- a/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp +++ b/src/OpenSHC/Synchrony/LoadSkirmishCampaignData.cpp @@ -1,3 +1,6 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + #include "../Synchrony.func.hpp" #include "OpenSHC/OS.func.hpp" @@ -32,7 +35,6 @@ void Synchrony::LoadSkirmishCampaignData(int missionID) strcpy(CHAR_ARRAY_00eb0ab0::instance, (char*)mission->mapNameAddress); MACRO_CALL(OS_Func::_memset)( DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); - // do-while: a for-loop here compiles to a different loop than the original int player = 0; do { DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] = -1; @@ -52,15 +54,13 @@ void Synchrony::LoadSkirmishCampaignData(int missionID) MACRO_CALL(Synchrony_Func::ResetAiVariationArrayValue)(i + 1); } MACRO_CALL(Synchrony_Func::SetAIPlayerNickNames)(); - int const players = mission->numberOfPlayers; - for (int i = 0; i < 8; i++) { - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i + 1] = (char)(&mission->team1)[i]; - if (i >= players) { + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray) - 1; i++) { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i + 1] = (&mission->team1)[i]; + if (i >= mission->numberOfPlayers) { DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i + 1] = -1; } } // players in a group play as that team; the others each get a team of their own after the highest group - // do-while: a for-loop here is unrolled by the compiler, the original is not int highestTeam = 0; int playerID = 1; do { @@ -73,7 +73,7 @@ void Synchrony::LoadSkirmishCampaignData(int missionID) } } playerID++; - } while (playerID < 9); + } while (playerID < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray)); playerID = 1; do { if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID] == 0) { @@ -81,15 +81,15 @@ void Synchrony::LoadSkirmishCampaignData(int missionID) DAT_GameState::instance.mapAndTime.playerTeams[playerID] = highestTeam; } playerID++; - } while (playerID < 9); + } while (playerID < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray)); DAT_GameSynchronyState::instance.skirmishCurrentAdvantageBalance = mission->fairness; DAT_GameSynchronyState::instance.skirmishGameIntensityType = mission->startLevels; memset(DAT_GameSynchronyState::instance.playerPositionsArray, -10, sizeof(DAT_GameSynchronyState::instance.playerPositionsArray)); // position N of the map goes to the player that lists it - for (int i = 0; i < 8; i++) { + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.playerPositionsArray); i++) { if ((&mission->position1)[i] != 0) { - DAT_GameSynchronyState::instance.playerPositionsArray[(&mission->position1)[i] - 1] = (char)i; + DAT_GameSynchronyState::instance.playerPositionsArray[(&mission->position1)[i] - 1] = i; } } } diff --git a/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp b/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp index bb94ab5e56..ff26522202 100644 --- a/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp +++ b/src/OpenSHC/UI/MenuTextInputState/loadOrSaveGame.cpp @@ -9,6 +9,7 @@ #include "OpenSHC/Commands/GameCommandType.hpp" #include "OpenSHC/Game/GameMode.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-macros.hpp" #include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" #include "OpenSHC/Globals/DAT_MinimapViewState.hpp" @@ -16,25 +17,24 @@ #include "OpenSHC/Globals/DAT_ResourceManager.hpp" #include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" #include "OpenSHC/Globals/INT_00b95b64.hpp" -#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" namespace OpenSHC { namespace UI { /* - Opens the load (action 9) or save (action 10) dialog: lists the saved games (*.sav, or *.msv in multiplayer), - resets the list view and restores the last selection of that dialog. No enum exists yet for the actions. + Opens the load or save dialog: lists the saved games (*.sav, or *.msv in multiplayer), resets the list view and + restores the last selection of that dialog. */ // FUNCTION: STRONGHOLDCRUSADER 0x004968A0 void MenuTextInputState::loadOrSaveGame(int action) { if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER - && DAT_GameSynchronyState::instance.saveRelated == 1 && action == 10) { + && DAT_GameSynchronyState::instance.saveRelated == 1 && action == UI::Enums::MMT_SAVE_MAP) { MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, this)(); return; } - DAT_MouseState::instance.waitCursorToggle = 1; + DAT_MouseState::instance.waitCursorToggle = TRUE; MACRO_CALL(UI::Helpers_Func::SetCursorDependingOnProgramState)(); MACRO_CALL(OS_Func::_memset)( DAT_MinimapViewState::instance.loadedMiniMap, 0, sizeof(DAT_MinimapViewState::instance.loadedMiniMap)); @@ -42,30 +42,29 @@ namespace UI { if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER) { std::string savesPath(DAT_ResourceManager::instance.paths_getSavesPath(true)); - savesPath.append("*.msv", 5); + savesPath += S__MSV_005A75D4; MACRO_CALL_MEMBER(IO::ResourceManager_Func::discoverMapFiles, DAT_ResourceManager::ptr)(savesPath.c_str()); this->fileListEntryCount = DAT_ResourceManager::instance.mapFileCounter; for (int i = 0; i < DAT_ResourceManager::instance.mapFileCounter; i++) { this->DAT_ArrayOfMapIndices[i] = i; // fixme: the original writes one entry before index i, so i = 0 writes the field before the array this->DAT_ArrayOfMapIndices2[i - 1] = 1; - if (action != 10) { + if (action != UI::Enums::MMT_SAVE_MAP) { DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = i; MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - (Commands::GameCommandType)(Commands::GCT_LOAD_MAP_HEADER - | Commands::GCT_MULTIPLAYER_INITIATE_ANNOUNCE_HOST)); + (Commands::GameCommandType)50); } } } else { std::string savesPath(DAT_ResourceManager::instance.paths_getSavesPath(true)); - savesPath.append("*.sav", 5); + savesPath += S__SAV_005A75CC; MACRO_CALL_MEMBER(IO::ResourceManager_Func::discoverMapFiles, DAT_ResourceManager::ptr)(savesPath.c_str()); this->fileListEntryCount = DAT_ResourceManager::instance.mapFileCounter; for (int i = 0; i < DAT_ResourceManager::instance.mapFileCounter; i++) { this->DAT_ArrayOfMapIndices[i] = i; } } - DAT_MouseState::instance.waitCursorToggle = 0; + DAT_MouseState::instance.waitCursorToggle = FALSE; this->fileListSortOrder = 0; this->menuLoadGameRelativeSelectionOffset = 0; if (!this->fileListEntryCount) { @@ -78,7 +77,7 @@ namespace UI { this->DAT_ArrayOfMapU3EndInt2 = 0; this->previewedListIndex = -1; this->fileListVisibleRowCount = 16; - if (action == 9) { + if (action == UI::Enums::MMT_LOAD_MAP) { MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, this)( UI::Enums::MMT_LOAD_MAP); this->fileListContext = 1; @@ -96,10 +95,10 @@ namespace UI { } else { MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, this)( UI::Enums::MMT_SAVE_MAP); - DAT_UserTextHandlerState::instance.allowUserTextInput = 0; + DAT_UserTextHandlerState::instance.allowUserTextInput = FALSE; MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(2); MACRO_CALL_MEMBER(Text::UserTextHandler_Func::moveCursorToEnd, DAT_UserTextHandlerState::ptr)(); - DAT_UserTextHandlerState::instance.allowUserTextInput = 1; + DAT_UserTextHandlerState::instance.allowUserTextInput = TRUE; this->fileListContext = 3; // restore where the list was left, unless that is past its end now if (this->menuLoadGameRelativeSelectionIndex != -1) { From 84a8769654cc354a419c11f6c9b23469b126e29a Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:14:15 +0100 Subject: [PATCH 15/16] enum: LeaderboardFilter values use the prefix LBF_ LF_ is already the prefix of Map/LogicHelpers/Logic1Flags (LF_NONE). Renamed in the header and in Skirmish_PrepareLeaderboardView; quick_diff output is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp | 6 +++--- .../Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp index 90e8c1c120..009fe8f9c6 100644 --- a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp +++ b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp @@ -14,9 +14,9 @@ namespace Game { namespace Enums { typedef enum LeaderboardFilter { - LF_ALL_GAMES = 0, // 0x00000000 - LF_CRUSADER_TRAIL_ONLY = 1, // 0x00000001 - LF_CUSTOM_GAMES_ONLY = 2 // 0x00000002 + LBF_ALL_GAMES = 0, // 0x00000000 + LBF_CRUSADER_TRAIL_ONLY = 1, // 0x00000001 + LBF_CUSTOM_GAMES_ONLY = 2 // 0x00000002 } LeaderboardFilter; diff --git a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp index e71e1cec26..efd11eb231 100644 --- a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp +++ b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp @@ -28,13 +28,13 @@ namespace Game { INT_ARRAY_00eb0e48::instance[i] = 1; } // custom games have no trail mission (score 0) - if (DAT_00ed3124::instance == Skirmish::Enums::LF_CRUSADER_TRAIL_ONLY) { + if (DAT_00ed3124::instance == Skirmish::Enums::LBF_CRUSADER_TRAIL_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (!DAT_SkMasters2Data::instance.entries[i].score) { INT_ARRAY_00eb0e48::instance[i] = 0; } } - } else if (DAT_00ed3124::instance == Skirmish::Enums::LF_CUSTOM_GAMES_ONLY) { + } else if (DAT_00ed3124::instance == Skirmish::Enums::LBF_CUSTOM_GAMES_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (DAT_SkMasters2Data::instance.entries[i].score) { INT_ARRAY_00eb0e48::instance[i] = 0; @@ -81,7 +81,7 @@ namespace Game { // mission: trail missions by score, custom maps by the first two letters of their name if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_MISSION) { INT_00eb9b60::instance = 0; - if (DAT_00ed3124::instance == Skirmish::Enums::LF_CRUSADER_TRAIL_ONLY) { + if (DAT_00ed3124::instance == Skirmish::Enums::LBF_CRUSADER_TRAIL_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { INT_ARRAY_00ed27f0::instance[INT_00eb9b60::instance] = i; From f48e73f53a5506156f09f6584769a9f87ad2ffbe Mon Sep 17 00:00:00 2001 From: Gynt Date: Fri, 4 Dec 2026 17:24:08 +0100 Subject: [PATCH 16/16] enum: rename LeaderboardFilter / LeaderboardSortColumn to LeaderBoardFilter / LeaderBoardSortColumn The type names now match their value prefixes: LBF_ for LeaderBoardFilter, and LBSC_ (unused on main) instead of LSC_ for LeaderBoardSortColumn. Files, generated path comments, the include and every use in Skirmish_PrepareLeaderboardView are renamed; quick_diff output is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp --- ...rboardFilter.hpp => LeaderBoardFilter.hpp} | 8 ++--- .../Skirmish/Enums/LeaderBoardSortColumn.hpp | 29 +++++++++++++++++++ .../Skirmish/Enums/LeaderboardSortColumn.hpp | 29 ------------------- .../Skirmish_PrepareLeaderboardView.cpp | 12 ++++---- 4 files changed, 39 insertions(+), 39 deletions(-) rename src/OpenSHC/Game/Skirmish/Enums/{LeaderboardFilter.hpp => LeaderBoardFilter.hpp} (68%) create mode 100644 src/OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp delete mode 100644 src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderBoardFilter.hpp similarity index 68% rename from src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp rename to src/OpenSHC/Game/Skirmish/Enums/LeaderBoardFilter.hpp index 009fe8f9c6..6d3f648086 100644 --- a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp +++ b/src/OpenSHC/Game/Skirmish/Enums/LeaderBoardFilter.hpp @@ -3,7 +3,7 @@ Communicate changes to the dev team (e.g. via a Pull Request). Changes get lost otherwise. - path: 'OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp' + path: 'OpenSHC/Game/Skirmish/Enums/LeaderBoardFilter.hpp' */ #pragma once @@ -12,15 +12,15 @@ namespace OpenSHC { namespace Game { namespace Skirmish { namespace Enums { - typedef enum LeaderboardFilter { + typedef enum LeaderBoardFilter { LBF_ALL_GAMES = 0, // 0x00000000 LBF_CRUSADER_TRAIL_ONLY = 1, // 0x00000001 LBF_CUSTOM_GAMES_ONLY = 2 // 0x00000002 - } LeaderboardFilter; + } LeaderBoardFilter; - static_assert_cpp98_obj(sizeof(LeaderboardFilter) == 4, LeaderboardFilter); + static_assert_cpp98_obj(sizeof(LeaderBoardFilter) == 4, LeaderBoardFilter); } // namespace Enums } // namespace Skirmish } // namespace Game diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp new file mode 100644 index 0000000000..782a493f15 --- /dev/null +++ b/src/OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp @@ -0,0 +1,29 @@ +/** + THIS FILE IS AUTO GENERATED + Communicate changes to the dev team (e.g. via a Pull Request). + Changes get lost otherwise. + + path: 'OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace Game { + namespace Skirmish { + namespace Enums { + typedef enum LeaderBoardSortColumn { + + LBSC_UNKNOWN_0 = 0, // 0x00000000 + LBSC_UNKNOWN_1 = 1, // 0x00000001 + LBSC_MISSION = 2, // 0x00000002 + LBSC_DURATION = 3, // 0x00000003 + LBSC_DATE = 4 // 0x00000004 + + } LeaderBoardSortColumn; + + static_assert_cpp98_obj(sizeof(LeaderBoardSortColumn) == 4, LeaderBoardSortColumn); + } // namespace Enums + } // namespace Skirmish +} // namespace Game +} // namespace OpenSHC diff --git a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp b/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp deleted file mode 100644 index 9a31f6e4ae..0000000000 --- a/src/OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/** - THIS FILE IS AUTO GENERATED - Communicate changes to the dev team (e.g. via a Pull Request). - Changes get lost otherwise. - - path: 'OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp' -*/ - -#pragma once - -namespace OpenSHC { -namespace Game { - namespace Skirmish { - namespace Enums { - typedef enum LeaderboardSortColumn { - - LSC_UNKNOWN_0 = 0, // 0x00000000 - LSC_UNKNOWN_1 = 1, // 0x00000001 - LSC_MISSION = 2, // 0x00000002 - LSC_DURATION = 3, // 0x00000003 - LSC_DATE = 4 // 0x00000004 - - } LeaderboardSortColumn; - - static_assert_cpp98_obj(sizeof(LeaderboardSortColumn) == 4, LeaderboardSortColumn); - } // namespace Enums - } // namespace Skirmish -} // namespace Game -} // namespace OpenSHC diff --git a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp index efd11eb231..46c828a573 100644 --- a/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp +++ b/src/OpenSHC/Game/Skirmish/Skirmish_PrepareLeaderboardView.cpp @@ -5,8 +5,8 @@ #include "OpenSHC/Text/TextManager.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Game/Skirmish/Enums/LeaderboardFilter.hpp" -#include "OpenSHC/Game/Skirmish/Enums/LeaderboardSortColumn.hpp" +#include "OpenSHC/Game/Skirmish/Enums/LeaderBoardFilter.hpp" +#include "OpenSHC/Game/Skirmish/Enums/LeaderBoardSortColumn.hpp" #include "OpenSHC/Globals/DAT_00ed3124.hpp" #include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" @@ -42,7 +42,7 @@ namespace Game { } } // columns 0 and 1 keep the stored order, forwards or backwards - if (DAT_MissionDefinedData::instance.sortColumn <= Skirmish::Enums::LSC_UNKNOWN_1) { + if (DAT_MissionDefinedData::instance.sortColumn <= Skirmish::Enums::LBSC_UNKNOWN_1) { INT_00eb9b60::instance = 0; if (DAT_MissionDefinedData::instance.descending == TRUE) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { @@ -62,7 +62,7 @@ namespace Game { } return; } - if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_DATE) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LBSC_DATE) { INT_00eb9b60::instance = 0; for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) { @@ -79,7 +79,7 @@ namespace Game { return; } // mission: trail missions by score, custom maps by the first two letters of their name - if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_MISSION) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LBSC_MISSION) { INT_00eb9b60::instance = 0; if (DAT_00ed3124::instance == Skirmish::Enums::LBF_CRUSADER_TRAIL_ONLY) { for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { @@ -116,7 +116,7 @@ namespace Game { MACRO_CALL(Game::Skirmish_Func::Skirmish_SortAIOpponentOrder)(DAT_MissionDefinedData::instance.descending); return; } - if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LSC_DURATION) { + if (DAT_MissionDefinedData::instance.sortColumn == Skirmish::Enums::LBSC_DURATION) { INT_00eb9b60::instance = 0; for (int i = 0; i < DAT_SkMasters2Data::instance.count; i++) { if (INT_ARRAY_00eb0e48::instance[i] != 0) {