From 282cfeeacb821387cd91be6cae3d86b385dc1f18 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:07 +0100 Subject: [PATCH 01/14] reimplement: SHC_3BB0A8C1_0x004C1070 100.0% Reimplemented MenuItemRenderFunction_TraderSettings, from our draft on the fork branch reimpl/UI-MenuItems-3-development (88.0% there, in #327). Each goods row shows the good's picture and "On" or "Off" (greyed out by blending when off); below 1000 are the dialog's own buttons, 1100 is the "Trader 1" header box and the rest is the goods list box. The "On" and "Off" texts take their position as locals, y then x (in the call: quick_diff 0.9570 -> 0.8865; x first: 0.9140), the draft's register blocker. The four kinds of button are one if/else-if chain with a single RT_MAP_GAME store at the end, which MSVC duplicates into each tail as the original has it (ties with the seven early returns). The parameter is button and the goods index row, as in main's TraderSettings handler; the shadow colours are COL_003E66 and COL_000000; partial pitch's picture is pitch's, with a comment. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_TraderSettings.cpp | 121 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp diff --git a/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp new file mode 100644 index 0000000000..d86dd5ed42 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp @@ -0,0 +1,121 @@ +#include "../TraderSettings.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/RoundedBoxEdgeRoundingLevel.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_BLUE.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C1070 + void TraderSettings::MenuItemRenderFunction_TraderSettings(int button, ...) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // below 0 the goods rows, below 1000 the dialog's buttons, 1100 the trader's name, else the goods list + if (button < 0) { + int const row = -1 - button; + DAT_ButtonCurrentlyInteracting::instance + = DAT_MapPropertiesState::instance.SEC_Section1065 + .tradeabilityArray[DAT_MissionAestheticsDefinedData::instance.field_0x345c[row]] + != FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const resource = DAT_MissionAestheticsDefinedData::instance.field_0x345c[row]; + // Two pictures per good from 141; partial pitch (157) shows the pitch picture (155) + int icon = resource * 2 + 141; + if (icon == 157) { + icon = 155; + } + int const imhIndex = icon + GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2] - 1; + // y then x for the On/Off text (in the call: quick_diff 0.9570 -> 0.8865; x first: 0.9140) + if (DAT_MapPropertiesState::instance.SEC_Section1065.tradeabilityArray[resource]) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, icon, + DAT_ButtonX::instance + 10, + DAT_ButtonY::instance - DAT_GMImageHeaders::instance.imh[imhIndex].height / 2 + 15); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + // "On" + 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_SCENARIO, 172), + textX, textY, OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, icon, + DAT_ButtonX::instance + 10, + DAT_ButtonY::instance - DAT_GMImageHeaders::instance.imh[imhIndex].height / 2 + 15, 16); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + // "Off" + 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_SCENARIO, 173), + textX, textY, OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_7CAAAF, 18, FALSE, 0); + } + } else if (button < 1000) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(button); + } else if (button == 1100) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + OpenSHC::UI::Enums::RBERL_SLIGHT); + // "Trader 1" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_TRADER_NAMES, 1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_00A2FF, + OpenSHC::Rendering::Colors::COL_003E66, 18, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + // "Trader 1" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_TRADER_NAMES, 1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_FFFFFF, + OpenSHC::Rendering::Colors::COL_000000, 18, FALSE); + } + } else if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLUE::instance.shortValue, OpenSHC::UI::Enums::RBERL_SLIGHT); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d195ecb365..642290f8b7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -33187,7 +33187,7 @@ SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending -SHC_3BB0A8C1_0x004C1070 | 0.0% | Pending +SHC_3BB0A8C1_0x004C1070 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004C1320 | 0.0% | Pending From ec602090eea2344724284d96beb4ca46504758fd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:08 +0100 Subject: [PATCH 02/14] reimplement: SHC_3BB0A8C1_0x004ABEB0 100.0% Reimplemented MenuItemActionHandler_EditorMapTypeQuickChange_Main, from our draft on the fork branch reimpl/UI-MenuItems-3-development (94.5% there, in #327). The editor's quick buttons set the map lock state (0 to 2), the map type (3 to 6, unless the map has an event that needs another), single or multiplayer (10, 11), or the map size (20 to 23, MC_MAP_SIZE_*), which resets the map and everything that depends on its size. The parameter is button, as in main's render function of this menu. The map size chain has no else, as in the original: button is 20 to 23 in that case, and the original's unreachable else reads mapSize unset, which MSVC keeps in the parameter's stack slot (`mov eax, [esp + 8]` at 0x004ABF39). An else keeping button measures reccmp 94.5% (the draft); reassigning the parameter instead of a mapSize local: reccmp 89.5%. The sizes are compared in turn (a switch: reccmp 85.5%). For the PR text: an uninitialised read, but only on a path no caller can reach. Co-Authored-By: Claude Opus 5.5 --- ...nHandler_EditorMapTypeQuickChange_Main.cpp | 107 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp new file mode 100644 index 0000000000..d11251caa4 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp @@ -0,0 +1,107 @@ +#include "../EditorMapTypeQuickChange.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/WildlifeState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/Map/MapConstants.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WildlifeState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004ABEB0 + void EditorMapTypeQuickChange::MenuItemActionHandler_EditorMapTypeQuickChange_Main(int button, ...) + { + switch (button) { + case 0: // 0 to 2: editable, playable, mission + case 1: + case 2: + DAT_GameCore::instance.U3_mapLockedState = button; + return; + case 3: + case 4: + case 5: + case 6: + // 3 to 6: siege, invasion, economic, just build + if (!MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::mapHasCertainEvent, DAT_MapPropertiesState::ptr)()) { + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = button - 3; + } + return; + case 10: // single or multiplayer + DAT_GameCore::instance.U2_mapType_singleOrMulti = 0; + return; + case 11: + DAT_GameCore::instance.U2_mapType_singleOrMulti = 1; + return; + case 20: + case 21: + case 22: + case 23: { + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::resetAreaBasedOnLogicalLayer, DAT_TileMapState::ptr)(); + // No else: button is 20 to 23 here (an else keeping button: reccmp 100.0% -> 94.5%) + int mapSize; + // the sizes in turn (a switch: reccmp 100.0% -> 85.5%) + if (button == 20) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_160; + } else if (button == 21) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_200; + } else if (button == 22) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_300; + } else if (button == 23) { + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + } + DAT_TileMapState::instance.mapSize = mapSize; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::resetHeightAndMapBorders, DAT_TileMapState::ptr)( + mapSize); + MACRO_CALL_MEMBER( + OpenSHC::Map::TileMapState_Func::resetAreaBasedOnLogicalLayer, DAT_TileMapState::ptr)(); + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + MACRO_CALL_MEMBER( + OpenSHC::Map::Navigation::PathFindingState_Func::updatePathLinkageLayerForEachBuildingAtEachTile, + DAT_PathFindingState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updateSeparateAreaTileMap, + DAT_PathFindingState::ptr)(1); + MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::updatePathLinkageLayerForAllBuildings, + DAT_BuildingsState::ptr)(); + DAT_TileMapState::instance.forceUpdateMacroLayerFlag = 1; + DAT_TileMapState::instance.field_0x55487c = 200; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::processGameTick, DAT_GameState::ptr)(); + for (int row = 0; row < 40; ++row) { + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlifeGrid, DAT_WildlifeState::ptr)( + row); + } + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateWildlife, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateSection1034Info, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::WildlifeState_Func::updateNofFpoints, DAT_WildlifeState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::setTileColorsDependingOnMapSize, + DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::setMapPropertyDependingOnMapSize, + DAT_MinimapViewState::ptr)(0, 100); + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + return; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 642290f8b7..76a38d9bae 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25631,7 +25631,7 @@ SHC_3BB0A8C1_0x004ABE50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004ABE80 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004ABEB0 | 0.0% | Pending +SHC_3BB0A8C1_0x004ABEB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC008 | 0.0% | Pending From bb03c1593e6476887f26df99aa0895addbad5a09 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:09 +0100 Subject: [PATCH 03/14] reimplement: SHC_3BB0A8C1_0x004B8BF0 100.0% Reimplemented MenuItemRenderFunction_EditScenario_EventAndInvasionList, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 79.5% in #328). One row of the scenario editor's event list: the selection is clamped to the list, the row's background, the event's month and year, and then by its kind an invasion ("Invasion", its unit count and the repeat) or an event (its name and the repeat). The draft returned when an event's text index went past 155. The original adds 21 there and goes on (the event names have 21 other texts after the 28th), so events of those kinds lost their name and repeat in the draft. Both kinds end in "Month" or "Months" written out in each case, with one ")" after the switch: MSVC merges the two if/else copies into the original's one tail (a flag set in both cases and one if after the switch: quick_diff 0.9831 -> 0.7973). The month goes into a local first (in the call: 0.9831 -> 0.9155) and the event name takes its position as y then x locals (0.9696); without them the scratch registers rotate and the copies don't merge. The event index is written out at each use because the original re-reads eventListScrollOffset after every call (an eventID local: 0.6609). The colour is set in each branch (a default overridden: reccmp 100.0% -> 99.3%, which quick_diff can't see: it shows both colour constants as one token). quick_diff's 0.9831 is all artifacts (colour immediates, ret). Co-Authored-By: Claude Opus 5.5 --- ...tion_EditScenario_EventAndInvasionList.cpp | 194 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp new file mode 100644 index 0000000000..0564bccab4 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp @@ -0,0 +1,194 @@ +#include "../EditScenario.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/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.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 0x004B8BF0 + void EditScenario::MenuItemRenderFunction_EditScenario_EventAndInvasionList(int row, ...) + { + if (DAT_MapPropertiesState::instance.eventListSelection >= DAT_MapPropertiesState::instance.eventsCount) { + DAT_MapPropertiesState::instance.eventListSelection = DAT_MapPropertiesState::instance.eventsCount - 1; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, + DAT_PencilRenderCore::ptr)(row == DAT_MapPropertiesState::instance.eventListSelection, row, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + // the event index is re-read after every call (an eventID local: quick_diff 0.9831 -> 0.6609) + if (DAT_MapPropertiesState::instance.eventListScrollOffset + row + >= DAT_MapPropertiesState::instance.eventsCount) { + return; + } + // set in each branch (a default overridden: reccmp 100.0% -> 99.3%) + uint color; + if (row == DAT_MapPropertiesState::instance.eventListSelection + || DAT_ButtonCurrentlyInteracting::instance) { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } else { + color = OpenSHC::Rendering::Colors::COL_C2F0EB; + } + // the month in a local first (in the call: quick_diff 0.9831 -> 0.9155) + int const month = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .header.month; + 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_MONTHS, month), + DAT_ButtonX::instance + 8, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .header.year, + DAT_ButtonX::instance + 40, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // "Month(s)" in each case, merged by MSVC (a flag and one if after the switch: quick_diff 0.9831 -> 0.7973) + switch (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .header.tl_type) { + case 1: { + // an invasion: "Invasion", its unit count and, if it repeats, "(x Month(s))" + // "Invasion" + 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_SCENARIO, 46), + DAT_ButtonX::instance + 80, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, + 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.totalUnitCount, + DAT_ButtonX::instance + 250, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths + == 0) { + return; + } + // "(x" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s__x_005aa7f4, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, TRUE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.invasion.repeatMonths + == 1) { + // "Month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 210, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } else { + // "Months" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 211, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } + break; + } + case 3: { + // an event: its name and, if it repeats, "(x Month(s))" + // the event names start at 128 in the scenario texts, with 21 other texts after the 28th + int textIndex = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.ScenarioEventType + + 128; + if (textIndex > 155) { + textIndex += 21; + } + // y then x for the name (in the call: quick_diff 0.9831 -> 0.9696) + int const nameY = DAT_ButtonY::instance + 4; + int const nameX = DAT_ButtonX::instance + 80; + 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_SCENARIO, textIndex), + nameX, nameY, OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat + == 0) { + return; + } + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths + == 1) { + return; + } + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + // 10 shows no number + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths + != 10) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeatMonths, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, + TRUE); + } + // "x" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_x_005aa7f8, DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat, + DAT_ButtonX::instance + 340, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, color, 18, TRUE, + 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + row] + .data.scenario.repeat + == 1) { + // "Month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 210, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } else { + // "Months" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 211, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, + OpenSHC::Text::TTA_LEFT, color, 18, TRUE); + } + break; + } + default: + return; + } + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, DAT_ButtonX::instance + 346, DAT_ButtonY::instance + 4, OpenSHC::Text::TTA_LEFT, + color, 18, TRUE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 76a38d9bae..b50fe2318d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27521,7 +27521,7 @@ SHC_3BB0A8C1_0x004B8B0C | 0.0% | Pending SHC_3BB0A8C1_0x004B8B10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8BF0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B8BF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B9020 | 100.0% | Reimplemented From be8277d12df8482f2a4b1de9d709bdef6a7a0b8f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:09 +0100 Subject: [PATCH 04/14] headers: MapPropertiesState::sumUnitCounts returns int sumUnitCounts (0x004B8000) adds up the unit counts of the current event, stores the sum at this+0x14548 and leaves it in eax. EditScenario's TextBoxLike render (0x004BF1D0) pushes that eax straight into renderNumberToScreen2 for box 101, so the function returns the sum. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapPropertiesState.func.hpp | 2 +- src/OpenSHC/Map/MapPropertiesState.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Map/MapPropertiesState.func.hpp b/src/OpenSHC/Map/MapPropertiesState.func.hpp index e4fa4438cb..95b6984699 100644 --- a/src/OpenSHC/Map/MapPropertiesState.func.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.func.hpp @@ -45,7 +45,7 @@ namespace Map { sumUnitPoints; MACRO_FUNCTION_RESOLVER( - void (MapPropertiesState::*)(), false, Address::SHC_3BB0A8C1_0x004B8000, &MapPropertiesState::sumUnitCounts) + int (MapPropertiesState::*)(), false, Address::SHC_3BB0A8C1_0x004B8000, &MapPropertiesState::sumUnitCounts) sumUnitCounts; MACRO_FUNCTION_RESOLVER(void (MapPropertiesState::*)(), false, Address::SHC_3BB0A8C1_0x004BA7D0, diff --git a/src/OpenSHC/Map/MapPropertiesState.hpp b/src/OpenSHC/Map/MapPropertiesState.hpp index bb47c668bf..064eda1c4c 100644 --- a/src/OpenSHC/Map/MapPropertiesState.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.hpp @@ -138,7 +138,7 @@ namespace Map { int sumUnitPoints(); - void sumUnitCounts(); + int sumUnitCounts(); void sortEventsByDate(); From 6b266f8978d50e8fdbf08398754f38a5b971ac19 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:10 +0100 Subject: [PATCH 05/14] headers: MapPropertiesState::indexStored is an int indexStored (0x00013580) picks the starting good, unit or popularity that the scenario editor's text box edits. EditScenario's TextBoxLike render (0x004BF1D0) compares it signed (cmp eax, 0x14 / jge at 0x004BF37C and cmp eax, 0x1e / jge at 0x004BF3AF), so the field is an int, not undefined4. Main's two users, EditScenario's EventAndInvasionList handler and the TraderSettings handler, stay at 100% with it. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapPropertiesState.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Map/MapPropertiesState.hpp b/src/OpenSHC/Map/MapPropertiesState.hpp index 064eda1c4c..73576c698a 100644 --- a/src/OpenSHC/Map/MapPropertiesState.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.hpp @@ -82,7 +82,7 @@ namespace Map { int DAT_BuildingAvailabilityScrollbarOffset; // 0x00013574 length: 4 undefined4 flag; // 0x00013578 length: 4 undefined4 offset; // 0x0001357C length: 4 - undefined4 indexStored; // 0x00013580 length: 4 + int indexStored; // 0x00013580 length: 4 int selectedAbsoluteIndex; // 0x00013584 length: 4 dword selectionTime; // 0x00013588 length: 4 undefined4 value; // 0x0001358C length: 4 From a16459ad1ef7982dcd0c7062d35d29653dc31e9f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:10 +0100 Subject: [PATCH 06/14] headers: MapPropertiesState::SEC_SiegeInformation is an int[20] The scenario editor's starting units sit at MapPropertiesState+0xEC, right after SEC_StartingResources. EditScenario's TextBoxLike render (0x004BF1D0) stores box 3's typed value for indexStored 20 to 29 at [indexStored*4 + 0x016538F4] (0x004BF3C9, 0x004BF3F5), which is element indexStored - 20 of the 20 ints at +0xEC, and sumUnitPoints (0x004B7FA0) adds them up from +0xEC. As an array the code indexes it inside its bounds instead of past the end of SEC_StartingResources. The units are in SiegeUnitCounts' order (archers first). No .cpp on main reads the field; MapAndTimeState::siegeInformation keeps SiegeUnitCounts. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/MapPropertiesState.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/OpenSHC/Map/MapPropertiesState.hpp b/src/OpenSHC/Map/MapPropertiesState.hpp index 73576c698a..784be63ce8 100644 --- a/src/OpenSHC/Map/MapPropertiesState.hpp +++ b/src/OpenSHC/Map/MapPropertiesState.hpp @@ -8,7 +8,6 @@ #pragma once -#include "OpenSHC/AI/Siege/SiegeUnitCounts.hpp" #include "OpenSHC/Commands/MappersEnum.hpp" #include "OpenSHC/Game/Scenario/BarracksRecruitabilityShort.hpp" #include "OpenSHC/Game/ScenarioEvents/InGameEventExtra.hpp" @@ -23,7 +22,6 @@ namespace OpenSHC { namespace Map { - using OpenSHC::AI::Siege::SiegeUnitCounts; using OpenSHC::Commands::MappersEnum; using OpenSHC::Game::TradeableResourcesSection; using OpenSHC::Game::Scenario::BarracksRecruitabilityShort; @@ -44,7 +42,7 @@ namespace Map { int SEC_StartingYear; // 0x00000080 length: 4 int SEC_StartingMonth; // 0x00000084 length: 4 int SEC_StartingResources[25]; // 0x00000088 length: 100 - SiegeUnitCounts SEC_SiegeInformation; // 0x000000EC length: 80 + int SEC_SiegeInformation[20]; // 0x000000EC length: 80 SiegeGameModeRelatedSection SEC_Section1067; // 0x0000013C length: 28 int SEC_StartingPopularity; // 0x00000158 length: 4 short buildingAvailability[100]; // 0x0000015C length: 200 From 1246843600cef4d79e905fe75b8d54356032af30 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:10 +0100 Subject: [PATCH 07/14] headers: TextArrayIndexType gets TAIT_UNKNOWN_10, _12 and _14 EditScenario's TextBoxLike render (0x004BF1D0) compares the user text handler's textArrayIndex with 10, 12 and 14 (0x004BF281, 0x004BF331, 0x004BF426, 0x004BF47E) and reads those text slots, next to 11 and 15, which the enum already names TAIT_UNKNOWN_11 and TAIT_UNKNOWN_15. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Text/TextArrayIndexType.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenSHC/Text/TextArrayIndexType.hpp b/src/OpenSHC/Text/TextArrayIndexType.hpp index 5f664db6d4..23170757f8 100644 --- a/src/OpenSHC/Text/TextArrayIndexType.hpp +++ b/src/OpenSHC/Text/TextArrayIndexType.hpp @@ -21,7 +21,10 @@ namespace Text { TAIT_SEVEN__NUMERIC_ONLY = 7, // 0x00000007 TAIT_EIGHT__FILTER_B = 8, // 0x00000008 TAIT_NINE__FILTER_B = 9, // 0x00000009 + TAIT_UNKNOWN_10 = 10, // 0x0000000A TAIT_UNKNOWN_11 = 11, // 0x0000000B + TAIT_UNKNOWN_12 = 12, // 0x0000000C + TAIT_UNKNOWN_14 = 14, // 0x0000000E TAIT_UNKNOWN_15 = 15 // 0x0000000F } TextArrayIndexType; From 1c8e46388ab73e4a0aef41e97cf50575568ed7d9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:11 +0100 Subject: [PATCH 08/14] reimplement: SHC_3BB0A8C1_0x004BF1D0 100.0% Reimplemented MenuItemRenderFunction_EditScenario_TextBoxLike, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 81.2% in #328). The scenario editor's text boxes: boxes 0 to 7 show a text slot of the user text handler, with the cursor when that slot is being typed into; box 3 stores the typed starting good, siege unit or popularity, box 7 an event condition value; 100 to 102 show unit totals. Each box renders its own text, as in the original: MSVC merges the identical endings, so each case keeps its own y, x and slot push before the shared getTextArrayPointer call (one call after the switch: quick_diff 0.9606 -> 0.9356). The y, x and text locals stay (positions in the call: 0.8724; the text in the call: 0.8459). The totals are read into locals before their render calls, as the original calls the sum first. quick_diff's 0.9606 is all artifacts (colour immediates, ret, the jump table). Box 3 with indexStored 20 to 29 stores into the siege units (SEC_SiegeInformation[indexStored - 20]); the draft wrote SEC_StartingResources[indexStored + 5], past the end of that array, which lands on the same address. reccmp reads 99.1%: only the call target of atol differs (the CRT's against the game's copy at 0x00583628), as in main's NewEvent handler, whose status line has the same remark. It needs the four header commits before it: sumUnitCounts returns int, indexStored is an int, SEC_SiegeInformation is an int[20], and TAIT_UNKNOWN_10/12/14. Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_EditScenario_TextBoxLike.cpp | 216 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp new file mode 100644 index 0000000000..12f4282e54 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp @@ -0,0 +1,216 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +#include + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BF1D0 + void EditScenario::MenuItemRenderFunction_EditScenario_TextBoxLike(int box, ...) + { + if (box == 7 + && DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + int const cursorOffset = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // each case renders its own text (one call after the switch: quick_diff 0.9606 -> 0.9356) + switch (box) { + // boxes 0 to 7 show a text slot, with the cursor while it is typed into + case 0: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_15) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 5 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + // y, x and the text first (in the call: quick_diff 0.9606 -> 0.8724; the text in it: 0.8459) + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_15); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 1: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_10) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 10; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_10); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 2: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_11) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 10; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_11); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 3: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 10 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + // the typed value goes to the starting good, unit or popularity being edited + if (DAT_MapPropertiesState::instance.indexStored < 20) { + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance + .field_0x345c[DAT_MapPropertiesState::instance.indexStored]] + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + } else if (DAT_MapPropertiesState::instance.indexStored < 30) { + DAT_MapPropertiesState::instance + .SEC_SiegeInformation[DAT_MapPropertiesState::instance.indexStored - 20] + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + int const unitPoints = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + // the starting units may cost 500 points at most + if (unitPoints > 500) { + DAT_MapPropertiesState::instance + .SEC_SiegeInformation[DAT_MapPropertiesState::instance.indexStored - 20] + += 500 - unitPoints; + } + } else if (DAT_MapPropertiesState::instance.indexStored == 30) { + DAT_MapPropertiesState::instance.SEC_StartingPopularity + = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)); + } + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 11; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 6: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_14) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 5 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 6; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_14); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 7: { + if (DAT_UserTextHandlerState::instance.textArrayIndex == OpenSHC::Text::TAIT_UNKNOWN_12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + cursorOffset, DAT_ButtonY::instance + 2, + DAT_ButtonX::instance + 10 + cursorOffset, DAT_ButtonY::instance + DAT_ButtonH::instance - 4, + COL_DARK_LIME::instance.shortValue); + // the typed value, in the condition's unit + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[DAT_MapPropertiesState::instance.invasionTroopIndex] + .value = atol(MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12)) + / DAT_MissionAestheticsDefinedData::instance + .EventConditionValueScale[DAT_MapPropertiesState::instance.invasionTroopIndex]; + } + int const textY = DAT_ButtonY::instance + 6; + int const textX = DAT_ButtonX::instance + 11; + char* const text = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(OpenSHC::Text::TAIT_UNKNOWN_12); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + text, textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + // 100 to 102 show a total under a "Total Troops" label + case 100: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonW::instance / 2 - 20 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE); + int const unitPoints = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + unitPoints, DAT_ButtonW::instance / 2 - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + break; + } + case 101: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + int const unitCount = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitCounts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + unitCount, DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + case 102: { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); + int const invasionUnitCount = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumInvasionEventUnitCount, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + invasionUnitCount, DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + break; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b50fe2318d..376a928841 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30495,7 +30495,7 @@ SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BEC40 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BF1D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BF1D0 | 100.0% | Reimplemented, only the atol call target differs SHC_3BB0A8C1_0x004BF684 | 0.0% | Pending From a50024fef0336174d0866a293532c82cd6dcbb64 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:11 +0100 Subject: [PATCH 09/14] headers: DAT_00eb0b24 is an int DAT_00eb0b24 (0x00EB0B24) is a counter that ScenarioDescription's Main handler (0x004D8570, button -4) steps and wraps against INT_00ed27c4: mov eax, [0x00EB0B24] / add eax, 1 / cmp eax, [0x00ED27C4] / jl at 0x004D89B2. The compare is signed, so the global is an int, not undefined4. Nothing on main uses it. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00eb0b24.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00eb0b24.hpp b/src/OpenSHC/Globals/DAT_00eb0b24.hpp index d81227d775..69df49a10d 100644 --- a/src/OpenSHC/Globals/DAT_00eb0b24.hpp +++ b/src/OpenSHC/Globals/DAT_00eb0b24.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00EB0B24 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00EB0B24) DAT_00eb0b24; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00EB0B24) DAT_00eb0b24; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EB0B24); From de9eded6a8290a31ea1bf007a2647cd6466abd88 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 22:20:12 +0100 Subject: [PATCH 10/14] reimplement: SHC_3BB0A8C1_0x004D8570 100.0% Reimplemented MenuItemActionHandler_ScenarioDescription_Main, rewritten from the binary (gynt's draft from his fork's reimpl/UI-MenuItems-development, 64.5% in #328). The mission briefing's buttons: 10 starts the mission (the map and its lord unless in the builder, then the build menu), 12 and 13 go back to the map choice in the builder, 11 goes back to the mission select (or asks first while a game is suspended), 6, 8 and 9 switch the help pages (9 opens mission.hlp), -1 steps the difficulty, -2 views the briefing, -3 asks to restart the mission and -4 goes to the next description page. Three behaviour fixes against the draft, all from the binary: a mission number of 0 or less becomes 1 and the mission still starts (the draft returned), the difficulty wraps from 3 to 0 and is still stored (the draft returned), and -1 doesn't fall into -2 (the draft set DAT_00ed27bc there). Three more of the same kind: 11 with DAT_00ed27bc set clears it and returns, 11 outside a campaign mission returns after switching the menu, and 12 or 13 in the builder with a game suspended returns after the yes/no dialog (the draft fell through in all three). 12 and 13 fall into 11 outside the builder, as in the original. The build menu tab is BMTT_CASTLE (10; the draft had BASMTT_HUNTERSHUT, the same value in the building menu's enum) and the landscaping tab 231, as main's hideOrUnhideUI writes it. Needs the DAT_00eb0b24 header commit before it. Co-Authored-By: Claude Opus 5.5 --- ...ActionHandler_ScenarioDescription_Main.cpp | 210 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..c17e819e68 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -0,0 +1,210 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b24.hpp" +#include "OpenSHC/Globals/DAT_00ed2794.hpp" +#include "OpenSHC/Globals/DAT_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_00ed27bc.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8570 + void ScenarioDescription::MenuItemActionHandler_ScenarioDescription_Main(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + switch (button) { + case 10: + // start the mission + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + if (DAT_GameCore::instance.gameSuspended == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + return; + } + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + if (DAT_GameCore::instance.missionNumber1to20 <= 0) { + DAT_GameCore::instance.missionNumber1to20 = 1; + } + DAT_GameCore::instance.section1066 = 1; + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab = 231; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::loadMissionMapAndSetLord, + DAT_MapPropertiesState::ptr)(DAT_GameCore::instance.missionNumber1to20); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + MACRO_CALL(OpenSHC::Synchrony_Func::SetAIPlayerNickNames)(); + if (DAT_GameCore::instance.missionNumber1to20 >= 16) { + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeFinalResultsForActivePlayers, + DAT_GameSynchronyState::ptr)(); + } + } + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = OpenSHC::UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearModalDialog2to6, DAT_MenuTextInputState::ptr)(); + DAT_00ed2794::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case 12: + case 13: + // in the builder: back to the map choice, or ask first while a game is suspended + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + // the map choice's mission type: 0 just build, 1 economic, 2 siege, 3 invasion + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_SIEGE: + DAT_MapMissionType::instance = 2; + break; + case OpenSHC::Map::MT_INVASION: + DAT_MapMissionType::instance = 3; + break; + case OpenSHC::Map::MT_ECONOMIC: + DAT_MapMissionType::instance = 1; + break; + case OpenSHC::Map::MT_JUST_BUILD: + DAT_MapMissionType::instance = 0; + break; + } + if (!DAT_GameCore::instance.gameSuspended) { + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE, 0); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = -7; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + } + // otherwise as 11 + case 11: + if (DAT_00ed27bc::instance == 1) { + DAT_00ed27bc::instance = 0; + return; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + if (!DAT_GameCore::instance.gameSuspended) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_SELECT, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk, 0); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 1000; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + case 6: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + } + return; + case 8: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 2; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + } + return; + case 9: + // the mission's help page + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) { + DAT_00ed2798::instance = 3; + char helpSectionName[100]; + // "mission%d.hlp" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + helpSectionName, s_mission_d_hlp_005aaf7c, DAT_GameCore::instance.missionNumber1to20); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::openScenarioHelpDialog, DAT_TextEditorState::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(helpSectionName)); + } + return; + case -1: + // "Difficulty": from 0 to 3 and round again + if (DAT_00ed2798::instance == 0 + && (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + && !DAT_GameCore::instance.gameSuspended) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (DAT_GameState::instance.mapAndTime.difficulty > 3) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + DAT_GameCore::instance.missionDifficulty = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + return; + } + DAT_GameCore::instance.missionDifficulty2 = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + } + return; + case -2: // "View Briefing" + DAT_00ed27bc::instance = 1; + return; + case -3: // "Restart Mission", asked first + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + return; + case -4: // "Next": the next description page + ++DAT_00eb0b24::instance; + if (DAT_00eb0b24::instance >= INT_00ed27c4::instance) { + DAT_00eb0b24::instance = 0; + } + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 376a928841..dd0ae4c4df 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35929,7 +35929,7 @@ SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending SHC_3BB0A8C1_0x004D839E | 0.0% | Pending -SHC_3BB0A8C1_0x004D8570 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8570 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D89CC | 0.0% | Pending From 1be9d7d7a1d06835ee8d92a3f4cef59dd761a671 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 01:11:41 +0100 Subject: [PATCH 11/14] fix: ScenarioDescription_Main after the INT_00eb0b24 rename The Ghidra header sync 8125c61c2 renamed the global DAT_00eb0b24 to INT_00eb0b24 (it took in this branch's own int retype, so the merge above drops that header commit's file in favour of main's). The ScenarioDescription render (0x004D8570) still includes and names it in the old form, so it no longer compiles on main's headers. This follows 8125c61c2, as #350 did for INT_00ed3120: the include and the name become INT_00eb0b24, and clang-format re-sorts the include lines. The type is int either way, so the generated code is the same and the function keeps its 100% status line. Globals: DAT_00eb0b24 -> INT_00eb0b24 (8125c61c2) - UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_ScenarioDescription_Main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp index c17e819e68..977b05ab35 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -18,7 +18,6 @@ #include "OpenSHC/UI/Enums/MenuViewType.hpp" #include "OpenSHC/string-literals.hpp" -#include "OpenSHC/Globals/DAT_00eb0b24.hpp" #include "OpenSHC/Globals/DAT_00ed2794.hpp" #include "OpenSHC/Globals/DAT_00ed2798.hpp" #include "OpenSHC/Globals/DAT_00ed27bc.hpp" @@ -32,6 +31,7 @@ #include "OpenSHC/Globals/DAT_MouseState.hpp" #include "OpenSHC/Globals/DAT_SoundSystemState.hpp" #include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/INT_00eb0b24.hpp" #include "OpenSHC/Globals/INT_00ed27c4.hpp" namespace OpenSHC { @@ -197,9 +197,9 @@ namespace UI { DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); return; case -4: // "Next": the next description page - ++DAT_00eb0b24::instance; - if (DAT_00eb0b24::instance >= INT_00ed27c4::instance) { - DAT_00eb0b24::instance = 0; + ++INT_00eb0b24::instance; + if (INT_00eb0b24::instance >= INT_00ed27c4::instance) { + INT_00eb0b24::instance = 0; } return; } From 8f6a96aec69f2bbf3f6e5f8fd16c7218c8c8eaa8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:14:48 +0100 Subject: [PATCH 12/14] headers: DAT_00ed27bc is a BOOLEnum The scenario description's "briefing is open" flag only ever holds 0 or 1. Its three stores in the exe: 1 at 0x004D895F ("View Briefing", -2), 0 at 0x004D8788 (11, esi, which ScenarioDescription_Main zeroes there) and 0 at 0x004DD2CD (esi, the same register that resets the page index to 0 at 0x004DD2B7). Its readers compare it with 1 or with a zero register (0x004D8296, 0x004D877F, 0x004DD42D, 0x004DD6F4). BOOLEnum is a typedef of int, so the size and every access stay the same. Its only user on main and in this PR is ScenarioDescription_Main. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00ed27bc.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00ed27bc.hpp b/src/OpenSHC/Globals/DAT_00ed27bc.hpp index a4b6a323a8..d5319ccb64 100644 --- a/src/OpenSHC/Globals/DAT_00ed27bc.hpp +++ b/src/OpenSHC/Globals/DAT_00ed27bc.hpp @@ -8,12 +8,16 @@ #pragma once +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + // GLOBAL: STRONGHOLDCRUSADER 0x00ED27BC -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00ED27BC) DAT_00ed27bc; +using OpenSHC::WindowsHelper::Enums::BOOLEnum; + +MACRO_STRUCT_RESOLVER(BOOLEnum, false, Address::SHC_3BB0A8C1_0x00ED27BC) DAT_00ed27bc; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00ED27BC); From 3dcc3052a4e7cc032962001cce0918554548cea1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 03:16:23 +0100 Subject: [PATCH 13/14] style: ScenarioDescription_Main stores FALSE / TRUE into DAT_00ed27bc DAT_00ed27bc is a BOOLEnum since the header commit before this one; the two stores (11 closing the briefing, -2 opening it) use its names. The same code (reccmp 100.0%). Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_ScenarioDescription_Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp index 977b05ab35..09cca5a64b 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -117,7 +117,7 @@ namespace UI { // otherwise as 11 case 11: if (DAT_00ed27bc::instance == 1) { - DAT_00ed27bc::instance = 0; + DAT_00ed27bc::instance = FALSE; return; } MACRO_CALL_MEMBER( @@ -189,7 +189,7 @@ namespace UI { } return; case -2: // "View Briefing" - DAT_00ed27bc::instance = 1; + DAT_00ed27bc::instance = TRUE; return; case -3: // "Restart Mission", asked first DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44; From deb3e4f9eb3bec3ab696866366ad6b6a8874cf13 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 7 Nov 2026 17:49:24 +0100 Subject: [PATCH 14/14] MenuItemActionHandler_ScenarioDescription_Main: use main's INT_00ed27bc gynt's header sync (eef6f667a) renamed DAT_00ed27bc to INT_00ed27bc, an int; this branch had typed it a BOOLEnum (8f6a96aec), and the merge before takes main's. It is tested against 1 and set to 1 and 0, so TRUE and FALSE become 1 and 0. reccmp 100.0%. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_ScenarioDescription_Main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp index 09cca5a64b..7261d4146d 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -20,7 +20,6 @@ #include "OpenSHC/Globals/DAT_00ed2794.hpp" #include "OpenSHC/Globals/DAT_00ed2798.hpp" -#include "OpenSHC/Globals/DAT_00ed27bc.hpp" #include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" #include "OpenSHC/Globals/DAT_GameCore.hpp" #include "OpenSHC/Globals/DAT_GameState.hpp" @@ -32,6 +31,7 @@ #include "OpenSHC/Globals/DAT_SoundSystemState.hpp" #include "OpenSHC/Globals/DAT_TextEditorState.hpp" #include "OpenSHC/Globals/INT_00eb0b24.hpp" +#include "OpenSHC/Globals/INT_00ed27bc.hpp" #include "OpenSHC/Globals/INT_00ed27c4.hpp" namespace OpenSHC { @@ -116,8 +116,8 @@ namespace UI { } // otherwise as 11 case 11: - if (DAT_00ed27bc::instance == 1) { - DAT_00ed27bc::instance = FALSE; + if (INT_00ed27bc::instance == 1) { + INT_00ed27bc::instance = 0; return; } MACRO_CALL_MEMBER( @@ -189,7 +189,7 @@ namespace UI { } return; case -2: // "View Briefing" - DAT_00ed27bc::instance = TRUE; + INT_00ed27bc::instance = 1; return; case -3: // "Restart Mission", asked first DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44;