From b4889c19c5e2464c273d7cef20fd1f93b4765447 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:14:41 +0100 Subject: [PATCH 01/64] reimplement: SHC_3BB0A8C1_0x004348D0 50.2% 18 returns and the range tests fixed; block layout and register allocation gynt's draft (43.3% on his branch) with two fixes for the a521bf7bd headers: setBottomLeftTextDisplayText takes an int as its 4th argument (the zeroed union local is gone), and Building's field at 0xC2 is field70_0xc2. The rest is the mechanical pass (decimal numbers, // comments, compound assignments, unused usings); quick_diff output identical. What is left is mostly block layout: 54 diff regions cover about 2000 of 2829 instructions. Behaviour fixes against the original's asm, which the draft still had: 18 dropped returns (the empty `if (...) {}` and five blocks that end in the original's epilogues or tail calls, e.g. 0x00434908, 0x0043492E, 0x00434C93, 0x00434CF8, 0x00436949); the six tactical-power range tests, where Ghidra's SBORROW had become an always-true compare (so a power was refused at every distance except exactly 2500 or 12544, and bVar15 / bVar16 got stray writes the function reads later), are `distance > limit` as the original's cmp / jle (0x00434E9E-0x00434EAA); and `extraout_ECX == 2` read an uninitialised local where the original's ecx still holds shiftRelated0or3 (0x004376E6). Mechanical: local_18 is an int, `+ TRUE` and the unitControlsRelated TRUEs are 1, `<= 200` / `<= 2401`, `--x == 0`, the shift as `shift ? 3 : 0`, and the decompiler's comments are gone. The `(-x & mask) + 2916` lines stay as they are: as a conditional they lose the match (0.5517 -> 0.4777 in quick_diff). Co-Authored-By: Claude Opus 5.5 --- ...InGameMenu_UnitSelectionAndControlsUnk.cpp | 2323 +++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 2324 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp new file mode 100644 index 0000000000..85afb92ba9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp @@ -0,0 +1,2323 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Map/Entities/EntityState.func.hpp" +#include "OpenSHC/Map/Navigation/DirectionAlgorithmState.func.hpp" +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Units/TribesState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/BottomLeftTextDisplayState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.hpp" +#include "OpenSHC/Game/Player/PlayerData.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Map/Buildings/BuildingTypeShort.hpp" +#include "OpenSHC/Map/Units/States/UnitState.hpp" +#include "OpenSHC/Map/Units/UnitInstructionType.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/Map/Units/UnitTypeShort.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/BOOLEnum_00b98414.hpp" +#include "OpenSHC/Globals/DAT_00b9841c.hpp" +#include "OpenSHC/Globals/DAT_00b98420.hpp" +#include "OpenSHC/Globals/DAT_00b98424.hpp" +#include "OpenSHC/Globals/DAT_BottomLeftTextDisplayState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_DirectionAlgorithmState.hpp" +#include "OpenSHC/Globals/DAT_EntityState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_TribesState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/TIME_PreviousClick.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using Map::Buildings::BuildingTypeShort; + using Map::Units::UnitTypeShort; + using WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004348D0 + void InGameMenu::MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk(int param_1, ...) + { + int uVar1; + int uVar2; + int sVar3; + UnitTypeShort UVar4; + BuildingTypeShort BVar5; + BOOLEnum BVar8; + uint _clickHitEnemy; + uint _otherUnitIDUnk; + uint uVar9; + short* psVar10; + int _shooterID; + int _yDifference; + int _specificRange2; + DWORD DVar11; + BOOLEnum BVar12; + undefined4 uVar13; + int _xDifference2; + int _xDifference; + dword toArea; + int _specificRange; + int iVar14; + int bVar15; + int bVar16; + bool bVar17; + int bVar18; + int local_20; + int local_18; + int _playerID; + undefined4 _setRallying; + uint flag1003; + int _oneOr129; + DWORD DVar7 = timeGetTime(); + local_20 = -2; + bVar16 = 0; + bVar17 = false; + bVar18 = 0; + bVar15 = 0; + BOOLEnum siegeUnitSelectedUnk = FALSE; + if (DAT_GameCore::instance.gamePausedLogical) { + return; + } + BVar8 = MACRO_CALL(UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO); + if (BVar8) { + return; + } + if (DAT_GameSynchronyState::instance.syncStatus) { + if (!DAT_MouseState::instance.selectionBoxMode) { + return; + } + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + return; + } + if (DAT_GameSynchronyState::instance.saveRelated) { + return; + } + DAT_MouseState::instance.field_0x1dc = -1; + DAT_MouseState::instance.savedSelectionBoxState = DAT_MouseState::instance.selectionBoxState; + DAT_TileMapState::instance.DAT_SelectionIconType = 0; + if (70 < (int)(DVar7 - DAT_TileMapState::instance.cursorAnimationTime)) { + ++DAT_TileMapState::instance.cursorOverlayAnimationFrame; + if (16 < DAT_TileMapState::instance.cursorOverlayAnimationFrame) { + DAT_TileMapState::instance.cursorOverlayAnimationFrame = 1; + } + ++DAT_TileMapState::instance.flagAnimationFrame; + DAT_TileMapState::instance.cursorAnimationTime = DVar7; + } + if (0 + < DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID]) { + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::drawFlagsAndUnitDestinations, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID); + } + if ((((!DAT_TileMapState::instance.shiftRelated0or3) || (DAT_TileMapState::instance.shiftRelated0or3 == 3)) + || (DAT_TileMapState::instance.shiftRelated0or3 == 2)) + && DAT_MouseState::instance.draggingStopped && DAT_MouseState::instance.selectionBoxMode) { + DAT_TribesState::instance.rallyCount = 1; + if (DAT_TileMapState::instance.shiftRelated0or3 == 3) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::createTribeFromSelectedUnits, DAT_UnitsState::ptr)(); + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.shiftRelated0or3 = 1; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } else { + if (((DAT_UnitsState::instance.totalUnitsInSelection <= 0) + || (DAT_MouseState::instance.leftClickStartMoment == -1)) + && (MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::applyDragBoxSelectionByPriority, DAT_UnitsState::ptr)(), + DAT_UnitsState::instance.totalUnitsInSelection == 0)) { + if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) + || (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SHIELD)) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + } + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + DAT_TileMapState::instance.shiftRelated0or3 = 0; + } + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + if (0 < DAT_UnitsState::instance.totalUnitsInSelection) { + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::createUnitSelection, DAT_UnitsState::ptr)(); + if (!_shooterID) { + return; + } + if ((!DAT_UnitsState::instance.someSelectedUnitID) + && (DAT_UnitsState::instance.totalUnitsInSelection == 1)) { + DAT_UnitsState::instance.someSelectedUnitID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + DAT_UnitsState::instance.timePreviousDoubleClick = timeGetTime(); + } + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getSelectedLordIDIfOwnedByCurrentPlayer, + DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk) { + if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + != UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) + && (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + != UI::Enums::BASMTT_SIEGETENT_SHIELD)) { + DAT_GameCore::instance.tabTypeSiegeSubset + = DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab; + } + if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SIEGETOWER) + || (bVar18 = DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SHIELD, + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + = UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM, + bVar18)) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + = UI::Enums::BASMTT_SIEGETENT_SHIELD; + } + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + DAT_UnitsState::instance.hasEngineerSelected = FALSE; + } else if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) + || (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SHIELD)) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + } + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.shiftRelated0or3 = 1; + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + return; + } + } + } + if (DAT_TileMapState::instance.shiftRelated0or3 == 1) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::recountUnitsInSelection, DAT_UnitsState::ptr)(); + } + _shooterID = DAT_BuildingsState::instance.unitID; + if ((DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordKilledByPlayerID + != 0) + && (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SOLITARY)) { + return; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + != 0) { + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SOLITARY) { + return; + } + if (DAT_GameState::instance.mapAndTime.gameOver + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + return; + } + } + if (DAT_TileMapState::instance.shiftRelated0or3 == 1 + && DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + < 1 + && DAT_UnitsState::instance.totalUnitsInSelection <= 0) { + if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) + || (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SHIELD)) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + } + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + DAT_TileMapState::instance.shiftRelated0or3 = 0; + return; + } + if (DAT_BuildingsState::instance.siegeEngineCreationRelated01 != 0 + && --DAT_BuildingsState::instance.siegeEngineCreationRelated01 == 0) { + DAT_GameCore::instance.tabTypeSiegeSubset = UI::Enums::BMTT_CASTLE; + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + DAT_UnitsState::instance.units[_shooterID].isSelected = 1; + DAT_TileMapState::instance.shiftRelated0or3 = 1; + DAT_UnitsState::instance.totalUnitsInSelection = 1; + DAT_UnitsState::instance.hasEngineerSelected = FALSE; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::createUnitSelection, DAT_UnitsState::ptr)(); + return; + } + if ((!DAT_ViewportRenderState::instance.viewportState.field_0x0) + && (!DAT_MinimapViewState::instance.minimapClickEnabled)) { + return; + } + if (DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_NULL) { + return; + } + if (DAT_MouseState::instance.rightClickStart) { + if ((DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM) + || (DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType + == UI::Enums::BASMTT_SIEGETENT_SHIELD)) { + if (DAT_MinimapViewState::instance.minimapClickEnabled) { + return; + } + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + } else if ((DAT_MinimapViewState::instance.minimapClickEnabled) + && (DAT_TileMapState::instance.shiftRelated0or3 == 1)) { + return; + } + DAT_UnitsState::instance.lastSelectedUnitID = 0; + if (0 < DAT_UnitsState::instance.totalUnitsInSelection) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + } + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + DAT_TileMapState::instance.shiftRelated0or3 = 0; + return; + } + if (!DAT_MinimapViewState::instance.minimapClickEnabled) { + MACRO_CALL_MEMBER( + Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + } + if (DAT_TileMapState::instance.shiftRelated0or3 == 5) { + if ((!DAT_MouseState::instance.leftClickStart) && (!DAT_MouseState::instance.leftClickState)) { + DAT_TileMapState::instance.shiftRelated0or3 = 4; + } + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.shiftRelated0or3 == 4) { + _shooterID = (int)DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent + [DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile]; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + _specificRange = DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile + - DAT_ViewportRenderState::instance.translationMatrix[_shooterID].addXgetTile; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + bVar18 = 0; + bVar17 = false; + if (DAT_TileMapState::instance.activeTacticalPower == 6 + && (DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 0x100U)) { + LAB_00434f28: + bVar18 = 1; + } else { + switch (DAT_TileMapState::instance.activeTacticalPower) { + case 2: + case 3: + case 4: + case 6: + case 13: + case 16: + iVar14 = _shooterID + - DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry; + _yDifference = _specificRange + - DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + bVar17 = true; + // out of the power's range: cmp / jle at 0x00434E9E-0x00434EAA + bVar18 = DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500; + if (!DAT_GameState::instance.mapAndTime.skirmishExtremeMode2) { + LAB_00434fbe: + if (bVar18) + break; + } else if (bVar18) { + _yDifference = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordID; + if ((!_yDifference) + || (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordUID + != DAT_UnitsState::instance.units[_yDifference].uid)) + goto LAB_00434fbe; + iVar14 = _specificRange - DAT_UnitsState::instance.units[_yDifference].x; + _yDifference = _shooterID - DAT_UnitsState::instance.units[_yDifference].y; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + bVar18 = 0; + if (DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500) + goto LAB_00434f28; + } + _playerID = 1; + do { + if (0 < DAT_GameState::instance.playerDataArray[_playerID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id + && 0 < DAT_GameState::instance.playerDataArray[_playerID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .id + && DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != DAT_GameState::instance.mapAndTime.playerTeams[_playerID] + && (_yDifference = _shooterID + - DAT_GameState::instance.playerDataArray[_playerID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry, + iVar14 = _specificRange + - DAT_GameState::instance.playerDataArray[_playerID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry, + iVar14 * iVar14 + _yDifference * _yDifference < 625)) { + if (!DAT_GameState::instance.mapAndTime.skirmishExtremeMode2) + goto LAB_00434f28; + _yDifference = DAT_GameState::instance.playerDataArray[_playerID].lordID; + if ((_yDifference) + && (DAT_GameState::instance.playerDataArray[_playerID].lordUID + == DAT_UnitsState::instance.units[_yDifference].uid)) { + iVar14 = _specificRange - DAT_UnitsState::instance.units[_yDifference].x; + _yDifference = _shooterID - DAT_UnitsState::instance.units[_yDifference].y; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + if (DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500) + goto LAB_00434f28; + } + if (bVar18) + break; + } + if (0 < DAT_GameState::instance.playerDataArray[_playerID + 1] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id + && 0 < DAT_GameState::instance.playerDataArray[_playerID + 1] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .id + && DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != DAT_GameState::instance.mapAndTime.playerTeams[_playerID + 1] + && (_yDifference = _shooterID + - DAT_GameState::instance.playerDataArray[_playerID + 1] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry, + (_specificRange + - DAT_GameState::instance.playerDataArray[_playerID + 1] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry) + * (_specificRange + - DAT_GameState::instance.playerDataArray[_playerID + 1] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry) + + _yDifference * _yDifference + < 625)) { + if (!DAT_GameState::instance.mapAndTime.skirmishExtremeMode2) + goto LAB_00434f28; + _yDifference = DAT_GameState::instance.playerDataArray[_playerID + 1].lordID; + if ((_yDifference) + && (DAT_GameState::instance.playerDataArray[_playerID + 1].lordUID + == DAT_UnitsState::instance.units[_yDifference].uid)) { + iVar14 = _specificRange - DAT_UnitsState::instance.units[_yDifference].x; + _yDifference = _shooterID - DAT_UnitsState::instance.units[_yDifference].y; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + if (DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500) + goto LAB_00434f28; + } + if (bVar18) + break; + } + if (0 < DAT_GameState::instance.playerDataArray[_playerID + 2] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id + && 0 < DAT_GameState::instance.playerDataArray[_playerID + 2] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .id + && DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != DAT_GameState::instance.mapAndTime.playerTeams[_playerID + 2] + && (_yDifference = _specificRange + - DAT_GameState::instance.playerDataArray[_playerID + 2] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry, + _yDifference * _yDifference + + (_shooterID + - DAT_GameState::instance.playerDataArray[_playerID + 2] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry) + * (_shooterID + - DAT_GameState::instance.playerDataArray[_playerID + 2] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry) + < 625)) { + if (!DAT_GameState::instance.mapAndTime.skirmishExtremeMode2) + goto LAB_00434f28; + _yDifference = DAT_GameState::instance.playerDataArray[_playerID + 2].lordID; + if ((_yDifference) + && (DAT_GameState::instance.playerDataArray[_playerID + 2].lordUID + == DAT_UnitsState::instance.units[_yDifference].uid)) { + iVar14 = _specificRange - DAT_UnitsState::instance.units[_yDifference].x; + _yDifference = _shooterID - DAT_UnitsState::instance.units[_yDifference].y; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + if (DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500) + goto LAB_00434f28; + } + if (bVar18) + break; + } + if (0 < DAT_GameState::instance.playerDataArray[_playerID + 3] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id + && 0 < DAT_GameState::instance.playerDataArray[_playerID + 3] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .id + && DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != DAT_GameState::instance.mapAndTime.playerTeams[_playerID + 3] + && (_yDifference = _shooterID + - DAT_GameState::instance.playerDataArray[_playerID + 3] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .yEntry, + iVar14 = _specificRange + - DAT_GameState::instance.playerDataArray[_playerID + 3] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .xEntry, + iVar14 * iVar14 + _yDifference * _yDifference < 625)) { + if (!DAT_GameState::instance.mapAndTime.skirmishExtremeMode2) + goto LAB_00434f28; + _yDifference = DAT_GameState::instance.playerDataArray[_playerID + 3].lordID; + if ((_yDifference) + && (DAT_GameState::instance.playerDataArray[_playerID + 3].lordUID + == DAT_UnitsState::instance.units[_yDifference].uid)) { + iVar14 = _specificRange - DAT_UnitsState::instance.units[_yDifference].x; + _yDifference = _shooterID - DAT_UnitsState::instance.units[_yDifference].y; + _yDifference = _yDifference * _yDifference + iVar14 * iVar14; + if (DAT_TileMapState::instance.activeTacticalPower == 3 ? _yDifference > 12544 + : _yDifference > 2500) + goto LAB_00434f28; + } + if (bVar18) + break; + } + _playerID += 4; + } while (_playerID < 9); + } + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordKilledByPlayerID + != 0 + || bVar18 + || (((DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 0x40501481U) + || (DAT_TileMapState::instance.PathConnectionLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + == 0)) + && (bVar17))) { + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + local_20 = 4; + } else if (!DAT_MouseState::instance.leftClickStart) { + switch (DAT_TileMapState::instance.activeTacticalPower) { + case 2: + case 4: + case 6: + case 13: + case 16: + MACRO_CALL_MEMBER(Map::TileMapState_Func::spawnFloatingNumberAroundTile, DAT_TileMapState::ptr)( + _specificRange, _shooterID, (int)(10)); + break; + case 3: + case 5: + case 7: + MACRO_CALL_MEMBER(Map::TileMapState_Func::spawnFloatingNumberAroundTile, DAT_TileMapState::ptr)( + _specificRange, _shooterID, (int)(14)); + break; + default: + MACRO_CALL_MEMBER(Map::TileMapState_Func::spawnFloatingNumberAroundTile, DAT_TileMapState::ptr)( + _specificRange, _shooterID, (int)(12)); + } + } else { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_TileMapState::instance.activeTacticalPower; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_ACTIVATE_TACTICAL_POWERS); + DAT_TileMapState::instance.shiftRelated0or3 = 0; + } + goto LAB_0043782c; + } + if (!DAT_TileMapState::instance.shiftRelated0or3 || DAT_TileMapState::instance.shiftRelated0or3 == 3 + || DAT_TileMapState::instance.shiftRelated0or3 == 2) { + if (DAT_MouseState::instance.leftClickStart) { + BOOLEnum_00b98414::instance = FALSE; + DAT_UnitsState::instance.someSelectedUnitID = -1; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + if (DAT_TileMapState::instance.shiftRelated0or3 == 2) { + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + } + if (DAT_UnitsState::instance.totalUnitsInSelection <= 0) { + MACRO_CALL_MEMBER(Input::MouseState_Func::beginPointSelectionBox, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectFirstUnitInDragBoxAnyPlayer, DAT_UnitsState::ptr)(); + DAT_UnitsState::instance.lastSelectedUnitID + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(0); + if (0 < DAT_UnitsState::instance.totalUnitsInSelection) { + DAT_UnitsState::instance.someSelectedUnitID = 0; + DAT_MouseState::instance.selectionBoxState = 1; + MACRO_CALL_MEMBER(Input::MouseState_Func::extendSelectionBoxToMouse, DAT_MouseState::ptr)(); + BOOLEnum_00b98414::instance = TRUE; + } + } + goto LAB_0043782c; + } + if (!DAT_MouseState::instance.leftClickState) { + if (!DAT_MouseState::instance.draggingStopped) { + DAT_UnitsState::instance.totalUnitsInSelection = 0; + MACRO_CALL_MEMBER(Input::MouseState_Func::setupHitBox, DAT_MouseState::ptr)(4, 4); + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(4); + if ((_otherUnitIDUnk) && (DAT_UnitsState::instance.units[_otherUnitIDUnk].isSelected == 0)) { + local_20 = 0; + } + } + goto LAB_0043782c; + } + if (!DAT_MouseState::instance.selectionBoxMode + || (MACRO_CALL_MEMBER(Input::MouseState_Func::extendSelectionBoxToMouse, DAT_MouseState::ptr)(), + DAT_MouseState::instance.selectionBoxState == 0) + || (DAT_GameCore::instance.menuSwitchDelay = -1, + 0 < DAT_UnitsState::instance.totalUnitsInSelection + && ((DAT_MouseState::instance.leftClickStartMoment != -1 + && ((int)(DVar7 - DAT_MouseState::instance.leftClickStartMoment) <= 200))))) + goto LAB_0043782c; + if (DAT_TileMapState::instance.shiftRelated0or3 != 3) { + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::applyDragBoxSelectionByPriority, DAT_UnitsState::ptr)(); + goto LAB_0043782c; + } + LAB_004377dc: + DAT_GameCore::instance.menuSwitchDelay = -1; + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectUnitsInDragBoxForCurrentPlayer, DAT_UnitsState::ptr)(); + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.shiftRelated0or3 != 1) + goto LAB_0043782c; + if (DAT_ModifierKeyState::instance.shift && !DAT_TribesState::instance.patrolButtonPressed + && DAT_MouseState::instance.leftClickStart) { + local_20 = 0; + MACRO_CALL_MEMBER(Input::MouseState_Func::setupHitBox, DAT_MouseState::ptr)(4, 4); + _clickHitEnemy + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(5); + if (_clickHitEnemy) { + if (DAT_UnitsState::instance.units[_clickHitEnemy].isSelected == 0) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getFirstSelectedUnitID, DAT_UnitsState::ptr)( + _clickHitEnemy); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } else { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectUnit, DAT_UnitsState::ptr)( + _clickHitEnemy); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickHitEnemy; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_UNIT_DESELECT); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + goto LAB_0043782c; + } + } + DAT_TileMapState::instance.field_0x5549b8 = 1; + if (DAT_UnitsState::instance.unitControlsRelated == 4) + goto LAB_moveToTileUI; + if (DAT_UnitsState::instance.unitControlsRelated == 1) { + bVar16 = DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY; + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.DAT_SelectionIconType = 1; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getFirstSelectedSiegeEngineID, DAT_UnitsState::ptr)(); + if (((DAT_ViewportRenderState::instance.viewportState.field_0x38) + && (_shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasFootSoldiers, DAT_UnitsState::ptr)(), + _shooterID != 0)) + || (DAT_ViewportRenderState::instance.viewportState.field_0x40 + && (_shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasFootSoldiers, DAT_UnitsState::ptr)(), + _shooterID != 0))) { + bVar15 = 1; + local_20 = 1; + DAT_TileMapState::instance.DAT_SelectionIconType = 25; + DAT_TileMapState::instance.cursorOverlayGmID = 16; + DAT_TileMapState::instance.cursorOverlayImageBase = 91; + DAT_TileMapState::instance.pendingUnitCommand = -1; + } + _shooterID = DAT_ViewportRenderState::instance.viewportState.somePitchDitchID; + if (DAT_ViewportRenderState::instance.viewportState.somePitchDitchID + && DAT_GameState::instance.mapAndTime.playerTeams[DAT_TileMapState::instance + .pitchDitches[DAT_ViewportRenderState::instance.viewportState.somePitchDitchID] + .owner] + == DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID] + && (BVar8 + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasArchers, DAT_UnitsState::ptr)(), + BVar8)) { + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + _yDifference = MACRO_CALL_MEMBER(Map::Entities::EntityState_Func::isBrazierNearby, + DAT_EntityState::ptr)((int)DAT_UnitsState::instance.units[_specificRange].x, + (int)(DAT_UnitsState::instance.units[_specificRange].y), + (int)(DAT_UnitsState::instance.units[_specificRange].buildingHeight + + DAT_UnitsState::instance.units[_specificRange].terrainOrClimbHeight)); + if ((_yDifference) + && (_yDifference = (int)DAT_TileMapState::instance.pitchDitches[_shooterID].y + - (int)DAT_UnitsState::instance.units[_specificRange].y, + _shooterID = (int)DAT_TileMapState::instance.pitchDitches[_shooterID].x + - (int)DAT_UnitsState::instance.units[_specificRange].x, + _shooterID * _shooterID + _yDifference * _yDifference <= 2401)) { + DAT_TileMapState::instance.pendingUnitCommand = 12; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + goto LAB_00436d33; + } + } + MACRO_CALL_MEMBER(Input::MouseState_Func::setupHitBox, DAT_MouseState::ptr)(4, 4); + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(1); + if (!_otherUnitIDUnk + || (_shooterID = MACRO_CALL(UI::Helpers_Func::SomeUnitAndViewportCheck)(_otherUnitIDUnk), + !_shooterID) + || (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsEngineersOnly, DAT_UnitsState::ptr)(), + BVar8 + && (BVar8 = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasUnmannedSiegeEngine, + DAT_UnitsState::ptr)(_otherUnitIDUnk), + !BVar8))) { + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(2); + if (!_otherUnitIDUnk || DAT_MinimapViewState::instance.minimapClickEnabled + || (_shooterID = MACRO_CALL(UI::Helpers_Func::SomeUnitAndViewportCheck)(_otherUnitIDUnk), + !_shooterID)) { + if ((DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) + && (DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)) { + switch (DAT_BuildingsState::instance + .buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID] + .buildingType) { + case Map::Buildings::BT_MANORHOUSE: + case Map::Buildings::BT_STONEKEEP: + case Map::Buildings::BT_STRONGHOLD: + case Map::Buildings::BT_KEEPFOUR: + case Map::Buildings::BT_KEEPFIVE: + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + break; + default: + bVar17 = true; + goto LAB_00435e83; + } + } + do { + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, + DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk) { + _specificRange = 30; + _shooterID = 30; + } else { + _specificRange = 50; + _shooterID = 50; + } + MACRO_CALL_MEMBER(Input::MouseState_Func::setupHitBox, DAT_MouseState::ptr)( + _shooterID, _specificRange); + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(1); + if (_otherUnitIDUnk + && (_shooterID + = MACRO_CALL(UI::Helpers_Func::SomeUnitAndViewportCheck)(_otherUnitIDUnk), + _shooterID) + && (BVar8 + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionContainsEngineersOnly, + DAT_UnitsState::ptr)(), + !BVar8 + || (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasUnmannedSiegeEngine, + DAT_UnitsState::ptr)(_otherUnitIDUnk), + BVar8))) { + uVar1 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_otherUnitIDUnk].tile]; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + uVar2 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_shooterID].tile]; + BVar8 = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasUnmannedSiegeEngine, + DAT_UnitsState::ptr)(_otherUnitIDUnk); + if (BVar8) { + _shooterID = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (dword)uVar1, (dword)uVar2, 1); + if (!_shooterID) + goto LAB_moveToTileUI; + DAT_TileMapState::instance.pendingUnitCommand = 3; + DAT_TileMapState::instance.cursorOverlayImageBase = -3; + DAT_UnitsState::instance.units[_otherUnitIDUnk].field_0x6c = 2; + local_20 = -1; + DAT_TileMapState::instance.instructionTargetUnitID = _otherUnitIDUnk; + goto LAB_00436d33; + } + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasShieldOrSiegeMobileUnits, + DAT_UnitsState::ptr)(); + if (_specificRange) + goto LAB_moveToTileUI; + switch (DAT_UnitsState::instance.units[_shooterID].unitType) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_HARCHER: + case Map::Units::UT_S_FBALLISTA: + _specificRange = 2916; + break; + default: + _specificRange = 100000000; + _yDifference = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::canAUnitClimb, DAT_UnitsState::ptr)(); + _yDifference = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)( + (int)DAT_UnitsState::instance.units[_shooterID].owner, (dword)uVar1, + (dword)uVar2, _yDifference); + if (!_yDifference + && (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsOnlyArabAssassins, + DAT_UnitsState::ptr)(), + !BVar8 + || (BVar8 = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanReachUsingCachedAreaLogic, + DAT_PathFindingState::ptr)( + DAT_UnitsState::instance.units[_otherUnitIDUnk].tile, + DAT_UnitsState::instance.units[_shooterID].tile), + !BVar8))) { + _specificRange + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasNoRangedUnits, + DAT_UnitsState::ptr)(); + // is _specificRange != 0 ? -1 : 2916 (neg / sbb in the original): as a + // conditional it loses the match + _specificRange = (-(uint)(_specificRange) & 0xfffff49b) + 2916; + } + break; + case Map::Units::UT_S_CATAPULT: + _specificRange = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + case Map::Units::UT_S_BALLISTA: + _specificRange = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _specificRange = 4900; + break; + case Map::Units::UT_A_SLINGER: + _specificRange = 484; + break; + case Map::Units::UT_A_FIRETHROWER: + _specificRange = 121; + } + _yDifference = (int)DAT_UnitsState::instance.units[_shooterID].y + - (int)DAT_UnitsState::instance.units[_otherUnitIDUnk].y; + _xDifference = (int)DAT_UnitsState::instance.units[_shooterID].x + - (int)DAT_UnitsState::instance.units[_otherUnitIDUnk].x; + if (_specificRange < _xDifference * _xDifference + _yDifference * _yDifference) + goto LAB_moveToTileUI; + uVar9 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, + DAT_UnitsState::ptr)(); + if (!uVar9) { + bVar16 = 1; + DAT_TileMapState::instance.pendingUnitCommand = 10; + } else { + DAT_TileMapState::instance.pendingUnitCommand = 11; + } + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated + = DAT_UnitsState::instance.units[_otherUnitIDUnk].uid; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + local_20 = 2; + DAT_TileMapState::instance.uiSelectedUnitIDUnk = _otherUnitIDUnk; + goto LAB_00436d33; + } + if ((!DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID) || (bVar17)) { + LAB_00436245: + if (local_20 == -2) + goto LAB_00436262; + break; + } + LAB_00435e83: + _shooterID = DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID; + local_18 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getFirstSelectedSiegeEngineID, DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk) { + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Buildings::BuildingsState_Func::isBuildingPathBlockerOrDamageable, + DAT_BuildingsState::ptr)(_shooterID, DAT_UnitsState::instance.units[local_18].tile); + if (_otherUnitIDUnk + || (BVar8 = MACRO_CALL_MEMBER( + Map::Buildings::BuildingsState_Func::getBuildingHasHealthProperty, + DAT_BuildingsState::ptr)( + _shooterID, DAT_UnitsState::instance.units[local_18].tile), + BVar8 + && (_specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasMixedAssaultAndInfantry, + DAT_UnitsState::ptr)(), + _specificRange != 0))) + goto LAB_00435eef; + } else { + LAB_00435eef: + if ((DAT_BuildingsState::instance.buildings[_shooterID].buildingType + != Map::Buildings::BT_KILLINGPIT) + && (_specificRange + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasShieldOrSiegeTower, + DAT_UnitsState::ptr)(), + _specificRange == 0)) { + BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsOnlyArabAssassins, + DAT_UnitsState::ptr)(); + if (BVar8) { + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + BVar8 = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanReachUsingCachedAreaLogic, + DAT_PathFindingState::ptr)( + DAT_ViewportRenderState::instance.viewportState.cursorTile, + DAT_UnitsState::instance.units[local_18].tile); + if (BVar8) + goto LAB_moveToTileUI; + } + } + if ((DAT_GameState::instance.mapAndTime + .playerTeams[DAT_BuildingsState::instance.buildings[_shooterID].owner] + == DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID]) + || (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsEngineersOnly, + DAT_UnitsState::ptr)(), + BVar8)) { + BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasEngineers, DAT_UnitsState::ptr)(); + if (BVar8 + && (int)DAT_BuildingsState::instance.buildings[_shooterID].owner + == DAT_GameSynchronyState::instance.currentPlayerSlotID + && !DAT_MinimapViewState::instance.minimapClickEnabled + && (BVar5 = DAT_BuildingsState::instance.buildings[_shooterID].buildingType, + BVar5 == Map::Buildings::BT_CATAPULT + || (((((BVar5 == Map::Buildings::BT_FIREBALLISTA + || (BVar5 == Map::Buildings::BT_TREBUCHET)) + || (BVar5 == Map::Buildings::BT_BATTERINGRAM)) + || ((BVar5 == Map::Buildings::BT_SIEGETOWER + || (BVar5 == Map::Buildings::BT_SHIELD)))) + || (BVar5 == Map::Buildings::BT_OILSMELTER))))) { + DAT_BuildingsState::instance.buildings[_shooterID].field_0xc2 = 2; + DAT_TileMapState::instance.pendingUnitCommand = 2; + DAT_TileMapState::instance.cursorOverlayImageBase = -2; + local_20 = -1; + } + } else { + LAB_00435bb3: + UVar4 = DAT_UnitsState::instance.units[local_18].unitType; + _specificRange = 0; + switch (UVar4) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_HARCHER: + _specificRange = 2916; + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + switchD_00435c7b_caseD_2d: + _specificRange = -1; + if (DAT_UnitsState::instance.unitControlsRelated == 5) + goto switchD_00435bd8_caseD_18; + } + break; + default: + switchD_00435bd8_caseD_18: + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SOLITARY + || !DAT_GameState::instance.mapAndTime.skirmishStrongWalls + || UVar4 == Map::Units::UT_S_BATTERINGRAM + || 4 < (int)(short)DAT_BuildingsState::instance.buildings[_shooterID] + .buildingType + - 0x4aU) { + if (_specificRange != -1) { + _specificRange = 100000000; + _yDifference + = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func:: + canUnitReachBuildingPerimeter, + DAT_BuildingsState::ptr)(_shooterID, local_18); + if (!_yDifference) { + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasNoRangedUnits, + DAT_UnitsState::ptr)(); + _specificRange = (-(uint)(_specificRange) & 0xfffff49b) + 2916; + } + } + } else { + _specificRange = -1; + siegeUnitSelectedUnk = TRUE; + } + break; + case Map::Units::UT_S_CATAPULT: + _specificRange = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + _specificRange = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _specificRange = 4900; + break; + case Map::Units::UT_S_BALLISTA: + _specificRange = 7225; + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + switchD_00435ce1_caseD_2d: + _specificRange = -1; + } + break; + case Map::Units::UT_A_SLINGER: + _specificRange = 484; + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + goto switchD_00435c7b_caseD_2d; + } + break; + case Map::Units::UT_A_FIRETHROWER: + _specificRange = 121; + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + goto switchD_00435c7b_caseD_2d; + } + break; + case Map::Units::UT_S_FBALLISTA: + _specificRange = 2916; + switch (DAT_BuildingsState::instance.buildings[_shooterID].buildingType) { + case Map::Buildings::BT_GATEHOUSELARGE: + case Map::Buildings::BT_GATEHOUSESMALL: + case Map::Buildings::BT_WOODGATE1: + case Map::Buildings::BT_WOODGATE2: + case Map::Buildings::BT_TOWER1: + case Map::Buildings::BT_TOWER2: + case Map::Buildings::BT_TOWER3: + case Map::Buildings::BT_TOWER4: + case Map::Buildings::BT_TOWER5: + goto switchD_00435ce1_caseD_2d; + } + } + if ((DAT_BuildingsState::instance.buildings[_shooterID].buildingType + == Map::Buildings::BT_PITCHDITCH) + && (BVar8 + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasArchers, + DAT_UnitsState::ptr)(), + !BVar8)) { + _specificRange = -1; + } + if (DAT_GameState::instance.mapAndTime.skirmishNoRushTicks + && DAT_GameSynchronyState::instance.currentGameMode + != Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) { + _specificRange = -1; + } + _yDifference = (int)(short)DAT_BuildingsState::instance.buildings[_shooterID].y + - (int)DAT_UnitsState::instance.units[local_18].y; + _shooterID = (int)(short)DAT_BuildingsState::instance.buildings[_shooterID].x + - (int)DAT_UnitsState::instance.units[local_18].x; + if (_specificRange < _shooterID * _shooterID + _yDifference * _yDifference) { + if (bVar18) + goto LAB_0043674b; + } else { + bVar16 = 1; + DAT_TileMapState::instance.pendingUnitCommand = 1; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + } + } + } + } + if (!bVar17) + goto LAB_00436245; + } while (local_20 == -2); + if (local_20 == -1) { + if (!bVar15) + goto LAB_00436d33; + LAB_00436262: + if (DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile + && (DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 0x10000300U) + && (BVar8 + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionContainsEngineersOnly, + DAT_UnitsState::ptr)(), + !BVar8 + && (!(DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 2)))) { + uVar1 = (short)DAT_TileMapState::instance.PathConnectionLayer + [DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile]; + local_18 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + uVar2 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[local_18].tile]; + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getFirstSelectedLadderUnitID, DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk) { + if (DAT_UnitsState::instance.units[local_18].unitType != Map::Units::UT_S_TOWER) { + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::checkAnySelectedUnitCannotClimb, + DAT_UnitsState::ptr)(); + if (!_shooterID) { + UVar4 = DAT_UnitsState::instance.units[local_18].unitType; + if ((((UVar4 == Map::Units::UT_S_BATTERINGRAM) + || (UVar4 == Map::Units::UT_S_CATAPULT)) + || ((UVar4 == Map::Units::UT_S_TREBUCHET + || (((UVar4 == Map::Units::UT_E_KNIGHT + || (UVar4 == Map::Units::UT_S_TOWER)) + || (_shooterID = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func:: + calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)( + DAT_GameSynchronyState::instance + .currentPlayerSlotID, + (dword)uVar1, (dword)uVar2, 0), + _shooterID == 0)))))) + && (_shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsShieldmenOnly, + DAT_UnitsState::ptr)(), + _shooterID == 0 + && ((DAT_TileMapState::instance + .WallOwnerLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + != DAT_GameSynchronyState::instance.currentPlayerSlotID))) { + UVar4 = DAT_UnitsState::instance.units[local_18].unitType; + switch (UVar4) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_SLINGER: + case Map::Units::UT_A_HARCHER: + case Map::Units::UT_A_FIRETHROWER: + _shooterID = -1; + if (DAT_UnitsState::instance.unitControlsRelated == 5) + goto switchD_004364b3_caseD_18; + break; + default: + switchD_004364b3_caseD_18: + if (DAT_GameSynchronyState::instance.currentGameMode + == Game::GM_SOLITARY + || DAT_GameState::instance.mapAndTime.skirmishStrongWalls == 0 + || UVar4 == Map::Units::UT_S_BATTERINGRAM) + goto switchD_004364b3_caseD_3a; + _shooterID = -1; + siegeUnitSelectedUnk = TRUE; + break; + case Map::Units::UT_S_CATAPULT: + _shooterID = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + _shooterID = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _shooterID = 4900; + break; + case Map::Units::UT_S_TOWER: + switchD_004364b3_caseD_3a: + _shooterID = 100000000; + _specificRange = MACRO_CALL_MEMBER( + Map::Buildings::BuildingsState_Func::canUnitReachAdjacentTile, + DAT_BuildingsState::ptr)( + DAT_ViewportRenderState::instance.viewportState + .mouseAtomRefFloorTile, + local_18); + if (!_specificRange) { + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasNoRangedUnits, + DAT_UnitsState::ptr)(); + _shooterID = (-(uint)(_shooterID) & 0xfffff49b) + 2916; + } + break; + case Map::Units::UT_S_BALLISTA: + case Map::Units::UT_S_FBALLISTA: + _shooterID = -1; + } + if (DAT_GameState::instance.mapAndTime.skirmishNoRushTicks + && DAT_GameSynchronyState::instance.currentGameMode + != Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.currentGameMode + != Game::GM_SOLITARY) { + _shooterID = -1; + } + _yDifference + = (DAT_ViewportRenderState::instance.viewportState + .mouseAtomRefFloorTile + - DAT_ViewportRenderState::instance + .translationMatrix[DAT_ViewportRenderState::instance + .tileTranslationMatrix_YComponent + [DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile]] + .addXgetTile) + - (int)DAT_UnitsState::instance.units[local_18].x; + _specificRange + = (int)DAT_ViewportRenderState::instance + .tileTranslationMatrix_YComponent[DAT_ViewportRenderState:: + instance.viewportState.mouseAtomRefFloorTile] + - (int)DAT_UnitsState::instance.units[local_18].y; + if (_specificRange * _specificRange + _yDifference * _yDifference + <= _shooterID) { + bVar16 = 1; + DAT_TileMapState::instance.pendingUnitCommand = 6; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + goto LAB_00436d33; + } + } + } else { + _shooterID + = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, (dword)uVar1, + (dword)uVar2, 1); + if (!_shooterID + && (DAT_TileMapState::instance + .WallOwnerLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + != DAT_GameSynchronyState::instance.currentPlayerSlotID) + goto LAB_00436607; + } + goto LAB_moveToTileUI; + } + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::findFreeTileNearby, DAT_UnitsState::ptr)(local_18, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile)); + if (_otherUnitIDUnk) { + DAT_TileMapState::instance.pendingUnitCommand = 6; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + goto LAB_00436d33; + } + goto LAB_00436953; + } + if ((DAT_TileMapState::instance.WallOwnerLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_TileMapState::instance.pendingUnitCommand = 5; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + local_20 = 2; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + goto LAB_00436d33; + } + } + } + } else { + DAT_TileMapState::instance.instructionTargetUnitID = _otherUnitIDUnk; + _shooterID = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getRemainingRequiredEngineers, + DAT_UnitsState::ptr)(_otherUnitIDUnk); + if ((!_shooterID) + || (uVar9 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(), + uVar9 == 0)) { + sVar3 = DAT_UnitsState::instance.units[_otherUnitIDUnk] + .digTileX__OR__countCurrentlyManningEnginers__OR__forCowsRandomBelow300; + if ((sVar3) && (DAT_UnitsState::instance.units[_otherUnitIDUnk].isSelected != 0)) { + bVar18 = 1; + if (0 < sVar3) { + _shooterID + = (int)DAT_UnitsState::instance.units[_otherUnitIDUnk] + .digTileX__OR__countCurrentlyManningEnginers__OR__forCowsRandomBelow300; + psVar10 = DAT_UnitsState::instance.units[_otherUnitIDUnk].manningEngineerRef; + do { + if (DAT_UnitsState::instance.units[*psVar10].state.generic + == Map::Units::States::US_JESTER_ROAM_TO) { + bVar18 = 0; + } + ++psVar10; + --_shooterID; + } while (_shooterID); + if (!bVar18) + goto LAB_moveToTileUI; + } + DAT_TileMapState::instance.pendingUnitCommand = 4; + DAT_TileMapState::instance.cursorOverlayImageBase = -4; + DAT_UnitsState::instance.units[_otherUnitIDUnk].field_0x6c = 3; + local_20 = -1; + goto LAB_00436d33; + } + } else { + uVar1 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_otherUnitIDUnk].tile]; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + _shooterID = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (dword)uVar1, + (dword)((int)((short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_shooterID].tile])), + 1); + if (_shooterID) { + DAT_TileMapState::instance.pendingUnitCommand = 3; + DAT_TileMapState::instance.cursorOverlayImageBase = -3; + DAT_UnitsState::instance.units[_otherUnitIDUnk].field_0x6c = 2; + local_20 = -1; + goto LAB_00436d33; + } + } + } + } else { + uVar1 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_otherUnitIDUnk].tile]; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + uVar2 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_UnitsState::instance.units[_shooterID].tile]; + BVar8 = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionHasUnmannedSiegeEngine, + DAT_UnitsState::ptr)(_otherUnitIDUnk); + if (!BVar8) { + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasShieldOrSiegeMobileUnits, DAT_UnitsState::ptr)(); + if (!_specificRange) { + switch (DAT_UnitsState::instance.units[_shooterID].unitType) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_HARCHER: + case Map::Units::UT_S_FBALLISTA: + _specificRange = 2916; + break; + default: + _specificRange = 100000000; + _yDifference = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::canAUnitClimb, DAT_UnitsState::ptr)(); + _yDifference = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)((int)DAT_UnitsState::instance.units[_shooterID].owner, + (dword)uVar1, (dword)uVar2, _yDifference); + if (!_yDifference + && (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsOnlyArabAssassins, + DAT_UnitsState::ptr)(), + !BVar8 + || (BVar8 = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func:: + calculateCanReachUsingCachedAreaLogic, + DAT_PathFindingState::ptr)( + DAT_UnitsState::instance.units[_otherUnitIDUnk].tile, + DAT_UnitsState::instance.units[_shooterID].tile), + !BVar8))) { + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasNoRangedUnits, DAT_UnitsState::ptr)(); + _specificRange = (-(uint)(_specificRange) & 0xfffff49b) + 2916; + } + break; + case Map::Units::UT_S_CATAPULT: + _specificRange = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + case Map::Units::UT_S_BALLISTA: + _specificRange = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _specificRange = 4900; + break; + case Map::Units::UT_A_SLINGER: + _specificRange = 484; + break; + case Map::Units::UT_A_FIRETHROWER: + _specificRange = 121; + } + _yDifference = (int)DAT_UnitsState::instance.units[_shooterID].y + - (int)DAT_UnitsState::instance.units[_otherUnitIDUnk].y; + _xDifference2 = (int)DAT_UnitsState::instance.units[_shooterID].x + - (int)DAT_UnitsState::instance.units[_otherUnitIDUnk].x; + // Check if unit under mouse is in range to be attacked + if (_xDifference2 * _xDifference2 + _yDifference * _yDifference <= _specificRange) { + uVar9 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, + DAT_UnitsState::ptr)(); + if (!uVar9) { + DAT_TileMapState::instance.pendingUnitCommand = 10; + } else { + DAT_TileMapState::instance.pendingUnitCommand = 11; + } + bVar16 = uVar9 == 0 || bVar16; + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated + = DAT_UnitsState::instance.units[_otherUnitIDUnk].uid; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + local_20 = 2; + DAT_TileMapState::instance.uiSelectedUnitIDUnk = _otherUnitIDUnk; + goto LAB_00436d33; + } + } + } else { + _shooterID = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID, (dword)uVar1, (dword)uVar2, 1); + if (_shooterID) { + DAT_TileMapState::instance.pendingUnitCommand = 3; + DAT_TileMapState::instance.cursorOverlayImageBase = -3; + DAT_UnitsState::instance.units[_otherUnitIDUnk].field_0x6c = 2; + local_20 = -1; + DAT_TileMapState::instance.instructionTargetUnitID = _otherUnitIDUnk; + goto LAB_00436d33; + } + } + } + LAB_moveToTileUI: + if ((local_20 != -2) || (DAT_MouseState::instance.selectionBoxMode)) + goto LAB_00436d33; + MACRO_CALL_MEMBER(Input::MouseState_Func::setupHitBox, DAT_MouseState::ptr)(4, 4); + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(5); + if (_otherUnitIDUnk) { + if (DAT_UnitsState::instance.units[_otherUnitIDUnk].isSelected == 0) { + local_20 = 0; + goto LAB_00436d33; + } + if (_otherUnitIDUnk == DAT_UnitsState::instance.someSelectedUnitID + && (DVar11 = timeGetTime(), DVar11 - DAT_UnitsState::instance.timePreviousDoubleClick < 500) + && DAT_MouseState::instance.leftClickStart) { + DAT_00b98424::instance = 0; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectAllUnitsOfTypeForPlayer, + DAT_UnitsState::ptr)((int)DAT_UnitsState::instance.units[_otherUnitIDUnk].owner, + (int)((short)DAT_UnitsState::instance.units[_otherUnitIDUnk].unitType)); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::createTribeFromSelectedUnits, DAT_UnitsState::ptr)(); + DAT_UnitsState::instance.someSelectedUnitID = 0; + return; + } + } + if (!DAT_ViewportRenderState::instance.viewportState.cursorTile) + goto LAB_00436953; + bVar18 = 0; + // at most two passes, the second from the campground; both exits test what the pass computes + while (true) { + bVar17 = false; + flag1003 = DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.cursorTile]; + uVar1 = (short)DAT_TileMapState::instance + .PathConnectionLayer[DAT_ViewportRenderState::instance.viewportState.cursorTile]; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + if (0 < _shooterID) { + _specificRange = DAT_UnitsState::instance.units[_shooterID].tile; + toArea = (dword)(short)DAT_TileMapState::instance.PathConnectionLayer[_specificRange]; + if ((DAT_TileMapState::instance.LogicLayer[_specificRange] & 0x40000000U)) { + toArea = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::canNavigateFunctionReturnsArea, + DAT_PathFindingState::ptr)((int)DAT_UnitsState::instance.units[_shooterID].owner, + (dword)uVar1, (uint)(DAT_UnitsState::instance.units[_shooterID].x), + (uint)(DAT_UnitsState::instance.units[_shooterID].y)); + } + _specificRange + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::canAUnitClimb, DAT_UnitsState::ptr)(); + _specificRange = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::calculateCanPlayerUnitsNavigateToAreaFromArea, + DAT_PathFindingState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (dword)uVar1, (dword)((int)(toArea)), _specificRange); + bVar17 = _specificRange != 0; + } + BVar8 = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::isTowerTileOvercrowdedByCurrentPlayer, + DAT_UnitsState::ptr)(DAT_ViewportRenderState::instance.viewportState.cursorTile); + if (BVar8) { + bVar17 = false; + } + _specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasMovableNonSiegeUnit, DAT_UnitsState::ptr)(); + if (!_specificRange) { + bVar17 = false; + } + _yDifference = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasMixedAssaultAndInfantry, DAT_UnitsState::ptr)(); + if (_yDifference) { + if ((flag1003 & 0x10000100) + || (_yDifference = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::calculatePathKeepAndWallsGatesNotAllowed, + DAT_PathFindingState::ptr)((int)DAT_UnitsState::instance.units[_shooterID].x, + (int)(DAT_UnitsState::instance.units[_shooterID].y), + DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile + - DAT_ViewportRenderState::instance + .translationMatrix[DAT_ViewportRenderState::instance + .tileTranslationMatrix_YComponent[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile]] + .addXgetTile, + (int)(DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent + [DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile]), + 100000), + _yDifference == 0)) { + bVar17 = false; + } + } + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedLordIDIfOwnedByCurrentPlayer, DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk || bVar17 || bVar16 || bVar18) + break; + bVar18 = 1; + if ((DAT_TileMapState::instance + .BuildingLayer[DAT_ViewportRenderState::instance.viewportState.cursorTile] + == 0) + || (DAT_BuildingsState::instance + .buildings[DAT_TileMapState::instance + .BuildingLayer[DAT_ViewportRenderState::instance.viewportState.cursorTile]] + .buildingType + != Map::Buildings::BT_MANORHOUSE)) + break; + DAT_ViewportRenderState::instance.viewportState.cursorTile + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .tileEntry; + DAT_ViewportRenderState::instance.viewportState.mouseX + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .xEntry; + DAT_ViewportRenderState::instance.viewportState.mouseY + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_CAMPGROUND] + .yEntry; + } + BVar12 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsOnlyArabAssassins, DAT_UnitsState::ptr)(); + if ((!BVar12) + || (BVar12 = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::calculateCanReachUsingCachedAreaLogic, + DAT_PathFindingState::ptr)(DAT_ViewportRenderState::instance.viewportState.cursorTile, + DAT_UnitsState::instance.units[_shooterID].tile), + !BVar12)) { + if (bVar17) + goto LAB_00436b8a; + if (!_specificRange || BVar8 + || !(DAT_TileMapState::instance.LogicLayer[DAT_UnitsState::instance.units[_shooterID].tile] + & 0x10000100U) + || (_specificRange = MACRO_CALL_MEMBER( + Map::Navigation::PathFindingState_Func::someBinaryAlgFunctionPathFinding, + DAT_PathFindingState::ptr)(_shooterID), + _specificRange == 0) + || (_shooterID + = MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func::findCrossAreaBridgeTileToTarget, + DAT_PathFindingState::ptr)(_shooterID, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseX), + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseY)), + _shooterID == 0)) { + DAT_TileMapState::instance.pendingUnitCommand = -10; + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + // NoEntry-Icon under mouse + DAT_TileMapState::instance.DAT_SelectionIconType = 17; + local_20 = 4; + goto LAB_00436c74; + } + local_20 = 2; + goto LAB_00436d8a; + } + bVar17 = true; + LAB_00436b8a: + if (DAT_ViewportRenderState::instance.viewportState.field_0x6c == 1) { + DAT_TileMapState::instance.pendingUnitCommand = -1; + DAT_TileMapState::instance.cursorOverlayImageBase = 181; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + // MoveTo-Icon under mouse + DAT_TileMapState::instance.DAT_SelectionIconType = 1; + local_20 = 4; + } else { + local_20 = 2; + } + LAB_00436c74: + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedLordIDIfOwnedByCurrentPlayer, DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk || !bVar17 || bVar16 + || (_shooterID = (int)DAT_TileMapState::instance + .BuildingLayer[DAT_ViewportRenderState::instance.viewportState.cursorTile], + _shooterID == 0 + || (BVar5 = DAT_BuildingsState::instance.buildings[_shooterID].buildingType, + (short)BVar5 < 40))) + goto LAB_00436d33; + if ((short)BVar5 < 45) { + if ((int)DAT_BuildingsState::instance.buildings[_shooterID].owner + == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + bVar16 = 1; + } + goto LAB_00436d33; + } + if (BVar5 != Map::Buildings::BT_CAMPGROUND || !bVar18 + || (int)DAT_BuildingsState::instance.buildings[_shooterID].owner + != DAT_GameSynchronyState::instance.currentPlayerSlotID + || (bVar16 = true, !DAT_MouseState::instance.leftClickStart)) + goto LAB_00436d33; + } else { + if (DAT_UnitsState::instance.unitControlsRelated == 20) { + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, DAT_UnitsState::ptr)(); + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.uiSelectedUnitIDUnk = 0; + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated = 0; + local_20 = -1; + MACRO_CALL_MEMBER( + Map::Navigation::DirectionAlgorithmState_Func::calculatePreferredRelativeOrientation, + DAT_DirectionAlgorithmState::ptr)((int)DAT_UnitsState::instance.units[_otherUnitIDUnk].x, + (int)(DAT_UnitsState::instance.units[_otherUnitIDUnk].y), + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY); + if (DAT_DirectionAlgorithmState::instance.orientation == 15 + || (!DAT_ViewportRenderState::instance.viewportState.mouseX + && (!DAT_ViewportRenderState::instance.viewportState.mouseY))) { + DAT_TileMapState::instance.pendingUnitCommand = -1; + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + local_20 = 4; + } else { + uVar9 = (int)((DAT_DirectionAlgorithmState::instance.orientation + - DAT_TileMapState::instance.mapOrientation) + + 12) + % 8; + DAT_UnitsState::instance.units[_otherUnitIDUnk].field_0x6e = (short)uVar9 + 1; + } + goto LAB_00436d33; + } + if (DAT_UnitsState::instance.unitControlsRelated != 5) { + if (DAT_UnitsState::instance.unitControlsRelated == 22) { + DAT_TileMapState::instance.pendingUnitCommand = -1; + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + DAT_TileMapState::instance.DAT_SelectionIconType = 17; + local_20 = 4; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + switch (DAT_UnitsState::instance.units[_shooterID].unitType) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_HARCHER: + case Map::Units::UT_S_FBALLISTA: + _specificRange = 2916; + break; + default: + _specificRange = 0; + break; + case Map::Units::UT_S_CATAPULT: + _specificRange = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + case Map::Units::UT_S_BALLISTA: + _specificRange = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _specificRange = 4900; + break; + case Map::Units::UT_A_SLINGER: + _specificRange = 484; + break; + case Map::Units::UT_A_FIRETHROWER: + _specificRange = 121; + } + _yDifference = DAT_ViewportRenderState::instance.viewportState.mouseX + - DAT_UnitsState::instance.units[_shooterID].x; + _shooterID = DAT_ViewportRenderState::instance.viewportState.mouseY + - DAT_UnitsState::instance.units[_shooterID].y; + if (_specificRange < _shooterID * _shooterID + _yDifference * _yDifference) + goto LAB_00436d33; + } + LAB_004367d0: + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + DAT_TileMapState::instance.uiSelectedUnitIDUnk = 0; + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated = 0; + local_20 = 2; + goto LAB_00436d33; + } + bVar18 = 1; + local_18 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + _shooterID = DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID; + if (!DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID) { + if (DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile + && (DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 0x10000300U) + && (BVar8 = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsEngineersOnly, DAT_UnitsState::ptr)(), + !BVar8 + && (!(DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 2)))) { + LAB_00436607: + UVar4 = DAT_UnitsState::instance.units[local_18].unitType; + switch (UVar4) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_SLINGER: + case Map::Units::UT_A_HARCHER: + _shooterID = -1; + if (DAT_UnitsState::instance.unitControlsRelated == 5) + goto switchD_0043662c_caseD_18; + break; + default: + switchD_0043662c_caseD_18: + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SOLITARY + || !DAT_GameState::instance.mapAndTime.skirmishStrongWalls + || UVar4 == Map::Units::UT_S_BATTERINGRAM) + goto switchD_0043662c_caseD_3a; + _shooterID = -1; + siegeUnitSelectedUnk = TRUE; + break; + case Map::Units::UT_S_CATAPULT: + _shooterID = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + _shooterID = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _shooterID = 4900; + break; + case Map::Units::UT_S_TOWER: + switchD_0043662c_caseD_3a: + _shooterID = 100000000; + _specificRange = MACRO_CALL_MEMBER( + Map::Buildings::BuildingsState_Func::canUnitReachAdjacentTile, DAT_BuildingsState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile, local_18); + if (!_specificRange) { + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasNoRangedUnits, DAT_UnitsState::ptr)(); + _shooterID = (-(uint)(_shooterID) & 0xfffff49b) + 2916; + } + break; + case Map::Units::UT_S_BALLISTA: + case Map::Units::UT_A_FIRETHROWER: + case Map::Units::UT_S_FBALLISTA: + _shooterID = -1; + } + if (DAT_GameState::instance.mapAndTime.skirmishNoRushTicks + && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) { + _shooterID = -1; + } + _yDifference + = (DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile + - DAT_ViewportRenderState::instance + .translationMatrix[DAT_ViewportRenderState::instance + .tileTranslationMatrix_YComponent[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile]] + .addXgetTile) + - (int)DAT_UnitsState::instance.units[local_18].x; + _specificRange = (int)DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent + [DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + - (int)DAT_UnitsState::instance.units[local_18].y; + if (_specificRange * _specificRange + _yDifference * _yDifference <= _shooterID) { + bVar16 = 1; + DAT_TileMapState::instance.pendingUnitCommand = 6; + DAT_TileMapState::instance.cursorOverlayImageBase = 32; + DAT_TileMapState::instance.DAT_SelectionIconType = 9; + local_20 = 2; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + goto LAB_00436d33; + } + if (!bVar18) + goto LAB_moveToTileUI; + } + } else { + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getFirstSelectedSiegeEngineID, DAT_UnitsState::ptr)(); + if (!_otherUnitIDUnk) { + BVar8 = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::getBuildingHasHealthProperty, + DAT_BuildingsState::ptr)(_shooterID, DAT_UnitsState::instance.units[local_18].tile); + if (!BVar8 + && (BVar8 + = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::getBuildingHasHealthProperty, + DAT_BuildingsState::ptr)(_shooterID, DAT_UnitsState::instance.units[local_18].tile), + !BVar8 + || (_specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasMixedAssaultAndInfantry, + DAT_UnitsState::ptr)(), + _specificRange == 0))) + goto LAB_0043674b; + } + if (DAT_BuildingsState::instance.buildings[_shooterID].buildingType != Map::Buildings::BT_KILLINGPIT + && (_specificRange = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasShieldOrSiegeTower, DAT_UnitsState::ptr)(), + _specificRange == 0 + && (BVar8 + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::selectionContainsEngineersOnly, + DAT_UnitsState::ptr)(), + !BVar8))) + goto LAB_00435bb3; + } + LAB_0043674b: + switch (DAT_UnitsState::instance.units[local_18].unitType) { + case Map::Units::UT_E_ARCHER: + case Map::Units::UT_E_XBOW: + case Map::Units::UT_A_ARCHER: + case Map::Units::UT_A_HARCHER: + case Map::Units::UT_S_FBALLISTA: + _specificRange2 = 2916; + break; + default: + _specificRange2 = 0; + break; + case Map::Units::UT_S_CATAPULT: + _specificRange2 = 5625; + break; + case Map::Units::UT_S_TREBUCHET: + case Map::Units::UT_S_BALLISTA: + _specificRange2 = 7225; + break; + case Map::Units::UT_S_MANGONEL: + _specificRange2 = 4900; + break; + case Map::Units::UT_A_SLINGER: + _specificRange2 = 484; + break; + case Map::Units::UT_A_FIRETHROWER: + _specificRange2 = 121; + } + _specificRange = DAT_ViewportRenderState::instance.viewportState.mouseX + - DAT_UnitsState::instance.units[local_18].x; + _shooterID = DAT_ViewportRenderState::instance.viewportState.mouseY + - DAT_UnitsState::instance.units[local_18].y; + if (_shooterID * _shooterID + _specificRange * _specificRange <= _specificRange2) + goto LAB_004367d0; + LAB_00436953: + DAT_TileMapState::instance.pendingUnitCommand = -1; + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + DAT_TileMapState::instance.DAT_SelectionIconType = 17; + local_20 = 4; + LAB_00436d33: + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedLordIDIfOwnedByCurrentPlayer, DAT_UnitsState::ptr)(); + if ((_otherUnitIDUnk) && (!bVar16)) { + DAT_TileMapState::instance.pendingUnitCommand = -1; + DAT_TileMapState::instance.cursorOverlayImageBase = 65; + DAT_TileMapState::instance.flagAnimationDivisor = 16; + DAT_TileMapState::instance.cursorOverlayGmID = 172; + DAT_TileMapState::instance.DAT_SelectionIconType = 17; + local_20 = 4; + } + LAB_00436d8a: + if (DAT_MouseState::instance.leftClickStart) { + DAT_00b98424::instance = 1; + if (((!local_20) + || (((local_20 == 2 && (!DAT_TileMapState::instance.cursorOverlayImageBase)) + && (DAT_UnitsState::instance.unitControlsRelated != 5)))) + && DAT_TileMapState::instance.pendingUnitCommand != 3 + && DAT_TileMapState::instance.pendingUnitCommand != 4) { + MACRO_CALL_MEMBER(Input::MouseState_Func::beginPointSelectionBox, DAT_MouseState::ptr)(); + _otherUnitIDUnk + = MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::getUnitInHitBox, DAT_UnitsState::ptr)(5); + if (_otherUnitIDUnk) { + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectFirstUnitInDragBoxAnyPlayer, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::beginPointSelectionBox, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectFirstUnitInDragBoxAnyPlayer, DAT_UnitsState::ptr)(); + DAT_UnitsState::instance.someSelectedUnitID = -1; + if (0 < DAT_UnitsState::instance.totalUnitsInSelection) { + DAT_UnitsState::instance.someSelectedUnitID = 0; + } + DAT_MouseState::instance.selectionBoxState = 1; + MACRO_CALL_MEMBER(Input::MouseState_Func::extendSelectionBoxToMouse, DAT_MouseState::ptr)(); + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_TileMapState::instance.shiftRelated0or3 = 0; + } + } + DAT_TileMapState::instance.field_0x554a00 = DAT_ViewportRenderState::instance.viewportState.mouseX; + DAT_TileMapState::instance.instructionTargetX + = DAT_ViewportRenderState::instance.viewportState.mouseX; + DAT_TileMapState::instance.field_0x554a04 = DAT_ViewportRenderState::instance.viewportState.mouseY; + DAT_TileMapState::instance.instructionTargetY + = DAT_ViewportRenderState::instance.viewportState.mouseY; + goto LAB_0043782c; + } + if ((DAT_MouseState::instance.leftClickState) && (DAT_00b98424::instance)) { + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if ((!DAT_MouseState::instance.selectionBoxMode) + || (MACRO_CALL_MEMBER(Input::MouseState_Func::extendSelectionBoxToMouse, DAT_MouseState::ptr)(), + DAT_MouseState::instance.selectionBoxState == 0)) + goto LAB_0043782c; + if (!DAT_ModifierKeyState::instance.shift) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + } + DAT_TileMapState::instance.shiftRelated0or3 = DAT_ModifierKeyState::instance.shift ? 3 : 0; + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.pendingUnitCommand = 0; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + DAT_GameCore::instance.menuSwitchDelay = -1; + if (0 < DAT_UnitsState::instance.totalUnitsInSelection + && DAT_MouseState::instance.leftClickStartMoment != -1 + && (int)(DVar7 - DAT_MouseState::instance.leftClickStartMoment) <= 200) + goto LAB_0043782c; + if (DAT_TileMapState::instance.shiftRelated0or3 != 3) { + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::applyDragBoxSelectionByPriority, DAT_UnitsState::ptr)(); + goto LAB_0043782c; + } + goto LAB_004377dc; + } + if ((!DAT_MouseState::instance.draggingStopped) + || (bVar18 = DAT_00b98424::instance == 0, DAT_00b98424::instance = 0, bVar18)) + goto LAB_0043782c; + _otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::getSelectedLordIDIfOwnedByCurrentPlayer, DAT_UnitsState::ptr)(); + if ((_otherUnitIDUnk) && (!bVar16)) { + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + goto LAB_0043782c; + } + } + _setRallying = 0; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseCursorState, DAT_MouseState::ptr)(); + _shooterID = DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID; + switch (DAT_UnitsState::instance.unitControlsRelated) { + case 1: + if (DAT_TileMapState::instance.pendingUnitCommand == -10) { + if (siegeUnitSelectedUnk) { + MACRO_CALL_MEMBER(UI::BottomLeftTextDisplayState_Func::setBottomLeftTextDisplayText, + DAT_BottomLeftTextDisplayState::ptr)(1, 257, 0, 0, 105, 2000); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + } else { + if (DAT_TileMapState::instance.pendingUnitCommand == 11) + goto LAB_00437671; + if (DAT_TileMapState::instance.pendingUnitCommand == 10) { + if ((DAT_TileMapState::instance.uiSelectedUnitIDUnk) + && (DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated + == DAT_UnitsState::instance.units[DAT_TileMapState::instance.uiSelectedUnitIDUnk] + .uid)) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_UNIT_ATTACK_UNIT, DAT_TileMapState::instance.uiSelectedUnitIDUnk, + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated, 0); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitCombatSpeechForTarget, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + (int)(DAT_TileMapState::instance.uiSelectedUnitIDUnk)); + } + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.pendingUnitCommand == 12) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand4Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, 34, + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.somePitchDitchID)), + (undefined4)((int)(DAT_TileMapState::instance + .pitchDitches[DAT_ViewportRenderState::instance.viewportState.somePitchDitchID] + .uid))); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playArcherCommandSpeech, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.pendingUnitCommand == 1) { + uVar13 = 9; + goto LAB_004374dc; + } + if (DAT_TileMapState::instance.pendingUnitCommand == 2) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand4Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, 15, + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)), + (undefined4)((int)(DAT_BuildingsState::instance + .buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID] + .uid))); + if ((DAT_BuildingsState::instance.buildings[_shooterID].buildingType + != Map::Buildings::BT_OILSMELTER) + || (_otherUnitIDUnk = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(), + _otherUnitIDUnk == 0)) + break; + if (DAT_BuildingsState::instance.buildings[_shooterID].currentEmployeeCount == 0) { + _otherUnitIDUnk = 28; + } else { + _otherUnitIDUnk = 29; + } + } else if (DAT_TileMapState::instance.pendingUnitCommand == 3) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand4Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, 16, + DAT_TileMapState::instance.instructionTargetUnitID, + (undefined4)(( + int)(DAT_UnitsState::instance.units[DAT_TileMapState::instance.instructionTargetUnitID] + .uid))); + _otherUnitIDUnk = 20; + } else { + if (DAT_TileMapState::instance.pendingUnitCommand != 4) { + if (DAT_TileMapState::instance.pendingUnitCommand == 5) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand3Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, 24, + (undefined4)(( + int)(DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile))); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playWorkCommandSpeech, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.pendingUnitCommand == 6) { + uVar13 = 23; + goto LAB_00437494; + } + if ((DAT_ViewportRenderState::instance.viewportState.field_0x38) + && (_shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasFootSoldiers, DAT_UnitsState::ptr)(), + _shooterID != 0)) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_FILL_MOAT, + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseX)), + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseY)), 1000); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitSelectSpeech, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if ((DAT_ViewportRenderState::instance.viewportState.field_0x40) + && (_shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionHasFootSoldiers, DAT_UnitsState::ptr)(), + _shooterID != 0)) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_DIG_MOAT, + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseX)), + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseY)), 1000); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitSelectSpeech, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if (!DAT_ModifierKeyState::instance.shift) { + DVar7 = timeGetTime(); + _oneOr129 = 1; + if (DAT_00b98420::instance == DAT_ViewportRenderState::instance.viewportState.mouseX + && DAT_00b9841c::instance == DAT_ViewportRenderState::instance.viewportState.mouseY + && (_oneOr129 = 1, (int)(DVar7 - TIME_PreviousClick::instance) < 500)) { + _oneOr129 = 129; + } + DAT_00b98420::instance = DAT_ViewportRenderState::instance.viewportState.mouseX; + DAT_00b9841c::instance = DAT_ViewportRenderState::instance.viewportState.mouseY; + TIME_PreviousClick::instance = DVar7; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::giveMoveCommand, DAT_UnitsState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY, + (int)(DAT_TribesState::instance.patrolButtonPressed), _oneOr129); + DAT_TribesState::instance.rallyCount = 2; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + // rallying shift == 1 + if (!DAT_TribesState::instance.patrolButtonPressed) { + if (9 < DAT_TribesState::instance.rallyCount) + goto LAB_00437357; + if (DAT_TribesState::instance.rallyCount == 1) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::giveMoveCommand, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY, -1, 1); + ++DAT_TribesState::instance.rallyCount; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + } else { + _setRallying = 1; + if (DAT_TribesState::instance.rallyCount < 10) { + if (DAT_TribesState::instance.rallyCount == 1) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::giveMoveCommand, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY, + (int)(DAT_TribesState::instance.patrolButtonPressed), 1); + ++DAT_TribesState::instance.rallyCount; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(1); + goto LAB_0043782c; + } + } else { + LAB_00437357: + DAT_TribesState::instance.rallyCount = 9; + } + } + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::extendRallyPoint, DAT_UnitsState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY, + (int)(DAT_TribesState::instance.rallyCount)); + ++DAT_TribesState::instance.rallyCount; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(_setRallying); + goto LAB_0043782c; + } + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_EXIT_SIEGE_EQUIPMENT, DAT_TileMapState::instance.instructionTargetUnitID, + (undefined4)(( + int)(DAT_UnitsState::instance.units[DAT_TileMapState::instance.instructionTargetUnitID] + .uid)), + 0); + _otherUnitIDUnk = 22; + } + LAB_004376a4: + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playUnitSpeechEffect, DAT_SFXState::ptr)( + _otherUnitIDUnk); + } + break; + case 4: + if (DAT_TileMapState::instance.uiSelectedUnitIDUnk) { + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_UNIT_ATTACK_UNIT, DAT_TileMapState::instance.uiSelectedUnitIDUnk, + DAT_TileMapState::instance.DAT_SomeUNitUIDUIRelated, 0); + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitCombatSpeechForTarget, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + (int)(DAT_TileMapState::instance.uiSelectedUnitIDUnk)); + } + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + case 5: + if (local_20 == 2) { + if (DAT_TileMapState::instance.pendingUnitCommand == 6) { + uVar13 = 35; + LAB_00437494: + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitMoveSpeech, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand3Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + (undefined4)((int)(uVar13)), + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile))); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + if (DAT_TileMapState::instance.pendingUnitCommand != 1) { + DAT_UnitsState::instance.unitControlsRelated = DAT_UnitsState::instance.pendingUnitControlMode; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::giveMoveCommand, DAT_UnitsState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID, + DAT_ViewportRenderState::instance.viewportState.mouseX, + DAT_ViewportRenderState::instance.viewportState.mouseY, 0, 0); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, + Map::Units::UIT_ATTACK_LAND, DAT_TileMapState::instance.instructionTargetX, + DAT_TileMapState::instance.instructionTargetY, DAT_TileMapState::instance.field_0x554a08); + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playUnitMoveSpeech, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + goto LAB_0043782c; + } + uVar13 = 36; + LAB_004374dc: + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand4Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, (undefined4)((int)(uVar13)), + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)), + (undefined4)((int)(DAT_BuildingsState::instance + .buildings[DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID] + .uid))); + if ((!_shooterID) + || (DAT_BuildingsState::instance.buildings[_shooterID].buildingType + != Map::Buildings::BT_PITCHDITCH)) { + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playAttackCommandFeedback, + DAT_TribesState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + } else { + MACRO_CALL_MEMBER(Map::Units::TribesState_Func::playArcherCommandSpeech, DAT_TribesState::ptr)( + DAT_TribesState::instance.DAT_CurrentTribeID); + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + } + goto LAB_0043782c; + } + break; + case 20: + if (local_20 != 3) { + DAT_UnitsState::instance.pendingUnitControlMode = 20; + LAB_00437671: + DAT_UnitsState::instance.unitControlsRelated = DAT_UnitsState::instance.pendingUnitControlMode; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand4Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, 20, + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseX)), + (undefined4)((int)(DAT_ViewportRenderState::instance.viewportState.mouseY))); + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + _otherUnitIDUnk = 23; + goto LAB_004376a4; + } + break; + case 22: + if (DAT_TileMapState::instance.pendingUnitCommand != -1) { + DAT_UnitsState::instance.unitControlsRelated = DAT_UnitsState::instance.pendingUnitControlMode; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::queueDisbandAndAttackCommand5Params, + DAT_UnitsState::ptr)(DAT_TribesState::instance.DAT_CurrentTribeID, Map::Units::UIT_THROW_COW, + DAT_TileMapState::instance.instructionTargetX, DAT_TileMapState::instance.instructionTargetY, + DAT_TileMapState::instance.field_0x554a08); + DAT_UnitsState::instance.pendingUnitControlMode = TRUE; + DAT_UnitsState::instance.unitControlsRelated = 1; + DAT_TileMapState::instance.cursorOverlayImageBase = 0; + DAT_TileMapState::instance.cursorOverlayGmID = 107; + _shooterID = MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::selectionContainsCombatUnit, DAT_UnitsState::ptr)(1); + if ((_shooterID) + && (DAT_UnitsState::instance.units[_shooterID] + .digTileX__OR__countCurrentlyManningEnginers__OR__forCowsRandomBelow300 + != 0)) { + _otherUnitIDUnk = 30; + goto LAB_004376a4; + } + } + } + MACRO_CALL(UI::Helpers_Func::SetTribesPatrolButtonPressed)(0); + LAB_0043782c: + switch (local_20) { + case 0: + DAT_MouseState::instance.field_0x1dc = 1; + return; + case 1: + DAT_MouseState::instance.field_0x1dc = 2; + return; + case 2: + DAT_MouseState::instance.field_0x1dc = 3; + return; + case 3: + DAT_MouseState::instance.field_0x1dc = 4; + return; + case 4: + DAT_MouseState::instance.field_0x1dc = 5; + break; + case -1: + DAT_MouseState::instance.field_0x1dc = 0; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 45a88e2504..9ff25e87be 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11149,7 +11149,7 @@ SHC_3BB0A8C1_0x00434350 | 0.0% | Pending SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004348D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004348D0 | 50.2% | 18 returns and the range tests fixed; block layout and register allocation SHC_3BB0A8C1_0x00434FE0 | 0.0% | Pending From d18cf4350fe8a2e93398f3e36cfb6ca937d20435 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:00 +0100 Subject: [PATCH 02/64] headers: GameCommandType value 103 as GCT_UNKNOWN_103 LobbyscreenStartButtonClick queues command 103 with the selected map's index as its parameter (button 105). The draft wrote it as GCT_SHARE_GAME_STATE_PARTIAL_HASHES | GCT_MULTIPLAYER_ANNOUNCE_HOST (100 | 3). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Commands/GameCommandType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/Commands/GameCommandType.hpp b/src/OpenSHC/Commands/GameCommandType.hpp index c85f33d415..fbaed2f30c 100644 --- a/src/OpenSHC/Commands/GameCommandType.hpp +++ b/src/OpenSHC/Commands/GameCommandType.hpp @@ -92,6 +92,7 @@ namespace Commands { GCT_UNKNOWN_98 = 98, // 0x00000062 GCT_SHARE_GAME_STATE_PARTIAL_HASHES = 100, // 0x00000064 GCT_SHARE_SYNC_STATUS = 101, // 0x00000065 + GCT_UNKNOWN_103 = 103, // 0x00000067 GCT_START_OR_STOP_SEND_MAP_FILEUnk = 104, // 0x00000068 GCT_RECEIVE_SENT_MAPPARTUnk = 105, // 0x00000069 GCT_UNKNOWN_107 = 107, // 0x0000006B From d9e82ffa9c6d110f5bf672a06ca99fc2da6b4e74 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:00 +0100 Subject: [PATCH 03/64] headers: SoundEffectID value 253 as SEID_UNKNOWN_0xFD Used by the drafts in the companion development PRs: LobbyscreenStartButtonClick and CrusadeMap_Main play sound 253 when they switch to the rankings screen. The LobbyscreenStartButtonClick draft wrote it as SEID_UNIT_DAMAGE3 | SEID_ARROW_SHOOT (248 | 5). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SoundEffectID.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp index a5472591af..9ad615d102 100644 --- a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp +++ b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp @@ -195,7 +195,8 @@ namespace Audio { SEID_UNIT_DAMAGE1 = 246, // 0x000000F6 SEID_UNIT_DAMAGE2 = 247, // 0x000000F7 SEID_UNIT_DAMAGE3 = 248, // 0x000000F8 - SEID_UNIT_DAMAGE4 = 249 // 0x000000F9 + SEID_UNIT_DAMAGE4 = 249, // 0x000000F9 + SEID_UNKNOWN_0xFD = 253 // 0x000000FD } SoundEffectID; From de8c9f3c51521acbbb4b5ad00219cb2994ee9524 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:13 +0100 Subject: [PATCH 04/64] headers: DAT_00b95960, DAT_00b95f64 and DAT_00b95b74 are ints The lobby's keep-position drag keeps the dragged player's position in DAT_00b95960 (-1 for none, compared signed: cmp/jl at 0x00442A29) and its slot index in DAT_00b95f64 (an array index). DAT_00b95b74 is the map description's height, used signed in the scroll limit. General_MenuMiniMap reads DAT_00b95960 here; the other users are drafts in the companion PRs (LobbyscreenStartButtonClick, MapEditorProperties_MainButtons, SingleplayerMapChoice_ButtonsAndHands). On main, DisplayMapDescriptionAndAllocatePlayersToSlots stores to DAT_00b95b74 and compiles to the same instructions with the int. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00b95960.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b95b74.hpp | 4 ++-- src/OpenSHC/Globals/DAT_00b95f64.hpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00b95960.hpp b/src/OpenSHC/Globals/DAT_00b95960.hpp index 6deb320f2b..226fd387d7 100644 --- a/src/OpenSHC/Globals/DAT_00b95960.hpp +++ b/src/OpenSHC/Globals/DAT_00b95960.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B95960 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B95960) DAT_00b95960; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B95960) DAT_00b95960; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B95960); diff --git a/src/OpenSHC/Globals/DAT_00b95b74.hpp b/src/OpenSHC/Globals/DAT_00b95b74.hpp index 78d702b8d2..57c5c867a4 100644 --- a/src/OpenSHC/Globals/DAT_00b95b74.hpp +++ b/src/OpenSHC/Globals/DAT_00b95b74.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B95B74 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B95B74) DAT_00b95b74; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B95B74) DAT_00b95b74; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B95B74); diff --git a/src/OpenSHC/Globals/DAT_00b95f64.hpp b/src/OpenSHC/Globals/DAT_00b95f64.hpp index 96b21fa118..9837bdba36 100644 --- a/src/OpenSHC/Globals/DAT_00b95f64.hpp +++ b/src/OpenSHC/Globals/DAT_00b95f64.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00B95F64 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00B95F64) DAT_00b95f64; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00B95F64) DAT_00b95f64; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00B95F64); From 908031bd8c6bf9eb30943a64df2e1a5d906d09c9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:27 +0100 Subject: [PATCH 05/64] headers: GameSynchronyState::chatScrollOffset is an int It is compared signed against 0 and 15 (cmp/jge at 0x00442683, jle at 0x0044269E). addChatMessageToDisplayList and clearChatEvents, its users on main, compile to the same code with the int (quick_diff identical). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Synchrony/GameSynchronyState.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/Synchrony/GameSynchronyState.hpp b/src/OpenSHC/Synchrony/GameSynchronyState.hpp index 6fb1b07b32..b6c2e7cd50 100644 --- a/src/OpenSHC/Synchrony/GameSynchronyState.hpp +++ b/src/OpenSHC/Synchrony/GameSynchronyState.hpp @@ -262,7 +262,7 @@ namespace Synchrony { undefined4 skirmishCurrentAdvantageBalance; // 0x001072E4 length: 4 int field_0x1072e8; // 0x001072E8 length: 4 int field_0x1072ec; // 0x001072EC length: 4 - undefined4 chatScrollOffset; // 0x001072F0 length: 4 + int chatScrollOffset; // 0x001072F0 length: 4 BOOLEnum reparseMaps; // 0x001072F4 length: 4 int mapExistenceAckCountdown; // 0x001072F8 length: 4 int DAT_MapSelectionScrollOffset; // 0x001072FC length: 4 From cb601a0749db195988b85ac09fb6f34d8784b9fb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:35:05 +0100 Subject: [PATCH 06/64] reimplement: SHC_3BB0A8C1_0x00442640 90.7% one switch, 3 behaviour fixes; block layout Rewritten from gynt's draft (83.0%) as one switch: the original dispatches 105 and 413 with the table cases (cmp 0x69; jg; je; then the -201..4 jump table), so they are cases, not ifs before the switch, and the ~190 empty case labels are gone. Three behaviour fixes the original's asm shows: - load game (1) and start game (4) return as soon as an occupied slot is not ready (je to the epilogue at 0x004426CA / 0x0044282B); the draft only left the loop and carried on; - dropping a keep position (-201) ends with DAT_00b95960 = -1 on every path, and stops when no position is under the mouse; the draft's loop never ended in that case and skipped the reset after a swap. Command 103 and sound 253 have names (header commits), DAT_00b95960 / DAT_00b95f64 / DAT_00b95b74 and chatScrollOffset are ints, which removes the casts. The swap's temporary is an int, as the original's movsx shows. quick_diff 0.7976 -> 0.9274. Left: block layout - the original places the shared epilogue right after case -1 and falls into it there; ours puts it elsewhere, which shifts most jump displacements. Co-Authored-By: Claude Opus 5.5 --- ..._LobbyMenu_LobbyscreenStartButtonClick.cpp | 292 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp new file mode 100644 index 0000000000..e07dd5c072 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp @@ -0,0 +1,292 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b95960.hpp" +#include "OpenSHC/Globals/DAT_00b95b74.hpp" +#include "OpenSHC/Globals/DAT_00b95f64.hpp" +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00442640 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick(int action, ...) + { + if (DAT_00b960dc::instance != 0) { + return; + } + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + switch (action) { + case -1: + // chat scroll up + if (DAT_GameSynchronyState::instance.chatScrollOffset < 15) { + ++DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case -2: + // chat scroll down + if (DAT_GameSynchronyState::instance.chatScrollOffset > 0) { + --DAT_GameSynchronyState::instance.chatScrollOffset; + } + break; + case 1: + // load game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < 9; ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2) { + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::loadOrSaveGame, DAT_MenuTextInputState::ptr)(9); + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + break; + case 2: + // leave the lobby + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + } else { + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_MULTIPLAYER_END_OF_GAME; + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 7; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk)(22); + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + } + } + break; + case -20: + case 3: + // ready button + if (DAT_GameSynchronyState::instance.flag_0x7aad8 + && DAT_GameSynchronyState::instance.DAT_TwoIfNotHost == 2) { + DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] ^= 1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + } + if (DAT_GameSynchronyState::instance.isHost + && DAT_GameSynchronyState::instance + .DAT_PlayerSlotArraySomeValue[DAT_GameSynchronyState::instance.currentPlayerSlotID] + != 0) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + } + break; + case 4: + // start the game: only when every occupied slot is ready + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int player = 1; player < 9; ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { + return; + } + } + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::checkPlayerSetValid, DAT_GameSynchronyState::ptr)() + >= 2 + && DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + >= 0 + && DAT_GameSynchronyState::instance + .unknownMapRelatedReceivedDataArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices + [DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset]] + > 0) { + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::setTimeBasedSeed, SEC_RNG::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TRIGGER_LOBBY_PLAYER_INFORMATION_REFRESH); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_GAME_INTENSITY_OR_BALANCE); + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_GameCore::instance.isSkirmishTrail = FALSE; + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSkirmishGame)(0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_START_MULTIPLAYER_GAME); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + break; + case -10: + // map list scroll up + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset > 0) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -11: + // map list scroll down + if (DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 8) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CHANGE_MAP_SELECTION); + } + } + break; + case -100: + // map description scroll up + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < -19) { + DAT_00b960f4::instance = -19; + } + break; + case -101: { + // map description scroll down + int const limit = DAT_00b95b74::instance - 114; + if (DAT_00b960f4::instance < limit) { + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + } + break; + } + case -200: + // pick up the keep position under the mouse + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + for (int position = 0; position < 8; ++position) { + int const x = DAT_GameCore::instance.keepPositions[position].x; + if (x < 0 + || DAT_MouseState::instance.screenSpaceX + < x + 572 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + || DAT_MouseState::instance.screenSpaceX + > x + 595 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + DAT_00b95960::instance = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + DAT_00b95f64::instance = position; + return; + } + break; + case -201: + // drop it on the keep position under the mouse: swap the two players' positions + if (!DAT_GameSynchronyState::instance.isHost) { + break; + } + if (DAT_00b95960::instance >= 0) { + for (int position = 0; position < 8; ++position) { + int const x = DAT_GameCore::instance.keepPositions[position].x; + if (x < 0 + || DAT_MouseState::instance.screenSpaceX + < x + 572 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + || DAT_MouseState::instance.screenSpaceX + > x + 595 + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth) { + continue; + } + int const y = DAT_GameCore::instance.keepPositions[position].y + + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + if (DAT_MouseState::instance.screenSpaceY < y + 3 + || DAT_MouseState::instance.screenSpaceY > y + 35) { + continue; + } + int const dragged + = DAT_GameSynchronyState::instance.playerPositionsArray[DAT_00b95f64::instance]; + DAT_GameSynchronyState::instance.playerPositionsArray[DAT_00b95f64::instance] + = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + DAT_GameSynchronyState::instance.playerPositionsArray[position] = dragged; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_HOST_ANNOUNCE_TEAMS_AND_POSITIONS); + break; + } + } + DAT_00b95960::instance = -1; + break; + case 105: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset]; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNKNOWN_103); + break; + case 413: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9ff25e87be..071f1bbe50 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13693,7 +13693,7 @@ SHC_3BB0A8C1_0x00442230 | 0.0% | Pending SHC_3BB0A8C1_0x00442300 | 0.0% | Pending -SHC_3BB0A8C1_0x00442640 | 0.0% | Pending +SHC_3BB0A8C1_0x00442640 | 90.7% | one switch, 3 behaviour fixes; block layout SHC_3BB0A8C1_0x004429C0 | 0.0% | Pending From b88acae1cdf2212849220640a6b7bf7048651443 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:40:20 +0100 Subject: [PATCH 07/64] strings: 0x005A55E0 "Pic" The TextEditor buttons render the label "Pic" (0x005A55E0, between "Link" and "ScrSize"), which had no entry. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/string-literals.hpp | 3 +++ src/OpenSHC/string-macros.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/OpenSHC/string-literals.hpp b/src/OpenSHC/string-literals.hpp index 82ba171ee8..95ede65fda 100644 --- a/src/OpenSHC/string-literals.hpp +++ b/src/OpenSHC/string-literals.hpp @@ -4499,6 +4499,9 @@ char const* const s__Link_005a55d0 = S__LINK_005A55D0; // 0x005a55d8 char const* const s_Link_005a55d8 = S_LINK_005A55D8; +// 0x005a55e0 +char const* const s_Pic_005a55e0 = S_PIC_005A55E0; + // 0x005a55e4 char const* const s_ScrSize_005a55e4 = S_SCRSIZE_005A55E4; diff --git a/src/OpenSHC/string-macros.hpp b/src/OpenSHC/string-macros.hpp index c3439c078e..9fd49cdce0 100644 --- a/src/OpenSHC/string-macros.hpp +++ b/src/OpenSHC/string-macros.hpp @@ -4503,6 +4503,9 @@ // STRING: STRONGHOLDCRUSADER 0x005a55d8 #define S_LINK_005A55D8 "Link" +// STRING: STRONGHOLDCRUSADER 0x005a55e0 +#define S_PIC_005A55E0 "Pic" + // STRING: STRONGHOLDCRUSADER 0x005a55e4 #define S_SCRSIZE_005A55E4 "ScrSize" From 55f7dba604367d032cba0d33877cd2e055ae01ea Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:00:08 +0100 Subject: [PATCH 08/64] reimplement: SHC_3BB0A8C1_0x0045DE40 91.5% switches in the original's order, 3 behaviour fixes; scheduling gynt's draft (77.3% here) with the switches rebuilt from the original's tables: the outer cases in the original's layout order (-1, -2, -4, -5, the 1..15/20 buttons, 31..36), the button labels as a switch on the button number itself (it was param_1 + 5), and the first field52 switch with case 10 after case 3. Three behaviour fixes: button -5 drew its label twice when not pressed (the original returns after the first text call, 0x0045DF3B). Case -4 is an if/else with one call per arm. The 1..15/20 arm keeps the original's test of -4, which never matches there; one comment line says so. The "Pic" label has a string entry now (its own commit). Left: case -5's and the colour copy's scheduling. Pressed buttons 32 and 34 (arms 2, 3, 10 and 12) no longer return after setting the colours: the original goes on into the field52 switch (0x0045E5F8 -> 0x0045E617) and draws the box and "NEXT" (0x0045EAFA -> 0x0045EB0D). The no-op casts on DAT_Button* and textColor are gone, 255 is COL_0000FF, the alignment codes are plain numbers, and the "Back", "Exit" and "Pic" texts are commented (identical code). Co-Authored-By: Claude Opus 5.5 --- ...uItemRenderFunction_TextEditor_Buttons.cpp | 511 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 512 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp new file mode 100644 index 0000000000..1a85bae175 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp @@ -0,0 +1,511 @@ +#include "../TextEditor.func.hpp" + +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/Text/TextManager.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/string-macros.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_WHITE.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_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserHelpDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Text::TextAlignment; + + // FUNCTION: STRONGHOLDCRUSADER 0x0045DE40 + void TextEditor::MenuItemRenderFunction_TextEditor_Buttons(int param_1, ...) + { + char* textAddress; + int xParam; + int yParam; + switch (param_1) { + case -1: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, 0); + break; + case -2: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, 0); + return; + case -4: + if (DAT_TextEditorState::instance.helpSectionHistoryStack[0] != -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + // "Back" + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_HELP, 1, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + // "Back" + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_HELP, 1, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 2); + } + return; + } + break; + case -5: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + // "Exit" + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_HELP, 2, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + // "Exit" + OpenSHC::DE::SHCDE::TEXT_HELP, 2, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE, 2); + return; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 20: + // fixme: the original tests -4 here and in the inner switch (-4, -5), though this arm never sees them + if (param_1 == -4 && DAT_TextEditorState::instance.helpSectionHistoryStack[0] == -1) { + break; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; + } else { + DAT_TextManagerObject::instance.textColor = 0; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + switch (param_1) { + case -4: + // "Back" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_HELP, 1, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 18, FALSE); + return; + case -5: + // "Exit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_HELP, 2, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 18, FALSE); + return; + case 1: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Symbols" + S_SYMBOLS_005A5608, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 2: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "New Page" + S_NEW_PAGE_005A55FC, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 3: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Load" + S_LOAD_005A55F4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 4: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Save" + S_SAVE_005A55EC, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 20: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "ScrSize" + S_SCRSIZE_005A55E4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 5: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Pic" + S_PIC_005A55E0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 6: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Link" + S_LINK_005A55D8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 7: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "\\Link" + S__LINK_005A55D0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 8: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Font" + S_FONT_005A55C8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 9: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Centre" + S_CENTRE_005A55C0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 10: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "\\Centre" + S__CENTRE_005A55B8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 11: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Colour" + S_COLOUR_005A55B0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 12: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "LinkClr" + S_LINKCLR_005A55A8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 13: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Sound" + S_SOUND_005A55A0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 14: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "String" + S_STRING_005A5598, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 15: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "Include" + S_INCLUDE_005A5590, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + } + break; + case 31: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "PIC" + S_PIC_005A558C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + 16777215, 19, FALSE, 0); + return; + case 2: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "FONT" + S_FONT_005A5584, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + 16777215, 19, FALSE, 0); + return; + case 3: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "COLOUR" + S_COLOUR_005A557C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 10: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "LINKCLR" + S_LINKCLR_005A5574, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 4: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "LINK" + S_LINK_005A556C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + 16777215, 19, FALSE, 0); + return; + case 5: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "\\LINK" + S__LINK_005A5564, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + 16777215, 19, FALSE, 0); + return; + case 7: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "CENTRE" + S_CENTRE_005A555C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 8: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "\\CENTRE" + S__CENTRE_005A5554, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 11: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "SOUND" + S_SOUND_005A554C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + 16777215, 19, FALSE, 0); + return; + case 12: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "STRING" + S_STRING_005A5544, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 14: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "INCLUDE" + S_INCLUDE_005A553C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + } + break; + case 32: + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; + } else { + DAT_TextManagerObject::instance.textColor = 16777215; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; + } + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + DAT_TextEditorState::instance.graphicFileNames[(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1]], + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 2: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + yParam = DAT_ButtonY::instance + 3; + xParam = DAT_ButtonX::instance + 3; + textAddress = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::getHelpSectionText, + DAT_TextEditorState::ptr)((uint)(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1]); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + textAddress, xParam, yParam, OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + return; + case 3: + case 10: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + DAT_UserHelpDefinedData::instance + .field_0x7a16c[(ushort)DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex + 1]] + .name_0x0, + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, 16777215, 19, + FALSE, 0); + return; + case 4: + case 14: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + DAT_UserHelpDefinedData::instance.HelpSections[(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1]], + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + default: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + return; + case 11: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + DAT_TextEditorState::instance.soundFileNames[(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + + 1]], + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE); + return; + case 12: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( + (uint)(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1], + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE); + } + break; + case 33: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + DAT_TextManagerObject::instance.textColor + = (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + == 0 + ? OpenSHC::Rendering::Colors::COL_0000FF + : 16777215); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "Left" + S_LEFT_005A5534, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + return; + case 2: + case 3: + case 10: + case 12: + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; + } else { + DAT_TextManagerObject::instance.textColor = 16777215; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "PREV" + S_PREV_005A552C, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + } + break; + case 34: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + switch (DAT_TextEditorState::instance.field_0x23970) { + case 1: + DAT_TextManagerObject::instance.textColor + = (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + == 1 + ? OpenSHC::Rendering::Colors::COL_0000FF + : 16777215); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "Centre" + S_CENTRE_005A55C0, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + return; + case 2: + case 3: + case 10: + case 12: + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; + } else { + DAT_TextManagerObject::instance.textColor = 16777215; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + DAT_PencilRenderCore::instance.otherColorUnk_0x0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( + // "NEXT" + S_NEXT_005A5524, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); + } + break; + case 35: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + if (DAT_TextEditorState::instance.field_0x23970 == 1) { + DAT_TextManagerObject::instance.textColor + = (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + == 2 + ? OpenSHC::Rendering::Colors::COL_0000FF + : 16777215); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "Right" + S_RIGHT_005A551C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + } + break; + case 36: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, DAT_ButtonY::instance, + DAT_ButtonW::instance + DAT_ButtonX::instance, DAT_ButtonH::instance + DAT_ButtonY::instance, + COL_BLACK::instance.shortValue); + if (DAT_TextEditorState::instance.field_0x23970 == 1) { + DAT_TextManagerObject::instance.textColor + = (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] + == 3 + ? OpenSHC::Rendering::Colors::COL_0000FF + : 16777215); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "Here" + S_HERE_005A5514, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + } + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 071f1bbe50..3ab7d446ae 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -18399,7 +18399,7 @@ SHC_3BB0A8C1_0x0045DE34 | 0.0% | Pending SHC_3BB0A8C1_0x0045DE38 | 0.0% | Pending -SHC_3BB0A8C1_0x0045DE40 | 0.0% | Pending +SHC_3BB0A8C1_0x0045DE40 | 91.5% | switches in the original's order, 3 behaviour fixes; scheduling SHC_3BB0A8C1_0x0045EC94 | 0.0% | Pending From 4e89c8ad6d56814016ada6dd1c0c005342b9f189 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:17:12 +0100 Subject: [PATCH 09/64] headers: SoundEffectID values 123-128 and 257 as SEID_UNKNOWN_ InGameMenu_MainButtons plays sound 257 when it opens the pause menu, and 123, 124, 125, 126, 127 and 128 when it opens the build menu's tabs 10, 20, 30, 40, 25 and 28. The draft wrote most of them as ORs of unrelated sounds (SEID_SIEGE_EQUIPMENT_DESTROYED | SEID_INN is 124). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SoundEffectID.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp index 9ad615d102..af86107261 100644 --- a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp +++ b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp @@ -97,6 +97,12 @@ namespace Audio { SEID_UNIT_KILLED_BY_ARROW2 = 118, // 0x00000076 SEID_New_Name = 119, // 0x00000077 SEID_FIRE_IGNITE = 122, // 0x0000007A + SEID_UNKNOWN_0x7B = 123, // 0x0000007B + SEID_UNKNOWN_0x7C = 124, // 0x0000007C + SEID_UNKNOWN_0x7D = 125, // 0x0000007D + SEID_UNKNOWN_0x7E = 126, // 0x0000007E + SEID_UNKNOWN_0x7F = 127, // 0x0000007F + SEID_UNKNOWN_0x80 = 128, // 0x00000080 SEID_UNKNOWN_0x87 = 135, // 0x00000087 SEID_CHICKEN1 = 137, // 0x00000089 SEID_GATEHOUSE_CLOSE = 141, // 0x0000008D @@ -196,7 +202,8 @@ namespace Audio { SEID_UNIT_DAMAGE2 = 247, // 0x000000F7 SEID_UNIT_DAMAGE3 = 248, // 0x000000F8 SEID_UNIT_DAMAGE4 = 249, // 0x000000F9 - SEID_UNKNOWN_0xFD = 253 // 0x000000FD + SEID_UNKNOWN_0xFD = 253, // 0x000000FD + SEID_UNKNOWN_0x101 = 257 // 0x00000101 } SoundEffectID; From de6e5848539e54a5111c2355ad0dcdd5713a86fa Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:39:34 +0100 Subject: [PATCH 10/64] reimplement: SHC_3BB0A8C1_0x00444B80 100.0% Reimplemented From gynt's draft (86.3% here). reccmp's raw 99.8% differs only in the target of the tail call to confirmAndQueueDestructionCommand; normalized 100.0%. The chain tests -1/-6 last (if (button != -1 && button != -6) ... else ...), as the original lays it out. Four behaviour fixes the original's asm shows: - pause button in siege-editor mode: the original returns after switching to the siege view (0x0044513E); the draft fell through and also opened the pause menu; - skirmish/scenario end (-5): the scenario-description path also switches the view and closes the three modal dialogs (the draft returned early); - buttons 71..79 in the editor or siege-editor mode clear DAT_StopHandlingMenuItems and return (0x00444ECC to 0x00444D60); the draft carried on into the menu switch; - closing the building help with those buttons carries on into the menu switch (call at 0x00444EE9, no return); the draft returned. Sounds 123-128 and 257 have names (header commit), the editor slot index is one local, the nine player-ID clears are a loop, and the keep-and-granary test calls its checks inline instead of through temporaries. Co-Authored-By: Claude Opus 5.5 --- ...emActionHandler_InGameMenu_MainButtons.cpp | 330 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp new file mode 100644 index 0000000000..cc7bc3f9f3 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp @@ -0,0 +1,330 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Map/WallAndPitchState.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/MenuItems/MapEditorLandscaping.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_GreatestLordDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00444B80 + void InGameMenu::MenuItemActionHandler_InGameMenu_MainButtons(int buttonID, ...) + { + if (buttonID != -1 && buttonID != -6) { + if (buttonID == -2) { + if (DAT_GameSynchronyState::instance.syncStatus == 0 + && DAT_GameSynchronyState::instance.saveRelated == 0 + && DAT_GameCore::instance.gamePausedLogical == 0 + && (DAT_GameCore::instance.currentMenuViewType + != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU + || (DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM + && DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)) + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordKilledByPlayerID + == 0 + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + == 0) { + MACRO_CALL_MEMBER(OpenSHC::Map::WallAndPitchState_Func::confirmAndQueueDestructionCommand, + DAT_WallAndPitchState::ptr)(); + } + } else if (buttonID == -3) { + if (DAT_GameSynchronyState::instance.syncStatus == 0 + && DAT_GameSynchronyState::instance.saveRelated == 0 + && DAT_GameCore::instance.gamePausedLogical == 0 + && (DAT_GameCore::instance.currentMenuViewType + != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU + || (DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM + && DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)) + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .lordKilledByPlayerID + == 0 + && (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + == 0 + || (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameState::instance.mapAndTime.gameOver + == DAT_GameSynchronyState::instance.currentPlayerSlotID))) { + MACRO_CALL( + OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_ToolbarButtonPressed)( + OpenSHC::Commands::M_MAPPER_DELETE); + } + } else if (buttonID == -5) { + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + == 0) { + DAT_GameCore::instance.gameSuspended = 1; + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, + DAT_BinkControlState::ptr)(1); + DAT_GameCore::instance.isBinkVideoPlaying = 0; + // compared with TRUE: the original tests isSkirmishTrail == 1 (0x00444D14) + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_GameCore::instance.isSkirmishTrail == TRUE) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_MISSION_INTRO, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + } + } else { + // nested, with the two early returns: one else-if chain loses the match + if (buttonID == -4) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + if (buttonID == -90) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + if (DAT_GameCore::instance.genieVoiceActive) { + // "Genie_11.wav" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + SFX_YourAllies); + } + } else { + if (buttonID == -91) { + DAT_GreatestLordDefinedData::instance.tableSortBy = -1; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_GREATEST_LORD, FALSE); + return; + } + if (buttonID <= -10) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + if (buttonID > -100) { + for (int player = 0; player < 9; ++player) { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] = -1; + } + // buttons -10 to -17 pick editor player 1 to 8 + int const slot = -9 - buttonID; + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = slot; + return; + } + // without the -100 test the original's je after the jle (0x00444DDB) goes + if (buttonID != -100) { + if (buttonID == -101) { + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + DAT_TileMapState::instance.savedEditorActiveBrush + = DAT_TileMapState::instance.editorActiveBrush; + MACRO_CALL(OpenSHC::UI::MenuItems::MapEditorLandscaping_Func:: + MenuItemActionHandler_MapEditorLandscaping_GeneralButtons)( + OpenSHC::Commands::M_MAPPER_TOMAIN); + } else if (buttonID == -102) { + DAT_TileMapState::instance.editorActiveBrush + = DAT_TileMapState::instance.savedEditorActiveBrush; + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, + DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, + DAT_UnitsState::ptr)(); + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemActionHandler_General_ToolbarButtonPressed)( + OpenSHC::Commands::M_MAPPER_TOTEST); + } + } + } + } else if (buttonID >= OpenSHC::UI::Enums::BASMTT_STATUS_OVERVIEW + && buttonID <= OpenSHC::UI::Enums::BASMTT_STATUS_RELIGION) { + if (DAT_GameSynchronyState::instance.syncStatus == 0 + && DAT_GameCore::instance.gamePausedLogical == 0) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BUILDING_HELP_TEXT) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + } + int statusTab = buttonID; + if ((((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) + && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) + || (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1 + && MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func:: + singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)() + == 0 + && MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, + DAT_UnitsState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID) + != 0) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + && DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 + == OpenSHC::Map::MT_SIEGE)) + && !MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { + statusTab = OpenSHC::UI::Enums::BASMTT_STATUS_ARMY; + } + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + if (DAT_UnitsState::instance + .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + > 0) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, + DAT_GameCore::ptr)(OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + } + MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, + DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = statusTab; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 1; + DAT_BuildingsState::instance.newSelectedBuildingID = 0; + DAT_BuildingsState::instance.newSelectedUnitID = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL + && statusTab == OpenSHC::UI::Enums::BASMTT_STATUS_OVERVIEW) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialBuildingActionState)( + 14, OpenSHC::Map::Buildings::BT_HOVEL); + } + } + } else if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_BUILD_MENU + || buttonID != DAT_GameCore::instance.activeMenuTab.buildMenuTab) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + if (DAT_UnitsState::instance + .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + > 0) { + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = DAT_GameCore::instance.tabTypeSiegeSubset; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + } + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = buttonID; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 1; + switch (buttonID) { + case OpenSHC::UI::Enums::BMTT_CASTLE: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7B); + break; + case OpenSHC::UI::Enums::BMTT_INDUSTRY: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7C); + break; + case OpenSHC::UI::Enums::BMTT_TOWN: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7D); + break; + case OpenSHC::UI::Enums::BMTT_FARMS: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7E); + break; + case OpenSHC::UI::Enums::BMTT_FOOD: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7F); + break; + case OpenSHC::UI::Enums::BMTT_WEAPONS: + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, + DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x80); + break; + } + } + } + } + } else { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNUSED_CREATE_SIEGE, 0); + return; + } + if (((DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU) + || ((DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM + && (DAT_GameCore::instance.activeMenuTab.tabType + != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)))) + && DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_PAUSE_MENU); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x101); + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3ab7d446ae..c8a28f18e1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -15407,7 +15407,7 @@ SHC_3BB0A8C1_0x00444B71 | 0.0% | Pending SHC_3BB0A8C1_0x00444B72 | 0.0% | Pending -SHC_3BB0A8C1_0x00444B80 | 0.0% | Pending +SHC_3BB0A8C1_0x00444B80 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00445184 | 0.0% | Pending From 2001534042e3011b778e053f4bbae4cf0d990fe6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:03:56 +0100 Subject: [PATCH 11/64] reimplement: SHC_3BB0A8C1_0x004B9E50 88.0% arms in the original's order and store order; register allocation gynt's draft (83.3% here) with the -1 and -2 arms as the original lays them out: the repeat clamp in case 4 falls through into the minimum check (no early return), the minimum clamp stores the value first, both arms write case 7 out (the original shares one block between them, so the goto into -2's case 7 is gone) and -2's case 7 comes before case 4. The minimum, maximum and current values are stored in the original's order in -2's cases 1-3 and in the action arm's case 1 (stores through the three pointers keep source order). quick_diff 0.7797 -> 0.8373. Left: register choice in the -2 arm, one byte longer. Co-Authored-By: Claude Opus 5.5 --- ...uItemActionHandler_General_EventSlider.cpp | 309 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp new file mode 100644 index 0000000000..8b9d7f4673 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp @@ -0,0 +1,309 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9E50 + void General::MenuItemActionHandler_General_EventSlider( + int param_1, int param_2, int* minValue, int* maxValue, int* currentValue) + { + int iVar1 = 0; + switch (param_1) { + case 5: + iVar1 = 10; + break; + case 12: + case 18: + iVar1 = 5; + break; + case 19: + case 21: + iVar1 = 20; + break; + case -10: + iVar1 = (*(int*)&DAT_MapPropertiesState::instance.invasionEventContent.padding_0xa4[0]); + break; + case -9: + case -8: + case -7: + case -6: + case -5: + case -4: + case -3: + case -2: + case -1: + case 0: + case 1: + case 2: + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 13: + case 14: + case 15: + case 16: + case 17: + case 20: + break; + default: + break; + } + switch (param_1) { + case -1: + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case 5: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 29: + case 30: + switch (param_2) { + case 1: + *minValue = 0; + *maxValue = 60; + *currentValue = (uint)DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat; + return; + case 2: + case 3: + *minValue = 0; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = (byte)*currentValue; + return; + case 4: + *currentValue = (uint)DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat; + *minValue = 0; + *maxValue = 60; + if (*currentValue > 60) { + *currentValue = 60; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = (byte)*maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = (byte)*minValue; + } + break; + case 7: + *currentValue = 1; + break; + } + } + break; + case -2: + switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + case 5: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 29: + case 30: + switch (param_2) { + case 1: + *minValue = 1; + *maxValue = 10; + *currentValue = (uint)DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = (byte)*currentValue; + return; + case 7: + *currentValue = 1; + break; + case 4: + *currentValue = (uint)DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths; + *minValue = 1; + *maxValue = 10; + if (*currentValue > 10) { + *currentValue = 10; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = (byte)*maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = (byte)*minValue; + } + break; + } + } + break; + case 5: + case 12: + case 18: + case 19: + case 21: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == param_1 - 1) { + switch (param_2) { + case 1: + *minValue = 1; + *maxValue = iVar1; + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *currentValue; + return; + case 4: + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + *minValue = 1; + *maxValue = iVar1; + if (iVar1 < *currentValue) { + *currentValue = iVar1; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = *minValue; + } + break; + case 5: + iVar1 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + if (iVar1 < *maxValue) { + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = iVar1 + 1; + } + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + return; + case 6: + iVar1 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + if (iVar1 > 0) { + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = iVar1 - 1; + } + *currentValue = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData; + } + } + break; + case -10: + switch (param_2) { + case 1: + *minValue = 1; + *maxValue = iVar1; + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + return; + case 2: + case 3: + *minValue = 1; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *currentValue; + return; + case 4: + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + *minValue = 1; + *maxValue = iVar1; + if (iVar1 < *currentValue) { + *currentValue = iVar1; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *maxValue; + } + if (*currentValue < *minValue) { + *currentValue = *minValue; + DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 = *minValue; + } + break; + case 5: + if (DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 < *maxValue) { + ++DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + return; + case 6: + if (DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8 > 0) { + --DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + *currentValue = DAT_MapPropertiesState::instance.invasionEventContent.field_0xa8; + } + break; + case -9: + case -8: + case -7: + case -6: + case -5: + case -4: + case -3: + case 0: + case 1: + case 2: + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 13: + case 14: + case 15: + case 16: + case 17: + case 20: + break; + default: + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c8a28f18e1..dd2ea38541 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -28653,7 +28653,7 @@ SHC_3BB0A8C1_0x004B9E4E | 0.0% | Pending SHC_3BB0A8C1_0x004B9E4F | 0.0% | Pending -SHC_3BB0A8C1_0x004B9E50 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9E50 | 88.0% | arms in the original's order and store order; register allocation SHC_3BB0A8C1_0x004BA2A0 | 0.0% | Pending From 59e1c3096baa1f472c980ef360c00eca48128692 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:06:12 +0100 Subject: [PATCH 12/64] headers: BuildingsAndStatusMenuTabType value 0 as BASMTT_NONE SelectCrusade_Main clears the menu tab to switch to with 0 (no tab), and MissionEndscreen_Main stores 0 into the active tab. The ChooseNetworkServiceProvider_Buttons draft in the companion development PR uses it too. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp b/src/OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp index 48b86d130a..afe445a7fd 100644 --- a/src/OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp +++ b/src/OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp @@ -13,6 +13,7 @@ namespace UI { namespace Enums { typedef enum BuildingsAndStatusMenuTabType { + BASMTT_NONE = 0, // 0x00000000 BASMTT_BARRACKS_OR_MPMENU_MODEM = 1, // 0x00000001 BASMTT_KEEP_OR_MPMENU_IPX = 2, // 0x00000002 BASMTT_INN_OR_MPMMENU_UNK = 3, // 0x00000003 From 1c0e578c74005c627b5665f1864e01102e690714 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:23:36 +0100 Subject: [PATCH 13/64] headers: TileMapState's editor brush, brush half-size and affect type are ints The map editor compares the active brush and the affect type signed (jle at 0x00431563 and 0x004315E3, jge at 0x004317D3) and halves the brush with sar. switchToMenuView on main and InGameMenu_MainButtons here compile to the same code (quick_diff identical); the other users are drafts in the companion development PRs (MapEditorLandscaping_GeneralButtons, MapEditorLandscaping_QueueCommandCallback). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/TileMapState.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/Map/TileMapState.hpp b/src/OpenSHC/Map/TileMapState.hpp index b56f2d9b3e..86c035d116 100644 --- a/src/OpenSHC/Map/TileMapState.hpp +++ b/src/OpenSHC/Map/TileMapState.hpp @@ -125,16 +125,16 @@ namespace Map { undefined4 flatViewToggleValue2; // 0x005548D4 length: 4 undefined4 refreshRelatedTwo; // 0x005548D8 length: 4 undefined4 savedEditorActiveBrush; // 0x005548DC length: 4 - undefined4 editorActiveBrush; // 0x005548E0 length: 4 + int editorActiveBrush; // 0x005548E0 length: 4 MappersEnum currentMapperCommand; // 0x005548E4 length: 4 undefined4 DAT_BuildingSize; // 0x005548E8 length: 4 undefined4 unitPlacementCount; // 0x005548EC length: 4 BOOLEnum mapperMax; // 0x005548F0 length: 4 undefined4 rockFlagStartNumber; // 0x005548F4 length: 4 - undefined4 unknownBrushRelated; // 0x005548F8 length: 4 + int unknownBrushRelated; // 0x005548F8 length: 4 undefined4 editorSnapToMode; // 0x005548FC length: 4 undefined4 unknownZero_0x554900; // 0x00554900 length: 4 - undefined4 editorAffectType; // 0x00554904 length: 4 + int editorAffectType; // 0x00554904 length: 4 undefined4 wallCornerRotation; // 0x00554908 length: 4 int dragStartX; // 0x0055490C length: 4 int dragStartY; // 0x00554910 length: 4 From d6257a499cc89ddf0c5a6cf4f42b6d74343c4169 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:33:29 +0100 Subject: [PATCH 14/64] reimplement: SHC_3BB0A8C1_0x004314E0 83.4% one switch, no gotos; shared brush store gynt's draft (81.1% here) as one switch without gotos: AREA_BACK is a case of it (the original dispatches it next to the table, cmp 0x14b; je), AREA and AREA_BACK each write their brush step in full, and every big-rock case writes its odd-brush adjustment itself; MSVC merges the rock cases' identical tails again, as the original does. The brush, its half-size and the affect type are ints (header commit), so the compares are signed as in the original. quick_diff 0.7430 -> 0.8145. Left: the original shares one brush store between AREA's and AREA_BACK's adjustments (cross-jumps between the two cases); written out per branch, ours stores in each. Co-Authored-By: Claude Opus 5.5 --- ...er_MapEditorLandscaping_GeneralButtons.cpp | 246 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp new file mode 100644 index 0000000000..4bd8371612 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp @@ -0,0 +1,246 @@ +#include "../MapEditorLandscaping.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Commands::MappersEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004314E0 + void MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_GeneralButtons(MappersEnum param_1, ...) + { + switch (param_1) { + case OpenSHC::Commands::M_MAPPER_EXIT: + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNUSED_OLD_TITLE_MENU, 0); + return; + case OpenSHC::Commands::M_MAPPER_REBUILD: + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::ptr)(); + return; + case OpenSHC::Commands::M_MAPPER_TO_MAP_EDIT: + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + return; + case OpenSHC::Commands::M_MAPPER_TOMAIN: + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_HUNTERSHUT; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + return; + case OpenSHC::Commands::M_MAPPER_AREA: { + int brush = DAT_TileMapState::instance.editorActiveBrush + 1; + DAT_TileMapState::instance.editorActiveBrush = brush; + if (brush > 7) { + brush = 1; + DAT_TileMapState::instance.editorActiveBrush = brush; + } + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK1 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK2 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK3 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK4 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK5) { + if (brush == 2) { + brush = 3; + DAT_TileMapState::instance.editorActiveBrush = brush; + } else if (brush == 4) { + brush = 5; + DAT_TileMapState::instance.editorActiveBrush = brush; + } else if (brush == 6) { + brush = 7; + DAT_TileMapState::instance.editorActiveBrush = brush; + } + } + DAT_TileMapState::instance.unknownBrushRelated = brush >> 1; + DAT_StopHandlingMenuItems::instance = 0; + return; + } + case OpenSHC::Commands::M_MAPPER_AFFECT_TYPE: + if (++DAT_TileMapState::instance.editorAffectType > 1) { + DAT_TileMapState::instance.editorAffectType = 0; + } + return; + case OpenSHC::Commands::M_MAPPER_MIN: + DAT_TileMapState::instance.mapperMax = FALSE; + DAT_TileMapState::instance.currentMapperCommand = param_1; + return; + case OpenSHC::Commands::M_MAPPER_MAX: + DAT_TileMapState::instance.mapperMax = TRUE; + DAT_TileMapState::instance.currentMapperCommand = param_1; + return; + // each rock steps the brush up to the next odd size: the original repeats the tail in every case + case OpenSHC::Commands::M_MAPPER_BIGROCK1: + DAT_TileMapState::instance.editorRockType = 1; + DAT_TileMapState::instance.rockOrientation = 0; + DAT_TileMapState::instance.currentMapperCommand = param_1; + if (DAT_TileMapState::instance.editorActiveBrush == 2) { + DAT_TileMapState::instance.editorActiveBrush = 3; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 4) { + DAT_TileMapState::instance.editorActiveBrush = 5; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 6) { + DAT_TileMapState::instance.editorActiveBrush = 7; + } + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK2: + DAT_TileMapState::instance.editorRockType = 2; + DAT_TileMapState::instance.rockOrientation = 2; + DAT_TileMapState::instance.currentMapperCommand = param_1; + if (DAT_TileMapState::instance.editorActiveBrush == 2) { + DAT_TileMapState::instance.editorActiveBrush = 3; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 4) { + DAT_TileMapState::instance.editorActiveBrush = 5; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 6) { + DAT_TileMapState::instance.editorActiveBrush = 7; + } + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK3: + DAT_TileMapState::instance.editorRockType = 3; + DAT_TileMapState::instance.rockOrientation = 4; + DAT_TileMapState::instance.currentMapperCommand = param_1; + if (DAT_TileMapState::instance.editorActiveBrush == 2) { + DAT_TileMapState::instance.editorActiveBrush = 3; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 4) { + DAT_TileMapState::instance.editorActiveBrush = 5; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 6) { + DAT_TileMapState::instance.editorActiveBrush = 7; + } + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK4: + DAT_TileMapState::instance.editorRockType = 4; + DAT_TileMapState::instance.rockOrientation = 6; + DAT_TileMapState::instance.currentMapperCommand = param_1; + if (DAT_TileMapState::instance.editorActiveBrush == 2) { + DAT_TileMapState::instance.editorActiveBrush = 3; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 4) { + DAT_TileMapState::instance.editorActiveBrush = 5; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 6) { + DAT_TileMapState::instance.editorActiveBrush = 7; + } + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK5: + DAT_TileMapState::instance.editorRockType = 5; + DAT_TileMapState::instance.rockOrientation = 0; + DAT_TileMapState::instance.currentMapperCommand = param_1; + if (DAT_TileMapState::instance.editorActiveBrush == 2) { + DAT_TileMapState::instance.editorActiveBrush = 3; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 4) { + DAT_TileMapState::instance.editorActiveBrush = 5; + return; + } + if (DAT_TileMapState::instance.editorActiveBrush == 6) { + DAT_TileMapState::instance.editorActiveBrush = 7; + } + return; + case OpenSHC::Commands::M_MAPPER_SNAP_TO: + if (DAT_TileMapState::instance.editorSnapToMode == 0) { + DAT_TileMapState::instance.editorSnapToMode = 1; + return; + } + DAT_TileMapState::instance.editorSnapToMode = DAT_TileMapState::instance.editorSnapToMode == 1 ? 2 : 0; + return; + case OpenSHC::Commands::M_MAPPER_MAP_SIZE: + if (DAT_TileMapState::instance.mapSize == 0) { + DAT_TileMapState::instance.mapSize = 400; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapSize, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.mapSize); + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::resetHeightAndMapBorders, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.mapSize); + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::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; + case OpenSHC::Commands::M_MAPPER_MP_KEEP1: + case OpenSHC::Commands::M_MAPPER_MP_KEEP2: + case OpenSHC::Commands::M_MAPPER_MP_KEEP3: + case OpenSHC::Commands::M_MAPPER_MP_KEEP4: + case OpenSHC::Commands::M_MAPPER_MP_KEEP5: + case OpenSHC::Commands::M_MAPPER_MP_KEEP6: + case OpenSHC::Commands::M_MAPPER_MP_KEEP7: + case OpenSHC::Commands::M_MAPPER_MP_KEEP8: + DAT_GameSynchronyState::instance.editorPlacementPlayerID + = param_1 - OpenSHC::Commands::M_MAPPER_SUB_MODE_FEATURE_MP; + if (DAT_GameCore::instance.mapU2MiddleBytes[2] == 0) { + DAT_TileMapState::instance.currentMapperCommand + = (OpenSHC::Commands::MappersEnum)((DAT_GameCore::instance.mapU2MiddleBytes[1] != 0) + + OpenSHC::Commands::M_MAPPER_KEEP1); + return; + } + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_KEEP3; + return; + case OpenSHC::Commands::M_MAPPER_AREA_BACK: { + int brush = DAT_TileMapState::instance.editorActiveBrush - 1; + DAT_TileMapState::instance.editorActiveBrush = brush; + if (brush < 1) { + brush = 7; + DAT_TileMapState::instance.editorActiveBrush = brush; + } + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK1 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK2 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK3 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK4 + || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK5) { + if (brush == 2) { + brush = 1; + DAT_TileMapState::instance.editorActiveBrush = brush; + } else if (brush == 4) { + brush = 3; + DAT_TileMapState::instance.editorActiveBrush = brush; + } else if (brush == 6) { + brush = 5; + DAT_TileMapState::instance.editorActiveBrush = brush; + } + } + DAT_TileMapState::instance.unknownBrushRelated = brush >> 1; + DAT_StopHandlingMenuItems::instance = 0; + return; + } + default: + DAT_GameSynchronyState::instance.editorPlacementPlayerID = 1; + DAT_TileMapState::instance.currentMapperCommand = param_1; + return; + case OpenSHC::Commands::M_MAPPER_TEST: + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index dd2ea38541..c3513ff51d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -10543,7 +10543,7 @@ SHC_3BB0A8C1_0x004313C0 | 0.0% | Pending SHC_3BB0A8C1_0x00431460 | 0.0% | Pending -SHC_3BB0A8C1_0x004314E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004314E0 | 83.4% | one switch, no gotos; shared brush store SHC_3BB0A8C1_0x0043184C | 0.0% | Pending From dc70c99cebef2a3c1fa518a088bb261ddeaa781f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 15:23:19 +0100 Subject: [PATCH 15/64] headers: SoundEffectID values 146 and 251 as SEID_UNKNOWN_ Sound 146 is the menu buttons' hover sound: NewMapMapsize_Buttons and NewMapMaptype_Buttons play it when the cursor moves onto another button, and so does the HistoricCampaignSelect draft in the companion development PR. 251 has no user in these PRs: the main menu render function, which is not in them, plays it when the cursor first moves onto button 5. The drafts wrote them as SEID_CHILDREN_PLAY_MAYPOLE | SEID_WOOD_CHOP (144 | 2) and SEID_UNIT_DAMAGE3 | SEID_WOOD_SAW (248 | 3). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SoundEffectID.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp index af86107261..ad21aa676c 100644 --- a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp +++ b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp @@ -109,6 +109,7 @@ namespace Audio { SEID_GATEHOUSE_OPEN = 143, // 0x0000008F SEID_CHILDREN_PLAY_MAYPOLE = 144, // 0x00000090 SEID_SWORDSMAN_SWORD_SWING = 145, // 0x00000091 + SEID_UNKNOWN_0x92 = 146, // 0x00000092 SEID_GATEHOUSE_CLOSED = 147, // 0x00000093 SEID_UNIT_MACE_KILL2 = 151, // 0x00000097 SEID_UNIT_PENETRATION_DAMAGE = 153, // 0x00000099 @@ -202,6 +203,7 @@ namespace Audio { SEID_UNIT_DAMAGE2 = 247, // 0x000000F7 SEID_UNIT_DAMAGE3 = 248, // 0x000000F8 SEID_UNIT_DAMAGE4 = 249, // 0x000000F9 + SEID_UNKNOWN_0xFB = 251, // 0x000000FB SEID_UNKNOWN_0xFD = 253, // 0x000000FD SEID_UNKNOWN_0x101 = 257 // 0x00000101 From 4cfd4b4012162ba51aa2b59c6a5158e18178c26e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 15:37:37 +0100 Subject: [PATCH 16/64] reimplement: SHC_3BB0A8C1_0x00428150 100.0% Reimplemented Rewritten from gynt's draft (94.0%). The original returns as soon as a modal dialog is open (call, test, jne to the epilogue before any register is saved) and reads the button position afterwards; the draft read the position first and wrapped the body in an if. The position loop is a for loop instead of do-while, the locals are named (keepX, drawX, player, playerIndex) and the casts are gone: the fields are already char and int. Raw 98.5%: only the type name in the symbol of DAT_00b95960 differs (int here, unsigned int on the original side), the address is the same; normalized 100%. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_General_MenuMiniMap.cpp | 146 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp new file mode 100644 index 0000000000..3a3cdf0c45 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp @@ -0,0 +1,146 @@ +#include "../General.func.hpp" + +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MinimapViewState.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00b95960.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/INT_00b95950.hpp" +#include "OpenSHC/Globals/INT_00b95f6c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00428150 + void General::MenuItemRenderFunction_General_MenuMiniMap(int unused, ...) + { + if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + int const buttonX = DAT_ButtonX::instance; + int const buttonY = DAT_ButtonY::instance; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderedBoxWithCustomBlendedBackground, + DAT_PencilRenderCore::ptr)( + buttonX - 108, buttonY - 108, 216, 216, DAT_ButtonBackgroundBlendStrength::instance); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber == 0 + || DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected == -1) { + return; + } + if (DAT_ButtonBackgroundBlendStrength::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapPreview, DAT_MinimapViewState::ptr)( + buttonX - 100, buttonY - 100); + for (int position = 0; position < 8; ++position) { + int const keepX = DAT_GameCore::instance.keepPositions[position].x; + if (keepX < 0) { + continue; + } + char const player = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + if (player == DAT_00b95960::instance) { + continue; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // -10 marks a free position + if (player == -10) { + if (INT_00b95950::instance == position) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 211, + keepX - 103 + buttonX, + DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 220, + keepX - 103 + buttonX, + DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); + } + } else { + if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player + 1] > 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player + 1] * 2 + 492, + keepX - 96 + buttonX, DAT_GameCore::instance.keepPositions[position].y - 100 + buttonY, + 12); + } + if (INT_00b95f6c::instance != 0) { + // the keep position and the player are read again: caching them loses the match + int const drawX = DAT_GameCore::instance.keepPositions[position].x - 113 + buttonX; + int const playerIndex = DAT_GameSynchronyState::instance.playerPositionsArray[position]; + int const drawY = DAT_GameCore::instance.keepPositions[position].y - 116 + buttonY; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerIndex + 1] != -1) { + // Render Player portrait + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, playerIndex + 719, drawX, drawY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameSynchronyState::instance.playerPositionsArray[position] + 20, drawX + 2, + drawY + 2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)( + drawX, drawY, drawX + 35, drawY + 35, COL_BLACK::instance.shortValue); + } else if (DAT_GameSynchronyState::instance.currentAIArray[playerIndex + 1] != 0) { + // Render AI portrait + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, playerIndex + 719, drawX, drawY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameSynchronyState::instance.currentAIArray + [DAT_GameSynchronyState::instance.playerPositionsArray[position] + 1] + + 700, + drawX, drawY); + } + } else if (INT_00b95950::instance == position) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, + DAT_GameSynchronyState::instance.playerPositionsArray[position] + 212, + DAT_GameCore::instance.keepPositions[position].x - 103 + buttonX, + DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameSynchronyState::instance.playerPositionsArray[position] + 470, + DAT_GameCore::instance.keepPositions[position].x - 103 + buttonX, + DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); + } + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (DAT_00b95960::instance >= 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_00b95960::instance + 470, DAT_MouseState::instance.screenSpaceX - 5, + DAT_MouseState::instance.screenSpaceY - 7); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (!DAT_MouseState::instance.leftClickState && !DAT_MouseState::instance.draggingStopped) { + DAT_00b95960::instance = -1; + } + } + } + INT_00b95950::instance = -1; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c3513ff51d..cd1eb90b45 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6861,7 +6861,7 @@ SHC_3BB0A8C1_0x0042804F | 0.0% | Pending SHC_3BB0A8C1_0x00428050 | 0.0% | Pending -SHC_3BB0A8C1_0x00428150 | 0.0% | Pending +SHC_3BB0A8C1_0x00428150 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00428480 | 0.0% | Pending From 9529bf126fdd5911b8e28bba6a2bc12b2587ec5f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 15:37:37 +0100 Subject: [PATCH 17/64] reimplement: SHC_3BB0A8C1_0x004437E0 99.4% 1 behaviour fix; scheduling Rewritten from gynt's draft (89.1%). One behaviour fix the original's asm shows: in case 5 the original opens the quit dialog only when INT_00b95f68 is set, and otherwise only switches to the custom scenarios menu; the draft opened the quit dialog on both paths. The player slot is read once into a const local, as the original keeps it in a register for every playerDataArray store, startResources is indexed by RT_GOLD / RT_STONE, and the map name is STR_Mission22Map from string-literals.hpp. Left: the original loads ecx for importTradingCosts after the three playerDataArray stores, ours before them; reordering the stores around it made it worse. Co-Authored-By: Claude Opus 5.5 --- ...ionHandler_UnusedCreateSiege_SiegeThat.cpp | 174 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp new file mode 100644 index 0000000000..62a5cd335e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp @@ -0,0 +1,174 @@ +#include "../Unused.func.hpp" + +#include "OpenSHC/AI/AICState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Units/TroopValueState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/UI/MenuItems/MapEditorLandscaping.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Map/MapLockState.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_AICState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_TroopValueState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95f68.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" +#include "OpenSHC/Globals/INT_00b960ec.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004437E0 + void Unused::MenuItemActionHandler_UnusedCreateSiege_SiegeThat(int param_1, ...) + { + switch (param_1) { + case 5: + if (INT_00b95f68::instance != 0) { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 43; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_QUIT_DIALOG); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + return; + case 4: { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setupAllMapSections, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + // "mission22.map" + OpenSHC::IO::FRT_MAPS, STR_Mission22Map); + MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + DAT_GameCore::instance.section1095 = 0; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::clearEnemyRelatedStructures, DAT_GameState::ptr)(); + DAT_UnitsState::instance.lastSelectedUnitID = 0; + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameState::instance.playerDataArray[slot].startResources[OpenSHC::Game::Resources::RT_GOLD] = 1500; + DAT_GameState::instance.playerDataArray[slot].startResources[OpenSHC::Game::Resources::RT_STONE] = 1000; + DAT_GameState::instance.playerDataArray[slot].pitchDitchTileCount = 0; + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; + DAT_GameState::instance.playerDataArray[slot].moatTileCount = 0; + DAT_GameCore::instance.mapU4Int1 = 1; + INT_00b960ec::instance = 1; + MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::importTradingCosts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::TroopValueState_Func::clearAttackInfo, DAT_TroopValueState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::AI::AICState_Func::recomputeAIZonerLayer, DAT_AICState::ptr)(); + // case 4 goes on into case 6 + } + case 6: + INT_00b95f68::instance = 1; + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SIEGE_THAT; + DAT_GameCore::instance.missionNumber1to20 = 27; + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_GameCore::instance.missionNumber1to20 = 31; + MACRO_CALL(OpenSHC::UI::MenuItems::MapEditorLandscaping_Func:: + MenuItemActionHandler_MapEditorLandscaping_GeneralButtons)(OpenSHC::Commands::M_MAPPER_TOMAIN); + INT_00b960ec::instance = 1; + return; + case 2: + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::loadOrSaveMap, DAT_MenuTextInputState::ptr)( + OpenSHC::UI::Enums::MMT_LOAD_MAP); + INT_00b960ec::instance = 1; + return; + case 35: + if (INT_00b960ec::instance != 0) { + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, + DAT_MapPropertiesState::ptr)(); + DAT_MenuTextInputState::instance.field_0x9c = 1; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + DAT_GameCore::instance.U3_mapLockedState = OpenSHC::Map::MLS_EDITABLE; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::loadOrSaveMap, DAT_MenuTextInputState::ptr)( + OpenSHC::UI::Enums::MMT_SAVE_MAP); + INT_00b960e4::instance = 1; + } + break; + case 36: + if (INT_00b960ec::instance != 0) { + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, + DAT_MapPropertiesState::ptr)(); + DAT_MenuTextInputState::instance.field_0x9c = 1; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + DAT_GameCore::instance.U3_mapLockedState = OpenSHC::Map::MLS_PLAYABLE; + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, DAT_MenuTextInputState::ptr)(10); + INT_00b960e4::instance = 1; + } + break; + case 3: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + case 33: + case 34: + break; + default: + break; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index cd1eb90b45..4ed1cc1264 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14265,7 +14265,7 @@ SHC_3BB0A8C1_0x004437D8 | 0.0% | Pending SHC_3BB0A8C1_0x004437D9 | 0.0% | Pending -SHC_3BB0A8C1_0x004437E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004437E0 | 99.4% | 1 behaviour fix; scheduling SHC_3BB0A8C1_0x004439F0 | 0.0% | Pending From 296480f2a03268b6c4a82468368d5be5f1c91eba Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 15:55:50 +0100 Subject: [PATCH 18/64] headers: the tutorial step counters are ints DAT_TutorialCurrentStep and DAT_00df5554 are compared signed everywhere the original reads them (jl / jle in the tutorial box handler), so they are int, like DAT_00df5558, DAT_00df555c and DAT_00df556c, which main's header sync 7c6bb9e26 already has as int; that removes the casts in the tutorial box handler. Their other users compile to the same instructions (only the resolver symbols' type changes): GetCurrentTutorialStep on main and the tutorial box render function here. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00df5554.hpp | 4 ++-- src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00df5554.hpp b/src/OpenSHC/Globals/DAT_00df5554.hpp index 2f54576c25..49c7c492af 100644 --- a/src/OpenSHC/Globals/DAT_00df5554.hpp +++ b/src/OpenSHC/Globals/DAT_00df5554.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF5554 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5554) DAT_00df5554; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF5554) DAT_00df5554; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5554); diff --git a/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp b/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp index f3bdf38a75..2e9a4a38d2 100644 --- a/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp +++ b/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF5550 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5550) DAT_TutorialCurrentStep; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF5550) DAT_TutorialCurrentStep; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5550); From de8063421c0b711cbdb0efe20372d413d8a1c160 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:45:36 +0100 Subject: [PATCH 19/64] reimplement: SHC_3BB0A8C1_0x004C1070 88.0% cleanup; register allocation Rewritten from gynt's draft (88.0%, the same code). Named locals (traderIndex, resource, icon, imhIndex), GM_INTERFACE_ICONS2 for the GM index, early returns, no casts. The draft's comment on the second text said "On"; the game's text table has 173 as "Off". Left: register allocation in the text position sums; the compiler normalises the operand order, so no spelling moves it. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_TraderSettings.cpp | 127 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 128 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..075cc4c29d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp @@ -0,0 +1,127 @@ +#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/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 param_1, ...) + { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (param_1 < 0) { + int const traderIndex = -1 - param_1; + DAT_ButtonCurrentlyInteracting::instance + = DAT_MapPropertiesState::instance.SEC_Section1065 + .tradeabilityArray[DAT_MissionAestheticsDefinedData::instance.field_0x345c[traderIndex]] + != 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[traderIndex]; + int icon = resource * 2 + 141; + if (icon == 157) { + icon = 155; + } + int const imhIndex = icon + GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2] - 1; + 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); + // "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), + DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + 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); + // "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), + DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, 8170159, 18, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (param_1 < 1000) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (param_1 == 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, 41727, 15974, 18, FALSE); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + 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, 16777215, 0, 18, FALSE); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + 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); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + 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 4ed1cc1264..5f394dc8b1 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 | 88.0% | cleanup; register allocation SHC_3BB0A8C1_0x004C1320 | 0.0% | Pending From 4967da730b4b3f94eeeed7aaa0f3a6568915e410 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:45:36 +0100 Subject: [PATCH 20/64] reimplement: SHC_3BB0A8C1_0x004BBA60 96.8% 1 behaviour fix; register allocation Rewritten from gynt's draft (95.6%). One behaviour fix the original's asm shows: a crusader or arabian button that is not the current choice falls back to the default button render (jne to the RenderScenarioButtonWithText call); the draft fell through into the bandits case and drew it as a bandits button. The highlighted text is chosen by if/else around one call each, which MSVC merges into the original's single call with a branch on the colour push; a ternary compiles branch-free instead. The " - " string is s___005a2304 from string-literals.hpp, COL_CCFAFF names the highlight colour. Left: register allocation around the name width. Co-Authored-By: Claude Opus 5.5 --- ...on_General_CreateEventCallbackFunction.cpp | 135 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp new file mode 100644 index 0000000000..bed2469b09 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp @@ -0,0 +1,135 @@ +#include "../General.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/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.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/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BBA60 + void General::MenuItemRenderFunction_General_CreateEventCallbackFunction(int param_1, ...) + { + int option = -1; + int iconOffset = 2; + switch (param_1) { + case 91: + case 221: + option = 0; + break; + case 92: + case 222: + option = 1; + break; + case 93: + option = iconOffset; + break; + case 94: + option = 3; + break; + case 95: + option = 4; + break; + case 96: + option = 5; + break; + case 97: + option = 6; + break; + case 98: + option = 7; + break; + case 99: + option = 8; + break; + case 157: + option = 9; + break; + case 158: + option = 10; + break; + case 159: + option = 11; + break; + case 160: + option = 12; + break; + case 161: + option = 13; + break; + case 162: + option = 14; + break; + } + switch (param_1) { + case 221: + case 222: + if (DAT_MapPropertiesState::instance.invasionEventContent.crusaderArabian == option) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); + return; + } + break; + case 148: + // drawn as the bandits button with the other icon + param_1 = 146; + iconOffset = 0; + case 146: { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // "Bandits" + if (!DAT_ButtonCurrentlyInteracting::instance) { + 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, param_1), + DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + } else { + 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, param_1), + DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + int const nameWidth = DAT_TextManagerObject::instance.currentXOffset_0x0; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // " - " + s___005a2304, nameWidth / 2 - 15 + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, + DAT_ButtonW::instance / 2 - 9 + (DAT_TextManagerObject::instance.currentXOffset_0x0 + nameWidth) / 2 + + DAT_ButtonX::instance, + DAT_ButtonY::instance + 3); + return; + } + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 5f394dc8b1..7073db00f3 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29321,7 +29321,7 @@ SHC_3BB0A8C1_0x004BBA20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBA30 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBA60 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBA60 | 96.8% | 1 behaviour fix; register allocation SHC_3BB0A8C1_0x004BBC64 | 0.0% | Pending From 9a43ae70c69d11c0fdb700d888b86eedf8e992ed Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:45:36 +0100 Subject: [PATCH 21/64] reimplement: SHC_3BB0A8C1_0x004BFA60 99.0% 2 behaviour fixes; register allocation Rewritten from gynt's draft (96.8%). Two behaviour fixes the original's asm shows: the month button (-1) returns after drawing its text once, in the plain or the highlight colour; the draft drew the plain text and then the highlighted one over it. An invader button whose choice matches returns after drawing; the draft also fell into the default button render. The draft's comment "Crusader. Arabian. (...)" is replaced by the list of invaders the buttons stand for (cr.tex: rat, snake, pig, wolf, other, crusader, arabian). Left: one register choice in the invader text call. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_NewInvasion_Buttons.cpp | 132 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp new file mode 100644 index 0000000000..b7c187aecb --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp @@ -0,0 +1,132 @@ +#include "../NewInvasion.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BFA60 + void NewInvasion::MenuItemRenderFunction_NewInvasion_Buttons(int param_1, ...) + { + int option = -1; + switch (param_1) { + case 9: + case 91: + case 221: + option = 0; + break; + case 10: + case 92: + case 222: + option = 1; + break; + case 11: + case 93: + option = 2; + break; + case 12: + case 94: + option = 3; + break; + case 87: + case 95: + option = 4; + break; + case 96: + option = 5; + break; + case 97: + option = 6; + break; + case 98: + option = 7; + break; + case 99: + option = 8; + break; + case 157: + option = 9; + break; + case 158: + option = 10; + break; + case 159: + option = 11; + break; + case 160: + option = 12; + break; + case 161: + option = 13; + break; + case 162: + option = 14; + break; + } + switch (param_1) { + case -1: + // the event's month, in full + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month + + 12, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month + + 12, + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + return; + case 9: + case 10: + case 11: + case 12: + case 87: + case 221: + case 222: + // the invader: rat, snake, pig, wolf, other, crusader or arabian + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.invasion.crusaderArabian + == option) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + 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, param_1), + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + break; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 7073db00f3..384e638102 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -31189,7 +31189,7 @@ SHC_3BB0A8C1_0x004BFA56 | 0.0% | Pending SHC_3BB0A8C1_0x004BFA57 | 0.0% | Pending -SHC_3BB0A8C1_0x004BFA60 | 0.0% | Pending +SHC_3BB0A8C1_0x004BFA60 | 99.0% | 2 behaviour fixes; register allocation SHC_3BB0A8C1_0x004BFC10 | 0.0% | Pending From a70deedcf176e34ca7e2334f47c91db3c85a410a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:45:36 +0100 Subject: [PATCH 22/64] reimplement: SHC_3BB0A8C1_0x004B9C00 97.1% inner switch in the original's order, no goto; scheduling Rewritten from gynt's draft (93.4%). The inner switch has its arms in the original's order (50, 100, then 10 falling into the slider set-up) and returns from default instead of jumping to a label. The second column's buttons adjust param_1 itself and a copy drives the inner switch, which is how the original keeps them (edx and esi); the slider value and destination are read in place rather than through a local pointer; the popup delay is stored first, as in the original. The pointer to the event type stays: without it the match halves. Left: one store scheduled differently and an lea / add choice. Co-Authored-By: Claude Opus 5.5 --- ...uItemActionHandler_NewEventAction_Main.cpp | 130 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp new file mode 100644 index 0000000000..09eaed9dcd --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp @@ -0,0 +1,130 @@ +#include "../NewEventAction.func.hpp" + +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9C00 + void NewEventAction::MenuItemActionHandler_NewEventAction_Main(int param_1, ...) + { + DAT_StopHandlingMenuItems::instance = 0; + int const pressed = param_1; + switch (param_1) { + case 37: + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_NEW_EVENT, FALSE); + return; + case 177: + case 178: + case 179: + case 180: + case 181: + case 182: + case 183: + case 184: + case 185: + case 186: + case 187: + // the second column continues the first one's event types + param_1 -= 21; + case 128: + case 129: + case 130: + case 131: + case 132: + case 133: + case 134: + case 135: + case 136: + case 137: + case 138: + case 139: + case 140: + case 141: + case 142: + case 143: + case 144: + case 145: + case 146: + case 147: + case 148: + case 149: + case 150: + case 151: + case 152: + case 153: + case 154: + case 155: { + // the original takes the field's address once and reads and writes through it + int* const eventType + = &DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType; + if (*eventType != param_1 - 128) { + *eventType = param_1 - 128; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = 0; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeat = 0; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.repeatMonths = 10; + int const newType = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType; + if (newType == 2 || newType == 26 || newType == 27) { + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = -1; + } + } + int maximum; + switch (pressed) { + case 146: + case 148: + maximum = 50; + break; + case 178: + maximum = 100; + break; + case 132: + case 139: + case 145: + case 179: + maximum = 10; + break; + default: + return; + } + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData + == 0) { + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData = 1; + } + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(1, + maximum, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData, + (undefined*)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data, + (void*)MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); + DAT_MapPropertiesState::instance.sliderPopupDelay = 2; + DAT_MapPropertiesState::instance.sliderPopupX = DAT_ButtonX::instance + 58; + DAT_MapPropertiesState::instance.sliderPopupY = DAT_ButtonY::instance + 28; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 384e638102..6688550989 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -28251,7 +28251,7 @@ SHC_3BB0A8C1_0x004B9BF2 | 0.0% | Pending SHC_3BB0A8C1_0x004B9BF3 | 0.0% | Pending -SHC_3BB0A8C1_0x004B9C00 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9C00 | 97.1% | inner switch in the original's order, no goto; scheduling SHC_3BB0A8C1_0x004B9D68 | 0.0% | Pending From 5389043fb0f8e07802daa8853ca32d831c4c2b22 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:45:37 +0100 Subject: [PATCH 23/64] reimplement: SHC_3BB0A8C1_0x004BCEC0 97.7% speech file name as a field; scheduling Rewritten from gynt's draft (96.9%). The draft computed the speech file name as a raw address (counter * 0x60 + 0xb3d810); it is MissionAestheticsDefinedData::field112_0x41e4[counter], a char[3][32] per entry. Taking a pointer to the name before the counter is incremented matches better than indexing in the call. The hand-written security cookie is gone (the compiler adds it for the char buffer), the tutorial counters are ints (header commit), early returns, and the player slot is read inside the step-14 test, as the original does. Left: the order of two loads. Co-Authored-By: Claude Opus 5.5 --- ...MenuItemActionHandler_TutorialBox_Main.cpp | 121 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp new file mode 100644 index 0000000000..2d466df347 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp @@ -0,0 +1,121 @@ +#include "../TutorialBox.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df5540.hpp" +#include "OpenSHC/Globals/DAT_00df5554.hpp" +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df555c.hpp" +#include "OpenSHC/Globals/DAT_00df5560.hpp" +#include "OpenSHC/Globals/DAT_00df556c.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/INT_DisableTutorialRestrictions.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BCEC0 + void TutorialBox::MenuItemActionHandler_TutorialBox_Main(int param_1, ...) + { + char speechPath[32]; + if (param_1 == 2) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); + return; + } + if (param_1 != 1 || DAT_00df5560::instance == 0 || DAT_00df5540::instance != 0) { + return; + } + ++DAT_00df5558::instance; + DAT_00df5560::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( + OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); + if (DAT_TutorialCurrentStep::instance == 2 && DAT_00df5558::instance == 1 + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] + .id + > 0) { + DAT_00df5558::instance = 2; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetTutorialActionTrackers)(); + if (DAT_00df5558::instance < DAT_00df555c::instance) { + return; + } + --DAT_00df5558::instance; + MACRO_CALL(OpenSHC::UI::Helpers_Func::InitTutorialStepTransition)(2); + DAT_00df5560::instance = 0; + if (DAT_TutorialCurrentStep::instance >= DAT_00df5554::instance - 1) { + INT_DisableTutorialRestrictions::instance = 1; + } + if (DAT_MissionAestheticsDefinedData::instance.TutorialStepSpeechTrigger[DAT_TutorialCurrentStep::instance] + == 1) { + char const* const name + = DAT_MissionAestheticsDefinedData::instance.field_0x41e4[DAT_00df556c::instance][0]; + ++DAT_00df556c::instance; + // "%s%s", "fx\\speech\\" + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(speechPath, s__s_s_005aa800, s_fx_speech__005a64cc, name); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::playAmbientStreamWithLoop, + DAT_SoundSystemState::ptr)(speechPath); + if (DAT_00df556c::instance > 39) { + DAT_00df556c::instance = 36; + } + } + if (DAT_TutorialCurrentStep::instance != 14) { + return; + } + int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameState::instance.playerDataArray[slot].taxesSetting = 3; + DAT_GameState::instance.playerDataArray[slot].taxesSetting2 = 3; + DAT_GameState::instance.playerDataArray[slot].taxesSliderUI = 3; + DAT_GameState::instance.playerDataArray[slot].rationsSetting = 2; + DAT_GameState::instance.playerDataArray[slot].rationsSetting2 = 2; + DAT_GameState::instance.playerDataArray[slot].rationsSetting3 = 2; + DAT_GameState::instance.playerDataArray[slot].popularity = 10000; + int const missingFood = 75 - DAT_GameState::instance.playerDataArray[slot].totalFood; + if (missingFood > 0) { + MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::processResourceGain, + DAT_BuildingsState::ptr)(slot, OpenSHC::Game::Resources::RT_MEAT, missingFood); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6688550989..fdc0952a5c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30171,7 +30171,7 @@ SHC_3BB0A8C1_0x004BCB9E | 0.0% | Pending SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending -SHC_3BB0A8C1_0x004BCEC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BCEC0 | 97.7% | speech file name as a field; scheduling SHC_3BB0A8C1_0x004BD0F0 | 0.0% | Pending From a557256b38f430d17122a163b705e6be4ced3a30 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:52:45 +0100 Subject: [PATCH 24/64] strings: 0x005A22D0 "Exit" The old title menu's exit button renders the label "Exit" (0x005A22D0, between "FireFly's" and "Continue"), which had no entry. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/string-literals.hpp | 3 +++ src/OpenSHC/string-macros.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/OpenSHC/string-literals.hpp b/src/OpenSHC/string-literals.hpp index 95ede65fda..d2438aa321 100644 --- a/src/OpenSHC/string-literals.hpp +++ b/src/OpenSHC/string-literals.hpp @@ -2276,6 +2276,9 @@ char const* const s_Crusader_005a22b8 = S_CRUSADER_005A22B8; // 0x005a22c4 char const* const s_FireFly_s_005a22c4 = S_FIREFLY_S_005A22C4; +// 0x005a22d0 +char const* const s_Exit_005a22d0 = S_EXIT_005A22D0; + // 0x005a22d8 char const* const s_Continue_005a22d8 = S_CONTINUE_005A22D8; diff --git a/src/OpenSHC/string-macros.hpp b/src/OpenSHC/string-macros.hpp index 9fd49cdce0..2900831ae6 100644 --- a/src/OpenSHC/string-macros.hpp +++ b/src/OpenSHC/string-macros.hpp @@ -2280,6 +2280,9 @@ // STRING: STRONGHOLDCRUSADER 0x005a22c4 #define S_FIREFLY_S_005A22C4 "FireFly's" +// STRING: STRONGHOLDCRUSADER 0x005a22d0 +#define S_EXIT_005A22D0 "Exit" + // STRING: STRONGHOLDCRUSADER 0x005a22d8 #define S_CONTINUE_005A22D8 "Continue" From 1ef32694ad02db28eb566df106a9b6ec893a859d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 16:56:38 +0100 Subject: [PATCH 25/64] headers: GameCommandType value 112 as GCT_UNKNOWN_112 The AI lord select handler queues command 112 with the slot it filled as its parameter, after a lobby AI is added (111 is GCT_SKIRMISH_ADD_AI_PLAYER). The draft wrote it as GCT_SEND_RESYNC_TILEMAPDATA2 | GCT_LOAD_MAP_HEADER (64 | 48). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Commands/GameCommandType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/Commands/GameCommandType.hpp b/src/OpenSHC/Commands/GameCommandType.hpp index fbaed2f30c..d7de0cfac4 100644 --- a/src/OpenSHC/Commands/GameCommandType.hpp +++ b/src/OpenSHC/Commands/GameCommandType.hpp @@ -98,6 +98,7 @@ namespace Commands { GCT_UNKNOWN_107 = 107, // 0x0000006B GCT_LOAD_SKIRMISH_SCREEN = 109, // 0x0000006D GCT_SKIRMISH_ADD_AI_PLAYER = 111, // 0x0000006F + GCT_UNKNOWN_112 = 112, // 0x00000070 GCT_SEND_PLAYER_TO_PLAYER_REQUEST = 113, // 0x00000071 GCT_HOST_SHARE_AIV = 114, // 0x00000072 GCT_HOST_SHARE_HEATMAP = 115, // 0x00000073 From 132a6f5f27f0736282c0426f5a595085ba565132 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:29 +0100 Subject: [PATCH 26/64] reimplement: SHC_3BB0A8C1_0x004AE7D0 100.0% Reimplemented Rewritten from gynt's draft (95.3%). One behaviour fix the original's asm shows: when no slot is free the original closes the dialog and returns (0x004AE82B); the draft's while loop reset the dialog but kept going past slot 8. The free-slot search is a for loop with a break, and the occupied-slot count a for loop that MSVC unrolls into the original's eight tests (writing them out by hand gives the same code). Command 112 has a name (header commit) instead of GCT_SEND_RESYNC_TILEMAPDATA2 | GCT_LOAD_MAP_HEADER. Co-Authored-By: Claude Opus 5.5 --- ...enuItemActionHandler_AiLordSelect_Main.cpp | 71 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp new file mode 100644 index 0000000000..ac8f4933ef --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp @@ -0,0 +1,71 @@ +#include "../AiLordSelect.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LobbyAddAICurrentlyHoveredAI.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AE7D0 + void AiLordSelect::MenuItemActionHandler_AiLordSelect_Main(int buttonID, ...) + { + if (buttonID == 100) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + return; + } + if (buttonID > DAT_GameCore::instance.numOfAIsWithCastleUnk) { + return; + } + DAT_LobbyAddAICurrentlyHoveredAI::instance = DAT_GameCore::instance.arrayOfLordIdsWithAIVsUnk[buttonID - 1]; + int slot = 0; + for (int candidate = 1; candidate <= 8; ++candidate) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[candidate] == -1 + && DAT_GameSynchronyState::instance.currentAIArray[candidate] == 0) { + slot = candidate; + break; + } + } + if (slot == 0) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + return; + } + DAT_GameSynchronyState::instance.currentAIArray[slot] = DAT_LobbyAddAICurrentlyHoveredAI::instance; + MACRO_CALL(OpenSHC::Synchrony_Func::ResetAiVariationArrayValue)(slot); + DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[slot] = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = slot; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_UNKNOWN_112); + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + MACRO_CALL(OpenSHC::UI::Helpers_Func::PlayAMessageFromAI)( + DAT_GameSynchronyState::instance.currentAIArray[slot], 22); + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, DAT_GameSynchronyState::ptr)(); + int occupied = 0; + for (int i = 1; i <= 8; ++i) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] != -1 + || DAT_GameSynchronyState::instance.currentAIArray[i] != 0) { + ++occupied; + } + } + if (occupied != 8) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index fdc0952a5c..96cdf9b55a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25873,7 +25873,7 @@ SHC_3BB0A8C1_0x004AE720 | 0.0% | Pending SHC_3BB0A8C1_0x004AE7C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004AE7D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004AE7D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AE950 | 0.0% | Pending From df4fad16685a40b237ba1b6de12950c2989f5e52 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:30 +0100 Subject: [PATCH 27/64] reimplement: SHC_3BB0A8C1_0x0042F140 100.0% Reimplemented Rewritten from gynt's draft (98.0%). One behaviour fix the original's asm shows: the larger font is for French, Italian and Spanish only (an unsigned range test, cmp 2 / ja); the draft's signed `gameLanguage - GL_FRENCH < 3` also took English, American and German. Written as GL_FRENCH <= language <= GL_SPANISH, which MSVC compiles to the same test. Sound 146 is SEID_UNKNOWN_0x92 (header commit), the text comments come from cr.tex, early returns. Co-Authored-By: Claude Opus 5.5 --- ...emRenderFunction_NewMapMaptype_Buttons.cpp | 95 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp new file mode 100644 index 0000000000..529f60bdc2 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp @@ -0,0 +1,95 @@ +#include "../NewMapMaptype.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Enums/GmDataIndex.hpp" +#include "OpenSHC/Text/GameLanguage.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042F140 + void NewMapMaptype::MenuItemRenderFunction_NewMapMaptype_Buttons(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU + || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + if (button == 7) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { + DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + if (INT_00b95abc::instance != button) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = button; + } else { + if (button == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { + DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + int textY = 19; + int fontSize = 17; + if (DAT_TextManagerObject::instance.gameLanguage >= OpenSHC::Text::GL_FRENCH + && DAT_TextManagerObject::instance.gameLanguage <= OpenSHC::Text::GL_SPANISH) { + fontSize = 18; + textY = 20; + } + if (button == 1) { + // "New Castle Builder Map" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_TITLES, 1, DAT_ButtonX::instance + 26, DAT_ButtonY::instance + textY, + OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); + } + if (button == 2) { + // "New Custom Scenario Map" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SHC_STANDALONE, 2, DAT_ButtonX::instance + 26, + DAT_ButtonY::instance + textY, OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); + } + if (button == 3) { + // "New Crusader Map" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_TITLES, 2, DAT_ButtonX::instance + 26, DAT_ButtonY::instance + textY, + OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 96cdf9b55a..817383c3d9 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8723,7 +8723,7 @@ SHC_3BB0A8C1_0x0042EFE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042F010 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042F140 | 0.0% | Pending +SHC_3BB0A8C1_0x0042F140 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042F2B0 | 0.0% | Pending From 15de69611ac4f777e9c6c8b659517a2defc22779 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:30 +0100 Subject: [PATCH 28/64] reimplement: SHC_3BB0A8C1_0x0042DE20 100.0% Reimplemented gynt's draft (97.3%) passed the literal "Exit", so reccmp saw our own copy of the string; with the string's entry at 0x005A22D0 (string commit) it is s_Exit_005a22d0 and the function matches. Also COL_0000FF for the text colour and no casts; the button width passed as the alignment stays, with a comment, because the original does that. Co-Authored-By: Claude Opus 5.5 --- ...Function_UnusedOldTitleMenu_ExitButton.cpp | 46 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp new file mode 100644 index 0000000000..96bd483e5c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp @@ -0,0 +1,46 @@ +#include "../Unused.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_WHITE.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_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042DE20 + void Unused::MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton(int unused, ...) + { + if (DAT_ButtonCurrentlyInteracting::instance) { + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; + } else { + DAT_TextManagerObject::instance.textColor = 0; + DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( + DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonW::instance + DAT_ButtonX::instance, + DAT_ButtonY::instance + DAT_ButtonH::instance, DAT_PencilRenderCore::instance.otherColorUnk_0x0); + // a positive alignment centres the text within that many pixels from x + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "Exit" + s_Exit_005a22d0, DAT_ButtonX::instance, DAT_ButtonY::instance + 6, + (OpenSHC::Text::TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 17, + FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 817383c3d9..83485f9977 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -8259,7 +8259,7 @@ SHC_3BB0A8C1_0x0042DCB0 | 0.0% | Pending SHC_3BB0A8C1_0x0042DD00 | 0.0% | Pending -SHC_3BB0A8C1_0x0042DE20 | 0.0% | Pending +SHC_3BB0A8C1_0x0042DE20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042DEB0 | 0.0% | Pending From 90d128473dbb1224f78c8d9f050eff8693adef0d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:30 +0100 Subject: [PATCH 29/64] reimplement: SHC_3BB0A8C1_0x004255D0 98.7% cleanup; scheduling Rewritten from gynt's draft (98.7%, the same code): early returns, the branches in the original's order, sound 146 as SEID_UNKNOWN_0x92, the campaign names from cr.tex. Left: the original loads ecx for getTextStringInGroupAtOffset between its two pushes; ours after them. No spelling of the text index or the position moves it. Co-Authored-By: Claude Opus 5.5 --- ...erFunction_HistoricCampaignSelect_Main.cpp | 86 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp new file mode 100644 index 0000000000..82b405e868 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp @@ -0,0 +1,86 @@ +#include "../HistoricCampaignSelect.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004255D0 + void HistoricCampaignSelect::MenuItemRenderFunction_HistoricCampaignSelect_Main(int param_1, ...) + { + if (DAT_UnknownGFXIndex::instance == 1) { + return; + } + if (param_1 != 5 && !DAT_ButtonCurrentlyInteracting::instance) { + if (param_1 == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && param_1 < 5) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } else { + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && param_1 < 5) { + DAT_CurrentButtonGmDataIndex::instance = 353; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + if (param_1 >= 5) { + return; + } + if (INT_00b95abc::instance != param_1) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = param_1; + } + if (param_1 >= 5) { + return; + } + // the campaign's name: "Heads on Spikes", "The Call to Arms", "Saladin's Conquest", "The Kings Crusade" or + // "Crusader States" + int const textY = DAT_ButtonY::instance + 15; + int const textX = DAT_ButtonX::instance + 30; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, param_1 + 309), + textX, textY, OpenSHC::Text::TTA_LEFT, 12775659, 0, 16, FALSE, 0); + if (!DAT_ButtonCurrentlyInteracting::instance) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 1, + DAT_ButtonX::instance - 85, DAT_ButtonY::instance - 28, OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 2, + 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 83485f9977..bb3530cf8a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6711,7 +6711,7 @@ SHC_3BB0A8C1_0x00425500 | 0.0% | Pending SHC_3BB0A8C1_0x00425580 | 0.0% | Pending -SHC_3BB0A8C1_0x004255D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004255D0 | 98.7% | cleanup; scheduling SHC_3BB0A8C1_0x00425720 | 0.0% | Pending From 8f88cf174de73e7deae51c814383985936fb989e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:30 +0100 Subject: [PATCH 30/64] reimplement: SHC_3BB0A8C1_0x004BB570 98.4% cleanup; scheduling Rewritten from gynt's draft (98.4%, the same code). The draft read SEC_MercRecruitable[param_1 - 7], a negative index; the address is barracksRecruitability.array.barracksRecruitability[param_1], as the handler for the same screen reads it. Early returns, `param_1 >= 0 && param_1 <= 7` instead of the unsigned cast, COL_CCFAFF, no casts. Left: one push 0 that the original schedules before the sar of the text position. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableEuroTroops_Main.cpp | 73 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp new file mode 100644 index 0000000000..db9fde28d6 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp @@ -0,0 +1,73 @@ +#include "../DisableEuroTroops.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB570 + void DisableEuroTroops::MenuItemRenderFunction_DisableEuroTroops_Main(int param_1, ...) + { + if (param_1 >= 0 && param_1 <= 7) { + if (param_1 == 2) { + DAT_ButtonX::instance -= 8; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + if (DAT_MapPropertiesState::instance.barracksRecruitability.array.barracksRecruitability[param_1] + != 0) { + return; + } + if (param_1 == 2) { + DAT_ButtonX::instance += 8; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, + DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (param_1 != -3) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + if (!DAT_ButtonCurrentlyInteracting::instance) { + // "Exit" + 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, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + return; + } + // "Exit" + 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, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bb3530cf8a..5cd469d439 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29289,7 +29289,7 @@ SHC_3BB0A8C1_0x004BB530 | 0.0% | Pending SHC_3BB0A8C1_0x004BB540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB570 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB570 | 98.4% | cleanup; scheduling SHC_3BB0A8C1_0x004BB650 | 100.0% | Reimplemented From 45815854a73aadcd5911795d542f2064487f3814 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:31 +0100 Subject: [PATCH 31/64] reimplement: SHC_3BB0A8C1_0x004BB680 98.2% cleanup; scheduling Rewritten from gynt's draft (98.2%, the same code), the same way as the euro troops render: early returns, both bounds spelled out, COL_CCFAFF, no casts. Left: the same push 0 scheduling. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableArabTroops_Main.cpp | 66 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp new file mode 100644 index 0000000000..cf6ecd72ef --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp @@ -0,0 +1,66 @@ +#include "../DisableArabTroops.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BB680 + void DisableArabTroops::MenuItemRenderFunction_DisableArabTroops_Main(int param_1, ...) + { + if (param_1 >= 0 && param_1 <= 7) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + if (DAT_MapPropertiesState::instance.SEC_MercRecruitable[param_1] != 0) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, + DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (param_1 != -3) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + if (!DAT_ButtonCurrentlyInteracting::instance) { + // "Exit" + 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, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + return; + } + // "Exit" + 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, 3), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 5cd469d439..49e4b4493e 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29293,7 +29293,7 @@ SHC_3BB0A8C1_0x004BB570 | 98.4% | cleanup; scheduling SHC_3BB0A8C1_0x004BB650 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB680 | 0.0% | Pending +SHC_3BB0A8C1_0x004BB680 | 98.2% | cleanup; scheduling SHC_3BB0A8C1_0x004BB740 | 0.0% | Pending From 36d0a96ca01c9fec72d2683f93f33f00f323eb66 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:31 +0100 Subject: [PATCH 32/64] reimplement: SHC_3BB0A8C1_0x004BD0F0 97.9% cleanup; scheduling Rewritten from gynt's draft (97.9%, the same code): early returns, the button texts from cr.tex ("Continue", "Exit", "Skip"), no casts now that the tutorial counters are ints (header commit), COL_CCFAFF. Left: the same push 0 scheduling as the other text buttons. Co-Authored-By: Claude Opus 5.5 --- ...enuItemRenderFunction_TutorialBox_Main.cpp | 68 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp new file mode 100644 index 0000000000..8bc06d4f63 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp @@ -0,0 +1,68 @@ +#include "../TutorialBox.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00df5540.hpp" +#include "OpenSHC/Globals/DAT_00df5558.hpp" +#include "OpenSHC/Globals/DAT_00df555c.hpp" +#include "OpenSHC/Globals/DAT_00df5560.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BD0F0 + void TutorialBox::MenuItemRenderFunction_TutorialBox_Main(int param_1, ...) + { + // "Continue" + int buttonText = 1; + if (DAT_00df5540::instance != 0) { + return; + } + if (param_1 == 2) { + // "Exit" + buttonText = 2; + } else { + if (DAT_00df5560::instance == 0) { + return; + } + if (DAT_00df5558::instance < DAT_00df555c::instance - 1 + && DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 + && DAT_SoundSystemState::instance.soundActiveUnk_0x0) { + // "Skip" + buttonText = 5; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + // >> 1 rather than / 2: the original shifts without the sign fix-up (sar at 0x004BD160) + int const textX = (DAT_ButtonW::instance >> 1) + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 8; + if (DAT_ButtonCurrentlyInteracting::instance) { + 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_TUTORIAL_BUTTONS, buttonText), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + 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_TUTORIAL_BUTTONS, buttonText), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 49e4b4493e..ba2cc44a23 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30173,7 +30173,7 @@ SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending SHC_3BB0A8C1_0x004BCEC0 | 97.7% | speech file name as a field; scheduling -SHC_3BB0A8C1_0x004BD0F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BD0F0 | 97.9% | cleanup; scheduling SHC_3BB0A8C1_0x004BD1B0 | 100.0% | Reimplemented From 8d25a1fa525c27fc47052561f8085e079dbdc8d5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:31 +0100 Subject: [PATCH 33/64] reimplement: SHC_3BB0A8C1_0x00491C50 97.7% cleanup; scheduling Rewritten from gynt's draft (97.7%, the same code): no TextAlignment local, an early return, COL_CCFAFF, no casts. Left: the same push 0 scheduling as the other text buttons; none of seven variants moved it. Co-Authored-By: Claude Opus 5.5 --- ...rFunction_EnterTitleOnGameStart_Button.cpp | 43 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp diff --git a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp new file mode 100644 index 0000000000..3afffcddf7 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp @@ -0,0 +1,43 @@ +#include "../EnterTitleOnGameStart.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00491C50 + void EnterTitleOnGameStart::MenuItemRenderFunction_EnterTitleOnGameStart_Button(int param_1, ...) + { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + if (!DAT_ButtonCurrentlyInteracting::instance) { + 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_BUBBLE_HELP_TEXT, param_1), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, param_1), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ba2cc44a23..a28bbcb4e8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23425,7 +23425,7 @@ SHC_3BB0A8C1_0x00491BF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00491C20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00491C50 | 0.0% | Pending +SHC_3BB0A8C1_0x00491C50 | 97.7% | cleanup; scheduling SHC_3BB0A8C1_0x00491CE0 | 0.0% | Pending From 197b9d49c97fbe1790e24c8b19436c2684f13a56 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:05:32 +0100 Subject: [PATCH 34/64] reimplement: SHC_3BB0A8C1_0x004AC440 97.3% cleanup; scheduling Rewritten from gynt's draft (97.3%, the same code): early returns, COL_CCFAFF, decimal numbers, no casts. Left: the same push 0 scheduling as the other text buttons. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_SendReceiveMap_Main.cpp | 47 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp new file mode 100644 index 0000000000..ade60d1ca9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp @@ -0,0 +1,47 @@ +#include "../SendReceiveMap.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AC440 + void SendReceiveMap::MenuItemRenderFunction_SendReceiveMap_Main(int param_1, ...) + { + if (DAT_GameSynchronyState::instance.DAT_MapFileReceivingState != 0 && param_1 == 68) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 6; + if (DAT_ButtonCurrentlyInteracting::instance) { + 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_MULTIPLAYER_CONNECTION, param_1), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + 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_MULTIPLAYER_CONNECTION, param_1), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a28bbcb4e8..c64bb11924 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25785,7 +25785,7 @@ SHC_3BB0A8C1_0x004AC280 | 0.0% | Pending SHC_3BB0A8C1_0x004AC310 | 0.0% | Pending -SHC_3BB0A8C1_0x004AC440 | 0.0% | Pending +SHC_3BB0A8C1_0x004AC440 | 97.3% | cleanup; scheduling SHC_3BB0A8C1_0x004AC4C0 | 0.0% | Pending From 7c86afa340ddf51f79fbbdfcb8c1a5823e9b444e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:26:19 +0100 Subject: [PATCH 35/64] reimplement: SHC_3BB0A8C1_0x0042F7F0 100.0% Reimplemented, Security Cookie mismatches Rewritten from gynt's draft (92.3%). One behaviour fix the original's asm shows: a button that is not hovered still renders and gets its size label when the highlight flag is set; the draft returned after setting the highlight index. The hand-written security cookie is gone (the compiler adds it for the buffer), sound 146 is SEID_UNKNOWN_0x92, the size switch keeps the original's arm order, early returns, no casts. reccmp without --ignore-security-cookie differs only in the __security_check_cookie call and the cookie load. Co-Authored-By: Claude Opus 5.5 --- ...emRenderFunction_NewMapMapsize_Buttons.cpp | 94 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp new file mode 100644 index 0000000000..8f7a7dabbb --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp @@ -0,0 +1,94 @@ +#include "../NewMapMapsize.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Map/MapConstants.hpp" +#include "OpenSHC/Rendering/Enums/GmDataIndex.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/INT_00b95abc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042F7F0 + void NewMapMapsize::MenuItemRenderFunction_NewMapMapsize_Buttons(int button, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU + || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + if (button == 7) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { + DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + if (INT_00b95abc::instance != button) { + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); + } + INT_00b95abc::instance = button; + } else { + if (button == INT_00b95abc::instance) { + INT_00b95abc::instance = -1; + } + if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { + DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + int mapSize; + switch (button) { + default: + mapSize = OpenSHC::Map::MC_MAP_SIZE_400; + break; + case 3: + mapSize = OpenSHC::Map::MC_MAP_SIZE_300; + break; + case 2: + mapSize = OpenSHC::Map::MC_MAP_SIZE_200; + break; + case 1: + mapSize = OpenSHC::Map::MC_MAP_SIZE_160; + break; + } + // "%dx%d" + char sizeText[20]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); + // a positive alignment centres the text within that many pixels from x + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + sizeText, DAT_ButtonX::instance, DAT_ButtonY::instance + 19, + (OpenSHC::Text::TextAlignment)DAT_ButtonW::instance, 12775659, 0, 17, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c64bb11924..f5b5718026 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -9157,7 +9157,7 @@ SHC_3BB0A8C1_0x0042F7E3 | 0.0% | Pending SHC_3BB0A8C1_0x0042F7E4 | 0.0% | Pending -SHC_3BB0A8C1_0x0042F7F0 | 0.0% | Pending +SHC_3BB0A8C1_0x0042F7F0 | 100.0% | Reimplemented, Security Cookie mismatches SHC_3BB0A8C1_0x0042F940 | 0.0% | Pending From 1f6511533a005415434934415343fb9d7ed928dd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:26:20 +0100 Subject: [PATCH 36/64] reimplement: SHC_3BB0A8C1_0x0042BF00 100.0% Reimplemented Rewritten from gynt's draft (93.8%). The skirmish button (2) comes first behind a `!=` chain, which puts the trail buttons' block last as the original does; the -1 button returns. The trail type is set by an if / else if chain before a single switchToMenuView call, as the original computes it (sete for warchest). The player name is copied with strcpy (the original's inlined copy loop) and the slot flags in a for loop; memset uses sizeof, BASMTT_NONE replaces the cast 0. Co-Authored-By: Claude Opus 5.5 --- ...nuItemActionHandler_SelectCrusade_Main.cpp | 81 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp b/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp new file mode 100644 index 0000000000..df2fba1c7c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp @@ -0,0 +1,81 @@ +// disable deprecation warnings for strcpy +#pragma warning(disable : 4996) + +#include "../SelectCrusade.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042BF00 + void SelectCrusade::MenuItemActionHandler_SelectCrusade_Main(int skirmishType, ...) + { + if (skirmishType == -1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + return; + } + if (skirmishType != 1 && skirmishType != 3 && skirmishType != 4) { + if (skirmishType != 2) { + return; + } + // "Custom skirmish game" + DAT_GameCore::instance.isSkirmishTrail = FALSE; + DAT_GameSynchronyState::instance.field_0x106ee4 = 1; + DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_LOBBY_MENU, 0); + MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); + Menu_LobbyMenu::instance.thousand = 0; + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::setupSkirmishLobby, DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.isHost = TRUE; + DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER; + DAT_GameSynchronyState::instance.DPLAYX_ReceivedPlayerID = 1; + DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER; + MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); + // the player's name + strcpy(DAT_GameSynchronyState::instance.DAT_PlayerNames[1], + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); + DAT_GameSynchronyState::instance.currentPlayerSlotID = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + for (int slot = 0; slot < 9; ++slot) { + DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[slot] = 1; + } + return; + } + DAT_GameCore::instance.gameSuspended = 0; + if (skirmishType == 4) { + DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_EXTREME; + } else if (skirmishType == 3) { + DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_WARCHEST; + } else { + DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_FIRST_EDITION; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_MAP, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f5b5718026..b3d2fae4d8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7449,7 +7449,7 @@ SHC_3BB0A8C1_0x0042BB90 | 0.0% | Pending SHC_3BB0A8C1_0x0042BBF0 | 0.0% | Pending -SHC_3BB0A8C1_0x0042BF00 | 0.0% | Pending +SHC_3BB0A8C1_0x0042BF00 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042BFC0 | 0.0% | Pending From d2eadc8f03b87246b18bedac3a71d9738cc2359f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:26:21 +0100 Subject: [PATCH 37/64] reimplement: SHC_3BB0A8C1_0x004ABEB0 94.5% one store for the map size; parameter reload Rewritten from gynt's draft (93.3%). The map size is chosen into a local and stored once, as the original does (one store from eax before the call); the column loop is a plain for loop. Left: the original's fallback size re-reads param_1 from the stack where ours uses the register copy, and its loop alignment padding is a jump over three bytes. The map-size chain stays an if chain: the original compares the ids in turn (0x004ABF0B), so neither a loop nor a table fits. Co-Authored-By: Claude Opus 5.5 --- ...nHandler_EditorMapTypeQuickChange_Main.cpp | 106 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 107 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..b746f3ed5e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp @@ -0,0 +1,106 @@ +#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/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 param_1, ...) + { + switch (param_1) { + case 0: + case 1: + case 2: + DAT_GameCore::instance.U3_mapLockedState = param_1; + return; + case 3: + case 4: + case 5: + case 6: + // buttons 3 to 6 are the map types siege, invasion, economic and just build + if (!MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::mapHasCertainEvent, DAT_MapPropertiesState::ptr)()) { + DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = param_1 - 3; + } + return; + case 10: + 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)(); + int mapSize; + if (param_1 == 20) { + mapSize = 160; + } else if (param_1 == 21) { // the original compares the ids in turn, not a table + mapSize = 200; + } else if (param_1 == 22) { + mapSize = 300; + } else if (param_1 == 23) { + mapSize = 400; + } else { + mapSize = param_1; + } + 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 b3d2fae4d8..8d234a0763 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 | 94.5% | one store for the map size; parameter reload SHC_3BB0A8C1_0x004AC008 | 0.0% | Pending From 5d5079f6df139ddcdfcd4562043f72e4a2f87cb3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:30:03 +0100 Subject: [PATCH 38/64] headers: eTextSections value 0 as TEXT_UNKNOWN_0 The vote-quit dialog's render function starts with text group 0 (the group that holds the "Copyright FireFly Studios, 2001" line in cr.tex) and keeps it for buttons it has no label for. The draft wrote it as (eTextSections)0. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/DE/SHCDE/eTextSections.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/DE/SHCDE/eTextSections.hpp b/src/OpenSHC/DE/SHCDE/eTextSections.hpp index f3afb1f118..4c62d9d320 100644 --- a/src/OpenSHC/DE/SHCDE/eTextSections.hpp +++ b/src/OpenSHC/DE/SHCDE/eTextSections.hpp @@ -13,6 +13,7 @@ namespace DE { namespace SHCDE { typedef enum eTextSections { + TEXT_UNKNOWN_0 = 0, // 0x00000000 TEXT_MONTHS = 1, // 0x00000001 TEXT_GOODS = 2, // 0x00000002 TEXT_POPULARITY_EFFECTS = 3, // 0x00000003 From bcf4d9bcfc87ccda3168d9395e3c9440e98a41d0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:49:34 +0100 Subject: [PATCH 39/64] reimplement: SHC_3BB0A8C1_0x00493850 100.0% Reimplemented Rewritten from gynt's draft (87.9%) without gotos: one switch picks the text group and index ("Quit Game", "End this game?", "Cancel" in cr.tex). Declaring the group before the index and assigning it first in every arm gives the original's registers (esi for the group, edi for the index); the draft had them swapped. Text group 0 has a name now (header commit) instead of (eTextSections)0. Co-Authored-By: Claude Opus 5.5 --- ...unction_OnlineVoteQuitAndQuitGame_Main.cpp | 66 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp new file mode 100644 index 0000000000..401a826a2d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp @@ -0,0 +1,66 @@ +#include "../OnlineVoteQuitAndQuitGame.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::DE::SHCDE::eTextSections; + + // FUNCTION: STRONGHOLDCRUSADER 0x00493850 + void OnlineVoteQuitAndQuitGame::MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main(int button, ...) + { + eTextSections section = OpenSHC::DE::SHCDE::TEXT_UNKNOWN_0; + int textIndex = 0; + switch (button) { + case 1: + // "Quit Game" + section = OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS; + textIndex = 8; + break; + case 2: + case 4: + // "End this game?" + section = OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION; + textIndex = 59; + break; + case 3: + case 5: + // "Cancel" + section = OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION; + textIndex = 3; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + int const textY = DAT_ButtonY::instance + 7; + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(section, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(section, textIndex), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 2); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8d234a0763..b0db813821 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23633,7 +23633,7 @@ SHC_3BB0A8C1_0x004937B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004937E0 | 0.0% | Pending -SHC_3BB0A8C1_0x00493850 | 0.0% | Pending +SHC_3BB0A8C1_0x00493850 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004938EC | 0.0% | Pending From 9cae3061a963446daf928dbb6293137e6551a358 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:49:35 +0100 Subject: [PATCH 40/64] reimplement: SHC_3BB0A8C1_0x00434120 89.9% cleanup; tail call Rewritten from gynt's draft (89.9%, the same code apart from the end): compound assignments, the two shared steps of the diagonal directions as fall-throughs instead of a goto, early returns, no casts. Left: MSVC turns the final RecordTutorialPlayerAction(1) into a tail call that reuses param_1's slot; the original makes a plain call, probably because its handler takes no parameter at all. Co-Authored-By: Claude Opus 5.5 --- ...ItemActionHandler_InGameMenu_Scrolling.cpp | 83 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp new file mode 100644 index 0000000000..eff91451bd --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp @@ -0,0 +1,83 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/ScrollingHandler.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" + +#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00434120 + void InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling(int param_1, ...) + { + if (!MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + OpenSHC::UI::Enums::DEID_DEBUG_NUMBERS)) { + // computes the debug numbers without drawing them + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::RenderDebugNumbersDisplayElement)(0, 0, -1000); + } + if (DAT_MouseState::instance.selectionBoxMode != 0) { + return; + } + if (DAT_MouseState::instance.rightClickState) { + return; + } + int scrollDistance = MACRO_CALL_MEMBER( + OpenSHC::UI::ScrollingHandler_Func::getScrollDistanceBaseUnk, DAT_ScrollingHandler::ptr)(); + if (scrollDistance == 0) { + return; + } + // below the game speed's frame rate the step grows, so the view keeps its speed + if (DAT_CurrentFramerate::instance < DAT_GameCore::instance.gameSpeedLevel + && DAT_CurrentFramerate::instance != 0) { + scrollDistance = DAT_GameCore::instance.gameSpeedLevel * scrollDistance + / ((DAT_GameCore::instance.gameSpeedLevel - DAT_CurrentFramerate::instance) / 2 + + DAT_CurrentFramerate::instance); + } + switch (DAT_ScrollingHandler::instance.scrollDirection_0x4) { + case OpenSHC::UI::SD_UP: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step right + case OpenSHC::UI::SD_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_RIGHT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + break; + case OpenSHC::UI::SD_DOWN_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + case OpenSHC::UI::SD_UP_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; + // falls through to the step left + case OpenSHC::UI::SD_LEFT: + DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; + break; + } + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, + DAT_ViewportRenderState::ptr)(); + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(1); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b0db813821..3f0d6f4fa5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11115,7 +11115,7 @@ SHC_3BB0A8C1_0x00433D00 | 0.0% | Pending SHC_3BB0A8C1_0x00433DA0 | 0.0% | Pending -SHC_3BB0A8C1_0x00434120 | 0.0% | Pending +SHC_3BB0A8C1_0x00434120 | 89.9% | cleanup; tail call SHC_3BB0A8C1_0x004341E1 | 0.0% | Pending From 371aef6adfa5f6250a859f0e98b14257c4e46002 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:49:35 +0100 Subject: [PATCH 41/64] reimplement: SHC_3BB0A8C1_0x0043A8E0 88.9% cleanup; register allocation Rewritten from gynt's draft (88.9%, the same code): the label comment above its line, COL_B8EEFB, decimal numbers, no casts. Left: the original keeps the button's y in ecx and x in eax; ours swaps them, and no spelling of the positions changes that. Co-Authored-By: Claude Opus 5.5 --- ...usMenu_AvailablePeasantsTextUpperRight.cpp | 39 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp new file mode 100644 index 0000000000..60d719d888 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp @@ -0,0 +1,39 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0043A8E0 + void BuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight( + int param_1, ...) + { + // "Available Peasants" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_BARRACKS, 3), + DAT_ButtonX::instance - 5, DAT_ButtonY::instance, OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availablePeasantsOrHousedPeasants + - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .count, + DAT_ButtonX::instance, DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3f0d6f4fa5..84308125db 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13403,7 +13403,7 @@ SHC_3BB0A8C1_0x0043A8C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043A8D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043A8E0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043A8E0 | 88.9% | cleanup; register allocation SHC_3BB0A8C1_0x0043A960 | 0.0% | Pending From fcff9b3931da281d8fd9fa5004ac49b9b78f3626 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:55:16 +0100 Subject: [PATCH 42/64] headers: INT_00eb0e44 is a char The mission end screen's handler and render function read and write INT_00eb0e44 as one byte (cmp byte ptr / mov byte ptr at 0x004D6BEF, 0x004D6C1B); the drafts cast it to char and wrote it through a char pointer. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/INT_00eb0e44.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/INT_00eb0e44.hpp b/src/OpenSHC/Globals/INT_00eb0e44.hpp index cac8b5665e..26e63fbc87 100644 --- a/src/OpenSHC/Globals/INT_00eb0e44.hpp +++ b/src/OpenSHC/Globals/INT_00eb0e44.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00EB0E44 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00EB0E44) INT_00eb0e44; +MACRO_STRUCT_RESOLVER(char, false, Address::SHC_3BB0A8C1_0x00EB0E44) INT_00eb0e44; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EB0E44); From 1016e7c2379321d8e5d2eec2b18f9d8aa4c03aef Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 17:56:10 +0100 Subject: [PATCH 43/64] headers: DAT_00ec082c is an int The mission end screen's handler compares it signed (jge at 0x004D6C42 and 0x004D6C69); its render function only tests it for equality, which compiles the same either way. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00ec082c.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00ec082c.hpp b/src/OpenSHC/Globals/DAT_00ec082c.hpp index 1d94dbc620..3ca602239a 100644 --- a/src/OpenSHC/Globals/DAT_00ec082c.hpp +++ b/src/OpenSHC/Globals/DAT_00ec082c.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00EC082C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00EC082C) DAT_00ec082c; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00EC082C) DAT_00ec082c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EC082C); From bf5f3bc3c9adcb2aa1112d517555a7a3fcc7b61d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 18:10:46 +0100 Subject: [PATCH 44/64] reimplement: SHC_3BB0A8C1_0x004D6BC0 100.0% Reimplemented Rewritten from gynt's draft (87.6%). Two behaviour fixes the original's asm shows: button -1 draws the black box only while INT_00eb0e44 is set (and otherwise sets INT_00ed279c); the draft always drew it. Button -100 picks tab 2 or tab 0; the draft had no else, so it always ended on 0. INT_00eb0e44 is a char and DAT_00ec082c an int (header commits), which removes the char casts and gives the original's signed compares; the results column is stored before the flag is cleared, as in the original. Co-Authored-By: Claude Opus 5.5 --- ...temActionHandler_MissionEndscreen_Main.cpp | 76 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp new file mode 100644 index 0000000000..b6491bbf2a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp @@ -0,0 +1,76 @@ +#include "../MissionEndscreen.func.hpp" + +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00ec082c.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00eb0e44.hpp" +#include "OpenSHC/Globals/INT_00ed279c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D6BC0 + void MissionEndscreen::MenuItemActionHandler_MissionEndscreen_Main(int action, ...) + { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { + return; + } + // DAT_00ec082c is the page: 0 and 1 are the 800x600 layout, 2 and 3 the larger one + switch (action) { + case -1: + if (INT_00eb0e44::instance != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, + DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); + INT_00eb0e44::instance = 0; + return; + } + INT_00ed279c::instance = 1; + return; + case -100: + if (INT_00eb0e44::instance != 0) { + return; + } + if (DAT_00ec082c::instance >= 2) { + DAT_00ec082c::instance = 2; + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_KEEP_OR_MPMENU_IPX; + return; + } + DAT_00ec082c::instance = 0; + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + return; + case -101: + if (INT_00eb0e44::instance != 0) { + return; + } + if (DAT_00ec082c::instance < 2) { + DAT_00ec082c::instance = 1; + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM; + return; + } + DAT_00ec082c::instance = 3; + DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_INN_OR_MPMMENU_UNK; + return; + case -10: + return; + case -2: + // -2 sorts by the first column + action = 0; + default: + DAT_FinalResultsOrderByColumn::instance = action; + INT_00eb0e44::instance = 0; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 84308125db..ef1b5104a9 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35615,7 +35615,7 @@ SHC_3BB0A8C1_0x004D6BB8 | 0.0% | Pending SHC_3BB0A8C1_0x004D6BBC | 0.0% | Pending -SHC_3BB0A8C1_0x004D6BC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D6BC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D6C98 | 0.0% | Pending From a9d58c62e5d3529b07a1b7e7e58256b62aae5272 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 10:40:03 +0100 Subject: [PATCH 45/64] Move three functions to the new ready branch UnusedCreateSiege's handler (0x004437E0), NewInvasion's buttons render (0x004BFA60) and the TutorialBox handler (0x004BCEC0) reach 100% on reimpl/UI-MenuItems-4-100 with no header change, so they leave this draft and their status lines go back to main's. Header commit 296480f2a stays: the TutorialBox render here still uses it. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_NewInvasion_Buttons.cpp | 132 ------------- ...MenuItemActionHandler_TutorialBox_Main.cpp | 121 ------------ ...ionHandler_UnusedCreateSiege_SiegeThat.cpp | 174 ------------------ status/addresses-SHC-3BB0A8C1.txt | 6 +- 4 files changed, 3 insertions(+), 430 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp deleted file mode 100644 index b7c187aecb..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewInvasion/MenuItemRenderFunction_NewInvasion_Buttons.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "../NewInvasion.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BFA60 - void NewInvasion::MenuItemRenderFunction_NewInvasion_Buttons(int param_1, ...) - { - int option = -1; - switch (param_1) { - case 9: - case 91: - case 221: - option = 0; - break; - case 10: - case 92: - case 222: - option = 1; - break; - case 11: - case 93: - option = 2; - break; - case 12: - case 94: - option = 3; - break; - case 87: - case 95: - option = 4; - break; - case 96: - option = 5; - break; - case 97: - option = 6; - break; - case 98: - option = 7; - break; - case 99: - option = 8; - break; - case 157: - option = 9; - break; - case 158: - option = 10; - break; - case 159: - option = 11; - break; - case 160: - option = 12; - break; - case 161: - option = 13; - break; - case 162: - option = 14; - break; - } - switch (param_1) { - case -1: - // the event's month, in full - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MONTHS, - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.month - + 12, - DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MONTHS, - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.month - + 12, - DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - return; - case 9: - case 10: - case 11: - case 12: - case 87: - case 221: - case 222: - // the invader: rat, snake, pig, wolf, other, crusader or arabian - if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.invasion.crusaderArabian - == option) { - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - 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, param_1), - DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - } - break; - } - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp deleted file mode 100644 index 2d466df347..0000000000 --- a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemActionHandler_TutorialBox_Main.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "../TutorialBox.func.hpp" - -#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" -#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.hpp" -#include "OpenSHC/Game/Resources/ResourceType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_00df5540.hpp" -#include "OpenSHC/Globals/DAT_00df5554.hpp" -#include "OpenSHC/Globals/DAT_00df5558.hpp" -#include "OpenSHC/Globals/DAT_00df555c.hpp" -#include "OpenSHC/Globals/DAT_00df5560.hpp" -#include "OpenSHC/Globals/DAT_00df556c.hpp" -#include "OpenSHC/Globals/DAT_BuildingsState.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" -#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/DAT_TutorialCurrentStep.hpp" -#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" -#include "OpenSHC/Globals/INT_DisableTutorialRestrictions.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BCEC0 - void TutorialBox::MenuItemActionHandler_TutorialBox_Main(int param_1, ...) - { - char speechPath[32]; - if (param_1 == 2) { - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( - OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( - OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); - return; - } - if (param_1 != 1 || DAT_00df5560::instance == 0 || DAT_00df5540::instance != 0) { - return; - } - ++DAT_00df5558::instance; - DAT_00df5560::instance = 0; - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( - OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_1); - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSoundStream, DAT_SoundSystemState::ptr)( - OpenSHC::Audio::MSS::enums::SND_STR_SPEECH_2); - if (DAT_TutorialCurrentStep::instance == 2 && DAT_00df5558::instance == 1 - && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_KEEP] - .id - > 0) { - DAT_00df5558::instance = 2; - } - MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetTutorialActionTrackers)(); - if (DAT_00df5558::instance < DAT_00df555c::instance) { - return; - } - --DAT_00df5558::instance; - MACRO_CALL(OpenSHC::UI::Helpers_Func::InitTutorialStepTransition)(2); - DAT_00df5560::instance = 0; - if (DAT_TutorialCurrentStep::instance >= DAT_00df5554::instance - 1) { - INT_DisableTutorialRestrictions::instance = 1; - } - if (DAT_MissionAestheticsDefinedData::instance.TutorialStepSpeechTrigger[DAT_TutorialCurrentStep::instance] - == 1) { - char const* const name - = DAT_MissionAestheticsDefinedData::instance.field_0x41e4[DAT_00df556c::instance][0]; - ++DAT_00df556c::instance; - // "%s%s", "fx\\speech\\" - MACRO_CALL(OpenSHC::OS_Func::_sprintf)(speechPath, s__s_s_005aa800, s_fx_speech__005a64cc, name); - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::playAmbientStreamWithLoop, - DAT_SoundSystemState::ptr)(speechPath); - if (DAT_00df556c::instance > 39) { - DAT_00df556c::instance = 36; - } - } - if (DAT_TutorialCurrentStep::instance != 14) { - return; - } - int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; - DAT_GameState::instance.playerDataArray[slot].taxesSetting = 3; - DAT_GameState::instance.playerDataArray[slot].taxesSetting2 = 3; - DAT_GameState::instance.playerDataArray[slot].taxesSliderUI = 3; - DAT_GameState::instance.playerDataArray[slot].rationsSetting = 2; - DAT_GameState::instance.playerDataArray[slot].rationsSetting2 = 2; - DAT_GameState::instance.playerDataArray[slot].rationsSetting3 = 2; - DAT_GameState::instance.playerDataArray[slot].popularity = 10000; - int const missingFood = 75 - DAT_GameState::instance.playerDataArray[slot].totalFood; - if (missingFood > 0) { - MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::processResourceGain, - DAT_BuildingsState::ptr)(slot, OpenSHC::Game::Resources::RT_MEAT, missingFood); - } - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp deleted file mode 100644 index 62a5cd335e..0000000000 --- a/src/OpenSHC/UI/MenuItems/Unused/MenuItemActionHandler_UnusedCreateSiege_SiegeThat.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "../Unused.func.hpp" - -#include "OpenSHC/AI/AICState.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Game/GameStateStructures.func.hpp" -#include "OpenSHC/IO/FilePackager.func.hpp" -#include "OpenSHC/IO/ResourceManager.func.hpp" -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/Map/TileMapState.func.hpp" -#include "OpenSHC/Map/Units/TroopValueState.func.hpp" -#include "OpenSHC/Map/Units/UnitsState.func.hpp" -#include "OpenSHC/UI/MenuItems/MapEditorLandscaping.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Game/Resources/ResourceType.hpp" -#include "OpenSHC/IO/FileResourceType.hpp" -#include "OpenSHC/Map/MapLockState.hpp" -#include "OpenSHC/Map/MapType2.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_AICState.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_ResourceManager.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_TroopValueState.hpp" -#include "OpenSHC/Globals/DAT_UnitsState.hpp" -#include "OpenSHC/Globals/FilePackagerObj.hpp" -#include "OpenSHC/Globals/INT_00b95f68.hpp" -#include "OpenSHC/Globals/INT_00b960e4.hpp" -#include "OpenSHC/Globals/INT_00b960ec.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004437E0 - void Unused::MenuItemActionHandler_UnusedCreateSiege_SiegeThat(int param_1, ...) - { - switch (param_1) { - case 5: - if (INT_00b95f68::instance != 0) { - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 43; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_QUIT_DIALOG); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS, 0); - return; - case 4: { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setupAllMapSections, DAT_TileMapState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( - // "mission22.map" - OpenSHC::IO::FRT_MAPS, STR_Mission22Map); - MACRO_CALL_MEMBER(OpenSHC::IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( - DAT_MapDefinedData::instance.MapSectionAddressArray); - DAT_GameCore::instance.section1095 = 0; - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Game::GameStateStructures_Func::clearEnemyRelatedStructures, DAT_GameState::ptr)(); - DAT_UnitsState::instance.lastSelectedUnitID = 0; - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); - int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; - DAT_GameState::instance.playerDataArray[slot].startResources[OpenSHC::Game::Resources::RT_GOLD] = 1500; - DAT_GameState::instance.playerDataArray[slot].startResources[OpenSHC::Game::Resources::RT_STONE] = 1000; - DAT_GameState::instance.playerDataArray[slot].pitchDitchTileCount = 0; - DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; - DAT_GameState::instance.playerDataArray[slot].moatTileCount = 0; - DAT_GameCore::instance.mapU4Int1 = 1; - INT_00b960ec::instance = 1; - MACRO_CALL_MEMBER( - OpenSHC::Map::MapPropertiesState_Func::importTradingCosts, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::TroopValueState_Func::clearAttackInfo, DAT_TroopValueState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::AI::AICState_Func::recomputeAIZonerLayer, DAT_AICState::ptr)(); - // case 4 goes on into case 6 - } - case 6: - INT_00b95f68::instance = 1; - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SIEGE_THAT; - DAT_GameCore::instance.missionNumber1to20 = 27; - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_GameCore::instance.missionNumber1to20 = 31; - MACRO_CALL(OpenSHC::UI::MenuItems::MapEditorLandscaping_Func:: - MenuItemActionHandler_MapEditorLandscaping_GeneralButtons)(OpenSHC::Commands::M_MAPPER_TOMAIN); - INT_00b960ec::instance = 1; - return; - case 2: - DAT_MenuTextInputState::instance.field_0x9c = 1; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::loadOrSaveMap, DAT_MenuTextInputState::ptr)( - OpenSHC::UI::Enums::MMT_LOAD_MAP); - INT_00b960ec::instance = 1; - return; - case 35: - if (INT_00b960ec::instance != 0) { - DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; - MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, - DAT_MapPropertiesState::ptr)(); - DAT_MenuTextInputState::instance.field_0x9c = 1; - DAT_MenuTextInputState::instance.field_0xa4 = 0; - DAT_GameCore::instance.U3_mapLockedState = OpenSHC::Map::MLS_EDITABLE; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::loadOrSaveMap, DAT_MenuTextInputState::ptr)( - OpenSHC::UI::Enums::MMT_SAVE_MAP); - INT_00b960e4::instance = 1; - } - break; - case 36: - if (INT_00b960ec::instance != 0) { - DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = OpenSHC::Map::MT_SIEGE; - MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, - DAT_MapPropertiesState::ptr)(); - DAT_MenuTextInputState::instance.field_0x9c = 1; - DAT_MenuTextInputState::instance.field_0xa4 = 0; - DAT_GameCore::instance.U3_mapLockedState = OpenSHC::Map::MLS_PLAYABLE; - MACRO_CALL_MEMBER( - OpenSHC::UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, DAT_MenuTextInputState::ptr)(10); - INT_00b960e4::instance = 1; - } - break; - case 3: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - break; - default: - break; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ef1b5104a9..3d9b2d2e03 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14265,7 +14265,7 @@ SHC_3BB0A8C1_0x004437D8 | 0.0% | Pending SHC_3BB0A8C1_0x004437D9 | 0.0% | Pending -SHC_3BB0A8C1_0x004437E0 | 99.4% | 1 behaviour fix; scheduling +SHC_3BB0A8C1_0x004437E0 | 0.0% | Pending SHC_3BB0A8C1_0x004439F0 | 0.0% | Pending @@ -30171,7 +30171,7 @@ SHC_3BB0A8C1_0x004BCB9E | 0.0% | Pending SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending -SHC_3BB0A8C1_0x004BCEC0 | 97.7% | speech file name as a field; scheduling +SHC_3BB0A8C1_0x004BCEC0 | 0.0% | Pending SHC_3BB0A8C1_0x004BD0F0 | 97.9% | cleanup; scheduling @@ -31189,7 +31189,7 @@ SHC_3BB0A8C1_0x004BFA56 | 0.0% | Pending SHC_3BB0A8C1_0x004BFA57 | 0.0% | Pending -SHC_3BB0A8C1_0x004BFA60 | 99.0% | 2 behaviour fixes; register allocation +SHC_3BB0A8C1_0x004BFA60 | 0.0% | Pending SHC_3BB0A8C1_0x004BFC10 | 0.0% | Pending From 3c42c8083385f55899e088fe2712271b4da7642a Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 12:52:35 +0100 Subject: [PATCH 46/64] headers: drop the tutorial counters' int retype Only the TutorialBox handler (0x004BCEC0) used it, and that function moved to reimpl/UI-MenuItems-4-100, which compiles against main's headers. Nothing left on this draft needs the change. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_00df5554.hpp | 4 ++-- src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_00df5554.hpp b/src/OpenSHC/Globals/DAT_00df5554.hpp index 49c7c492af..2f54576c25 100644 --- a/src/OpenSHC/Globals/DAT_00df5554.hpp +++ b/src/OpenSHC/Globals/DAT_00df5554.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF5554 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF5554) DAT_00df5554; +MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5554) DAT_00df5554; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5554); diff --git a/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp b/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp index 2e9a4a38d2..f3bdf38a75 100644 --- a/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp +++ b/src/OpenSHC/Globals/DAT_TutorialCurrentStep.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF5550 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF5550) DAT_TutorialCurrentStep; +MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF5550) DAT_TutorialCurrentStep; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF5550); From 77613ac42576f1485789909cd3c3bfe7cb3c9d18 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 10:47:02 +0100 Subject: [PATCH 47/64] reimplement: SHC_3BB0A8C1_0x004B9C00 97.4% inner switch in the original's order, no goto; scheduling DAT_StopHandlingMenuItems is cleared after param_1 is copied for the inner switch, which puts the store where the original has it (97.1% -> 97.4%). Left: the original takes the event type's address with lea, ours with add; an element pointer, pointer arithmetic and a non-const pointer all keep the add. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_NewEventAction_Main.cpp | 2 +- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp index 09eaed9dcd..1a6be89b9a 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp @@ -18,8 +18,8 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x004B9C00 void NewEventAction::MenuItemActionHandler_NewEventAction_Main(int param_1, ...) { - DAT_StopHandlingMenuItems::instance = 0; int const pressed = param_1; + DAT_StopHandlingMenuItems::instance = 0; switch (param_1) { case 37: MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3d9b2d2e03..22c6a6cc18 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -28251,7 +28251,7 @@ SHC_3BB0A8C1_0x004B9BF2 | 0.0% | Pending SHC_3BB0A8C1_0x004B9BF3 | 0.0% | Pending -SHC_3BB0A8C1_0x004B9C00 | 97.1% | inner switch in the original's order, no goto; scheduling +SHC_3BB0A8C1_0x004B9C00 | 97.4% | inner switch in the original's order, no goto; scheduling SHC_3BB0A8C1_0x004B9D68 | 0.0% | Pending From 77b0f81e174a26b6c738d7ae5c52fc252bb8f774 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 11:57:15 +0100 Subject: [PATCH 48/64] drop: the nine functions at 100% go to reimpl/UI-MenuItems-headers-100 0x00444B80, 0x00428150, 0x004AE7D0, 0x0042F140, 0x0042DE20, 0x0042F7F0, 0x0042BF00, 0x00493850 and 0x004D6BC0 move to the ready PR with the header commits they need, now that header changes may stay in a PR. Their files go and their status lines are main's again; the header changes only they used go in the next commit. Co-Authored-By: Claude Opus 5.5 --- ...enuItemActionHandler_AiLordSelect_Main.cpp | 71 ---- ...ItemRenderFunction_General_MenuMiniMap.cpp | 146 -------- ...emActionHandler_InGameMenu_MainButtons.cpp | 330 ------------------ ...temActionHandler_MissionEndscreen_Main.cpp | 76 ---- ...emRenderFunction_NewMapMapsize_Buttons.cpp | 94 ----- ...emRenderFunction_NewMapMaptype_Buttons.cpp | 95 ----- ...unction_OnlineVoteQuitAndQuitGame_Main.cpp | 66 ---- ...nuItemActionHandler_SelectCrusade_Main.cpp | 81 ----- ...Function_UnusedOldTitleMenu_ExitButton.cpp | 46 --- status/addresses-SHC-3BB0A8C1.txt | 18 +- 10 files changed, 9 insertions(+), 1014 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp diff --git a/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp deleted file mode 100644 index ac8f4933ef..0000000000 --- a/src/OpenSHC/UI/MenuItems/AiLordSelect/MenuItemActionHandler_AiLordSelect_Main.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "../AiLordSelect.func.hpp" - -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_LobbyAddAICurrentlyHoveredAI.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004AE7D0 - void AiLordSelect::MenuItemActionHandler_AiLordSelect_Main(int buttonID, ...) - { - if (buttonID == 100) { - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - return; - } - if (buttonID > DAT_GameCore::instance.numOfAIsWithCastleUnk) { - return; - } - DAT_LobbyAddAICurrentlyHoveredAI::instance = DAT_GameCore::instance.arrayOfLordIdsWithAIVsUnk[buttonID - 1]; - int slot = 0; - for (int candidate = 1; candidate <= 8; ++candidate) { - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[candidate] == -1 - && DAT_GameSynchronyState::instance.currentAIArray[candidate] == 0) { - slot = candidate; - break; - } - } - if (slot == 0) { - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - return; - } - DAT_GameSynchronyState::instance.currentAIArray[slot] = DAT_LobbyAddAICurrentlyHoveredAI::instance; - MACRO_CALL(OpenSHC::Synchrony_Func::ResetAiVariationArrayValue)(slot); - DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[slot] = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = slot; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - OpenSHC::Commands::GCT_UNKNOWN_112); - DAT_GameSynchronyState::instance.reparseMaps = TRUE; - MACRO_CALL(OpenSHC::UI::Helpers_Func::PlayAMessageFromAI)( - DAT_GameSynchronyState::instance.currentAIArray[slot], 22); - MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, DAT_GameSynchronyState::ptr)(); - int occupied = 0; - for (int i = 1; i <= 8; ++i) { - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] != -1 - || DAT_GameSynchronyState::instance.currentAIArray[i] != 0) { - ++occupied; - } - } - if (occupied != 8) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp deleted file mode 100644 index 3a3cdf0c45..0000000000 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_MenuMiniMap.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "../General.func.hpp" - -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/MinimapViewState.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eGM.hpp" -#include "OpenSHC/IO/Graphics/GmID.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/DAT_00b95960.hpp" -#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/INT_00b95950.hpp" -#include "OpenSHC/Globals/INT_00b95f6c.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00428150 - void General::MenuItemRenderFunction_General_MenuMiniMap(int unused, ...) - { - if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { - return; - } - int const buttonX = DAT_ButtonX::instance; - int const buttonY = DAT_ButtonY::instance; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderedBoxWithCustomBlendedBackground, - DAT_PencilRenderCore::ptr)( - buttonX - 108, buttonY - 108, 216, 216, DAT_ButtonBackgroundBlendStrength::instance); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if (DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber == 0 - || DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected == -1) { - return; - } - if (DAT_ButtonBackgroundBlendStrength::instance == 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::renderMinimapPreview, DAT_MinimapViewState::ptr)( - buttonX - 100, buttonY - 100); - for (int position = 0; position < 8; ++position) { - int const keepX = DAT_GameCore::instance.keepPositions[position].x; - if (keepX < 0) { - continue; - } - char const player = DAT_GameSynchronyState::instance.playerPositionsArray[position]; - if (player == DAT_00b95960::instance) { - continue; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - // -10 marks a free position - if (player == -10) { - if (INT_00b95950::instance == position) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 211, - keepX - 103 + buttonX, - DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 220, - keepX - 103 + buttonX, - DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); - } - } else { - if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player + 1] > 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[player + 1] * 2 + 492, - keepX - 96 + buttonX, DAT_GameCore::instance.keepPositions[position].y - 100 + buttonY, - 12); - } - if (INT_00b95f6c::instance != 0) { - // the keep position and the player are read again: caching them loses the match - int const drawX = DAT_GameCore::instance.keepPositions[position].x - 113 + buttonX; - int const playerIndex = DAT_GameSynchronyState::instance.playerPositionsArray[position]; - int const drawY = DAT_GameCore::instance.keepPositions[position].y - 116 + buttonY; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerIndex + 1] != -1) { - // Render Player portrait - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)( - OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, playerIndex + 719, drawX, drawY); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, - DAT_TextureRenderCoreObject::ptr)( - DAT_GameSynchronyState::instance.playerPositionsArray[position] + 20, drawX + 2, - drawY + 2); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, - DAT_PencilRenderCore::ptr)( - drawX, drawY, drawX + 35, drawY + 35, COL_BLACK::instance.shortValue); - } else if (DAT_GameSynchronyState::instance.currentAIArray[playerIndex + 1] != 0) { - // Render AI portrait - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)( - OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, playerIndex + 719, drawX, drawY); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, - DAT_GameSynchronyState::instance.currentAIArray - [DAT_GameSynchronyState::instance.playerPositionsArray[position] + 1] - + 700, - drawX, drawY); - } - } else if (INT_00b95950::instance == position) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, - DAT_GameSynchronyState::instance.playerPositionsArray[position] + 212, - DAT_GameCore::instance.keepPositions[position].x - 103 + buttonX, - DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, - DAT_GameSynchronyState::instance.playerPositionsArray[position] + 470, - DAT_GameCore::instance.keepPositions[position].x - 103 + buttonX, - DAT_GameCore::instance.keepPositions[position].y - 107 + buttonY); - } - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - if (DAT_00b95960::instance >= 0) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, - DAT_00b95960::instance + 470, DAT_MouseState::instance.screenSpaceX - 5, - DAT_MouseState::instance.screenSpaceY - 7); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if (!DAT_MouseState::instance.leftClickState && !DAT_MouseState::instance.draggingStopped) { - DAT_00b95960::instance = -1; - } - } - } - INT_00b95950::instance = -1; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp deleted file mode 100644 index cc7bc3f9f3..0000000000 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_MainButtons.cpp +++ /dev/null @@ -1,330 +0,0 @@ -#include "../InGameMenu.func.hpp" - -#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Game/GameStateStructures.func.hpp" -#include "OpenSHC/Map/Units/UnitsState.func.hpp" -#include "OpenSHC/Map/WallAndPitchState.func.hpp" -#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" -#include "OpenSHC/Text/TextEditorState.func.hpp" -#include "OpenSHC/UI/DisplayElements.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/MenuItems/MapEditorLandscaping.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Map/Buildings/BuildingType.hpp" -#include "OpenSHC/Map/MapType2.hpp" -#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/DisplayElementID.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_BinkControlState.hpp" -#include "OpenSHC/Globals/DAT_BuildingsState.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_GreatestLordDefinedData.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_PathFindingState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" -#include "OpenSHC/Globals/DAT_TextEditorState.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" -#include "OpenSHC/Globals/DAT_UnitsState.hpp" -#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" -#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00444B80 - void InGameMenu::MenuItemActionHandler_InGameMenu_MainButtons(int buttonID, ...) - { - if (buttonID != -1 && buttonID != -6) { - if (buttonID == -2) { - if (DAT_GameSynchronyState::instance.syncStatus == 0 - && DAT_GameSynchronyState::instance.saveRelated == 0 - && DAT_GameCore::instance.gamePausedLogical == 0 - && (DAT_GameCore::instance.currentMenuViewType - != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU - || (DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM - && DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)) - && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .lordKilledByPlayerID - == 0 - && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerDeathRelated - == 0) { - MACRO_CALL_MEMBER(OpenSHC::Map::WallAndPitchState_Func::confirmAndQueueDestructionCommand, - DAT_WallAndPitchState::ptr)(); - } - } else if (buttonID == -3) { - if (DAT_GameSynchronyState::instance.syncStatus == 0 - && DAT_GameSynchronyState::instance.saveRelated == 0 - && DAT_GameCore::instance.gamePausedLogical == 0 - && (DAT_GameCore::instance.currentMenuViewType - != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU - || (DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM - && DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)) - && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .lordKilledByPlayerID - == 0 - && (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerDeathRelated - == 0 - || (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY - && DAT_GameState::instance.mapAndTime.gameOver - == DAT_GameSynchronyState::instance.currentPlayerSlotID))) { - MACRO_CALL( - OpenSHC::UI::MenuItems::General_Func::MenuItemActionHandler_General_ToolbarButtonPressed)( - OpenSHC::Commands::M_MAPPER_DELETE); - } - } else if (buttonID == -5) { - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerDeathRelated - == 0) { - DAT_GameCore::instance.gameSuspended = 1; - DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, - DAT_SoundSystemState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, - DAT_BinkControlState::ptr)(1); - DAT_GameCore::instance.isBinkVideoPlaying = 0; - // compared with TRUE: the original tests isSkirmishTrail == 1 (0x00444D14) - if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER - && DAT_GameCore::instance.isSkirmishTrail == TRUE) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_CRUSADE_MISSION_INTRO, 0); - } else { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); - } - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition3::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - } - } else { - // nested, with the two early returns: one else-if chain loses the match - if (buttonID == -4) { - DAT_StopHandlingMenuItems::instance = 0; - return; - } - if (buttonID == -90) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); - if (DAT_GameCore::instance.genieVoiceActive) { - // "Genie_11.wav" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - SFX_YourAllies); - } - } else { - if (buttonID == -91) { - DAT_GreatestLordDefinedData::instance.tableSortBy = -1; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_GREATEST_LORD, FALSE); - return; - } - if (buttonID <= -10) { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - if (buttonID > -100) { - for (int player = 0; player < 9; ++player) { - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] = -1; - } - // buttons -10 to -17 pick editor player 1 to 8 - int const slot = -9 - buttonID; - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] = 1; - DAT_GameSynchronyState::instance.currentPlayerSlotID = slot; - return; - } - // without the -100 test the original's je after the jle (0x00444DDB) goes - if (buttonID != -100) { - if (buttonID == -101) { - DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; - DAT_TileMapState::instance.savedEditorActiveBrush - = DAT_TileMapState::instance.editorActiveBrush; - MACRO_CALL(OpenSHC::UI::MenuItems::MapEditorLandscaping_Func:: - MenuItemActionHandler_MapEditorLandscaping_GeneralButtons)( - OpenSHC::Commands::M_MAPPER_TOMAIN); - } else if (buttonID == -102) { - DAT_TileMapState::instance.editorActiveBrush - = DAT_TileMapState::instance.savedEditorActiveBrush; - DAT_UnitsState::instance.lastSelectedUnitID = 0; - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, - DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, - DAT_UnitsState::ptr)(); - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemActionHandler_General_ToolbarButtonPressed)( - OpenSHC::Commands::M_MAPPER_TOTEST); - } - } - } - } else if (buttonID >= OpenSHC::UI::Enums::BASMTT_STATUS_OVERVIEW - && buttonID <= OpenSHC::UI::Enums::BASMTT_STATUS_RELIGION) { - if (DAT_GameSynchronyState::instance.syncStatus == 0 - && DAT_GameCore::instance.gamePausedLogical == 0) { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR - || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - DAT_StopHandlingMenuItems::instance = 0; - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_BUILDING_HELP_TEXT) { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, - DAT_TextEditorState::ptr)(); - } - int statusTab = buttonID; - if ((((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk - || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) - && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) - || (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1 - && MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func:: - singlePlayerHasKeepAndGranaryCheck, - DAT_GameState::ptr)() - == 0 - && MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, - DAT_UnitsState::ptr)( - DAT_GameSynchronyState::instance.currentPlayerSlotID) - != 0) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk - && DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 - == OpenSHC::Map::MT_SIEGE)) - && !MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { - statusTab = OpenSHC::UI::Enums::BASMTT_STATUS_ARMY; - } - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - if (DAT_UnitsState::instance - .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - > 0) { - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab - = DAT_GameCore::instance.tabTypeSiegeSubset; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, - DAT_GameCore::ptr)(OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - } - MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, - DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); - DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = statusTab; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 1; - DAT_BuildingsState::instance.newSelectedBuildingID = 0; - DAT_BuildingsState::instance.newSelectedUnitID = 0; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL - && statusTab == OpenSHC::UI::Enums::BASMTT_STATUS_OVERVIEW) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialBuildingActionState)( - 14, OpenSHC::Map::Buildings::BT_HOVEL); - } - } - } else if (DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_BUILD_MENU - || buttonID != DAT_GameCore::instance.activeMenuTab.buildMenuTab) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - if (DAT_UnitsState::instance - .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - > 0) { - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab - = DAT_GameCore::instance.tabTypeSiegeSubset; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - } - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::queueEscapeCommand, DAT_UnitsState::ptr)(); - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab = buttonID; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 1; - switch (buttonID) { - case OpenSHC::UI::Enums::BMTT_CASTLE: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7B); - break; - case OpenSHC::UI::Enums::BMTT_INDUSTRY: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7C); - break; - case OpenSHC::UI::Enums::BMTT_TOWN: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7D); - break; - case OpenSHC::UI::Enums::BMTT_FARMS: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7E); - break; - case OpenSHC::UI::Enums::BMTT_FOOD: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x7F); - break; - case OpenSHC::UI::Enums::BMTT_WEAPONS: - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, - DAT_SFXState::ptr)(OpenSHC::Audio::SFX::SEID_UNKNOWN_0x80); - break; - } - } - } - } - } else { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); - return; - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_UNUSED_CREATE_SIEGE, 0); - return; - } - if (((DAT_GameCore::instance.currentMenuViewType != OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU) - || ((DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM - && (DAT_GameCore::instance.activeMenuTab.tabType - != OpenSHC::UI::Enums::BASMTT_MERCENARYPOST)))) - && DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_PAUSE_MENU); - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_UNKNOWN_0x101); - } - } - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp b/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp deleted file mode 100644 index b6491bbf2a..0000000000 --- a/src/OpenSHC/UI/MenuItems/MissionEndscreen/MenuItemActionHandler_MissionEndscreen_Main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "../MissionEndscreen.func.hpp" - -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/DAT_00ec082c.hpp" -#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/INT_00eb0e44.hpp" -#include "OpenSHC/Globals/INT_00ed279c.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004D6BC0 - void MissionEndscreen::MenuItemActionHandler_MissionEndscreen_Main(int action, ...) - { - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER) { - return; - } - // DAT_00ec082c is the page: 0 and 1 are the 800x600 layout, 2 and 3 the larger one - switch (action) { - case -1: - if (INT_00eb0e44::instance != 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, - DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); - INT_00eb0e44::instance = 0; - return; - } - INT_00ed279c::instance = 1; - return; - case -100: - if (INT_00eb0e44::instance != 0) { - return; - } - if (DAT_00ec082c::instance >= 2) { - DAT_00ec082c::instance = 2; - DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_KEEP_OR_MPMENU_IPX; - return; - } - DAT_00ec082c::instance = 0; - DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_NONE; - return; - case -101: - if (INT_00eb0e44::instance != 0) { - return; - } - if (DAT_00ec082c::instance < 2) { - DAT_00ec082c::instance = 1; - DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM; - return; - } - DAT_00ec082c::instance = 3; - DAT_GameCore::instance.activeMenuTab.tabType = OpenSHC::UI::Enums::BASMTT_INN_OR_MPMMENU_UNK; - return; - case -10: - return; - case -2: - // -2 sorts by the first column - action = 0; - default: - DAT_FinalResultsOrderByColumn::instance = action; - INT_00eb0e44::instance = 0; - return; - } - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp deleted file mode 100644 index 8f7a7dabbb..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewMapMapsize/MenuItemRenderFunction_NewMapMapsize_Buttons.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "../NewMapMapsize.func.hpp" - -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/Map/MapConstants.hpp" -#include "OpenSHC/Rendering/Enums/GmDataIndex.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/INT_00b95abc.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042F7F0 - void NewMapMapsize::MenuItemRenderFunction_NewMapMapsize_Buttons(int button, ...) - { - if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU - || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { - return; - } - if (button == 7) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - return; - } - if (DAT_ButtonCurrentlyInteracting::instance) { - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { - DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4; - if (INT_00b95abc::instance != button) { - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); - } - INT_00b95abc::instance = button; - } else { - if (button == INT_00b95abc::instance) { - INT_00b95abc::instance = -1; - } - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { - DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } - int mapSize; - switch (button) { - default: - mapSize = OpenSHC::Map::MC_MAP_SIZE_400; - break; - case 3: - mapSize = OpenSHC::Map::MC_MAP_SIZE_300; - break; - case 2: - mapSize = OpenSHC::Map::MC_MAP_SIZE_200; - break; - case 1: - mapSize = OpenSHC::Map::MC_MAP_SIZE_160; - break; - } - // "%dx%d" - char sizeText[20]; - MACRO_CALL(OpenSHC::OS_Func::_sprintf)(sizeText, s__dx_d_005a22fc, mapSize, mapSize); - // a positive alignment centres the text within that many pixels from x - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - sizeText, DAT_ButtonX::instance, DAT_ButtonY::instance + 19, - (OpenSHC::Text::TextAlignment)DAT_ButtonW::instance, 12775659, 0, 17, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp b/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp deleted file mode 100644 index 529f60bdc2..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewMapMaptype/MenuItemRenderFunction_NewMapMaptype_Buttons.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "../NewMapMaptype.func.hpp" - -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Enums/GmDataIndex.hpp" -#include "OpenSHC/Text/GameLanguage.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/INT_00b95abc.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042F140 - void NewMapMaptype::MenuItemRenderFunction_NewMapMaptype_Buttons(int button, ...) - { - if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU - || DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { - return; - } - if (button == 7) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - return; - } - if (DAT_ButtonCurrentlyInteracting::instance) { - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { - DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4; - if (INT_00b95abc::instance != button) { - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); - } - INT_00b95abc::instance = button; - } else { - if (button == INT_00b95abc::instance) { - INT_00b95abc::instance = -1; - } - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag) { - DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_ICONS_FRONT_END_353_PIC_17; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } - int textY = 19; - int fontSize = 17; - if (DAT_TextManagerObject::instance.gameLanguage >= OpenSHC::Text::GL_FRENCH - && DAT_TextManagerObject::instance.gameLanguage <= OpenSHC::Text::GL_SPANISH) { - fontSize = 18; - textY = 20; - } - if (button == 1) { - // "New Castle Builder Map" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAP_TITLES, 1, DAT_ButtonX::instance + 26, DAT_ButtonY::instance + textY, - OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); - } - if (button == 2) { - // "New Custom Scenario Map" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SHC_STANDALONE, 2, DAT_ButtonX::instance + 26, - DAT_ButtonY::instance + textY, OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); - } - if (button == 3) { - // "New Crusader Map" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAP_TITLES, 2, DAT_ButtonX::instance + 26, DAT_ButtonY::instance + textY, - OpenSHC::Text::TTA_LEFT, 12775659, 0, fontSize, FALSE); - } - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp b/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp deleted file mode 100644 index 401a826a2d..0000000000 --- a/src/OpenSHC/UI/MenuItems/OnlineVoteQuitAndQuitGame/MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "../OnlineVoteQuitAndQuitGame.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::DE::SHCDE::eTextSections; - - // FUNCTION: STRONGHOLDCRUSADER 0x00493850 - void OnlineVoteQuitAndQuitGame::MenuItemRenderFunction_OnlineVoteQuitAndQuitGame_Main(int button, ...) - { - eTextSections section = OpenSHC::DE::SHCDE::TEXT_UNKNOWN_0; - int textIndex = 0; - switch (button) { - case 1: - // "Quit Game" - section = OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS; - textIndex = 8; - break; - case 2: - case 4: - // "End this game?" - section = OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION; - textIndex = 59; - break; - case 3: - case 5: - // "Cancel" - section = OpenSHC::DE::SHCDE::TEXT_MULTIPLAYER_CONNECTION; - textIndex = 3; - break; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 7; - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(section, textIndex), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(section, textIndex), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 2); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp b/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp deleted file mode 100644 index df2fba1c7c..0000000000 --- a/src/OpenSHC/UI/MenuItems/SelectCrusade/MenuItemActionHandler_SelectCrusade_Main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// disable deprecation warnings for strcpy -#pragma warning(disable : 4996) - -#include "../SelectCrusade.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Game/TrailType.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" -#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042BF00 - void SelectCrusade::MenuItemActionHandler_SelectCrusade_Main(int skirmishType, ...) - { - if (skirmishType == -1) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); - return; - } - if (skirmishType != 1 && skirmishType != 3 && skirmishType != 4) { - if (skirmishType != 2) { - return; - } - // "Custom skirmish game" - DAT_GameCore::instance.isSkirmishTrail = FALSE; - DAT_GameSynchronyState::instance.field_0x106ee4 = 1; - DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_LOBBY_MENU, 0); - MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); - Menu_LobbyMenu::instance.thousand = 0; - MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::setupSkirmishLobby, DAT_GameSynchronyState::ptr)(); - DAT_GameSynchronyState::instance.isHost = TRUE; - DAT_GameSynchronyState::instance.currentGameMode = OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER; - DAT_GameSynchronyState::instance.DPLAYX_ReceivedPlayerID = 1; - DAT_GameCore::instance.gameMode_2 = OpenSHC::Game::GM_SKIRMISH_AND_MULTIPLAYER; - MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, - sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); - // the player's name - strcpy(DAT_GameSynchronyState::instance.DAT_PlayerNames[1], - MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0)); - DAT_GameSynchronyState::instance.currentPlayerSlotID = 0; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); - for (int slot = 0; slot < 9; ++slot) { - DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[slot] = 1; - } - return; - } - DAT_GameCore::instance.gameSuspended = 0; - if (skirmishType == 4) { - DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_EXTREME; - } else if (skirmishType == 3) { - DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_WARCHEST; - } else { - DAT_GameCore::instance.currentTrailType = OpenSHC::Game::TT_FIRST_EDITION; - } - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_CRUSADE_MAP, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp b/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp deleted file mode 100644 index 96bd483e5c..0000000000 --- a/src/OpenSHC/UI/MenuItems/Unused/MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "../Unused.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/COL_WHITE.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_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042DE20 - void Unused::MenuItemRenderFunction_UnusedOldTitleMenu_ExitButton(int unused, ...) - { - if (DAT_ButtonCurrentlyInteracting::instance) { - DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; - DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; - } else { - DAT_TextManagerObject::instance.textColor = 0; - DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, DAT_PencilRenderCore::ptr)( - DAT_ButtonX::instance, DAT_ButtonY::instance, DAT_ButtonW::instance + DAT_ButtonX::instance, - DAT_ButtonY::instance + DAT_ButtonH::instance, DAT_PencilRenderCore::instance.otherColorUnk_0x0); - // a positive alignment centres the text within that many pixels from x - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // "Exit" - s_Exit_005a22d0, DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - (OpenSHC::Text::TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 17, - FALSE, 0); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 22c6a6cc18..a784f98c9f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6861,7 +6861,7 @@ SHC_3BB0A8C1_0x0042804F | 0.0% | Pending SHC_3BB0A8C1_0x00428050 | 0.0% | Pending -SHC_3BB0A8C1_0x00428150 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x00428150 | 0.0% | Pending SHC_3BB0A8C1_0x00428480 | 0.0% | Pending @@ -7449,7 +7449,7 @@ SHC_3BB0A8C1_0x0042BB90 | 0.0% | Pending SHC_3BB0A8C1_0x0042BBF0 | 0.0% | Pending -SHC_3BB0A8C1_0x0042BF00 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0042BF00 | 0.0% | Pending SHC_3BB0A8C1_0x0042BFC0 | 0.0% | Pending @@ -8259,7 +8259,7 @@ SHC_3BB0A8C1_0x0042DCB0 | 0.0% | Pending SHC_3BB0A8C1_0x0042DD00 | 0.0% | Pending -SHC_3BB0A8C1_0x0042DE20 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0042DE20 | 0.0% | Pending SHC_3BB0A8C1_0x0042DEB0 | 0.0% | Pending @@ -8723,7 +8723,7 @@ SHC_3BB0A8C1_0x0042EFE0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0042F010 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0042F140 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0042F140 | 0.0% | Pending SHC_3BB0A8C1_0x0042F2B0 | 0.0% | Pending @@ -9157,7 +9157,7 @@ SHC_3BB0A8C1_0x0042F7E3 | 0.0% | Pending SHC_3BB0A8C1_0x0042F7E4 | 0.0% | Pending -SHC_3BB0A8C1_0x0042F7F0 | 100.0% | Reimplemented, Security Cookie mismatches +SHC_3BB0A8C1_0x0042F7F0 | 0.0% | Pending SHC_3BB0A8C1_0x0042F940 | 0.0% | Pending @@ -15407,7 +15407,7 @@ SHC_3BB0A8C1_0x00444B71 | 0.0% | Pending SHC_3BB0A8C1_0x00444B72 | 0.0% | Pending -SHC_3BB0A8C1_0x00444B80 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x00444B80 | 0.0% | Pending SHC_3BB0A8C1_0x00445184 | 0.0% | Pending @@ -23633,7 +23633,7 @@ SHC_3BB0A8C1_0x004937B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004937E0 | 0.0% | Pending -SHC_3BB0A8C1_0x00493850 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x00493850 | 0.0% | Pending SHC_3BB0A8C1_0x004938EC | 0.0% | Pending @@ -25873,7 +25873,7 @@ SHC_3BB0A8C1_0x004AE720 | 0.0% | Pending SHC_3BB0A8C1_0x004AE7C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004AE7D0 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x004AE7D0 | 0.0% | Pending SHC_3BB0A8C1_0x004AE950 | 0.0% | Pending @@ -35615,7 +35615,7 @@ SHC_3BB0A8C1_0x004D6BB8 | 0.0% | Pending SHC_3BB0A8C1_0x004D6BBC | 0.0% | Pending -SHC_3BB0A8C1_0x004D6BC0 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x004D6BC0 | 0.0% | Pending SHC_3BB0A8C1_0x004D6C98 | 0.0% | Pending From 09bca785ea297c569746d407299f2d9724fff78b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 11:57:41 +0100 Subject: [PATCH 49/64] headers: drop the changes only the nine functions now in reimpl/UI-MenuItems-headers-100 used Removes SoundEffectID values 123-128 and 257, GameCommandType value 112, eTextSections value 0, the "Exit" string at 0x005A22D0, INT_00eb0e44 as a char and DAT_00ec082c as an int: no function left on this branch or on reimpl/UI-MenuItems-3-development-2 uses them. The other header commits stay, because 0x00442640, 0x004255D0, 0x004314E0 here and 0x004909E0 on -development-2 use them. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Audio/SFX/SoundEffectID.hpp | 9 +-------- src/OpenSHC/Commands/GameCommandType.hpp | 1 - src/OpenSHC/DE/SHCDE/eTextSections.hpp | 1 - src/OpenSHC/Globals/DAT_00ec082c.hpp | 4 ++-- src/OpenSHC/Globals/INT_00eb0e44.hpp | 4 ++-- src/OpenSHC/string-literals.hpp | 3 --- src/OpenSHC/string-macros.hpp | 3 --- 7 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp index ad21aa676c..fe0483d855 100644 --- a/src/OpenSHC/Audio/SFX/SoundEffectID.hpp +++ b/src/OpenSHC/Audio/SFX/SoundEffectID.hpp @@ -97,12 +97,6 @@ namespace Audio { SEID_UNIT_KILLED_BY_ARROW2 = 118, // 0x00000076 SEID_New_Name = 119, // 0x00000077 SEID_FIRE_IGNITE = 122, // 0x0000007A - SEID_UNKNOWN_0x7B = 123, // 0x0000007B - SEID_UNKNOWN_0x7C = 124, // 0x0000007C - SEID_UNKNOWN_0x7D = 125, // 0x0000007D - SEID_UNKNOWN_0x7E = 126, // 0x0000007E - SEID_UNKNOWN_0x7F = 127, // 0x0000007F - SEID_UNKNOWN_0x80 = 128, // 0x00000080 SEID_UNKNOWN_0x87 = 135, // 0x00000087 SEID_CHICKEN1 = 137, // 0x00000089 SEID_GATEHOUSE_CLOSE = 141, // 0x0000008D @@ -204,8 +198,7 @@ namespace Audio { SEID_UNIT_DAMAGE3 = 248, // 0x000000F8 SEID_UNIT_DAMAGE4 = 249, // 0x000000F9 SEID_UNKNOWN_0xFB = 251, // 0x000000FB - SEID_UNKNOWN_0xFD = 253, // 0x000000FD - SEID_UNKNOWN_0x101 = 257 // 0x00000101 + SEID_UNKNOWN_0xFD = 253 // 0x000000FD } SoundEffectID; diff --git a/src/OpenSHC/Commands/GameCommandType.hpp b/src/OpenSHC/Commands/GameCommandType.hpp index d7de0cfac4..fbaed2f30c 100644 --- a/src/OpenSHC/Commands/GameCommandType.hpp +++ b/src/OpenSHC/Commands/GameCommandType.hpp @@ -98,7 +98,6 @@ namespace Commands { GCT_UNKNOWN_107 = 107, // 0x0000006B GCT_LOAD_SKIRMISH_SCREEN = 109, // 0x0000006D GCT_SKIRMISH_ADD_AI_PLAYER = 111, // 0x0000006F - GCT_UNKNOWN_112 = 112, // 0x00000070 GCT_SEND_PLAYER_TO_PLAYER_REQUEST = 113, // 0x00000071 GCT_HOST_SHARE_AIV = 114, // 0x00000072 GCT_HOST_SHARE_HEATMAP = 115, // 0x00000073 diff --git a/src/OpenSHC/DE/SHCDE/eTextSections.hpp b/src/OpenSHC/DE/SHCDE/eTextSections.hpp index 4c62d9d320..f3afb1f118 100644 --- a/src/OpenSHC/DE/SHCDE/eTextSections.hpp +++ b/src/OpenSHC/DE/SHCDE/eTextSections.hpp @@ -13,7 +13,6 @@ namespace DE { namespace SHCDE { typedef enum eTextSections { - TEXT_UNKNOWN_0 = 0, // 0x00000000 TEXT_MONTHS = 1, // 0x00000001 TEXT_GOODS = 2, // 0x00000002 TEXT_POPULARITY_EFFECTS = 3, // 0x00000003 diff --git a/src/OpenSHC/Globals/DAT_00ec082c.hpp b/src/OpenSHC/Globals/DAT_00ec082c.hpp index 3ca602239a..1d94dbc620 100644 --- a/src/OpenSHC/Globals/DAT_00ec082c.hpp +++ b/src/OpenSHC/Globals/DAT_00ec082c.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00EC082C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00EC082C) DAT_00ec082c; +MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00EC082C) DAT_00ec082c; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EC082C); diff --git a/src/OpenSHC/Globals/INT_00eb0e44.hpp b/src/OpenSHC/Globals/INT_00eb0e44.hpp index 26e63fbc87..cac8b5665e 100644 --- a/src/OpenSHC/Globals/INT_00eb0e44.hpp +++ b/src/OpenSHC/Globals/INT_00eb0e44.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00EB0E44 -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(char, false, Address::SHC_3BB0A8C1_0x00EB0E44) INT_00eb0e44; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00EB0E44) INT_00eb0e44; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00EB0E44); diff --git a/src/OpenSHC/string-literals.hpp b/src/OpenSHC/string-literals.hpp index d2438aa321..95ede65fda 100644 --- a/src/OpenSHC/string-literals.hpp +++ b/src/OpenSHC/string-literals.hpp @@ -2276,9 +2276,6 @@ char const* const s_Crusader_005a22b8 = S_CRUSADER_005A22B8; // 0x005a22c4 char const* const s_FireFly_s_005a22c4 = S_FIREFLY_S_005A22C4; -// 0x005a22d0 -char const* const s_Exit_005a22d0 = S_EXIT_005A22D0; - // 0x005a22d8 char const* const s_Continue_005a22d8 = S_CONTINUE_005A22D8; diff --git a/src/OpenSHC/string-macros.hpp b/src/OpenSHC/string-macros.hpp index 2900831ae6..9fd49cdce0 100644 --- a/src/OpenSHC/string-macros.hpp +++ b/src/OpenSHC/string-macros.hpp @@ -2280,9 +2280,6 @@ // STRING: STRONGHOLDCRUSADER 0x005a22c4 #define S_FIREFLY_S_005A22C4 "FireFly's" -// STRING: STRONGHOLDCRUSADER 0x005a22d0 -#define S_EXIT_005A22D0 "Exit" - // STRING: STRONGHOLDCRUSADER 0x005a22d8 #define S_CONTINUE_005A22D8 "Continue" From 516cbc64ea41205386777f770d1ba370e9da655f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 13:35:00 +0100 Subject: [PATCH 50/64] headers: ColorsEnum gets the colours our menus and displays use COL_007D3E, COL_00A2FF, COL_7CAAAF, COL_7F7F7F, COL_B8E6F5 and COL_C2F0EB, in the generated style and value order. They were written as numbers in our reimplementations; gynt's review of #323 asked for them in the Colors enum. The same commit is in each of our PRs that uses one of them. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Rendering/Colors/ColorsEnum.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp b/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp index e31edf4234..6fec3f33ab 100644 --- a/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp +++ b/src/OpenSHC/Rendering/Colors/ColorsEnum.hpp @@ -14,9 +14,15 @@ namespace Rendering { typedef enum ColorsEnum { COL_0000FF = 255, // 0x000000FF + COL_007D3E = 32062, // 0x00007D3E COL_0080FF = 33023, // 0x000080FF + COL_00A2FF = 41727, // 0x0000A2FF COL_00FF00 = 65280, // 0x0000FF00 + COL_7CAAAF = 8170159, // 0x007CAAAF + COL_7F7F7F = 8355711, // 0x007F7F7F + COL_B8E6F5 = 12117749, // 0x00B8E6F5 COL_B8EEFB = 12119803, // 0x00B8EEFB + COL_C2F0EB = 12775659, // 0x00C2F0EB COL_CCFAFF = 13433599, // 0x00CCFAFF COL_FFFFFF = 16777215 // 0x00FFFFFF From 446f9fa173dd08c87b31633753860d0657f3e5d9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 14:07:31 +0100 Subject: [PATCH 51/64] style: colours by their ColorsEnum name gynt on #323: colours by their ColorsEnum name, never as numbers. Every colour number in this branch's files is now its OpenSHC::Rendering::Colors name (COL_C2F0EB, COL_FFFFFF, COL_00A2FF, COL_7CAAAF, from the shared ColorsEnum commit before this one). Each function's /FA listing is identical before and after. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableArabTroops_Main.cpp | 2 +- ...mRenderFunction_DisableEuroTroops_Main.cpp | 2 +- ...rFunction_EnterTitleOnGameStart_Button.cpp | 2 +- ...on_General_CreateEventCallbackFunction.cpp | 2 +- ...erFunction_HistoricCampaignSelect_Main.cpp | 3 +- ...ItemRenderFunction_SendReceiveMap_Main.cpp | 2 +- ...uItemRenderFunction_TextEditor_Buttons.cpp | 47 ++++++++++--------- .../MenuItemRenderFunction_TraderSettings.cpp | 11 +++-- ...enuItemRenderFunction_TutorialBox_Main.cpp | 2 +- 9 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp index cf6ecd72ef..9030f0df64 100644 --- a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp @@ -51,7 +51,7 @@ namespace UI { 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } // "Exit" diff --git a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp index db9fde28d6..9b97c7d7c3 100644 --- a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp @@ -58,7 +58,7 @@ namespace UI { 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } // "Exit" diff --git a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp index 3afffcddf7..40887bb826 100644 --- a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp +++ b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp @@ -29,7 +29,7 @@ namespace UI { 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_BUBBLE_HELP_TEXT, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp index bed2469b09..83b55d813c 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp @@ -105,7 +105,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1), DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, diff --git a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp index 82b405e868..d2b3c1eaa0 100644 --- a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp @@ -7,6 +7,7 @@ #include "OpenSHC/Audio/SFX/SoundEffectID.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" @@ -69,7 +70,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, param_1 + 309), - textX, textY, OpenSHC::Text::TTA_LEFT, 12775659, 0, 16, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); if (!DAT_ButtonCurrentlyInteracting::instance) { return; } diff --git a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp index ade60d1ca9..078dbce4d5 100644 --- a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp @@ -39,7 +39,7 @@ namespace UI { 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_MULTIPLAYER_CONNECTION, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } } diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp index 1a85bae175..dfcc721006 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp @@ -53,7 +53,7 @@ namespace UI { // "Back" DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_HELP, 1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 4); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, // "Back" @@ -72,7 +72,7 @@ namespace UI { // "Exit" DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_HELP, 2, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 4); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 4); return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( @@ -233,67 +233,67 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "PIC" S_PIC_005A558C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - 16777215, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 2: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "FONT" S_FONT_005A5584, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - 16777215, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 3: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "COLOUR" S_COLOUR_005A557C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 10: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "LINKCLR" S_LINKCLR_005A5574, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 4: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "LINK" S_LINK_005A556C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - 16777215, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 5: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "\\LINK" S__LINK_005A5564, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - 16777215, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 7: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "CENTRE" S_CENTRE_005A555C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 8: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "\\CENTRE" S__CENTRE_005A5554, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 11: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "SOUND" S_SOUND_005A554C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - 16777215, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 12: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "STRING" S_STRING_005A5544, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 14: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "INCLUDE" S_INCLUDE_005A553C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, - OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); } break; case 32: @@ -301,7 +301,7 @@ namespace UI { DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; } else { - DAT_TextManagerObject::instance.textColor = 16777215; + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_FFFFFF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; } switch (DAT_TextEditorState::instance.field_0x23970) { @@ -329,7 +329,8 @@ namespace UI { .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex + 1]); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - textAddress, xParam, yParam, OpenSHC::Text::TTA_LEFT, 16777215, 19, FALSE, 0); + textAddress, xParam, yParam, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, + 19, FALSE, 0); return; case 3: case 10: @@ -342,8 +343,8 @@ namespace UI { .field_0x7a16c[(ushort)DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory [DAT_TextEditorState::instance.activeHelpHotspotIndex + 1]] .name_0x0, - DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, 16777215, 19, - FALSE, 0); + DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 4: case 14: @@ -401,7 +402,7 @@ namespace UI { [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] == 0 ? OpenSHC::Rendering::Colors::COL_0000FF - : 16777215); + : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Left" S_LEFT_005A5534, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, @@ -415,7 +416,7 @@ namespace UI { DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; } else { - DAT_TextManagerObject::instance.textColor = 16777215; + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_FFFFFF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; } MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, @@ -440,7 +441,7 @@ namespace UI { [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] == 1 ? OpenSHC::Rendering::Colors::COL_0000FF - : 16777215); + : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Centre" S_CENTRE_005A55C0, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, @@ -454,7 +455,7 @@ namespace UI { DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_0000FF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_WHITE::instance.shortValue; } else { - DAT_TextManagerObject::instance.textColor = 16777215; + DAT_TextManagerObject::instance.textColor = OpenSHC::Rendering::Colors::COL_FFFFFF; DAT_PencilRenderCore::instance.otherColorUnk_0x0 = COL_BLACK::instance.shortValue; } MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, @@ -478,7 +479,7 @@ namespace UI { [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] == 2 ? OpenSHC::Rendering::Colors::COL_0000FF - : 16777215); + : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Right" S_RIGHT_005A551C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, @@ -496,7 +497,7 @@ namespace UI { [DAT_TextEditorState::instance.activeHelpHotspotIndex + 2] == 3 ? OpenSHC::Rendering::Colors::COL_0000FF - : 16777215); + : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Here" S_HERE_005A5514, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, diff --git a/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp index 075cc4c29d..bf5a703590 100644 --- a/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp +++ b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp @@ -8,6 +8,7 @@ #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" @@ -59,7 +60,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 172), DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; @@ -73,7 +74,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 173), DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, 8170159, 18, FALSE, 0); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_7CAAAF, 18, FALSE, 0); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; } @@ -91,7 +92,8 @@ namespace UI { // "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, 41727, 15974, 18, FALSE); + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_00A2FF, + 15974, 18, FALSE); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; @@ -103,7 +105,8 @@ namespace UI { // "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, 16777215, 0, 18, FALSE); + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_FFFFFF, 0, 18, + FALSE); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; return; } diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp index 8bc06d4f63..8ab0964738 100644 --- a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp @@ -60,7 +60,7 @@ namespace UI { 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_TUTORIAL_BUTTONS, buttonText), - textX, textY, OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE, 0); + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } } From b7d09c0a32dd50c03b8163c6008916f5e26dc85c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 12:21:28 +0100 Subject: [PATCH 52/64] Move AvailablePeasantsTextUpperRight to the ready PR MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight (0x0043A8E0) reaches 100.0 on main's headers in a new form, so it goes to reimpl/batch4-100. Its .cpp leaves this draft and its status line is main's again. Co-Authored-By: Claude Opus 5.5 --- ...usMenu_AvailablePeasantsTextUpperRight.cpp | 39 ------------------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp deleted file mode 100644 index 60d719d888..0000000000 --- a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "../BuildingAndStatusMenu.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" - -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0043A8E0 - void BuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_AvailablePeasantsTextUpperRight( - int param_1, ...) - { - // "Available Peasants" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_BARRACKS, 3), - DAT_ButtonX::instance - 5, DAT_ButtonY::instance, OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 18, FALSE, 0); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availablePeasantsOrHousedPeasants - - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .count, - DAT_ButtonX::instance, DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 18, FALSE, 0); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a784f98c9f..ffced8ac8b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13403,7 +13403,7 @@ SHC_3BB0A8C1_0x0043A8C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043A8D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043A8E0 | 88.9% | cleanup; register allocation +SHC_3BB0A8C1_0x0043A8E0 | 0.0% | Pending SHC_3BB0A8C1_0x0043A960 | 0.0% | Pending From 1918de9f5ec229f2ac87973f15d171b9022ceb6f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 17:34:38 +0100 Subject: [PATCH 53/64] Loop bounds by countof(), as main's 948dce845 LobbyscreenStartButtonClick's two loops over player slots (currentPlayerFullIDArray, 9) and two over keep positions (keepPositions, 8) now write countof(that array). quick_diff is unchanged at 0.9215, but with three or more of the four sites MSVC swaps the registers of two loads that feed a commutative add (ScrollOffset + RelativeSelected), so two instructions leave the original's address order; the two keep-position sites alone, or the two player sites alone, compile identically. Nine source variants tried, including both operand orders of the sum. Co-Authored-By: Claude Opus 5.5 --- ...onHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp index e07dd5c072..778f4257bb 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_LobbyscreenStartButtonClick.cpp @@ -62,7 +62,8 @@ namespace UI { if (!DAT_GameSynchronyState::instance.isHost) { break; } - for (int player = 1; player < 9; ++player) { + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { return; @@ -135,7 +136,8 @@ namespace UI { if (!DAT_GameSynchronyState::instance.isHost) { break; } - for (int player = 1; player < 9; ++player) { + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 && DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[player] == 0) { return; @@ -217,7 +219,7 @@ namespace UI { if (!DAT_GameSynchronyState::instance.isHost) { break; } - for (int position = 0; position < 8; ++position) { + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { int const x = DAT_GameCore::instance.keepPositions[position].x; if (x < 0 || DAT_MouseState::instance.screenSpaceX @@ -243,7 +245,7 @@ namespace UI { break; } if (DAT_00b95960::instance >= 0) { - for (int position = 0; position < 8; ++position) { + for (int position = 0; position < countof(DAT_GameCore::instance.keepPositions); ++position) { int const x = DAT_GameCore::instance.keepPositions[position].x; if (x < 0 || DAT_MouseState::instance.screenSpaceX From 14b584f8ba71296c4585373a5acacdd3358f7119 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 19:22:05 +0100 Subject: [PATCH 54/64] drop: 0x004314E0 goes to reimpl/UI-MenuItems-6-100 MapEditorLandscaping_GeneralButtons reached 100% and moves to the ready PR with the TileMapState header commit it needs. Its file goes and its status line is main's again; the header change only it used goes in the next commit. Co-Authored-By: Claude Opus 5.5 --- ...er_MapEditorLandscaping_GeneralButtons.cpp | 246 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp deleted file mode 100644 index 4bd8371612..0000000000 --- a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_GeneralButtons.cpp +++ /dev/null @@ -1,246 +0,0 @@ -#include "../MapEditorLandscaping.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Map/TileMapState.func.hpp" -#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" -#include "OpenSHC/UI/MinimapViewState.func.hpp" -#include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MinimapViewState.hpp" -#include "OpenSHC/Globals/DAT_PathFindingState.hpp" -#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Commands::MappersEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004314E0 - void MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_GeneralButtons(MappersEnum param_1, ...) - { - switch (param_1) { - case OpenSHC::Commands::M_MAPPER_EXIT: - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_UNUSED_OLD_TITLE_MENU, 0); - return; - case OpenSHC::Commands::M_MAPPER_REBUILD: - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::ptr)(); - return; - case OpenSHC::Commands::M_MAPPER_TO_MAP_EDIT: - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); - return; - case OpenSHC::Commands::M_MAPPER_TOMAIN: - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_HUNTERSHUT; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - return; - case OpenSHC::Commands::M_MAPPER_AREA: { - int brush = DAT_TileMapState::instance.editorActiveBrush + 1; - DAT_TileMapState::instance.editorActiveBrush = brush; - if (brush > 7) { - brush = 1; - DAT_TileMapState::instance.editorActiveBrush = brush; - } - if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK1 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK2 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK3 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK4 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK5) { - if (brush == 2) { - brush = 3; - DAT_TileMapState::instance.editorActiveBrush = brush; - } else if (brush == 4) { - brush = 5; - DAT_TileMapState::instance.editorActiveBrush = brush; - } else if (brush == 6) { - brush = 7; - DAT_TileMapState::instance.editorActiveBrush = brush; - } - } - DAT_TileMapState::instance.unknownBrushRelated = brush >> 1; - DAT_StopHandlingMenuItems::instance = 0; - return; - } - case OpenSHC::Commands::M_MAPPER_AFFECT_TYPE: - if (++DAT_TileMapState::instance.editorAffectType > 1) { - DAT_TileMapState::instance.editorAffectType = 0; - } - return; - case OpenSHC::Commands::M_MAPPER_MIN: - DAT_TileMapState::instance.mapperMax = FALSE; - DAT_TileMapState::instance.currentMapperCommand = param_1; - return; - case OpenSHC::Commands::M_MAPPER_MAX: - DAT_TileMapState::instance.mapperMax = TRUE; - DAT_TileMapState::instance.currentMapperCommand = param_1; - return; - // each rock steps the brush up to the next odd size: the original repeats the tail in every case - case OpenSHC::Commands::M_MAPPER_BIGROCK1: - DAT_TileMapState::instance.editorRockType = 1; - DAT_TileMapState::instance.rockOrientation = 0; - DAT_TileMapState::instance.currentMapperCommand = param_1; - if (DAT_TileMapState::instance.editorActiveBrush == 2) { - DAT_TileMapState::instance.editorActiveBrush = 3; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 4) { - DAT_TileMapState::instance.editorActiveBrush = 5; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 6) { - DAT_TileMapState::instance.editorActiveBrush = 7; - } - return; - case OpenSHC::Commands::M_MAPPER_BIGROCK2: - DAT_TileMapState::instance.editorRockType = 2; - DAT_TileMapState::instance.rockOrientation = 2; - DAT_TileMapState::instance.currentMapperCommand = param_1; - if (DAT_TileMapState::instance.editorActiveBrush == 2) { - DAT_TileMapState::instance.editorActiveBrush = 3; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 4) { - DAT_TileMapState::instance.editorActiveBrush = 5; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 6) { - DAT_TileMapState::instance.editorActiveBrush = 7; - } - return; - case OpenSHC::Commands::M_MAPPER_BIGROCK3: - DAT_TileMapState::instance.editorRockType = 3; - DAT_TileMapState::instance.rockOrientation = 4; - DAT_TileMapState::instance.currentMapperCommand = param_1; - if (DAT_TileMapState::instance.editorActiveBrush == 2) { - DAT_TileMapState::instance.editorActiveBrush = 3; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 4) { - DAT_TileMapState::instance.editorActiveBrush = 5; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 6) { - DAT_TileMapState::instance.editorActiveBrush = 7; - } - return; - case OpenSHC::Commands::M_MAPPER_BIGROCK4: - DAT_TileMapState::instance.editorRockType = 4; - DAT_TileMapState::instance.rockOrientation = 6; - DAT_TileMapState::instance.currentMapperCommand = param_1; - if (DAT_TileMapState::instance.editorActiveBrush == 2) { - DAT_TileMapState::instance.editorActiveBrush = 3; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 4) { - DAT_TileMapState::instance.editorActiveBrush = 5; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 6) { - DAT_TileMapState::instance.editorActiveBrush = 7; - } - return; - case OpenSHC::Commands::M_MAPPER_BIGROCK5: - DAT_TileMapState::instance.editorRockType = 5; - DAT_TileMapState::instance.rockOrientation = 0; - DAT_TileMapState::instance.currentMapperCommand = param_1; - if (DAT_TileMapState::instance.editorActiveBrush == 2) { - DAT_TileMapState::instance.editorActiveBrush = 3; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 4) { - DAT_TileMapState::instance.editorActiveBrush = 5; - return; - } - if (DAT_TileMapState::instance.editorActiveBrush == 6) { - DAT_TileMapState::instance.editorActiveBrush = 7; - } - return; - case OpenSHC::Commands::M_MAPPER_SNAP_TO: - if (DAT_TileMapState::instance.editorSnapToMode == 0) { - DAT_TileMapState::instance.editorSnapToMode = 1; - return; - } - DAT_TileMapState::instance.editorSnapToMode = DAT_TileMapState::instance.editorSnapToMode == 1 ? 2 : 0; - return; - case OpenSHC::Commands::M_MAPPER_MAP_SIZE: - if (DAT_TileMapState::instance.mapSize == 0) { - DAT_TileMapState::instance.mapSize = 400; - } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapSize, DAT_TileMapState::ptr)( - DAT_TileMapState::instance.mapSize); - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::resetHeightAndMapBorders, DAT_TileMapState::ptr)( - DAT_TileMapState::instance.mapSize); - DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, DAT_TileMapState::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; - case OpenSHC::Commands::M_MAPPER_MP_KEEP1: - case OpenSHC::Commands::M_MAPPER_MP_KEEP2: - case OpenSHC::Commands::M_MAPPER_MP_KEEP3: - case OpenSHC::Commands::M_MAPPER_MP_KEEP4: - case OpenSHC::Commands::M_MAPPER_MP_KEEP5: - case OpenSHC::Commands::M_MAPPER_MP_KEEP6: - case OpenSHC::Commands::M_MAPPER_MP_KEEP7: - case OpenSHC::Commands::M_MAPPER_MP_KEEP8: - DAT_GameSynchronyState::instance.editorPlacementPlayerID - = param_1 - OpenSHC::Commands::M_MAPPER_SUB_MODE_FEATURE_MP; - if (DAT_GameCore::instance.mapU2MiddleBytes[2] == 0) { - DAT_TileMapState::instance.currentMapperCommand - = (OpenSHC::Commands::MappersEnum)((DAT_GameCore::instance.mapU2MiddleBytes[1] != 0) - + OpenSHC::Commands::M_MAPPER_KEEP1); - return; - } - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_KEEP3; - return; - case OpenSHC::Commands::M_MAPPER_AREA_BACK: { - int brush = DAT_TileMapState::instance.editorActiveBrush - 1; - DAT_TileMapState::instance.editorActiveBrush = brush; - if (brush < 1) { - brush = 7; - DAT_TileMapState::instance.editorActiveBrush = brush; - } - if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK1 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK2 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK3 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK4 - || DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_BIGROCK5) { - if (brush == 2) { - brush = 1; - DAT_TileMapState::instance.editorActiveBrush = brush; - } else if (brush == 4) { - brush = 3; - DAT_TileMapState::instance.editorActiveBrush = brush; - } else if (brush == 6) { - brush = 5; - DAT_TileMapState::instance.editorActiveBrush = brush; - } - } - DAT_TileMapState::instance.unknownBrushRelated = brush >> 1; - DAT_StopHandlingMenuItems::instance = 0; - return; - } - default: - DAT_GameSynchronyState::instance.editorPlacementPlayerID = 1; - DAT_TileMapState::instance.currentMapperCommand = param_1; - return; - case OpenSHC::Commands::M_MAPPER_TEST: - return; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b2a2f45456..144ea9f235 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -10543,7 +10543,7 @@ SHC_3BB0A8C1_0x004313C0 | 0.0% | Pending SHC_3BB0A8C1_0x00431460 | 0.0% | Pending -SHC_3BB0A8C1_0x004314E0 | 83.4% | one switch, no gotos; shared brush store +SHC_3BB0A8C1_0x004314E0 | 0.0% | Pending SHC_3BB0A8C1_0x0043184C | 0.0% | Pending From b0a3028a79d20bb48c68b8ee71f55b9287d528fd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 19:22:06 +0100 Subject: [PATCH 55/64] headers: drop the TileMapState change only 0x004314E0 used editorActiveBrush, unknownBrushRelated and editorAffectType are main's undefined4 again. Their one remaining user here is main's switchToMenuView, which compiles to the same code either way; the int change travels with 0x004314E0 in reimpl/UI-MenuItems-6-100. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/TileMapState.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/Map/TileMapState.hpp b/src/OpenSHC/Map/TileMapState.hpp index 86c035d116..b56f2d9b3e 100644 --- a/src/OpenSHC/Map/TileMapState.hpp +++ b/src/OpenSHC/Map/TileMapState.hpp @@ -125,16 +125,16 @@ namespace Map { undefined4 flatViewToggleValue2; // 0x005548D4 length: 4 undefined4 refreshRelatedTwo; // 0x005548D8 length: 4 undefined4 savedEditorActiveBrush; // 0x005548DC length: 4 - int editorActiveBrush; // 0x005548E0 length: 4 + undefined4 editorActiveBrush; // 0x005548E0 length: 4 MappersEnum currentMapperCommand; // 0x005548E4 length: 4 undefined4 DAT_BuildingSize; // 0x005548E8 length: 4 undefined4 unitPlacementCount; // 0x005548EC length: 4 BOOLEnum mapperMax; // 0x005548F0 length: 4 undefined4 rockFlagStartNumber; // 0x005548F4 length: 4 - int unknownBrushRelated; // 0x005548F8 length: 4 + undefined4 unknownBrushRelated; // 0x005548F8 length: 4 undefined4 editorSnapToMode; // 0x005548FC length: 4 undefined4 unknownZero_0x554900; // 0x00554900 length: 4 - int editorAffectType; // 0x00554904 length: 4 + undefined4 editorAffectType; // 0x00554904 length: 4 undefined4 wallCornerRotation; // 0x00554908 length: 4 int dragStartX; // 0x0055490C length: 4 int dragStartY; // 0x00554910 length: 4 From c1c152bf9b8188d19f55bf6fe0a3d0f8369da3ed Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 11:07:00 +0100 Subject: [PATCH 56/64] drafts: move five text buttons to the 100% PR 0x004BB570 DisableEuroTroops_Main, 0x004BB680 DisableArabTroops_Main, 0x004BD0F0 TutorialBox_Main (render), 0x00491C50 EnterTitleOnGameStart_Button and 0x004AC440 SendReceiveMap_Main reach 100% with the text position computed in each path, which puts the first push 0 where the original has it. They move to reimpl/UI-MenuItems-8-100, so this draft drops them and their status lines go back to main's. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_DisableArabTroops_Main.cpp | 66 ----------------- ...mRenderFunction_DisableEuroTroops_Main.cpp | 73 ------------------- ...rFunction_EnterTitleOnGameStart_Button.cpp | 43 ----------- ...ItemRenderFunction_SendReceiveMap_Main.cpp | 47 ------------ ...enuItemRenderFunction_TutorialBox_Main.cpp | 68 ----------------- status/addresses-SHC-3BB0A8C1.txt | 10 +-- 6 files changed, 5 insertions(+), 302 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp deleted file mode 100644 index 9030f0df64..0000000000 --- a/src/OpenSHC/UI/MenuItems/DisableArabTroops/MenuItemRenderFunction_DisableArabTroops_Main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "../DisableArabTroops.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BB680 - void DisableArabTroops::MenuItemRenderFunction_DisableArabTroops_Main(int param_1, ...) - { - if (param_1 >= 0 && param_1 <= 7) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - if (DAT_MapPropertiesState::instance.SEC_MercRecruitable[param_1] != 0) { - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, - DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (param_1 != -3) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 6; - if (!DAT_ButtonCurrentlyInteracting::instance) { - // "Exit" - 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - // "Exit" - 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp b/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp deleted file mode 100644 index 9b97c7d7c3..0000000000 --- a/src/OpenSHC/UI/MenuItems/DisableEuroTroops/MenuItemRenderFunction_DisableEuroTroops_Main.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "../DisableEuroTroops.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BB570 - void DisableEuroTroops::MenuItemRenderFunction_DisableEuroTroops_Main(int param_1, ...) - { - if (param_1 >= 0 && param_1 <= 7) { - if (param_1 == 2) { - DAT_ButtonX::instance -= 8; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - if (DAT_MapPropertiesState::instance.barracksRecruitability.array.barracksRecruitability[param_1] - != 0) { - return; - } - if (param_1 == 2) { - DAT_ButtonX::instance += 8; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 45, - DAT_ButtonX::instance + 9, DAT_ButtonY::instance + 3, 12); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (param_1 != -3) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 6; - if (!DAT_ButtonCurrentlyInteracting::instance) { - // "Exit" - 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - // "Exit" - 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, 3), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp b/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp deleted file mode 100644 index 40887bb826..0000000000 --- a/src/OpenSHC/UI/MenuItems/EnterTitleOnGameStart/MenuItemRenderFunction_EnterTitleOnGameStart_Button.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "../EnterTitleOnGameStart.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00491C50 - void EnterTitleOnGameStart::MenuItemRenderFunction_EnterTitleOnGameStart_Button(int param_1, ...) - { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 7; - if (!DAT_ButtonCurrentlyInteracting::instance) { - 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_BUBBLE_HELP_TEXT, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp b/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp deleted file mode 100644 index 078dbce4d5..0000000000 --- a/src/OpenSHC/UI/MenuItems/SendReceiveMap/MenuItemRenderFunction_SendReceiveMap_Main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "../SendReceiveMap.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004AC440 - void SendReceiveMap::MenuItemRenderFunction_SendReceiveMap_Main(int param_1, ...) - { - if (DAT_GameSynchronyState::instance.DAT_MapFileReceivingState != 0 && param_1 == 68) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 6; - if (DAT_ButtonCurrentlyInteracting::instance) { - 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_MULTIPLAYER_CONNECTION, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - } - 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_MULTIPLAYER_CONNECTION, param_1), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp b/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp deleted file mode 100644 index 8ab0964738..0000000000 --- a/src/OpenSHC/UI/MenuItems/TutorialBox/MenuItemRenderFunction_TutorialBox_Main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "../TutorialBox.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.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/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_00df5540.hpp" -#include "OpenSHC/Globals/DAT_00df5558.hpp" -#include "OpenSHC/Globals/DAT_00df555c.hpp" -#include "OpenSHC/Globals/DAT_00df5560.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BD0F0 - void TutorialBox::MenuItemRenderFunction_TutorialBox_Main(int param_1, ...) - { - // "Continue" - int buttonText = 1; - if (DAT_00df5540::instance != 0) { - return; - } - if (param_1 == 2) { - // "Exit" - buttonText = 2; - } else { - if (DAT_00df5560::instance == 0) { - return; - } - if (DAT_00df5558::instance < DAT_00df555c::instance - 1 - && DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 - && DAT_SoundSystemState::instance.soundActiveUnk_0x0) { - // "Skip" - buttonText = 5; - } - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - // >> 1 rather than / 2: the original shifts without the sign fix-up (sar at 0x004BD160) - int const textX = (DAT_ButtonW::instance >> 1) + DAT_ButtonX::instance; - int const textY = DAT_ButtonY::instance + 8; - if (DAT_ButtonCurrentlyInteracting::instance) { - 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_TUTORIAL_BUTTONS, buttonText), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - } - 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_TUTORIAL_BUTTONS, buttonText), - textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1ba75bf49e..3c28870ba4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23425,7 +23425,7 @@ SHC_3BB0A8C1_0x00491BF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00491C20 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00491C50 | 97.7% | cleanup; scheduling +SHC_3BB0A8C1_0x00491C50 | 0.0% | Pending SHC_3BB0A8C1_0x00491CE0 | 0.0% | Pending @@ -25785,7 +25785,7 @@ SHC_3BB0A8C1_0x004AC280 | 0.0% | Pending SHC_3BB0A8C1_0x004AC310 | 0.0% | Pending -SHC_3BB0A8C1_0x004AC440 | 97.3% | cleanup; scheduling +SHC_3BB0A8C1_0x004AC440 | 0.0% | Pending SHC_3BB0A8C1_0x004AC4C0 | 0.0% | Pending @@ -29289,11 +29289,11 @@ SHC_3BB0A8C1_0x004BB530 | 0.0% | Pending SHC_3BB0A8C1_0x004BB540 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB570 | 98.4% | cleanup; scheduling +SHC_3BB0A8C1_0x004BB570 | 0.0% | Pending SHC_3BB0A8C1_0x004BB650 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BB680 | 98.2% | cleanup; scheduling +SHC_3BB0A8C1_0x004BB680 | 0.0% | Pending SHC_3BB0A8C1_0x004BB740 | 0.0% | Pending @@ -30173,7 +30173,7 @@ SHC_3BB0A8C1_0x004BCBA0 | 0.0% | Pending SHC_3BB0A8C1_0x004BCEC0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BD0F0 | 97.9% | cleanup; scheduling +SHC_3BB0A8C1_0x004BD0F0 | 0.0% | Pending SHC_3BB0A8C1_0x004BD1B0 | 100.0% | Reimplemented From 636a731f378afdc939a695bfe307ea3b60c25170 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 16:04:44 +0100 Subject: [PATCH 57/64] drafts: move 0x00434120 InGameMenu_Scrolling to the 100% PR Declared with no parameters, the function calls RecordTutorialPlayerAction at the end the way the original does instead of tail-calling it, and reaches 100%. It moves to reimpl/UI-MenuItems-9-100 together with that header change. This draft drops it, and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...ItemActionHandler_InGameMenu_Scrolling.cpp | 83 ------------------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp deleted file mode 100644 index eff91451bd..0000000000 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_Scrolling.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "../InGameMenu.func.hpp" - -#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" -#include "OpenSHC/UI/DisplayElements.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/ScrollingHandler.func.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/UI/Enums/DisplayElementID.hpp" - -#include "OpenSHC/Globals/DAT_CurrentFramerate.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00434120 - void InGameMenu::MenuItemActionHandler_InGameMenu_Scrolling(int param_1, ...) - { - if (!MACRO_CALL(OpenSHC::UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( - OpenSHC::UI::Enums::DEID_DEBUG_NUMBERS)) { - // computes the debug numbers without drawing them - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::RenderDebugNumbersDisplayElement)(0, 0, -1000); - } - if (DAT_MouseState::instance.selectionBoxMode != 0) { - return; - } - if (DAT_MouseState::instance.rightClickState) { - return; - } - int scrollDistance = MACRO_CALL_MEMBER( - OpenSHC::UI::ScrollingHandler_Func::getScrollDistanceBaseUnk, DAT_ScrollingHandler::ptr)(); - if (scrollDistance == 0) { - return; - } - // below the game speed's frame rate the step grows, so the view keeps its speed - if (DAT_CurrentFramerate::instance < DAT_GameCore::instance.gameSpeedLevel - && DAT_CurrentFramerate::instance != 0) { - scrollDistance = DAT_GameCore::instance.gameSpeedLevel * scrollDistance - / ((DAT_GameCore::instance.gameSpeedLevel - DAT_CurrentFramerate::instance) / 2 - + DAT_CurrentFramerate::instance); - } - switch (DAT_ScrollingHandler::instance.scrollDirection_0x4) { - case OpenSHC::UI::SD_UP: - DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; - break; - case OpenSHC::UI::SD_UP_RIGHT: - DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; - // falls through to the step right - case OpenSHC::UI::SD_RIGHT: - DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; - break; - case OpenSHC::UI::SD_DOWN_RIGHT: - DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; - DAT_ViewportRenderState::instance.viewportState.viewportX += scrollDistance; - break; - case OpenSHC::UI::SD_DOWN: - DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; - break; - case OpenSHC::UI::SD_DOWN_LEFT: - DAT_ViewportRenderState::instance.viewportState.viewportY += scrollDistance; - DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; - break; - case OpenSHC::UI::SD_UP_LEFT: - DAT_ViewportRenderState::instance.viewportState.viewportY -= scrollDistance; - // falls through to the step left - case OpenSHC::UI::SD_LEFT: - DAT_ViewportRenderState::instance.viewportState.viewportX -= scrollDistance; - break; - } - MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::setViewportBasedOnMapSize, - DAT_ViewportRenderState::ptr)(); - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(1); - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 34c543c186..5786306b72 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11115,7 +11115,7 @@ SHC_3BB0A8C1_0x00433D00 | 0.0% | Pending SHC_3BB0A8C1_0x00433DA0 | 0.0% | Pending -SHC_3BB0A8C1_0x00434120 | 89.9% | cleanup; tail call +SHC_3BB0A8C1_0x00434120 | 0.0% | Pending SHC_3BB0A8C1_0x004341E1 | 0.0% | Pending From 8504e3aeb5747cd91f6391385da5d3c16bcd8f40 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 18:10:09 +0100 Subject: [PATCH 58/64] drafts: move 0x004C1070 and 0x004ABEB0 to the 100% PR TraderSettings (0x004C1070) and EditorMapTypeQuickChange_Main (0x004ABEB0) reached 100% and are in the ready PR from reimpl/batch16-100, so this draft drops their files and sets their status lines back to main's. Co-Authored-By: Claude Opus 5.5 --- ...nHandler_EditorMapTypeQuickChange_Main.cpp | 106 -------------- .../MenuItemRenderFunction_TraderSettings.cpp | 130 ------------------ status/addresses-SHC-3BB0A8C1.txt | 4 +- 3 files changed, 2 insertions(+), 238 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp b/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp deleted file mode 100644 index b746f3ed5e..0000000000 --- a/src/OpenSHC/UI/MenuItems/EditorMapTypeQuickChange/MenuItemActionHandler_EditorMapTypeQuickChange_Main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#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/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 param_1, ...) - { - switch (param_1) { - case 0: - case 1: - case 2: - DAT_GameCore::instance.U3_mapLockedState = param_1; - return; - case 3: - case 4: - case 5: - case 6: - // buttons 3 to 6 are the map types siege, invasion, economic and just build - if (!MACRO_CALL_MEMBER( - OpenSHC::Map::MapPropertiesState_Func::mapHasCertainEvent, DAT_MapPropertiesState::ptr)()) { - DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 = param_1 - 3; - } - return; - case 10: - 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)(); - int mapSize; - if (param_1 == 20) { - mapSize = 160; - } else if (param_1 == 21) { // the original compares the ids in turn, not a table - mapSize = 200; - } else if (param_1 == 22) { - mapSize = 300; - } else if (param_1 == 23) { - mapSize = 400; - } else { - mapSize = param_1; - } - 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/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp b/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp deleted file mode 100644 index bf5a703590..0000000000 --- a/src/OpenSHC/UI/MenuItems/TraderSettings/MenuItemRenderFunction_TraderSettings.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#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 param_1, ...) - { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (param_1 < 0) { - int const traderIndex = -1 - param_1; - DAT_ButtonCurrentlyInteracting::instance - = DAT_MapPropertiesState::instance.SEC_Section1065 - .tradeabilityArray[DAT_MissionAestheticsDefinedData::instance.field_0x345c[traderIndex]] - != 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[traderIndex]; - int icon = resource * 2 + 141; - if (icon == 157) { - icon = 155; - } - int const imhIndex = icon + GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2] - 1; - 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); - // "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), - DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - 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); - // "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), - DAT_ButtonW::instance - 10 + DAT_ButtonX::instance, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_7CAAAF, 18, FALSE, 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (param_1 < 1000) { - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (param_1 == 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, - 15974, 18, FALSE); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - 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, 0, 18, - FALSE); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - 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); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - 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 5786306b72..fb2ee63523 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 | 94.5% | one store for the map size; parameter reload +SHC_3BB0A8C1_0x004ABEB0 | 0.0% | Pending SHC_3BB0A8C1_0x004AC008 | 0.0% | Pending @@ -33187,7 +33187,7 @@ SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending -SHC_3BB0A8C1_0x004C1070 | 88.0% | cleanup; register allocation +SHC_3BB0A8C1_0x004C1070 | 0.0% | Pending SHC_3BB0A8C1_0x004C1320 | 0.0% | Pending From bddd6bea0c4bb0e85ec2a2faaf0ab2482e402679 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 00:48:15 +0100 Subject: [PATCH 59/64] style: scenario event types by their ScenarioEventType names gynt asked on sourcehold/OpenSHC#354 why the case labels do not use the enum names. In this draft the switched value has an enum on main in one place: MenuItemActionHandler_General_EventSlider's two switches on the current event's ScenarioEventType now name their 13 cases (SET_TRAVELING_FAIR, SET_PLAGUE ... SET_THEFT_FROM_GRANARY, SET_FIRE), and MenuItemActionHandler_NewEventAction_Main's test of the new type compares with SET_MESSAGE, SET_WIN_AND_MESSAGE and SET_LOSE_AND_MESSAGE. The other switches here are on button numbers, slider steps and fields with no enum (activeTacticalPower, unitControlsRelated, TextEditorState.field_0x23970), so they keep their numbers. The code is unchanged: quick_diff gives the same output for both files before and after. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...uItemActionHandler_General_EventSlider.cpp | 54 ++++++++++--------- ...uItemActionHandler_NewEventAction_Main.cpp | 5 +- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp index 8b9d7f4673..afba850ef5 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_EventSlider.cpp @@ -1,5 +1,7 @@ #include "../General.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" + #include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" namespace OpenSHC { @@ -60,19 +62,19 @@ namespace UI { case -1: switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] .data.scenario.ScenarioEventType) { - case 5: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 29: - case 30: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: switch (param_2) { case 1: *minValue = 0; @@ -115,19 +117,19 @@ namespace UI { case -2: switch (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] .data.scenario.ScenarioEventType) { - case 5: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 29: - case 30: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TRAVELING_FAIR: + case OpenSHC::Game::ScenarioEvents::Enums::SET_PLAGUE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_WHEAT_DISEASE: + case OpenSHC::Game::ScenarioEvents::Enums::SET_HOPS_WEEVIL: + case OpenSHC::Game::ScenarioEvents::Enums::SET_APPLE_BLIGHT: + case OpenSHC::Game::ScenarioEvents::Enums::SET_TREE_FUNGUS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_RABBIT_EXPLOSION: + case OpenSHC::Game::ScenarioEvents::Enums::SET_LION_ATTACK: + case OpenSHC::Game::ScenarioEvents::Enums::SET_BANDITS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_MAD_COWS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_ARCHERS: + case OpenSHC::Game::ScenarioEvents::Enums::SET_THEFT_FROM_GRANARY: + case OpenSHC::Game::ScenarioEvents::Enums::SET_FIRE: switch (param_2) { case 1: *minValue = 1; diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp index 1a6be89b9a..50855d01f7 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp @@ -2,6 +2,7 @@ #include "OpenSHC/UI/Helpers.func.hpp" #include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventType.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" #include "OpenSHC/Globals/DAT_ButtonX.hpp" @@ -81,7 +82,9 @@ namespace UI { int const newType = DAT_MapPropertiesState::instance .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] .data.scenario.ScenarioEventType; - if (newType == 2 || newType == 26 || newType == 27) { + if (newType == OpenSHC::Game::ScenarioEvents::Enums::SET_MESSAGE + || newType == OpenSHC::Game::ScenarioEvents::Enums::SET_WIN_AND_MESSAGE + || newType == OpenSHC::Game::ScenarioEvents::Enums::SET_LOSE_AND_MESSAGE) { DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] .data.scenario.actionData = -1; } From 644c9ab9b9d78e5c1fe47e3b78e8759414324e06 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 00:58:28 +0100 Subject: [PATCH 60/64] fix: pass the slider callback as main's NoArgCallback* Main's 3a1c7f771 (merged in 0b412b26c) types setSliderParameters' last parameter NoArgCallback*, so the (void*) cast on CaptureCurrentTimeToUnknownTime01 no longer compiles; the callback is passed as MACRO_CALL(...) as main's EditScenario calls do. Same instructions. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_NewEventAction_Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp index 50855d01f7..864a4e45cf 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemActionHandler_NewEventAction_Main.cpp @@ -120,7 +120,7 @@ namespace UI { (undefined*)&DAT_MapPropertiesState::instance .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] .data, - (void*)MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); + MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); DAT_MapPropertiesState::instance.sliderPopupDelay = 2; DAT_MapPropertiesState::instance.sliderPopupX = DAT_ButtonX::instance + 58; DAT_MapPropertiesState::instance.sliderPopupY = DAT_ButtonY::instance + 28; From fba4a225abb74e7512aeeb8a35419ccc11a45651 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:06:17 +0100 Subject: [PATCH 61/64] drafts: move 0x004BBA60 General_CreateEventCallbackFunction to the round 11 PR With the bandits text's position read into y-then-x locals inside each colour path, the function reaches 100.0% (96.8% here), so it moves to the round 11 PR (reimpl/UI-B-round11-100, 69a3ba260). This draft drops it, and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...on_General_CreateEventCallbackFunction.cpp | 135 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp deleted file mode 100644 index 83b55d813c..0000000000 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_CreateEventCallbackFunction.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "../General.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/TextureRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eGM.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/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.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_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BBA60 - void General::MenuItemRenderFunction_General_CreateEventCallbackFunction(int param_1, ...) - { - int option = -1; - int iconOffset = 2; - switch (param_1) { - case 91: - case 221: - option = 0; - break; - case 92: - case 222: - option = 1; - break; - case 93: - option = iconOffset; - break; - case 94: - option = 3; - break; - case 95: - option = 4; - break; - case 96: - option = 5; - break; - case 97: - option = 6; - break; - case 98: - option = 7; - break; - case 99: - option = 8; - break; - case 157: - option = 9; - break; - case 158: - option = 10; - break; - case 159: - option = 11; - break; - case 160: - option = 12; - break; - case 161: - option = 13; - break; - case 162: - option = 14; - break; - } - switch (param_1) { - case 221: - case 222: - if (DAT_MapPropertiesState::instance.invasionEventContent.crusaderArabian == option) { - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, - DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, - 18, FALSE); - return; - } - break; - case 148: - // drawn as the bandits button with the other icon - param_1 = 146; - iconOffset = 0; - case 146: { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - // "Bandits" - if (!DAT_ButtonCurrentlyInteracting::instance) { - 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, param_1), - DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } else { - 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, param_1), - DAT_ButtonW::instance / 2 - 15 + DAT_ButtonX::instance, DAT_ButtonY::instance + 6, - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - int const nameWidth = DAT_TextManagerObject::instance.currentXOffset_0x0; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // " - " - s___005a2304, nameWidth / 2 - 15 + DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, - DAT_ButtonY::instance + 6, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, - FALSE, 0); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iconOffset + 128, - DAT_ButtonW::instance / 2 - 9 + (DAT_TextManagerObject::instance.currentXOffset_0x0 + nameWidth) / 2 - + DAT_ButtonX::instance, - DAT_ButtonY::instance + 3); - return; - } - } - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8fe8d604fe..6437ac759f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29321,7 +29321,7 @@ SHC_3BB0A8C1_0x004BBA20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BBA30 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBA60 | 96.8% | 1 behaviour fix; register allocation +SHC_3BB0A8C1_0x004BBA60 | 0.0% | Pending SHC_3BB0A8C1_0x004BBC64 | 0.0% | Pending From 2da7d39ebab78f124f9505f5682585bd8e9558fa Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 13:16:46 +0100 Subject: [PATCH 62/64] drafts: move 0x004255D0 to the round 13 PR HistoricCampaignSelect's render (0x004255D0) goes from 98.7% here to 100.0% in the round 13 PR (reimpl/UI-B-round13-100, b607ec8bf): the campaign name is drawn by two identical calls, one per hover state, which gives the original's load order for the text call. This draft drops its .cpp file, and its status line goes back to main's. Main doesn't have the function, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 --- ...erFunction_HistoricCampaignSelect_Main.cpp | 87 ------------------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp b/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp deleted file mode 100644 index d2b3c1eaa0..0000000000 --- a/src/OpenSHC/UI/MenuItems/HistoricCampaignSelect/MenuItemRenderFunction_HistoricCampaignSelect_Main.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "../HistoricCampaignSelect.func.hpp" - -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/IO/Graphics/GmID.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" - -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/DAT_UnknownGFXIndex.hpp" -#include "OpenSHC/Globals/INT_00b95abc.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004255D0 - void HistoricCampaignSelect::MenuItemRenderFunction_HistoricCampaignSelect_Main(int param_1, ...) - { - if (DAT_UnknownGFXIndex::instance == 1) { - return; - } - if (param_1 != 5 && !DAT_ButtonCurrentlyInteracting::instance) { - if (param_1 == INT_00b95abc::instance) { - INT_00b95abc::instance = -1; - } - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && param_1 < 5) { - DAT_CurrentButtonGmDataIndex::instance = 353; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } else { - if (DAT_TextureRenderCoreObject::instance.unknownSfxAndGmRelatedFlag && param_1 < 5) { - DAT_CurrentButtonGmDataIndex::instance = 353; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4; - if (param_1 >= 5) { - return; - } - if (INT_00b95abc::instance != param_1) { - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_UNKNOWN_0x92); - } - INT_00b95abc::instance = param_1; - } - if (param_1 >= 5) { - return; - } - // the campaign's name: "Heads on Spikes", "The Call to Arms", "Saladin's Conquest", "The Kings Crusade" or - // "Crusader States" - int const textY = DAT_ButtonY::instance + 15; - int const textX = DAT_ButtonX::instance + 30; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_BUBBLE_HELP_TEXT, param_1 + 309), - textX, textY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 16, FALSE, 0); - if (!DAT_ButtonCurrentlyInteracting::instance) { - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 1, - DAT_ButtonX::instance - 85, DAT_ButtonY::instance - 28, OpenSHC::IO::Graphics::GID_ICONS_FRONT_END, 2, - 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6437ac759f..bdb77ebd5a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6711,7 +6711,7 @@ SHC_3BB0A8C1_0x00425500 | 0.0% | Pending SHC_3BB0A8C1_0x00425580 | 0.0% | Pending -SHC_3BB0A8C1_0x004255D0 | 98.7% | cleanup; scheduling +SHC_3BB0A8C1_0x004255D0 | 0.0% | Pending SHC_3BB0A8C1_0x00425720 | 0.0% | Pending From 823367891cb5a23138b34a06080e1da12bc435a2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:25:26 +0100 Subject: [PATCH 63/64] fix: UnitSelectionAndControlsUnk builds against main's Building::targetMarker Main's Ghidra sync (1b36c0ad7) named Building's field at 0xC2 targetMarker, a BuildingTargetMarkerShort. The draft stored 2 into field_0xc2, which is BTM_ENGINEER_TARGET; it now says so. quick_diff 0.5332 on main e086ba7c3 (the draft did not compile there before). Co-Authored-By: Claude Opus 5.5 --- ...temActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp index 8c9e697fde..e0546ccd1f 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_UnitSelectionAndControlsUnk.cpp @@ -974,7 +974,8 @@ namespace UI { || ((BVar5 == Map::Buildings::BT_SIEGETOWER || (BVar5 == Map::Buildings::BT_SHIELD)))) || (BVar5 == Map::Buildings::BT_OILSMELTER))))) { - DAT_BuildingsState::instance.buildings[_shooterID].field_0xc2 = 2; + DAT_BuildingsState::instance.buildings[_shooterID].targetMarker + = OpenSHC::Map::Buildings::Enums::BTM_ENGINEER_TARGET; DAT_TileMapState::instance.pendingUnitCommand = 2; DAT_TileMapState::instance.cursorOverlayImageBase = -2; local_20 = -1; From 020b8de2ed1d86e9b2c05521d0b0c155132f92ee Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:25:27 +0100 Subject: [PATCH 64/64] style: TextEditor Buttons render uses the s_ string pointers The 33 TextEditor keyword and button strings are the s_ pointers from string-literals.hpp instead of the S_ macros, cast to char* for renderText's parameter as elsewhere on main. quick_diff gives the same instructions as before (0.9743). Co-Authored-By: Claude Opus 5.5 --- ...uItemRenderFunction_TextEditor_Buttons.cpp | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp index dfcc721006..1d2d844430 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemRenderFunction_TextEditor_Buttons.cpp @@ -8,7 +8,7 @@ #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/string-macros.hpp" +#include "OpenSHC/string-literals.hpp" #include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" #include "OpenSHC/Globals/COL_BLACK.hpp" @@ -128,97 +128,97 @@ namespace UI { case 1: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Symbols" - S_SYMBOLS_005A5608, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Symbols_005a5608, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 2: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "New Page" - S_NEW_PAGE_005A55FC, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_New_Page_005a55fc, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 3: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Load" - S_LOAD_005A55F4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Load_005a55f4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 4: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Save" - S_SAVE_005A55EC, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Save_005a55ec, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 20: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "ScrSize" - S_SCRSIZE_005A55E4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_ScrSize_005a55e4, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 5: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Pic" - S_PIC_005A55E0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Pic_005a55e0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 6: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Link" - S_LINK_005A55D8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Link_005a55d8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 7: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "\\Link" - S__LINK_005A55D0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s__Link_005a55d0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 8: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Font" - S_FONT_005A55C8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Font_005a55c8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 9: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Centre" - S_CENTRE_005A55C0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Centre_005a55c0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 10: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "\\Centre" - S__CENTRE_005A55B8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s__Centre_005a55b8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 11: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Colour" - S_COLOUR_005A55B0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Colour_005a55b0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 12: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "LinkClr" - S_LINKCLR_005A55A8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_LinkClr_005a55a8, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 13: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Sound" - S_SOUND_005A55A0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Sound_005a55a0, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 14: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "String" - S_STRING_005A5598, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_String_005a5598, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; case 15: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "Include" - S_INCLUDE_005A5590, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_Include_005a5590, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); return; } @@ -232,67 +232,67 @@ namespace UI { case 1: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "PIC" - S_PIC_005A558C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); + (char*)s_PIC_005a558c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 2: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "FONT" - S_FONT_005A5584, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); + (char*)s_FONT_005a5584, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 3: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "COLOUR" - S_COLOUR_005A557C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_COLOUR_005a557c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 10: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "LINKCLR" - S_LINKCLR_005A5574, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_LINKCLR_005a5574, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 4: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "LINK" - S_LINK_005A556C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); + (char*)s_LINK_005a556c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 5: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "\\LINK" - S__LINK_005A5564, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); + (char*)s__LINK_005a5564, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 7: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "CENTRE" - S_CENTRE_005A555C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_CENTRE_005a555c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 8: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "\\CENTRE" - S__CENTRE_005A5554, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s__CENTRE_005a5554, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 11: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "SOUND" - S_SOUND_005A554C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); + (char*)s_SOUND_005a554c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 12: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "STRING" - S_STRING_005A5544, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_STRING_005a5544, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); return; case 14: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "INCLUDE" - S_INCLUDE_005A553C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_INCLUDE_005a553c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_FFFFFF, 19, FALSE, 0); } break; @@ -405,8 +405,8 @@ namespace UI { : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Left" - S_LEFT_005A5534, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + (char*)s_Left_005a5534, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); return; case 2: case 3: @@ -425,7 +425,7 @@ namespace UI { DAT_PencilRenderCore::instance.otherColorUnk_0x0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "PREV" - S_PREV_005A552C, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_PREV_005a552c, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); } break; @@ -444,7 +444,7 @@ namespace UI { : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Centre" - S_CENTRE_005A55C0, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + (char*)s_Centre_005a55c0, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); return; case 2: @@ -464,7 +464,7 @@ namespace UI { DAT_PencilRenderCore::instance.otherColorUnk_0x0); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen2, DAT_TextManagerObject::ptr)( // "NEXT" - S_NEXT_005A5524, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, + (char*)s_NEXT_005a5524, DAT_ButtonX::instance, DAT_ButtonY::instance + 3, (TextAlignment)DAT_ButtonW::instance, DAT_TextManagerObject::instance.textColor, 19, FALSE); } break; @@ -482,8 +482,8 @@ namespace UI { : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Right" - S_RIGHT_005A551C, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + (char*)s_Right_005a551c, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); } break; case 36: @@ -500,8 +500,8 @@ namespace UI { : OpenSHC::Rendering::Colors::COL_FFFFFF); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // "Here" - S_HERE_005A5514, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, OpenSHC::Text::TTA_LEFT, - DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); + (char*)s_Here_005a5514, DAT_ButtonX::instance + 3, DAT_ButtonY::instance + 3, + OpenSHC::Text::TTA_LEFT, DAT_TextManagerObject::instance.textColor, 19, FALSE, 0); } break; }