From 4196eb049f5e9af73fda8be45706319d55d5265d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:00 +0100 Subject: [PATCH 01/85] 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 09a646e2812dd90287b3d1331d2f0055a0afe00b Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 12:18:13 +0100 Subject: [PATCH 02/85] 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 530c671e7c5a6b8261518ad4bda0ab10bf4b4f33 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:38 +0100 Subject: [PATCH 03/85] reimplement: SHC_3BB0A8C1_0x00428AC0 42.5% gynt's draft, mechanical pass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...erFunction_General_AdvancedGameOptions.cpp | 411 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 412 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp new file mode 100644 index 0000000000..20f9c2e99a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp @@ -0,0 +1,411 @@ +#include "../General.func.hpp" + +#include "OpenSHC/Text/TextManager.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/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.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_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // The 23 `((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 0x20` below are each a signed + // `iVar1 / 32`, and undiv.py rewrites them, but measured: raw match 40.4% -> 24.6%. The + // opcodes are unchanged - the division frees a register, MSVC then picks ebx where the + // original uses edi, and every instruction after it is renamed. Normalized match rises + // 41.1% -> 48.1%, so the division is arguably the closer stream; it is kept in the shift + // form only because the raw percentage is the gate. Retry together with whatever fixes + // this function's register allocation. + // FUNCTION: STRONGHOLDCRUSADER 0x00428AC0 + void General::MenuItemRenderFunction_General_AdvancedGameOptions(int param_1, ...) + { + int iVar1; + uint _color; + int iVar2; + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_LOAD_MAP + || DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_SEND_MAP_TO + || DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_RECEIVE_MAP_FROM) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_SKIRMISH_PLAY_OPTIONS) { + if (param_1 != -1000 && param_1 != -10 && param_1 != -11 && param_1 != -12 && param_1 != -13 + && param_1 != -14 && param_1 != 99 && param_1 != 100 && param_1 != 83 && param_1 != 109 + && param_1 != 82 && param_1 != 94) { + return; + } + } else { + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + return; + } + } + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (param_1 == 93) { + return; + } + if (param_1 == 31) { + return; + } + } + if ((param_1 == 103) + && (DAT_ButtonUnknownZero::instance = 0, + DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (!DAT_GameSynchronyState::instance.isHost) { + if (param_1 == 103) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (param_1 == 93) { + return; + } + } + if (param_1 == -1) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (param_1 != 103) { + if ((!DAT_ButtonCurrentlyInteracting::instance) || (!DAT_GameSynchronyState::instance.isHost)) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderNonInteractingButtonBackground, + AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance); + _color = 12775659; + } else { + _color = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + } + } + if (param_1 == 31) { + iVar2 = DAT_GameSynchronyState::instance.skirmishTechLevel / 2; + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Tech Level" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 85, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Early" "Middle" "Late" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar2 + 79, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 36) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Win: Regicide" / "Win: 10000 Gold" / "Win: 3" / "Win: 4" / "Win: 5" / .... + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.skirmishWinCondition + 36), + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 83) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 86, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + iVar1 = 83; + // "Free" + if (DAT_GameSynchronyState::instance.skirmishTroopsCostGold != 0) { + // "Cost Gold" + iVar1 = 84; + } + iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 109) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // Fog of War + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 109, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + if (DAT_GameState::instance.mapAndTime.skirmishFogOfWar == 0) { + // OFF + iVar1 = 95; + } else { + // Please Wait + iVar1 = (DAT_GameState::instance.mapAndTime.skirmishFogOfWar != 1) + 109; + } + iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); + return; + } + if (param_1 == -1000) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, 17, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 103) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; + if (param_1 == -10) { + // No Cow Throwing + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 5, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishNoCowThrowing; + LAB_00428ffd: + if (iVar1 != 0) { + iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; + iVar2 = 206; + goto LAB_00429039; + } + } else { + if (param_1 == -11) { + // "No Dogs" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 6, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishNoDogs; + LAB_00429086: + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (iVar1 == 0) { + iVar1 = 208; + } else { + iVar1 = 206; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, + (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (param_1 == -13) { + // "Extreme mode" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 13, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_GameSynchronyState::instance.skirmishExtremeMode == 0) { + iVar1 = 208; + } else { + iVar1 = 206; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, + (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if (param_1 != -14) { + if (param_1 != 99) { + if (param_1 == -12) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 7, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 0) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 1) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 2) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 3) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 4) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 8, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishNoRushSetting != 5) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "1 Hour" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 9, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + if (param_1 == 14) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishStartGold, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 15) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishDefaultPopularity, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 82) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishGameSpeedLevel, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 == 94) { + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 0) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 5) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 10) { + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes != 20) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); + } + if (param_1 != 100) { + return; + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; + // "Alliances" + if (DAT_GameSynchronyState::instance.skirmishAlliances == 0) { + // "Anytime" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 101, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + iVar1); + } + // "Start only" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 102, + (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, iVar1); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 99, + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishStrongWalls; + goto LAB_00429086; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 14, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); + iVar1 = DAT_GameSynchronyState::instance.skirmishExtremeMode; + if (DAT_GameSynchronyState::instance.skirmishExtremeMode2 != 0) + goto LAB_00428ffd; + } + iVar2 = 208; + iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; + LAB_00429039: + 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_ICONS3, iVar2, iVar1, (int)(DAT_ButtonY::instance)); + 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 45a88e2504..e85b2aa5f5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6889,7 +6889,7 @@ SHC_3BB0A8C1_0x00428A50 | 0.0% | Pending SHC_3BB0A8C1_0x00428A60 | 0.0% | Pending -SHC_3BB0A8C1_0x00428AC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00428AC0 | 42.5% | gynt's draft, mechanical pass; register allocation and structure SHC_3BB0A8C1_0x00429630 | 100.0% | Reimplemented From 89a680f85d6b94101b4d519a8af8078d98fef552 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:38 +0100 Subject: [PATCH 04/85] reimplement: SHC_3BB0A8C1_0x004AC7A0 52.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_Allies_Main.cpp | 438 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp new file mode 100644 index 0000000000..24753b39eb --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp @@ -0,0 +1,438 @@ +#include "../Allies.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.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/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_00df42b0.hpp" +#include "OpenSHC/Globals/DAT_00df51f0.hpp" +#include "OpenSHC/Globals/DAT_00df51f4.hpp" +#include "OpenSHC/Globals/DAT_AlliesCount.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AC7A0 + void Allies::MenuItemRenderFunction_Allies_Main(int param_1, ...) + { + BOOLEnum BVar1; + int iVar4; + int iVar5; + int iVar6; + int iVar7; + eTextSections textOffsetIndex; + int xParam; + int iVar2; + int iVar3; + if (param_1 == 100) { + return; + } + if ((int)DAT_AlliesCount::instance < 1 && param_1 != -1) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + if ((param_1 == 110) || (param_1 == 111)) { + if (((DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestStateUnk + != 1) + || ((iVar3 = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk, + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1 + || (iVar3 + != DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance])))) + && DAT_GameState::instance + .playerDataArray + [DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]] + .isNotNervousByEnemyTroopValue + == 0) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); + } + if (param_1 == 200) { + if (DAT_00df51f4::instance == 0) { + return; + } + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, DAT_00df51f0::instance, (int)(DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, + 18, FALSE); + DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + } + DAT_ButtonUnknownZero::instance = 0; + if (19 < (uint)param_1) { + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (!DAT_ButtonCurrentlyInteracting::instance) { + return; + } + if (param_1 == 20) { + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 5; + } + if (param_1 == 21) { + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 6; + } + if (param_1 != 22) { + return; + } + DAT_00df51f4::instance = 1; + DAT_00df51f0::instance = 7; + } + if (6 >= param_1) { + if (param_1 == 1) { + DAT_00df51f4::instance = 0; + } + iVar3 = param_1 - 1; + if ((int)DAT_AlliesCount::instance <= iVar3) { + DAT_ButtonUnknownZero::instance = 0; + } + iVar6 = 0; + iVar2 = DAT_SomeTeamMemberPlayerIDArray::instance[iVar3]; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar2] == -1) { + iVar6 = DAT_GameSynchronyState::instance.currentAIArray[iVar2]; + } + if (iVar3 == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar2 + 546, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + if (iVar6 == 0) { + if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 539, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } else if (DAT_GameCore::instance.lordIcons[iVar2] == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 540, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace, + DAT_TextureRenderCoreObject::ptr)( + iVar2 + 19, (int)(DAT_ButtonX::instance + 4), (int)(DAT_ButtonY::instance + 4)); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar6 + 522, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + } + } else { + if (iVar6 == 0) { + if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { + iVar6 = 539; + } else { + if (DAT_GameCore::instance.lordIcons[iVar2] != 1) { + if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + 541, (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk, + DAT_TextureRenderCoreObject::ptr)(iVar2 + 19, (int)(DAT_ButtonX::instance + 4), + (int)(DAT_ButtonY::instance + 4), 12); + } + goto LAB_004aca47; + } + iVar6 = 540; + } + } else { + iVar6 += 522; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar6, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); + return; + } + LAB_004aca47: + if (iVar3 == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 514, + (int)(DAT_ButtonX::instance - 6), (int)(DAT_ButtonY::instance - 6), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 513, 0); + return; + } + iVar6 = 0; + if (iVar3 != DAT_LastTeamMemberIndex::instance) { + iVar6 = 8; + } + iVar3 + = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[iVar2]; + if (iVar3 == 7) { + iVar3 = 8; + } + if (-1 < iVar3 - 2) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 578, + (int)(DAT_ButtonX::instance + 60), (int)(DAT_ButtonY::instance - 12), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].isNotNervousByEnemyTroopValue != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + DAT_00df42b0::instance + 578, (int)(DAT_ButtonX::instance + 60), + (int)(DAT_ButtonY::instance + 60), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 576, + (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 577, iVar6); + } + if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 2) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 604, + (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 605, iVar6); + } + return; + } + if (param_1 != 10) { + DAT_ButtonUnknownZero::instance = 0; + } + iVar3 = DAT_ButtonX::instance; + iVar2 = DAT_ButtonY::instance; + iVar6 = 0; + if (0 < (int)DAT_ButtonH::instance) { + do { + if (iVar6 == 0) { + iVar5 = 1; + } else { + if (iVar6 == DAT_ButtonH::instance - 24) { + iVar5 = 13; + } else { + iVar5 = 7; + } + } + iVar7 = 0; + do { + iVar4 = iVar5; + if (iVar7 == 0) { + LAB_004acbeb: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4, + iVar7 + iVar3, iVar2 + iVar6, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4 + 3, + 0); + } else { + if (iVar7 == 624) { + iVar4 = iVar5 + 2; + goto LAB_004acbeb; + return; + } + if (iVar5 != 7) { + iVar4 = iVar5 + 1; + goto LAB_004acbeb; + } + } + iVar7 += 24; + } while (iVar7 < 648); + iVar6 += 24; + } while (iVar6 < (int)DAT_ButtonH::instance); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(iVar3 + 24, iVar2 + 24, iVar3 + 623, DAT_ButtonH::instance - 25 + iVar2, 20); + iVar3 = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + iVar2 = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3]; + if ((iVar2 == -1) + && (BVar1 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3), + !BVar1)) { + return; + } + iVar7 = DAT_ButtonY::instance; + iVar5 = DAT_ButtonX::instance; + iVar6 = DAT_ButtonX::instance + 24; + if (iVar2 == -1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 103 + + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 8), + iVar6, (int)(DAT_ButtonY::instance + 24), OpenSHC::Text::TTA_LEFT, + (uint)(DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), + 0, 17, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], iVar6, (int)(DAT_ButtonY::instance + 24), + OpenSHC::Text::TTA_LEFT, + (uint)(DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), + 0, 17, FALSE); + } + iVar2 = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[iVar3]; + if (iVar2 == 7) { + iVar2 = 8; + } + iVar4 = iVar7 + 56; + int bVar8 = -1 < iVar2 - 2; + if (bVar8) { + // added by script: "Requests" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 12, iVar6, iVar4, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderLeftAlignedNumberToScreen, DAT_TextManagerObject::ptr)( + (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray2Unk[iVar3], + iVar5 + 29, iVar4, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, 1); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar2 + 578, + DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6, iVar7 + 48, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, 0); + xParam = iVar5 + 69; + textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; + } else { + iVar2 = 1; + xParam = iVar6; + textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(textOffsetIndex, + iVar2, xParam, iVar4, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, + (BOOLEnum)bVar8); + iVar2 = iVar7 + 88; + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 0) { + // added by script: "No Orders" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 2, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } else { + // added by script: "Orders:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 16, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 1) { + // added by script: "Attack" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } + if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 2) { + // added by script: "Defend" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 17, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else { + iVar4 = DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk; + if (iVar4 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // added by script: "You" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 18, iVar5 + 34, iVar2, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else { + iVar2 = iVar7 + 76; + iVar5 = DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar4] == -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + (int)(DAT_GameSynchronyState::instance.currentAIArray + [DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk] + + 700), + iVar5, iVar2); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk + 19, iVar5 + 2, + iVar7 + 78); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)( + iVar5, iVar2, iVar5 + 35, iVar7 + 111, (ushort)(COL_BLACK::instance.shortValue)); + } + } + } + } + if (DAT_GameState::instance.playerDataArray[iVar3].isNotNervousByEnemyTroopValue != 0) { + // added by script: "Help Needed!" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 4, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + iVar2 = DAT_GameSynchronyState::instance.currentPlayerSlotID; + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestStateUnk + != 1) { + return; + } + iVar5 = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar5] == -1) { + return; + } + if (iVar5 != iVar3) { + return; + } + // added by script: "Attack" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + iVar6 += DAT_TextManagerObject::instance.currentXOffset_0x0 + 10; + iVar3 = DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk; + iVar5 = iVar7 + 115; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk + 19, iVar6 + 2, + iVar7 + 117); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + iVar6, iVar5, iVar6 + 35, iVar7 + 150, (ushort)(COL_BLACK::instance.shortValue)); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + (int)(DAT_GameSynchronyState::instance + .currentAIArray[DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk] + + 700), + iVar6, iVar5); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e85b2aa5f5..cb2e456fe8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25795,7 +25795,7 @@ SHC_3BB0A8C1_0x004AC650 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC6E0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AC7A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004AC7A0 | 52.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004AD110 | 0.0% | Pending From 3f2ac05c330f8341555deb587ee8cab655bc1339 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:39 +0100 Subject: [PATCH 05/85] reimplement: SHC_3BB0A8C1_0x00443A30 23.5% gynt's draft, mechanical pass; register allocation and structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...EditorLandscaping_QueueCommandCallback.cpp | 444 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 445 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp new file mode 100644 index 0000000000..e0a0988a86 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp @@ -0,0 +1,444 @@ +#include "../MapEditorLandscaping.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.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/Commands/MappersEnumInt.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b9844c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Commands::GameCommandType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00443A30 + void MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback() + { + BOOLEnum BVar3; + bool bVar4; + GameCommandType commandType; + if (DAT_MouseState::instance.mouseBasedEvent == 1) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); + LAB_00443aed: + INT_00b9844c::instance = 1; + } else { + if (((DAT_MouseState::instance.rightClickState) && (DAT_MouseState::instance.mouseBasedEvent != 2)) + || (DAT_ModifierKeyState::instance.ctrl != 0 && (DAT_ModifierKeyState::instance.downArrow != 0)) + || DAT_ModifierKeyState::instance.v != 0) { + if (DAT_MouseState::instance.mouseBasedEvent == 3) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( + DAT_MouseState::instance.mapOrientationCopy3); + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, + DAT_ViewportRenderState::ptr)( + (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { + if (DAT_MouseState::instance.mouseBasedEvent != 5) + goto LAB_00443af3; + DAT_MouseState::instance.field_0x19c = 2; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); + return; + } + goto LAB_00443aed; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); + } + LAB_00443af3: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, + (dword)((int)(2300 < (int)DAT_UnitsState::instance.unitCount))); + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::HandleWallTerrainMouseDrag)(); + } + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + } + if (DAT_MouseState::instance.rightClickStop != 0) { + if (INT_00b9844c::instance == 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + return; + } + INT_00b9844c::instance = 0; + } + if (!DAT_MouseState::instance.leftClickState) { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseTile); + 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 (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_NULL) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderPreviewMapperWithBrush, + DAT_TileMapState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), + DAT_TileMapState::instance.currentMapperCommand); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderWallPlacementPreview, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), + (short)(DAT_TileMapState::instance.rockFlagStartNumber + + DAT_TileMapState::instance.unknownBrushRelated * 4)); + } + if ((DAT_MouseState::instance.leftClickStart == 0) + && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseTile)) { + return; + } + DAT_ViewportRenderState::instance.viewportState.previousMouseTile + = DAT_ViewportRenderState::instance.viewportState.mouseTile; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + int iVar2 = DAT_ViewportRenderState::instance.viewportState.mouseTileY; + int _clickedX = DAT_ViewportRenderState::instance.viewportState.mouseTileX; + int iVar1 = DAT_TileMapState::instance.editorSnapToMode; + int _orientation = DAT_TileMapState::instance.mapOrientation; + if (DAT_MouseState::instance.leftClickStart != 0) { + DAT_TileMapState::instance.DAT_ClickedTileX + = DAT_ViewportRenderState::instance.viewportState.mouseTileX; + DAT_TileMapState::instance.DAT_ClickedTileY + = DAT_ViewportRenderState::instance.viewportState.mouseTileY; + BVar3 = MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::xyAreValid, + DAT_ViewportRenderState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, + (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY)); + if ((BVar3) + && (DAT_TileMapState::instance.editorAffectType = 0, + (DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.translationMatrix[iVar2].addXgetTile + + _clickedX] + & 0x41) + != 0)) { + DAT_TileMapState::instance.editorAffectType = 1; + } + } + int _clickedY = DAT_TileMapState::instance.DAT_ClickedTileY; + if ((_orientation == 0) || (_orientation == 4)) { + if (iVar1 != 1) { + bVar4 = iVar1 == 2; + goto LAB_00443cb1; + } + } else if (iVar1 != 2) { + bVar4 = iVar1 == 1; + LAB_00443cb1: + _clickedY = iVar2; + if (bVar4) { + _clickedX = DAT_TileMapState::instance.DAT_ClickedTileX; + } + } + if (340 < (int)DAT_TileMapState::instance.currentMapperCommand) { + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_SCRUBGRASS) { + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = -128; + goto LAB_00444270; + } + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_DUNES) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + } + switch (DAT_TileMapState::instance.currentMapperCommand) { + case OpenSHC::Commands::M_MAPPER_DELETE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNIT_ERASE); + return; + case OpenSHC::Commands::M_MAPPER_RAISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_RAISE_LAND); + return; + case OpenSHC::Commands::M_MAPPER_MOUNTAIN: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LAND; + commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; + break; + case OpenSHC::Commands::M_MAPPER_HILL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LOWER; + commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; + break; + case OpenSHC::Commands::M_MAPPER_LOWER: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -1; + commandType = OpenSHC::Commands::GCT_RAISE_LAND; + goto LAB_0044427c; + case OpenSHC::Commands::M_MAPPER_LAND: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_LAND); + return; + case OpenSHC::Commands::M_MAPPER_SEA: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_BEACH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; + goto LAB_00444270; + case OpenSHC::Commands::M_MAPPER_EQUALISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_EQUALIZE); + return; + case OpenSHC::Commands::M_MAPPER_PLAIN1: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 4; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CREATE_PLATEAU); + return; + case OpenSHC::Commands::M_MAPPER_PLAIN2: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 8; + commandType = OpenSHC::Commands::GCT_CREATE_PLATEAU; + goto LAB_0044427c; + case OpenSHC::Commands::M_MAPPER_MIN: + case OpenSHC::Commands::M_MAPPER_MAX: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.mapperMax; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_MIN_MAX); + return; + case OpenSHC::Commands::M_MAPPER_BIGROCK1: + case OpenSHC::Commands::M_MAPPER_BIGROCK2: + case OpenSHC::Commands::M_MAPPER_BIGROCK3: + case OpenSHC::Commands::M_MAPPER_BIGROCK4: + case OpenSHC::Commands::M_MAPPER_BIGROCK5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.rockFlagStartNumber + + DAT_TileMapState::instance.unknownBrushRelated * 4; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 20; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk); + ++DAT_TileMapState::instance.rockFlagStartNumber; + if (4 <= (int)DAT_TileMapState::instance.rockFlagStartNumber) { + DAT_TileMapState::instance.rockFlagStartNumber = 0; + } + return; + case OpenSHC::Commands::M_MAPPER_ROCKY: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 128; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_STONES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_RIVER: + case OpenSHC::Commands::M_MAPPER_FOAM: + case OpenSHC::Commands::M_MAPPER_RIPPLE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1048576; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_FOAM) { + if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_AREA; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_FORD: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 2097152; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_BOULDERS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 131072; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_PEBBLES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 262144; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_IRON: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 524288; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_OIL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -2147483648; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_MARSH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 536870912; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_DUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; + LAB_0044427a: + commandType = OpenSHC::Commands::GCT_SET_TERRAIN; + LAB_0044427c: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + break; + case OpenSHC::Commands::M_MAPPER_UNDUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 3; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_DIRT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_GRASS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; + LAB_00444270: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + goto LAB_0044427a; + case OpenSHC::Commands::M_MAPPER_SCRUB: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + return; + case OpenSHC::Commands::M_MAPPER_CHESTNUT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_CHESTNUT; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_OAK: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_OAK; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_SHRUB1A: + case OpenSHC::Commands::M_MAPPER_SHRUB1B: + case OpenSHC::Commands::M_MAPPER_SHRUB1C: + case OpenSHC::Commands::M_MAPPER_SHRUB1D: + case OpenSHC::Commands::M_MAPPER_SHRUB1E: + case OpenSHC::Commands::M_MAPPER_SHRUB2A: + case OpenSHC::Commands::M_MAPPER_SHRUB2B: + case OpenSHC::Commands::M_MAPPER_SHRUB2C: + case OpenSHC::Commands::M_MAPPER_SHRUB2D: + case OpenSHC::Commands::M_MAPPER_SHRUB2E: + case OpenSHC::Commands::M_MAPPER_SHRUB3A: + case OpenSHC::Commands::M_MAPPER_SHRUB3B: + case OpenSHC::Commands::M_MAPPER_SHRUB3C: + case OpenSHC::Commands::M_MAPPER_SHRUB3D: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_TileMapState::instance.currentMapperCommand; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_PINE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_PINE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_BIRCH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_BIRCH; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; + commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; + break; + case OpenSHC::Commands::M_MAPPER_DEER: + case OpenSHC::Commands::M_MAPPER_LION: + case OpenSHC::Commands::M_MAPPER_RABBIT: + case OpenSHC::Commands::M_MAPPER_CAMEL: + case OpenSHC::Commands::M_MAPPER_CROW_SEAGULL: + case OpenSHC::Commands::M_MAPPER_SEAGULL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_TileMapState::instance.currentMapperCommand; + commandType = OpenSHC::Commands::GCT_CREATE_ANIMAL; + break; + default: + return; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + commandType); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index cb2e456fe8..13ed26bd80 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14351,7 +14351,7 @@ SHC_3BB0A8C1_0x00443A2D | 0.0% | Pending SHC_3BB0A8C1_0x00443A2E | 0.0% | Pending -SHC_3BB0A8C1_0x00443A30 | 0.0% | Pending +SHC_3BB0A8C1_0x00443A30 | 23.5% | gynt's draft, mechanical pass; register allocation and structure SHC_3BB0A8C1_0x004442A4 | 0.0% | Pending From 791f92c571d448e2f5642d6193f546d6c74bfc94 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:39 +0100 Subject: [PATCH 06/85] reimplement: SHC_3BB0A8C1_0x00494950 64.2% strcat intrinsic, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again (GameModeInt include). The map-name extension is a strcat with the string-macros.hpp literal (the draft's hand-made scan and strcpy into the end), and auto_backup_map.map is STR_AutoBackupMap; quick_diff 0.6907 -> 0.7065. The rest is the mechanical pass. Both PlayerSlotUnitColor copies are for loops (identical code). Co-Authored-By: Claude Opus 5.5 --- ...General_LaunchOrQuitMultiplayerGameUnk.cpp | 370 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp new file mode 100644 index 0000000000..614c422f10 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp @@ -0,0 +1,370 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../General.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/Skirmish.func.hpp" +#include "OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure.func.hpp" +#include "OpenSHC/IO/FilePackager.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuItems/CustomScenarios.func.hpp" +#include "OpenSHC/UI/MenuItems/HistoricCampaignSelect.func.hpp" +#include "OpenSHC/UI/MenuItems/MainMenu.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/DE/SHCDE/eMusicIDs.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/GameModeInt.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/IO/FileResourceType.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/string-macros.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.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_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_SoundEffectsHelperData1.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" +#include "OpenSHC/Globals/UI_MissionModeIntent.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using UI::Enums::MenuViewType; + + // FUNCTION: STRONGHOLDCRUSADER 0x00494950 + void General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk(int param_1, ...) + { + OpenSHC::Game::GameModeInt GVar1; + char* pcVar2; + char* pcVar3; + MenuViewType menuID; + GVar1 = DAT_GameSynchronyState::instance.currentGameMode; + if (param_1 != 22) { + if (param_1 == 23) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated = 0; + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::activateScenarioTypeEvents, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::createScenarioEventForNextMonth, + DAT_MapPropertiesState::ptr)(); + DAT_GameCore::instance.section1095 = 2; + } + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto LAB_00495061; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 44) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 43) { + DAT_GameCore::instance.isTimeHalted2 = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + goto LAB_00494b4a; + } + switch (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter) { + case 7: + break; + case 9: + MACRO_CALL_MEMBER( + Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case 30: + if ((DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) + && (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER)) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_GameCore::instance.mapTimeInTicks; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeSomeHashOnUnitArray, + DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_SAVE); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + case -7: + for (int i = 0; i < 9; ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + break; + default: + goto switchD_00494a01_caseD_fffffffa; + } + } else { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 50) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 49) { + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::spawnInvasionEventAttackWave, DAT_MapPropertiesState::ptr)(); + } else { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 44) { + // restart game + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition3::ptr)(UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER( + Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); + DAT_SoundEffectsHelperData1::instance.SEC_Section1079.musicState = 1; + MACRO_CALL_MEMBER( + Audio::MSS::SoundSystem_Func::setSomeSoundTime, DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setupVolumeAndSoundID, + DAT_SoundSystemState::ptr)(DE::SHCDE::MUSIC_TUNE_NARR1); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.isSkirmishTrail != TRUE) { + MACRO_CALL_MEMBER( + Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, + SEC_SkirmishLobbySetupStructure::ptr)(); + MACRO_CALL(UI::Actions_Func::LaunchSkirmishGame)(0); + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_GameCore::instance.currentTrailType == Game::TT_EXTREME) { + if (DAT_GameCore::instance.extremeTrailProgress < 20) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.extremeTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_GameCore::instance.currentTrailType == Game::TT_WARCHEST) { + if (DAT_GameCore::instance.warchestTrailProgress < 30) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.warchestTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } else if (DAT_GameCore::instance.skirmishTrailProgress < 50) { + MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( + DAT_GameCore::instance.skirmishTrailProgress); + MACRO_CALL_MEMBER( + Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto LAB_00495061; + } + } else { + if (DAT_GameCore::instance.gameMode_2 == Game::GM_BUILDERUnk) { + DAT_GameCore::instance.currentMenuViewType + = UI::Enums::MVT_UNKNOWN_49_DOES_NOTHINGUnk; + MACRO_CALL(Map_Func::ResetSomeValuesFunctionUnk)(); + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, + DAT_WindowAndDirectDraw::instance.resolutionY, + (ushort)((int)(COL_BLACK::instance.shortValue))); + MACRO_CALL(UI::Actions_Func::LaunchSinglePlayerGameUnk)(1); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER(Game::GameCore_Func::removeJesterAndLadyUnitsInCertainMissions, + DAT_GameCore::ptr)(); + } + if (DAT_GameCore::instance.gameMode_2 == Game::GM_ECONOMIC_CAMPAIGN_SH1) { + MACRO_CALL_MEMBER(Game::GameCore_Func::removeLadyAndJester, DAT_GameCore::ptr)(); + } + } + DAT_GameCore::instance.gameSuspended = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + DAT_GameCore::instance.section1095 = 0; + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + } + switchD_00494a01_caseD_fffffffa: + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 1000) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { + // ".map" + strcat(DAT_GameSynchronyState::instance.unknownMapName_01, S__MAP_005A2294); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, (char const*)((int)(DAT_GameSynchronyState::instance.unknownMapName_01))); + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + goto switchD_00494a01_caseD_fffffffa; + } + } + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_MULTIPLAYER) { + MACRO_CALL_MEMBER( + Synchrony::GameSynchronyState_Func::initMultiplayerLobbyState, DAT_GameSynchronyState::ptr)(); + return; + } + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition3::ptr)( + UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); + DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; + if (DAT_GameCore::instance.field_0x6c) { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 31; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); + DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; + MACRO_CALL_MEMBER( + UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, STR_AutoBackupMap); + FilePackagerObj::instance.loadAndSaveBarFunc = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + MACRO_CALL_MEMBER(Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + DAT_GameCore::instance.field_0x6c = 0; + goto LAB_0049504b; + } + if (!UI_MissionModeIntent::instance) { + if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 7) { + menuID = UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE; + goto LAB_00495046; + } + if (GVar1 == Game::GM_SOLITARY) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_BUILDERUnk) { + menuID = UI::Enums::MVT_MAIN_MENU; + goto LAB_00495046; + } + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_INVASION) { + MACRO_CALL(UI::MenuItems::CustomScenarios_Func::MenuItemActionHandler_CustomScenarios_Main)(4); + } else { + MACRO_CALL(UI::MenuItems::MainMenu_Func::MenuItemActionHandler_MainMenu_Main)(3); + } + } else if (GVar1 == Game::GM_SKIRMISH_SINGLE_PLAYER) { + if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { + if (!DAT_GameCore::instance.isSkirmishTrail) { + menuID = UI::Enums::MVT_UNKNOWN_61_RETURN_TO_SKIRMISH_MENUUnk; + } else { + DAT_GameCore::instance.gameSuspended = 0; + menuID = UI::Enums::MVT_CRUSADE_MAP; + } + goto LAB_00495046; + } + MACRO_CALL( + UI::MenuItems::HistoricCampaignSelect_Func::MenuItemActionHandler_HistoricCampaignSelect_Main)( + 4); + } else { + DAT_GameSynchronyState::instance.nextModalDialog = UI::Enums::MMT_CHOOSE_NETWORK_SERVICE_PROVIDER; + DAT_GameCore::instance.gameMode_2 = Game::GM_SKIRMISH_AND_MULTIPLAYER; + DAT_GameCore::instance.xbowProducible_logic = 1; + DAT_GameCore::instance.pikeProducible_logic = 1; + DAT_GameCore::instance.swordProducible_logic = 1; + DAT_GameCore::instance.bowProducible_logic = 1; + DAT_GameCore::instance.spearProducible_logic = 1; + DAT_GameCore::instance.maceProducible_logic = 1; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MP_CONNECTION, 0); + for (int i = 0; i < 9; ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + } + } else { + if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { + menuID = UI::Enums::MVT_HISTORIC_MISSION_SELECT; + } else { + menuID = UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk; + } + LAB_00495046: + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(menuID, 0); + } + LAB_0049504b: + if (DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU) { + LAB_00494b4a: + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::meth_0x4917c0, DAT_MenuTextInputState::ptr)(); + LAB_00495061: + MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 13ed26bd80..1ff4c20c75 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -24113,7 +24113,7 @@ SHC_3BB0A8C1_0x004948C0 | 0.0% | Pending SHC_3BB0A8C1_0x00494920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00494950 | 0.0% | Pending +SHC_3BB0A8C1_0x00494950 | 64.2% | strcat intrinsic, mechanical pass; structure SHC_3BB0A8C1_0x00494DB0 | 0.0% | Pending From 59372c9e0dc906cb20b02f15bfe26d97a3a02da8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:39 +0100 Subject: [PATCH 07/85] reimplement: SHC_3BB0A8C1_0x00443070 53.2% compiles again, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again: the menu tabs to switch to are ActiveMenuTab structs now (.tabType). auto_backup_map.map is STR_AutoBackupMap; the rest is the mechanical pass (identical code). The player IDs are set by a for loop (identical code). Re-measured on main 06d4938a6, where #319 and #322 reimplement callees of this function: 50.6% -> 53.2% (same code as before). Co-Authored-By: Claude Opus 5.5 --- ...andler_MapEditorProperties_MainButtons.cpp | 380 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 381 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp new file mode 100644 index 0000000000..f3024c7ac9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp @@ -0,0 +1,380 @@ +#include "../MapEditorProperties.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/Units/TroopValueState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00b95b74.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_AICState.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.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/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/FilePackagerObj.hpp" +#include "OpenSHC/Globals/INT_00b95f68.hpp" +#include "OpenSHC/Globals/INT_00b960e4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00443070 + void MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons(int param_1, ...) + { + byte(*pabVar1)[10]; + byte* pbVar2; + char cVar3; + char cVar4; + char cVar5; + int iVar6; + int* piVar7; + int* piVar8; + if ((DAT_MenuTextInputState::instance.currentModalDialog == UI::Enums::MMT_NO_MENU) + && (DAT_MenuModalComposition1::instance.activeModalDialogID == UI::Enums::MMT_NONE)) { + DAT_TileMapState::instance.unitPlacementCount = 1; + switch (param_1) { + case 2: + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, DAT_MenuTextInputState::ptr)(9); + return; + case 3: + if ((!DAT_GameCore::instance.U2_mapType_singleOrMulti) + || (DAT_GameCore::instance.mapLoadedForEditor)) { + MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, + DAT_MapPropertiesState::ptr)(); + DAT_MenuTextInputState::instance.field_0x9c = 1; + DAT_MenuTextInputState::instance.field_0xa4 = 0; + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, DAT_MenuTextInputState::ptr)(10); + INT_00b960e4::instance = 1; + return; + } + break; + case 4: + INT_00b960e4::instance = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_NEW_MAP_MAPTYPE, 0); + return; + case 5: + if (INT_00b95f68::instance) { + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 43; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(UI::Enums::MMT_QUIT_DIALOG); + return; + } + DAT_GameCore::instance.isTimeHalted2 = 0; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_CUSTOM_SCENARIOS, 0); + return; + case 6: + if (DAT_GameCore::instance.mapLoadedForEditor) { + INT_00b95f68::instance = 1; + DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; + DAT_GameCore::instance.gameMode_2 = Game::GM_EDITOR; + DAT_GameCore::instance.missionNumber1to20 = 27; + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + for (int i = 0; i < 9; ++i) { + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; + } + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; + if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType == 237) { + if (DAT_GameCore::instance.U2_mapType_singleOrMulti < 1) + goto LAB_00443214; + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 239; + } else if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType != 239) + goto LAB_00443214; + if (!DAT_GameCore::instance.U2_mapType_singleOrMulti) { + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 237; + } + LAB_00443214: + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_LANDSCAPING, 0); + return; + } + break; + case 9: + MACRO_CALL(UI::MenuItems::MapEditorProperties_Func:: + MenuItemActionHandler_MapEditorProperties_MapDescriptionBox)(); + return; + case 25: + if ((DAT_GameCore::instance.U2_mapType_singleOrMulti != 1) + && (DAT_GameCore::instance.mapLoadedForEditor)) { + INT_00b95f68::instance = 1; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_EDIT_SCENARIO, 0); + return; + } + break; + case 31: + if (DAT_GameCore::instance.mapLoadedForEditor) { + DAT_GameCore::instance.missionNumber1to20 = 27; + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); + MACRO_CALL_MEMBER( + UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); + MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( + IO::FRT_MAPS, STR_AutoBackupMap); + FilePackagerObj::instance.loadAndSaveBarFunc + = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); + MACRO_CALL_MEMBER(IO::FilePackager_Func::writeMapOrSaveFile, FilePackagerObj::ptr)( + DAT_MapDefinedData::instance.MapSectionAddressArray); + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[1] = 1; + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[2] = 2; + } + DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = 9; + MACRO_CALL_MEMBER( + UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; + DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; + DAT_GameCore::instance.gameMode_2 = Game::GM_BUILDERUnk; + DAT_GameCore::instance.field_0x6c = 1; + DAT_GameState::instance.mapAndTime.difficulty = 1; + DAT_GameCore::instance.section1095 = 0; + MACRO_CALL_MEMBER( + Map::Units::TroopValueState_Func::clearAttackInfo, DAT_TroopValueState::ptr)(); + MACRO_CALL_MEMBER(AI::AICState_Func::recomputeAIZonerLayer, DAT_AICState::ptr)(); + ++DAT_TroopValueState::instance.attackInfo.inv_count; + if (49 < DAT_TroopValueState::instance.attackInfo.inv_count) { + DAT_TroopValueState::instance.attackInfo.inv_count = 1; + } + MACRO_CALL_MEMBER(Map::Units::TroopValueState_Func::initializeAttackWaveSlot, + DAT_TroopValueState::ptr)(DAT_TroopValueState::instance.attackInfo.inv_count, 1); + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[0]; + DAT_TroopValueState::instance.attackInfo + .attackWavePlayerIDArray[DAT_TroopValueState::instance.attackInfo.inv_count] = 2; + cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[1]; + pabVar1 = DAT_TroopValueState::instance.attackInfo.someSinglePlayerScore + + DAT_TroopValueState::instance.attackInfo.inv_count; + (*pabVar1)[0] = (*pabVar1)[0] + cVar3; + cVar5 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[3]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 1; + *pbVar2 += cVar4; + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[2]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 2; + *pbVar2 += cVar5; + cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[4]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 3; + *pbVar2 += cVar3; + cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[5]; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 4; + *pbVar2 += cVar4; + pbVar2 = DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] + + 8; + *pbVar2 += cVar3; + DAT_GameState::instance.mapAndTime.siegeInformation.archers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.archers; + piVar7 = DAT_MapPropertiesState::instance.SEC_StartingResources; + piVar8 = DAT_GameState::instance.mapAndTime.startGoods; + for (iVar6 = 25; iVar6 != 0; --iVar6) { + *piVar8 = *piVar7; + ++piVar7; + ++piVar8; + } + DAT_GameState::instance.mapAndTime.startGoods[7] + = DAT_GameState::instance.mapAndTime.startGoods[8]; + DAT_GameState::instance.mapAndTime.siegeInformation.pikemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.pikemen; + DAT_GameState::instance.mapAndTime.siegeInformation.spearmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.spearmen; + DAT_GameState::instance.mapAndTime.siegeInformation.crossbowmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.crossbowmen; + DAT_GameState::instance.mapAndTime.siegeInformation.knights + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.knights; + DAT_GameState::instance.mapAndTime.siegeInformation.swordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.swordsmen; + DAT_GameState::instance.mapAndTime.siegeInformation.macemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.macemen; + DAT_GameState::instance.mapAndTime.siegeInformation.monks + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.monks; + DAT_GameState::instance.mapAndTime.siegeInformation.engineers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.engineers; + DAT_GameState::instance.mapAndTime.siegeInformation.laddermen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.laddermen; + DAT_GameState::instance.mapAndTime.siegeInformation.slingers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.slingers; + DAT_GameState::instance.mapAndTime.siegeInformation.slaves + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.slaves; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.arabianArchers; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianSwordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.arabianSwordsmen; + DAT_GameState::instance.mapAndTime.siegeInformation.horseArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.horseArchers; + DAT_GameState::instance.mapAndTime.siegeInformation.assassins + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.assassins; + DAT_GameState::instance.mapAndTime.siegeInformation.field_0x48 + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.field_0x48; + DAT_GameState::instance.mapAndTime.siegeInformation.fireBallistas + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.fireBallistas; + DAT_GameState::instance.mapAndTime.siegeInformation.fireThrowers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.fireThrowers; + DAT_GameState::instance.mapAndTime.startGoods[8] = 0; + DAT_GameState::instance.mapAndTime.siegeInformation.field_0x4c + = DAT_MapPropertiesState::instance.SEC_SiegeInformation.field_0x4c; + DAT_GameState::instance.mapAndTime.startingPopularity + = DAT_MapPropertiesState::instance.SEC_StartingPopularity * 10; + MACRO_CALL_MEMBER(Game::GameStateStructures_Func::setMonthAndYear, DAT_GameState::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingMonth, + DAT_MapPropertiesState::instance.SEC_StartingYear); + MACRO_CALL_MEMBER( + Game::GameStateStructures_Func::clearEnemyRelatedStructures, DAT_GameState::ptr)(); + DAT_GameState::instance.mapAndTime.mercRecruitable[3] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[3]; + DAT_GameCore::instance.xbowProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_XbowProducible_save; + DAT_GameCore::instance.bowProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_BowProducible_save; + DAT_GameCore::instance.pikeProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_PikeProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[2] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[2]; + DAT_GameState::instance.mapAndTime.euroRecruitable[4] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.macemen; + DAT_GameState::instance.mapAndTime.mercRecruitable[4] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[4]; + DAT_GameState::instance.mapAndTime.euroRecruitable[5] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.swordsmen; + DAT_GameCore::instance.spearProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_SpearProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[5] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[5]; + DAT_GameState::instance.mapAndTime.mercRecruitable[0] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[0]; + DAT_GameState::instance.mapAndTime.euroRecruitable[6] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.knights; + DAT_GameCore::instance.swordProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_SwordProducible_save; + DAT_GameCore::instance.maceProducible_logic + = (int)DAT_MapPropertiesState::instance.SEC_MaceProducible_save; + DAT_GameState::instance.mapAndTime.mercRecruitable[1] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[1]; + DAT_GameState::instance.mapAndTime.mercRecruitable[6] + = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[6]; + DAT_GameState::instance.mapAndTime.euroRecruitable[0] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.archers; + DAT_GameState::instance.mapAndTime.euroRecruitable[1] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.crossbowmen; + DAT_GameState::instance.mapAndTime.euroRecruitable[2] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.spearmen; + DAT_GameState::instance.mapAndTime.euroRecruitable[3] + = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.pikemen; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_0 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[0] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_2 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[2] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_b + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_4 + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0); + if (DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c + = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0); + DAT_GameState::instance.mapAndTime.countUpTo201 = 0; + MACRO_CALL_MEMBER( + Map::MapPropertiesState_Func::importTradingCosts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); + MACRO_CALL_MEMBER( + Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = UI::Enums::BASMTT_HUNTERSHUT; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + return; + } + break; + case -6: + DAT_GameCore::instance.mapU3EndInt = 1; + break; + case -5: + DAT_GameCore::instance.mapU3EndInt = 0; + return; + case -4: + DAT_GameCore::instance.mapU4Int3_balanced = 1; + return; + case -3: + DAT_GameCore::instance.mapU4Int3_balanced = 0; + return; + case -2: + iVar6 = DAT_00b95b74::instance - 231; + if ((DAT_00b960f4::instance < iVar6) + && (DAT_00b960f4::instance = DAT_00b960f4::instance + 14, iVar6 < DAT_00b960f4::instance)) { + DAT_00b960f4::instance = iVar6; + return; + } + break; + case -1: + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + return; + } + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1ff4c20c75..f7a15b3115 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14157,7 +14157,7 @@ SHC_3BB0A8C1_0x0044305C | 0.0% | Pending SHC_3BB0A8C1_0x00443060 | 0.0% | Pending -SHC_3BB0A8C1_0x00443070 | 0.0% | Pending +SHC_3BB0A8C1_0x00443070 | 53.2% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x00443778 | 0.0% | Pending From f5da9024687552a0e25013d70f624010fa3dedcc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:40 +0100 Subject: [PATCH 08/85] reimplement: SHC_3BB0A8C1_0x004B9620 64.0% compiles again, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again: the byte the draft wrote through units[0x9bb].field_0x3e3 (a field the header no longer has) is addressed from that unit's start + 0x3e3, the same address; the target is not really in a unit, see the PR text. The rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 --- ...emActionHandler_NewEventCondition_Main.cpp | 384 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp new file mode 100644 index 0000000000..5961be2fed --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp @@ -0,0 +1,384 @@ +#include "../NewEventCondition.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_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_UnknownTime_01.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B9620 + void NewEventCondition::MenuItemActionHandler_NewEventCondition_Main(int param_1, ...) + { + ushort* puVar1; + short* destination; + byte* pbVar2; + short sVar3; + byte(*pabVar4)[100]; + DWORD DVar5; + char* pcVar6; + int iVar7; + int iVar8; + if (param_1 < 1001) { + if (param_1 == 1000) { + sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + < (int)sVar3) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 - 1; + return; + } + } else { + switch (param_1) { + case 19: + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 15) = 0; + return; + case 37: + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 15) + != '\0') { + iVar8 = 1; + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 19); + while (*pcVar6 == '\0') { + ++iVar8; + pcVar6 += 4; + if (39 < iVar8) { + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); + return; + } + } + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 15) = 0; + } + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); + return; + case 104: + puVar1 = (ushort*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 8); + *puVar1 ^= 1; + return; + case 190: + case 191: + case 192: + case 193: + case 194: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 205: + case 206: + case 207: + case 208: + case 209: + param_1 -= 64; + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 116: + case 117: + case 118: + case 119: + case 120: + case 121: + case 122: + case 123: + case 124: + case 125: + DAT_MapPropertiesState::instance.invasionTroopIndex = param_1 - 106; + *(undefined1*)((int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags + + DAT_MapPropertiesState::instance.currentEventID * 228 + param_1 * 4 + 511) = 1; + DAT_UnknownTime_01::instance = 0; + if ((int)*(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) + < DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) + = (short)DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]; + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + destination = (short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::setSliderParameters2, DAT_MenuModalComposition2::ptr)( + DAT_MissionAestheticsDefinedData::instance + .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex], + (dword)((int)(DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex])), + (dword)((int)((int)*destination)), (dword)((int)(destination)), + (undefined*)MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, + (int)((int)(DAT_ButtonX::instance + 58)), (int)((int)(DAT_ButtonY::instance + 28))); + return; + } + } + } + } else if (param_1 < 2003) { + if (param_1 < 2001) { + if (param_1 == 1001) { + sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); + if ((int)sVar3 < DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 + 1; + return; + } + } else if (param_1 == 2000) { + iVar8 = 0; + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + iVar7 + = (int)*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + pbVar2 = (byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + if (*(int*)DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] + != iVar7) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + do { + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + ++iVar8; + } while (*(int*)*pabVar4 != iVar7); + } + if (iVar8 - 1 < 0) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + iVar8 = 0; + do { + iVar7 = iVar8; + if (*(int*)*pabVar4 == -1) { + *pbVar2 + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex - 1] + [iVar7 * 4 + 96]; + goto LAB_004b98bd; + } + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + iVar8 = iVar7 + 1; + } while (iVar7 + 1 < 100); + *pbVar2 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar7 * 4 + 4]; + } else { + *pbVar2 + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex - 1][iVar8 * 4 + 96]; + } + } + LAB_004b98bd: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 2) { + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + --*pcVar6; + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + < '\0') { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 4; + } + } + } + } + } else { + iVar8 = 0; + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 0) { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + iVar7 = (int)*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + if (!iVar7) { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 10; + iVar7 = 10; + } + if (*(int*)DAT_MissionAestheticsDefinedData::instance + .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] + != iVar7) { + pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + + DAT_MapPropertiesState::instance.invasionTroopIndex; + do { + pabVar4 = (byte(*)[100])(*pabVar4 + 4); + ++iVar8; + } while (*(int*)*pabVar4 != iVar7); + } + if (*(int*)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex] + + iVar8 * 4 + 4) + == -1) { + *(byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][0]; + } else { + *(byte*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) + = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues + [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar8 * 4 + 4]; + } + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 2) { + pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); + *pcVar6 += '\x01'; + if ('\x04' < *(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)) { + *(undefined1*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 0; + return; + } + } + } + } + } else { + switch (param_1) { + case 5190: + case 5191: + case 5192: + case 5193: + case 5194: + case 5195: + case 5196: + case 5197: + case 5198: + case 5199: + case 5200: + case 5201: + case 5202: + case 5203: + case 5204: + case 5205: + case 5206: + case 5207: + case 5208: + case 5209: + param_1 -= 64; + case 5106: + case 5107: + case 5108: + case 5109: + case 5110: + case 5111: + case 5112: + case 5113: + case 5114: + case 5115: + case 5116: + case 5117: + case 5118: + case 5119: + case 5120: + case 5121: + case 5122: + case 5123: + case 5124: + case 5125: + if ((DAT_MenuModalComposition2::instance.activeModalDialogID == UI::Enums::MMT_NONE) + && ((DVar5 = timeGetTime(), + 1000 < DVar5 - DAT_UnknownTime_01::instance || (!DAT_UnknownTime_01::instance)))) { + DAT_UnknownTime_01::instance = 0; + ((char*)&DAT_UnitsState::instance.units[2491] + + 995)[(DAT_MapPropertiesState::instance.currentEventID * 57 + param_1) * 4] = 0; + return; + } + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f7a15b3115..f547e708a1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27641,7 +27641,7 @@ SHC_3BB0A8C1_0x004B9530 | 0.0% | Pending SHC_3BB0A8C1_0x004B9610 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B9620 | 0.0% | Pending +SHC_3BB0A8C1_0x004B9620 | 64.0% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004B9AA8 | 0.0% | Pending From 98b3cb9667f570945150d4748dce76c11bd9dc2d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:40 +0100 Subject: [PATCH 09/85] reimplement: SHC_3BB0A8C1_0x004C01B0 72.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_NewEventCondition_Main.cpp | 379 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp new file mode 100644 index 0000000000..d5e9b0f870 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp @@ -0,0 +1,379 @@ +#include "../NewEventCondition.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/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/RoundedBoxEdgeRoundingLevel.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.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_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004C01B0 + void NewEventCondition::MenuItemRenderFunction_NewEventCondition_Main(int param_1, ...) + { + DAT_ButtonUnknownZero::instance = 0; + if (5000 < param_1) { + return; + } + int iVar1; + switch (param_1) { + case -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::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month + + 12, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + } else { + 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, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + break; + case 126: + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 15) + == '\0') { + param_1 = 127; + } + case 19: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + return; + case 104: + if (*(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 8) + != 0) { + param_1 = 105; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + return; + case 209: { + int iVar3 = 0; + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 19) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 31) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 35) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 39) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 43) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 83) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 95) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 99) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 103) + != '\0') { + iVar3 = 1; + } + if (*(char*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + 107) + == '\0' + && iVar3 == 0) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + } + case 190: + case 191: + case 192: + case 193: + case 194: + case 195: + case 196: + case 197: + case 198: + case 199: + case 200: + case 201: + case 202: + case 203: + case 204: + case 205: + case 206: + case 207: + case 208: { + iVar1 = param_1 - 64; + goto switchD_004c01f4_caseD_6a; + } + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 116: + case 117: + case 118: + case 119: + case 120: + case 121: + case 122: + case 123: + case 124: + case 125: { + iVar1 = param_1; + switchD_004c01f4_caseD_6a: + DAT_ButtonCurrentlyInteracting::instance + = (BOOLEnum)(DAT_MapPropertiesState::instance.invasionTroopIndex == iVar1 - 106); + uint uVar2 = 12775659; + if (DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (param_1 == 111 || param_1 == 112 || param_1 == 113 || param_1 == 123) { + param_1 = 113; + } + if (*(char*)((int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags + + DAT_MapPropertiesState::instance.currentEventID * 228 + iVar1 * 4 + 511) + != '\0') { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, (int)(DAT_ButtonX::instance + 5), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, uVar2, 18, FALSE); + if (DAT_MissionAestheticsDefinedData::instance.unknown3[iVar1 + 862] == 0) { + return; + } + if (DAT_MissionAestheticsDefinedData::instance.EventConditionMinValue[iVar1 + 14] == 1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + (int)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionTextOffsets[( + char)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 + + DAT_MapPropertiesState::instance.currentEventID * 114 + 255]]), + (int)(DAT_ButtonX::instance + 14), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, uVar2, 18, TRUE); + } + if (DAT_MissionAestheticsDefinedData::instance.EventConditionMinValue[iVar1 + 14] == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, + (int)(DAT_MissionAestheticsDefinedData::instance.field_0x170[( + char)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 + + DAT_MapPropertiesState::instance.currentEventID * 114 + 255]]), + (int)(DAT_ButtonX::instance + 14), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, uVar2, 18, TRUE); + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( + (int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 + + DAT_MapPropertiesState::instance.currentEventID * 114 + 254] + * DAT_MissionAestheticsDefinedData::instance.unknown3[iVar1 + 902], + (int)(DAT_ButtonW::instance - 8 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, uVar2, 18, FALSE); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, (int)(DAT_ButtonX::instance + 5), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, 8355711, 18, FALSE); + return; + } + case 1001: { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + } + case 1000: { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + } + case 2000: { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + } + default: { + switchD_004c01f4_caseD_0: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + return; + } + case 2002: { + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 1) { + 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, + (int)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionTextOffsets[*( + char*)(&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + } + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + != 2) { + return; + } + 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, + (int)(DAT_MissionAestheticsDefinedData::instance + .field_0x170[*(char*)(&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + return; + return; + } + case 2001: + if (DAT_MissionAestheticsDefinedData::instance + .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0) { + return; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); + } + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index f547e708a1..2e173c56dc 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -32329,7 +32329,7 @@ SHC_3BB0A8C1_0x004C01A5 | 0.0% | Pending SHC_3BB0A8C1_0x004C01A6 | 0.0% | Pending -SHC_3BB0A8C1_0x004C01B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004C01B0 | 72.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004C0770 | 0.0% | Pending From 8c967b43bad59800fc764b87d8984ac80310b880 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:15:40 +0100 Subject: [PATCH 10/85] reimplement: SHC_3BB0A8C1_0x00427810 58.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 355 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp new file mode 100644 index 0000000000..9b2127af3c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -0,0 +1,355 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00427810 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons(int param_1, ...) + { + int iVar3; + int iVar4; + int iVar6; + BOOLEnum BVar2 = MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)(); + if (BVar2) { + return; + } + if (param_1 == 0) { + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar4 = (iVar3 / 32) + 32; + BVar2 = FALSE; + int iVar10 = 19; + BGR24 BVar9 = 12775659; + TextAlignment TVar7 = OpenSHC::Text::TTA_LEFT; + iVar3 = DAT_ButtonX::instance; + iVar6 = DAT_ButtonY::instance; + // added by script: "Players" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 28), + iVar3, iVar6, TVar7, BVar9, iVar10, BVar2, iVar4); + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar6 = (iVar3 / 32) + 32; + BVar2 = FALSE; + iVar10 = 19; + BVar9 = 12775659; + TVar7 = OpenSHC::Text::TTA_CENTER; + iVar4 = DAT_ButtonX::instance + 335; + iVar3 = DAT_ButtonY::instance; + // added by script: "Status" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 29), + iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); + } + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar6 = (iVar3 / 32) + 32; + BVar2 = FALSE; + iVar10 = 19; + BVar9 = 12775659; + TVar7 = OpenSHC::Text::TTA_CENTER; + iVar4 = DAT_ButtonX::instance + 370; + iVar3 = DAT_ButtonY::instance; + // added by script: "Eject" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 91), + iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); + } + if (10 < param_1) { + iVar3 + = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); + DAT_ButtonUnknownZero::instance = 1; + if (iVar3 < 1) { + return; + } + byte bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if ('\0' < (char)bVar1) { + if ((bVar1 == 1) || (bVar1 == 3)) { + iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { + iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 204, + iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (iVar4 / 32) + 32); + iVar6 += 20; + } + } else { + iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { + iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 205, + iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (iVar4 / 32) + 32); + iVar6 += 20; + } + } + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE + && 27 + < DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + && DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + < 350 + && (int)DAT_ButtonY::instance <= DAT_MouseState::instance.screenSpaceY + && DAT_MouseState::instance.screenSpaceY < (int)DAT_ButtonY::instance + 20) { + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + iVar6 = 403; + } else if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { + iVar6 = 405; + } else { + iVar6 = 404; + } + // added by script: "Computer Opponent" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar6, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)((char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3] + 405), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 145, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, TRUE); + } + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, 12775659, 19, + (iVar6 / 32) + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, 8170159, 19, + (iVar6 / 32) + 32); + } + } + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + return; + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9 + 230), + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 70, 8170159, 19, + (iVar6 / 32) + 32); + return; + } + if (0 < param_1) { + iVar3 = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[param_1]; + DAT_ButtonUnknownZero::instance = 1; + if (iVar3 < 1) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && (iVar3 == DAT_GameSynchronyState::instance.DAT_HostPlayerSlotID + || ((DAT_GameSynchronyState::instance.isHost + && (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID))))) { + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 138, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 36, (int)(DAT_ButtonY::instance - 2), + (iVar6 / 32) + 32); + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 469, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, (int)(DAT_ButtonY::instance), + (iVar6 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 231 + + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9), + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 8170159, 19, + (iVar6 / 32) + 32); + } + iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + DAT_TextManagerObject::instance.field_0x30 = 1; + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 12775659, 19, + (iVar6 / 32) + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 8170159, 19, + (iVar6 / 32) + 32); + } + } + if (-10 < param_1) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + return; + } + iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1089092 - param_1)); + DAT_ButtonUnknownZero::instance = 0; + if (iVar3 < 1) { + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + if (iVar3 != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + DAT_CurrentButtonGmDataIndex::instance + = 207 - (uint)(DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[iVar3] != 0); + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + return; + } + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + DAT_ButtonUnknownZero::instance = 0; + return; + } + DAT_CurrentButtonGmDataIndex::instance = 627; + switch (DAT_GameSynchronyState::instance.currentAIArray[iVar3]) { + case 1: + case 2: + case 3: + case 4: + case 8: + case 9: + case 10: + case 14: + case 15: + case 16: + DAT_CurrentButtonGmDataIndex::instance = 626; + } + DAT_ButtonX::instance -= 6; + DAT_ButtonY::instance -= 3; + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (param_1 < -199) { + DAT_ButtonUnknownZero::instance = 0; + if (!DAT_GameSynchronyState::instance.isHost) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1088892 - param_1)); + if (iVar3 < 1) { + DAT_ButtonUnknownZero::instance = 0; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameSynchronyState::instance.slotActionPending[iVar3] != 0) { + DAT_ButtonUnknownZero::instance = 0; + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + BVar2 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3); + if (!BVar2) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (iVar3 / 32) + 32); + } + if (param_1 == -101) { + DAT_ButtonUnknownZero::instance = 1; + if ((DAT_GameSynchronyState::instance.isHost) + && (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE)) { + for (int iVar3 = 1; iVar3 < 9; ++iVar3) { + if ((char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[iVar3] < '\x01') + goto LAB_00427f46; + } + } + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } else { + if (param_1 == -102) { + if (!DAT_GameSynchronyState::instance.isHost) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE + && DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT + && DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) + goto LAB_00427f4c; + } else { + if (param_1 != -103) + goto LAB_00427f4c; + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_ButtonUnknownZero::instance = 1; + } + } + LAB_00427f46: + DAT_ButtonUnknownZero::instance = 0; + } + LAB_00427f4c: + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)((iVar3 / 32) + 32); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2e173c56dc..451fc97dcb 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6819,7 +6819,7 @@ SHC_3BB0A8C1_0x004276F0 | 0.0% | Pending SHC_3BB0A8C1_0x00427740 | 0.0% | Pending -SHC_3BB0A8C1_0x00427810 | 0.0% | Pending +SHC_3BB0A8C1_0x00427810 | 58.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00427CB2 | 0.0% | Pending From acab824054734ccdcc9ecb70082fc146c24a81a2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:43:06 +0100 Subject: [PATCH 11/85] headers: UnitType value -1 as UT_NONE BuildMenu_UnitActionButtons' render function tests the selected unit's type against -1 (no unit). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Map/Units/UnitType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/Map/Units/UnitType.hpp b/src/OpenSHC/Map/Units/UnitType.hpp index 3bcd1f457c..8fb41d4bfe 100644 --- a/src/OpenSHC/Map/Units/UnitType.hpp +++ b/src/OpenSHC/Map/Units/UnitType.hpp @@ -13,6 +13,7 @@ namespace Map { namespace Units { typedef enum UnitType { + UT_NONE = -1, // 0xFFFFFFFF UT_PEASANT = 1, // 0x00000001 UT_BURNINGMAN = 2, // 0x00000002 UT_WOODCUTTER = 3, // 0x00000003 From 7e35a4570a9969f95220a5fb2c690c98ebcf1281 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:43:07 +0100 Subject: [PATCH 12/85] headers: BuildMenuTabType value 49 as BMTT_UNKNOWN_49 InGameMenu_PeasantBuildAndRightClickMenuSelection compares the active build-menu tab with 49. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/UI/Enums/BuildMenuTabType.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenSHC/UI/Enums/BuildMenuTabType.hpp b/src/OpenSHC/UI/Enums/BuildMenuTabType.hpp index f65bb724d9..def20ec6e8 100644 --- a/src/OpenSHC/UI/Enums/BuildMenuTabType.hpp +++ b/src/OpenSHC/UI/Enums/BuildMenuTabType.hpp @@ -30,6 +30,7 @@ namespace UI { BMTT_TOWN = 30, // 0x0000001E BMTT_TOWN_BAD_THINGS = 33, // 0x00000021 BMTT_FARMS = 40, // 0x00000028 + BMTT_UNKNOWN_49 = 49, // 0x00000031 BMTT_MENU_HIDDEN = 60, // 0x0000003C BMTT_SOLDIERS = 61, // 0x0000003D BMTT_CITIZEN_SELECTED = 70 // 0x00000046 From d05e6ffe8218904334687ccc9666b1ecf28f3908 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:45:11 +0100 Subject: [PATCH 13/85] headers: UserTextHandler::copyIntoTextArray takes a char const* It copies the text it is given into the active text slot and does not write to it (0x00472C30), so its parameter is const. EditScenario_BaseMenuButtons passes the string pointer for "", which is const; readUserConfig on main passes a char* and compiles to the same code (quick_diff identical). Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Text/UserTextHandler.func.hpp | 2 +- src/OpenSHC/Text/UserTextHandler.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Text/UserTextHandler.func.hpp b/src/OpenSHC/Text/UserTextHandler.func.hpp index 2992d44fb2..b8899d0e0d 100644 --- a/src/OpenSHC/Text/UserTextHandler.func.hpp +++ b/src/OpenSHC/Text/UserTextHandler.func.hpp @@ -83,7 +83,7 @@ namespace Text { void (UserTextHandler::*)(int), false, Address::SHC_3BB0A8C1_0x00472BE0, &UserTextHandler::clearEntry) clearEntry; - MACRO_FUNCTION_RESOLVER(void (UserTextHandler::*)(char*), false, Address::SHC_3BB0A8C1_0x00472C30, + MACRO_FUNCTION_RESOLVER(void (UserTextHandler::*)(char const*), false, Address::SHC_3BB0A8C1_0x00472C30, &UserTextHandler::copyIntoTextArray) copyIntoTextArray; diff --git a/src/OpenSHC/Text/UserTextHandler.hpp b/src/OpenSHC/Text/UserTextHandler.hpp index 05d3867c47..eaa7c60b4c 100644 --- a/src/OpenSHC/Text/UserTextHandler.hpp +++ b/src/OpenSHC/Text/UserTextHandler.hpp @@ -80,7 +80,7 @@ namespace Text { void clearEntry(int param_1); - void copyIntoTextArray(char* param_1); + void copyIntoTextArray(char const* text); int isTextInputAtCapacity(); From 1f29978594b239f8dfa0eb3d98f4b1e6f712cfcc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:24 +0100 Subject: [PATCH 14/85] reimplement: SHC_3BB0A8C1_0x004B14C0 60.5% compiles again, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again: getResourceSpace takes a ResourceType now (the draft passed (int*)(int)x). Gold is RT_GOLD; the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 --- ...Handler_AlliesSendAndRequestGoods_Main.cpp | 263 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp new file mode 100644 index 0000000000..e913b4a295 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp @@ -0,0 +1,263 @@ +#include "../AlliesSendAndRequestGoods.func.hpp" + +#include "OpenSHC/AI/AICState.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeInt.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeMin1.hpp" +#include "OpenSHC/Game/Resources/ResourceTypeMin1Int.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df4284.hpp" +#include "OpenSHC/Globals/DAT_AICState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp" +#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Game::Resources::ResourceType; + using OpenSHC::Game::Resources::ResourceTypeInt; + using OpenSHC::Game::Resources::ResourceTypeMin1Int; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B14C0 + void AlliesSendAndRequestGoods::MenuItemActionHandler_AlliesSendAndRequestGoods_Main(int param_1, ...) + { + BOOLEnum BVar1; + int iVar2; + int _space; + int playerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if (param_1 == 40) { + return; + } + if (param_1 < 21) { + DAT_RequestedGoodsByWhoArray::instance[0] = param_1; + if (4 <= param_1) { + DAT_RequestedGoodsByWhoArray::instance[0] = param_1 + 1; + } + if (5 <= param_1) { + ++DAT_RequestedGoodsByWhoArray::instance[0]; + } + if (DAT_RequestedGoodsByWhoArray::instance[0] != 14) { + return; + } + DAT_RequestedGoodsByWhoArray::instance[0] = 23; + return; + } + if (param_1 == 21) { + DAT_RequestedGoodsByWhoArray::instance[0] = 14; + } + if (param_1 == 50) { + DAT_SentOrRequestedGoodsAmount::instance += 10; + } + if (param_1 == 51) { + DAT_SentOrRequestedGoodsAmount::instance += 25; + } + if (param_1 == 52) { + DAT_SentOrRequestedGoodsAmount::instance += 100; + } + if (param_1 == 53) { + DAT_SentOrRequestedGoodsAmount::instance += 5; + } + if (param_1 != 54) { + if (param_1 == 102) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + if (DAT_MenuModalComposition1::instance.activeModalDialogID + != OpenSHC::UI::Enums::MMT_ALLIES_SEND_GOODS) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + } + if (DAT_00df4284::instance == 0) { + DAT_RequestedGoodsByWhoArray::instance[0] = -1; + DAT_SentOrRequestedGoodsAmount::instance = 0; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 3; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + return; + } + if (param_1 != 100) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + } + if (0 <= DAT_RequestedGoodsByWhoArray::instance[0]) { + if ((int)DAT_SentOrRequestedGoodsAmount::instance <= 0) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_ALLIES_REQUEST_GOODS) { + if ((int*)(DAT_RequestedGoodsByWhoArray::instance[0] + 1) == (int*)15) { + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, OpenSHC::Game::Resources::RT_GOLD, + (int)(DAT_SentOrRequestedGoodsAmount::instance)); + } else { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (OpenSHC::Game::Resources::ResourceType)(( + DAT_RequestedGoodsByWhoArray::instance[0] + 1))); + if (iVar2 == -1) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 3, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 6) { + // "No stockpile built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning2.wav" + DAT_SFXState::ptr)(s_space_warning2_wav_005a5950); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 5) { + // "No granary built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning1.wav" + DAT_SFXState::ptr)(s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 7) { + DAT_MenuModalComposition1::instance.activeModalDialogID + = OpenSHC::UI::Enums::MMT_NONE; + } + // "No armory built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning3.wav" + s_space_warning3_wav_005a5928); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + if (iVar2 < (int)DAT_SentOrRequestedGoodsAmount::instance) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( + 4, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 9) { + // "No space in the stockpile" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning5.wav" + DAT_SFXState::ptr)(s_space_warning5_wav_005a50b0); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 8) { + // "No space in the granary" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "space_warning4.wav" + DAT_SFXState::ptr)(s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 10) { + DAT_MenuModalComposition1::instance.activeModalDialogID + = OpenSHC::UI::Enums::MMT_NONE; + } + // "No space in the armory" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning6.wav" + s_space_warning6_wav_005a5900); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + return; + } + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, + DAT_AICState::ptr)(playerID, + (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0] + + OpenSHC::Game::Resources::RT_LOGS)), + (int)(DAT_SentOrRequestedGoodsAmount::instance)); + } + if (BVar1) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 + = DAT_RequestedGoodsByWhoArray::instance[0]; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 + = DAT_SentOrRequestedGoodsAmount::instance; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::AI::AICState_Func::playGoodsNotSentBikFromPlayer, DAT_AICState::ptr)( + playerID); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); + int _sendAmount = DAT_SentOrRequestedGoodsAmount::instance; + ResourceTypeMin1Int _resource + = DAT_RequestedGoodsByWhoArray::instance[0] + OpenSHC::Game::Resources::RTM_WOOD; + ResourceTypeInt _resourceType = _resource; + if (_resource == OpenSHC::Game::Resources::RTM_WHEAT) { + _resourceType = DAT_RequestedGoodsByWhoArray::instance[0]; + } + if (_resource == OpenSHC::Game::Resources::RTM_FLOUR) { + // gold + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD] + < (int)DAT_SentOrRequestedGoodsAmount::instance) { + return; + } + } else { + _space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(playerID, (OpenSHC::Game::Resources::ResourceType)(_resourceType)); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[_resourceType] + < _sendAmount) { + return; + } + if (_space < 0) { + return; + } + if (_space < _sendAmount) { + _sendAmount = _space; + } + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 2; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = _resource; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = _sendAmount; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + } + return; + } + DAT_SentOrRequestedGoodsAmount::instance += 500; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 451fc97dcb..b0198a9d6c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25979,7 +25979,7 @@ SHC_3BB0A8C1_0x004B1410 | 0.0% | Pending SHC_3BB0A8C1_0x004B1471 | 0.0% | Pending -SHC_3BB0A8C1_0x004B14C0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B14C0 | 60.5% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004B18D0 | 0.0% | Pending From 72d2bc16bfd5eeea8648686ad2e5360fca047a7d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:25 +0100 Subject: [PATCH 15/85] reimplement: SHC_3BB0A8C1_0x00438BE0 42.3% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass; the no-unit test uses UT_NONE (header commit). quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...erFunction_BuildMenu_UnitActionButtons.cpp | 314 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 315 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp new file mode 100644 index 0000000000..a63c3e9523 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp @@ -0,0 +1,314 @@ +#include "../BuildMenu.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/Units/Behavior/UnitStanceEnum.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_00ee1090.hpp" +#include "OpenSHC/Globals/DAT_00ee1094.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TribesState.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Map::Units::UnitType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00438BE0 + void BuildMenu::MenuItemRenderFunction_BuildMenu_UnitActionButtons(int mapperValue, ...) + { + BOOLEnum BVar1; + int iVar2; + int yPosition; + uint uVar3; + UnitType UVar4; + int xPosition; + uint color2; + int fontSize; + BVar1 = MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::isMapperAvailable, + DAT_MapPropertiesState::ptr)((OpenSHC::Commands::MappersEnum)mapperValue); + if (!BVar1) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + DAT_ButtonUnknownZero::instance = 0; + switch ((int)DAT_CurrentButtonGmDataIndex::instance) { + case 376: + // the original tail-jumps to the render here (`pop edi; pop esi; jmp` after + // the `cmp [hasEngineerSelected], esi`), so this arm returns rather than + // falling into `case 0x176` and rendering the button a second time + if (DAT_UnitsState::instance.hasEngineerSelected == TRUE) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + return; + } + case 374: + DAT_00ee1094::instance = 291; + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (!DAT_UnitsState::instance.hasEngineerSelected)) { + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); + if (uVar3 != 0) + goto LAB_00438ec1; + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::countSelectedCatapultsAndTrebuchets, + DAT_UnitsState::ptr)(); + if (iVar2 != 0) { + DAT_00ee1094::instance = 308; + DAT_CurrentButtonGmDataIndex::instance = 377; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + } + break; + case 218: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && !DAT_UnitsState::instance.hasEngineerSelected + && (uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getTunnelerIDOnlyIfFirstSelected, + DAT_UnitsState::ptr)(), + uVar3 != 0)) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + break; + case 220: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + || (( + DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + || (DAT_GameState::instance.mapAndTime.skirmishNoCowThrowing == 0)))) + && !DAT_UnitsState::instance.hasEngineerSelected + && (uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, + DAT_UnitsState::ptr)(39, 40), + uVar3 != 0 + && (0 < DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .counter))) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + BVar1 = FALSE; + yPosition = DAT_ButtonY::instance + 2; + xPosition = DAT_ButtonX::instance + 2; + fontSize = 19; + color2 = 0; + uVar3 = 16777215; + iVar2 + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .counter; + LAB_00438e95: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber, DAT_TextManagerObject::ptr)( + iVar2, xPosition, yPosition, uVar3, color2, fontSize, BVar1); + DAT_ButtonUnknownZero::instance = 0; + return; + } + break; + case 219: + DAT_00ee1090::instance = 202; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && !DAT_UnitsState::instance.hasEngineerSelected) { + BVar1 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::selectionContainsEngineersOnly, DAT_UnitsState::ptr)(); + if (BVar1) { + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, + DAT_UnitsState::ptr)(); + if (uVar3 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 210; + DAT_00ee1090::instance = 198; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + } else { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsTunnelersOnly, + DAT_UnitsState::ptr)(); + if (iVar2 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 218; + DAT_00ee1090::instance = 201; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + uVar3 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, + DAT_UnitsState::ptr)(39, 40); + if (uVar3 != 0) { + DAT_CurrentButtonGmDataIndex::instance = 375; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + BVar1 = FALSE; + fontSize = 19; + color2 = 0; + uVar3 = 16777215; + yPosition = DAT_ButtonY::instance + 2; + xPosition = DAT_ButtonX::instance + 2; + iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getMaxStoneAmmoInSelectedSiegeEngines, + DAT_UnitsState::ptr)(); + goto LAB_00438e95; + } + BVar1 + = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsRangedOnlyUnits, + DAT_UnitsState::ptr)(); + if (BVar1) { + DAT_CurrentButtonGmDataIndex::instance = 375; + goto LAB_00438ec1; + } + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsLaddermenOnly, + DAT_UnitsState::ptr)(); + if ((iVar2 == 0) + && (iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::selectionContainsShieldmenOnly, + DAT_UnitsState::ptr)(), + iVar2 == 0)) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + } + } + break; + case 370: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_NONE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_STAND_GROUND) { + DAT_ButtonY::instance -= 5; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + goto LAB_00438f47; + case 371: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_NONE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_DEFENSIVE) { + --DAT_ButtonY::instance; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + goto LAB_00438f47; + case 372: + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_NONE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance + == OpenSHC::Map::Units::Behavior::USE_AGGRESSIVE) { + --DAT_ButtonY::instance; + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + LAB_00438f47: + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + case 216: + if (DAT_UnitsState::instance.hasEngineerSelected) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_NONE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_TribesState::instance.patrolButtonPressed) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + goto LAB_00438ec1; + case 211: + case 212: + case 213: + case 214: + case 215: + case 558: + if (DAT_UnitsState::instance.hasEngineerSelected != TRUE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + uVar3 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); + if (uVar3 == 0) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + goto LAB_00438ec1; + default: + if (DAT_UnitsState::instance.hasEngineerSelected) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + UVar4 = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); + if (UVar4 == OpenSHC::Map::Units::UT_NONE) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + LAB_00438ec1: + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + DAT_ButtonUnknownZero::instance = 0; + return; + } + DAT_ButtonUnknownZero::instance = 1; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b0198a9d6c..bdba537b29 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -12943,7 +12943,7 @@ SHC_3BB0A8C1_0x004387D0 | 0.0% | Pending SHC_3BB0A8C1_0x00438B60 | 0.0% | Pending -SHC_3BB0A8C1_0x00438BE0 | 0.0% | Pending +SHC_3BB0A8C1_0x00438BE0 | 42.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0043907C | 0.0% | Pending From 05a22439b77853263fb397918a31003f264afaf6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:25 +0100 Subject: [PATCH 16/85] reimplement: SHC_3BB0A8C1_0x004B8220 73.5% compiles again, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again (InGameEventUnionVersion using). The %d and empty strings are their string-literals.hpp pointers (copyIntoTextArray takes a char const* now, header commit), the starting resources are indexed by RT_GOLD / RT_PARTIALPITCH; the rest is the mechanical pass. The new event's condition stores name their fields (conditions[k].subType and .enabled) instead of byte offsets, identical code; conditions 5-7 stay written out, since a for loop loses the match (quick_diff 0.6452 -> 0.5879). Co-Authored-By: Claude Opus 5.5 --- ...onHandler_EditScenario_BaseMenuButtons.cpp | 279 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp new file mode 100644 index 0000000000..8b5c5bd4e1 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp @@ -0,0 +1,279 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/ScenarioEvents/InGameEventUnionVersion.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Game/Resources/ResourceType.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_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CopyOfScenarioGold.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" + +#include "stdlib.h" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using Game::ScenarioEvents::InGameEventUnionVersion; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B8220 + void EditScenario::MenuItemActionHandler_EditScenario_BaseMenuButtons(int param_1, ...) + { + char* pcVar1; + InGameEventUnionVersion* pIVar2; + char local_10[12]; + uint local_4; + local_4 = MSVC_SecurityCookie::instance ^ (uint)local_10; + if (DAT_MenuModalComposition1::instance.activeModalDialogID != UI::Enums::MMT_NONE) + goto switchD_004b8254_caseD_0; + switch (param_1) { + case 3: + pcVar1 = MACRO_CALL_MEMBER( + Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); + DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); + if (DAT_MapPropertiesState::instance.year_copy != DAT_MapPropertiesState::instance.SEC_StartingYear) { + DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + } + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); + ; + return; + case 38: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_SIEGE) { + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_TRADER_SETTINGS, FALSE); + ; + return; + } + goto LAB_004b82b4; + case 41: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { + DAT_MapPropertiesState::instance.indexStored = 20; + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(12); + MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5]); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( + local_10); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + DAT_MapPropertiesState::instance.DAT_MapEditorUnitPointsSum + = MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_UNUSED_SIEGE_ATTACKING_FORCEUnk, FALSE); + ; + return; + } + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(12); + MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, + DAT_MapPropertiesState::instance.SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance + .field_0x345c[DAT_MapPropertiesState::instance.indexStored]]); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( + local_10); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_START_GOODS, FALSE); + ; + return; + case 42: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_INVASION) { + DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; + pIVar2 = DAT_MapPropertiesState::instance.scenarioEvents + + DAT_MapPropertiesState::instance.eventsCount; + DAT_MapPropertiesState::instance.editedEventType = 1; + ++DAT_MapPropertiesState::instance.eventsCount; + MACRO_CALL_MEMBER(Game::ScenarioEvents::InGameEventUnionVersion_Func::resetEvent, pIVar2)(); + pcVar1 = MACRO_CALL_MEMBER( + Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); + DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(14); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( + s__005a5339); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(11); + MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year); + MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( + local_10); + DAT_MapPropertiesState::instance.field_0x1356c = 0; + DAT_MapPropertiesState::instance.offset = 0; + DAT_MapPropertiesState::instance.indexStored = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_INVASION, FALSE); + ; + return; + } + break; + case 43: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_JUST_BUILD) { + DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; + pIVar2 = DAT_MapPropertiesState::instance.scenarioEvents + + DAT_MapPropertiesState::instance.eventsCount; + DAT_MapPropertiesState::instance.editedEventType = 3; + ++DAT_MapPropertiesState::instance.eventsCount; + MACRO_CALL_MEMBER( + Game::ScenarioEvents::InGameEventUnionVersion_Func::initializeScenarioEvent, pIVar2)(); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[0] + .enabled = 1; + // a for loop over conditions 5-7 loses the match + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[5] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[6] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[7] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[17] + .subType = 10; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[22] + .value = 5; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.conditions[23] + .value = 5; + pcVar1 = MACRO_CALL_MEMBER( + Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); + DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + DAT_MapPropertiesState::instance.invasionTroopIndex = 0; + DAT_MapPropertiesState::instance.flag = 1; + MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, + DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .header.year); + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); + ; + return; + } + break; + case 61: + if (DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) { + DAT_CopyOfScenarioGold::instance = (int)DAT_GameState::instance.mapAndTime.scenarioGold; + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 10000, + DAT_CopyOfScenarioGold::instance, (undefined*)DAT_CopyOfScenarioGold::ptr, + (void*)MACRO_CALL(UI::Helpers_Func::RestoreScenarioGold)); + DAT_MenuModalComposition2::instance.textIndex = 61; + LAB_004b8756: + DAT_MenuModalComposition2::instance.textGroup = 199; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, + (int)((int)(DAT_ButtonX::instance - 2)), (int)((int)(DAT_ButtonY::instance + 25))); + ; + return; + } + break; + case 79: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_SIEGE) { + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setSliderParameters, + DAT_MenuModalComposition2::ptr)(0, 100, DAT_MapPropertiesState::instance.SEC_StartingPopularity, + (undefined*)((int)(&DAT_MapPropertiesState::instance.SEC_StartingPopularity)), + (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textGroup = 199; + DAT_MenuModalComposition2::instance.textIndex = 79; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, + (int)((int)(DAT_ButtonX::instance - 2)), (int)((int)(DAT_ButtonY::instance + 25))); + ; + return; + } + LAB_004b82b4: + DAT_StopHandlingMenuItems::instance = 0; + ; + return; + case 166: + if ((DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) + && (DAT_GameState::instance.mapAndTime.scenarioRationsSetting + = DAT_GameState::instance.mapAndTime.scenarioRationsSetting + 1, + 4 < DAT_GameState::instance.mapAndTime.scenarioRationsSetting)) { + DAT_GameState::instance.mapAndTime.scenarioRationsSetting = 0; + ; + return; + } + break; + case 167: + if ((DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) + && (DAT_GameState::instance.mapAndTime.scenarioTaxesSetting + = DAT_GameState::instance.mapAndTime.scenarioTaxesSetting + 1, + 9 < DAT_GameState::instance.mapAndTime.scenarioTaxesSetting)) { + DAT_GameState::instance.mapAndTime.scenarioTaxesSetting = 0; + } + break; + case 168: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 10000, + (int)((int)(DAT_MapPropertiesState::instance + .SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD])), + (undefined*)((int)((DAT_MapPropertiesState::instance.SEC_StartingResources + 15))), + (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textIndex = 168; + goto LAB_004b8756; + } + break; + case 169: + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { + MACRO_CALL_MEMBER( + UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 100, + (int)((int)(DAT_MapPropertiesState::instance + .SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH])), + (undefined*)((int)((DAT_MapPropertiesState::instance.SEC_StartingResources + 8))), + (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); + DAT_MenuModalComposition2::instance.textIndex = 169; + goto LAB_004b8756; + } + break; + case 171: + DAT_MapPropertiesState::instance.DAT_BuildingAvailabilityScrollbarOffset = 0; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( + UI::Enums::MMT_BUILDING_AVAILABILITY, FALSE); + ; + return; + case -1: + ++DAT_MapPropertiesState::instance.SEC_StartingMonth; + if (11 < DAT_MapPropertiesState::instance.SEC_StartingMonth) { + DAT_MapPropertiesState::instance.SEC_StartingMonth = 0; + } + DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; + DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; + ; + return; + } + switchD_004b8254_caseD_0:; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bdba537b29..7274328859 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27111,7 +27111,7 @@ SHC_3BB0A8C1_0x004B8200 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B8210 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8220 | 0.0% | Pending +SHC_3BB0A8C1_0x004B8220 | 73.5% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004B88A4 | 0.0% | Pending From c6a037b2bdf4c0b9830bd08e46b18c3df72e6402 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:25 +0100 Subject: [PATCH 17/85] reimplement: SHC_3BB0A8C1_0x00434350 67.1% compiles again, mechanical pass; structure gynt's draft. Compiles at a521bf7bd again (AlphaAndButtonSurface's processBuildingClickBonus and selectUnitAndOpenStatusMenu were renamed). Tab 49 is BMTT_UNKNOWN_49 (header commit); the rest is the mechanical pass (identical code). Co-Authored-By: Claude Opus 5.5 --- ...PeasantBuildAndRightClickMenuSelection.cpp | 271 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp new file mode 100644 index 0000000000..282812529f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp @@ -0,0 +1,271 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Commands/MappersEnum.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.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/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_00b960f8.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_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00b960f0.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00434350 + void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int param_1, ...) + { + DWORD DVar1; + int iVar2; + BOOLEnum BVar3; + dword elementState; + if (DAT_GameSynchronyState::instance.syncStatus != 0) { + return; + } + if (DAT_GameSynchronyState::instance.saveRelated != 0) { + return; + } + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY + && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && DAT_00b960f8::instance != 66) { + if (INT_00b960f0::instance == 0) { + DVar1 = timeGetTime(); + INT_00b960f0::instance = DVar1 + 20000; + } else { + DVar1 = timeGetTime(); + if (1500 < (int)(DVar1 - INT_00b960f0::instance)) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_00b960f8::instance; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameSynchronyState::instance.currentPlayerSlotID; + INT_00b960f0::instance = DVar1; + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_UPDATE_LOBBY_FACE_BITMAPSPECIALTRANSMITLOGIC); + ++DAT_00b960f8::instance; + } + } + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + LAB_004344b0: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, + (dword)((int)(2299 < (int)DAT_UnitsState::instance.unitCount))); + } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + LAB_004344a8: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + goto LAB_004344b0; + } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) + || (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE)) { + if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { + iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID); + if (iVar2 == 0) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab + == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { + if (DAT_GameCore::instance.menuSwitchDelay == -1) { + iVar2 = MACRO_CALL_MEMBER( + OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)(); + if (iVar2 == 1) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + 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); + goto LAB_004344a8; + } + elementState = 1; + goto LAB_00434498; + } + } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab + == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) + goto LAB_00434497; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + } else if (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_UNUSED_WITCHHOIST) { + LAB_00434497: + elementState = 2; + LAB_00434498: + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, (dword)((int)(elementState))); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } + } + goto LAB_004344a8; + } + if (DAT_MouseState::instance.mouseBasedEvent == 1) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 4; + } else if (((!DAT_MouseState::instance.rightClickState) || (DAT_MouseState::instance.mouseBasedEvent == 2)) + && (DAT_ModifierKeyState::instance.ctrl == 0 || (DAT_ModifierKeyState::instance.downArrow == 0)) + && DAT_ModifierKeyState::instance.v == 0) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 5; + } else if (DAT_MouseState::instance.mouseBasedEvent == 3) { + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( + DAT_MouseState::instance.mapOrientationCopy3); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 2; + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)( + (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 3; + } else { + if (DAT_MouseState::instance.mouseBasedEvent != 5) + goto LAB_004345e4; + DAT_MouseState::instance.field_0x19c = 2; + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); + DAT_GameCore::instance.field_0x15c = 1; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) + goto LAB_004345e4; + iVar2 = 17; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(iVar2); + LAB_004345e4: + if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { + if (DAT_MouseState::instance.rightClickStart != 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + DAT_GameCore::instance.field_0x15c = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + } + if (DAT_MouseState::instance.rightClickStart != 0) { + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_MOAT) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + } + DAT_GameCore::instance.field_0x15c = 0; + } else { + if (DAT_MouseState::instance.rightClickStop != 0 + && DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_MOAT + && DAT_GameCore::instance.field_0x15c == 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseTile); + if (!DAT_MouseState::instance.leftClickState) { + if (DAT_UnitsState::instance + .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + <= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::processBuildingClickBonus, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID); + } + if (!DAT_MouseState::instance.draggingStopped) { + return; + } + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + return; + } + } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + if ((DAT_MouseState::instance.leftClickStart == 0) + && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseTile)) { + return; + } + DAT_ViewportRenderState::instance.viewportState.previousMouseTile + = DAT_ViewportRenderState::instance.viewportState.mouseTile; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + } + if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + < 1 + && DAT_UnitsState::instance.totalUnitsInSelection < 1 + && (DVar1 = timeGetTime(), + DAT_MouseState::instance.draggingStopped + && ((((DAT_MouseState::instance.selectionBoxState == 0 + && (DAT_MouseState::instance.savedSelectionBoxState == 0)) + && (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: + selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID), + !BVar3)) + && ((199 < (int)(DVar1 - DAT_ViewportRenderState::instance.viewportState.field_0x34) + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: + selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID), + !BVar3)))))) + && (BVar3 = MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID), + !BVar3 + && (((DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance.viewportState + .mouseAtomRefFloorTile] + & 2) + != 0 + && ((DAT_TileMapState::instance.WallOwnerLayer[DAT_ViewportRenderState::instance + .viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + == DAT_GameSynchronyState::instance.currentPlayerSlotID)))) + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id + != 0) { + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = 11; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_BuildingsState::instance.newSelectedUnitID = 0; + DAT_BuildingsState::instance.newSelectedBuildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 7274328859..ea2e7aa03a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11145,7 +11145,7 @@ SHC_3BB0A8C1_0x00434300 | 0.0% | Pending SHC_3BB0A8C1_0x00434340 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00434350 | 0.0% | Pending +SHC_3BB0A8C1_0x00434350 | 67.1% | compiles again, mechanical pass; structure SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented From ee10c60a99c96c97e0969c0f40633272d8387273 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:25 +0100 Subject: [PATCH 18/85] reimplement: SHC_3BB0A8C1_0x004643F0 49.0% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...mRenderFunction_InGameMenu_MainButtons.cpp | 300 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp new file mode 100644 index 0000000000..8ee64e51bd --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp @@ -0,0 +1,300 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004643F0 + void InGameMenu::MenuItemRenderFunction_InGameMenu_MainButtons(int param_1, ...) + { + ButtonGmData* buttonGmData; + int iVar1; + int iVar2; + int iVar3; + bool bVar4; + iVar3 = 0; + DAT_ButtonUnknownZero::instance = 0; + 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)) + && param_1 != 71 && param_1 != -4 && param_1 <= -10) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.activeMenuTab.tabType == param_1) { + if (param_1 != 71) { + iVar3 = 2; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + goto LAB_00464449; + } + LAB_0046444e: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + } else { + LAB_00464449: + if (param_1 == 71) + goto LAB_0046444e; + } + if (param_1 == -4) { + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + goto LAB_00464732; + } + if (param_1 == -5) { + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + && (DAT_GameCore::instance.field_0x6c != 0)) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } else if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL + || (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk))) { + LAB_004644dc: + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + } else { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) + goto LAB_004644dc; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) { + bVar4 = DAT_GameCore::instance.isSkirmishTrail == TRUE; + goto LAB_004644d6; + } + } + LAB_004645b6: + if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) + && (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM)) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + LAB_004645c8: + if ((param_1 == -90) || (param_1 == -91)) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) + goto LAB_004645f5; + if (param_1 == -90) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = 1; + return; + } + } else { + LAB_004645f5: + if (param_1 == -90) + goto LAB_00464611; + } + if (param_1 == -91 || (10 <= param_1 && (param_1 <= 49))) + goto LAB_00464611; + } else { + if (param_1 <= -10 && param_1 != -90 && param_1 != -91) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (-100 < param_1) { + iVar1 = -9 - param_1; + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION) { + if (5 < iVar1) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + } else if (iVar1 != 1) { + DAT_ButtonUnknownZero::instance = 1; + } + } + if (iVar1 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + iVar3 = 8; + } + } + } + if (param_1 == -1) { + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + if ((DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_QUIT_DIALOG) + && (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47)) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + goto LAB_004645b6; + } + if (param_1 == -6) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + bVar4 = DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT; + LAB_004644d6: + if (!bVar4) + goto LAB_004644dc; + } + goto LAB_004645b6; + } + if ((param_1 == 29) || (param_1 == 26)) { + LAB_004645a4: + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_ButtonUnknownZero::instance = 1; + return; + } + LAB_004645ad: + if ((param_1 <= -1) && (-10 < param_1)) + goto LAB_004645b6; + goto LAB_004645c8; + } + if (param_1 != 27) + goto LAB_004645ad; + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT) + goto LAB_004645a4; + LAB_00464611: + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + } else { + if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) + && (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS)) { + DAT_ButtonUnknownZero::instance = 1; + return; + } + iVar1 + = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, + DAT_GameState::ptr)(); + if (iVar1 < 1 + || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU + && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_STOCKS))) { + if ((param_1 != -90) && (param_1 != -91)) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + iVar3 = 1; + switch (param_1) { + case 10: + iVar3 = 54; + break; + case 20: + iVar3 = 55; + break; + case 40: + iVar3 = 56; + break; + case 30: + iVar3 = 57; + break; + case 28: + iVar3 = 58; + break; + case 25: + iVar3 = 59; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)(DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0), + iVar3, (int)(DAT_ButtonX::instance), DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance = iVar3; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + } + } + if ((param_1 == -2) && (DAT_WallAndPitchState::instance.countdown == 0)) { + DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + iVar3 = 2; + } + LAB_00464732: + buttonGmData = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + iVar2 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, buttonGmData)( + DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)(buttonGmData->gmId_0x0), iVar2 + iVar3, + DAT_ButtonX::instance, DAT_ButtonY::instance); + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4 + + iVar3; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (param_1 == -4) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + DAT_ButtonX::instance - 1, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 1), + (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + DAT_ButtonX::instance - 2, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 2), + (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); + return; + } + if (param_1 == 71) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScribeFrame)(); + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGoldValue)(); + return; + } + 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 ea2e7aa03a..2daf0fa79a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19763,7 +19763,7 @@ SHC_3BB0A8C1_0x00464300 | 0.0% | Pending SHC_3BB0A8C1_0x00464370 | 0.0% | Pending -SHC_3BB0A8C1_0x004643F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004643F0 | 49.0% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0046481C | 0.0% | Pending From 15884ad5390251578d39ce75d2f2055118340d87 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:26 +0100 Subject: [PATCH 19/85] reimplement: SHC_3BB0A8C1_0x004AEA50 71.2% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings); quick_diff output identical. The group maximum and the group count are for loops and the copy of the saved groups is a memcpy (67.4% -> 71.2% in the combined build). Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_Roundtable_Main.cpp | 227 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp new file mode 100644 index 0000000000..3054890ab7 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp @@ -0,0 +1,227 @@ +#include "../Roundtable.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00df423c.hpp" +#include "OpenSHC/Globals/DAT_00df4240.hpp" +#include "OpenSHC/Globals/DAT_00df4298.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/INT_00df4244.hpp" +#include "OpenSHC/Globals/SEC_RNG.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AEA50 + void Roundtable::MenuItemActionHandler_Roundtable_Main(int param_1, ...) + { + BOOLEnum BVar3; + int playerID_01; + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + if (param_1 < 9) { + if (DAT_00df423c::instance != 0) { + param_1 += 10; + } + if (param_1 < 9) { + DAT_00df423c::instance = param_1; + INT_00df4244::instance = 0; + } + } + if ((param_1 - 0xbU < 8) && (DAT_00df423c::instance != 0)) { + int playerID + = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); + playerID_01 + = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]; + if (0 < playerID_01 && 0 < playerID && playerID != playerID_01 + && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_01] != -1 + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID_01), + BVar3)) + && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID] != -1 + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID), + BVar3))) { + int iVar4 = 0; + for (int playerID_00 = 1; playerID_00 < 9; ++playerID_00) { + if ((DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_00] != -1) + || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, + DAT_GameSynchronyState::ptr)(playerID_00), + BVar3)) { + ++iVar4; + } + } + if (2 < iVar4) { + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == 1) + && (DAT_00df4240::instance == 0)) { + if (DAT_GameCore::instance.genieVoiceActive) { + // "Not the rodent" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_13.wav" + s_Genie_13_wav_005a7710); + } + DAT_00df4240::instance = 1; + } + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == 7) + && (DAT_00df4298::instance == 0)) { + if (DAT_GameCore::instance.genieVoiceActive) { + // "Oh no" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_14.wav" + s_Genie_14_wav_005a7700); + } + DAT_00df4298::instance = 1; + } + } + int bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID]; + if ((DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] != bVar1) + || (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] == 0)) { + if (bVar1 == 0) { + bVar1 = 0; + for (int i = 1; i < 9; ++i) { + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i] + && (char)bVar1 < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { + bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]; + } + } + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( + char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] + = bVar1 + 1; + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[*( + char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + + 26)] = bVar1 + 1; + MACRO_CALL_MEMBER( + OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); + BVar3 = MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::shouldSoundXNotBePlaying, + DAT_SoundSystemState::ptr)(); + if (!BVar3 && 2 < iVar4 && DAT_GameCore::instance.genieVoiceActive) { + MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::nextRandomNumber1, SEC_RNG::ptr)(); + switch ((int)SEC_RNG::instance.currentNumber1 % 7) { + case 0: + // "We will be invincible" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_05.wav" + DAT_SFXState::ptr)(s_genie_05_wav_005a76f0); + break; + case 1: + // "A worthy ally" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_06.wav" + DAT_SFXState::ptr)(s_genie_06_wav_005a76e0); + break; + case 2: + // "Watch my back" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_07.wav" + DAT_SFXState::ptr)(s_genie_07_wav_005a76d0); + break; + case 3: + // "Yeeees" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_08.wav" + DAT_SFXState::ptr)(s_genie_08_wav_005a76c0); + break; + case 4: + // "On my honour" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_09.wav" + DAT_SFXState::ptr)(s_genie_09_wav_005a76b0); + break; + case 5: + // "We rule" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_10.wav" + DAT_SFXState::ptr)(s_genie_10_wav_005a76a0); + break; + case 6: + // "I pledge allegiance" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, + // "genie_04.wav" + DAT_SFXState::ptr)(s_genie_04_wav_005a7690); + } + } + } else { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] = bVar1; + MACRO_CALL_MEMBER( + OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); + } + } + } + if ((param_1 - 10 == DAT_00df423c::instance) && (INT_00df4244::instance == 0)) { + INT_00df4244::instance = 1; + } else { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_00df423c::instance = 0; + } + } + if (param_1 == 21) { + if ((DAT_00df423c::instance != 0) + && (DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance] != 0)) { + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( + char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_00df423c::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)( + 7, 0); + } + } else if (param_1 == 100) { + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + int cVar2 = 0; + for (int i = 1; i < 9; ++i) { + if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { + cVar2 += '\x01'; + } + } + if (cVar2 != '\0') { + // "The sides are drawn" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "Genie_02.wav" + s_Genie_02_wav_005a7680); + } + } else { + if (param_1 == 101) { + memcpy(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray, + DAT_GameSynchronyState::instance.playerGroupArray2Unk, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray)); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, + DAT_GameSynchronyState::ptr)(); + } + if (param_1 == 200) { + if (DAT_00df423c::instance != 0) { + DAT_00df423c::instance = 0; + } + } else if (((param_1 == 201) || (param_1 == 202)) && DAT_00df423c::instance != 0 + && (INT_00df4244::instance != 1 || (param_1 == 201))) { + DAT_00df423c::instance = 0; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2daf0fa79a..ef3fdbcfd0 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25879,7 +25879,7 @@ SHC_3BB0A8C1_0x004AE950 | 0.0% | Pending SHC_3BB0A8C1_0x004AEA10 | 0.0% | Pending -SHC_3BB0A8C1_0x004AEA50 | 0.0% | Pending +SHC_3BB0A8C1_0x004AEA50 | 71.2% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004AEB20 | 0.0% | Pending From 61df885052837f629c2923b29708308387b98227 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 13:56:26 +0100 Subject: [PATCH 20/85] reimplement: SHC_3BB0A8C1_0x00461570 40.9% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass; no pending token is HTT_NONE (header commit), and the character tests compare with 32 without a HelpTextToken cast. quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...Handler_TextEditor_TextInputRelatedUnk.cpp | 255 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp new file mode 100644 index 0000000000..f66f9bb327 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp @@ -0,0 +1,255 @@ +#include "../TextEditor.func.hpp" + +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/Util/WideCharMultiByteState.func.hpp" +#include "OpenSHC/Text/Enums/HelpTextToken.hpp" + +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WideCharMultiByteState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Text::Enums::HelpTextToken; + + // FUNCTION: STRONGHOLDCRUSADER 0x00461570 + void TextEditor::MenuItemActionHandler_TextEditor_TextInputRelatedUnk() + { + WCHAR WVar1; + uint uVar2; + int iVar3; + WCHAR* pWVar4; + int iVar5; + int iVar6; + WCHAR* pWVar7; + if (DAT_TextEditorState::instance.useAlternateHelpTab == 0) { + uVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); + if ((int)uVar2 < 240) { + return; + } + switch (uVar2) { + case 245: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - 18) { + iVar3 += 18; + if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + } else { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + return; + case 244: + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (18 <= iVar3) { + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - 18; + return; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + case 246: + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + case 247: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + DAT_TextEditorState::instance.helpContentScrollOffsetY = (iVar5 <= 0) - 1 & iVar5; + return; + case 251: + iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight; + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - DAT_TextEditorState::instance.dialogContentHeight) { + iVar3 += DAT_TextEditorState::instance.dialogContentHeight; + if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + } else { + iVar3 = (iVar5 <= 0) - 1 & iVar5; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + return; + case 250: + iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; + iVar6 = DAT_TextEditorState::instance.dialogContentHeight; + if (iVar3 >= iVar6) { + DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - iVar6; + return; + } + DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; + return; + default: + return; + } + } + uVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + if (uVar2 != -1) { + if ((int)uVar2 < 240) { + if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { + iVar3 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar3; + DAT_TextEditorState::instance.pendingTokenTypeToSkip = (OpenSHC::Text::Enums::HTT_NONE); + } + if ((DAT_TextEditorState::instance.isCustomTextMode != 0) + && (-1 < DAT_TextEditorState::instance.customTextMaxLength)) { + pWVar4 = pWVar7; + do { + WVar1 = *pWVar4; + ++pWVar4; + } while (WVar1 != L'\0'); + if (DAT_TextEditorState::instance.customTextMaxLength <= (int)pWVar4 - (int)(pWVar7 + 1) >> 1) + goto switchD_00461715_caseD_a; + } + LAB_004616f7: + iVar3 = DAT_TextEditorState::instance.customHelpTextLength; + if (DAT_TextEditorState::instance.activeHelpHotspotIndex + <= DAT_TextEditorState::instance.customHelpTextLength) { + do { + pWVar7[iVar3 + 1] = pWVar7[iVar3]; + --iVar3; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + } while (iVar3 >= DAT_TextEditorState::instance.activeHelpHotspotIndex); + } + WVar1 = MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::singleMultiByteToWideChar, + DAT_WideCharMultiByteState::ptr)((char)uVar2); + // put character in memory + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = WVar1; + ++DAT_TextEditorState::instance.customHelpTextLength; + ++DAT_TextEditorState::instance.activeHelpHotspotIndex; + } else { + switch (uVar2) { + case 240: + if (DAT_TextEditorState::instance.isCustomTextMode == 0) { + uVar2 = 9; + goto LAB_004616f7; + } + break; + case 241: + if (DAT_TextEditorState::instance.isCustomTextMode == 0) { + uVar2 = 6; + goto LAB_004616f7; + } + break; + case 242: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 <= 0) + break; + iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3 - 1]; + if (32 <= iVar6) { + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - 1; + break; + } + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - iVar5; + break; + case 243: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 >= DAT_TextEditorState::instance.customHelpTextLength) + break; + iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3]; + if (32 <= iVar6) { + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + 1; + break; + } + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + iVar5; + break; + case 244: + DAT_TextEditorState::instance.field_0x2396c = -1; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::setTextRenderingLogic, DAT_TextEditorState::ptr)(); + break; + case 245: + DAT_TextEditorState::instance.field_0x2396c = 1; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::setTextRenderingLogic, DAT_TextEditorState::ptr)(); + break; + case 246: + DAT_TextEditorState::instance.activeHelpHotspotIndex = 0; + break; + case 247: + DAT_TextEditorState::instance.activeHelpHotspotIndex + = DAT_TextEditorState::instance.customHelpTextLength; + break; + case 248: + iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; + if (iVar3 <= 0) + break; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + iVar6 = pWVar7[iVar3 - 1]; + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); + if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { + iVar6 = (iVar3 - iVar5) * 2; + do { + // delete character in memory + *(WCHAR*)(iVar6 + (int)pWVar7) = pWVar7[iVar3]; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + if (pWVar7[iVar3] == L'') + break; + ++iVar3; + iVar6 += 2; + } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + } + DAT_TextEditorState::instance.customHelpTextLength -= iVar5; + DAT_TextEditorState::instance.activeHelpHotspotIndex -= iVar5; + break; + case 249: + iVar5 = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance + .activeHelpHotspotIndex]); + if (iVar3 < DAT_TextEditorState::instance.customHelpTextLength) { + if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { + iVar6 = (iVar3 + iVar5) * 2; + do { + pWVar7[iVar3] = *(WCHAR*)(iVar6 + (int)pWVar7); + if (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3] == L'\0') + break; + ++iVar3; + iVar6 += 2; + pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; + } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + } + DAT_TextEditorState::instance.customHelpTextLength -= iVar5; + } + } + } + switchD_00461715_caseD_a: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); + } + if ((ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + < 32) { + DAT_TextEditorState::instance.field_0x23970 + = (uint)(ushort)DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex]; + return; + } + DAT_TextEditorState::instance.field_0x23970 = 0; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ef3fdbcfd0..3a73c61e05 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -18835,7 +18835,7 @@ SHC_3BB0A8C1_0x00461520 | 0.0% | Pending SHC_3BB0A8C1_0x00461550 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00461570 | 0.0% | Pending +SHC_3BB0A8C1_0x00461570 | 40.9% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00461750 | 0.0% | Pending From 44e029010035447ce98bfad449831c68b668f22f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:06:12 +0100 Subject: [PATCH 21/85] 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 0a929fa2bc83052e2cad8411d32fcf8cbe3df3e8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:18:58 +0100 Subject: [PATCH 22/85] reimplement: SHC_3BB0A8C1_0x004D8570 64.5% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The PlayerSlotUnitColor copy is a for loop (identical code). Co-Authored-By: Claude Opus 5.5 --- ...ActionHandler_ScenarioDescription_Main.cpp | 218 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..2adaa09db3 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -0,0 +1,218 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00eb0b24.hpp" +#include "OpenSHC/Globals/DAT_00ed2794.hpp" +#include "OpenSHC/Globals/DAT_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_00ed27bc.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" +#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8570 + void ScenarioDescription::MenuItemActionHandler_ScenarioDescription_Main(int param_1, ...) + { + int iVar1; + char local_68[100]; + uint local_4 = MSVC_SecurityCookie::instance ^ (uint)local_68; + if (DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { + switch (param_1) { + case 10: + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + if (DAT_GameCore::instance.gameSuspended == 1) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); + ; + return; + } + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + if (DAT_GameCore::instance.missionNumber1to20 < 1) { + DAT_GameCore::instance.missionNumber1to20 = 1; + return; + } + DAT_GameCore::instance.section1066 = 1; + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 231; + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::loadMissionMapAndSetLord, + DAT_MapPropertiesState::ptr)(DAT_GameCore::instance.missionNumber1to20); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + MACRO_CALL(OpenSHC::Synchrony_Func::SetAIPlayerNickNames)(); + if (16 <= DAT_GameCore::instance.missionNumber1to20) { + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeFinalResultsForActivePlayers, + DAT_GameSynchronyState::ptr)(); + } + } + 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); + MACRO_CALL_MEMBER( + OpenSHC::UI::MenuTextInputState_Func::clearModalDialog2to6, DAT_MenuTextInputState::ptr)(); + DAT_00ed2794::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + ; + return; + case 12: + case 13: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { + case OpenSHC::Map::MT_SIEGE: + DAT_MapMissionType::instance = 2; + break; + case OpenSHC::Map::MT_INVASION: + DAT_MapMissionType::instance = 3; + break; + case OpenSHC::Map::MT_ECONOMIC: + DAT_MapMissionType::instance = 1; + break; + case OpenSHC::Map::MT_JUST_BUILD: + DAT_MapMissionType::instance = 0; + } + if (DAT_GameCore::instance.gameSuspended == 0) { + for (int i = 0; i < 9; ++i) { + DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] + = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE, 0); + ; + return; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = -7; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + ; + } + case 11: + if (DAT_00ed27bc::instance == 1) { + DAT_00ed27bc::instance = 0; + ; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, + DAT_SoundSystemState::ptr)(); + if (DAT_GameCore::instance.gameSuspended == 0) { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_SELECT, 0); + ; + return; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk, 0); + ; + } + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 1000; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + ; + return; + case 6: + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { + DAT_00ed2798::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + ; + } + break; + case 8: + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { + DAT_00ed2798::instance = 2; + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, + DAT_TextEditorState::ptr)(); + ; + } + break; + case 9: + if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { + DAT_00ed2798::instance = 3; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + // "mission%d.hlp" + local_68, s_mission_d_hlp_005aaf7c, DAT_GameCore::instance.missionNumber1to20); + iVar1 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, + DAT_TextEditorState::ptr)(local_68); + MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::openScenarioHelpDialog, + DAT_TextEditorState::ptr)(iVar1); + ; + } + break; + case -1: + if (DAT_00ed2798::instance == 0 + && (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) + && DAT_GameCore::instance.gameSuspended == 0) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (3 < DAT_GameState::instance.mapAndTime.difficulty) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + DAT_GameCore::instance.missionDifficulty = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + ; + return; + } + DAT_GameCore::instance.missionDifficulty2 = DAT_GameState::instance.mapAndTime.difficulty; + MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); + ; + } + case -2: + DAT_00ed27bc::instance = 1; + ; + return; + case -3: + DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, + DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); + ; + return; + case -4: + ++DAT_00eb0b24::instance; + if ((int)DAT_00eb0b24::instance >= INT_00ed27c4::instance) { + DAT_00eb0b24::instance = 0; + } + break; + } + }; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3a73c61e05..9f42f9cc63 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35929,7 +35929,7 @@ SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending SHC_3BB0A8C1_0x004D839E | 0.0% | Pending -SHC_3BB0A8C1_0x004D8570 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8570 | 64.5% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004D89CC | 0.0% | Pending From 09e4dd8e3ac3e890e14bc0571c8f0b35bc2b0676 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:18:58 +0100 Subject: [PATCH 23/85] reimplement: SHC_3BB0A8C1_0x004AD920 53.3% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...unction_AlliesSendAndRequestGoods_Main.cpp | 221 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp new file mode 100644 index 0000000000..017608c9a8 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp @@ -0,0 +1,221 @@ +#include "../AlliesSendAndRequestGoods.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering.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/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.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_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" +#include "OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::DE::SHCDE::eTextSections; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004AD920 + void AlliesSendAndRequestGoods::MenuItemRenderFunction_AlliesSendAndRequestGoods_Main(int actionParam, ...) + { + int iVar1; + int iVar2; + int iVar3; + int iVar4; + eTextSections offsetIndex; + BOOLEnum keepOffsetX; + // first render resource type in condensed form + if (actionParam < 20) { + int _xOffset = 0; + if (actionParam == 6 || actionParam == 11 || actionParam == 20) { + _xOffset = 8; + } + // skip unusable resources + if (4 <= actionParam) { + ++actionParam; + } + if (6 <= actionParam) { + ++actionParam; + } + if (actionParam == 14) { + actionParam = 23; + } + int _gmID = actionParam * 2 + 617; + if (DAT_ButtonCurrentlyInteracting::instance) { + _gmID = actionParam * 2 + 618; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, _gmID, + DAT_ButtonX::instance + _xOffset, (int)(DAT_ButtonY::instance)); + if (actionParam == 7) { + actionParam = 6; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[actionParam + 1], + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_CENTER, + 12775659, 0, 19, FALSE, 0); + } else if (actionParam == 21) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + iVar1 = 645; + } else { + iVar1 = 646; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD], + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 20), OpenSHC::Text::TTA_CENTER, + 12775659, 0, 19, FALSE, 0); + return; + } + iVar1 = DAT_ButtonX::instance; + int iVar5 = DAT_ButtonY::instance; + // then draw the rest + if (actionParam == 40) { + // everything below belongs to actionParam == 40 only + if (0 < (int)DAT_ButtonH::instance) { + for (int iVar2 = 0; iVar2 < (int)DAT_ButtonH::instance; iVar2 = iVar2 + 24) { + if (iVar2 == 0) { + iVar3 = 1; + } else { + if (iVar2 == DAT_ButtonH::instance - 24) { + iVar3 = 13; + } else { + iVar3 = 7; + } + } + iVar4 = 0; + do { + int imageID = iVar3; + if (iVar4 == 0) { + LAB_004adacf: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + imageID, iVar4 + iVar1, iVar2 + iVar5, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + imageID + 3, 0); + } else { + if (iVar4 == 528) { + imageID = iVar3 + 2; + goto LAB_004adacf; + } + if (iVar3 != 7) { + imageID = iVar3 + 1; + goto LAB_004adacf; + } + return; + } + iVar4 += 24; + } while (iVar4 < 552); + } + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + iVar1 + 24, iVar5 + 24, iVar1 + 527, DAT_ButtonH::instance - 25 + iVar5, 20); + if (DAT_RequestedGoodsByWhoArray::instance[0] == 6) { + iVar1 = 7; + LAB_004adb48: + if (DAT_SentOrRequestedGoodsAmount::instance != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_SentOrRequestedGoodsAmount::instance, (int)(DAT_ButtonX::instance + 36), + (int)(DAT_ButtonY::instance + 36), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, + (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 46 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 24)); + keepOffsetX = TRUE; + iVar1 = DAT_ButtonX::instance + 96; + iVar5 = DAT_RequestedGoodsByWhoArray::instance[0] + 1; + offsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; + goto LAB_004adbc8; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, + (int)(DAT_ButtonX::instance + 36), (int)(DAT_ButtonY::instance + 24)); + iVar1 = DAT_ButtonX::instance + 84; + iVar5 = 14; + } else { + iVar1 = DAT_RequestedGoodsByWhoArray::instance[0]; + if (0 < DAT_RequestedGoodsByWhoArray::instance[0]) + goto LAB_004adb48; + iVar1 = DAT_ButtonX::instance + 36; + iVar5 = 13; + } + keepOffsetX = FALSE; + offsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; + LAB_004adbc8: + iVar2 = DAT_ButtonY::instance + 36; + iVar4 = 0; + iVar3 = 17; + // added by script: "Choose Goods" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(offsetIndex, iVar5), + iVar1, iVar2, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, iVar3, keepOffsetX, + iVar4); + return; + } + if (100 <= actionParam) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); + return; + } + // the original ends this bound with `jl`, so 0x32 is inside it; written as + // `50 <` the `actionParam == 0x32` test below could never be true + if (50 <= actionParam) { + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (actionParam == 50) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(10, + (int)(DAT_ButtonX::instance + 18), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 51) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(25, + (int)(DAT_ButtonX::instance + 15), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 52) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(100, + (int)(DAT_ButtonX::instance + 12), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 53) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(5, + (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 54) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(500, + (int)(DAT_ButtonX::instance + 11), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9f42f9cc63..b9e08aa3f3 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25811,7 +25811,7 @@ SHC_3BB0A8C1_0x004AD780 | 0.0% | Pending SHC_3BB0A8C1_0x004AD7C0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AD920 | 0.0% | Pending +SHC_3BB0A8C1_0x004AD920 | 53.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004ADD90 | 0.0% | Pending From dcaa477ea6129603a73fa8855e1fef896f234c5c Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:18:59 +0100 Subject: [PATCH 24/85] reimplement: SHC_3BB0A8C1_0x0042D140 46.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 214 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp new file mode 100644 index 0000000000..3e9b803e45 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,214 @@ +#include "../SinglePlayerMapChoice.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/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_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042D140 + void SinglePlayerMapChoice::MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands(int param_1, ...) + { + int iVar1; + int yParam; + uint uVar2; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + switch (param_1) { + case -10: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -11: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -100: + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case -101: + // scroll arrows + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, + DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 2: + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 /= 32; + break; + case 69: + if (DAT_MapMissionType::instance == 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + if (DAT_ButtonCurrentlyInteracting::instance) { + // Difficulty + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, (iVar1 / 32) + 32); + } else { + // Difficulty + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, + 12775659, 18, FALSE, (iVar1 / 32) + 32); + } + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "easy, normal, hard, very hard" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE, (iVar1 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 74: + if (DAT_MapMissionType::instance != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerSlotID != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if ((DAT_SH1_SiegeAdvancedMode::instance != 0) && (DAT_00b960dc::instance == 0)) { + DAT_ButtonCurrentlyInteracting::instance = TRUE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = (iVar1 / 32) + 32; + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + yParam = DAT_ButtonY::instance + 7; + goto LAB_0042d4cd; + } + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + // "Advanced" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, + (iVar1 / 32) + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 += (iVar1 >> 0x1f & 0x1fU); + uVar2 = 12775659; + goto LAB_0042d4c2; + case 77: + if (DAT_MapMissionType::instance != 2) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { + param_1 = 78; + } + if (DAT_GameCore::instance.mapU4Int1_2 != 0) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 = (iVar1 / 32) + 32; + uVar2 = 12775659; + yParam = DAT_ButtonY::instance + 7; + goto LAB_0042d4cd; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; + iVar1 += (iVar1 >> 0x1f & 0x1fU); + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + LAB_0042d4c2: + yParam = DAT_ButtonY::instance + 7; + iVar1 = (iVar1 >> 5) + 32; + LAB_0042d4cd: + // "Attacking" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), yParam, OpenSHC::Text::TTA_CENTER, uVar2, + 18, FALSE, iVar1); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + case 65: + iVar1 = 32; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < 0) { + iVar1 = 16; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + iVar1 *= 32 - DAT_ButtonBackgroundBlendStrength::instance; + iVar1 = -(iVar1 / 32); + break; + default: + goto switchD_0042d163_caseD_ffffff9d; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)(iVar1 + 32); + switchD_0042d163_caseD_ffffff9d: + 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 b9e08aa3f3..d725b19008 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7481,7 +7481,7 @@ SHC_3BB0A8C1_0x0042D138 | 0.0% | Pending SHC_3BB0A8C1_0x0042D13C | 0.0% | Pending -SHC_3BB0A8C1_0x0042D140 | 0.0% | Pending +SHC_3BB0A8C1_0x0042D140 | 46.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0042D554 | 0.0% | Pending From c792435b5999b53be6e78b37f84ab972630aaaec Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:18:59 +0100 Subject: [PATCH 25/85] reimplement: SHC_3BB0A8C1_0x00440A50 46.3% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...ctionHandler_LobbyMenu_MapSelectHeader.cpp | 218 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp new file mode 100644 index 0000000000..726745dd0c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp @@ -0,0 +1,218 @@ +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" + +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapNameCache.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/INT_00b95ab8.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00440A50 + void LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader(int param_1, ...) + { + int iVar1; + int iVar2; + int iVar3; + int iVar4; + uint uVar5; + uint uVar6; + int iVar7; + int iVar8; + int iVar9; + iVar8 = param_1; + iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; + DAT_GameSynchronyState::instance.mapExistenceAckCountdown = 0; + if (param_1 < 0) { + iVar1 = -param_1; + if (param_1 == -1) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; + iVar1 = 0; + } else if (param_1 == -2) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; + iVar1 = 0; + } else if (param_1 == -3) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; + iVar1 = 2; + } else if (param_1 == -4) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; + iVar1 = 2; + } else if (4 < iVar1) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar1 - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 4) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 11; + } + iVar1 = 1; + } + } else { + if (DAT_00b960dc::instance != 0) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { + return; + } + iVar1 = param_1; + if (DAT_MenuModalComposition1::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { + return; + } + } + // the original dispatches the sort column with a `sub eax, K; je` chain + // (0x440a9e), MSVC's sparse switch, and the arm bodies sit in the order + // 2, 1, 0 + switch (iVar1) { + case 2: + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 3) { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (DAT_GameSynchronyState::instance.mapBalanceArray[iVar4] + < DAT_GameSynchronyState::instance.mapBalanceArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[iVar3 + 1]]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; + } else { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (DAT_GameSynchronyState::instance + .mapBalanceArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]] + < DAT_GameSynchronyState::instance.mapBalanceArray[iVar4]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; + } + break; + case 1: + if ((int)DAT_GameSynchronyState::instance.lobbyMapSortOrder < 5) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; + } + param_1 = 7; + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + do { + iVar3 = DAT_GameSynchronyState::instance.lobbyMapSortOrder - 5; + do { + iVar9 = 0; + iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; + for (iVar4 = 0; iVar4 < iVar1; ++iVar4) { + iVar2 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4]; + uVar5 = (DAT_GameSynchronyState::instance.mapPlayerCountArray[iVar2] + iVar3) % 8; + uVar6 + = (DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[iVar4 + 1]] + + iVar3) + % 8; + if ((int)uVar6 < (int)uVar5) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1] = iVar2; + ++iVar9; + } + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + } + iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; + iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; + } while (iVar9 != 0); + --param_1; + DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar7 + 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 12) { + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; + } + } while ((DAT_GameSynchronyState::instance + .mapPlayerCountArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[0]] + != 13 - iVar7) + && (0 < param_1)); + break; + case 0: + iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; + if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 1) { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if (iVar4 < (int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; + } else { + do { + iVar7 = 0; + for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { + iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; + if ((int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] < iVar4) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] + = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; + ++iVar7; + } + } + } while (iVar7 != 0); + DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; + } + break; + } + if (0 <= iVar8) { + INT_00b95ab8::instance = 1; + MACRO_CALL(OpenSHC::UI::MenuItems::LobbyMenu_Func::MenuItemActionHandler_LobbyMenu_MapSelectTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + return; + } + iVar8 = 0; + if (0 < iVar2) { + while (MACRO_CALL(OpenSHC::OS_Func::__stricmp)(DAT_MapNameCache::instance, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar8])) + != 0) { + ++iVar8; + if (iVar8 >= (int)DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { + return; + } + } + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = 0; + if (iVar8 < 0) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 0; + return; + } + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = iVar8; + if (7 < iVar8) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8 - 7; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 7; + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index d725b19008..5ad04e9e31 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13661,7 +13661,7 @@ SHC_3BB0A8C1_0x004409B4 | 0.0% | Pending SHC_3BB0A8C1_0x004409C0 | 0.0% | Pending -SHC_3BB0A8C1_0x00440A50 | 0.0% | Pending +SHC_3BB0A8C1_0x00440A50 | 46.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00440AE0 | 0.0% | Pending From 1fa7012e8e2f2409a3e760c638f337f616154afa Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:18:59 +0100 Subject: [PATCH 26/85] reimplement: SHC_3BB0A8C1_0x004D8250 42.4% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_ScenarioDescription_Main.cpp | 220 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp new file mode 100644 index 0000000000..f98fff6c1a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -0,0 +1,220 @@ +#include "../ScenarioDescription.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode2.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_00ed2798.hpp" +#include "OpenSHC/Globals/DAT_00ed27bc.hpp" +#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8250 + void ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main(int param_1, ...) + { + bool bVar1; + uint uVar2; + DAT_ButtonUnknownZero::instance = 1; + DAT_StopHandlingMenuItems::instance = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && param_1 != 10 && param_1 != 12 + && param_1 != 13 && param_1 != -3 && param_1 != -4 && param_1 != -1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if ((DAT_00ed27bc::instance == 1) && (param_1 != 12)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (param_1 == -1) { + if ((DAT_00ed2798::instance) && (DAT_00ed2798::instance != 1)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.missionNumber1to20 < 4) { + return; + } + } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk)) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.mapU4Int1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameSuspended == 1) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = 12775659; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, uVar2, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE); + return; + } + if (param_1 == -2) { + if (DAT_00ed2798::instance) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_00ed27bc::instance) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = 12775659; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (param_1 == -3) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameSuspended != 1) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = 12775659; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (param_1 == -4) { + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (INT_00ed27c4::instance < 2) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar2 = 12775659; + } else { + uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); + return; + } + if (((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) + && DAT_00ed27bc::instance != 1) { + if (param_1 == 12) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + LAB_004d8543: + if (param_1 == 13) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + goto LAB_004d8563; + if (param_1 == 12) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + bVar1 = param_1 == 13; + } else { + if (param_1 == 11) { + DAT_StopHandlingMenuItems::instance = 0; + DAT_ButtonUnknownZero::instance = 1; + return; + } + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) + || (DAT_GameCore::instance.gameSuspended != 1)) + goto LAB_004d8543; + bVar1 = param_1 == 12; + } + if (bVar1) { + DAT_ButtonUnknownZero::instance = 1; + DAT_StopHandlingMenuItems::instance = 0; + return; + } + LAB_004d8563: + DAT_ButtonUnknownZero::instance = 0; + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 5ad04e9e31..62570200ff 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35925,7 +35925,7 @@ SHC_3BB0A8C1_0x004D8228 | 0.0% | Pending SHC_3BB0A8C1_0x004D822C | 0.0% | Pending -SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8250 | 42.4% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004D839E | 0.0% | Pending From 5b1ec3bad4a3f943d0af7ca02452f0f37cfa1667 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:19:00 +0100 Subject: [PATCH 27/85] reimplement: SHC_3BB0A8C1_0x004C0860 62.3% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_NewEventAction_Main.cpp | 210 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp new file mode 100644 index 0000000000..a508d2726c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp @@ -0,0 +1,210 @@ +#include "../NewEventAction.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.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/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonUnknownZero.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_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C0860 + void NewEventAction::MenuItemRenderFunction_NewEventAction_Main(int param_1, ...) + { + int textNumInGroup; + int iVar2 = -1; + DAT_ButtonUnknownZero::instance = 0; + int iVar1 = param_1; + switch (param_1) { + case 37: + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + return; + case 38: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == 27) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1 + 2); + } + break; + case 39: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == 26) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1 + 1); + } + break; + case 40: + if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType + == 2) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + } + break; + default: + DAT_ButtonUnknownZero::instance = 0; + return; + case 177: + case 178: + case 179: + case 180: + case 181: + case 182: + case 183: + case 184: + case 185: + case 186: + case 187: + iVar1 = 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: + if (param_1 == 148) { + iVar2 = 0; + textNumInGroup = 146; + } else { + textNumInGroup = param_1; + if (param_1 == 146) { + iVar2 = 2; + } + } + if (iVar1 - 128 + == DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.ScenarioEventType) { + 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, textNumInGroup, (int)(DAT_ButtonX::instance + 14), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + if (0 <= iVar2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // " - " + DAT_TextManagerObject::ptr)(S___005A2304, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 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, iVar2 + 128, + (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 23 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 3)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + if ((DAT_MapPropertiesState::instance.sliderPopupDelay != 0) + && (DAT_MapPropertiesState::instance.sliderPopupDelay + = DAT_MapPropertiesState::instance.sliderPopupDelay - 1, + DAT_MapPropertiesState::instance.sliderPopupDelay == 0)) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, + (int)(DAT_MapPropertiesState::instance.sliderPopupX), + (int)(DAT_MapPropertiesState::instance.sliderPopupY)); + } + switch (param_1) { + case 132: + case 139: + case 145: + case 146: + case 148: + case 179: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData, + (int)(DAT_ButtonW::instance - 14 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + default: + return; + case 178: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "%" + DAT_TextManagerObject::ptr)(S_PERCENTAGE_005A2770, + (int)(DAT_ButtonW::instance - 14 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data.scenario.actionData, + (int)(DAT_ButtonW::instance - 28 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + } else { + 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, textNumInGroup, (int)(DAT_ButtonX::instance + 14), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + if (iVar2 < 0) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // " - " + S___005A2304, (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), + OpenSHC::Text::TTA_LEFT, 12775659, 18, TRUE, 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, iVar2 + 128, + (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 23 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 3)); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + DAT_ButtonUnknownZero::instance = 1; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 62570200ff..c9a2d3000d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -32765,7 +32765,7 @@ SHC_3BB0A8C1_0x004C085C | 0.0% | Pending SHC_3BB0A8C1_0x004C085D | 0.0% | Pending -SHC_3BB0A8C1_0x004C0860 | 0.0% | Pending +SHC_3BB0A8C1_0x004C0860 | 62.3% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004C0BF8 | 0.0% | Pending From 7b18743eda1f927b78ef99cd761aa9da3721d3f8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:19:00 +0100 Subject: [PATCH 28/85] reimplement: SHC_3BB0A8C1_0x004C0CF0 53.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ..._SiegeAttackingForceAndStartGoods_Main.cpp | 192 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp new file mode 100644 index 0000000000..e108f8d3b7 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp @@ -0,0 +1,192 @@ +#include "../SiegeAttackingForceAndStartGoods.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/Map/MapType2.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_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" +#include "OpenSHC/Globals/PTR_ARRAY_Unknown_UnitGMHeights.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004C0CF0 + void SiegeAttackingForceAndStartGoods::MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main( + int param_1, ...) + { + int iVar2; + uint uVar4; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (param_1 < 0) { + int iVar1 = -param_1; + int iVar3 = iVar1 - 1; + if (iVar3 < 20) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + 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::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingResources + [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingResources + [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + iVar1 = DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3] * 2 + 141; + if (iVar1 == 157) { + iVar1 = 155; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, + (int)(DAT_ButtonX::instance + 10), + (DAT_ButtonY::instance + - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance + + (GMFirstPictureIndex::instance[46] + iVar1) * 16 + 114) + / 2) + + 15); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + if (iVar3 < 30) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + uVar4 = 12775659; + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + } else { + uVar4 = OpenSHC::Rendering::Colors::COL_CCFAFF; + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(iVar2, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, uVar4, 18, FALSE, 0); + iVar2 = iVar1 - 20; + if (iVar3 == 29) { + iVar2 = iVar1 - 19; + } + } else { + if (iVar3 == 30) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + } else { + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (iVar1 > 9 - 0x29U) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + iVar2 = iVar1 - 29; + if (iVar3 == 45) { + iVar2 = 10; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, iVar2, + (int)(DAT_ButtonX::instance), + (DAT_ButtonY::instance + - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance + + (GMFirstPictureIndex::instance[174] + iVar2) * 16 + 114) + / 2) + + 15); + 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 (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), + OpenSHC::UI::Enums::RBERL_SLIGHT); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), + (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), + (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), 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 c9a2d3000d..ad70c54ec1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -33185,7 +33185,7 @@ SHC_3BB0A8C1_0x004C0CE6 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending -SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending +SHC_3BB0A8C1_0x004C0CF0 | 53.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004C1070 | 0.0% | Pending From 0a2494864aee6f35be49a957aa8e85c5b332a251 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:19:00 +0100 Subject: [PATCH 29/85] reimplement: SHC_3BB0A8C1_0x004649D0 43.9% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, prefix steps, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. The cost tests are for loops (identical code). Co-Authored-By: Claude Opus 5.5 --- ...dStatusMenu_BarracksWeaponAvailability.cpp | 176 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp new file mode 100644 index 0000000000..925487a73f --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp @@ -0,0 +1,176 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_00df3350.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_EnoughGoldForRequestedUnit.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/DAT_UnitPropertiesDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004649D0 + void BuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability( + int param_1, ...) + { + ButtonGmData* pBVar1; + int sVar2; + bool bVar3; + int iVar4; + int iVar8; + int iVar9; + bVar3 = false; + if (param_1 == -1) { + if ((!DAT_EnoughGoldForRequestedUnit::instance) + || (DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c == 0)) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } else { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // the original tests each cost with a one-armed if setting the flag + // (0x464a14..0x464a41), then branches on the flag once + if (0 <= (int)DAT_00df3350::instance) { + for (int i = 0; i < 4; ++i) { + if (DAT_UnitPropertiesDefinedData::instance.EuroUnitResourceCosts[DAT_00df3350::instance][i] + == -1) { + bVar3 = true; + } + } + } + if (bVar3) { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + + DAT_CurrentButtonGmDataIndex::instance; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + pBVar1)(DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 287, iVar8, iVar9); + sVar2 = (ushort)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availableHorses; + if (sVar2 != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(sVar2, (int)(DAT_ButtonX::instance + 8), + (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + } + } else if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availableHorses + != 0) { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + + DAT_CurrentButtonGmDataIndex::instance; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, + pBVar1)(DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4, iVar8, iVar9); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + (int)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .availableHorses, + (int)(DAT_ButtonX::instance + 8), (int)(DAT_ButtonY::instance + 40), + OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + } else { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + + DAT_CurrentButtonGmDataIndex::instance; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 = MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)(FALSE); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 9, iVar8, iVar9); + } + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + } + if ((!DAT_EnoughGoldForRequestedUnit::instance) + || (DAT_GameState::instance.mapAndTime.euroRecruitable[param_1 - 10] == 0)) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (0 <= (int)DAT_00df3350::instance) { + for (int i = 0; i < 3; ++i) { + if (DAT_UnitPropertiesDefinedData::instance.EuroUnitResourceCosts[DAT_00df3350::instance][i] + == param_1) { + bVar3 = true; + } + } + } + if (bVar3) { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)( + DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 287, iVar8, iVar9); + iVar8 = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[param_1]; + if (iVar8 != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(iVar8, (int)(DAT_ButtonX::instance + 8), + (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + } + } else if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[param_1] + != 0) { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)( + DAT_ButtonCurrentlyInteracting::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4, iVar8, iVar9); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[param_1], + (int)(DAT_ButtonX::instance + 8), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, + FALSE, 0); + } else { + pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + iVar8 = DAT_ButtonX::instance; + iVar9 = DAT_ButtonY::instance; + iVar4 + = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)(FALSE); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 9, iVar8, iVar9); + } + DAT_CurrentButtonPictureInGm::instance + = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .pictureInGm_0x4; + 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 ad70c54ec1..a52e85b229 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19845,7 +19845,7 @@ SHC_3BB0A8C1_0x00464860 | 0.0% | Pending SHC_3BB0A8C1_0x004649C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004649D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004649D0 | 43.9% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00464D90 | 100.0% | Reimplemented From 751edebb48e6ed5b9b1c75226af599f22d0a6383 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:23:36 +0100 Subject: [PATCH 30/85] 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 f2bde296b3eb427828e8c5c9bc743f54809de1e4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:37:14 +0100 Subject: [PATCH 31/85] headers: ChooseNetworkServiceProviderButtonActions gets its negative actions The service-provider screen's handler also takes -1 and -2 (scroll the provider list up and down), -10 (GameSpy Arcade), -1000 (next stored IP address) and -10000 (leaves like EXIT). Named by what the handler does, with the Unk suffix. Co-Authored-By: Claude Opus 5.5 --- .../ChooseNetworkServiceProviderButtonActions.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp b/src/OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp index 9cab6397f7..61d063b8a2 100644 --- a/src/OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp +++ b/src/OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp @@ -13,6 +13,11 @@ namespace UI { namespace ChooseNetworkServiceProvider { typedef enum ChooseNetworkServiceProviderButtonActions { + CNSPBA_EXIT_ALTUnk = -10000, // 0xFFFFD8F0 + CNSPBA_NEXT_IP_ADDRESSUnk = -1000, // 0xFFFFFC18 + CNSPBA_GAMESPY_ARCADEUnk = -10, // 0xFFFFFFF6 + CNSPBA_SCROLL_DOWNUnk = -2, // 0xFFFFFFFE + CNSPBA_SCROLL_UPUnk = -1, // 0xFFFFFFFF CNSPBA_EXIT = 3, // 0x00000003 CNSPBA_HOST_GAME = 7, // 0x00000007 CNSPBA_JOIN_GAME = 8 // 0x00000008 From 306a61abc7fb6886e9db869fb355c6eebb42f326 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:10 +0100 Subject: [PATCH 32/85] reimplement: SHC_3BB0A8C1_0x004909E0 79.4% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass; the negative actions have names (header commit), the stored IP addresses are ipRelatedArray[ipArrayIndex] instead of a raw address, and the player-name clear uses sizeof. quick_diff 0.9095 -> 0.9138. The row shift of the stored IP addresses is a memcpy per row plus a memset, which compiles to the original's dword moves and its `xor eax, eax` zeroing (77.5% -> 79.4% in the combined build). Co-Authored-By: Claude Opus 5.5 --- ...r_ChooseNetworkServiceProvider_Buttons.cpp | 201 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp new file mode 100644 index 0000000000..9f29cf886a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp @@ -0,0 +1,201 @@ +#include "../ChooseNetworkServiceProvider.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::UI::ChooseNetworkServiceProvider::ChooseNetworkServiceProviderButtonActions; + + // FUNCTION: STRONGHOLDCRUSADER 0x004909E0 + void ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons( + ChooseNetworkServiceProviderButtonActions param_1, ...) + { + char cVar1; + char* pcVar2; + char* pcVar3; + int iVar4; + char (*pacVar5)[20]; + char (*pacVar6)[20]; + char (*pacVar7)[250]; + switch (param_1) { + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_NEXT_IP_ADDRESSUnk: + MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, DAT_UserTextHandlerState::ptr)( + 5, DAT_GameSynchronyState::instance.ipRelatedArray[DAT_GameSynchronyState::instance.ipArrayIndex]); + iVar4 = DAT_GameSynchronyState::instance.ipArrayIndex + 1; + DAT_GameSynchronyState::instance.ipArrayIndex = iVar4; + if (4 <= iVar4) { + DAT_GameSynchronyState::instance.ipArrayIndex = 0; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_GAMESPY_ARCADEUnk: + if (DAT_GameSynchronyState::instance.gameSpyArcadeAvailable != 0) { + DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; + DAT_GameSynchronyState::instance.openOnClose = TRUE; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_DOWNUnk: + if (DAT_GameSynchronyState::instance.scrollBarItemOffset + < DAT_GameSynchronyState::instance.scrollBarItemCount - 4) { + ++DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_UPUnk: + if (0 < DAT_GameSynchronyState::instance.scrollBarItemOffset) { + --DAT_GameSynchronyState::instance.scrollBarItemOffset; + } + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_JOIN_GAME: + DAT_GameSynchronyState::instance.isHost = FALSE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + if (DAT_GameCore::instance.activeMenuTab.tabType + == OpenSHC::UI::Enums::BASMTT_GRANARY_OR_MPMENU_TCPIP) { + pcVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5); + pcVar3 = pcVar2 + 1; + do { + cVar1 = *pcVar2; + ++pcVar2; + } while (cVar1 != '\0'); + if (pcVar2 != pcVar3) { + pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray; + do { + pacVar5 = pacVar6; + pcVar3 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5); + iVar4 = MACRO_CALL(OpenSHC::OS_Func::__stricmp)(pcVar3, (char const*)((int)(*pacVar5))); + if (iVar4 == 0) + goto LAB_00490c30; + ++pacVar6; + } while ((int)pacVar6 < (int)&DAT_GameSynchronyState::instance + 1088908); + iVar4 = 0; + pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray; + do { + pacVar5 = pacVar6; + do { + pcVar3 = *pacVar5; + pacVar5 = (char (*)[20])(*pacVar5 + 1); + } while (*pcVar3 != '\0'); + if (pacVar5 == (char (*)[20])(*pacVar6 + 1)) { + pcVar3 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(5); + pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray + iVar4; + do { + cVar1 = *pcVar3; + (*pacVar6)[0] = cVar1; + ++pcVar3; + pacVar6 = (char (*)[20])(*pacVar6 + 1); + } while (cVar1 != '\0'); + goto LAB_00490c30; + } + ++pacVar6; + ++iVar4; + } while ((int)pacVar6 < (int)&DAT_GameSynchronyState::instance + 1088908); + // memcpy and memset compile to the original's dword moves + for (int row = 0; row < 3; ++row) { + memcpy(DAT_GameSynchronyState::instance.ipRelatedArray[row], + DAT_GameSynchronyState::instance.ipRelatedArray[row + 1], + sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[row])); + } + memset(DAT_GameSynchronyState::instance.ipRelatedArray[3], 0, + sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[3])); + pcVar3 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5); + pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray + 3; + do { + cVar1 = *pcVar3; + (*pacVar6)[0] = cVar1; + ++pcVar3; + pacVar6 = (char (*)[20])(*pacVar6 + 1); + } while (cVar1 != '\0'); + } + } + LAB_00490c30: + iVar4 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE); + if (0 <= iVar4) { + DAT_GameSynchronyState::instance.unkEnumerationRelatedBool = false; + DAT_GameSynchronyState::instance.scrollBarIndex = -1; + DAT_GameSynchronyState::instance.scrollBarItemOffset = 0; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::restartDPlaySessionEnumeration, + DAT_GameSynchronyState::ptr)(FALSE); + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_FINDING_NETWORK_SESSIONS, FALSE); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_HOST_GAME: + DAT_GameSynchronyState::instance.isHost = TRUE; + DAT_GameSynchronyState::instance.kickedAtTime = 0; + iVar4 = MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, + DAT_GameSynchronyState::ptr)(FALSE); + if (0 <= iVar4) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + DAT_GameSynchronyState::instance.field_0x106ee4 = 1; + DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_LOBBY_MENU, 0); + MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); + Menu_LobbyMenu::instance.thousand = 0; + MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, + sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); + pcVar3 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0); + pacVar7 = DAT_GameSynchronyState::instance.DAT_PlayerNames + 1; + do { + cVar1 = *pcVar3; + (*pacVar7)[0] = cVar1; + ++pcVar3; + pacVar7 = (char (*)[250])(*pacVar7 + 1); + } while (cVar1 != '\0'); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::waitForMultiplayerHost, + DAT_GameSynchronyState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); + } + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + + return; + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT: + case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT_ALTUnk: + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); + DAT_GameSynchronyState::instance.kickedAtTime = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a52e85b229..2be885516b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23383,7 +23383,7 @@ SHC_3BB0A8C1_0x00490690 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004909E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004909E0 | 79.4% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00490C20 | 0.0% | Pending From 6325fb75fb799a40c56bc21dc5a87e0079f89d37 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:10 +0100 Subject: [PATCH 33/85] reimplement: SHC_3BB0A8C1_0x00492170 80.4% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. A comment says why the -3, -2 and -1 tests stay written out. Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_VideoOptions_Main.cpp | 242 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp new file mode 100644 index 0000000000..2864c02f9e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp @@ -0,0 +1,242 @@ +#include "../VideoOptions.func.hpp" + +#include "OpenSHC/Text/TextManager.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/BGR24.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/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_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::Colors::BGR24; + + // FUNCTION: STRONGHOLDCRUSADER 0x00492170 + void VideoOptions::MenuItemRenderFunction_VideoOptions_Main(int param_1, ...) + { + int iVar1; + int yParam; + BGR24 color; + if (param_1 < -9) { + iVar1 = 0; + if (param_1 == -10) { + if (DAT_MenuTextInputState::instance.menuCursorType == 2) { + iVar1 = 2; + } + iVar1 += 182; + } else { + if (param_1 != -20) { + return; + } + if (DAT_MenuTextInputState::instance.menuCursorType == 1) { + iVar1 = 2; + } + iVar1 += 183; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, + (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); + return; + } + if (param_1 >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + iVar1 = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + yParam = DAT_ButtonY::instance + 7; + if (!DAT_ButtonCurrentlyInteracting::instance) { + color = 12775659; + 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_GAME_OPTIONS, param_1), + iVar1, yParam, OpenSHC::Text::TTA_CENTER, color, 18, FALSE, 0); + return; + } + } else { + // three tests, not a loop: the original checks -3, -2 and -1 in this order + if (param_1 != -3) { + if (param_1 != -2) { + if (param_1 != -1) { + return; + } + switch (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution) { + case 1: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "800x600" + DAT_TextManagerObject::ptr)(S_800X600_005A7598, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 2: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1024x768" + DAT_TextManagerObject::ptr)(S_1024X768_005A7580, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 3: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1280x720" + DAT_TextManagerObject::ptr)(S_1280X720_005A755C, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 4: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1280x1024" + DAT_TextManagerObject::ptr)(S_1280X1024_005A7574, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 5: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1366x768" + DAT_TextManagerObject::ptr)(S_1366X768_005A7514, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 6: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1440x900" + DAT_TextManagerObject::ptr)(S_1440X900_005A7550, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 7: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1600x900" + DAT_TextManagerObject::ptr)(S_1600X900_005A74F0, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 8: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1600x1200" + DAT_TextManagerObject::ptr)(S_1600X1200_005A7568, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 9: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1680x1050" + DAT_TextManagerObject::ptr)(S_1680X1050_005A74FC, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 10: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1920x1080" + DAT_TextManagerObject::ptr)(S_1920X1080_005A7544, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 11: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1920x1200" + DAT_TextManagerObject::ptr)(S_1920X1200_005A7538, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 12: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "2560x1440" + DAT_TextManagerObject::ptr)(S_2560X1440_005A752C, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 13: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "2560x1600" + DAT_TextManagerObject::ptr)(S_2560X1600_005A7520, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 14: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1360x768" + DAT_TextManagerObject::ptr)(S_1360X768_005A7508, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + case 15: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, + // "1024x600" + DAT_TextManagerObject::ptr)(S_1024X600_005A758C, + (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + default: + break; + } + } + // the same sparse switch on the zoom flag (0x4925a3), `case 1` first + switch (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01) { + case 1: + param_1 = 13; + break; + case 0: + param_1 = 14; + break; + default: + return; + } + } else { + // the original dispatches with a `sub eax, K; je` chain (0x4925be), + // MSVC's sparse switch, whose arms are written in the reverse of the + // test order + switch (DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { + case 2: + param_1 = 19; + break; + case 1: + param_1 = 21; + break; + case 0: + param_1 = 20; + break; + default: + return; + } + } + yParam = DAT_ButtonY::instance + 7; + iVar1 = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + } + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + 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_GAME_OPTIONS, param_1), + iVar1, yParam, OpenSHC::Text::TTA_CENTER, color, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2be885516b..04424beb34 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23453,7 +23453,7 @@ SHC_3BB0A8C1_0x00492080 | 0.0% | Pending SHC_3BB0A8C1_0x00492120 | 0.0% | Pending -SHC_3BB0A8C1_0x00492170 | 0.0% | Pending +SHC_3BB0A8C1_0x00492170 | 80.4% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x00492620 | 0.0% | Pending From 60565a81eb9b2733049a387a6c0049b18b2bf131 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:11 +0100 Subject: [PATCH 34/85] reimplement: SHC_3BB0A8C1_0x004BEC40 82.0% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...rFunction_EditScenario_BaseMenuButtons.cpp | 204 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp new file mode 100644 index 0000000000..69ecce037c --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp @@ -0,0 +1,204 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/MenuItems/General.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Map/MapType2.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_CopyOfScenarioGold.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BEC40 + void EditScenario::MenuItemRenderFunction_EditScenario_BaseMenuButtons(int param_1, ...) + { + int iVar1; + uint color; + if (param_1 == 3) { + MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: + MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); + return; + } + if (param_1 == 61 || param_1 == 166 || param_1 == 167) { + if (DAT_GameState::instance.mapAndTime.editScenarioExtraOptions != 0) { + if (param_1 == 61) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Gold" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 61, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(DAT_CopyOfScenarioGold::instance, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + return; + } + // added by script: "Gold" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 61, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(DAT_CopyOfScenarioGold::instance, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + if (param_1 == 166) { + iVar1 = DAT_MissionAestheticsDefinedData::instance + .field_0x3448[DAT_GameState::instance.mapAndTime.scenarioRationsSetting]; + 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_IN_GRANARY, iVar1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), + (int)(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_IN_GRANARY, iVar1, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + return; + } + if (param_1 == 167) { + iVar1 = (int)DAT_GameState::instance.mapAndTime.scenarioTaxesSetting; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + color = 12775659; + } else { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_IN_KEEP, iVar1 + 7, + (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_CENTER, color, 18, FALSE); + } + } + } else if (param_1 == 168) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (!DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Starting Gold" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + } else { + // added by script: "Starting Gold" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance.SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD], + iVar1, (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_RIGHT, + 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, 72, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance)); + } + } else if (param_1 == 169) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Starting Pitch" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + return; + } else { + // added by script: "Starting Pitch" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH], + iVar1, (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_RIGHT, + 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, 58, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance)); + } + } else if ((param_1 != 42) + || (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION)) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + if (param_1 != 38) { + if (param_1 == 79) { + return; + } + LAB_004beed3: + if (param_1 == 41) { + if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { + param_1 = 164; + } + } else if (param_1 == 79) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + if (DAT_ButtonCurrentlyInteracting::instance) { + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(DAT_MapPropertiesState::instance.SEC_StartingPopularity, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + return; + } + // added by script: "Popularity" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, (int)(DAT_ButtonX::instance + 10), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(DAT_MapPropertiesState::instance.SEC_StartingPopularity, + (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + return; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); + } + } else if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_JUST_BUILD + || ((param_1 != 42 && (param_1 != 17)) && (param_1 != 43))) + goto LAB_004beed3; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 04424beb34..8265df5c50 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30493,7 +30493,7 @@ SHC_3BB0A8C1_0x004BEB20 | 0.0% | Pending SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BEC40 | 0.0% | Pending +SHC_3BB0A8C1_0x004BEC40 | 82.0% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004BF1D0 | 0.0% | Pending From b74b83613e5c02bb8b659d697ce20bcb68c48df0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:11 +0100 Subject: [PATCH 35/85] reimplement: SHC_3BB0A8C1_0x004BF1D0 81.2% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Re-measured on main 06d4938a6, where #319 and #322 reimplement callees of this function: 81.8% -> 81.2% (same code as before). Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_EditScenario_TextBoxLike.cpp | 201 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp new file mode 100644 index 0000000000..75d0a09994 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp @@ -0,0 +1,201 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Map/MapPropertiesState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/Text/UserTextHandler.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/COL_DARK_LIME.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonH.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" + +#include "stdlib.h" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004BF1D0 + void EditScenario::MenuItemRenderFunction_EditScenario_TextBoxLike(int param_1, ...) + { + int iVar1; + char* pcVar2; + long lVar3; + int number; + int xParam; + int iVar4; + if ((param_1 == 7) + && (DAT_MissionAestheticsDefinedData::instance + .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] + == 0)) { + return; + } + iVar1 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + switch (param_1) { + case 0: + if (DAT_UserTextHandlerState::instance.textArrayIndex + == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_SEVEN__NUMERIC_ONLY)) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 5 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + } + iVar1 = DAT_ButtonY::instance + 6; + xParam = DAT_ButtonX::instance + 6; + iVar4 = 15; + break; + case 1: + if (DAT_UserTextHandlerState::instance.textArrayIndex + == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_TWO__FILTER_A)) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + } + iVar1 = DAT_ButtonY::instance + 6; + xParam = DAT_ButtonX::instance + 10; + iVar4 = 10; + break; + case 2: + if (DAT_UserTextHandlerState::instance.textArrayIndex + == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_THREE__FILTER_A)) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + } + iVar1 = DAT_ButtonY::instance + 6; + xParam = DAT_ButtonX::instance + 10; + iVar4 = 11; + break; + case 3: + if (DAT_UserTextHandlerState::instance.textArrayIndex == 12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 10 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + if (DAT_MapPropertiesState::instance.indexStored < 20) { + pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(12); + lVar3 = atol(pcVar2); + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance + .field_0x345c[DAT_MapPropertiesState::instance.indexStored]] = lVar3; + } else if (DAT_MapPropertiesState::instance.indexStored < 30) { + pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(12); + lVar3 = atol(pcVar2); + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] = lVar3; + iVar1 = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + if (500 < iVar1) { + DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] + = DAT_MapPropertiesState::instance + .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] + + (500 - iVar1); + } + } else if (DAT_MapPropertiesState::instance.indexStored == 30) { + pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, + DAT_UserTextHandlerState::ptr)(12); + DAT_MapPropertiesState::instance.SEC_StartingPopularity = atol(pcVar2); + } + } + goto LAB_004bf4f3; + default: + return; + case 6: + if (DAT_UserTextHandlerState::instance.textArrayIndex + == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY)) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 5 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + } + iVar1 = DAT_ButtonY::instance + 6; + xParam = DAT_ButtonX::instance + 6; + iVar4 = 14; + break; + case 7: + if (DAT_UserTextHandlerState::instance.textArrayIndex == 12) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonY::instance + 2), + DAT_ButtonX::instance + 10 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), + (ushort)(COL_DARK_LIME::instance.shortValue)); + pcVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(12); + lVar3 = atol(pcVar2); + *(short*)((int)&DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] + .data + + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = (short)(lVar3 + / DAT_MissionAestheticsDefinedData::instance + .EventConditionValueScale[DAT_MapPropertiesState::instance.invasionTroopIndex]); + } + LAB_004bf4f3: + iVar1 = DAT_ButtonY::instance + 6; + xParam = DAT_ButtonX::instance + 11; + iVar4 = 12; + break; + case 100: + // added by script: "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, + (int)(DAT_ButtonW::instance / 2 - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + iVar1 = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + iVar1, (int)(DAT_ButtonW::instance / 2 - 10 + DAT_ButtonX::instance), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, TRUE, 0); + return; + case 101: + // added by script: "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::sumUnitCounts, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + number, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + return; + case 102: + // added by script: "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + iVar1 = MACRO_CALL_MEMBER( + OpenSHC::Map::MapPropertiesState_Func::sumInvasionEventUnitCount, DAT_MapPropertiesState::ptr)(); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + iVar1, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), + OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + return; + } + pcVar2 = MACRO_CALL_MEMBER( + OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(iVar4); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + pcVar2, xParam, iVar1, OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8265df5c50..c8633f8877 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30495,7 +30495,7 @@ SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BEC40 | 82.0% | gynt's draft, mechanical pass; structure -SHC_3BB0A8C1_0x004BF1D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004BF1D0 | 81.2% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004BF684 | 0.0% | Pending From 031cb7d21d46e9782e9ad08754841d2d3b3c9b54 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:11 +0100 Subject: [PATCH 36/85] reimplement: SHC_3BB0A8C1_0x0042D640 75.1% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Re-measured on main 06d4938a6, where #319 and #322 reimplement callees of this function: 74.8% -> 75.1% (same code as before). Co-Authored-By: Claude Opus 5.5 --- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 173 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp new file mode 100644 index 0000000000..50ac310025 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -0,0 +1,173 @@ +#include "../SinglePlayerMapChoice.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_00b95b74.hpp" +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapMissionType.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" +#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" +#include "OpenSHC/Globals/DWORD_00b95b1c.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x0042D640 + void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands(int param_1, ...) + { + if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { + return; + } + DAT_StopHandlingMenuItems::instance = 0; + if (param_1 < -100) { + if (param_1 == -101) { + int iVar1 = DAT_00b95b74::instance - 204; + if ((int)DAT_00b960f4::instance >= iVar1) { + DAT_StopHandlingMenuItems::instance = 0; + } + if (DAT_00b960f4::instance + 14 <= iVar1) { + DAT_00b960f4::instance += 14; + DAT_StopHandlingMenuItems::instance = 0; + } + DAT_00b960f4::instance = iVar1; + return; + } + if (param_1 != -1100) { + if (param_1 != -1000) { + DAT_StopHandlingMenuItems::instance = 0; + return; + } + switchD_0042d6cf_caseD_2: + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + (DAT_MapMissionType::instance == 0 ? OpenSHC::UI::Enums::MVT_MAIN_MENU + : OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS), + 10000); + DWORD_00b95b1c::instance = timeGetTime(); + DAT_00b960dc::instance = 1; + MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); + return; + } + switchD_0042d6cf_caseD_41: + // Start game + if (-(int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + > 1 + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected) { + if ((DAT_MapMissionType::instance == 0) || (DAT_MapMissionType::instance == 3)) { + DAT_GameState::instance.mapAndTime.difficulty = 1; + return; + } + MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSinglePlayerGameUnk)(0); + } + } else { + switch (param_1) { + case 2: + goto switchD_0042d6cf_caseD_2; + case 65: + goto switchD_0042d6cf_caseD_41; + case 66: + // castle builder and landscape mode + if (DAT_MapMissionType::instance != 0) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 0; + return; + } + break; + case 67: + // unknown + if (DAT_MapMissionType::instance != 1) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 1; + return; + } + break; + case 68: + // siege mode + if (DAT_MapMissionType::instance != 2) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_MapMissionType::instance = 2; + return; + } + break; + case 69: + // difficulty button + if ((DAT_GameCore::instance.mapU4Int1_2 == 0) && (DAT_MapMissionType::instance != 0)) { + ++DAT_GameState::instance.mapAndTime.difficulty; + if (4 <= DAT_GameState::instance.mapAndTime.difficulty) { + DAT_GameState::instance.mapAndTime.difficulty = 0; + } + MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( + DAT_GameState::instance.mapAndTime.difficulty); + } + break; + case 74: + // Advanced? + if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance == 2 + && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) { + DAT_SH1_SiegeAdvancedMode::instance ^= 1; + return; + } + break; + case 76: + if (DAT_MapMissionType::instance != 3) { + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_MapMissionType::instance = 3; + return; + } + break; + case 77: + // "Attacking" or "Defending" + if ((DAT_MapMissionType::instance == 2) && (DAT_GameCore::instance.mapU4Int1_2 == 0)) { + if (DAT_GameSynchronyState::instance.currentPlayerSlotID != 1) { + DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; + DAT_SH1_SiegeAdvancedMode::instance = 0; + return; + } + DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; + return; + } + break; + case -100: + DAT_00b960f4::instance -= 14; + if ((int)DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + return; + } + break; + case -11: + if ((int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + < (int)DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13) { + ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + return; + } + break; + case -10: + if (0 < (int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { + --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: + MenuItemActionHandler_SingleplayerMapChoice_MapTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + } + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c8633f8877..3af381acc0 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7865,7 +7865,7 @@ SHC_3BB0A8C1_0x0042D632 | 0.0% | Pending SHC_3BB0A8C1_0x0042D633 | 0.0% | Pending -SHC_3BB0A8C1_0x0042D640 | 0.0% | Pending +SHC_3BB0A8C1_0x0042D640 | 75.1% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0042D8B0 | 0.0% | Pending From b2d7696ac374ba6163f80e32659e7c593777cfc2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:12 +0100 Subject: [PATCH 37/85] reimplement: SHC_3BB0A8C1_0x00493E20 61.5% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...enuItemActionHandler_VideoOptions_Main.cpp | 186 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp new file mode 100644 index 0000000000..59b49aa88e --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp @@ -0,0 +1,186 @@ +#include "../VideoOptions.func.hpp" + +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" +#include "OpenSHC/UI/MenuItems/BuildingAndStatusMenu.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/MenuTextInputState.func.hpp" +#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/ScrollSpeed.hpp" + +#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" +#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::ScreenResolutionEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00493E20 + void VideoOptions::MenuItemActionHandler_VideoOptions_Main(int param_1, ...) + { + int dialogX; + int dialogY; + switch (param_1) { + case 11: + do { + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_800x600) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1024x600; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1024x600) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1024x768; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1280x1024) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1360x768; + } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1360x768) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_1366x768; + } else { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + += OpenSHC::Rendering::SRE_800x600; + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + == OpenSHC::Rendering::SRE_1360x768) { + DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + = OpenSHC::Rendering::SRE_800x600; + } + } + } while (DAT_WindowAndDirectDraw::instance.resolutionSupported_0x68 + .array[DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution] + == 0); + return; + case 12: + DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 ^= 1; + return; + case 16: + DAT_MenuTextInputState::instance.menuScrollSpeedSetting += OpenSHC::UI::SS_FAST; + if (3 <= (int)DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { + DAT_MenuTextInputState::instance.menuScrollSpeedSetting = 0; + } + break; + case 17: + goto switchD_00493e37_caseD_11; + case 18: + if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution + != DAT_WindowAndDirectDraw::instance.currentGameResolution) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDraw_2Unk, + DAT_WindowAndDirectDraw::ptr)(DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen, + (ScreenResolutionEnum)(( + int)(DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution))); + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewportThunk, + DAT_ViewportRenderState::ptr)(); + MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: + MenuItemActionHandler_BuildingAndStatusMenu_StopBuildingOrPeasantBinkPlayback)(); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + if (DAT_MenuModalComposition3::instance.activeModalDialogID + == OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_800x600) { + dialogY = 50; + dialogX = 745; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1024x768) { + dialogY = 56; + dialogX = 969; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1024x600) { + dialogY = 56; + dialogX = 969; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1600x1200) { + LAB_00493fda: + dialogY = 56; + dialogX = 1545; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1280x1024) { + dialogY = 56; + dialogX = 1225; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1280x720) { + dialogY = 56; + dialogX = 1225; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1440x900) { + dialogY = 56; + dialogX = 1385; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1920x1080) { + dialogY = 56; + dialogX = 1865; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1920x1200) { + dialogY = 56; + dialogX = 1865; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_2560x1440) { + dialogY = 56; + dialogX = 2505; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_2560x1600) { + dialogY = 56; + dialogX = 2505; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1366x768) { + dialogY = 56; + dialogX = 1311; + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution + == OpenSHC::Rendering::SRE_1360x768) { + dialogY = 56; + dialogX = 1305; + } else { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + != OpenSHC::Rendering::SRE_1680x1050) { + if (DAT_WindowAndDirectDraw::instance.currentGameResolution + != OpenSHC::Rendering::SRE_1600x900) + goto LAB_00493ff0; + goto LAB_00493fda; + } + dialogY = 56; + dialogX = 1625; + } + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, + DAT_MenuModalComposition3::ptr)( + OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, dialogX, dialogY); + } + } + LAB_00493ff0: + if (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 + != DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { + MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, + DAT_ViewportRenderState::ptr)(DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } + if (DAT_MenuTextInputState::instance.menuCursorType != DAT_MouseState::instance.cursorType) { + DAT_MouseState::instance.cursorType = DAT_MenuTextInputState::instance.menuCursorType; + MACRO_CALL_MEMBER( + OpenSHC::Input::MouseState_Func::makeSelectedCursorTypeCurrent, DAT_MouseState::ptr)(); + } + DAT_ScrollingHandler::instance.scrollSpeedSetting_0x38 + = DAT_MenuTextInputState::instance.menuScrollSpeedSetting; + switchD_00493e37_caseD_11: + MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); + return; + case -20: + DAT_MenuTextInputState::instance.menuCursorType = 1; + break; + case -10: + DAT_MenuTextInputState::instance.menuCursorType = 2; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 3af381acc0..b75f061725 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23837,7 +23837,7 @@ SHC_3BB0A8C1_0x00493E16 | 0.0% | Pending SHC_3BB0A8C1_0x00493E17 | 0.0% | Pending -SHC_3BB0A8C1_0x00493E20 | 0.0% | Pending +SHC_3BB0A8C1_0x00493E20 | 61.5% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0049404E | 0.0% | Pending From d518768d8f1d04df38179d76b9eef325640b151e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:12 +0100 Subject: [PATCH 38/85] reimplement: SHC_3BB0A8C1_0x004B8BF0 79.5% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- ...tion_EditScenario_EventAndInvasionList.cpp | 192 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp new file mode 100644 index 0000000000..64c311dd5b --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp @@ -0,0 +1,192 @@ +#include "../EditScenario.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/BGR24.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + using OpenSHC::Rendering::Colors::BGR24; + using OpenSHC::Text::TextAlignment; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004B8BF0 + void EditScenario::MenuItemRenderFunction_EditScenario_EventAndInvasionList(int param_1, ...) + { + byte bVar1; + BGR24 color; + bool bVar5; + if (DAT_MapPropertiesState::instance.eventListSelection >= DAT_MapPropertiesState::instance.eventsCount) { + DAT_MapPropertiesState::instance.eventListSelection = DAT_MapPropertiesState::instance.eventsCount - 1; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, DAT_PencilRenderCore::ptr)( + (uint)(param_1 == DAT_MapPropertiesState::instance.eventListSelection), param_1, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if ((int)DAT_MapPropertiesState::instance.eventListScrollOffset + param_1 + >= DAT_MapPropertiesState::instance.eventsCount) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + if ((param_1 == DAT_MapPropertiesState::instance.eventListSelection) + || (color = 12775659, DAT_ButtonCurrentlyInteracting::instance)) { + color = OpenSHC::Rendering::Colors::COL_CCFAFF; + } + int iVar10 = 0; + BOOLEnum BVar9 = FALSE; + int iVar8 = 18; + BGR24 BVar7 = OpenSHC::Rendering::Colors::COL_CCFAFF; + TextAlignment TVar6 = OpenSHC::Text::TTA_LEFT; + int iVar3 = DAT_ButtonY::instance + 4; + int iVar4 = DAT_ButtonX::instance + 8; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .header.month), + iVar4, iVar3, TVar6, BVar7, iVar8, BVar9, iVar10); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .header.year, + (int)(DAT_ButtonX::instance + 40), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + iVar3 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .header.tl_type; + if (iVar3 != 1) { + if (iVar3 != 3) { + return; + } + iVar3 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.ScenarioEventType; + iVar4 = iVar3 + 128; + if (155 < iVar4) { + iVar4 = iVar3 + 149; + return; + } + BVar9 = FALSE; + iVar10 = 18; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar3 = DAT_ButtonY::instance + 4; + iVar8 = DAT_ButtonX::instance + 80; + BVar7 = color; + 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, iVar4), + iVar8, iVar3, TVar6, BVar7, iVar10, BVar9, 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.repeat + == 0) { + return; + } + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.repeatMonths + == 1) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "(" + S_BRACE_CLOSE_005A2778, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), + OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + bVar1 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.repeatMonths; + if (bVar1 != 10) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen, + DAT_TextManagerObject::ptr)((uint)bVar1, (int)(DAT_ButtonX::instance + 340), + (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, (uint)(color), 18, TRUE); + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "x" + S_X_005AA7F8, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), + OpenSHC::Text::TTA_LEFT, color, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + (uint)DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.repeat, + (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, + (uint)(color), 18, TRUE, 0); + bVar5 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.repeat + == 1; + } else { + iVar10 = 0; + BVar9 = FALSE; + iVar8 = 18; + TVar6 = OpenSHC::Text::TTA_LEFT; + iVar3 = DAT_ButtonY::instance + 4; + iVar4 = DAT_ButtonX::instance + 80; + BVar7 = color; + // added by script: S_INVASION_005A7638 + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 46), + iVar4, iVar3, TVar6, BVar7, iVar8, BVar9, iVar10); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.scenario.actionData, + (int)(DAT_ButtonX::instance + 250), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, + (uint)(color), 18, FALSE, 0); + if (DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.invasion.repeatMonths + == 0) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // "(x" + S__X_005AA7F4, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), + OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.invasion.repeatMonths, + (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, + (uint)(color), 18, TRUE, 0); + bVar5 = DAT_MapPropertiesState::instance + .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] + .data.invasion.repeatMonths + == 1; + } + if (bVar5) { + iVar3 = 210; + } else { + iVar3 = 211; + } + // added by script: "Months" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_SCENARIO, iVar3, (int)(DAT_ButtonX::instance + 346), + (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, (uint)(color), 18, TRUE); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + // ")" + S_BRACE_OPEN_005A2774, (int)(DAT_ButtonX::instance + 346), (int)(DAT_ButtonY::instance + 4), + OpenSHC::Text::TTA_LEFT, color, 18, TRUE, 0); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b75f061725..6a562041ab 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27521,7 +27521,7 @@ SHC_3BB0A8C1_0x004B8B0C | 0.0% | Pending SHC_3BB0A8C1_0x004B8B10 | 0.0% | Pending -SHC_3BB0A8C1_0x004B8BF0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B8BF0 | 79.5% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004B9020 | 0.0% | Pending From 74bdd124ba01860707702219c17ce0865d8d6d9f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:12 +0100 Subject: [PATCH 39/85] reimplement: SHC_3BB0A8C1_0x00467040 83.8% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Re-measured on main 06d4938a6, where #319 and #322 reimplement callees of this function: 84.4% -> 83.8% (same code as before). Co-Authored-By: Claude Opus 5.5 --- ...dStatusMenu_BuySellMenuButtonsAndHands.cpp | 173 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp new file mode 100644 index 0000000000..cee3965d40 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp @@ -0,0 +1,173 @@ +#include "../BuildingAndStatusMenu.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Actions.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/BOOL_CurrentMenuClickState.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00467040 + void BuildingAndStatusMenu::MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands( + int param_1, ...) + { + int _buyingPrice; + int _player; + if (param_1 == 2) { + _buyingPrice + = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getPreviousGoodsFilteringUnallowed, + DAT_GameState::ptr)((OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (_buyingPrice == 8) { + _buyingPrice = 7; + } + MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: + MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)(_buyingPrice); + return; + } + if (param_1 == 3) { + _buyingPrice = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getNextGoodFilteringUnallowed, + DAT_GameState::ptr)((OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (_buyingPrice == 8) { + _buyingPrice = 7; + } + MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: + MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)(_buyingPrice); + } + BOOL_CurrentMenuClickState::instance = FALSE; + if (param_1 == 0) { + // Buying + _buyingPrice = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getBatchBuyPrice, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (int)(DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType)); + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[OpenSHC::Game::Resources::RT_GOLD] + < _buyingPrice) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(1, + (ResourceType)((int)(DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType))); + // "Not enough gold" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning8.wav" + s_space_warning8_wav_005a5964); + return; + } + int _space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (OpenSHC::Game::Resources::ResourceType)(DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType)); + if (_space == -1) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(3, + (ResourceType)((int)(DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType))); + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 6) { + // "No stockpile built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning2.wav" + s_space_warning2_wav_005a5950); + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 5) { + // "No Granary built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning1.wav" + s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 7) { + return; + } + // "No Armory built" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning3.wav" + s_space_warning3_wav_005a5928); + } + if (_space < 5) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(4, + (ResourceType)((int)(DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType))); + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 9) { + // "No space in the stockpile" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning5.wav" + s_space_warning5_wav_005a50b0); + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 8) { + // "No space in the granary" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning4.wav" + s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + != 10) { + return; + } + // "No space in the armory" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning6.wav" + s_space_warning6_wav_005a5900); + } + } else { + _player = DAT_GameSynchronyState::instance.currentPlayerSlotID; + // Selling + if (param_1 != 1) + goto LAB_004672c0; + ResourceType _resource = (OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType; + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[_resource] + <= 0) { + MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(2, _resource); + // "Not enough goods" + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + // "space_warning7.wav" + s_space_warning7_wav_005a58ec); + } + } + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_DRAWBRIDGE_CONTROL); + _player = DAT_GameSynchronyState::instance.currentPlayerSlotID; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState = 0; + LAB_004672c0: + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameState::instance.playerDataArray[_player].marketSelectedResourceType; + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = param_1; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_BUY_OR_SELL); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6a562041ab..847cc41d77 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19995,7 +19995,7 @@ SHC_3BB0A8C1_0x00466E20 | 0.0% | Pending SHC_3BB0A8C1_0x00466F60 | 0.0% | Pending -SHC_3BB0A8C1_0x00467040 | 0.0% | Pending +SHC_3BB0A8C1_0x00467040 | 83.8% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004672F0 | 0.0% | Pending From 2d468df235e485fc47bf8aaeeaa05e18a30e87c2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 4 Nov 2026 14:49:13 +0100 Subject: [PATCH 40/85] reimplement: SHC_3BB0A8C1_0x004D8EC0 35.2% gynt's draft, mechanical pass; structure gynt's draft with the mechanical pass (decimal numbers, truthiness tests, unused usings, enum names for cast numbers); quick_diff output identical. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_CrusadeMap_Main.cpp | 180 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp b/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp new file mode 100644 index 0000000000..4b56563b3a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp @@ -0,0 +1,180 @@ +#include "../CrusadeMap.func.hpp" + +#include "OpenSHC/Audio/SFX/SFXState.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" +#include "OpenSHC/Game/TrailType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.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_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_SFXState.hpp" +#include "OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DWORD_00ed27a8.hpp" +#include "OpenSHC/Globals/DWORD_00ed311c.hpp" +#include "OpenSHC/Globals/INT_00eb9b48.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D8EC0 + void CrusadeMap::MenuItemActionHandler_CrusadeMap_Main(int param_1, ...) + { + int iVar1; + int iVar2; + dword dVar3; + int iVar5; + if (param_1 == 1000) { + if ((int)DAT_SkirmishTrailRelated1::instance <= 0) { + return; + } + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + iVar1 = DAT_GameCore::instance.furthestSkirmishTrailMission; + if (iVar1 >= 49) { + return; + } + DAT_GameCore::instance.skirmishTrailProgress = iVar1; + if (DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[iVar1] != -1) { + return; + } + DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[iVar1] = -1200; + if (DAT_GameCore::instance.skirmishTrailProgress == 49) { + return; + } + ++DAT_GameCore::instance.skirmishTrailProgress; + ++DAT_GameCore::instance.furthestSkirmishTrailMission; + iVar5 = 1; + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + iVar1 = DAT_GameCore::instance.furthestWarchestTrailMission; + if (iVar1 >= 29) { + return; + } + DAT_GameCore::instance.warchestTrailProgress = iVar1; + if (DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[iVar1] != -1) { + return; + } + DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[iVar1] = -1200; + if (DAT_GameCore::instance.warchestTrailProgress == 29) { + return; + } + ++DAT_GameCore::instance.warchestTrailProgress; + ++DAT_GameCore::instance.furthestWarchestTrailMission; + iVar5 = 2; + } else { + if (DAT_GameCore::instance.currentTrailType != OpenSHC::Game::TT_EXTREME) { + return; + } + iVar1 = DAT_GameCore::instance.furthestExtremeTrailMission; + if (iVar1 >= 19) { + return; + } + DAT_GameCore::instance.extremeTrailProgress = iVar1; + if (DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[iVar1] != -1) { + return; + } + DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[iVar1] = -1200; + if (DAT_GameCore::instance.extremeTrailProgress == 19) { + return; + } + ++DAT_GameCore::instance.extremeTrailProgress; + ++DAT_GameCore::instance.furthestExtremeTrailMission; + iVar5 = 3; + } + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)(iVar5); + --DAT_SkirmishTrailRelated1::instance; + DWORD_00ed311c::instance = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setSoundWithVariation, DAT_SFXState::ptr)( + 258, 100); + return; + } else { + if (param_1 == 10) { + // copy bitmap of icon + MACRO_CALL(OpenSHC::OS_Func::_memcpy)( + (void*)((DAT_GameSynchronyState::instance.currentPlayerSlotID + 19) * 8448 + + (int)DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94), + (void*)((DAT_GameCore::instance.lordIconUnk - 2) * 8448 + + (int)DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94), + 8448); + DAT_TextureRenderCoreObject::instance + .bitmapFaceSizes[DAT_GameSynchronyState::instance.currentPlayerSlotID + 19] = 8448; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_CRUSADE_MISSION_INTRO, 0); + } + if (param_1 == 11) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_SELECT_CRUSADE, 0); + } + if (param_1 == 1) { + int _clickX = DAT_MouseState::instance.screenSpaceX - DAT_ButtonX::instance; + int _clickY = DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance; + dword dVar4 = DAT_GameCore::instance.warchestTrailProgress; + iVar5 = DAT_GameCore::instance.extremeTrailProgress; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { + dVar3 = 0; + do { + if ((int)dVar3 > DAT_GameCore::instance.furthestSkirmishTrailMission) { + return; + } + iVar1 = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[dVar3][0]; + iVar2 = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[dVar3][1]; + if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 + -_clickY >= 10 + && _clickY <= iVar2 + 10) { + LAB_004d9190: + DAT_GameCore::instance.extremeTrailProgress = iVar5; + DAT_GameCore::instance.warchestTrailProgress = dVar4; + DAT_GameCore::instance.skirmishTrailProgress = dVar3; + INT_00eb9b48::instance = 1; + DWORD_00ed27a8::instance = timeGetTime(); + return; + } + ++dVar3; + } while ((int)dVar3 < 50); + } else { + dVar3 = DAT_GameCore::instance.skirmishTrailProgress; + if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { + dVar4 = 0; + while ((int)dVar4 <= DAT_GameCore::instance.furthestWarchestTrailMission) { + iVar1 = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[dVar4][0]; + iVar2 = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[dVar4][1]; + if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 - 10 <= _clickY + && _clickY <= iVar2 + 10) + goto LAB_004d9190; + ++dVar4; + if ((int)dVar4 > 30) { + return; + } + } + } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { + iVar5 = 0; + while (iVar5 <= DAT_GameCore::instance.furthestExtremeTrailMission) { + iVar1 = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[iVar5][0]; + iVar2 = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[iVar5][1]; + if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 + -_clickY >= 10 + && _clickY <= iVar2 + 10) + goto LAB_004d9190; + ++iVar5; + if (20 < iVar5) { + return; + } + } + } + } + } else if (param_1 == 99) { + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); + MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); + } + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 847cc41d77..0a76b338cf 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36013,7 +36013,7 @@ SHC_3BB0A8C1_0x004D8DC0 | 0.0% | Pending SHC_3BB0A8C1_0x004D8DF0 | 0.0% | Pending -SHC_3BB0A8C1_0x004D8EC0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D8EC0 | 35.2% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004D91D0 | 0.0% | Pending From 60ea82a07567124b39bcf9a9381e81a2767dd5bf Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 12:22:35 +0100 Subject: [PATCH 41/85] reimplement: SHC_3BB0A8C1_0x00467040 93.3% BuySellMenuButtonsAndHands MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands rewritten from the binary's control flow (83.8% before): no goto, early returns, RT_PARTIALPITCH / RT_PITCH, main's namespace form. 93.3%. Behaviour fixes (the draft did not return where the original does): - after selecting the next good (button 3) it fell through into the buy/sell code; - after the no-armory and no-space-in-the-armory warnings it went on to the next check or to the command; - after the not-enough-goods warning it still queued the sell command. Now a failed check returns, the click sound and the fail-state reset only happen for buy and sell, and any other button goes straight to the command, as in the original. Left: register choice in the shared tail and in the sell branch. Co-Authored-By: Claude Opus 5.5 --- ...dStatusMenu_BuySellMenuButtonsAndHands.cpp | 258 +++++++++--------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 130 insertions(+), 130 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp index cee3965d40..48c6068ed9 100644 --- a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp +++ b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp @@ -19,155 +19,155 @@ namespace OpenSHC { namespace UI { namespace MenuItems { + namespace BuildingAndStatusMenu { - // FUNCTION: STRONGHOLDCRUSADER 0x00467040 - void BuildingAndStatusMenu::MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands( - int param_1, ...) - { - int _buyingPrice; - int _player; - if (param_1 == 2) { - _buyingPrice - = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getPreviousGoodsFilteringUnallowed, - DAT_GameState::ptr)((OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance + using Game::Resources::ResourceType; + + // FUNCTION: STRONGHOLDCRUSADER 0x00467040 + void MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands(int param_1, ...) + { + // Buttons 2 and 3 step through the goods (partial pitch shows as pitch), 0 buys and 1 sells. + if (param_1 == 2) { + int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getPreviousGoodsFilteringUnallowed, + DAT_GameState::ptr)((ResourceType)DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .marketSelectedResourceType); - if (_buyingPrice == 8) { - _buyingPrice = 7; - } - MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: - MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)(_buyingPrice); - return; - } - if (param_1 == 3) { - _buyingPrice = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getNextGoodFilteringUnallowed, - DAT_GameState::ptr)((OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (_buyingPrice == 8) { - _buyingPrice = 7; - } - MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: - MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)(_buyingPrice); - } - BOOL_CurrentMenuClickState::instance = FALSE; - if (param_1 == 0) { - // Buying - _buyingPrice = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::getBatchBuyPrice, - DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, - (int)(DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType)); - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[OpenSHC::Game::Resources::RT_GOLD] - < _buyingPrice) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(1, - (ResourceType)((int)(DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType))); - // "Not enough gold" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning8.wav" - s_space_warning8_wav_005a5964); + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + MACRO_CALL( + BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( + resource); return; } - int _space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, - DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, - (OpenSHC::Game::Resources::ResourceType)(DAT_GameState::instance + if (param_1 == 3) { + int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getNextGoodFilteringUnallowed, + DAT_GameState::ptr)((ResourceType)DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType)); - if (_space == -1) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(3, - (ResourceType)((int)(DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType))); - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 6) { - // "No stockpile built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning2.wav" - s_space_warning2_wav_005a5950); - } - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 5) { - // "No Granary built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning1.wav" - s_space_warning1_wav_005a593c); + .marketSelectedResourceType); + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; } + MACRO_CALL( + BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( + resource); + return; + } + BOOL_CurrentMenuClickState::instance = FALSE; + if (param_1 == 0) { + int const price = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getBatchBuyPrice, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - != 7) { + .currentResources[Game::Resources::RT_GOLD] + < price) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(1, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + // "space_warning8.wav": not enough gold + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning8_wav_005a5964); return; } - // "No Armory built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning3.wav" - s_space_warning3_wav_005a5928); - } - if (_space < 5) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(4, - (ResourceType)((int)(DAT_GameState::instance + int const space = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::getResourceSpace, + DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (space == -1) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(3, + (ResourceType)DAT_GameState::instance .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType))); - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 9) { - // "No space in the stockpile" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning5.wav" - s_space_warning5_wav_005a50b0); + .marketSelectedResourceType); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 6) { + // "space_warning2.wav": no stockpile built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning2_wav_005a5950); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 5) { + // "space_warning1.wav": no granary built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning1_wav_005a593c); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 7) { + // "space_warning3.wav": no armory built + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning3_wav_005a5928); + } + return; } - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 8) { - // "No space in the granary" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning4.wav" - s_space_warning4_wav_005a5914); + if (space < 5) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(4, + (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType); + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 9) { + // "space_warning5.wav": no space in the stockpile + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning5_wav_005a50b0); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 8) { + // "space_warning4.wav": no space in the granary + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning4_wav_005a5914); + } + if (DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState + == 10) { + // "space_warning6.wav": no space in the armory + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning6_wav_005a5900); + } + return; } + } else if (param_1 == 1) { + ResourceType const resource + = (ResourceType)DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType; if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - != 10) { + .currentResources[resource] + <= 0) { + MACRO_CALL(Actions_Func::SetStorageMarketFailState)(2, resource); + // "space_warning7.wav": not enough goods + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( + s_space_warning7_wav_005a58ec); return; } - // "No space in the armory" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning6.wav" - s_space_warning6_wav_005a5900); } - } else { - _player = DAT_GameSynchronyState::instance.currentPlayerSlotID; - // Selling - if (param_1 != 1) - goto LAB_004672c0; - ResourceType _resource = (OpenSHC::Game::Resources::ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType; - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[_resource] - <= 0) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)(2, _resource); - // "Not enough goods" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning7.wav" - s_space_warning7_wav_005a58ec); + if (param_1 == 0 || param_1 == 1) { + MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( + Audio::SFX::SEID_DRAWBRIDGE_CONTROL); + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .storageMarketFailState = 0; } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = param_1; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .marketSelectedResourceType; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_BUY_OR_SELL); } - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_DRAWBRIDGE_CONTROL); - _player = DAT_GameSynchronyState::instance.currentPlayerSlotID; - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState = 0; - LAB_004672c0: - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 - = DAT_GameState::instance.playerDataArray[_player].marketSelectedResourceType; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = param_1; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - OpenSHC::Commands::GCT_BUY_OR_SELL); - } + } } } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 0a76b338cf..9793fcdb9c 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19995,7 +19995,7 @@ SHC_3BB0A8C1_0x00466E20 | 0.0% | Pending SHC_3BB0A8C1_0x00466F60 | 0.0% | Pending -SHC_3BB0A8C1_0x00467040 | 83.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00467040 | 93.3% | register allocation in the shared tail (reset and command parameters) and in the sell branch SHC_3BB0A8C1_0x004672F0 | 0.0% | Pending From e78114bc1dbb6291e813bdeddce3aacf67f3c0bc Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 13:35:00 +0100 Subject: [PATCH 42/85] 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 53bea5fdf322abbe5e183909f294906375b1bf81 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 14:09:41 +0100 Subject: [PATCH 43/85] 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 outside BuildMenu, BuildingAndStatusMenu and BuildingAvailability (worker A's from now on) is now its OpenSHC::Rendering::Colors name (COL_C2F0EB, COL_B8E6F5, COL_7CAAAF, COL_7F7F7F, COL_FFFFFF, 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 --- ...unction_AlliesSendAndRequestGoods_Main.cpp | 4 +- ...rFunction_EditScenario_BaseMenuButtons.cpp | 29 ++++++---- ...tion_EditScenario_EventAndInvasionList.cpp | 2 +- ...enderFunction_EditScenario_TextBoxLike.cpp | 18 ++++--- ...erFunction_General_AdvancedGameOptions.cpp | 53 ++++++++++++------- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 30 +++++------ ...ItemRenderFunction_NewEventAction_Main.cpp | 5 +- ...mRenderFunction_NewEventCondition_Main.cpp | 11 ++-- ...enderFunction_ScenarioDescription_Main.cpp | 8 +-- ..._SiegeAttackingForceAndStartGoods_Main.cpp | 10 ++-- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 6 +-- ...nuItemRenderFunction_VideoOptions_Main.cpp | 2 +- 12 files changed, 104 insertions(+), 74 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp index 017608c9a8..9846cf7807 100644 --- a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp @@ -70,7 +70,7 @@ namespace UI { DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[actionParam + 1], (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_CENTER, - 12775659, 0, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); } else if (actionParam == 21) { if (!DAT_ButtonCurrentlyInteracting::instance) { iVar1 = 645; @@ -84,7 +84,7 @@ namespace UI { DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[OpenSHC::Game::Resources::RT_GOLD], (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 20), OpenSHC::Text::TTA_CENTER, - 12775659, 0, 19, FALSE, 0); + OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); return; } iVar1 = DAT_ButtonX::instance; diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp index 69ecce037c..38285f8a13 100644 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp @@ -48,11 +48,13 @@ namespace UI { // added by script: "Gold" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 61, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(DAT_CopyOfScenarioGold::instance, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } // added by script: "Gold" @@ -75,7 +77,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_IN_GRANARY, iVar1, (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( @@ -89,7 +92,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - color = 12775659; + color = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { color = OpenSHC::Rendering::Colors::COL_CCFAFF; } @@ -107,13 +110,15 @@ namespace UI { // added by script: "Starting Gold" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; } else { // added by script: "Starting Gold" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; } MACRO_CALL_MEMBER( @@ -133,14 +138,16 @@ namespace UI { // added by script: "Starting Pitch" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; return; } else { // added by script: "Starting Pitch" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; } MACRO_CALL_MEMBER( @@ -184,11 +191,13 @@ namespace UI { // added by script: "Popularity" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(DAT_MapPropertiesState::instance.SEC_StartingPopularity, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp index 64c311dd5b..b70a196d95 100644 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp @@ -46,7 +46,7 @@ namespace UI { return; } if ((param_1 == DAT_MapPropertiesState::instance.eventListSelection) - || (color = 12775659, DAT_ButtonCurrentlyInteracting::instance)) { + || (color = OpenSHC::Rendering::Colors::COL_C2F0EB, DAT_ButtonCurrentlyInteracting::instance)) { color = OpenSHC::Rendering::Colors::COL_CCFAFF; } int iVar10 = 0; diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp index 75d0a09994..cdf762cca8 100644 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp +++ b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp @@ -6,6 +6,7 @@ #include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" #include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/Text/TextArrayIndexType.hpp" @@ -161,39 +162,42 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonW::instance / 2 - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); iVar1 = MACRO_CALL_MEMBER( OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( iVar1, (int)(DAT_ButtonW::instance / 2 - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, TRUE, 0); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, TRUE, 0); return; case 101: // added by script: "Total Troops" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::sumUnitCounts, DAT_MapPropertiesState::ptr)(); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( number, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; case 102: // added by script: "Total Troops" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); iVar1 = MACRO_CALL_MEMBER( OpenSHC::Map::MapPropertiesState_Func::sumInvasionEventUnitCount, DAT_MapPropertiesState::ptr)(); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( iVar1, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); return; } pcVar2 = MACRO_CALL_MEMBER( OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(iVar4); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - pcVar2, xParam, iVar1, OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE, 0); + pcVar2, xParam, iVar1, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } } diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp index 20f9c2e99a..41c402540e 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp @@ -99,7 +99,7 @@ namespace UI { MACRO_CALL_MEMBER( OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderNonInteractingButtonBackground, AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance); - _color = 12775659; + _color = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { _color = OpenSHC::Rendering::Colors::COL_CCFAFF; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, @@ -120,7 +120,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar2 + 79, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 == 36) { @@ -149,7 +149,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 == 109) { @@ -170,7 +170,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); return; } @@ -252,7 +252,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 1) { @@ -260,7 +261,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 2) { @@ -268,7 +270,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 3) { @@ -276,7 +279,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 4) { @@ -284,7 +288,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 8, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishNoRushSetting != 5) { @@ -295,7 +300,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 9, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, @@ -307,7 +313,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishStartGold, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 == 15) { @@ -315,7 +322,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishDefaultPopularity, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 == 82) { @@ -323,7 +331,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishGameSpeedLevel, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 == 94) { @@ -332,7 +341,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 5) { @@ -340,7 +350,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 10) { @@ -348,7 +359,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes != 20) { @@ -358,7 +370,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); } if (param_1 != 100) { @@ -372,14 +385,14 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 101, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, - iVar1); + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); } // "Start only" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 102, (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, 12117749, 0, 18, FALSE, iVar1); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp index 9b2127af3c..341d9a2a68 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -51,7 +51,7 @@ namespace UI { iVar4 = (iVar3 / 32) + 32; BVar2 = FALSE; int iVar10 = 19; - BGR24 BVar9 = 12775659; + BGR24 BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; TextAlignment TVar7 = OpenSHC::Text::TTA_LEFT; iVar3 = DAT_ButtonX::instance; iVar6 = DAT_ButtonY::instance; @@ -65,7 +65,7 @@ namespace UI { iVar6 = (iVar3 / 32) + 32; BVar2 = FALSE; iVar10 = 19; - BVar9 = 12775659; + BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; TVar7 = OpenSHC::Text::TTA_CENTER; iVar4 = DAT_ButtonX::instance + 335; iVar3 = DAT_ButtonY::instance; @@ -82,7 +82,7 @@ namespace UI { iVar6 = (iVar3 / 32) + 32; BVar2 = FALSE; iVar10 = 19; - BVar9 = 12775659; + BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; TVar7 = OpenSHC::Text::TTA_CENTER; iVar4 = DAT_ButtonX::instance + 370; iVar3 = DAT_ButtonY::instance; @@ -159,13 +159,13 @@ namespace UI { if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, 12775659, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, 8170159, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); } } if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { @@ -175,8 +175,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, (int)(DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9 + 230), - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 70, 8170159, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 70, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); return; } if (0 < param_1) { @@ -212,21 +212,21 @@ namespace UI { DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 231 + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9), - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 8170159, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); } iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; DAT_TextManagerObject::instance.field_0x30 = 1; if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 12775659, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, 8170159, 19, - (iVar6 / 32) + 32); + (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); } } if (-10 < param_1) { diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp index a508d2726c..7ada997bf8 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp @@ -187,14 +187,15 @@ namespace UI { } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, textNumInGroup, (int)(DAT_ButtonX::instance + 14), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); if (iVar2 < 0) { return; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( // " - " S___005A2304, (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, 12775659, 18, TRUE, 0); + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 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, iVar2 + 128, diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp index d5e9b0f870..7f173ebc68 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp @@ -49,7 +49,7 @@ namespace UI { .header.month + 12, (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); } else { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_MONTHS, @@ -202,7 +202,7 @@ namespace UI { switchD_004c01f4_caseD_6a: DAT_ButtonCurrentlyInteracting::instance = (BOOLEnum)(DAT_MapPropertiesState::instance.invasionTroopIndex == iVar1 - 106); - uint uVar2 = 12775659; + uint uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; if (DAT_ButtonCurrentlyInteracting::instance) { uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; } @@ -249,7 +249,8 @@ namespace UI { } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, (int)(DAT_ButtonX::instance + 5), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, 8355711, 18, FALSE); + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, + 18, FALSE); return; } case 1001: { @@ -331,7 +332,7 @@ namespace UI { .data + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); } if (DAT_MissionAestheticsDefinedData::instance .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] @@ -348,7 +349,7 @@ namespace UI { .data + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); return; return; } diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp index f98fff6c1a..4b72ea4545 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -79,7 +79,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; } @@ -112,7 +112,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; } @@ -137,7 +137,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; } @@ -162,7 +162,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; } else { uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; } diff --git a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp index e108f8d3b7..7e93925911 100644 --- a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp @@ -52,7 +52,8 @@ namespace UI { DAT_MapPropertiesState::instance.SEC_StartingResources [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } else { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( @@ -91,7 +92,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar4 = 12775659; + uVar4 = OpenSHC::Rendering::Colors::COL_C2F0EB; iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; } else { uVar4 = OpenSHC::Rendering::Colors::COL_CCFAFF; @@ -113,7 +114,8 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, 12775659, 18, FALSE); + (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); } else { // added by script: "Popularity" MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( @@ -143,7 +145,7 @@ namespace UI { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_RIGHT, 12775659, 18, FALSE, 0); + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); } else { MACRO_CALL_MEMBER( OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp index 3e9b803e45..27912f0023 100644 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -89,7 +89,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, - 12775659, 18, FALSE, (iVar1 / 32) + 32); + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, (iVar1 / 32) + 32); } iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; // "easy, normal, hard, very hard" @@ -146,7 +146,7 @@ namespace UI { DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; iVar1 += (iVar1 >> 0x1f & 0x1fU); - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; goto LAB_0042d4c2; case 77: if (DAT_MapMissionType::instance != 2) { @@ -168,7 +168,7 @@ namespace UI { DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; iVar1 = (iVar1 / 32) + 32; - uVar2 = 12775659; + uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; yParam = DAT_ButtonY::instance + 7; goto LAB_0042d4cd; } diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp index 2864c02f9e..5762873bd6 100644 --- a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp @@ -59,7 +59,7 @@ namespace UI { iVar1 = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; yParam = DAT_ButtonY::instance + 7; if (!DAT_ButtonCurrentlyInteracting::instance) { - color = 12775659; + color = OpenSHC::Rendering::Colors::COL_C2F0EB; 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_GAME_OPTIONS, param_1), From 013dc3bb1f9fd437f8205a18b303753daecd0bc4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 16:48:20 +0100 Subject: [PATCH 44/85] Move BarracksWeaponAvailability to the ready branch MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability (0x004649D0) reaches 100.0 in main's namespace form with /GL, so it goes to reimpl/batch6-100. Its .cpp leaves this draft and its status line is main's again. Co-Authored-By: Claude Opus 5.5 --- ...dStatusMenu_BarracksWeaponAvailability.cpp | 176 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 177 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp deleted file mode 100644 index 925487a73f..0000000000 --- a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "../BuildingAndStatusMenu.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" - -#include "OpenSHC/Globals/DAT_00df3350.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_EnoughGoldForRequestedUnit.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/DAT_UnitPropertiesDefinedData.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004649D0 - void BuildingAndStatusMenu::MenuItemRenderFunction_BuildingAndStatusMenu_BarracksWeaponAvailability( - int param_1, ...) - { - ButtonGmData* pBVar1; - int sVar2; - bool bVar3; - int iVar4; - int iVar8; - int iVar9; - bVar3 = false; - if (param_1 == -1) { - if ((!DAT_EnoughGoldForRequestedUnit::instance) - || (DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c == 0)) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } else { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - // the original tests each cost with a one-armed if setting the flag - // (0x464a14..0x464a41), then branches on the flag once - if (0 <= (int)DAT_00df3350::instance) { - for (int i = 0; i < 4; ++i) { - if (DAT_UnitPropertiesDefinedData::instance.EuroUnitResourceCosts[DAT_00df3350::instance][i] - == -1) { - bVar3 = true; - } - } - } - if (bVar3) { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray - + DAT_CurrentButtonGmDataIndex::instance; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, - pBVar1)(DAT_ButtonCurrentlyInteracting::instance); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 287, iVar8, iVar9); - sVar2 = (ushort)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availableHorses; - if (sVar2 != 0) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(sVar2, (int)(DAT_ButtonX::instance + 8), - (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); - } - } else if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availableHorses - != 0) { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray - + DAT_CurrentButtonGmDataIndex::instance; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, - pBVar1)(DAT_ButtonCurrentlyInteracting::instance); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4, iVar8, iVar9); - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - (int)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availableHorses, - (int)(DAT_ButtonX::instance + 8), (int)(DAT_ButtonY::instance + 40), - OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); - } else { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray - + DAT_CurrentButtonGmDataIndex::instance; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 = MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)(FALSE); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 9, iVar8, iVar9); - } - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - } - if ((!DAT_EnoughGoldForRequestedUnit::instance) - || (DAT_GameState::instance.mapAndTime.euroRecruitable[param_1 - 10] == 0)) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (0 <= (int)DAT_00df3350::instance) { - for (int i = 0; i < 3; ++i) { - if (DAT_UnitPropertiesDefinedData::instance.EuroUnitResourceCosts[DAT_00df3350::instance][i] - == param_1) { - bVar3 = true; - } - } - } - if (bVar3) { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)( - DAT_ButtonCurrentlyInteracting::instance); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 287, iVar8, iVar9); - iVar8 = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[param_1]; - if (iVar8 != 0) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(iVar8, (int)(DAT_ButtonX::instance + 8), - (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); - } - } else if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[param_1] - != 0) { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)( - DAT_ButtonCurrentlyInteracting::instance); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4, iVar8, iVar9); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[param_1], - (int)(DAT_ButtonX::instance + 8), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_LEFT, 0, 18, - FALSE, 0); - } else { - pBVar1 = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - iVar8 = DAT_ButtonX::instance; - iVar9 = DAT_ButtonY::instance; - iVar4 - = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, pBVar1)(FALSE); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)pBVar1->gmId_0x0, iVar4 + 9, iVar8, iVar9); - } - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4; - 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 9793fcdb9c..bbe5207404 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19845,7 +19845,7 @@ SHC_3BB0A8C1_0x00464860 | 0.0% | Pending SHC_3BB0A8C1_0x004649C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004649D0 | 43.9% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004649D0 | 0.0% | Pending SHC_3BB0A8C1_0x00464D90 | 100.0% | Reimplemented From ae5a9208ebfee2f54167c0ba9129793009b8cefb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 17:00:21 +0100 Subject: [PATCH 45/85] fix: UnitActionButtons render hides button 376 without an engineer MenuItemRenderFunction_BuildMenu_UnitActionButtons (0x00438BE0): with no engineer selected, button 376 falls into the original's shared hide (jne to UZ = 1); the draft fell through into case 374, which set DAT_00ee1094 and could draw the button. Now it breaks out to the hide. This costs 1.4 points (42.3 -> 40.9, reccmp on main e74aeed9c with this branch's UnitType header); the draft's fall-through happened to keep the original's block layout. A rewrite without the gotos (each case hiding with its own DAT_ButtonUnknownZero = 1, the switch on (int)) came to 41.3: the original keeps 1 in esi and 0 in edi, ours the other way round, which reccmp counts on every line. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp | 5 ++--- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp index a63c3e9523..d6178cd76b 100644 --- a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp @@ -52,14 +52,13 @@ namespace UI { DAT_ButtonUnknownZero::instance = 0; switch ((int)DAT_CurrentButtonGmDataIndex::instance) { case 376: - // the original tail-jumps to the render here (`pop edi; pop esi; jmp` after - // the `cmp [hasEngineerSelected], esi`), so this arm returns rather than - // falling into `case 0x176` and rendering the button a second time + // Without an engineer selected the button hides, as in the original (jne to the shared hide). if (DAT_UnitsState::instance.hasEngineerSelected == TRUE) { MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); return; } + break; case 374: DAT_00ee1094::instance = 291; if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index bbe5207404..e0a4011cdc 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -12943,7 +12943,7 @@ SHC_3BB0A8C1_0x004387D0 | 0.0% | Pending SHC_3BB0A8C1_0x00438B60 | 0.0% | Pending -SHC_3BB0A8C1_0x00438BE0 | 42.3% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00438BE0 | 40.9% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x0043907C | 0.0% | Pending From d79d89dc8c9288ef708f41295913764f2571b8d0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 17:37:16 +0100 Subject: [PATCH 46/85] Loop bounds by countof(), as main's 948dce845 Eight loops whose bound is the length of the array they index now write countof(that array): LaunchOrQuitMultiplayerGameUnk and ScenarioDescription_Main (PlayerSlotUnitColor, 9), PlayerListAndNpcButtons (DAT_RoundTableOrderArray, 9), MapEditorProperties_MainButtons (currentPlayerFullIDArray, 9) and Roundtable_Main (currentPlayerFullIDArray and DAT_PlayerGroupArray, 9). Every function's listing is identical to the literal bound's, apart from MSVC's goto label numbers. Co-Authored-By: Claude Opus 5.5 --- ...tionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp | 4 ++-- ...emRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp | 3 ++- ...uItemActionHandler_MapEditorProperties_MainButtons.cpp | 2 +- .../Roundtable/MenuItemActionHandler_Roundtable_Main.cpp | 8 +++++--- .../MenuItemActionHandler_ScenarioDescription_Main.cpp | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp index 614c422f10..e0a9ade9ca 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp @@ -133,7 +133,7 @@ namespace UI { MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); return; case -7: - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; } @@ -338,7 +338,7 @@ namespace UI { DAT_GameCore::instance.maceProducible_logic = 1; MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( UI::Enums::MVT_MP_CONNECTION, 0); - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; } diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp index 341d9a2a68..16d2bdcf4f 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -314,7 +314,8 @@ namespace UI { DAT_ButtonUnknownZero::instance = 1; if ((DAT_GameSynchronyState::instance.isHost) && (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE)) { - for (int iVar3 = 1; iVar3 < 9; ++iVar3) { + for (int iVar3 = 1; iVar3 < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); + ++iVar3) { if ((char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[iVar3] < '\x01') goto LAB_00427f46; } diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp index f3024c7ac9..5c7e14c10e 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp @@ -104,7 +104,7 @@ namespace UI { MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); MACRO_CALL_MEMBER( Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++i) { DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; } DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; diff --git a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp index 3054890ab7..9f6ccdb70e 100644 --- a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp @@ -59,7 +59,9 @@ namespace UI { DAT_GameSynchronyState::ptr)(playerID), BVar3))) { int iVar4 = 0; - for (int playerID_00 = 1; playerID_00 < 9; ++playerID_00) { + for (int playerID_00 = 1; + playerID_00 < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++playerID_00) { if ((DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_00] != -1) || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(playerID_00), @@ -94,7 +96,7 @@ namespace UI { || (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] == 0)) { if (bVar1 == 0) { bVar1 = 0; - for (int i = 1; i < 9; ++i) { + for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i] && (char)bVar1 < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]; @@ -188,7 +190,7 @@ namespace UI { MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, DAT_GameSynchronyState::ptr)(); int cVar2 = 0; - for (int i = 1; i < 9; ++i) { + for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { cVar2 += '\x01'; } diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp index 2adaa09db3..d6e6e831fa 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp @@ -102,7 +102,7 @@ namespace UI { DAT_MapMissionType::instance = 0; } if (DAT_GameCore::instance.gameSuspended == 0) { - for (int i = 0; i < 9; ++i) { + for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; } From dfa4b08d3a107da58aca1c6339bf851794ca9939 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 19:22:15 +0100 Subject: [PATCH 47/85] drop: 0x004BEC40 goes to reimpl/UI-MenuItems-6-100 EditScenario_BaseMenuButtons reached 100% (rewritten from the original's control flow, with a behaviour fix for button 169) and moves to the ready PR. Its file goes and its status line is main's again. None of this branch's header changes was used only by it: its one new name is COL_C2F0EB from the shared colours commit. Co-Authored-By: Claude Opus 5.5 --- ...rFunction_EditScenario_BaseMenuButtons.cpp | 213 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 214 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp deleted file mode 100644 index 38285f8a13..0000000000 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_BaseMenuButtons.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "../EditScenario.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eGM.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Game/Resources/ResourceType.hpp" -#include "OpenSHC/Map/MapType2.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_CopyOfScenarioGold.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BEC40 - void EditScenario::MenuItemRenderFunction_EditScenario_BaseMenuButtons(int param_1, ...) - { - int iVar1; - uint color; - if (param_1 == 3) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - return; - } - if (param_1 == 61 || param_1 == 166 || param_1 == 167) { - if (DAT_GameState::instance.mapAndTime.editScenarioExtraOptions != 0) { - if (param_1 == 61) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - // added by script: "Gold" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 61, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(DAT_CopyOfScenarioGold::instance, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - // added by script: "Gold" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 61, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(DAT_CopyOfScenarioGold::instance, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - } - if (param_1 == 166) { - iVar1 = DAT_MissionAestheticsDefinedData::instance - .field_0x3448[DAT_GameState::instance.mapAndTime.scenarioRationsSetting]; - 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_IN_GRANARY, iVar1, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_IN_GRANARY, iVar1, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - return; - } - if (param_1 == 167) { - iVar1 = (int)DAT_GameState::instance.mapAndTime.scenarioTaxesSetting; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - color = OpenSHC::Rendering::Colors::COL_C2F0EB; - } else { - color = OpenSHC::Rendering::Colors::COL_CCFAFF; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_IN_KEEP, iVar1 + 7, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, color, 18, FALSE); - } - } - } else if (param_1 == 168) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - // added by script: "Starting Gold" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; - } else { - // added by script: "Starting Gold" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 168, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; - } - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance.SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD], - iVar1, (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_RIGHT, - 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, 72, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance)); - } - } else if (param_1 == 169) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (DAT_ButtonCurrentlyInteracting::instance) { - // added by script: "Starting Pitch" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; - return; - } else { - // added by script: "Starting Pitch" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 169, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - iVar1 = DAT_ButtonW::instance - 10 + DAT_ButtonX::instance; - } - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH], - iVar1, (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_RIGHT, - 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, 58, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance)); - } - } else if ((param_1 != 42) - || (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION)) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { - if (param_1 != 38) { - if (param_1 == 79) { - return; - } - LAB_004beed3: - if (param_1 == 41) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_SIEGE) { - param_1 = 164; - } - } else if (param_1 == 79) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (DAT_ButtonCurrentlyInteracting::instance) { - // added by script: "Popularity" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(DAT_MapPropertiesState::instance.SEC_StartingPopularity, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - } - // added by script: "Popularity" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(DAT_MapPropertiesState::instance.SEC_StartingPopularity, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - } - } else if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_JUST_BUILD - || ((param_1 != 42 && (param_1 != 17)) && (param_1 != 43))) - goto LAB_004beed3; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index ab651718d8..02532ff44a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -30493,7 +30493,7 @@ SHC_3BB0A8C1_0x004BEB20 | 0.0% | Pending SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BEC40 | 82.0% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004BEC40 | 0.0% | Pending SHC_3BB0A8C1_0x004BF1D0 | 81.2% | gynt's draft, mechanical pass; structure From 2a4b5f2e33d647db041153af29f29895ba889da9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 19:48:04 +0100 Subject: [PATCH 48/85] headers: DAT_AlliesCount is an int The allies menu compares it signed: Allies_Main checks the chosen ally against it with jge at 0x004B12FC (lea eax, [esi - 1]; cmp eax, [0x00DF429C]). Main has no .cpp that uses it. The same change is on reimpl/UI-MenuItems-6-100 and reimpl/UI-MenuItems-3-development-2, so the two merge cleanly. Co-Authored-By: Claude Opus 5.5 --- src/OpenSHC/Globals/DAT_AlliesCount.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/Globals/DAT_AlliesCount.hpp b/src/OpenSHC/Globals/DAT_AlliesCount.hpp index a689c3f394..6059383445 100644 --- a/src/OpenSHC/Globals/DAT_AlliesCount.hpp +++ b/src/OpenSHC/Globals/DAT_AlliesCount.hpp @@ -9,11 +9,11 @@ #pragma once // GLOBAL: STRONGHOLDCRUSADER 0x00DF429C -// StructResolver::Instance::instance +// StructResolver::Instance::instance namespace OpenSHC { -MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00DF429C) DAT_AlliesCount; +MACRO_STRUCT_RESOLVER(int, false, Address::SHC_3BB0A8C1_0x00DF429C) DAT_AlliesCount; } // namespace OpenSHC MACRO_STRUCT_INSTANCE(Address::SHC_3BB0A8C1_0x00DF429C); From f8721e5a99f2e786cca6ea5f99a1563294375560 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Thu, 5 Nov 2026 20:07:31 +0100 Subject: [PATCH 49/85] Allies render draft: no casts on DAT_AlliesCount now that it is an int The two (int) casts on DAT_AlliesCount in 0x004AC7A0 go with the header commit before this one. The listing is identical with and without them (quick_diff 0.5519 either way); the status line stays at 52.8%. Co-Authored-By: Claude Opus 5.5 --- .../MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp index 24753b39eb..034299ee68 100644 --- a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp @@ -56,7 +56,7 @@ namespace UI { if (param_1 == 100) { return; } - if ((int)DAT_AlliesCount::instance < 1 && param_1 != -1) { + if (DAT_AlliesCount::instance < 1 && param_1 != -1) { DAT_ButtonUnknownZero::instance = 1; DAT_ButtonCurrentlyInteracting::instance = FALSE; } @@ -118,7 +118,7 @@ namespace UI { DAT_00df51f4::instance = 0; } iVar3 = param_1 - 1; - if ((int)DAT_AlliesCount::instance <= iVar3) { + if (DAT_AlliesCount::instance <= iVar3) { DAT_ButtonUnknownZero::instance = 0; } iVar6 = 0; From 13fbfea13dba34cd0094a305d674fc748f5eea4e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 02:48:41 +0100 Subject: [PATCH 50/85] reimplement: SHC_3BB0A8C1_0x004BBF40 92.3% was 100% before main's header sync; its two text arms keep two call tails Moved here from reimpl/UI-MenuItems-5-100 (7d7a5487d), unchanged, so that branch keeps only 100% functions. 100% before main's header sync a9401a727; with main's full header set MSVC stops sharing the tails of its two text branches (ButtonX + ButtonW - 10 loads the two globals in a different order in each arm, 105 instructions against the original's 100). No single header causes it, and 15 source variants were tried. Co-Authored-By: Claude Opus 5.5 --- ...temRenderFunction_TriggerInvasion_Main.cpp | 134 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp new file mode 100644 index 0000000000..4e75fe37b9 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp @@ -0,0 +1,134 @@ +#include "../TriggerInvasion.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.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_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.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 0x004BBF40 + void TriggerInvasion::MenuItemRenderFunction_TriggerInvasion_Main(int unitType, ...) + { + // the unit's picture in army_units.gm1, counted from 1 + int imageID = 0; + switch (unitType) { + case 0: + imageID = 1; + break; + case 1: + imageID = 2; + break; + case 2: + imageID = 3; + break; + case 3: + imageID = 4; + break; + case 4: + imageID = 5; + break; + case 5: + imageID = 6; + break; + case 6: + imageID = 7; + break; + case 7: + imageID = 8; + break; + case 8: + imageID = 9; + break; + case 9: + imageID = 12; + break; + case 10: + imageID = 13; + break; + case 11: + imageID = 15; + break; + case 12: + imageID = 14; + break; + case 13: + imageID = 16; + break; + case 14: + imageID = 11; + break; + case 15: + imageID = 10; + break; + case 16: + imageID = 17; + break; + case 17: + imageID = 18; + break; + case 18: + imageID = 19; + break; + case 19: + imageID = 20; + break; + case 20: + imageID = 21; + break; + case 21: + imageID = 22; + break; + case 22: + imageID = 23; + break; + case 23: + imageID = 24; + break; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const unitCount = DAT_MapPropertiesState::instance.invasionEventContent.unitCountsPerUnitType[unitType]; + if (unitCount != 0) { + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, + OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } + // the unit's picture, its middle at y + 15 + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, DAT_ButtonX::instance, + DAT_ButtonY::instance + - DAT_GMImageHeaders::instance + .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] + .height + / 2 + + 15); + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c9074bba54..69c1addd23 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29831,7 +29831,7 @@ SHC_3BB0A8C1_0x004BBF30 | 0.0% | Pending SHC_3BB0A8C1_0x004BBF34 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBF40 | 0.0% | Pending +SHC_3BB0A8C1_0x004BBF40 | 92.3% | was 100% before main's header sync; its two text arms keep two call tails SHC_3BB0A8C1_0x004BC0A8 | 0.0% | Pending From 8ed1d23b9b068edc18b0b340f692ec6f108c7eab Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 04:02:49 +0100 Subject: [PATCH 51/85] reimplement: SHC_3BB0A8C1_0x00443A30 23.3% gynt's draft, mechanical pass; register allocation and structure Status line only: it measures 23.3 after the merge of main 72b27322e (was 23.5 before), with the source unchanged. Co-Authored-By: Claude Opus 5.5 --- status/addresses-SHC-3BB0A8C1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 69c1addd23..126694fe46 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14351,7 +14351,7 @@ SHC_3BB0A8C1_0x00443A2D | 0.0% | Pending SHC_3BB0A8C1_0x00443A2E | 0.0% | Pending -SHC_3BB0A8C1_0x00443A30 | 23.5% | gynt's draft, mechanical pass; register allocation and structure +SHC_3BB0A8C1_0x00443A30 | 23.3% | gynt's draft, mechanical pass; register allocation and structure SHC_3BB0A8C1_0x004442A4 | 0.0% | Pending From 8101d64dfecdd5be33cb85244e8281b31b3df40f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 13:18:42 +0100 Subject: [PATCH 52/85] drafts: move 0x004BBF40 TriggerInvasion_Main to the 100% PR On main 57d333434 the function compiles to the original's 100 instructions again (92.3% on this draft's base), so it moves to reimpl/UI-MenuItems-9-100. This draft drops it, and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...temRenderFunction_TriggerInvasion_Main.cpp | 134 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 135 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp b/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp deleted file mode 100644 index 4e75fe37b9..0000000000 --- a/src/OpenSHC/UI/MenuItems/TriggerInvasion/MenuItemRenderFunction_TriggerInvasion_Main.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "../TriggerInvasion.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eGM.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_GMImageHeaders.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.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 0x004BBF40 - void TriggerInvasion::MenuItemRenderFunction_TriggerInvasion_Main(int unitType, ...) - { - // the unit's picture in army_units.gm1, counted from 1 - int imageID = 0; - switch (unitType) { - case 0: - imageID = 1; - break; - case 1: - imageID = 2; - break; - case 2: - imageID = 3; - break; - case 3: - imageID = 4; - break; - case 4: - imageID = 5; - break; - case 5: - imageID = 6; - break; - case 6: - imageID = 7; - break; - case 7: - imageID = 8; - break; - case 8: - imageID = 9; - break; - case 9: - imageID = 12; - break; - case 10: - imageID = 13; - break; - case 11: - imageID = 15; - break; - case 12: - imageID = 14; - break; - case 13: - imageID = 16; - break; - case 14: - imageID = 11; - break; - case 15: - imageID = 10; - break; - case 16: - imageID = 17; - break; - case 17: - imageID = 18; - break; - case 18: - imageID = 19; - break; - case 19: - imageID = 20; - break; - case 20: - imageID = 21; - break; - case 21: - imageID = 22; - break; - case 22: - imageID = 23; - break; - case 23: - imageID = 24; - break; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - int const unitCount = DAT_MapPropertiesState::instance.invasionEventContent.unitCountsPerUnitType[unitType]; - if (unitCount != 0) { - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, - DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } else { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(unitCount, - DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 7, - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - } - // the unit's picture, its middle at y + 15 - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, imageID, DAT_ButtonX::instance, - DAT_ButtonY::instance - - DAT_GMImageHeaders::instance - .imh[GMFirstPictureIndex::instance[OpenSHC::DE::SHCDE::GM_ARMY_UNITS] + imageID - 1] - .height - / 2 - + 15); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 71d3be5757..36d6bf2e31 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -29831,7 +29831,7 @@ SHC_3BB0A8C1_0x004BBF30 | 0.0% | Pending SHC_3BB0A8C1_0x004BBF34 | 0.0% | Pending -SHC_3BB0A8C1_0x004BBF40 | 92.3% | was 100% before main's header sync; its two text arms keep two call tails +SHC_3BB0A8C1_0x004BBF40 | 0.0% | Pending SHC_3BB0A8C1_0x004BC0A8 | 0.0% | Pending From 084c46912247abf5bd2e1440c1fa72fbe5f95e20 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 21:12:17 +0100 Subject: [PATCH 53/85] drafts: write TextInputRelatedUnk's wide NUL character as an escape Line 207 compared against L'' with a literal NUL byte between the quotes (from the mechanical pass in 61df88505), so git and the review tools treated the file as binary. It is now the escape sequence. The compiled function is the same 320 lines (quick_diff 0.5232 before and after), so 0x00461570 keeps its 40.9% status line. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp index f66f9bb327..69e087597b 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp @@ -204,7 +204,7 @@ namespace UI { // delete character in memory *(WCHAR*)(iVar6 + (int)pWVar7) = pWVar7[iVar3]; pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - if (pWVar7[iVar3] == L'') + if (pWVar7[iVar3] == L'\0') break; ++iVar3; iVar6 += 2; From 32e840ddb147c28817f48a6653773a6b75ed50f2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 21:31:28 +0100 Subject: [PATCH 54/85] drafts: move 0x004B8BF0, 0x004BF1D0 and 0x004D8570 to the 100% PR EditScenario_EventAndInvasionList (0x004B8BF0), EditScenario_TextBoxLike (0x004BF1D0) and ScenarioDescription_Main (0x004D8570) 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 --- ...tion_EditScenario_EventAndInvasionList.cpp | 192 --------------- ...enderFunction_EditScenario_TextBoxLike.cpp | 205 ---------------- ...ActionHandler_ScenarioDescription_Main.cpp | 218 ------------------ status/addresses-SHC-3BB0A8C1.txt | 6 +- 4 files changed, 3 insertions(+), 618 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp deleted file mode 100644 index b70a196d95..0000000000 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_EventAndInvasionList.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include "../EditScenario.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" -#include "OpenSHC/string-macros.hpp" - -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004B8BF0 - void EditScenario::MenuItemRenderFunction_EditScenario_EventAndInvasionList(int param_1, ...) - { - byte bVar1; - BGR24 color; - bool bVar5; - if (DAT_MapPropertiesState::instance.eventListSelection >= DAT_MapPropertiesState::instance.eventsCount) { - DAT_MapPropertiesState::instance.eventListSelection = DAT_MapPropertiesState::instance.eventsCount - 1; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::PencilRenderCore_Func::drawTableCellBackground, DAT_PencilRenderCore::ptr)( - (uint)(param_1 == DAT_MapPropertiesState::instance.eventListSelection), param_1, 0); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if ((int)DAT_MapPropertiesState::instance.eventListScrollOffset + param_1 - >= DAT_MapPropertiesState::instance.eventsCount) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if ((param_1 == DAT_MapPropertiesState::instance.eventListSelection) - || (color = OpenSHC::Rendering::Colors::COL_C2F0EB, DAT_ButtonCurrentlyInteracting::instance)) { - color = OpenSHC::Rendering::Colors::COL_CCFAFF; - } - int iVar10 = 0; - BOOLEnum BVar9 = FALSE; - int iVar8 = 18; - BGR24 BVar7 = OpenSHC::Rendering::Colors::COL_CCFAFF; - TextAlignment TVar6 = OpenSHC::Text::TTA_LEFT; - int iVar3 = DAT_ButtonY::instance + 4; - int iVar4 = DAT_ButtonX::instance + 8; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .header.month), - iVar4, iVar3, TVar6, BVar7, iVar8, BVar9, iVar10); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .header.year, - (int)(DAT_ButtonX::instance + 40), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - iVar3 = DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .header.tl_type; - if (iVar3 != 1) { - if (iVar3 != 3) { - return; - } - iVar3 = DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.ScenarioEventType; - iVar4 = iVar3 + 128; - if (155 < iVar4) { - iVar4 = iVar3 + 149; - return; - } - BVar9 = FALSE; - iVar10 = 18; - TVar6 = OpenSHC::Text::TTA_LEFT; - iVar3 = DAT_ButtonY::instance + 4; - iVar8 = DAT_ButtonX::instance + 80; - BVar7 = color; - 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, iVar4), - iVar8, iVar3, TVar6, BVar7, iVar10, BVar9, 0); - if (DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.repeat - == 0) { - return; - } - if (DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.repeatMonths - == 1) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // "(" - S_BRACE_CLOSE_005A2778, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), - OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); - bVar1 = DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.repeatMonths; - if (bVar1 != 10) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen, - DAT_TextManagerObject::ptr)((uint)bVar1, (int)(DAT_ButtonX::instance + 340), - (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, (uint)(color), 18, TRUE); - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // "x" - S_X_005AA7F8, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), - OpenSHC::Text::TTA_LEFT, color, 18, TRUE, 0); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - (uint)DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.repeat, - (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, - (uint)(color), 18, TRUE, 0); - bVar5 = DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.repeat - == 1; - } else { - iVar10 = 0; - BVar9 = FALSE; - iVar8 = 18; - TVar6 = OpenSHC::Text::TTA_LEFT; - iVar3 = DAT_ButtonY::instance + 4; - iVar4 = DAT_ButtonX::instance + 80; - BVar7 = color; - // added by script: S_INVASION_005A7638 - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SCENARIO, 46), - iVar4, iVar3, TVar6, BVar7, iVar8, BVar9, iVar10); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.scenario.actionData, - (int)(DAT_ButtonX::instance + 250), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, - (uint)(color), 18, FALSE, 0); - if (DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.invasion.repeatMonths - == 0) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // "(x" - S__X_005AA7F4, (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), - OpenSHC::Text::TTA_LEFT, color, 18, FALSE, 0); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.invasion.repeatMonths, - (int)(DAT_ButtonX::instance + 340), (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, - (uint)(color), 18, TRUE, 0); - bVar5 = DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.eventListScrollOffset + param_1] - .data.invasion.repeatMonths - == 1; - } - if (bVar5) { - iVar3 = 210; - } else { - iVar3 = 211; - } - // added by script: "Months" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, iVar3, (int)(DAT_ButtonX::instance + 346), - (int)(DAT_ButtonY::instance + 4), OpenSHC::Text::TTA_LEFT, (uint)(color), 18, TRUE); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // ")" - S_BRACE_OPEN_005A2774, (int)(DAT_ButtonX::instance + 346), (int)(DAT_ButtonY::instance + 4), - OpenSHC::Text::TTA_LEFT, color, 18, TRUE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp deleted file mode 100644 index cdf762cca8..0000000000 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemRenderFunction_EditScenario_TextBoxLike.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "../EditScenario.func.hpp" - -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/Text/TextArrayIndexType.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/COL_DARK_LIME.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonH.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" - -#include "stdlib.h" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004BF1D0 - void EditScenario::MenuItemRenderFunction_EditScenario_TextBoxLike(int param_1, ...) - { - int iVar1; - char* pcVar2; - long lVar3; - int number; - int xParam; - int iVar4; - if ((param_1 == 7) - && (DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 0)) { - return; - } - iVar1 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextWidthUntilCurrentCursor, DAT_UserTextHandlerState::ptr)(); - DAT_ButtonCurrentlyInteracting::instance = FALSE; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(-1, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - switch (param_1) { - case 0: - if (DAT_UserTextHandlerState::instance.textArrayIndex - == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_SEVEN__NUMERIC_ONLY)) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 5 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - } - iVar1 = DAT_ButtonY::instance + 6; - xParam = DAT_ButtonX::instance + 6; - iVar4 = 15; - break; - case 1: - if (DAT_UserTextHandlerState::instance.textArrayIndex - == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_TWO__FILTER_A)) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - } - iVar1 = DAT_ButtonY::instance + 6; - xParam = DAT_ButtonX::instance + 10; - iVar4 = 10; - break; - case 2: - if (DAT_UserTextHandlerState::instance.textArrayIndex - == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_THREE__FILTER_A)) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 8 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - } - iVar1 = DAT_ButtonY::instance + 6; - xParam = DAT_ButtonX::instance + 10; - iVar4 = 11; - break; - case 3: - if (DAT_UserTextHandlerState::instance.textArrayIndex == 12) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 10 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - if (DAT_MapPropertiesState::instance.indexStored < 20) { - pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, - DAT_UserTextHandlerState::ptr)(12); - lVar3 = atol(pcVar2); - DAT_MapPropertiesState::instance - .SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance - .field_0x345c[DAT_MapPropertiesState::instance.indexStored]] = lVar3; - } else if (DAT_MapPropertiesState::instance.indexStored < 30) { - pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, - DAT_UserTextHandlerState::ptr)(12); - lVar3 = atol(pcVar2); - DAT_MapPropertiesState::instance - .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] = lVar3; - iVar1 = MACRO_CALL_MEMBER( - OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); - if (500 < iVar1) { - DAT_MapPropertiesState::instance - .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] - = DAT_MapPropertiesState::instance - .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5] - + (500 - iVar1); - } - } else if (DAT_MapPropertiesState::instance.indexStored == 30) { - pcVar2 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, - DAT_UserTextHandlerState::ptr)(12); - DAT_MapPropertiesState::instance.SEC_StartingPopularity = atol(pcVar2); - } - } - goto LAB_004bf4f3; - default: - return; - case 6: - if (DAT_UserTextHandlerState::instance.textArrayIndex - == (OpenSHC::Text::TAIT_EIGHT__FILTER_B | OpenSHC::Text::TAIT_SIX__NUMERIC_ONLY)) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 4 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 5 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - } - iVar1 = DAT_ButtonY::instance + 6; - xParam = DAT_ButtonX::instance + 6; - iVar4 = 14; - break; - case 7: - if (DAT_UserTextHandlerState::instance.textArrayIndex == 12) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance + 9 + iVar1, (int)(DAT_ButtonY::instance + 2), - DAT_ButtonX::instance + 10 + iVar1, (int)(DAT_ButtonH::instance - 4 + DAT_ButtonY::instance), - (ushort)(COL_DARK_LIME::instance.shortValue)); - pcVar2 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(12); - lVar3 = atol(pcVar2); - *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = (short)(lVar3 - / DAT_MissionAestheticsDefinedData::instance - .EventConditionValueScale[DAT_MapPropertiesState::instance.invasionTroopIndex]); - } - LAB_004bf4f3: - iVar1 = DAT_ButtonY::instance + 6; - xParam = DAT_ButtonX::instance + 11; - iVar4 = 12; - break; - case 100: - // added by script: "Total Troops" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, - (int)(DAT_ButtonW::instance / 2 - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - iVar1 = MACRO_CALL_MEMBER( - OpenSHC::Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - iVar1, (int)(DAT_ButtonW::instance / 2 - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, TRUE, 0); - return; - case 101: - // added by script: "Total Troops" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::sumUnitCounts, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - number, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - case 102: - // added by script: "Total Troops" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - iVar1 = MACRO_CALL_MEMBER( - OpenSHC::Map::MapPropertiesState_Func::sumInvasionEventUnitCount, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - iVar1, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - return; - } - pcVar2 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(iVar4); - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - pcVar2, xParam, iVar1, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp deleted file mode 100644 index d6e6e831fa..0000000000 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemActionHandler_ScenarioDescription_Main.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include "../ScenarioDescription.func.hpp" - -#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/Text/TextEditorState.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Map/MapType2.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_00eb0b24.hpp" -#include "OpenSHC/Globals/DAT_00ed2794.hpp" -#include "OpenSHC/Globals/DAT_00ed2798.hpp" -#include "OpenSHC/Globals/DAT_00ed27bc.hpp" -#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapMissionType.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/DAT_TextEditorState.hpp" -#include "OpenSHC/Globals/INT_00ed27c4.hpp" -#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004D8570 - void ScenarioDescription::MenuItemActionHandler_ScenarioDescription_Main(int param_1, ...) - { - int iVar1; - char local_68[100]; - uint local_4 = MSVC_SecurityCookie::instance ^ (uint)local_68; - if (DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { - switch (param_1) { - case 10: - MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, - DAT_TextEditorState::ptr)(); - if (DAT_GameCore::instance.gameSuspended == 1) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - ; - return; - } - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - if (DAT_GameCore::instance.missionNumber1to20 < 1) { - DAT_GameCore::instance.missionNumber1to20 = 1; - return; - } - DAT_GameCore::instance.section1066 = 1; - DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 231; - MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::loadMissionMapAndSetLord, - DAT_MapPropertiesState::ptr)(DAT_GameCore::instance.missionNumber1to20); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); - MACRO_CALL(OpenSHC::Synchrony_Func::SetAIPlayerNickNames)(); - if (16 <= DAT_GameCore::instance.missionNumber1to20) { - MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::initializeFinalResultsForActivePlayers, - DAT_GameSynchronyState::ptr)(); - } - } - 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); - MACRO_CALL_MEMBER( - OpenSHC::UI::MenuTextInputState_Func::clearModalDialog2to6, DAT_MenuTextInputState::ptr)(); - DAT_00ed2794::instance = 0; - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, - DAT_SoundSystemState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - ; - return; - case 12: - case 13: - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { - switch (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1) { - case OpenSHC::Map::MT_SIEGE: - DAT_MapMissionType::instance = 2; - break; - case OpenSHC::Map::MT_INVASION: - DAT_MapMissionType::instance = 3; - break; - case OpenSHC::Map::MT_ECONOMIC: - DAT_MapMissionType::instance = 1; - break; - case OpenSHC::Map::MT_JUST_BUILD: - DAT_MapMissionType::instance = 0; - } - if (DAT_GameCore::instance.gameSuspended == 0) { - for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { - DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] - = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; - } - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE, 0); - ; - return; - } - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = -7; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); - ; - } - case 11: - if (DAT_00ed27bc::instance == 1) { - DAT_00ed27bc::instance = 0; - ; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, - DAT_TextEditorState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::endSpeechStreamsAndResetLoopFlags, - DAT_SoundSystemState::ptr)(); - if (DAT_GameCore::instance.gameSuspended == 0) { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_HISTORIC_MISSION_SELECT, 0); - ; - return; - } - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk, 0); - ; - } - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 1000; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); - ; - return; - case 6: - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { - DAT_00ed2798::instance = 0; - MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, - DAT_TextEditorState::ptr)(); - ; - } - break; - case 8: - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { - DAT_00ed2798::instance = 2; - MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, - DAT_TextEditorState::ptr)(); - ; - } - break; - case 9: - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) { - DAT_00ed2798::instance = 3; - MACRO_CALL(OpenSHC::OS_Func::_sprintf)( - // "mission%d.hlp" - local_68, s_mission_d_hlp_005aaf7c, DAT_GameCore::instance.missionNumber1to20); - iVar1 = MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::findOrAddHelpSectionName, - DAT_TextEditorState::ptr)(local_68); - MACRO_CALL_MEMBER(OpenSHC::Text::TextEditorState_Func::openScenarioHelpDialog, - DAT_TextEditorState::ptr)(iVar1); - ; - } - break; - case -1: - if (DAT_00ed2798::instance == 0 - && (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) - && DAT_GameCore::instance.gameSuspended == 0) { - ++DAT_GameState::instance.mapAndTime.difficulty; - if (3 < DAT_GameState::instance.mapAndTime.difficulty) { - DAT_GameState::instance.mapAndTime.difficulty = 0; - return; - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { - DAT_GameCore::instance.missionDifficulty = DAT_GameState::instance.mapAndTime.difficulty; - MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); - ; - return; - } - DAT_GameCore::instance.missionDifficulty2 = DAT_GameState::instance.mapAndTime.difficulty; - MACRO_CALL(OpenSHC::UI::Helpers_Func::ResetEventStatusUnk)(); - ; - } - case -2: - DAT_00ed27bc::instance = 1; - ; - return; - case -3: - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 44; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_YES_NO_DIALOG); - ; - return; - case -4: - ++DAT_00eb0b24::instance; - if ((int)DAT_00eb0b24::instance >= INT_00ed27c4::instance) { - DAT_00eb0b24::instance = 0; - } - break; - } - }; - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 36d6bf2e31..1c298ea7e5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27521,7 +27521,7 @@ SHC_3BB0A8C1_0x004B8B0C | 0.0% | Pending SHC_3BB0A8C1_0x004B8B10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8BF0 | 79.5% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004B8BF0 | 0.0% | Pending SHC_3BB0A8C1_0x004B9020 | 100.0% | Reimplemented @@ -30495,7 +30495,7 @@ SHC_3BB0A8C1_0x004BEC10 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004BEC40 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004BF1D0 | 81.2% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004BF1D0 | 0.0% | Pending SHC_3BB0A8C1_0x004BF684 | 0.0% | Pending @@ -35929,7 +35929,7 @@ SHC_3BB0A8C1_0x004D8250 | 42.4% | gynt's draft, mechanical pass; structure SHC_3BB0A8C1_0x004D839E | 0.0% | Pending -SHC_3BB0A8C1_0x004D8570 | 64.5% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004D8570 | 0.0% | Pending SHC_3BB0A8C1_0x004D89CC | 0.0% | Pending From ae90b765479b88c87ab3c05362f4073365d547f8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 6 Nov 2026 23:08:10 +0100 Subject: [PATCH 55/85] drafts: move 0x004C01B0, 0x004B8220 and 0x004C0860 to the 100% PR MenuItemRenderFunction_NewEventCondition_Main (0x004C01B0, 72.8% here), MenuItemActionHandler_EditScenario_BaseMenuButtons (0x004B8220, 73.5% here) and MenuItemRenderFunction_NewEventAction_Main (0x004C0860, 62.3% here) are at 100% on reimpl/batch17-100, rewritten from the binary. Their .cpp files leave this branch and their status lines go back to main's (0.0% | Pending). Co-Authored-By: Claude Opus 5.5 --- ...onHandler_EditScenario_BaseMenuButtons.cpp | 279 ------------- ...ItemRenderFunction_NewEventAction_Main.cpp | 211 ---------- ...mRenderFunction_NewEventCondition_Main.cpp | 380 ------------------ status/addresses-SHC-3BB0A8C1.txt | 6 +- 4 files changed, 3 insertions(+), 873 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp b/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp deleted file mode 100644 index 8b5c5bd4e1..0000000000 --- a/src/OpenSHC/UI/MenuItems/EditScenario/MenuItemActionHandler_EditScenario_BaseMenuButtons.cpp +++ /dev/null @@ -1,279 +0,0 @@ -#include "../EditScenario.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Game/ScenarioEvents/InGameEventUnionVersion.func.hpp" -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/Game/Resources/ResourceType.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_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CopyOfScenarioGold.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" -#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" -#include "OpenSHC/Globals/MSVC_SecurityCookie.hpp" - -#include "stdlib.h" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using Game::ScenarioEvents::InGameEventUnionVersion; - - // FUNCTION: STRONGHOLDCRUSADER 0x004B8220 - void EditScenario::MenuItemActionHandler_EditScenario_BaseMenuButtons(int param_1, ...) - { - char* pcVar1; - InGameEventUnionVersion* pIVar2; - char local_10[12]; - uint local_4; - local_4 = MSVC_SecurityCookie::instance ^ (uint)local_10; - if (DAT_MenuModalComposition1::instance.activeModalDialogID != UI::Enums::MMT_NONE) - goto switchD_004b8254_caseD_0; - switch (param_1) { - case 3: - pcVar1 = MACRO_CALL_MEMBER( - Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); - DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); - if (DAT_MapPropertiesState::instance.year_copy != DAT_MapPropertiesState::instance.SEC_StartingYear) { - DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; - DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; - } - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); - ; - return; - case 38: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_SIEGE) { - DAT_MapPropertiesState::instance.indexStored = 0; - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_TRADER_SETTINGS, FALSE); - ; - return; - } - goto LAB_004b82b4; - case 41: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { - DAT_MapPropertiesState::instance.indexStored = 20; - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(12); - MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, - DAT_MapPropertiesState::instance - .SEC_StartingResources[DAT_MapPropertiesState::instance.indexStored + 5]); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( - local_10); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); - DAT_MapPropertiesState::instance.DAT_MapEditorUnitPointsSum - = MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::sumUnitPoints, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_UNUSED_SIEGE_ATTACKING_FORCEUnk, FALSE); - ; - return; - } - DAT_MapPropertiesState::instance.indexStored = 0; - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(12); - MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, - DAT_MapPropertiesState::instance.SEC_StartingResources[DAT_MissionAestheticsDefinedData::instance - .field_0x345c[DAT_MapPropertiesState::instance.indexStored]]); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( - local_10); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(9); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( - UI::Enums::MMT_START_GOODS, FALSE); - ; - return; - case 42: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_INVASION) { - DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; - pIVar2 = DAT_MapPropertiesState::instance.scenarioEvents - + DAT_MapPropertiesState::instance.eventsCount; - DAT_MapPropertiesState::instance.editedEventType = 1; - ++DAT_MapPropertiesState::instance.eventsCount; - MACRO_CALL_MEMBER(Game::ScenarioEvents::InGameEventUnionVersion_Func::resetEvent, pIVar2)(); - pcVar1 = MACRO_CALL_MEMBER( - Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); - DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(14); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( - s__005a5339); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::resetToTextIndex, DAT_UserTextHandlerState::ptr)(11); - MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.year); - MACRO_CALL_MEMBER(Text::UserTextHandler_Func::copyIntoTextArray, DAT_UserTextHandlerState::ptr)( - local_10); - DAT_MapPropertiesState::instance.field_0x1356c = 0; - DAT_MapPropertiesState::instance.offset = 0; - DAT_MapPropertiesState::instance.indexStored = 0; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_INVASION, FALSE); - ; - return; - } - break; - case 43: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_JUST_BUILD) { - DAT_MapPropertiesState::instance.currentEventID = DAT_MapPropertiesState::instance.eventsCount; - pIVar2 = DAT_MapPropertiesState::instance.scenarioEvents - + DAT_MapPropertiesState::instance.eventsCount; - DAT_MapPropertiesState::instance.editedEventType = 3; - ++DAT_MapPropertiesState::instance.eventsCount; - MACRO_CALL_MEMBER( - Game::ScenarioEvents::InGameEventUnionVersion_Func::initializeScenarioEvent, pIVar2)(); - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[0] - .enabled = 1; - // a for loop over conditions 5-7 loses the match - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[5] - .subType = 10; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[6] - .subType = 10; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[7] - .subType = 10; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[17] - .subType = 10; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[22] - .value = 5; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.conditions[23] - .value = 5; - pcVar1 = MACRO_CALL_MEMBER( - Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(10); - DAT_MapPropertiesState::instance.SEC_StartingYear = atol(pcVar1); - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.year = DAT_MapPropertiesState::instance.SEC_StartingYear; - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; - DAT_MapPropertiesState::instance.invasionTroopIndex = 0; - DAT_MapPropertiesState::instance.flag = 1; - MACRO_CALL(OS_Func::_sprintf)(local_10, s__d_005aa7f0, - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.year); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); - ; - return; - } - break; - case 61: - if (DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) { - DAT_CopyOfScenarioGold::instance = (int)DAT_GameState::instance.mapAndTime.scenarioGold; - MACRO_CALL_MEMBER( - UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 10000, - DAT_CopyOfScenarioGold::instance, (undefined*)DAT_CopyOfScenarioGold::ptr, - (void*)MACRO_CALL(UI::Helpers_Func::RestoreScenarioGold)); - DAT_MenuModalComposition2::instance.textIndex = 61; - LAB_004b8756: - DAT_MenuModalComposition2::instance.textGroup = 199; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, - DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, - (int)((int)(DAT_ButtonX::instance - 2)), (int)((int)(DAT_ButtonY::instance + 25))); - ; - return; - } - break; - case 79: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != Map::MT_SIEGE) { - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setSliderParameters, - DAT_MenuModalComposition2::ptr)(0, 100, DAT_MapPropertiesState::instance.SEC_StartingPopularity, - (undefined*)((int)(&DAT_MapPropertiesState::instance.SEC_StartingPopularity)), - (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); - DAT_MenuModalComposition2::instance.textGroup = 199; - DAT_MenuModalComposition2::instance.textIndex = 79; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, - DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, - (int)((int)(DAT_ButtonX::instance - 2)), (int)((int)(DAT_ButtonY::instance + 25))); - ; - return; - } - LAB_004b82b4: - DAT_StopHandlingMenuItems::instance = 0; - ; - return; - case 166: - if ((DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) - && (DAT_GameState::instance.mapAndTime.scenarioRationsSetting - = DAT_GameState::instance.mapAndTime.scenarioRationsSetting + 1, - 4 < DAT_GameState::instance.mapAndTime.scenarioRationsSetting)) { - DAT_GameState::instance.mapAndTime.scenarioRationsSetting = 0; - ; - return; - } - break; - case 167: - if ((DAT_GameState::instance.mapAndTime.editScenarioExtraOptions) - && (DAT_GameState::instance.mapAndTime.scenarioTaxesSetting - = DAT_GameState::instance.mapAndTime.scenarioTaxesSetting + 1, - 9 < DAT_GameState::instance.mapAndTime.scenarioTaxesSetting)) { - DAT_GameState::instance.mapAndTime.scenarioTaxesSetting = 0; - } - break; - case 168: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { - MACRO_CALL_MEMBER( - UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 10000, - (int)((int)(DAT_MapPropertiesState::instance - .SEC_StartingResources[OpenSHC::Game::Resources::RT_GOLD])), - (undefined*)((int)((DAT_MapPropertiesState::instance.SEC_StartingResources + 15))), - (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); - DAT_MenuModalComposition2::instance.textIndex = 168; - goto LAB_004b8756; - } - break; - case 169: - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { - MACRO_CALL_MEMBER( - UI::MenuModalComposition_Func::setSliderParameters, DAT_MenuModalComposition2::ptr)(0, 100, - (int)((int)(DAT_MapPropertiesState::instance - .SEC_StartingResources[OpenSHC::Game::Resources::RT_PARTIALPITCH])), - (undefined*)((int)((DAT_MapPropertiesState::instance.SEC_StartingResources + 8))), - (void*)MACRO_CALL(UI::Helpers_Func::SumUnitPoints)); - DAT_MenuModalComposition2::instance.textIndex = 169; - goto LAB_004b8756; - } - break; - case 171: - DAT_MapPropertiesState::instance.DAT_BuildingAvailabilityScrollbarOffset = 0; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( - UI::Enums::MMT_BUILDING_AVAILABILITY, FALSE); - ; - return; - case -1: - ++DAT_MapPropertiesState::instance.SEC_StartingMonth; - if (11 < DAT_MapPropertiesState::instance.SEC_StartingMonth) { - DAT_MapPropertiesState::instance.SEC_StartingMonth = 0; - } - DAT_GameState::instance.mapAndTime.year = DAT_MapPropertiesState::instance.SEC_StartingYear; - DAT_GameState::instance.mapAndTime.month = DAT_MapPropertiesState::instance.SEC_StartingMonth; - ; - return; - } - switchD_004b8254_caseD_0:; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp deleted file mode 100644 index 7ada997bf8..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewEventAction/MenuItemRenderFunction_NewEventAction_Main.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include "../NewEventAction.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.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/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/string-macros.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.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_MenuModalComposition2.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004C0860 - void NewEventAction::MenuItemRenderFunction_NewEventAction_Main(int param_1, ...) - { - int textNumInGroup; - int iVar2 = -1; - DAT_ButtonUnknownZero::instance = 0; - int iVar1 = param_1; - switch (param_1) { - case 37: - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - return; - case 38: - if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.ScenarioEventType - == 27) { - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1 + 2); - } - break; - case 39: - if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.ScenarioEventType - == 26) { - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1 + 1); - } - break; - case 40: - if (DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.ScenarioEventType - == 2) { - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - } - break; - default: - DAT_ButtonUnknownZero::instance = 0; - return; - case 177: - case 178: - case 179: - case 180: - case 181: - case 182: - case 183: - case 184: - case 185: - case 186: - case 187: - iVar1 = 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: - if (param_1 == 148) { - iVar2 = 0; - textNumInGroup = 146; - } else { - textNumInGroup = param_1; - if (param_1 == 146) { - iVar2 = 2; - } - } - if (iVar1 - 128 - == DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.ScenarioEventType) { - 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, textNumInGroup, (int)(DAT_ButtonX::instance + 14), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - if (0 <= iVar2) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // " - " - DAT_TextManagerObject::ptr)(S___005A2304, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 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, iVar2 + 128, - (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 23 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 3)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - if ((DAT_MapPropertiesState::instance.sliderPopupDelay != 0) - && (DAT_MapPropertiesState::instance.sliderPopupDelay - = DAT_MapPropertiesState::instance.sliderPopupDelay - 1, - DAT_MapPropertiesState::instance.sliderPopupDelay == 0)) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, - DAT_MenuModalComposition2::ptr)(OpenSHC::UI::Enums::MMT_OVERLAY_SLIDER, - (int)(DAT_MapPropertiesState::instance.sliderPopupX), - (int)(DAT_MapPropertiesState::instance.sliderPopupY)); - } - switch (param_1) { - case 132: - case 139: - case 145: - case 146: - case 148: - case 179: - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.actionData, - (int)(DAT_ButtonW::instance - 14 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - default: - return; - case 178: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "%" - DAT_TextManagerObject::ptr)(S_PERCENTAGE_005A2770, - (int)(DAT_ButtonW::instance - 14 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data.scenario.actionData, - (int)(DAT_ButtonW::instance - 28 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - } - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - } else { - 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, textNumInGroup, (int)(DAT_ButtonX::instance + 14), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - if (iVar2 < 0) { - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - // " - " - S___005A2304, (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 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, iVar2 + 128, - (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 23 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 3)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - DAT_ButtonUnknownZero::instance = 1; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp deleted file mode 100644 index 7f173ebc68..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemRenderFunction_NewEventCondition_Main.cpp +++ /dev/null @@ -1,380 +0,0 @@ -#include "../NewEventCondition.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/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/UI/Enums/RoundedBoxEdgeRoundingLevel.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.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_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004C01B0 - void NewEventCondition::MenuItemRenderFunction_NewEventCondition_Main(int param_1, ...) - { - DAT_ButtonUnknownZero::instance = 0; - if (5000 < param_1) { - return; - } - int iVar1; - switch (param_1) { - case -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::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MONTHS, - DAT_MapPropertiesState::instance.scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .header.month - + 12, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - } else { - 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, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 6), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - } - break; - case 126: - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 15) - == '\0') { - param_1 = 127; - } - case 19: - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - return; - case 104: - if (*(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 8) - != 0) { - param_1 = 105; - } - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - return; - case 209: { - int iVar3 = 0; - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 19) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 31) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 35) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 39) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 43) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 83) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 95) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 99) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 103) - != '\0') { - iVar3 = 1; - } - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 107) - == '\0' - && iVar3 == 0) { - DAT_ButtonUnknownZero::instance = 1; - return; - } - } - case 190: - case 191: - case 192: - case 193: - case 194: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 202: - case 203: - case 204: - case 205: - case 206: - case 207: - case 208: { - iVar1 = param_1 - 64; - goto switchD_004c01f4_caseD_6a; - } - case 106: - case 107: - case 108: - case 109: - case 110: - case 111: - case 112: - case 113: - case 114: - case 115: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: { - iVar1 = param_1; - switchD_004c01f4_caseD_6a: - DAT_ButtonCurrentlyInteracting::instance - = (BOOLEnum)(DAT_MapPropertiesState::instance.invasionTroopIndex == iVar1 - 106); - uint uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; - if (DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (param_1 == 111 || param_1 == 112 || param_1 == 113 || param_1 == 123) { - param_1 = 113; - } - if (*(char*)((int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags - + DAT_MapPropertiesState::instance.currentEventID * 228 + iVar1 * 4 + 511) - != '\0') { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, (int)(DAT_ButtonX::instance + 5), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, uVar2, 18, FALSE); - if (DAT_MissionAestheticsDefinedData::instance.unknown3[iVar1 + 862] == 0) { - return; - } - if (DAT_MissionAestheticsDefinedData::instance.EventConditionMinValue[iVar1 + 14] == 1) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, - (int)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionTextOffsets[( - char)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 - + DAT_MapPropertiesState::instance.currentEventID * 114 + 255]]), - (int)(DAT_ButtonX::instance + 14), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, uVar2, 18, TRUE); - } - if (DAT_MissionAestheticsDefinedData::instance.EventConditionMinValue[iVar1 + 14] == 2) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, - (int)(DAT_MissionAestheticsDefinedData::instance.field_0x170[( - char)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 - + DAT_MapPropertiesState::instance.currentEventID * 114 + 255]]), - (int)(DAT_ButtonX::instance + 14), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, uVar2, 18, TRUE); - } - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen, DAT_TextManagerObject::ptr)( - (int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags[iVar1 * 2 - + DAT_MapPropertiesState::instance.currentEventID * 114 + 254] - * DAT_MissionAestheticsDefinedData::instance.unknown3[iVar1 + 902], - (int)(DAT_ButtonW::instance - 8 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, uVar2, 18, FALSE); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, param_1, (int)(DAT_ButtonX::instance + 5), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_7F7F7F, - 18, FALSE); - return; - } - case 1001: { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 0) { - return; - } - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), - OpenSHC::UI::Enums::RBERL_SLIGHT); - } - return; - } - case 1000: { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 0) { - return; - } - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), - OpenSHC::UI::Enums::RBERL_SLIGHT); - } - return; - } - case 2000: { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 0) { - return; - } - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), - OpenSHC::UI::Enums::RBERL_SLIGHT); - } - return; - } - default: { - switchD_004c01f4_caseD_0: - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScenarioButtonWithText)(param_1); - return; - } - case 2002: { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 1) { - 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, - (int)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionTextOffsets[*( - char*)(&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - } - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - != 2) { - return; - } - 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, - (int)(DAT_MissionAestheticsDefinedData::instance - .field_0x170[*(char*)(&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)]), - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - return; - return; - } - case 2001: - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 0) { - return; - } - if (DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), - OpenSHC::UI::Enums::RBERL_SLIGHT); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); - } - return; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1c298ea7e5..4b42c46237 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27111,7 +27111,7 @@ SHC_3BB0A8C1_0x004B8200 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B8210 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B8220 | 73.5% | compiles again, mechanical pass; structure +SHC_3BB0A8C1_0x004B8220 | 0.0% | Pending SHC_3BB0A8C1_0x004B88A4 | 0.0% | Pending @@ -32329,7 +32329,7 @@ SHC_3BB0A8C1_0x004C01A5 | 0.0% | Pending SHC_3BB0A8C1_0x004C01A6 | 0.0% | Pending -SHC_3BB0A8C1_0x004C01B0 | 72.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004C01B0 | 0.0% | Pending SHC_3BB0A8C1_0x004C0770 | 0.0% | Pending @@ -32765,7 +32765,7 @@ SHC_3BB0A8C1_0x004C085C | 0.0% | Pending SHC_3BB0A8C1_0x004C085D | 0.0% | Pending -SHC_3BB0A8C1_0x004C0860 | 62.3% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004C0860 | 0.0% | Pending SHC_3BB0A8C1_0x004C0BF8 | 0.0% | Pending From a552e96a33e805ef6f7d31b21a1624baaa1b91fb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 00:49:19 +0100 Subject: [PATCH 56/85] style: AI types and screen resolutions by their enum names gynt asked on sourcehold/OpenSHC#354 why the case labels do not use the enum names. Where the switched value has an enum on main this draft now uses it: MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons's switch on a player's currentAIArray entry names its ten cases by AITypeA (the European lords, AITA_RAT ... AITA_ABBOT), and MenuItemActionHandler_Roundtable_Main's two tests of it compare with AITA_RAT and AITA_SULTAN (the genie's "Not the rodent" line is the rat's); MenuItemRenderFunction_VideoOptions_Main's switch on menuCurrentlySelectedResolution names its 15 cases by ScreenResolutionEnum, each matching the text it draws (SRE_800x600 ... SRE_1024x600). The other switches here are on button numbers, GM picture indices, key codes and fields with no enum, so they keep their numbers. The code is unchanged: quick_diff gives the same output for all three files before and after. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 21 +++++++------ .../MenuItemActionHandler_Roundtable_Main.cpp | 5 +-- ...nuItemRenderFunction_VideoOptions_Main.cpp | 31 ++++++++++--------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp index 16d2bdcf4f..5f165e95e6 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -5,6 +5,7 @@ #include "OpenSHC/UI/Helpers.func.hpp" #include "OpenSHC/UI/Rendering.func.hpp" #include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/AI/AITypeA.hpp" #include "OpenSHC/DE/SHCDE/eTextSections.hpp" #include "OpenSHC/Game/GameMode.hpp" #include "OpenSHC/IO/Graphics/GmID.hpp" @@ -255,16 +256,16 @@ namespace UI { } DAT_CurrentButtonGmDataIndex::instance = 627; switch (DAT_GameSynchronyState::instance.currentAIArray[iVar3]) { - case 1: - case 2: - case 3: - case 4: - case 8: - case 9: - case 10: - case 14: - case 15: - case 16: + case OpenSHC::AI::AITA_RAT: + case OpenSHC::AI::AITA_SNAKE: + case OpenSHC::AI::AITA_PIG: + case OpenSHC::AI::AITA_WOLF: + case OpenSHC::AI::AITA_RICHARD: + case OpenSHC::AI::AITA_FREDERICK: + case OpenSHC::AI::AITA_PHILIPP: + case OpenSHC::AI::AITA_SHERIFF: + case OpenSHC::AI::AITA_MARSHAL: + case OpenSHC::AI::AITA_ABBOT: DAT_CurrentButtonGmDataIndex::instance = 626; } DAT_ButtonX::instance -= 6; diff --git a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp index 9f6ccdb70e..a65b4ba587 100644 --- a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp @@ -5,6 +5,7 @@ #include "OpenSHC/Input/MouseState.func.hpp" #include "OpenSHC/Random/RNG.func.hpp" #include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/AI/AITypeA.hpp" #include "OpenSHC/UI/Enums/MenuModalType.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/string-literals.hpp" @@ -70,7 +71,7 @@ namespace UI { } } if (2 < iVar4) { - if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == 1) + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_RAT) && (DAT_00df4240::instance == 0)) { if (DAT_GameCore::instance.genieVoiceActive) { // "Not the rodent" @@ -80,7 +81,7 @@ namespace UI { } DAT_00df4240::instance = 1; } - if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == 7) + if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_SULTAN) && (DAT_00df4298::instance == 0)) { if (DAT_GameCore::instance.genieVoiceActive) { // "Oh no" diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp index 5762873bd6..3232eb277c 100644 --- a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp @@ -8,6 +8,7 @@ #include "OpenSHC/Rendering/Colors/BGR24.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" #include "OpenSHC/Text/TextAlignment.hpp" #include "OpenSHC/string-macros.hpp" @@ -74,7 +75,7 @@ namespace UI { return; } switch (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution) { - case 1: + case OpenSHC::Rendering::SRE_800x600: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "800x600" DAT_TextManagerObject::ptr)(S_800X600_005A7598, @@ -82,7 +83,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 2: + case OpenSHC::Rendering::SRE_1024x768: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1024x768" DAT_TextManagerObject::ptr)(S_1024X768_005A7580, @@ -90,7 +91,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 3: + case OpenSHC::Rendering::SRE_1280x720: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1280x720" DAT_TextManagerObject::ptr)(S_1280X720_005A755C, @@ -98,7 +99,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 4: + case OpenSHC::Rendering::SRE_1280x1024: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1280x1024" DAT_TextManagerObject::ptr)(S_1280X1024_005A7574, @@ -106,7 +107,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 5: + case OpenSHC::Rendering::SRE_1366x768: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1366x768" DAT_TextManagerObject::ptr)(S_1366X768_005A7514, @@ -114,7 +115,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 6: + case OpenSHC::Rendering::SRE_1440x900: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1440x900" DAT_TextManagerObject::ptr)(S_1440X900_005A7550, @@ -122,7 +123,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 7: + case OpenSHC::Rendering::SRE_1600x900: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1600x900" DAT_TextManagerObject::ptr)(S_1600X900_005A74F0, @@ -130,7 +131,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 8: + case OpenSHC::Rendering::SRE_1600x1200: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1600x1200" DAT_TextManagerObject::ptr)(S_1600X1200_005A7568, @@ -138,7 +139,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 9: + case OpenSHC::Rendering::SRE_1680x1050: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1680x1050" DAT_TextManagerObject::ptr)(S_1680X1050_005A74FC, @@ -146,7 +147,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 10: + case OpenSHC::Rendering::SRE_1920x1080: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1920x1080" DAT_TextManagerObject::ptr)(S_1920X1080_005A7544, @@ -154,7 +155,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 11: + case OpenSHC::Rendering::SRE_1920x1200: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1920x1200" DAT_TextManagerObject::ptr)(S_1920X1200_005A7538, @@ -162,7 +163,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 12: + case OpenSHC::Rendering::SRE_2560x1440: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "2560x1440" DAT_TextManagerObject::ptr)(S_2560X1440_005A752C, @@ -170,7 +171,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 13: + case OpenSHC::Rendering::SRE_2560x1600: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "2560x1600" DAT_TextManagerObject::ptr)(S_2560X1600_005A7520, @@ -178,7 +179,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 14: + case OpenSHC::Rendering::SRE_1360x768: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1360x768" DAT_TextManagerObject::ptr)(S_1360X768_005A7508, @@ -186,7 +187,7 @@ namespace UI { (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); return; - case 15: + case OpenSHC::Rendering::SRE_1024x600: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, // "1024x600" DAT_TextManagerObject::ptr)(S_1024X600_005A758C, From 6202bb00f44f13dab7f1e5d6ad457f1ea57981a2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 00:59:35 +0100 Subject: [PATCH 57/85] fix: two files that main's header changes stopped compiling MenuItemActionHandler_NewEventCondition_Main: main's 3a1c7f771 (merged in e274e501a) types setSliderParameters2's last parameter NoArgCallback*, so the callback is passed as MACRO_CALL(...) as main's EditScenario calls do, without the (undefined*) cast. MenuItemActionHandler_MapEditorProperties_MainButtons: main's MapPropertiesState declares SEC_SiegeInformation as int[20] (it was a SiegeUnitCounts when the draft was written), so the 20 copies into siegeInformation index it by SiegeUnitCounts' field order; the field each one fills is named on the left. The file had stopped compiling with an earlier main merge on this branch. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...andler_MapEditorProperties_MainButtons.cpp | 40 +++++++++---------- ...emActionHandler_NewEventCondition_Main.cpp | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp index 7594e41884..b1e7e60586 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp @@ -209,7 +209,7 @@ namespace UI { + 8; *pbVar2 += cVar3; DAT_GameState::instance.mapAndTime.siegeInformation.archers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.archers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[0]; piVar7 = DAT_MapPropertiesState::instance.SEC_StartingResources; piVar8 = DAT_GameState::instance.mapAndTime.startGoods; for (iVar6 = 25; iVar6 != 0; --iVar6) { @@ -220,44 +220,44 @@ namespace UI { DAT_GameState::instance.mapAndTime.startGoods[7] = DAT_GameState::instance.mapAndTime.startGoods[8]; DAT_GameState::instance.mapAndTime.siegeInformation.pikemen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.pikemen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[3]; DAT_GameState::instance.mapAndTime.siegeInformation.spearmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.spearmen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[2]; DAT_GameState::instance.mapAndTime.siegeInformation.crossbowmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.crossbowmen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[1]; DAT_GameState::instance.mapAndTime.siegeInformation.knights - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.knights; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[6]; DAT_GameState::instance.mapAndTime.siegeInformation.swordsmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.swordsmen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[5]; DAT_GameState::instance.mapAndTime.siegeInformation.macemen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.macemen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[4]; DAT_GameState::instance.mapAndTime.siegeInformation.monks - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.monks; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[9]; DAT_GameState::instance.mapAndTime.siegeInformation.engineers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.engineers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[8]; DAT_GameState::instance.mapAndTime.siegeInformation.laddermen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.laddermen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[7]; DAT_GameState::instance.mapAndTime.siegeInformation.slingers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.slingers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[12]; DAT_GameState::instance.mapAndTime.siegeInformation.slaves - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.slaves; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[11]; DAT_GameState::instance.mapAndTime.siegeInformation.arabianArchers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.arabianArchers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[10]; DAT_GameState::instance.mapAndTime.siegeInformation.arabianSwordsmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.arabianSwordsmen; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[15]; DAT_GameState::instance.mapAndTime.siegeInformation.horseArchers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.horseArchers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[14]; DAT_GameState::instance.mapAndTime.siegeInformation.assassins - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.assassins; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[13]; DAT_GameState::instance.mapAndTime.siegeInformation.field_0x48 - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.field_0x48; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[18]; DAT_GameState::instance.mapAndTime.siegeInformation.fireBallistas - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.fireBallistas; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[17]; DAT_GameState::instance.mapAndTime.siegeInformation.fireThrowers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.fireThrowers; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[16]; DAT_GameState::instance.mapAndTime.startGoods[8] = 0; DAT_GameState::instance.mapAndTime.siegeInformation.field_0x4c - = DAT_MapPropertiesState::instance.SEC_SiegeInformation.field_0x4c; + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[19]; DAT_GameState::instance.mapAndTime.startingPopularity = DAT_MapPropertiesState::instance.SEC_StartingPopularity * 10; MACRO_CALL_MEMBER(Game::GameStateStructures_Func::setMonthAndYear, DAT_GameState::ptr)( diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp index 5961be2fed..21fb189c27 100644 --- a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp @@ -159,7 +159,7 @@ namespace UI { (dword)((int)(DAT_MissionAestheticsDefinedData::instance .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex])), (dword)((int)((int)*destination)), (dword)((int)(destination)), - (undefined*)MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); + MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, (int)((int)(DAT_ButtonX::instance + 58)), (int)((int)(DAT_ButtonY::instance + 28))); From 82e542549103f6263f13d45a940311e1b47110ce Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 9 Nov 2026 02:43:32 +0100 Subject: [PATCH 58/85] style: the lobby's empty AI slot test by its enum name MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons tests a player's currentAIArray entry against 0 in three places, next to the switch on the same field that already names its cases by AITypeA. Those three tests now compare with AITA_NULL (0 on main), so every use of the field reads the same way. The code is unchanged: quick_diff gives the same output before and after. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp index 5f165e95e6..4865c81758 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -169,7 +169,7 @@ namespace UI { OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); } } - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { return; } iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; @@ -204,7 +204,7 @@ namespace UI { (iVar6 / 32) + 32); DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; } @@ -250,7 +250,7 @@ namespace UI { (iVar3 / 32) + 32); return; } - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == 0) { + if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { DAT_ButtonUnknownZero::instance = 0; return; } From 18494241e1f1d9692a3db9fe7fb8f2200e6c2634 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 13 Nov 2026 16:10:38 +0100 Subject: [PATCH 59/85] drafts: move 0x00492170 VideoOptions_Main to the round 11 PR The button rows each making their own text call, y then x, and the resolution cases in the original's block order take the function from 80.4% to 100.0%, so it moves to the round 11 PR (reimpl/UI-B-round11-100, 028d7610e). This draft drops it, and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...nuItemRenderFunction_VideoOptions_Main.cpp | 243 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 244 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp deleted file mode 100644 index 3232eb277c..0000000000 --- a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemRenderFunction_VideoOptions_Main.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "../VideoOptions.func.hpp" - -#include "OpenSHC/Text/TextManager.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/BGR24.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/string-macros.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_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Rendering::Colors::BGR24; - - // FUNCTION: STRONGHOLDCRUSADER 0x00492170 - void VideoOptions::MenuItemRenderFunction_VideoOptions_Main(int param_1, ...) - { - int iVar1; - int yParam; - BGR24 color; - if (param_1 < -9) { - iVar1 = 0; - if (param_1 == -10) { - if (DAT_MenuTextInputState::instance.menuCursorType == 2) { - iVar1 = 2; - } - iVar1 += 182; - } else { - if (param_1 != -20) { - return; - } - if (DAT_MenuTextInputState::instance.menuCursorType == 1) { - iVar1 = 2; - } - iVar1 += 183; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - return; - } - if (param_1 >= 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - yParam = DAT_ButtonY::instance + 7; - if (!DAT_ButtonCurrentlyInteracting::instance) { - color = OpenSHC::Rendering::Colors::COL_C2F0EB; - 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_GAME_OPTIONS, param_1), - iVar1, yParam, OpenSHC::Text::TTA_CENTER, color, 18, FALSE, 0); - return; - } - } else { - // three tests, not a loop: the original checks -3, -2 and -1 in this order - if (param_1 != -3) { - if (param_1 != -2) { - if (param_1 != -1) { - return; - } - switch (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution) { - case OpenSHC::Rendering::SRE_800x600: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "800x600" - DAT_TextManagerObject::ptr)(S_800X600_005A7598, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1024x768: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1024x768" - DAT_TextManagerObject::ptr)(S_1024X768_005A7580, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1280x720: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1280x720" - DAT_TextManagerObject::ptr)(S_1280X720_005A755C, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1280x1024: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1280x1024" - DAT_TextManagerObject::ptr)(S_1280X1024_005A7574, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1366x768: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1366x768" - DAT_TextManagerObject::ptr)(S_1366X768_005A7514, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1440x900: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1440x900" - DAT_TextManagerObject::ptr)(S_1440X900_005A7550, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1600x900: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1600x900" - DAT_TextManagerObject::ptr)(S_1600X900_005A74F0, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1600x1200: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1600x1200" - DAT_TextManagerObject::ptr)(S_1600X1200_005A7568, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1680x1050: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1680x1050" - DAT_TextManagerObject::ptr)(S_1680X1050_005A74FC, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1920x1080: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1920x1080" - DAT_TextManagerObject::ptr)(S_1920X1080_005A7544, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1920x1200: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1920x1200" - DAT_TextManagerObject::ptr)(S_1920X1200_005A7538, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_2560x1440: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "2560x1440" - DAT_TextManagerObject::ptr)(S_2560X1440_005A752C, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_2560x1600: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "2560x1600" - DAT_TextManagerObject::ptr)(S_2560X1600_005A7520, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1360x768: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1360x768" - DAT_TextManagerObject::ptr)(S_1360X768_005A7508, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - case OpenSHC::Rendering::SRE_1024x600: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, - // "1024x600" - DAT_TextManagerObject::ptr)(S_1024X600_005A758C, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - return; - default: - break; - } - } - // the same sparse switch on the zoom flag (0x4925a3), `case 1` first - switch (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01) { - case 1: - param_1 = 13; - break; - case 0: - param_1 = 14; - break; - default: - return; - } - } else { - // the original dispatches with a `sub eax, K; je` chain (0x4925be), - // MSVC's sparse switch, whose arms are written in the reverse of the - // test order - switch (DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { - case 2: - param_1 = 19; - break; - case 1: - param_1 = 21; - break; - case 0: - param_1 = 20; - break; - default: - return; - } - } - yParam = DAT_ButtonY::instance + 7; - iVar1 = (int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; - } - color = OpenSHC::Rendering::Colors::COL_CCFAFF; - 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_GAME_OPTIONS, param_1), - iVar1, yParam, OpenSHC::Text::TTA_CENTER, color, 18, FALSE, 0); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b7384cc0ac..5ccb42a404 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23453,7 +23453,7 @@ SHC_3BB0A8C1_0x00492080 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00492120 | 0.0% | Pending -SHC_3BB0A8C1_0x00492170 | 80.4% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00492170 | 0.0% | Pending SHC_3BB0A8C1_0x00492620 | 0.0% | Pending From b379b2c4b7c6b241d9edd0d36186612b9d7ad4e5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 01:16:16 +0100 Subject: [PATCH 60/85] drafts: move 0x004909E0 and 0x0042D640 to the round 12 PR ChooseNetworkServiceProvider's Buttons handler (0x004909E0) goes from 79.4% to 100.0% with its join case written without gotos (strlen tests, a found flag and a stored flag, strcpy), and SingleplayerMapChoice's ButtonsAndHands handler (0x0042D640) from 75.1% to 100.0% as one switch in the original's block order. Both move to the round 12 PR (reimpl/UI-B-round12-100, bee3ec3f9 and 25cbd1b3e). This draft drops their .cpp files, and their status lines go back to main's. Main has neither function, and this draft changes no header, so nothing else goes. Co-Authored-By: Claude Opus 5.5 --- ...r_ChooseNetworkServiceProvider_Buttons.cpp | 201 ------------------ ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 173 --------------- status/addresses-SHC-3BB0A8C1.txt | 4 +- 3 files changed, 2 insertions(+), 376 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp b/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp deleted file mode 100644 index 9f29cf886a..0000000000 --- a/src/OpenSHC/UI/MenuItems/ChooseNetworkServiceProvider/MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "../ChooseNetworkServiceProvider.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Synchrony.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/Text/UserTextHandler.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/UI/ChooseNetworkServiceProvider/ChooseNetworkServiceProviderButtonActions.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_UserTextHandlerState.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/Menu_LobbyMenu.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::UI::ChooseNetworkServiceProvider::ChooseNetworkServiceProviderButtonActions; - - // FUNCTION: STRONGHOLDCRUSADER 0x004909E0 - void ChooseNetworkServiceProvider::MenuItemActionHandler_ChooseNetworkServiceProvider_Buttons( - ChooseNetworkServiceProviderButtonActions param_1, ...) - { - char cVar1; - char* pcVar2; - char* pcVar3; - int iVar4; - char (*pacVar5)[20]; - char (*pacVar6)[20]; - char (*pacVar7)[250]; - switch (param_1) { - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_NEXT_IP_ADDRESSUnk: - MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::setTextEntryAndUpdateCursor, DAT_UserTextHandlerState::ptr)( - 5, DAT_GameSynchronyState::instance.ipRelatedArray[DAT_GameSynchronyState::instance.ipArrayIndex]); - iVar4 = DAT_GameSynchronyState::instance.ipArrayIndex + 1; - DAT_GameSynchronyState::instance.ipArrayIndex = iVar4; - if (4 <= iVar4) { - DAT_GameSynchronyState::instance.ipArrayIndex = 0; - } - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_GAMESPY_ARCADEUnk: - if (DAT_GameSynchronyState::instance.gameSpyArcadeAvailable != 0) { - DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; - DAT_GameSynchronyState::instance.openOnClose = TRUE; - } - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_DOWNUnk: - if (DAT_GameSynchronyState::instance.scrollBarItemOffset - < DAT_GameSynchronyState::instance.scrollBarItemCount - 4) { - ++DAT_GameSynchronyState::instance.scrollBarItemOffset; - } - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_SCROLL_UPUnk: - if (0 < DAT_GameSynchronyState::instance.scrollBarItemOffset) { - --DAT_GameSynchronyState::instance.scrollBarItemOffset; - } - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_JOIN_GAME: - DAT_GameSynchronyState::instance.isHost = FALSE; - DAT_GameSynchronyState::instance.kickedAtTime = 0; - if (DAT_GameCore::instance.activeMenuTab.tabType - == OpenSHC::UI::Enums::BASMTT_GRANARY_OR_MPMENU_TCPIP) { - pcVar2 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5); - pcVar3 = pcVar2 + 1; - do { - cVar1 = *pcVar2; - ++pcVar2; - } while (cVar1 != '\0'); - if (pcVar2 != pcVar3) { - pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray; - do { - pacVar5 = pacVar6; - pcVar3 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, - DAT_UserTextHandlerState::ptr)(5); - iVar4 = MACRO_CALL(OpenSHC::OS_Func::__stricmp)(pcVar3, (char const*)((int)(*pacVar5))); - if (iVar4 == 0) - goto LAB_00490c30; - ++pacVar6; - } while ((int)pacVar6 < (int)&DAT_GameSynchronyState::instance + 1088908); - iVar4 = 0; - pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray; - do { - pacVar5 = pacVar6; - do { - pcVar3 = *pacVar5; - pacVar5 = (char (*)[20])(*pacVar5 + 1); - } while (*pcVar3 != '\0'); - if (pacVar5 == (char (*)[20])(*pacVar6 + 1)) { - pcVar3 = MACRO_CALL_MEMBER(OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, - DAT_UserTextHandlerState::ptr)(5); - pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray + iVar4; - do { - cVar1 = *pcVar3; - (*pacVar6)[0] = cVar1; - ++pcVar3; - pacVar6 = (char (*)[20])(*pacVar6 + 1); - } while (cVar1 != '\0'); - goto LAB_00490c30; - } - ++pacVar6; - ++iVar4; - } while ((int)pacVar6 < (int)&DAT_GameSynchronyState::instance + 1088908); - // memcpy and memset compile to the original's dword moves - for (int row = 0; row < 3; ++row) { - memcpy(DAT_GameSynchronyState::instance.ipRelatedArray[row], - DAT_GameSynchronyState::instance.ipRelatedArray[row + 1], - sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[row])); - } - memset(DAT_GameSynchronyState::instance.ipRelatedArray[3], 0, - sizeof(DAT_GameSynchronyState::instance.ipRelatedArray[3])); - pcVar3 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(5); - pacVar6 = DAT_GameSynchronyState::instance.ipRelatedArray + 3; - do { - cVar1 = *pcVar3; - (*pacVar6)[0] = cVar1; - ++pcVar3; - pacVar6 = (char (*)[20])(*pacVar6 + 1); - } while (cVar1 != '\0'); - } - } - LAB_00490c30: - iVar4 = MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, - DAT_GameSynchronyState::ptr)(FALSE); - if (0 <= iVar4) { - DAT_GameSynchronyState::instance.unkEnumerationRelatedBool = false; - DAT_GameSynchronyState::instance.scrollBarIndex = -1; - DAT_GameSynchronyState::instance.scrollBarItemOffset = 0; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::restartDPlaySessionEnumeration, - DAT_GameSynchronyState::ptr)(FALSE); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_FINDING_NETWORK_SESSIONS, FALSE); - } - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_HOST_GAME: - DAT_GameSynchronyState::instance.isHost = TRUE; - DAT_GameSynchronyState::instance.kickedAtTime = 0; - iVar4 = MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::initializeDirectPlayAndCreateOrJoinSession, - DAT_GameSynchronyState::ptr)(FALSE); - if (0 <= iVar4) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - DAT_GameSynchronyState::instance.field_0x106ee4 = 1; - DAT_GameCore::instance.menuTabToSwitchTo.tabType = OpenSHC::UI::Enums::BASMTT_NONE; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_LOBBY_MENU, 0); - MACRO_CALL(OpenSHC::Synchrony_Func::InitSkirmishLobbyData)(); - Menu_LobbyMenu::instance.thousand = 0; - MACRO_CALL(OpenSHC::OS_Func::_memset)(DAT_GameSynchronyState::instance.DAT_PlayerNames, 0, - sizeof(DAT_GameSynchronyState::instance.DAT_PlayerNames)); - pcVar3 = MACRO_CALL_MEMBER( - OpenSHC::Text::UserTextHandler_Func::getTextArrayPointer, DAT_UserTextHandlerState::ptr)(0); - pacVar7 = DAT_GameSynchronyState::instance.DAT_PlayerNames + 1; - do { - cVar1 = *pcVar3; - (*pacVar7)[0] = cVar1; - ++pcVar3; - pacVar7 = (char (*)[250])(*pacVar7 + 1); - } while (cVar1 != '\0'); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::waitForMultiplayerHost, - DAT_GameSynchronyState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_ASK_FOR_SLOT_ASSIGNMENT); - } - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - - return; - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT: - case OpenSHC::UI::ChooseNetworkServiceProvider::CNSPBA_EXIT_ALTUnk: - MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); - DAT_GameSynchronyState::instance.kickedAtTime = 0; - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_MAIN_MENU, 0); - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - - return; - } - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp deleted file mode 100644 index 32163e3ed8..0000000000 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "../SinglePlayerMapChoice.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/UI/Actions.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/DAT_00b960dc.hpp" -#include "OpenSHC/Globals/DAT_00b960f4.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapMissionType.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" -#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" -#include "OpenSHC/Globals/DWORD_00b95b1c.hpp" -#include "OpenSHC/Globals/INT_00b95b74.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042D640 - void SinglePlayerMapChoice::MenuItemActionHandler_SingleplayerMapChoice_ButtonsAndHands(int param_1, ...) - { - if (DAT_MenuTextInputState::instance.currentModalDialog != OpenSHC::UI::Enums::MMT_NO_MENU) { - return; - } - DAT_StopHandlingMenuItems::instance = 0; - if (param_1 < -100) { - if (param_1 == -101) { - int iVar1 = INT_00b95b74::instance - 204; - if ((int)DAT_00b960f4::instance >= iVar1) { - DAT_StopHandlingMenuItems::instance = 0; - } - if (DAT_00b960f4::instance + 14 <= iVar1) { - DAT_00b960f4::instance += 14; - DAT_StopHandlingMenuItems::instance = 0; - } - DAT_00b960f4::instance = iVar1; - return; - } - if (param_1 != -1100) { - if (param_1 != -1000) { - DAT_StopHandlingMenuItems::instance = 0; - return; - } - switchD_0042d6cf_caseD_2: - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - (DAT_MapMissionType::instance == 0 ? OpenSHC::UI::Enums::MVT_MAIN_MENU - : OpenSHC::UI::Enums::MVT_CUSTOM_SCENARIOS), - 10000); - DWORD_00b95b1c::instance = timeGetTime(); - DAT_00b960dc::instance = 1; - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - switchD_0042d6cf_caseD_41: - // Start game - if (-(int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset - > 1 + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected) { - if ((DAT_MapMissionType::instance == 0) || (DAT_MapMissionType::instance == 3)) { - DAT_GameState::instance.mapAndTime.difficulty = 1; - return; - } - MACRO_CALL(OpenSHC::UI::Actions_Func::LaunchSinglePlayerGameUnk)(0); - } - } else { - switch (param_1) { - case 2: - goto switchD_0042d6cf_caseD_2; - case 65: - goto switchD_0042d6cf_caseD_41; - case 66: - // castle builder and landscape mode - if (DAT_MapMissionType::instance != 0) { - DAT_GameSynchronyState::instance.reparseMaps = TRUE; - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_MapMissionType::instance = 0; - return; - } - break; - case 67: - // unknown - if (DAT_MapMissionType::instance != 1) { - DAT_GameSynchronyState::instance.reparseMaps = TRUE; - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_MapMissionType::instance = 1; - return; - } - break; - case 68: - // siege mode - if (DAT_MapMissionType::instance != 2) { - DAT_GameSynchronyState::instance.reparseMaps = TRUE; - DAT_MapMissionType::instance = 2; - return; - } - break; - case 69: - // difficulty button - if ((DAT_GameCore::instance.mapU4Int1_2 == 0) && (DAT_MapMissionType::instance != 0)) { - ++DAT_GameState::instance.mapAndTime.difficulty; - if (4 <= DAT_GameState::instance.mapAndTime.difficulty) { - DAT_GameState::instance.mapAndTime.difficulty = 0; - } - MACRO_CALL(OpenSHC::UI::Helpers_Func::SomeSiegeRelatedCopying)( - DAT_GameState::instance.mapAndTime.difficulty); - } - break; - case 74: - // Advanced? - if (DAT_GameCore::instance.mapU4Int1_2 == 0 && DAT_MapMissionType::instance == 2 - && DAT_GameSynchronyState::instance.currentPlayerSlotID == 2) { - DAT_SH1_SiegeAdvancedMode::instance ^= 1; - return; - } - break; - case 76: - if (DAT_MapMissionType::instance != 3) { - DAT_GameSynchronyState::instance.reparseMaps = TRUE; - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_MapMissionType::instance = 3; - return; - } - break; - case 77: - // "Attacking" or "Defending" - if ((DAT_MapMissionType::instance == 2) && (DAT_GameCore::instance.mapU4Int1_2 == 0)) { - if (DAT_GameSynchronyState::instance.currentPlayerSlotID != 1) { - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_SH1_SiegeAdvancedMode::instance = 0; - return; - } - DAT_GameSynchronyState::instance.currentPlayerSlotID = 2; - return; - } - break; - case -100: - DAT_00b960f4::instance -= 14; - if ((int)DAT_00b960f4::instance < 0) { - DAT_00b960f4::instance = 0; - return; - } - break; - case -11: - if ((int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset - < (int)DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 13) { - ++DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; - MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: - MenuItemActionHandler_SingleplayerMapChoice_MapTable)( - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); - return; - } - break; - case -10: - if (0 < (int)DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset) { - --DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; - MACRO_CALL(OpenSHC::UI::MenuItems::SinglePlayerMapChoice_Func:: - MenuItemActionHandler_SingleplayerMapChoice_MapTable)( - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); - } - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 5ccb42a404..c577c188d8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7865,7 +7865,7 @@ SHC_3BB0A8C1_0x0042D632 | 0.0% | Pending SHC_3BB0A8C1_0x0042D633 | 0.0% | Pending -SHC_3BB0A8C1_0x0042D640 | 75.1% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x0042D640 | 0.0% | Pending SHC_3BB0A8C1_0x0042D8B0 | 0.0% | Pending @@ -23383,7 +23383,7 @@ SHC_3BB0A8C1_0x00490690 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00490920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004909E0 | 79.4% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004909E0 | 0.0% | Pending SHC_3BB0A8C1_0x00490C20 | 0.0% | Pending From 3e3b70587a9c60781232dae21139417428309750 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 14 Nov 2026 13:16:45 +0100 Subject: [PATCH 61/85] drafts: move 0x004D8EC0 to the round 13 PR CrusadeMap's Main handler (0x004D8EC0) goes from 35.2% here to 100.0% in the round 13 PR (reimpl/UI-B-round13-100, cf7b873a3), rewritten from the binary with two fixes this draft needed too: two trails tested the click's y the wrong way round, and two mission searches went one mission too far. It also has one cleanup: a click wrote back all three trails' progress, where the original stores only the trail being played. 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 --- .../MenuItemActionHandler_CrusadeMap_Main.cpp | 180 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 181 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp b/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp deleted file mode 100644 index 4b56563b3a..0000000000 --- a/src/OpenSHC/UI/MenuItems/CrusadeMap/MenuItemActionHandler_CrusadeMap_Main.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "../CrusadeMap.func.hpp" - -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/Game/TrailType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.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_MissionDefinedData.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_SkirmishTrailRelated1.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DWORD_00ed27a8.hpp" -#include "OpenSHC/Globals/DWORD_00ed311c.hpp" -#include "OpenSHC/Globals/INT_00eb9b48.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004D8EC0 - void CrusadeMap::MenuItemActionHandler_CrusadeMap_Main(int param_1, ...) - { - int iVar1; - int iVar2; - dword dVar3; - int iVar5; - if (param_1 == 1000) { - if ((int)DAT_SkirmishTrailRelated1::instance <= 0) { - return; - } - if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { - iVar1 = DAT_GameCore::instance.furthestSkirmishTrailMission; - if (iVar1 >= 49) { - return; - } - DAT_GameCore::instance.skirmishTrailProgress = iVar1; - if (DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[iVar1] != -1) { - return; - } - DAT_GameCore::instance.skirmishTrailMonthsTakenOrChicken[iVar1] = -1200; - if (DAT_GameCore::instance.skirmishTrailProgress == 49) { - return; - } - ++DAT_GameCore::instance.skirmishTrailProgress; - ++DAT_GameCore::instance.furthestSkirmishTrailMission; - iVar5 = 1; - } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { - iVar1 = DAT_GameCore::instance.furthestWarchestTrailMission; - if (iVar1 >= 29) { - return; - } - DAT_GameCore::instance.warchestTrailProgress = iVar1; - if (DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[iVar1] != -1) { - return; - } - DAT_GameCore::instance.warchestTrailMonthsTakenOrChicken[iVar1] = -1200; - if (DAT_GameCore::instance.warchestTrailProgress == 29) { - return; - } - ++DAT_GameCore::instance.warchestTrailProgress; - ++DAT_GameCore::instance.furthestWarchestTrailMission; - iVar5 = 2; - } else { - if (DAT_GameCore::instance.currentTrailType != OpenSHC::Game::TT_EXTREME) { - return; - } - iVar1 = DAT_GameCore::instance.furthestExtremeTrailMission; - if (iVar1 >= 19) { - return; - } - DAT_GameCore::instance.extremeTrailProgress = iVar1; - if (DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[iVar1] != -1) { - return; - } - DAT_GameCore::instance.extremeTrailMonthsTakenOrChicken[iVar1] = -1200; - if (DAT_GameCore::instance.extremeTrailProgress == 19) { - return; - } - ++DAT_GameCore::instance.extremeTrailProgress; - ++DAT_GameCore::instance.furthestExtremeTrailMission; - iVar5 = 3; - } - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::setStartDateUnk, DAT_GameCore::ptr)(iVar5); - --DAT_SkirmishTrailRelated1::instance; - DWORD_00ed311c::instance = timeGetTime(); - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setSoundWithVariation, DAT_SFXState::ptr)( - 258, 100); - return; - } else { - if (param_1 == 10) { - // copy bitmap of icon - MACRO_CALL(OpenSHC::OS_Func::_memcpy)( - (void*)((DAT_GameSynchronyState::instance.currentPlayerSlotID + 19) * 8448 - + (int)DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94), - (void*)((DAT_GameCore::instance.lordIconUnk - 2) * 8448 - + (int)DAT_TextureRenderCoreObject::instance.bitmapsFaces_0x94), - 8448); - DAT_TextureRenderCoreObject::instance - .bitmapFaceSizes[DAT_GameSynchronyState::instance.currentPlayerSlotID + 19] = 8448; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_CRUSADE_MISSION_INTRO, 0); - } - if (param_1 == 11) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_SELECT_CRUSADE, 0); - } - if (param_1 == 1) { - int _clickX = DAT_MouseState::instance.screenSpaceX - DAT_ButtonX::instance; - int _clickY = DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance; - dword dVar4 = DAT_GameCore::instance.warchestTrailProgress; - iVar5 = DAT_GameCore::instance.extremeTrailProgress; - if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_FIRST_EDITION) { - dVar3 = 0; - do { - if ((int)dVar3 > DAT_GameCore::instance.furthestSkirmishTrailMission) { - return; - } - iVar1 = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[dVar3][0]; - iVar2 = DAT_MissionDefinedData::instance.SkirmishTrailMissionPositions[dVar3][1]; - if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 + -_clickY >= 10 - && _clickY <= iVar2 + 10) { - LAB_004d9190: - DAT_GameCore::instance.extremeTrailProgress = iVar5; - DAT_GameCore::instance.warchestTrailProgress = dVar4; - DAT_GameCore::instance.skirmishTrailProgress = dVar3; - INT_00eb9b48::instance = 1; - DWORD_00ed27a8::instance = timeGetTime(); - return; - } - ++dVar3; - } while ((int)dVar3 < 50); - } else { - dVar3 = DAT_GameCore::instance.skirmishTrailProgress; - if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_WARCHEST) { - dVar4 = 0; - while ((int)dVar4 <= DAT_GameCore::instance.furthestWarchestTrailMission) { - iVar1 = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[dVar4][0]; - iVar2 = DAT_MissionDefinedData::instance.WarchestTrailMissionPositions[dVar4][1]; - if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 - 10 <= _clickY - && _clickY <= iVar2 + 10) - goto LAB_004d9190; - ++dVar4; - if ((int)dVar4 > 30) { - return; - } - } - } else if (DAT_GameCore::instance.currentTrailType == OpenSHC::Game::TT_EXTREME) { - iVar5 = 0; - while (iVar5 <= DAT_GameCore::instance.furthestExtremeTrailMission) { - iVar1 = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[iVar5][0]; - iVar2 = DAT_MissionDefinedData::instance.ExtremeTrailMissionPositions[iVar5][1]; - if (iVar1 - 10 <= _clickX && _clickX <= iVar1 + 10 && iVar2 + -_clickY >= 10 - && _clickY <= iVar2 + 10) - goto LAB_004d9190; - ++iVar5; - if (20 < iVar5) { - return; - } - } - } - } - } else if (param_1 == 99) { - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_RANKING_GAMES, 0); - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - OpenSHC::Audio::SFX::SEID_UNKNOWN_0xFD); - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index c577c188d8..aea484bc40 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -36013,7 +36013,7 @@ SHC_3BB0A8C1_0x004D8DC0 | 0.0% | Pending SHC_3BB0A8C1_0x004D8DF0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D8EC0 | 35.2% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004D8EC0 | 0.0% | Pending SHC_3BB0A8C1_0x004D91D0 | 0.0% | Pending From 5fca8b920ecdc5c1352fd7c777ec6d290d226c8e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:28:57 +0100 Subject: [PATCH 62/85] fix: two drafts build against main's ViewportState::mouseFlatTile Main's Ghidra sync (1b36c0ad7) renamed ViewportState's field at 0x0C from mouseTile to mouseFlatTile. PeasantBuildAndRightClickMenuSelection (0x00434350) and MapEditorLandscaping's QueueCommandCallback (0x00443A30) use the new name. quick_diff on main e086ba7c3, where neither compiled before: 0.7911 and 0.3184. Co-Authored-By: Claude Opus 5.5 --- ...er_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp | 6 +++--- ...ionHandler_MapEditorLandscaping_QueueCommandCallback.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp index 282812529f..437f7c96cf 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp @@ -192,7 +192,7 @@ namespace UI { DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; } MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseTile); + DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); if (!DAT_MouseState::instance.leftClickState) { if (DAT_UnitsState::instance .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] @@ -210,11 +210,11 @@ namespace UI { } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { if ((DAT_MouseState::instance.leftClickStart == 0) && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile - == DAT_ViewportRenderState::instance.viewportState.mouseTile)) { + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { return; } DAT_ViewportRenderState::instance.viewportState.previousMouseTile - = DAT_ViewportRenderState::instance.viewportState.mouseTile; + = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; MACRO_CALL_MEMBER( OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); } diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp index e0a0988a86..543fe2a970 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp @@ -86,7 +86,7 @@ namespace UI { MACRO_CALL_MEMBER( OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseTile); + DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); 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 @@ -109,11 +109,11 @@ namespace UI { } if ((DAT_MouseState::instance.leftClickStart == 0) && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile - == DAT_ViewportRenderState::instance.viewportState.mouseTile)) { + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { return; } DAT_ViewportRenderState::instance.viewportState.previousMouseTile - = DAT_ViewportRenderState::instance.viewportState.mouseTile; + = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; MACRO_CALL_MEMBER( OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); int iVar2 = DAT_ViewportRenderState::instance.viewportState.mouseTileY; From 07a33e2bb47d7a0a93c86b213d0a7050906d5bd4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 05:28:57 +0100 Subject: [PATCH 63/85] style: DAT_ButtonUnknownZero stores TRUE and FALSE DAT_ButtonUnknownZero is a BOOLEnum; the 92 stores of 1 and 0 in seven drafts are written TRUE and FALSE. Same value, same instructions. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_Allies_Main.cpp | 12 ++--- ...erFunction_BuildMenu_UnitActionButtons.cpp | 48 +++++++++---------- ...erFunction_General_AdvancedGameOptions.cpp | 6 +-- ...mRenderFunction_InGameMenu_MainButtons.cpp | 40 ++++++++-------- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 28 +++++------ ...enderFunction_ScenarioDescription_Main.cpp | 48 +++++++++---------- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 2 +- 7 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp index 034299ee68..74127600a8 100644 --- a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp @@ -57,7 +57,7 @@ namespace UI { return; } if (DAT_AlliesCount::instance < 1 && param_1 != -1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; } if ((param_1 == 110) || (param_1 == 111)) { @@ -75,10 +75,10 @@ namespace UI { [DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]] .isNotNervousByEnemyTroopValue == 0) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); } if (param_1 == 200) { @@ -92,7 +92,7 @@ namespace UI { 18, FALSE); DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; if (19 < (uint)param_1) { MACRO_CALL( OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); @@ -119,7 +119,7 @@ namespace UI { } iVar3 = param_1 - 1; if (DAT_AlliesCount::instance <= iVar3) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; } iVar6 = 0; iVar2 = DAT_SomeTeamMemberPlayerIDArray::instance[iVar3]; @@ -225,7 +225,7 @@ namespace UI { return; } if (param_1 != 10) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; } iVar3 = DAT_ButtonX::instance; iVar2 = DAT_ButtonY::instance; diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp index 6b06bcdd8a..53a980eb96 100644 --- a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp @@ -46,10 +46,10 @@ namespace UI { BVar1 = MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::isMapperAvailable, DAT_MapPropertiesState::ptr)((OpenSHC::Commands::MappersEnum)mapperValue); if (!BVar1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; switch ((int)DAT_CurrentButtonGmDataIndex::instance) { case 376: // Without an engineer selected the button hides, as in the original (jne to the shared hide). @@ -74,7 +74,7 @@ namespace UI { DAT_CurrentButtonGmDataIndex::instance = 377; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } } @@ -89,7 +89,7 @@ namespace UI { uVar3 != 0)) { MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } break; @@ -122,7 +122,7 @@ namespace UI { LAB_00438e95: MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber, DAT_TextManagerObject::ptr)( iVar2, xPosition, yPosition, uVar3, color2, fontSize, BVar1); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } break; @@ -142,7 +142,7 @@ namespace UI { DAT_00ee1090::instance = 198; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } } else { @@ -153,7 +153,7 @@ namespace UI { DAT_00ee1090::instance = 201; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } uVar3 @@ -190,7 +190,7 @@ namespace UI { iVar2 == 0)) { MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } } @@ -200,7 +200,7 @@ namespace UI { UVar4 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance @@ -209,7 +209,7 @@ namespace UI { DAT_ButtonCurrentlyInteracting::instance = TRUE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } goto LAB_00438f47; @@ -217,7 +217,7 @@ namespace UI { UVar4 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance @@ -226,7 +226,7 @@ namespace UI { DAT_ButtonCurrentlyInteracting::instance = TRUE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } goto LAB_00438f47; @@ -234,7 +234,7 @@ namespace UI { UVar4 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance @@ -243,31 +243,31 @@ namespace UI { DAT_ButtonCurrentlyInteracting::instance = TRUE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } LAB_00438f47: DAT_ButtonCurrentlyInteracting::instance = FALSE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; case 216: if (DAT_UnitsState::instance.hasEngineerSelected) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } UVar4 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_TribesState::instance.patrolButtonPressed) { DAT_ButtonCurrentlyInteracting::instance = TRUE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } goto LAB_00438ec1; @@ -278,34 +278,34 @@ namespace UI { case 215: case 558: if (DAT_UnitsState::instance.hasEngineerSelected != TRUE) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } uVar3 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); if (uVar3 == 0) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } goto LAB_00438ec1; default: if (DAT_UnitsState::instance.hasEngineerSelected) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } UVar4 = MACRO_CALL_MEMBER( OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } LAB_00438ec1: MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; } } diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp index 41c402540e..b6a8ef527c 100644 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp +++ b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp @@ -78,12 +78,12 @@ namespace UI { if ((param_1 == 103) && (DAT_ButtonUnknownZero::instance = 0, DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (!DAT_GameSynchronyState::instance.isHost) { if (param_1 == 103) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (param_1 == 93) { @@ -91,7 +91,7 @@ namespace UI { } } if (param_1 == -1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (param_1 != 103) { diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp index 8ee64e51bd..4705b3d7b0 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp @@ -47,12 +47,12 @@ namespace UI { int iVar3; bool bVar4; iVar3 = 0; - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; 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)) && param_1 != 71 && param_1 != -4 && param_1 <= -10) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.activeMenuTab.tabType == param_1) { @@ -63,11 +63,11 @@ namespace UI { } LAB_0046444e: if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } } else { @@ -78,7 +78,7 @@ namespace UI { if (param_1 == -4) { if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } goto LAB_00464732; @@ -86,14 +86,14 @@ namespace UI { if (param_1 == -5) { if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) && (DAT_GameCore::instance.field_0x6c != 0)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; } else if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL || (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk))) { LAB_004644dc: - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; return; } @@ -109,14 +109,14 @@ namespace UI { if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } LAB_004645c8: if ((param_1 == -90) || (param_1 == -91)) { if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) @@ -125,7 +125,7 @@ namespace UI { goto LAB_004645f5; if (param_1 == -90) { DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } } else { @@ -138,7 +138,7 @@ namespace UI { } else { if (param_1 <= -10 && param_1 != -90 && param_1 != -91) { if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (-100 < param_1) { @@ -146,11 +146,11 @@ namespace UI { if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION) { if (5 < iVar1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } } else if (iVar1 != 1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; } } if (iVar1 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { @@ -161,13 +161,13 @@ namespace UI { if (param_1 == -1) { if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; return; } if ((DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_QUIT_DIALOG) && (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; return; } @@ -187,7 +187,7 @@ namespace UI { if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } LAB_004645ad: @@ -203,13 +203,13 @@ namespace UI { if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } } else { if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) && (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } iVar1 @@ -219,7 +219,7 @@ namespace UI { || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_STOCKS))) { if ((param_1 != -90) && (param_1 != -91)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; @@ -261,7 +261,7 @@ namespace UI { } } if ((param_1 == -2) && (DAT_WallAndPitchState::instance.countdown == 0)) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_ButtonCurrentlyInteracting::instance = FALSE; iVar3 = 2; } diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp index 4865c81758..8263d7eec2 100644 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -96,7 +96,7 @@ namespace UI { if (10 < param_1) { iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; if (iVar3 < 1) { return; } @@ -182,7 +182,7 @@ namespace UI { } if (0 < param_1) { iVar3 = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[param_1]; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; if (iVar3 < 1) { return; } @@ -235,7 +235,7 @@ namespace UI { return; } iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1089092 - param_1)); - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; if (iVar3 < 1) { return; } @@ -251,7 +251,7 @@ namespace UI { return; } if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } DAT_CurrentButtonGmDataIndex::instance = 627; @@ -275,23 +275,23 @@ namespace UI { (iVar3 / 32) + 32); } if (param_1 < -199) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; if (!DAT_GameSynchronyState::instance.isHost) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1088892 - param_1)); if (iVar3 < 1) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameSynchronyState::instance.slotActionPending[iVar3] != 0) { - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; return; } iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; @@ -299,7 +299,7 @@ namespace UI { (iVar3 / 32) + 32); } if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } BVar2 = MACRO_CALL_MEMBER( @@ -312,7 +312,7 @@ namespace UI { (iVar3 / 32) + 32); } if (param_1 == -101) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; if ((DAT_GameSynchronyState::instance.isHost) && (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE)) { for (int iVar3 = 1; iVar3 < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); @@ -325,7 +325,7 @@ namespace UI { } else { if (param_1 == -102) { if (!DAT_GameSynchronyState::instance.isHost) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE @@ -338,11 +338,11 @@ namespace UI { if (param_1 != -103) goto LAB_00427f4c; if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; } } LAB_00427f46: - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; } LAB_00427f4c: if (!DAT_GameSynchronyState::instance.isHost) { diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp index b0d685b633..43dc7c924c 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -33,23 +33,23 @@ namespace UI { { bool bVar1; uint uVar2; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_StopHandlingMenuItems::instance = 0; if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && param_1 != 10 && param_1 != 12 && param_1 != 13 && param_1 != -3 && param_1 != -4 && param_1 != -1) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if ((INT_00ed27bc::instance == 1) && (param_1 != 12)) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (param_1 == -1) { if ((DAT_00ed2798::instance) && (DAT_00ed2798::instance != 1)) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { @@ -59,23 +59,23 @@ namespace UI { } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk)) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.mapU4Int1) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameSuspended == 1) { DAT_ButtonCurrentlyInteracting::instance = FALSE; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { @@ -95,20 +95,20 @@ namespace UI { if (param_1 == -2) { if (DAT_00ed2798::instance) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (INT_00ed27bc::instance) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { @@ -125,15 +125,15 @@ namespace UI { if (param_1 == -3) { if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameSuspended != 1) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { @@ -150,15 +150,15 @@ namespace UI { if (param_1 == -4) { if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (INT_00ed27c4::instance < 2) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); if (!DAT_ButtonCurrentlyInteracting::instance) { @@ -176,27 +176,27 @@ namespace UI { && INT_00ed27bc::instance != 1) { if (param_1 == 12) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } LAB_004d8543: if (param_1 == 13) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) goto LAB_004d8563; if (param_1 == 12) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } bVar1 = param_1 == 13; } else { if (param_1 == 11) { DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; return; } if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) @@ -205,12 +205,12 @@ namespace UI { bVar1 = param_1 == 12; } if (bVar1) { - DAT_ButtonUnknownZero::instance = 1; + DAT_ButtonUnknownZero::instance = TRUE; DAT_StopHandlingMenuItems::instance = 0; return; } LAB_004d8563: - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); } diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp index 27912f0023..3fdd2e5b98 100644 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp +++ b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp @@ -203,7 +203,7 @@ namespace UI { default: goto switchD_0042d163_caseD_ffffff9d; } - DAT_ButtonUnknownZero::instance = 0; + DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)(iVar1 + 32); switchD_0042d163_caseD_ffffff9d: DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; From 5ef28e73c3d4c2fcaf0259146960cc1741b64c0e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 20:29:19 +0100 Subject: [PATCH 64/85] drafts: move MainButtons render, Roundtable's click handler and BuySellMenuButtonsAndHands to the round 15 PR MenuItemRenderFunction_InGameMenu_MainButtons (0x004643F0) and MenuItemActionHandler_Roundtable_Main (0x004AEA50) reach 100% under /GL, and MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands (0x00467040) is 100% by register allocation only (#414); they go out in reimpl/UI-B-round15-100. Their files leave this draft and their status lines go back to main's. Co-Authored-By: Claude Opus 5.5 --- ...dStatusMenu_BuySellMenuButtonsAndHands.cpp | 173 ---------- ...mRenderFunction_InGameMenu_MainButtons.cpp | 300 ------------------ .../MenuItemActionHandler_Roundtable_Main.cpp | 230 -------------- status/addresses-SHC-3BB0A8C1.txt | 6 +- 4 files changed, 3 insertions(+), 706 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp deleted file mode 100644 index 48c6068ed9..0000000000 --- a/src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "../BuildingAndStatusMenu.func.hpp" - -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Game/GameStateStructures.func.hpp" -#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/UI/Actions.func.hpp" -#include "OpenSHC/Audio/SFX/SoundEffectID.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/Game/Resources/ResourceType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/BOOL_CurrentMenuClickState.hpp" -#include "OpenSHC/Globals/DAT_BuildingsState.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - namespace BuildingAndStatusMenu { - - using Game::Resources::ResourceType; - - // FUNCTION: STRONGHOLDCRUSADER 0x00467040 - void MenuItemActionHandler_BuildingAndStatusMenu_BuySellMenuButtonsAndHands(int param_1, ...) - { - // Buttons 2 and 3 step through the goods (partial pitch shows as pitch), 0 buys and 1 sells. - if (param_1 == 2) { - int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getPreviousGoodsFilteringUnallowed, - DAT_GameState::ptr)((ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (resource == Game::Resources::RT_PARTIALPITCH) { - resource = Game::Resources::RT_PITCH; - } - MACRO_CALL( - BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( - resource); - return; - } - if (param_1 == 3) { - int resource = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getNextGoodFilteringUnallowed, - DAT_GameState::ptr)((ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (resource == Game::Resources::RT_PARTIALPITCH) { - resource = Game::Resources::RT_PITCH; - } - MACRO_CALL( - BuildingAndStatusMenu_Func::MenuItemActionHandler_BuildingAndStatusMenu_SelectBuySellGoods)( - resource); - return; - } - BOOL_CurrentMenuClickState::instance = FALSE; - if (param_1 == 0) { - int const price = MACRO_CALL_MEMBER(Game::GameStateStructures_Func::getBatchBuyPrice, - DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[Game::Resources::RT_GOLD] - < price) { - MACRO_CALL(Actions_Func::SetStorageMarketFailState)(1, - (ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - // "space_warning8.wav": not enough gold - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning8_wav_005a5964); - return; - } - int const space = MACRO_CALL_MEMBER(Map::Buildings::BuildingsState_Func::getResourceSpace, - DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, - (ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (space == -1) { - MACRO_CALL(Actions_Func::SetStorageMarketFailState)(3, - (ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 6) { - // "space_warning2.wav": no stockpile built - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning2_wav_005a5950); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 5) { - // "space_warning1.wav": no granary built - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning1_wav_005a593c); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 7) { - // "space_warning3.wav": no armory built - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning3_wav_005a5928); - } - return; - } - if (space < 5) { - MACRO_CALL(Actions_Func::SetStorageMarketFailState)(4, - (ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType); - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 9) { - // "space_warning5.wav": no space in the stockpile - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning5_wav_005a50b0); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 8) { - // "space_warning4.wav": no space in the granary - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning4_wav_005a5914); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 10) { - // "space_warning6.wav": no space in the armory - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning6_wav_005a5900); - } - return; - } - } else if (param_1 == 1) { - ResourceType const resource - = (ResourceType)DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType; - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[resource] - <= 0) { - MACRO_CALL(Actions_Func::SetStorageMarketFailState)(2, resource); - // "space_warning7.wav": not enough goods - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - s_space_warning7_wav_005a58ec); - return; - } - } - if (param_1 == 0 || param_1 == 1) { - MACRO_CALL_MEMBER(Audio::SFX::SFXState_Func::setUpSFXToPlayUnk, DAT_SFXState::ptr)( - Audio::SFX::SEID_DRAWBRIDGE_CONTROL); - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState = 0; - } - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = param_1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 - = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .marketSelectedResourceType; - MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - Commands::GCT_BUY_OR_SELL); - } - - } - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp deleted file mode 100644 index 4705b3d7b0..0000000000 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemRenderFunction_InGameMenu_MainButtons.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#include "../InGameMenu.func.hpp" - -#include "OpenSHC/Game/GameStateStructures.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/ButtonGmData.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Map/MapType2.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonH.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" -#include "OpenSHC/Globals/DAT_WallAndPitchState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004643F0 - void InGameMenu::MenuItemRenderFunction_InGameMenu_MainButtons(int param_1, ...) - { - ButtonGmData* buttonGmData; - int iVar1; - int iVar2; - int iVar3; - bool bVar4; - iVar3 = 0; - DAT_ButtonUnknownZero::instance = FALSE; - 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)) - && param_1 != 71 && param_1 != -4 && param_1 <= -10) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_GameCore::instance.activeMenuTab.tabType == param_1) { - if (param_1 != 71) { - iVar3 = 2; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - goto LAB_00464449; - } - LAB_0046444e: - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - } else { - LAB_00464449: - if (param_1 == 71) - goto LAB_0046444e; - } - if (param_1 == -4) { - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) - && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - goto LAB_00464732; - } - if (param_1 == -5) { - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) - && (DAT_GameCore::instance.field_0x6c != 0)) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } else if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL - || (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION - && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk))) { - LAB_004644dc: - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - return; - } - } else { - if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) - goto LAB_004644dc; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) { - bVar4 = DAT_GameCore::instance.isSkirmishTrail == TRUE; - goto LAB_004644d6; - } - } - LAB_004645b6: - if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) - && (DAT_GameCore::instance.activeMenuTab.tabType - == OpenSHC::UI::Enums::BASMTT_SIEGETENT_BATTERINGRAM)) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - LAB_004645c8: - if ((param_1 == -90) || (param_1 == -91)) { - if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION) - || (DAT_GameSynchronyState::instance.currentGameMode - != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) - goto LAB_004645f5; - if (param_1 == -90) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - } else { - LAB_004645f5: - if (param_1 == -90) - goto LAB_00464611; - } - if (param_1 == -91 || (10 <= param_1 && (param_1 <= 49))) - goto LAB_00464611; - } else { - if (param_1 <= -10 && param_1 != -90 && param_1 != -91) { - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (-100 < param_1) { - iVar1 = -9 - param_1; - if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == OpenSHC::Map::MT_INVASION) { - if (5 < iVar1) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - } else if (iVar1 != 1) { - DAT_ButtonUnknownZero::instance = TRUE; - } - } - if (iVar1 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - iVar3 = 8; - } - } - } - if (param_1 == -1) { - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - return; - } - if ((DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_QUIT_DIALOG) - && (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47)) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - return; - } - goto LAB_004645b6; - } - if (param_1 == -6) { - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { - bVar4 = DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT; - LAB_004644d6: - if (!bVar4) - goto LAB_004644dc; - } - goto LAB_004645b6; - } - if ((param_1 == 29) || (param_1 == 26)) { - LAB_004645a4: - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) - && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT)) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - LAB_004645ad: - if ((param_1 <= -1) && (-10 < param_1)) - goto LAB_004645b6; - goto LAB_004645c8; - } - if (param_1 != 27) - goto LAB_004645ad; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT) - goto LAB_004645a4; - LAB_00464611: - if ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT)) { - if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - } else { - if ((DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) - && (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_SOLDIERS)) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - iVar1 - = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, - DAT_GameState::ptr)(); - if (iVar1 < 1 - || (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU - && (DAT_GameCore::instance.activeMenuTab.tabType == OpenSHC::UI::Enums::BASMTT_STOCKS))) { - if ((param_1 != -90) && (param_1 != -91)) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - iVar3 = 1; - switch (param_1) { - case 10: - iVar3 = 54; - break; - case 20: - iVar3 = 55; - break; - case 40: - iVar3 = 56; - break; - case 30: - iVar3 = 57; - break; - case 28: - iVar3 = 58; - break; - case 25: - iVar3 = 59; - break; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)( - (OpenSHC::DE::SHCDE::eGM)(DAT_UIButtonDefinedData::instance - .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .gmId_0x0), - iVar3, (int)(DAT_ButtonX::instance), DAT_ButtonY::instance); - DAT_CurrentButtonPictureInGm::instance = iVar3; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } - } - } - if ((param_1 == -2) && (DAT_WallAndPitchState::instance.countdown == 0)) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - iVar3 = 2; - } - LAB_00464732: - buttonGmData = DAT_UIButtonDefinedData::instance.ButtonGmDataArray + DAT_CurrentButtonGmDataIndex::instance; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - iVar2 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::ButtonGmData_Func::getPictureNumberInGm, buttonGmData)( - DAT_ButtonCurrentlyInteracting::instance); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)(buttonGmData->gmId_0x0), iVar2 + iVar3, - DAT_ButtonX::instance, DAT_ButtonY::instance); - DAT_CurrentButtonPictureInGm::instance - = DAT_UIButtonDefinedData::instance.ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] - .pictureInGm_0x4 - + iVar3; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if (param_1 == -4) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - DAT_ButtonX::instance - 1, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 1), - (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( - DAT_ButtonX::instance - 2, (int)(DAT_ButtonY::instance + 17), (int)(DAT_ButtonX::instance - 2), - (int)(DAT_ButtonH::instance - 1 + DAT_ButtonY::instance), (ushort)(COL_BLACK::instance.shortValue)); - return; - } - if (param_1 == 71) { - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderScribeFrame)(); - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderGoldValue)(); - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp b/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp deleted file mode 100644 index a65b4ba587..0000000000 --- a/src/OpenSHC/UI/MenuItems/Roundtable/MenuItemActionHandler_Roundtable_Main.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "../Roundtable.func.hpp" - -#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Random/RNG.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/AI/AITypeA.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_00df423c.hpp" -#include "OpenSHC/Globals/DAT_00df4240.hpp" -#include "OpenSHC/Globals/DAT_00df4298.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/INT_00df4244.hpp" -#include "OpenSHC/Globals/SEC_RNG.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004AEA50 - void Roundtable::MenuItemActionHandler_Roundtable_Main(int param_1, ...) - { - BOOLEnum BVar3; - int playerID_01; - if (!DAT_GameSynchronyState::instance.isHost) { - return; - } - if (param_1 < 9) { - if (DAT_00df423c::instance != 0) { - param_1 += 10; - } - if (param_1 < 9) { - DAT_00df423c::instance = param_1; - INT_00df4244::instance = 0; - } - } - if ((param_1 - 0xbU < 8) && (DAT_00df423c::instance != 0)) { - int playerID - = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); - playerID_01 - = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]; - if (0 < playerID_01 && 0 < playerID && playerID != playerID_01 - && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_01] != -1 - || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, - DAT_GameSynchronyState::ptr)(playerID_01), - BVar3)) - && (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID] != -1 - || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, - DAT_GameSynchronyState::ptr)(playerID), - BVar3))) { - int iVar4 = 0; - for (int playerID_00 = 1; - playerID_00 < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); - ++playerID_00) { - if ((DAT_GameSynchronyState::instance.currentPlayerFullIDArray[playerID_00] != -1) - || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, - DAT_GameSynchronyState::ptr)(playerID_00), - BVar3)) { - ++iVar4; - } - } - if (2 < iVar4) { - if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_RAT) - && (DAT_00df4240::instance == 0)) { - if (DAT_GameCore::instance.genieVoiceActive) { - // "Not the rodent" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "Genie_13.wav" - s_Genie_13_wav_005a7710); - } - DAT_00df4240::instance = 1; - } - if ((DAT_GameSynchronyState::instance.currentAIArray[playerID_01] == OpenSHC::AI::AITA_SULTAN) - && (DAT_00df4298::instance == 0)) { - if (DAT_GameCore::instance.genieVoiceActive) { - // "Oh no" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "Genie_14.wav" - s_Genie_14_wav_005a7700); - } - DAT_00df4298::instance = 1; - } - } - int bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID]; - if ((DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] != bVar1) - || (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] == 0)) { - if (bVar1 == 0) { - bVar1 = 0; - for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { - if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i] - && (char)bVar1 < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { - bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]; - } - } - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( - char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] - = bVar1 + 1; - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[*( - char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 - + 26)] = bVar1 + 1; - MACRO_CALL_MEMBER( - OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); - BVar3 = MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::shouldSoundXNotBePlaying, - DAT_SoundSystemState::ptr)(); - if (!BVar3 && 2 < iVar4 && DAT_GameCore::instance.genieVoiceActive) { - MACRO_CALL_MEMBER(OpenSHC::Random::RNG_Func::nextRandomNumber1, SEC_RNG::ptr)(); - switch ((int)SEC_RNG::instance.currentNumber1 % 7) { - case 0: - // "We will be invincible" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_05.wav" - DAT_SFXState::ptr)(s_genie_05_wav_005a76f0); - break; - case 1: - // "A worthy ally" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_06.wav" - DAT_SFXState::ptr)(s_genie_06_wav_005a76e0); - break; - case 2: - // "Watch my back" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_07.wav" - DAT_SFXState::ptr)(s_genie_07_wav_005a76d0); - break; - case 3: - // "Yeeees" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_08.wav" - DAT_SFXState::ptr)(s_genie_08_wav_005a76c0); - break; - case 4: - // "On my honour" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_09.wav" - DAT_SFXState::ptr)(s_genie_09_wav_005a76b0); - break; - case 5: - // "We rule" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_10.wav" - DAT_SFXState::ptr)(s_genie_10_wav_005a76a0); - break; - case 6: - // "I pledge allegiance" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "genie_04.wav" - DAT_SFXState::ptr)(s_genie_04_wav_005a7690); - } - } - } else { - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[playerID_01] = bVar1; - MACRO_CALL_MEMBER( - OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)(7, 1); - } - } - } - if ((param_1 - 10 == DAT_00df423c::instance) && (INT_00df4244::instance == 0)) { - INT_00df4244::instance = 1; - } else { - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, - DAT_GameSynchronyState::ptr)(); - DAT_00df423c::instance = 0; - } - } - if (param_1 == 21) { - if ((DAT_00df423c::instance != 0) - && (DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance] != 0)) { - DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[( - char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[DAT_00df423c::instance]] = 0; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, - DAT_GameSynchronyState::ptr)(); - DAT_00df423c::instance = 0; - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::scheduleSFXVariation, DAT_SFXState::ptr)( - 7, 0); - } - } else if (param_1 == 100) { - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, - DAT_GameSynchronyState::ptr)(); - int cVar2 = 0; - for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray); ++i) { - if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[i]) { - cVar2 += '\x01'; - } - } - if (cVar2 != '\0') { - // "The sides are drawn" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "Genie_02.wav" - s_Genie_02_wav_005a7680); - } - } else { - if (param_1 == 101) { - memcpy(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray, - DAT_GameSynchronyState::instance.playerGroupArray2Unk, - sizeof(DAT_GameSynchronyState::instance.DAT_PlayerGroupArray)); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, - DAT_GameSynchronyState::ptr)(); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::reorderTeamsAndPositions, - DAT_GameSynchronyState::ptr)(); - } - if (param_1 == 200) { - if (DAT_00df423c::instance != 0) { - DAT_00df423c::instance = 0; - } - } else if (((param_1 == 201) || (param_1 == 202)) && DAT_00df423c::instance != 0 - && (INT_00df4244::instance != 1 || (param_1 == 201))) { - DAT_00df423c::instance = 0; - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 8f763bb448..6c723af249 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -19763,7 +19763,7 @@ SHC_3BB0A8C1_0x00464300 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00464370 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004643F0 | 49.0% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004643F0 | 0.0% | Pending SHC_3BB0A8C1_0x0046481C | 0.0% | Pending @@ -19995,7 +19995,7 @@ SHC_3BB0A8C1_0x00466E20 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00466F60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00467040 | 93.3% | register allocation in the shared tail (reset and command parameters) and in the sell branch +SHC_3BB0A8C1_0x00467040 | 0.0% | Pending SHC_3BB0A8C1_0x004672F0 | 0.0% | Pending @@ -25879,7 +25879,7 @@ SHC_3BB0A8C1_0x004AE950 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AEA10 | 0.0% | Pending -SHC_3BB0A8C1_0x004AEA50 | 71.2% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004AEA50 | 0.0% | Pending SHC_3BB0A8C1_0x004AEB20 | 0.0% | Pending From e4dd57dd763532225b03064eb5faf1cf4894a166 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 22:25:46 +0100 Subject: [PATCH 65/85] drafts: move VideoOptions_Main, SiegeAttackingForce's render and AlliesSendAndRequestGoods' handler to the ready PR MenuItemActionHandler_VideoOptions_Main (0x00493E20), MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main (0x004C0CF0) and MenuItemActionHandler_AlliesSendAndRequestGoods_Main (0x004B14C0) reach 100%, each rewritten from the listing. They go out with the ready PR built from reimpl/worker-C-ui-100, the handler together with the header commit it uses (DAT_SentOrRequestedGoodsAmount is an int). Their files leave this draft and their status lines go back to main's. Co-Authored-By: Claude Fable 5.2 --- ...Handler_AlliesSendAndRequestGoods_Main.cpp | 263 ------------------ ..._SiegeAttackingForceAndStartGoods_Main.cpp | 194 ------------- ...enuItemActionHandler_VideoOptions_Main.cpp | 186 ------------- status/addresses-SHC-3BB0A8C1.txt | 6 +- 4 files changed, 3 insertions(+), 646 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp delete mode 100644 src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp deleted file mode 100644 index e913b4a295..0000000000 --- a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemActionHandler_AlliesSendAndRequestGoods_Main.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "../AlliesSendAndRequestGoods.func.hpp" - -#include "OpenSHC/AI/AICState.func.hpp" -#include "OpenSHC/Audio/SFX/SFXState.func.hpp" -#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/UI/Actions.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/Game/Resources/ResourceType.hpp" -#include "OpenSHC/Game/Resources/ResourceTypeInt.hpp" -#include "OpenSHC/Game/Resources/ResourceTypeMin1.hpp" -#include "OpenSHC/Game/Resources/ResourceTypeMin1Int.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_00df4284.hpp" -#include "OpenSHC/Globals/DAT_AICState.hpp" -#include "OpenSHC/Globals/DAT_BuildingsState.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_RequestedGoodsByWhoArray.hpp" -#include "OpenSHC/Globals/DAT_SFXState.hpp" -#include "OpenSHC/Globals/DAT_SentOrRequestedGoodsAmount.hpp" -#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Game::Resources::ResourceType; - using OpenSHC::Game::Resources::ResourceTypeInt; - using OpenSHC::Game::Resources::ResourceTypeMin1Int; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004B14C0 - void AlliesSendAndRequestGoods::MenuItemActionHandler_AlliesSendAndRequestGoods_Main(int param_1, ...) - { - BOOLEnum BVar1; - int iVar2; - int _space; - int playerID = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; - if (param_1 == 40) { - return; - } - if (param_1 < 21) { - DAT_RequestedGoodsByWhoArray::instance[0] = param_1; - if (4 <= param_1) { - DAT_RequestedGoodsByWhoArray::instance[0] = param_1 + 1; - } - if (5 <= param_1) { - ++DAT_RequestedGoodsByWhoArray::instance[0]; - } - if (DAT_RequestedGoodsByWhoArray::instance[0] != 14) { - return; - } - DAT_RequestedGoodsByWhoArray::instance[0] = 23; - return; - } - if (param_1 == 21) { - DAT_RequestedGoodsByWhoArray::instance[0] = 14; - } - if (param_1 == 50) { - DAT_SentOrRequestedGoodsAmount::instance += 10; - } - if (param_1 == 51) { - DAT_SentOrRequestedGoodsAmount::instance += 25; - } - if (param_1 == 52) { - DAT_SentOrRequestedGoodsAmount::instance += 100; - } - if (param_1 == 53) { - DAT_SentOrRequestedGoodsAmount::instance += 5; - } - if (param_1 != 54) { - if (param_1 == 102) { - DAT_RequestedGoodsByWhoArray::instance[0] = -1; - DAT_SentOrRequestedGoodsAmount::instance = 0; - if (DAT_MenuModalComposition1::instance.activeModalDialogID - != OpenSHC::UI::Enums::MMT_ALLIES_SEND_GOODS) { - DAT_RequestedGoodsByWhoArray::instance[0] = -1; - DAT_SentOrRequestedGoodsAmount::instance = 0; - } - if (DAT_00df4284::instance == 0) { - DAT_RequestedGoodsByWhoArray::instance[0] = -1; - DAT_SentOrRequestedGoodsAmount::instance = 0; - } - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 - = DAT_GameSynchronyState::instance.currentPlayerSlotID; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 3; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); - return; - } - if (param_1 != 100) { - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); - } - if (0 <= DAT_RequestedGoodsByWhoArray::instance[0]) { - if ((int)DAT_SentOrRequestedGoodsAmount::instance <= 0) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_ALLIES_REQUEST_GOODS) { - if ((int*)(DAT_RequestedGoodsByWhoArray::instance[0] + 1) == (int*)15) { - BVar1 = MACRO_CALL_MEMBER( - OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, - DAT_AICState::ptr)(playerID, OpenSHC::Game::Resources::RT_GOLD, - (int)(DAT_SentOrRequestedGoodsAmount::instance)); - } else { - iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, - DAT_BuildingsState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID, - (OpenSHC::Game::Resources::ResourceType)(( - DAT_RequestedGoodsByWhoArray::instance[0] + 1))); - if (iVar2 == -1) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( - 3, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 6) { - // "No stockpile built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "space_warning2.wav" - DAT_SFXState::ptr)(s_space_warning2_wav_005a5950); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 5) { - // "No granary built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "space_warning1.wav" - DAT_SFXState::ptr)(s_space_warning1_wav_005a593c); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - != 7) { - DAT_MenuModalComposition1::instance.activeModalDialogID - = OpenSHC::UI::Enums::MMT_NONE; - } - // "No armory built" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning3.wav" - s_space_warning3_wav_005a5928); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - } - if (iVar2 < (int)DAT_SentOrRequestedGoodsAmount::instance) { - MACRO_CALL(OpenSHC::UI::Actions_Func::SetStorageMarketFailState)( - 4, (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0]))); - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 9) { - // "No space in the stockpile" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "space_warning5.wav" - DAT_SFXState::ptr)(s_space_warning5_wav_005a50b0); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - == 8) { - // "No space in the granary" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, - // "space_warning4.wav" - DAT_SFXState::ptr)(s_space_warning4_wav_005a5914); - } - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .storageMarketFailState - != 10) { - DAT_MenuModalComposition1::instance.activeModalDialogID - = OpenSHC::UI::Enums::MMT_NONE; - } - // "No space in the armory" - MACRO_CALL_MEMBER(OpenSHC::Audio::SFX::SFXState_Func::playWAVSFX, DAT_SFXState::ptr)( - // "space_warning6.wav" - s_space_warning6_wav_005a5900); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - return; - } - BVar1 = MACRO_CALL_MEMBER( - OpenSHC::AI::AICState_Func::isResourceLargerOrEqualThanMinimumGoodsRequiredAfterTrade, - DAT_AICState::ptr)(playerID, - (ResourceType)((int)(DAT_RequestedGoodsByWhoArray::instance[0] - + OpenSHC::Game::Resources::RT_LOGS)), - (int)(DAT_SentOrRequestedGoodsAmount::instance)); - } - if (BVar1) { - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 - = DAT_RequestedGoodsByWhoArray::instance[0]; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 - = DAT_SentOrRequestedGoodsAmount::instance; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 - = DAT_GameSynchronyState::instance.currentPlayerSlotID; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - } - MACRO_CALL_MEMBER(OpenSHC::AI::AICState_Func::playGoodsNotSentBikFromPlayer, DAT_AICState::ptr)( - playerID); - DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; - } - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_ALLIES, FALSE); - int _sendAmount = DAT_SentOrRequestedGoodsAmount::instance; - ResourceTypeMin1Int _resource - = DAT_RequestedGoodsByWhoArray::instance[0] + OpenSHC::Game::Resources::RTM_WOOD; - ResourceTypeInt _resourceType = _resource; - if (_resource == OpenSHC::Game::Resources::RTM_WHEAT) { - _resourceType = DAT_RequestedGoodsByWhoArray::instance[0]; - } - if (_resource == OpenSHC::Game::Resources::RTM_FLOUR) { - // gold - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[OpenSHC::Game::Resources::RT_GOLD] - < (int)DAT_SentOrRequestedGoodsAmount::instance) { - return; - } - } else { - _space = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::getResourceSpace, - DAT_BuildingsState::ptr)(playerID, (OpenSHC::Game::Resources::ResourceType)(_resourceType)); - if (DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .currentResources[_resourceType] - < _sendAmount) { - return; - } - if (_space < 0) { - return; - } - if (_space < _sendAmount) { - _sendAmount = _space; - } - } - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 2; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = playerID; - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = _resource; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = _sendAmount; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 - = DAT_GameSynchronyState::instance.currentPlayerSlotID; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SEND_PLAYER_TO_PLAYER_REQUEST); - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); - } - return; - } - DAT_SentOrRequestedGoodsAmount::instance += 500; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp deleted file mode 100644 index 7e93925911..0000000000 --- a/src/OpenSHC/UI/MenuItems/SiegeAttackingForceAndStartGoods/MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "../SiegeAttackingForceAndStartGoods.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/Map/MapType2.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_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" -#include "OpenSHC/Globals/PTR_ARRAY_Unknown_UnitGMHeights.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004C0CF0 - void SiegeAttackingForceAndStartGoods::MenuItemRenderFunction_SiegeAttackingForceAndStartGoods_Main( - int param_1, ...) - { - int iVar2; - uint uVar4; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (param_1 < 0) { - int iVar1 = -param_1; - int iVar3 = iVar1 - 1; - if (iVar3 < 20) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { - 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::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance.SEC_StartingResources - [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } else { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( - DAT_MapPropertiesState::instance.SEC_StartingResources - [DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3]], - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - iVar1 = DAT_MissionAestheticsDefinedData::instance.field_0x345c[iVar3] * 2 + 141; - if (iVar1 == 157) { - iVar1 = 155; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, - (int)(DAT_ButtonX::instance + 10), - (DAT_ButtonY::instance - - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance - + (GMFirstPictureIndex::instance[46] + iVar1) * 16 + 114) - / 2) - + 15); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - return; - } - if (iVar3 < 30) { - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar4 = OpenSHC::Rendering::Colors::COL_C2F0EB; - iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; - } else { - uVar4 = OpenSHC::Rendering::Colors::COL_CCFAFF; - iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, - DAT_TextManagerObject::ptr)(iVar2, (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, uVar4, 18, FALSE, 0); - iVar2 = iVar1 - 20; - if (iVar3 == 29) { - iVar2 = iVar1 - 19; - } - } else { - if (iVar3 == 30) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - // added by script: "Popularity" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - } else { - // added by script: "Popularity" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SCENARIO, 79, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 6), OpenSHC::Text::TTA_CENTER, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (iVar1 > 9 - 0x29U) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar2 = DAT_MapPropertiesState::instance.SEC_StartingResources[iVar3 + 5]; - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); - } else { - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(iVar2, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); - } - iVar2 = iVar1 - 29; - if (iVar3 == 45) { - iVar2 = 10; - } - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_ARMY_UNITS, iVar2, - (int)(DAT_ButtonX::instance), - (DAT_ButtonY::instance - - (int)*(short*)((int)PTR_ARRAY_Unknown_UnitGMHeights::instance - + (GMFirstPictureIndex::instance[174] + iVar2) * 16 + 114) - / 2) - + 15); - 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 (DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdgesAndColor, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), (ushort)(COL_BLUE::instance.shortValue), - OpenSHC::UI::Enums::RBERL_SLIGHT); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBoxWithRoundedEdges, - DAT_PencilRenderCore::ptr)(DAT_ButtonX::instance, (int)(DAT_ButtonY::instance), - (int)(DAT_ButtonW::instance + DAT_ButtonX::instance), - (int)(DAT_ButtonH::instance + DAT_ButtonY::instance), OpenSHC::UI::Enums::RBERL_SLIGHT); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - - } -} -} diff --git a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp b/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp deleted file mode 100644 index 59b49aa88e..0000000000 --- a/src/OpenSHC/UI/MenuItems/VideoOptions/MenuItemActionHandler_VideoOptions_Main.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "../VideoOptions.func.hpp" - -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" -#include "OpenSHC/UI/MenuItems/BuildingAndStatusMenu.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" -#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/ScrollSpeed.hpp" - -#include "OpenSHC/Globals/DAT_MenuModalComposition3.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_ScrollingHandler.hpp" -#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Rendering::ScreenResolutionEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x00493E20 - void VideoOptions::MenuItemActionHandler_VideoOptions_Main(int param_1, ...) - { - int dialogX; - int dialogY; - switch (param_1) { - case 11: - do { - if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - == OpenSHC::Rendering::SRE_800x600) { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - = OpenSHC::Rendering::SRE_1024x600; - } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - == OpenSHC::Rendering::SRE_1024x600) { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - = OpenSHC::Rendering::SRE_1024x768; - } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - == OpenSHC::Rendering::SRE_1280x1024) { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - = OpenSHC::Rendering::SRE_1360x768; - } else if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - == OpenSHC::Rendering::SRE_1360x768) { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - = OpenSHC::Rendering::SRE_1366x768; - } else { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - += OpenSHC::Rendering::SRE_800x600; - if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - == OpenSHC::Rendering::SRE_1360x768) { - DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - = OpenSHC::Rendering::SRE_800x600; - } - } - } while (DAT_WindowAndDirectDraw::instance.resolutionSupported_0x68 - .array[DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution] - == 0); - return; - case 12: - DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 ^= 1; - return; - case 16: - DAT_MenuTextInputState::instance.menuScrollSpeedSetting += OpenSHC::UI::SS_FAST; - if (3 <= (int)DAT_MenuTextInputState::instance.menuScrollSpeedSetting) { - DAT_MenuTextInputState::instance.menuScrollSpeedSetting = 0; - } - break; - case 17: - goto switchD_00493e37_caseD_11; - case 18: - if (DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution - != DAT_WindowAndDirectDraw::instance.currentGameResolution) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::prepareWindowAndDDraw_2Unk, - DAT_WindowAndDirectDraw::ptr)(DAT_WindowAndDirectDraw::instance.runGameAsExclusiveFullscreen, - (ScreenResolutionEnum)(( - int)(DAT_MenuTextInputState::instance.menuCurrentlySelectedResolution))); - MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewportThunk, - DAT_ViewportRenderState::ptr)(); - MACRO_CALL(OpenSHC::UI::MenuItems::BuildingAndStatusMenu_Func:: - MenuItemActionHandler_BuildingAndStatusMenu_StopBuildingOrPeasantBinkPlayback)(); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - if (DAT_MenuModalComposition3::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR) { - if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_800x600) { - dialogY = 50; - dialogX = 745; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1024x768) { - dialogY = 56; - dialogX = 969; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1024x600) { - dialogY = 56; - dialogX = 969; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1600x1200) { - LAB_00493fda: - dialogY = 56; - dialogX = 1545; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1280x1024) { - dialogY = 56; - dialogX = 1225; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1280x720) { - dialogY = 56; - dialogX = 1225; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1440x900) { - dialogY = 56; - dialogX = 1385; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1920x1080) { - dialogY = 56; - dialogX = 1865; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1920x1200) { - dialogY = 56; - dialogX = 1865; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_2560x1440) { - dialogY = 56; - dialogX = 2505; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_2560x1600) { - dialogY = 56; - dialogX = 2505; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1366x768) { - dialogY = 56; - dialogX = 1311; - } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution - == OpenSHC::Rendering::SRE_1360x768) { - dialogY = 56; - dialogX = 1305; - } else { - if (DAT_WindowAndDirectDraw::instance.currentGameResolution - != OpenSHC::Rendering::SRE_1680x1050) { - if (DAT_WindowAndDirectDraw::instance.currentGameResolution - != OpenSHC::Rendering::SRE_1600x900) - goto LAB_00493ff0; - goto LAB_00493fda; - } - dialogY = 56; - dialogX = 1625; - } - MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::setExtraActiveModalDialog, - DAT_MenuModalComposition3::ptr)( - OpenSHC::UI::Enums::MMT_TACTICAL_POWER_BAR, dialogX, dialogY); - } - } - LAB_00493ff0: - if (DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01 - != DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { - MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, - DAT_ViewportRenderState::ptr)(DAT_MenuTextInputState::instance.unknownZoomRelatedFlag01); - DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - } - if (DAT_MenuTextInputState::instance.menuCursorType != DAT_MouseState::instance.cursorType) { - DAT_MouseState::instance.cursorType = DAT_MenuTextInputState::instance.menuCursorType; - MACRO_CALL_MEMBER( - OpenSHC::Input::MouseState_Func::makeSelectedCursorTypeCurrent, DAT_MouseState::ptr)(); - } - DAT_ScrollingHandler::instance.scrollSpeedSetting_0x38 - = DAT_MenuTextInputState::instance.menuScrollSpeedSetting; - switchD_00493e37_caseD_11: - MACRO_CALL_MEMBER(OpenSHC::UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); - return; - case -20: - DAT_MenuTextInputState::instance.menuCursorType = 1; - break; - case -10: - DAT_MenuTextInputState::instance.menuCursorType = 2; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6c723af249..fda763c7b8 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23837,7 +23837,7 @@ SHC_3BB0A8C1_0x00493E16 | 0.0% | Pending SHC_3BB0A8C1_0x00493E17 | 0.0% | Pending -SHC_3BB0A8C1_0x00493E20 | 61.5% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00493E20 | 0.0% | Pending SHC_3BB0A8C1_0x0049404E | 0.0% | Pending @@ -25979,7 +25979,7 @@ SHC_3BB0A8C1_0x004B1410 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B1471 | 0.0% | Pending -SHC_3BB0A8C1_0x004B14C0 | 60.5% | compiles again, mechanical pass; structure +SHC_3BB0A8C1_0x004B14C0 | 0.0% | Pending SHC_3BB0A8C1_0x004B18D0 | 100.0% | Reimplemented @@ -33185,7 +33185,7 @@ SHC_3BB0A8C1_0x004C0CE6 | 0.0% | Pending SHC_3BB0A8C1_0x004C0CE7 | 0.0% | Pending -SHC_3BB0A8C1_0x004C0CF0 | 53.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004C0CF0 | 0.0% | Pending SHC_3BB0A8C1_0x004C1070 | 100.0% | Reimplemented From a45383fa5332c26fa892fdc6b48812a5a7b6eec0 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Tue, 17 Nov 2026 22:40:38 +0100 Subject: [PATCH 66/85] drafts: move SingleplayerMapChoice's ButtonsAndHands to the ready PR MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands (0x0042D140) reaches 100%, rewritten from the listing (04856c69d on reimpl/worker-C-ui-ready-100). It goes out with the ready PR built from that branch. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ..._SingleplayerMapChoice_ButtonsAndHands.cpp | 214 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 215 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp diff --git a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp b/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp deleted file mode 100644 index 3fdd2e5b98..0000000000 --- a/src/OpenSHC/UI/MenuItems/SinglePlayerMapChoice/MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "../SinglePlayerMapChoice.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/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_00b960dc.hpp" -#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapMissionType.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_SH1_SiegeAdvancedMode.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x0042D140 - void SinglePlayerMapChoice::MenuItemRenderFunction_SingleplayerMapChoice_ButtonsAndHands(int param_1, ...) - { - int iVar1; - int yParam; - uint uVar2; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - switch (param_1) { - case -10: - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, - DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case -11: - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, - DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case -100: - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, - DAT_PencilRenderCore::ptr)(0, (int)(DAT_ButtonBackgroundBlendStrength::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case -101: - // scroll arrows - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::renderUpDownButtonUnk, - DAT_PencilRenderCore::ptr)(1, (int)(DAT_ButtonBackgroundBlendStrength::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case 2: - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 /= 32; - break; - case 69: - if (DAT_MapMissionType::instance == 0) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (DAT_GameCore::instance.mapU4Int1_2 != 0) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - if (DAT_ButtonCurrentlyInteracting::instance) { - // Difficulty - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, (iVar1 / 32) + 32); - } else { - // Difficulty - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, (iVar1 / 32) + 32); - } - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "easy, normal, hard, very hard" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE, (iVar1 / 32) + 32); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case 74: - if (DAT_MapMissionType::instance != 2) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (DAT_GameSynchronyState::instance.currentPlayerSlotID != 2) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (DAT_GameCore::instance.mapU4Int1_2 != 0) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if ((DAT_SH1_SiegeAdvancedMode::instance != 0) && (DAT_00b960dc::instance == 0)) { - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 = (iVar1 / 32) + 32; - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; - yParam = DAT_ButtonY::instance + 7; - goto LAB_0042d4cd; - } - if (DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "Advanced" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, - (iVar1 / 32) + 32); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 += (iVar1 >> 0x1f & 0x1fU); - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; - goto LAB_0042d4c2; - case 77: - if (DAT_MapMissionType::instance != 2) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (DAT_GameSynchronyState::instance.currentPlayerSlotID == 1) { - param_1 = 78; - } - if (DAT_GameCore::instance.mapU4Int1_2 != 0) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - } - if (!DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 = (iVar1 / 32) + 32; - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; - yParam = DAT_ButtonY::instance + 7; - goto LAB_0042d4cd; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 += (iVar1 >> 0x1f & 0x1fU); - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; - LAB_0042d4c2: - yParam = DAT_ButtonY::instance + 7; - iVar1 = (iVar1 >> 5) + 32; - LAB_0042d4cd: - // "Attacking" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), yParam, OpenSHC::Text::TTA_CENTER, uVar2, - 18, FALSE, iVar1); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - return; - case 65: - iVar1 = 32; - if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected - + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset - < 0) { - iVar1 = 16; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } - iVar1 *= 32 - DAT_ButtonBackgroundBlendStrength::instance; - iVar1 = -(iVar1 / 32); - break; - default: - goto switchD_0042d163_caseD_ffffff9d; - } - DAT_ButtonUnknownZero::instance = FALSE; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)(iVar1 + 32); - switchD_0042d163_caseD_ffffff9d: - 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 fda763c7b8..a1a13f7b90 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -7481,7 +7481,7 @@ SHC_3BB0A8C1_0x0042D138 | 0.0% | Pending SHC_3BB0A8C1_0x0042D13C | 0.0% | Pending -SHC_3BB0A8C1_0x0042D140 | 46.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x0042D140 | 0.0% | Pending SHC_3BB0A8C1_0x0042D554 | 0.0% | Pending From f1f198c0e6d52731f64e415f8e19f92ccba2adc5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 11:06:29 +0100 Subject: [PATCH 67/85] reimplement: SHC_3BB0A8C1_0x00434350 90.6% block placement at the end InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection, a draft that is not at 100: it belongs in the draft PR. Rewritten from the listing on top of gynt's draft (04836feb9 at 48.55% on his fork's development; b1655ab19 at 48.6% on upstream's reimpl/UI-MenuItems; 294b0462b and 53e707235 at 64.55% and 65.07%, his fork's reimpl/UI-MenuItems; e475c55ed and b62cbe642 at 65.75% and 67.13% on his fork's reimpl/UI-MenuItems-development; 8ca78619c of 2026-10-27 on his fork's reimpl/Wilps-2026-10-18 is his newest commit on the file) and our c6a037b2b and 5fca8b920 in draft #328 (67.1%). Behaviour, where the draft differed from the original: - when the mouse is not over the map, the original ends with storeXYAndResetMouseState (a tail jump at 0x00434609). The draft went on into the click handling; - with a mapper command active and the left button down, the original ends with setupMouseTileXY (a tail jump at 0x004347E5). The draft went on into the selection code. 67.1% -> 90.6% (quick_diff 0.7911 -> 0.9780 without its own artefacts), with no goto left: - the keep and granary hint is one condition on the game mode and the menu, and the people-left hint a second if; - every arm of the hint and of the view events calls with its own constant (CheckDisplayElement... with 0, 1 or 2, RecordTutorialPlayerAction with 4, 5, 2, 3 or 17, resetupViewport with 0 or 1); the draft passed a local or a comparison, which costs the original's push / jmp pairs; - the time is stored before the two command parameters in the 1.5 second block; - the selection code is a list of early returns. Left, three places, all tried both as early returns and as one if / else with a condition chain (same result): - the return after field_0x15c = 0 (0x00434625) is the function's shared return block in the original; ours shares the one at the end, so each has the stores of the other's last block between its pops; - the original keeps the test of the else-if after the left-click branch in line (jmp over it at 0x00434697) and only its body at the end; ours moves the test out with the body. The selection code written in both arms does not merge (357 instructions); - the second selectUnitAndOpenStatusMenu result is compared with cmp eax, ebp (0x00434727), ours with test. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- ...PeasantBuildAndRightClickMenuSelection.cpp | 342 ++++++++++-------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 183 insertions(+), 161 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp index 437f7c96cf..4fb60f147b 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp @@ -20,7 +20,6 @@ #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/AlphaAndButtonSurfaceObj.hpp" #include "OpenSHC/Globals/DAT_00b960f8.hpp" @@ -42,228 +41,251 @@ namespace OpenSHC { namespace UI { namespace MenuItems { - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00434350 - void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int param_1, ...) + void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int unused, ...) { - DWORD DVar1; - int iVar2; - BOOLEnum BVar3; - dword elementState; if (DAT_GameSynchronyState::instance.syncStatus != 0) { return; } if (DAT_GameSynchronyState::instance.saveRelated != 0) { return; } + // in a multiplayer game, command 117 goes out every 1.5 seconds with a counter, until that reaches 66 if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER && DAT_00b960f8::instance != 66) { if (INT_00b960f0::instance == 0) { - DVar1 = timeGetTime(); - INT_00b960f0::instance = DVar1 + 20000; + INT_00b960f0::instance = timeGetTime() + 20000; } else { - DVar1 = timeGetTime(); - if (1500 < (int)(DVar1 - INT_00b960f0::instance)) { + DWORD const now = timeGetTime(); + if ((int)(now - INT_00b960f0::instance) > 1500) { + INT_00b960f0::instance = now; DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_00b960f8::instance; DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = DAT_GameSynchronyState::instance.currentPlayerSlotID; - INT_00b960f0::instance = DVar1; MACRO_CALL_MEMBER( OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( OpenSHC::Commands::GCT_UPDATE_LOBBY_FACE_BITMAPSPECIALTRANSMITLOGIC); - ++DAT_00b960f8::instance; + DAT_00b960f8::instance++; } } } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - LAB_004344b0: - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, - (dword)((int)(2299 < (int)DAT_UnitsState::instance.unitCount))); - } else if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - LAB_004344a8: - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) - goto LAB_004344b0; - } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) - || (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE)) { - if (DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { - iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( - DAT_GameSynchronyState::instance.currentPlayerSlotID); - if (iVar2 == 0) { - if (DAT_GameCore::instance.activeMenuTab.buildMenuTab - == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { - if (DAT_GameCore::instance.menuSwitchDelay == -1) { - iVar2 = MACRO_CALL_MEMBER( + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT + && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk + || DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) + && DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { + if (MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( + DAT_GameSynchronyState::instance.currentPlayerSlotID) + == 0) { + if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { + if (DAT_GameCore::instance.menuSwitchDelay == -1) { + if (MACRO_CALL_MEMBER( OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, - DAT_GameState::ptr)(); - if (iVar2 == 1) { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: - CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); - 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); - goto LAB_004344a8; - } - elementState = 1; - goto LAB_00434498; + DAT_GameState::ptr)() + != 1) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 1); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: + CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab + = OpenSHC::UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); } - } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab - == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) - goto LAB_00434497; + } else { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + MACRO_CALL( + OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); + } + } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab + == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + } else { DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); - } else if (DAT_GameCore::instance.activeMenuTab.tabType - == OpenSHC::UI::Enums::BASMTT_UNUSED_WITCHHOIST) { - LAB_00434497: - elementState = 2; - LAB_00434498: - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, (dword)((int)(elementState))); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; } + } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; } - goto LAB_004344a8; } + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + // a call in each arm with its own constant: the original pushes the constant inside the arm + if (DAT_UnitsState::instance.unitCount >= 2300) { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 1); + } else { + MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 0); + } + } + // the mouse's view events; each is recorded for the tutorial if (DAT_MouseState::instance.mouseBasedEvent == 1) { MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) - goto LAB_004345e4; - iVar2 = 4; - } else if (((!DAT_MouseState::instance.rightClickState) || (DAT_MouseState::instance.mouseBasedEvent == 2)) - && (DAT_ModifierKeyState::instance.ctrl == 0 || (DAT_ModifierKeyState::instance.downArrow == 0)) + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(4); + } + } else if ((!DAT_MouseState::instance.rightClickState || DAT_MouseState::instance.mouseBasedEvent == 2) + && (DAT_ModifierKeyState::instance.ctrl == 0 || DAT_ModifierKeyState::instance.downArrow == 0) && DAT_ModifierKeyState::instance.v == 0) { MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) - goto LAB_004345e4; - iVar2 = 5; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(5); + } } else if (DAT_MouseState::instance.mouseBasedEvent == 3) { MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( DAT_MouseState::instance.mapOrientationCopy3); DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) - goto LAB_004345e4; - iVar2 = 2; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(2); + } } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { DAT_MouseState::instance.field_0x198 = 2; - MACRO_CALL_MEMBER( - OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)( - (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); + // a call in each arm here too, each pushing its own argument as the original does + if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(1); + } DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) - goto LAB_004345e4; - iVar2 = 3; - } else { - if (DAT_MouseState::instance.mouseBasedEvent != 5) - goto LAB_004345e4; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(3); + } + } else if (DAT_MouseState::instance.mouseBasedEvent == 5) { DAT_MouseState::instance.field_0x19c = 2; MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CRUSADER_TUTORIAL) - goto LAB_004345e4; - iVar2 = 17; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(17); + } } - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(iVar2); - LAB_004345e4: + // the mouse is not over the map if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { - if (DAT_MouseState::instance.rightClickStart != 0) { + if (DAT_MouseState::instance.rightClickStart) { DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; DAT_GameCore::instance.field_0x15c = 0; } MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + return; } - if (DAT_MouseState::instance.rightClickStart != 0) { + if (DAT_MouseState::instance.rightClickStart) { if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_MOAT) { DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; } DAT_GameCore::instance.field_0x15c = 0; - } else { - if (DAT_MouseState::instance.rightClickStop != 0 - && DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_MOAT - && DAT_GameCore::instance.field_0x15c == 0) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + return; + } + if (DAT_MouseState::instance.rightClickStop + && DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_MOAT + && DAT_GameCore::instance.field_0x15c == 0) { + DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + } + MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); + if (!DAT_MouseState::instance.leftClickState) { + if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + <= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::processBuildingClickBonus, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID); } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); - if (!DAT_MouseState::instance.leftClickState) { - if (DAT_UnitsState::instance - .unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - <= 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::processBuildingClickBonus, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID); - } - if (!DAT_MouseState::instance.draggingStopped) { - return; - } - if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { - return; - } - } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { - if ((DAT_MouseState::instance.leftClickStart == 0) - && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile - == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { - return; - } - DAT_ViewportRenderState::instance.viewportState.previousMouseTile - = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; - MACRO_CALL_MEMBER( - OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + if (!DAT_MouseState::instance.draggingStopped) { + return; } - if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - < 1 - && DAT_UnitsState::instance.totalUnitsInSelection < 1 - && (DVar1 = timeGetTime(), - DAT_MouseState::instance.draggingStopped - && ((((DAT_MouseState::instance.selectionBoxState == 0 - && (DAT_MouseState::instance.savedSelectionBoxState == 0)) - && (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: - selectUnitAndOpenStatusMenu, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID), - !BVar3)) - && ((199 < (int)(DVar1 - DAT_ViewportRenderState::instance.viewportState.field_0x34) - || (BVar3 = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func:: - selectUnitAndOpenStatusMenu, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID), - !BVar3)))))) - && (BVar3 = MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID), - !BVar3 - && (((DAT_TileMapState::instance.LogicLayer[DAT_ViewportRenderState::instance.viewportState - .mouseAtomRefFloorTile] - & 2) - != 0 - && ((DAT_TileMapState::instance.WallOwnerLayer[DAT_ViewportRenderState::instance - .viewportState.mouseAtomRefFloorTile] - & 7) - + 1 - == DAT_GameSynchronyState::instance.currentPlayerSlotID)))) - && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] - .id - != 0) { - DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = 11; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); - DAT_BuildingsState::instance.newSelectedUnitID = 0; - DAT_BuildingsState::instance.newSelectedBuildingID - = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] - .id; + if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + return; + } + } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { + if (!DAT_MouseState::instance.leftClickStart + && DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile) { + return; + } + DAT_ViewportRenderState::instance.viewportState.previousMouseTile + = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); + return; + } + if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] + > 0) { + return; + } + if (DAT_UnitsState::instance.totalUnitsInSelection > 0) { + return; + } + // nothing selected: a click selects the unit or opens the building under the mouse, or the stockpile + // menu when the tile has the stockpile flag and belongs to the player + DWORD const clickTime = timeGetTime(); + if (!DAT_MouseState::instance.draggingStopped) { + return; + } + if (DAT_MouseState::instance.selectionBoxState != 0) { + return; + } + if (DAT_MouseState::instance.savedSelectionBoxState != 0) { + return; + } + if (MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID)) { + return; + } + if ((int)(clickTime - DAT_ViewportRenderState::instance.viewportState.field_0x34) < 200) { + if (MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID)) { + return; } } + if (MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, + AlphaAndButtonSurfaceObj::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)) { + return; + } + if ((DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 2) + == 0) { + return; + } + if ((DAT_TileMapState::instance + .WallOwnerLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] + & 7) + + 1 + != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + return; + } + if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id + == 0) { + return; + } + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = OpenSHC::UI::Enums::BASMTT_STOCKPILE; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_BuildingsState::instance.newSelectedUnitID = 0; + DAT_BuildingsState::instance.newSelectedBuildingID + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] + .id; } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a1a13f7b90..48fb9c41da 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11145,7 +11145,7 @@ SHC_3BB0A8C1_0x00434300 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00434340 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00434350 | 67.1% | compiles again, mechanical pass; structure +SHC_3BB0A8C1_0x00434350 | 90.6% | block placement at the end SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented From a8b32250fcc0e2340e89a80e9ef2dcb4971532e3 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 11:06:29 +0100 Subject: [PATCH 68/85] reimplement: SHC_3BB0A8C1_0x004D8250 95.0% block order of the last tests ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main, a draft that is not at 100: it belongs in the draft PR. Rewritten from the listing on top of gynt's draft (38ce29778 at 28.99%, his fork's development; dd1a7c48c and e63ae309a of 2026-11-02 on his fork's reimpl/UI-MenuItems-development, e63ae309a being his newest commit on the file) and our 1fa7012e8, 53bea5fdf and 07a33e2bb in draft #328 (42.4%). 42.4% -> 95.0% (quick_diff 0.5524 -> 0.9920, the same 249 instructions), with no goto and no flag local: - the two globals are set once at the top and every hidden button just returns; the draft stored them again before each return; - each text is drawn by a call in each arm of the colour test; - the mission test of button -1 is one condition ((mode != campaign || mission <= 3) && mode != economic && mode != builder): as an if / else-if it reads 0.9655, with the return jumped to where the original has it in line; - the last block is one if / else with the tests for 12 and 13 in both arms. A flag local (the decompiler's bVar1) costs a third saved register and reads 0.7480. Left, four lines: the original has the campaign arm's test for 12 just before the shared tests for 13 and jumps to those from the other arm; ours keeps the shared tests in the first arm and jumps from the campaign arm. Tried: the arms in the other order (0.9739), the builder test negated (0.9820), the shared tests once after the if / else with the render call in both places (0.9778, the compiler drops the second test for 13), a switch for 12 and 13 (0.9720). Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- ...enderFunction_ScenarioDescription_Main.cpp | 175 +++++++----------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 72 insertions(+), 105 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp index 43dc7c924c..ddea2b4e3e 100644 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp @@ -29,47 +29,32 @@ namespace UI { namespace MenuItems { // FUNCTION: STRONGHOLDCRUSADER 0x004D8250 - void ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main(int param_1, ...) + void ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main(int button, ...) { - bool bVar1; - uint uVar2; DAT_ButtonUnknownZero::instance = TRUE; DAT_StopHandlingMenuItems::instance = 0; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && param_1 != 10 && param_1 != 12 - && param_1 != 13 && param_1 != -3 && param_1 != -4 && param_1 != -1) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && button != 10 && button != 12 + && button != 13 && button != -3 && button != -4 && button != -1) { return; } - if ((INT_00ed27bc::instance == 1) && (param_1 != 12)) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + if (INT_00ed27bc::instance == 1 && button != 12) { return; } - if (param_1 == -1) { - if ((DAT_00ed2798::instance) && (DAT_00ed2798::instance != 1)) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + // -1: the difficulty and its setting, in a campaign mission after the third or an economic one + if (button == -1) { + if (DAT_00ed2798::instance != 0 && DAT_00ed2798::instance != 1) { return; } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { - if (DAT_GameCore::instance.missionNumber1to20 < 4) { - return; - } - } else if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) - && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk)) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.missionNumber1to20 <= 3) + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { return; } if (DAT_GameCore::instance.mapU4Int1) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameSuspended == 1) { @@ -78,138 +63,120 @@ namespace UI { DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + // a call for each colour: the original pushes the colour inside each arm + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); } else { - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, (int)(DAT_ButtonX::instance + 10), - (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_LEFT, uVar2, 18, FALSE); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, - (int)(DAT_ButtonW::instance - 10 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), + DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE); return; } - if (param_1 == -2) { + // -2 to -4: three text buttons + if (button == -2) { if (DAT_00ed2798::instance) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } if (INT_00ed27bc::instance) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); } else { - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); return; } - if (param_1 == -3) { + if (button == -3) { if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } if (DAT_GameCore::instance.gameSuspended != 1) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); } else { - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, - (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 8), - OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); return; } - if (param_1 == -4) { + if (button == -4) { if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; return; } - if (INT_00ed27c4::instance < 2) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + if (INT_00ed27c4::instance <= 1) { return; } DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - if (!DAT_ButtonCurrentlyInteracting::instance) { - uVar2 = OpenSHC::Rendering::Colors::COL_C2F0EB; + if (DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, + 18, FALSE); } else { - uVar2 = OpenSHC::Rendering::Colors::COL_CCFAFF; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, + DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE); } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, (int)(DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 8), OpenSHC::Text::TTA_CENTER, uVar2, 18, FALSE); return; } - if (((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1)) - && INT_00ed27bc::instance != 1) { - if (param_1 == 12) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + // the other buttons are drawn as they are, but for the ones the game mode hides. The tests for 12 and + // 13 stand in both arms: written once after them, the compiler drops a copy that the original keeps. + // In economic mode the first arm's test hides 12; the other re-tests decide nothing, but the original + // makes them + if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION + && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) + || INT_00ed27bc::instance == 1) { + if (button == 11) { return; } - LAB_004d8543: - if (param_1 == 13) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) - goto LAB_004d8563; - if (param_1 == 12) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - bVar1 = param_1 == 13; - } else { - if (param_1 == 11) { - DAT_StopHandlingMenuItems::instance = 0; - DAT_ButtonUnknownZero::instance = TRUE; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + && DAT_GameCore::instance.gameSuspended == 1) { + if (button == 12) { + return; + } + } else if (button == 13 + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + && (button == 12 || button == 13))) { return; } - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) - || (DAT_GameCore::instance.gameSuspended != 1)) - goto LAB_004d8543; - bVar1 = param_1 == 12; - } - if (bVar1) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_StopHandlingMenuItems::instance = 0; + } else if (button == 12 || button == 13 + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + && (button == 12 || button == 13))) { return; } - LAB_004d8563: DAT_ButtonUnknownZero::instance = FALSE; MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 48fb9c41da..adf8a5e833 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35925,7 +35925,7 @@ SHC_3BB0A8C1_0x004D8228 | 0.0% | Pending SHC_3BB0A8C1_0x004D822C | 0.0% | Pending -SHC_3BB0A8C1_0x004D8250 | 42.4% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004D8250 | 95.0% | block order of the last tests SHC_3BB0A8C1_0x004D839E | 0.0% | Pending From ecef1ca6397ec949d7b913c68347397f5af7e3db Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 14:30:10 +0100 Subject: [PATCH 69/85] reimplement: SHC_3BB0A8C1_0x00433370 85.2% the store at 0x0043351E reads ecx where the original reads eax Draft. MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange, rewritten from the binary with gynt's draft for the names (1831d1480 at 35.68%, 65a026cbb and d5895e2c4 at 29.41% on his fork's reimpl/UI-MenuItems; 80c151024 at 24.56% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file being 8725ec523; quick_diff 0.3923 on main). reccmp 85.2 (normalized 83.1) at this commit, on #328's a8b32250f, with the data and its own function resolver on, quick_diff 129/129 at 0.9147. The draft read the phase and the frame at the top, which moved every register (0.3923 -> 0.8992 with them read where they are used), and the frame tables' tails test the found frame first (0.9147). The phase is an int with three states, as GameCore::scribeAnimationPhase is declared on main since b734082c3. Left: the same 129 instructions and mnemonics, 478 bytes against our 479. The zero constant gets ebp where the original has ebx. At 0x0043351C both sides do `mov eax, ecx`, and at 0x0043351E the original stores eax (a3, the short form) where ours stores ecx (89 0d). That store is not a renamed register, so this is not register allocation only under #414. The extra byte lengthens the jumps that cross the store, such as the je at 0x00433378 (0x1cf against 0x1d0), and shortens the fill before the function's own switch table at 0x00433550. The zero's register is decided by the constants' uses: without the `countdown = 1` store or the monthChanged test the zero gets ebx, so the constant 1 competes for it, and sharing the three frame tables' tail through a label drops the zero register altogether. Case order, declaration order, types and dead initialisers leave it in ebp. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...nGameMenu_ProcessScribeAnimationChange.cpp | 125 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp new file mode 100644 index 0000000000..290df10c98 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp @@ -0,0 +1,125 @@ +#include "../InGameMenu.func.hpp" + +#include "OpenSHC/Game/GameMode2.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00433370 + void InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange(int button, ...) + { + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { + return; + } + int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; + int phase; + int frame; + if (DAT_GameCore::instance.taxesSettingUnk != 0) { + DWORD const now = timeGetTime(); + if ((int)(now - DAT_GameCore::instance.taxestimeUnk) < 60) { + return; + } + phase = DAT_GameCore::instance.scribeAnimationPhase; + DAT_GameCore::instance.taxestimeUnk = now; + switch (phase) { + case 2: { + int const target = (100 - DAT_GameState::instance.playerDataArray[slot].popularity / 100) / 10 + 1; + frame = DAT_GameCore::instance.scribeAnimationFrame; + if (frame > 11) { + frame = 6; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else if (frame > target) { + --frame; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else if (frame < target) { + ++frame; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else { + DAT_GameCore::instance.taxesSettingUnk = 0; + } + break; + } + case 1: + ++DAT_GameCore::instance.scribeAnimationFrame2; + frame = DAT_GameCore::instance.scribeAnimationFrame; + break; + case 0: + frame = DAT_GameCore::instance.scribeAnimationFrame; + if (frame < 6) { + ++frame; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else if (frame > 6) { + --frame; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else { + phase = 1; + DAT_GameCore::instance.scribeAnimationPhase = phase; + } + break; + default: + frame = DAT_GameCore::instance.scribeAnimationFrame; + break; + } + } else { + phase = DAT_GameCore::instance.scribeAnimationPhase; + frame = DAT_GameCore::instance.scribeAnimationFrame; + } + switch (DAT_GameCore::instance.taxesSettingUnk) { + case 0: + frame = (100 - DAT_GameState::instance.playerDataArray[slot].popularity / 100) / 10 + 1; + DAT_GameCore::instance.scribeAnimationFrame = frame; + break; + case 1: + if (phase == 1) { + int const next = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2]; + if (next != 0) { + frame = next; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else { + DAT_GameCore::instance.taxesSettingUnk = 0; + } + } + break; + case 2: + if (phase == 1) { + int const next = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2]; + if (next != 0) { + frame = next; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else { + DAT_GameCore::instance.taxesSettingUnk = 0; + } + } + break; + case 3: + if (phase == 1) { + int const next = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2]; + if (next != 0) { + frame = next; + DAT_GameCore::instance.scribeAnimationFrame = frame; + } else { + DAT_GameCore::instance.taxesSettingUnk = 0; + } + } + break; + } + if (DAT_GameCore::instance.scribeAnimationFrameCopy != frame + || DAT_GameState::instance.mapAndTime.monthChanged != 0) { + DAT_GameCore::instance.countdown = 1; + DAT_GameCore::instance.scribeAnimationFrameCopy = frame; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index adf8a5e833..5bcec4abdf 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11089,7 +11089,7 @@ SHC_3BB0A8C1_0x00433230 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00433260 | 0.0% | Pending -SHC_3BB0A8C1_0x00433370 | 0.0% | Pending +SHC_3BB0A8C1_0x00433370 | 85.2% | the store at 0x0043351E reads ecx where the original reads eax SHC_3BB0A8C1_0x00433550 | 0.0% | Pending From 106a282f28e0cbffa1ac99541c8b79dcae1a7ad4 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 20 Nov 2026 04:46:54 +0100 Subject: [PATCH 70/85] drafts: move ScenarioDescription_Main's render to the ready PR ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main (0x004D8250) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round23-100 (ff1813ba0). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...enderFunction_ScenarioDescription_Main.cpp | 187 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 188 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp b/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp deleted file mode 100644 index ddea2b4e3e..0000000000 --- a/src/OpenSHC/UI/MenuItems/ScenarioDescription/MenuItemRenderFunction_ScenarioDescription_Main.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "../ScenarioDescription.func.hpp" - -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Game/GameMode2.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_00ed2798.hpp" -#include "OpenSHC/Globals/DAT_ARRAY_00ed26d0.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_StopHandlingMenuItems.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/INT_00ed27bc.hpp" -#include "OpenSHC/Globals/INT_00ed27c4.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004D8250 - void ScenarioDescription::MenuItemRenderFunction_ScenarioDescription_Main(int button, ...) - { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_StopHandlingMenuItems::instance = 0; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk && button != 10 && button != 12 - && button != 13 && button != -3 && button != -4 && button != -1) { - return; - } - if (INT_00ed27bc::instance == 1 && button != 12) { - return; - } - // -1: the difficulty and its setting, in a campaign mission after the third or an economic one - if (button == -1) { - if (DAT_00ed2798::instance != 0 && DAT_00ed2798::instance != 1) { - return; - } - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION - || DAT_GameCore::instance.missionNumber1to20 <= 3) - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - return; - } - if (DAT_GameCore::instance.mapU4Int1) { - return; - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { - return; - } - if (DAT_GameCore::instance.gameSuspended == 1) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } - DAT_ButtonUnknownZero::instance = FALSE; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - // a call for each colour: the original pushes the colour inside each arm - if (DAT_ButtonCurrentlyInteracting::instance) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, - OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, 24, DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 8, - OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE); - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAINOPTIONS, DAT_GameState::instance.mapAndTime.difficulty + 19, - DAT_ButtonX::instance + DAT_ButtonW::instance - 10, DAT_ButtonY::instance + 8, - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_00FF00, 18, FALSE); - return; - } - // -2 to -4: three text buttons - if (button == -2) { - if (DAT_00ed2798::instance) { - return; - } - if (DAT_ARRAY_00ed26d0::instance[0].y == 0) { - return; - } - if (INT_00ed27bc::instance) { - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - 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_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, - 18, FALSE); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - } - return; - } - if (button == -3) { - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - return; - } - if (DAT_GameCore::instance.gameSuspended != 1) { - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - 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_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, - 18, FALSE); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MISSION_BUTTONS, 11, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - } - return; - } - if (button == -4) { - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { - return; - } - if (INT_00ed27c4::instance <= 1) { - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - 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_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, - 18, FALSE); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_MAPEDIT, 10, DAT_ButtonX::instance + DAT_ButtonW::instance / 2, - DAT_ButtonY::instance + 8, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, - 18, FALSE); - } - return; - } - // the other buttons are drawn as they are, but for the ones the game mode hides. The tests for 12 and - // 13 stand in both arms: written once after them, the compiler drops a copy that the original keeps. - // In economic mode the first arm's test hides 12; the other re-tests decide nothing, but the original - // makes them - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_CAMPAIGN_MISSION - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1) - || INT_00ed27bc::instance == 1) { - if (button == 11) { - return; - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk - && DAT_GameCore::instance.gameSuspended == 1) { - if (button == 12) { - return; - } - } else if (button == 13 - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 - && (button == 12 || button == 13))) { - return; - } - } else if (button == 12 || button == 13 - || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 - && (button == 12 || button == 13))) { - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 5bcec4abdf..2efdf3b7fa 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -35925,7 +35925,7 @@ SHC_3BB0A8C1_0x004D8228 | 0.0% | Pending SHC_3BB0A8C1_0x004D822C | 0.0% | Pending -SHC_3BB0A8C1_0x004D8250 | 95.0% | block order of the last tests +SHC_3BB0A8C1_0x004D8250 | 0.0% | Pending SHC_3BB0A8C1_0x004D839E | 0.0% | Pending From c5e065dac6483f685950a9906f89bec13a4d191e Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 20 Nov 2026 05:05:59 +0100 Subject: [PATCH 71/85] drafts: move PeasantBuildAndRightClickMenuSelection to the ready PR InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection (0x00434350) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round23-100 (6b3c69846). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...PeasantBuildAndRightClickMenuSelection.cpp | 293 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp deleted file mode 100644 index 4fb60f147b..0000000000 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection.cpp +++ /dev/null @@ -1,293 +0,0 @@ -#include "../InGameMenu.func.hpp" - -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Game/GameStateStructures.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Map/TileMapState.func.hpp" -#include "OpenSHC/Map/Units/UnitsState.func.hpp" -#include "OpenSHC/Rendering/ViewportRenderState.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/UI/DisplayElements.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Game/Player/Enums/BuildingEntryInfoEnum.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/MenuViewType.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_00b960f8.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_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" -#include "OpenSHC/Globals/DAT_UnitsState.hpp" -#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/INT_00b960f0.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00434350 - void InGameMenu::MenuItemActionHandler_InGameMenu_PeasantBuildAndRightClickMenuSelection(int unused, ...) - { - if (DAT_GameSynchronyState::instance.syncStatus != 0) { - return; - } - if (DAT_GameSynchronyState::instance.saveRelated != 0) { - return; - } - // in a multiplayer game, command 117 goes out every 1.5 seconds with a counter, until that reaches 66 - if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SOLITARY - && DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER - && DAT_00b960f8::instance != 66) { - if (INT_00b960f0::instance == 0) { - INT_00b960f0::instance = timeGetTime() + 20000; - } else { - DWORD const now = timeGetTime(); - if ((int)(now - INT_00b960f0::instance) > 1500) { - INT_00b960f0::instance = now; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_00b960f8::instance; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 - = DAT_GameSynchronyState::instance.currentPlayerSlotID; - MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - OpenSHC::Commands::GCT_UPDATE_LOBBY_FACE_BITMAPSPECIALTRANSMITLOGIC); - DAT_00b960f8::instance++; - } - } - } - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT - && (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk - || DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 != OpenSHC::Map::MT_SIEGE) - && DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_BUILD_MENU) { - if (MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getArmySize, DAT_UnitsState::ptr)( - DAT_GameSynchronyState::instance.currentPlayerSlotID) - == 0) { - if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_CASTLE_KEEPS) { - if (DAT_GameCore::instance.menuSwitchDelay == -1) { - if (MACRO_CALL_MEMBER( - OpenSHC::Game::GameStateStructures_Func::singlePlayerHasKeepAndGranaryCheck, - DAT_GameState::ptr)() - != 1) { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: - CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 1); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - } else { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func:: - CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.buildMenuTab - = OpenSHC::UI::Enums::BMTT_CASTLE; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILD_MENU, 0); - } - } else { - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - MACRO_CALL( - OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); - } - } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab - == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - } else { - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 0); - } - } else if (DAT_GameCore::instance.activeMenuTab.buildMenuTab == OpenSHC::UI::Enums::BMTT_UNKNOWN_49) { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO, 2); - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - } - } - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { - // a call in each arm with its own constant: the original pushes the constant inside the arm - if (DAT_UnitsState::instance.unitCount >= 2300) { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 1); - } else { - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, 0); - } - } - // the mouse's view events; each is recorded for the tutorial - if (DAT_MouseState::instance.mouseBasedEvent == 1) { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); - DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(4); - } - } else if ((!DAT_MouseState::instance.rightClickState || DAT_MouseState::instance.mouseBasedEvent == 2) - && (DAT_ModifierKeyState::instance.ctrl == 0 || DAT_ModifierKeyState::instance.downArrow == 0) - && DAT_ModifierKeyState::instance.v == 0) { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(5); - } - } else if (DAT_MouseState::instance.mouseBasedEvent == 3) { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( - DAT_MouseState::instance.mapOrientationCopy3); - DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(2); - } - } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { - DAT_MouseState::instance.field_0x198 = 2; - // a call in each arm here too, each pushing its own argument as the original does - if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { - MACRO_CALL_MEMBER( - OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(0); - } else { - MACRO_CALL_MEMBER( - OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(1); - } - DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(3); - } - } else if (DAT_MouseState::instance.mouseBasedEvent == 5) { - DAT_MouseState::instance.field_0x19c = 2; - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( - DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); - DAT_GameCore::instance.field_0x15c = 1; - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::RecordTutorialPlayerAction)(17); - } - } - // the mouse is not over the map - if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { - if (DAT_MouseState::instance.rightClickStart) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - DAT_GameCore::instance.field_0x15c = 0; - } - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); - return; - } - if (DAT_MouseState::instance.rightClickStart) { - if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_MOAT) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - } - DAT_GameCore::instance.field_0x15c = 0; - return; - } - if (DAT_MouseState::instance.rightClickStop - && DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_MOAT - && DAT_GameCore::instance.field_0x15c == 0) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; - } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); - if (!DAT_MouseState::instance.leftClickState) { - if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - <= 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::processBuildingClickBonus, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID); - } - if (!DAT_MouseState::instance.draggingStopped) { - return; - } - if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { - return; - } - } else if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_NULL) { - if (!DAT_MouseState::instance.leftClickStart - && DAT_ViewportRenderState::instance.viewportState.previousMouseTile - == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile) { - return; - } - DAT_ViewportRenderState::instance.viewportState.previousMouseTile - = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; - MACRO_CALL_MEMBER( - OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); - return; - } - if (DAT_UnitsState::instance.unitCountOfSelection[DAT_GameSynchronyState::instance.currentPlayerSlotID] - > 0) { - return; - } - if (DAT_UnitsState::instance.totalUnitsInSelection > 0) { - return; - } - // nothing selected: a click selects the unit or opens the building under the mouse, or the stockpile - // menu when the tile has the stockpile flag and belongs to the player - DWORD const clickTime = timeGetTime(); - if (!DAT_MouseState::instance.draggingStopped) { - return; - } - if (DAT_MouseState::instance.selectionBoxState != 0) { - return; - } - if (DAT_MouseState::instance.savedSelectionBoxState != 0) { - return; - } - if (MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, - AlphaAndButtonSurfaceObj::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseRayUnitID)) { - return; - } - if ((int)(clickTime - DAT_ViewportRenderState::instance.viewportState.field_0x34) < 200) { - if (MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::selectUnitAndOpenStatusMenu, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayLastUnitID)) { - return; - } - } - if (MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::openBuildingStatusMenuForBuildingID, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ViewportRenderState::instance.viewportState.mouseRayBuildingID)) { - return; - } - if ((DAT_TileMapState::instance - .LogicLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] - & 2) - == 0) { - return; - } - if ((DAT_TileMapState::instance - .WallOwnerLayer[DAT_ViewportRenderState::instance.viewportState.mouseAtomRefFloorTile] - & 7) - + 1 - != DAT_GameSynchronyState::instance.currentPlayerSlotID) { - return; - } - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] - .id - == 0) { - return; - } - DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = OpenSHC::UI::Enums::BASMTT_STOCKPILE; - MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); - DAT_BuildingsState::instance.newSelectedUnitID = 0; - DAT_BuildingsState::instance.newSelectedBuildingID - = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .buildingEntryInfos[OpenSHC::Game::Player::Enums::BEIE_STOCKPILE] - .id; - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 2efdf3b7fa..a005587880 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11145,7 +11145,7 @@ SHC_3BB0A8C1_0x00434300 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00434340 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00434350 | 90.6% | block placement at the end +SHC_3BB0A8C1_0x00434350 | 0.0% | Pending SHC_3BB0A8C1_0x004347F0 | 100.0% | Reimplemented From b730ba65bd0acc19df7fc36e1b32846946428303 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 20 Nov 2026 11:07:06 +0100 Subject: [PATCH 72/85] reimplement: SHC_3BB0A8C1_0x00433370 93.3% only the zero's register differs InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange, on top of ecef1ca63 (our rewrite from the binary with gynt's draft): the three animation cases read their table twice (if (table[i] != 0) { frame = table[i]; ... }) where they had the value in a local. The original copies the value before it stores it (mov eax, ecx at 0x0043351C, then the store of eax), which is what the compiler does for a value it has read twice and merged; with the local it stored ecx. 85.2% to 93.3% (89.3% normalized), in a narrow build on main 3458fea34; 129 instructions on both sides. Left: the zero is kept in ebp where the original has ebx (ebx is unused in ours). Initialising phase and frame, their order, truthiness tests and an int for the time do not move it. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- ...nGameMenu_ProcessScribeAnimationChange.cpp | 27 ++++++++++--------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp index 290df10c98..4219609fe6 100644 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp +++ b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp @@ -78,10 +78,11 @@ namespace UI { break; case 1: if (phase == 1) { - int const next = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2]; - if (next != 0) { - frame = next; + if (DAT_RenderingDefinedData::instance + .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2] + != 0) { + frame = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2]; DAT_GameCore::instance.scribeAnimationFrame = frame; } else { DAT_GameCore::instance.taxesSettingUnk = 0; @@ -90,10 +91,11 @@ namespace UI { break; case 2: if (phase == 1) { - int const next = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2]; - if (next != 0) { - frame = next; + if (DAT_RenderingDefinedData::instance + .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2] + != 0) { + frame = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2]; DAT_GameCore::instance.scribeAnimationFrame = frame; } else { DAT_GameCore::instance.taxesSettingUnk = 0; @@ -102,10 +104,11 @@ namespace UI { break; case 3: if (phase == 1) { - int const next = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2]; - if (next != 0) { - frame = next; + if (DAT_RenderingDefinedData::instance + .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2] + != 0) { + frame = DAT_RenderingDefinedData::instance + .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2]; DAT_GameCore::instance.scribeAnimationFrame = frame; } else { DAT_GameCore::instance.taxesSettingUnk = 0; diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index a005587880..4feeb0673f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11089,7 +11089,7 @@ SHC_3BB0A8C1_0x00433230 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00433260 | 0.0% | Pending -SHC_3BB0A8C1_0x00433370 | 85.2% | the store at 0x0043351E reads ecx where the original reads eax +SHC_3BB0A8C1_0x00433370 | 93.3% | only the zero's register differs: ebp where the original has ebx SHC_3BB0A8C1_0x00433550 | 0.0% | Pending From 8f1e257aa579d6e4d513be42fdc822f2868550f9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 20 Nov 2026 18:09:49 +0100 Subject: [PATCH 73/85] drafts: move MenuItemActionHandler_LobbyMenu_MapSelectHeader to the ready PR LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader (0x00440A50) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round27-100 (f570722e8). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...ctionHandler_LobbyMenu_MapSelectHeader.cpp | 218 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp deleted file mode 100644 index 726745dd0c..0000000000 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemActionHandler_LobbyMenu_MapSelectHeader.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include "../LobbyMenu.func.hpp" - -#include "OpenSHC/IO/ResourceManager.func.hpp" -#include "OpenSHC/OS.func.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/DAT_00b960dc.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapNameCache.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_ResourceManager.hpp" -#include "OpenSHC/Globals/INT_00b95ab8.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00440A50 - void LobbyMenu::MenuItemActionHandler_LobbyMenu_MapSelectHeader(int param_1, ...) - { - int iVar1; - int iVar2; - int iVar3; - int iVar4; - uint uVar5; - uint uVar6; - int iVar7; - int iVar8; - int iVar9; - iVar8 = param_1; - iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; - DAT_GameSynchronyState::instance.mapExistenceAckCountdown = 0; - if (param_1 < 0) { - iVar1 = -param_1; - if (param_1 == -1) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; - iVar1 = 0; - } else if (param_1 == -2) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; - iVar1 = 0; - } else if (param_1 == -3) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; - iVar1 = 2; - } else if (param_1 == -4) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; - iVar1 = 2; - } else if (4 < iVar1) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar1 - 1; - if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 4) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 11; - } - iVar1 = 1; - } - } else { - if (DAT_00b960dc::instance != 0) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { - return; - } - iVar1 = param_1; - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { - return; - } - } - // the original dispatches the sort column with a `sub eax, K; je` chain - // (0x440a9e), MSVC's sparse switch, and the arm bodies sit in the order - // 2, 1, 0 - switch (iVar1) { - case 2: - iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; - if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 3) { - do { - iVar7 = 0; - for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { - iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; - if (DAT_GameSynchronyState::instance.mapBalanceArray[iVar4] - < DAT_GameSynchronyState::instance.mapBalanceArray[DAT_MenuTextInputState::instance - .DAT_ArrayOfMapIndices[iVar3 + 1]]) { - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] - = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; - ++iVar7; - } - } - } while (iVar7 != 0); - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 4; - } else { - do { - iVar7 = 0; - for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { - iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; - if (DAT_GameSynchronyState::instance - .mapBalanceArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]] - < DAT_GameSynchronyState::instance.mapBalanceArray[iVar4]) { - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] - = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; - ++iVar7; - } - } - } while (iVar7 != 0); - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 3; - } - break; - case 1: - if ((int)DAT_GameSynchronyState::instance.lobbyMapSortOrder < 5) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; - } - param_1 = 7; - iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; - do { - iVar3 = DAT_GameSynchronyState::instance.lobbyMapSortOrder - 5; - do { - iVar9 = 0; - iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; - for (iVar4 = 0; iVar4 < iVar1; ++iVar4) { - iVar2 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4]; - uVar5 = (DAT_GameSynchronyState::instance.mapPlayerCountArray[iVar2] + iVar3) % 8; - uVar6 - = (DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance - .DAT_ArrayOfMapIndices[iVar4 + 1]] - + iVar3) - % 8; - if ((int)uVar6 < (int)uVar5) { - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4] - = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1]; - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar4 + 1] = iVar2; - ++iVar9; - } - iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; - } - iVar7 = DAT_GameSynchronyState::instance.lobbyMapSortOrder; - iVar2 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; - } while (iVar9 != 0); - --param_1; - DAT_GameSynchronyState::instance.lobbyMapSortOrder = iVar7 + 1; - if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 12) { - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 5; - } - } while ((DAT_GameSynchronyState::instance - .mapPlayerCountArray[DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[0]] - != 13 - iVar7) - && (0 < param_1)); - break; - case 0: - iVar1 = DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber - 1; - if (DAT_GameSynchronyState::instance.lobbyMapSortOrder == 1) { - do { - iVar7 = 0; - for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { - iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; - if (iVar4 < (int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]) { - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] - = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; - ++iVar7; - } - } - } while (iVar7 != 0); - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 2; - } else { - do { - iVar7 = 0; - for (iVar3 = 0; iVar3 < iVar1; ++iVar3) { - iVar4 = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3]; - if ((int)DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] < iVar4) { - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3] - = DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1]; - DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar3 + 1] = iVar4; - ++iVar7; - } - } - } while (iVar7 != 0); - DAT_GameSynchronyState::instance.lobbyMapSortOrder = 1; - } - break; - } - if (0 <= iVar8) { - INT_00b95ab8::instance = 1; - MACRO_CALL(OpenSHC::UI::MenuItems::LobbyMenu_Func::MenuItemActionHandler_LobbyMenu_MapSelectTable)( - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); - return; - } - iVar8 = 0; - if (0 < iVar2) { - while (MACRO_CALL(OpenSHC::OS_Func::__stricmp)(DAT_MapNameCache::instance, - MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, - DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[iVar8])) - != 0) { - ++iVar8; - if (iVar8 >= (int)DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber) { - return; - } - } - DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = 0; - if (iVar8 < 0) { - DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8; - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 0; - return; - } - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = iVar8; - if (7 < iVar8) { - DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = iVar8 - 7; - DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 7; - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4feeb0673f..e59d902e9a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -13661,7 +13661,7 @@ SHC_3BB0A8C1_0x004409B4 | 0.0% | Pending SHC_3BB0A8C1_0x004409C0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00440A50 | 46.3% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00440A50 | 0.0% | Pending SHC_3BB0A8C1_0x00440AE0 | 0.0% | Pending From 077d2c32a0feed7ae4400f87ac37f6533693f72f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Fri, 20 Nov 2026 21:27:34 +0100 Subject: [PATCH 74/85] reimplement: SHC_3BB0A8C1_0x004AD920 92.5% rewritten from the listing; two behaviour fixes AlliesSendAndRequestGoods::MenuItemRenderFunction_AlliesSendAndRequestGoods_Main, 53.3% to 92.5% (83.1% normalized), written from the original's listing. gynt's drafts: 3f8dd26d5 at 48.63% on his fork's reimpl/UI-MenuItems, and f45aa5070 at 51.23% ("reordered stores") on his fork's reimpl/UI-MenuItems-development, whose status line records 51.2%; the newest commit on the file, 50849804c, is on that branch too. Our draft 09e4dd8e3 (53.3%) was his code with a mechanical pass. Two behaviour fixes against the drafts (both are in his text on both branches as well): - The resource buttons are the numbers up to and including 20 (cmp esi, 0x14; jg at 0x004AD925). The drafts tested actionParam < 20, so button 20 was not drawn. - In the panel's frame a middle row draws only its two ends: for the columns between them the original goes on to the next column (cmp esi, 7; je to the loop's step at 0x004ADAF6). The drafts returned there, which ended the whole function at a middle row's second column: no further rows, no box and no text. What the match needed (quick_diff 0.6459 for the draft, 0.7371 for the plain rewrite, 0.9499 now): - X + 36, the amount and Y read into three locals in front of the amount test (0x004ADB48): 0.74 to 0.88. Read inside the arms, the compiler does not move them up. - The panel's x declared in front of its y. - The resource picture's call written in each arm of the pressed test. - The resource's index kept in the parameter: if (actionParam + 1 == 8) --actionParam; (lea ecx, [esi + 1]; cmp ecx, 8; sub esi, 1 at 0x004AD992). Left: from those three locals on, three scratch registers differ. The original has the amount in eax, Y in ecx and X + 36 in edx; ours X + 36 in eax and the amount in edx. The three text calls behind them are rotated by one: TEXT_ALLIES 14 at 0x004ADB79, TEXT_ALLIES 13 (the goods <= 0 case) at 0x004ADBA1 and TEXT_GOODS at 0x004ADC2C. The compiler's ranking gives the two coordinates a key of 64 and the amount 54, so the amount is served last; in the original it is served first. Tried without a change: the three locals in all six orders, only some of them named, the test as if / else in both directions, the amount tested in two ifs, the number call reading the globals again. Both sides have 359 instructions. Measured in a narrow build of this file as committed, alone, on main 3458fea34, data resolvers and its own resolver on. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- ...unction_AlliesSendAndRequestGoods_Main.cpp | 270 ++++++++---------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 126 insertions(+), 146 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp index 9846cf7807..c24930d3f4 100644 --- a/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp +++ b/src/OpenSHC/UI/MenuItems/AlliesSendAndRequestGoods/MenuItemRenderFunction_AlliesSendAndRequestGoods_Main.cpp @@ -10,7 +10,6 @@ #include "OpenSHC/IO/Graphics/GmID.hpp" #include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" #include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" #include "OpenSHC/Globals/DAT_ButtonH.hpp" @@ -28,191 +27,172 @@ namespace OpenSHC { namespace UI { namespace MenuItems { - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x004AD920 void AlliesSendAndRequestGoods::MenuItemRenderFunction_AlliesSendAndRequestGoods_Main(int actionParam, ...) { - int iVar1; - int iVar2; - int iVar3; - int iVar4; - eTextSections offsetIndex; - BOOLEnum keepOffsetX; - // first render resource type in condensed form - if (actionParam < 20) { - int _xOffset = 0; + // a resource's button: its picture, pressed or not, and how much of it the player has + if (actionParam <= 20) { + int xOffset = 0; if (actionParam == 6 || actionParam == 11 || actionParam == 20) { - _xOffset = 8; + xOffset = 8; } - // skip unusable resources - if (4 <= actionParam) { + // from the button's number to the resource's: two numbers are skipped, and 14 stands for 23 + if (actionParam >= 4) { ++actionParam; } - if (6 <= actionParam) { + if (actionParam >= 6) { ++actionParam; } if (actionParam == 14) { actionParam = 23; } - int _gmID = actionParam * 2 + 617; - if (DAT_ButtonCurrentlyInteracting::instance) { - _gmID = actionParam * 2 + 618; + // the call stands in each arm (one call with the picture chosen in it measures lower) + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + actionParam * 2 + 617, DAT_ButtonX::instance + xOffset, DAT_ButtonY::instance); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + actionParam * 2 + 618, DAT_ButtonX::instance + xOffset, DAT_ButtonY::instance); } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, _gmID, - DAT_ButtonX::instance + _xOffset, (int)(DAT_ButtonY::instance)); - if (actionParam == 7) { - actionParam = 6; + if (actionParam + 1 == 8) { + --actionParam; } MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[actionParam + 1], - (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 40), OpenSHC::Text::TTA_CENTER, + DAT_ButtonX::instance + 21, DAT_ButtonY::instance + 40, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); } else if (actionParam == 21) { + // the gold button if (!DAT_ButtonCurrentlyInteracting::instance) { - iVar1 = 645; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 645, DAT_ButtonX::instance, DAT_ButtonY::instance); } else { - iVar1 = 646; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 646, DAT_ButtonX::instance, DAT_ButtonY::instance); } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] .currentResources[OpenSHC::Game::Resources::RT_GOLD], - (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 20), OpenSHC::Text::TTA_CENTER, + DAT_ButtonX::instance + 21, DAT_ButtonY::instance + 20, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 0, 19, FALSE, 0); return; } - iVar1 = DAT_ButtonX::instance; - int iVar5 = DAT_ButtonY::instance; - // then draw the rest if (actionParam == 40) { - // everything below belongs to actionParam == 40 only - if (0 < (int)DAT_ButtonH::instance) { - for (int iVar2 = 0; iVar2 < (int)DAT_ButtonH::instance; iVar2 = iVar2 + 24) { - if (iVar2 == 0) { - iVar3 = 1; - } else { - if (iVar2 == DAT_ButtonH::instance - 24) { - iVar3 = 13; + // the panel: a frame of 24-pixel pieces, a dark box in it, and what is being sent or asked for + int const x = DAT_ButtonX::instance; + int const y = DAT_ButtonY::instance; + for (int row = 0; row < (int)DAT_ButtonH::instance; row += 24) { + int picture; + if (row == 0) { + picture = 1; + } else if (row == (int)DAT_ButtonH::instance - 24) { + picture = 13; + } else { + picture = 7; + } + for (int column = 0; column < 552; column += 24) { + // the left and right ends of every row, and all of the first and the last row + int piece = picture; + if (column != 0) { + if (column == 528) { + piece = picture + 2; + } else if (picture == 7) { + continue; } else { - iVar3 = 7; + piece = picture + 1; } } - iVar4 = 0; - do { - int imageID = iVar3; - if (iVar4 == 0) { - LAB_004adacf: - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, - imageID, iVar4 + iVar1, iVar2 + iVar5, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, - imageID + 3, 0); - } else { - if (iVar4 == 528) { - imageID = iVar3 + 2; - goto LAB_004adacf; - } - if (iVar3 != 7) { - imageID = iVar3 + 1; - goto LAB_004adacf; - } - return; - } - iVar4 += 24; - } while (iVar4 < 552); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, piece, + column + x, row + y, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, piece + 3, 0); } } - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( - iVar1 + 24, iVar5 + 24, iVar1 + 527, DAT_ButtonH::instance - 25 + iVar5, 20); - if (DAT_RequestedGoodsByWhoArray::instance[0] == 6) { - iVar1 = 7; - LAB_004adb48: - if (DAT_SentOrRequestedGoodsAmount::instance != 0) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( - DAT_SentOrRequestedGoodsAmount::instance, (int)(DAT_ButtonX::instance + 36), - (int)(DAT_ButtonY::instance + 36), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 17, FALSE, 0); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, - (int)(DAT_TextManagerObject::instance.currentXOffset_0x0 + 46 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 24)); - keepOffsetX = TRUE; - iVar1 = DAT_ButtonX::instance + 96; - iVar5 = DAT_RequestedGoodsByWhoArray::instance[0] + 1; - offsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; - goto LAB_004adbc8; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar1 * 2 + 618, - (int)(DAT_ButtonX::instance + 36), (int)(DAT_ButtonY::instance + 24)); - iVar1 = DAT_ButtonX::instance + 84; - iVar5 = 14; - } else { - iVar1 = DAT_RequestedGoodsByWhoArray::instance[0]; - if (0 < DAT_RequestedGoodsByWhoArray::instance[0]) - goto LAB_004adb48; - iVar1 = DAT_ButtonX::instance + 36; - iVar5 = 13; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(x + 24, y + 24, x + 527, (int)DAT_ButtonH::instance - 25 + y, 20); + int goods = DAT_RequestedGoodsByWhoArray::instance[0]; + if (goods == 6) { + goods = 7; + } else if (goods <= 0) { + 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_ALLIES, 13), + DAT_ButtonX::instance + 36, DAT_ButtonY::instance + 36, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + return; } - keepOffsetX = FALSE; - offsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; - LAB_004adbc8: - iVar2 = DAT_ButtonY::instance + 36; - iVar4 = 0; - iVar3 = 17; - // added by script: "Choose Goods" + // the three values both arms use are read first (read inside the arms, the match drops) + int const goodsX = DAT_ButtonX::instance + 36; + int const amount = DAT_SentOrRequestedGoodsAmount::instance; + int const goodsY = DAT_ButtonY::instance; + if (amount == 0) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, goods * 2 + 618, goodsX, goodsY + 24); + 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_ALLIES, 14), + DAT_ButtonX::instance + 84, DAT_ButtonY::instance + 36, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(amount, + goodsX, goodsY + 36, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 17, FALSE, + 0); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, goods * 2 + 618, + DAT_TextManagerObject::instance.currentXOffset_0x0 + 46 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 24); MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(offsetIndex, iVar5), - iVar1, iVar2, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, iVar3, keepOffsetX, - iVar4); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, DAT_RequestedGoodsByWhoArray::instance[0] + 1), + DAT_ButtonX::instance + 96, DAT_ButtonY::instance + 36, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 17, TRUE, 0); return; } - if (100 <= actionParam) { + // the amount buttons + if (actionParam >= 100) { MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); return; } - // the original ends this bound with `jl`, so 0x32 is inside it; written as - // `50 <` the `actionParam == 0x32` test below could never be true - if (50 <= actionParam) { - MACRO_CALL( - OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); - if (actionParam == 50) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(10, - (int)(DAT_ButtonX::instance + 18), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); - return; - } - if (actionParam == 51) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(25, - (int)(DAT_ButtonX::instance + 15), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); - return; - } - if (actionParam == 52) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(100, - (int)(DAT_ButtonX::instance + 12), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); - return; - } - if (actionParam == 53) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(5, - (int)(DAT_ButtonX::instance + 21), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); - return; - } - if (actionParam == 54) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(500, - (int)(DAT_ButtonX::instance + 11), (int)(DAT_ButtonY::instance + 16), OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); - return; - } + if (actionParam < 50) { + return; + } + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (actionParam == 50) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(10, + DAT_ButtonX::instance + 18, DAT_ButtonY::instance + 16, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 51) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(25, + DAT_ButtonX::instance + 15, DAT_ButtonY::instance + 16, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 52) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(100, + DAT_ButtonX::instance + 12, DAT_ButtonY::instance + 16, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 53) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(5, + DAT_ButtonX::instance + 21, DAT_ButtonY::instance + 16, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); + return; + } + if (actionParam == 54) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)(500, + DAT_ButtonX::instance + 11, DAT_ButtonY::instance + 16, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_B8EEFB, 0, 17, FALSE, 0); } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index e59d902e9a..4aa5dfc5ce 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25811,7 +25811,7 @@ SHC_3BB0A8C1_0x004AD780 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AD7C0 | 0.0% | Pending -SHC_3BB0A8C1_0x004AD920 | 53.3% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004AD920 | 92.5% | rewritten from the listing; behind the amount test three scratch registers differ (the amount in eax, Y in ecx, X + 36 in edx in the original) SHC_3BB0A8C1_0x004ADD90 | 100.0% | Reimplemented From d7cff498cbe1003833722f827caf3b459a9d73d8 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 00:54:28 +0100 Subject: [PATCH 75/85] drafts: move MenuItemRenderFunction_BuildMenu_UnitActionButtons to the ready PR BuildMenu::MenuItemRenderFunction_BuildMenu_UnitActionButtons (0x00438BE0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round29-100 (ea07ba39b). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...erFunction_BuildMenu_UnitActionButtons.cpp | 313 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 314 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp b/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp deleted file mode 100644 index 53a980eb96..0000000000 --- a/src/OpenSHC/UI/MenuItems/BuildMenu/MenuItemRenderFunction_BuildMenu_UnitActionButtons.cpp +++ /dev/null @@ -1,313 +0,0 @@ -#include "../BuildMenu.func.hpp" - -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/Map/Units/UnitsState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/MenuItems/General.func.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Map/Units/Behavior/UnitStanceEnum.hpp" -#include "OpenSHC/Map/Units/UnitType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" - -#include "OpenSHC/Globals/DAT_00ee1090.hpp" -#include "OpenSHC/Globals/DAT_00ee1094.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TribesState.hpp" -#include "OpenSHC/Globals/DAT_UnitsState.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Map::Units::UnitType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x00438BE0 - void BuildMenu::MenuItemRenderFunction_BuildMenu_UnitActionButtons(int mapperValue, ...) - { - BOOLEnum BVar1; - int iVar2; - int yPosition; - uint uVar3; - UnitType UVar4; - int xPosition; - uint color2; - int fontSize; - BVar1 = MACRO_CALL_MEMBER(OpenSHC::Map::MapPropertiesState_Func::isMapperAvailable, - DAT_MapPropertiesState::ptr)((OpenSHC::Commands::MappersEnum)mapperValue); - if (!BVar1) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - switch ((int)DAT_CurrentButtonGmDataIndex::instance) { - case 376: - // Without an engineer selected the button hides, as in the original (jne to the shared hide). - if (DAT_UnitsState::instance.hasEngineerSelected == TRUE) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - return; - } - break; - case 374: - DAT_00ee1094::instance = 291; - if ((DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) - && (!DAT_UnitsState::instance.hasEngineerSelected)) { - uVar3 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); - if (uVar3 != 0) - goto LAB_00438ec1; - iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::countSelectedCatapultsAndTrebuchets, - DAT_UnitsState::ptr)(); - if (iVar2 != 0) { - DAT_00ee1094::instance = 308; - DAT_CurrentButtonGmDataIndex::instance = 377; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - } - break; - case 218: - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT - && !DAT_UnitsState::instance.hasEngineerSelected - && (uVar3 - = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getTunnelerIDOnlyIfFirstSelected, - DAT_UnitsState::ptr)(), - uVar3 != 0)) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - break; - case 220: - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT - && (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY - || (( - DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER - || (DAT_GameState::instance.mapAndTime.skirmishNoCowThrowing == 0)))) - && !DAT_UnitsState::instance.hasEngineerSelected - && (uVar3 - = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, - DAT_UnitsState::ptr)(39, 40), - uVar3 != 0 - && (0 < DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availableCows))) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - BVar1 = FALSE; - yPosition = DAT_ButtonY::instance + 2; - xPosition = DAT_ButtonX::instance + 2; - fontSize = 19; - color2 = 0; - uVar3 = 16777215; - iVar2 - = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .availableCows; - LAB_00438e95: - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber, DAT_TextManagerObject::ptr)( - iVar2, xPosition, yPosition, uVar3, color2, fontSize, BVar1); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - break; - case 219: - DAT_00ee1090::instance = 202; - if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR - && DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_SIEGE_THAT - && !DAT_UnitsState::instance.hasEngineerSelected) { - BVar1 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::selectionContainsEngineersOnly, DAT_UnitsState::ptr)(); - if (BVar1) { - uVar3 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getSelectedEngineerCarryingResource, - DAT_UnitsState::ptr)(); - if (uVar3 != 0) { - DAT_CurrentButtonGmDataIndex::instance = 210; - DAT_00ee1090::instance = 198; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - } else { - iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsTunnelersOnly, - DAT_UnitsState::ptr)(); - if (iVar2 != 0) { - DAT_CurrentButtonGmDataIndex::instance = 218; - DAT_00ee1090::instance = 201; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - uVar3 - = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::getFirstSelectedUnitOfEitherType, - DAT_UnitsState::ptr)(39, 40); - if (uVar3 != 0) { - DAT_CurrentButtonGmDataIndex::instance = 375; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - BVar1 = FALSE; - fontSize = 19; - color2 = 0; - uVar3 = 16777215; - yPosition = DAT_ButtonY::instance + 2; - xPosition = DAT_ButtonX::instance + 2; - iVar2 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getMaxStoneAmmoInSelectedSiegeEngines, - DAT_UnitsState::ptr)(); - goto LAB_00438e95; - } - BVar1 - = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsRangedOnlyUnits, - DAT_UnitsState::ptr)(); - if (BVar1) { - DAT_CurrentButtonGmDataIndex::instance = 375; - goto LAB_00438ec1; - } - iVar2 = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::selectionContainsLaddermenOnly, - DAT_UnitsState::ptr)(); - if ((iVar2 == 0) - && (iVar2 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::selectionContainsShieldmenOnly, - DAT_UnitsState::ptr)(), - iVar2 == 0)) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - } - } - break; - case 370: - UVar4 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); - if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance - == OpenSHC::Map::Units::Behavior::USE_STAND_GROUND) { - DAT_ButtonY::instance -= 5; - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - goto LAB_00438f47; - case 371: - UVar4 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); - if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance - == OpenSHC::Map::Units::Behavior::USE_DEFENSIVE) { - --DAT_ButtonY::instance; - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - goto LAB_00438f47; - case 372: - UVar4 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); - if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_TribesState::instance.tribes[DAT_TribesState::instance.DAT_CurrentTribeID].unitStance - == OpenSHC::Map::Units::Behavior::USE_AGGRESSIVE) { - --DAT_ButtonY::instance; - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - LAB_00438f47: - DAT_ButtonCurrentlyInteracting::instance = FALSE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - case 216: - if (DAT_UnitsState::instance.hasEngineerSelected) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - UVar4 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); - if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_TribesState::instance.patrolButtonPressed) { - DAT_ButtonCurrentlyInteracting::instance = TRUE; - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - goto LAB_00438ec1; - case 211: - case 212: - case 213: - case 214: - case 215: - case 558: - if (DAT_UnitsState::instance.hasEngineerSelected != TRUE) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - uVar3 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::returnFirstSelectedEngineer, DAT_UnitsState::ptr)(); - if (uVar3 == 0) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - goto LAB_00438ec1; - default: - if (DAT_UnitsState::instance.hasEngineerSelected) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - UVar4 = MACRO_CALL_MEMBER( - OpenSHC::Map::Units::UnitsState_Func::getUnitTypeOfFirstSelectedUnit, DAT_UnitsState::ptr)(); - if (UVar4 == OpenSHC::Map::Units::UT_INVALID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - LAB_00438ec1: - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - DAT_ButtonUnknownZero::instance = TRUE; - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4aa5dfc5ce..7a6c0a801d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -12943,7 +12943,7 @@ SHC_3BB0A8C1_0x004387D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00438B60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00438BE0 | 40.9% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00438BE0 | 0.0% | Pending SHC_3BB0A8C1_0x0043907C | 0.0% | Pending From 48fac642fc39398ff8aea3f9943634a751a4f5c2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 02:52:43 +0100 Subject: [PATCH 76/85] reimplement: SHC_3BB0A8C1_0x00461570 90.2% rewritten from the listing; two behaviour fixes; two /GL lines TextEditor::MenuItemActionHandler_TextEditor_TextInputRelatedUnk, 40.9% to 90.2% (71.2% normalized), written from the original's listing. gynt's drafts: a3e51bfbe at 39.44% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems, whose status line records 39.4%, and ccd2b04e3 at 40.92% ("comparison operand order") on his fork's reimpl/UI-MenuItems-development, whose status line records 40.9%; the newest commit on the file there is dd1a7c48c. Our draft (61df88505, then 084c46912) was his code with a mechanical pass. The function handles one key of the help window's text. With the alternate tab off it only scrolls the text (keys 244 to 251, through the jump table at 0x00461984). Otherwise it edits the custom text (keys 240 to 249, jump table at 0x004619A4): a typed character is inserted, 240 and 241 insert a tab or a new paragraph token outside custom text mode, 242 / 243 move the cursor, 244 / 245 change the line, 246 / 247 go to the start or the end, 248 / 249 remove what stands in front of or at the cursor. Two behaviour fixes. Keys 248 and 249 move the rest of the text down in a loop, and the original runs that loop when index < length + advance (cmp ecx, edx; jge at 0x0046189E, and cmp ecx, edi; jge at 0x0046190D). The draft ran it when length > index + advance, taken over from ccd2b04e3; gynt's reimpl/UI-MenuItems has the original's test. With the draft's test a removal at the text's end did not copy the terminator down. It needs /GL. Behind three calls of helpToken_getHelpTokenAdvanceLength (0x0045F080) the original still has the cursor in edx (0x004617CE, 0x00461815, 0x00461894), so the caller must see that the callee leaves edx alone. This commit adds this file and helpToken.cpp to cmake/compiler-flags-gl.txt. With the two lines: 90.2%; without them: 69.0% (62.4% normalized). helpToken.cpp's two functions (0x0045F080, 0x0045F0D0) read 100.0% with the lines. What the match needed: - First half: 244, 247 and 250 assign one offset variable and leave by break to one store behind the switch; 245, 246 and 251 store themselves. With 244 and 250 storing themselves the shared zero block sits behind 244 instead of 250 (85.0%); with 245 and 251 breaking too 72.9%; with 246 breaking 64.3%. 247 reads the same either way and breaks. The first half matches completely. - Second half: the cursor index is read from the state each time in 242, 243, 248 and 249. In a local: 76.8%. - The insert is one block, entered from 240 and 241 by goto, because the original has one copy of it with the character in a register (mov esi, 9 at 0x00461728, mov esi, 6 at 0x0046173B, both jumping to 0x004616F7). Behind a flag: 75.5%. Written out three times the compiler pushes the constants and nothing merges: 67.7%. - The length test is one || test whose body is the insert block. Left, with 285 instructions on both sides (up to the last ret, alignment fill included): the character sits in edx in ours and in esi in the original, so the inlined wcslen's temporary (0x004616D6), the shift loop's temporary and one pair of loads use other registers; and the insert's entry test (0x004616F7) stands where the typed-character path falls into it in the original, behind 241 in ours. Tried for both without gain: the insert behind a flag (the entry test lands right, the loop goes behind the switch), the label in four places, for / do-while / while, the text pointer in a local (the character gets esi, the pointer takes edx), an unsigned character, the length test nested or with locals, locals for the pending token, the converted character and the loop's moved character, the pending step as an inline helper. A lead for the register: with one more call on the typed-character path that the compiler cannot see into, the character goes to esi and every register behind it is the original's, but the text pointer's early load (0x00461699) is lost. So in the original something on that path costs edx without touching memory; the call of helpToken_getHelpTokenAdvanceLength there does neither in ours. Measured in a narrow build of this file as committed and helpToken.cpp, on main 3458fea34, struct resolvers and the three functions' resolvers on, both files in the /GL list. No all-on build was run with the two new /GL lines. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- cmake/compiler-flags-gl.txt | 2 + ...Handler_TextEditor_TextInputRelatedUnk.cpp | 303 +++++++++--------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 3 files changed, 155 insertions(+), 152 deletions(-) diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 226cdc7ca6..253eb25c42 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -136,3 +136,5 @@ src/OpenSHC/Map/Units/UpdateMiner.cpp src/OpenSHC/Map/Units/UpdateQuarryMason.cpp src/OpenSHC/Map/Units/UpdateDrunkard.cpp src/OpenSHC/Map/Units/UpdateInnkeeper.cpp +src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp +src/OpenSHC/Text/TextEditorState/helpToken.cpp diff --git a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp index 69e087597b..87874453f3 100644 --- a/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp +++ b/src/OpenSHC/UI/MenuItems/TextEditor/MenuItemActionHandler_TextEditor_TextInputRelatedUnk.cpp @@ -18,160 +18,164 @@ namespace UI { // FUNCTION: STRONGHOLDCRUSADER 0x00461570 void TextEditor::MenuItemActionHandler_TextEditor_TextInputRelatedUnk() { - WCHAR WVar1; - uint uVar2; - int iVar3; - WCHAR* pWVar4; - int iVar5; - int iVar6; - WCHAR* pWVar7; - if (DAT_TextEditorState::instance.useAlternateHelpTab == 0) { - uVar2 = MACRO_CALL_MEMBER( + if (!DAT_TextEditorState::instance.useAlternateHelpTab) { + // the help text is only scrolled: by a line (244, 245), a page (250, 251) or to an end (246, 247) + int const key = MACRO_CALL_MEMBER( OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); - if ((int)uVar2 < 240) { + if (key < 240) { return; } - switch (uVar2) { + // 244, 247, 250 break to one store behind the switch; the rest store themselves (else the match drops) + int offset; + switch (key) { case 245: - iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex - - DAT_TextEditorState::instance.dialogContentHeight; - iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; - if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - 18) { - iVar3 += 18; - if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { - iVar3 = (iVar5 <= 0) - 1 & iVar5; + offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset < max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + - 18) { + offset += 18; + if (offset > max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0)) { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); } } else { - iVar3 = (iVar5 <= 0) - 1 & iVar5; + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); } - DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; return; case 244: - iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; - if (18 <= iVar3) { - DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - 18; - return; + offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset >= 18) { + offset -= 18; + } else { + offset = 0; } - DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; - return; + break; case 246: DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; return; case 247: - iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex - - DAT_TextEditorState::instance.dialogContentHeight; - DAT_TextEditorState::instance.helpContentScrollOffsetY = (iVar5 <= 0) - 1 & iVar5; - return; + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); + break; case 251: - iVar5 = DAT_TextEditorState::instance.topVisibleLineIndex - - DAT_TextEditorState::instance.dialogContentHeight; - iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; - if (iVar3 < ((iVar5 <= 0) - 1 & iVar5) - DAT_TextEditorState::instance.dialogContentHeight) { - iVar3 += DAT_TextEditorState::instance.dialogContentHeight; - if (((iVar5 <= 0) - 1 & iVar5) < iVar3) { - iVar3 = (iVar5 <= 0) - 1 & iVar5; + offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset < max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0) + - DAT_TextEditorState::instance.dialogContentHeight) { + offset += DAT_TextEditorState::instance.dialogContentHeight; + if (offset > max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0)) { + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); } } else { - iVar3 = (iVar5 <= 0) - 1 & iVar5; + offset = max(DAT_TextEditorState::instance.topVisibleLineIndex + - DAT_TextEditorState::instance.dialogContentHeight, + 0); } - DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3; + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; return; case 250: - iVar3 = DAT_TextEditorState::instance.helpContentScrollOffsetY; - iVar6 = DAT_TextEditorState::instance.dialogContentHeight; - if (iVar3 >= iVar6) { - DAT_TextEditorState::instance.helpContentScrollOffsetY = iVar3 - iVar6; - return; + offset = DAT_TextEditorState::instance.helpContentScrollOffsetY; + if (offset >= DAT_TextEditorState::instance.dialogContentHeight) { + offset -= DAT_TextEditorState::instance.dialogContentHeight; + } else { + offset = 0; } - DAT_TextEditorState::instance.helpContentScrollOffsetY = 0; - return; + break; default: return; } + DAT_TextEditorState::instance.helpContentScrollOffsetY = offset; + return; } - uVar2 = MACRO_CALL_MEMBER( + int character = MACRO_CALL_MEMBER( OpenSHC::Text::UserTextHandler_Func::dequeueInputBufferChar, DAT_UserTextHandlerState::ptr)(); - iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; - pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - if (uVar2 != -1) { - if ((int)uVar2 < 240) { + if (character != -1) { + if (character < 240) { + // a typed character: a pending token is stepped over first if (DAT_TextEditorState::instance.pendingTokenTypeToSkip != OpenSHC::Text::Enums::HTT_NONE) { - iVar3 = MACRO_CALL_MEMBER( + DAT_TextEditorState::instance.activeHelpHotspotIndex += MACRO_CALL_MEMBER( OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, DAT_TextEditorState::ptr)( - (OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); - DAT_TextEditorState::instance.activeHelpHotspotIndex += iVar3; - DAT_TextEditorState::instance.pendingTokenTypeToSkip = (OpenSHC::Text::Enums::HTT_NONE); - } - if ((DAT_TextEditorState::instance.isCustomTextMode != 0) - && (-1 < DAT_TextEditorState::instance.customTextMaxLength)) { - pWVar4 = pWVar7; - do { - WVar1 = *pWVar4; - ++pWVar4; - } while (WVar1 != L'\0'); - if (DAT_TextEditorState::instance.customTextMaxLength <= (int)pWVar4 - (int)(pWVar7 + 1) >> 1) - goto switchD_00461715_caseD_a; + (HelpTextToken)DAT_TextEditorState::instance.pendingTokenTypeToSkip); + DAT_TextEditorState::instance.pendingTokenTypeToSkip = OpenSHC::Text::Enums::HTT_NONE; } - LAB_004616f7: - iVar3 = DAT_TextEditorState::instance.customHelpTextLength; - if (DAT_TextEditorState::instance.activeHelpHotspotIndex - <= DAT_TextEditorState::instance.customHelpTextLength) { - do { - pWVar7[iVar3 + 1] = pWVar7[iVar3]; - --iVar3; - pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - } while (iVar3 >= DAT_TextEditorState::instance.activeHelpHotspotIndex); + if (!DAT_TextEditorState::instance.isCustomTextMode + || DAT_TextEditorState::instance.customTextMaxLength < 0 + || (int)wcslen(DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory) + < DAT_TextEditorState::instance.customTextMaxLength) { + insert: + for (int i = DAT_TextEditorState::instance.customHelpTextLength; + i >= DAT_TextEditorState::instance.activeHelpHotspotIndex; --i) { + DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i + 1] + = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i]; + } + DAT_TextEditorState::instance + .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] + = MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::singleMultiByteToWideChar, + DAT_WideCharMultiByteState::ptr)((char)character); + ++DAT_TextEditorState::instance.customHelpTextLength; + ++DAT_TextEditorState::instance.activeHelpHotspotIndex; } - WVar1 = MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::singleMultiByteToWideChar, - DAT_WideCharMultiByteState::ptr)((char)uVar2); - // put character in memory - DAT_TextEditorState::instance - .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] = WVar1; - ++DAT_TextEditorState::instance.customHelpTextLength; - ++DAT_TextEditorState::instance.activeHelpHotspotIndex; } else { - switch (uVar2) { + switch (character) { case 240: - if (DAT_TextEditorState::instance.isCustomTextMode == 0) { - uVar2 = 9; - goto LAB_004616f7; + if (!DAT_TextEditorState::instance.isCustomTextMode) { + character = OpenSHC::Text::Enums::HTT_TAB; + // to the one insert block: behind a flag the match is lower + goto insert; } break; case 241: - if (DAT_TextEditorState::instance.isCustomTextMode == 0) { - uVar2 = 6; - goto LAB_004616f7; + if (!DAT_TextEditorState::instance.isCustomTextMode) { + character = OpenSHC::Text::Enums::HTT_NEWPARAGRAPH; + // as in 240 + goto insert; } break; - case 242: - iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; - if (iVar3 <= 0) - break; - iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3 - 1]; - if (32 <= iVar6) { - DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - 1; - break; + case 242: { + // left; the cursor is re-read from the state, as in 243, 248, 249 (a local loses the match) + if (DAT_TextEditorState::instance.activeHelpHotspotIndex > 0) { + int const token = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex - 1]; + if (token >= 32) { + --DAT_TextEditorState::instance.activeHelpHotspotIndex; + } else { + DAT_TextEditorState::instance.activeHelpHotspotIndex -= MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((HelpTextToken)token); + } } - iVar5 = MACRO_CALL_MEMBER( - OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, - DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); - DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 - iVar5; break; - case 243: - iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; - if (iVar3 >= DAT_TextEditorState::instance.customHelpTextLength) - break; - iVar6 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3]; - if (32 <= iVar6) { - DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + 1; - break; + } + case 243: { + // right + if (DAT_TextEditorState::instance.activeHelpHotspotIndex + < DAT_TextEditorState::instance.customHelpTextLength) { + int const token = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex]; + if (token >= 32) { + ++DAT_TextEditorState::instance.activeHelpHotspotIndex; + } else { + DAT_TextEditorState::instance.activeHelpHotspotIndex += MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)((HelpTextToken)token); + } } - iVar5 = MACRO_CALL_MEMBER( - OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, - DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); - DAT_TextEditorState::instance.activeHelpHotspotIndex = iVar3 + iVar5; break; + } case 244: DAT_TextEditorState::instance.field_0x2396c = -1; MACRO_CALL_MEMBER( @@ -189,61 +193,58 @@ namespace UI { DAT_TextEditorState::instance.activeHelpHotspotIndex = DAT_TextEditorState::instance.customHelpTextLength; break; - case 248: - iVar3 = DAT_TextEditorState::instance.activeHelpHotspotIndex; - if (iVar3 <= 0) - break; - pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - iVar6 = pWVar7[iVar3 - 1]; - iVar5 = MACRO_CALL_MEMBER( - OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, - DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)iVar6); - if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { - iVar6 = (iVar3 - iVar5) * 2; - do { - // delete character in memory - *(WCHAR*)(iVar6 + (int)pWVar7) = pWVar7[iVar3]; - pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - if (pWVar7[iVar3] == L'\0') + case 248: { + // removes what stands in front of the cursor: the rest moves down, the terminator included + if (DAT_TextEditorState::instance.activeHelpHotspotIndex > 0) { + int const advance = MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, + DAT_TextEditorState::ptr)( + (HelpTextToken)DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory + [DAT_TextEditorState::instance.activeHelpHotspotIndex - 1]); + for (int i = DAT_TextEditorState::instance.activeHelpHotspotIndex; + i < DAT_TextEditorState::instance.customHelpTextLength + advance; ++i) { + DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i - advance] + = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i]; + if (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i] == L'\0') { break; - ++iVar3; - iVar6 += 2; - } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + } + } + DAT_TextEditorState::instance.customHelpTextLength -= advance; + DAT_TextEditorState::instance.activeHelpHotspotIndex -= advance; } - DAT_TextEditorState::instance.customHelpTextLength -= iVar5; - DAT_TextEditorState::instance.activeHelpHotspotIndex -= iVar5; break; - case 249: - iVar5 = MACRO_CALL_MEMBER( + } + case 249: { + // removes what stands at the cursor + int const advance = MACRO_CALL_MEMBER( OpenSHC::Text::TextEditorState_Func::helpToken_getHelpTokenAdvanceLength, - DAT_TextEditorState::ptr)((OpenSHC::Text::Enums::HelpTextToken)DAT_TextEditorState::instance + DAT_TextEditorState::ptr)((HelpTextToken)DAT_TextEditorState::instance .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance .activeHelpHotspotIndex]); - if (iVar3 < DAT_TextEditorState::instance.customHelpTextLength) { - if (DAT_TextEditorState::instance.customHelpTextLength > iVar3 + iVar5) { - iVar6 = (iVar3 + iVar5) * 2; - do { - pWVar7[iVar3] = *(WCHAR*)(iVar6 + (int)pWVar7); - if (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[iVar3] == L'\0') - break; - ++iVar3; - iVar6 += 2; - pWVar7 = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory; - } while (iVar3 < DAT_TextEditorState::instance.customHelpTextLength + iVar5); + if (DAT_TextEditorState::instance.activeHelpHotspotIndex + < DAT_TextEditorState::instance.customHelpTextLength) { + for (int i = DAT_TextEditorState::instance.activeHelpHotspotIndex; + i < DAT_TextEditorState::instance.customHelpTextLength + advance; ++i) { + DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i] + = DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i + advance]; + if (DAT_TextEditorState::instance.DAT_PointerToTemporaryTextMemory[i] == L'\0') { + break; + } } - DAT_TextEditorState::instance.customHelpTextLength -= iVar5; + DAT_TextEditorState::instance.customHelpTextLength -= advance; } + break; + } } } - switchD_00461715_caseD_a: MACRO_CALL_MEMBER( OpenSHC::Text::TextEditorState_Func::initializeAndLayoutHelpText, DAT_TextEditorState::ptr)(); } - if ((ushort)DAT_TextEditorState::instance + if (DAT_TextEditorState::instance .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex] < 32) { DAT_TextEditorState::instance.field_0x23970 - = (uint)(ushort)DAT_TextEditorState::instance + = DAT_TextEditorState::instance .DAT_PointerToTemporaryTextMemory[DAT_TextEditorState::instance.activeHelpHotspotIndex]; return; } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 7a6c0a801d..63efc029c9 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -18835,7 +18835,7 @@ SHC_3BB0A8C1_0x00461520 | 0.0% | Pending SHC_3BB0A8C1_0x00461550 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00461570 | 40.9% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00461570 | 90.2% | rewritten from the listing, needs its two /GL lines; left: the character's register (esi in the original) and the place of the insert's entry test SHC_3BB0A8C1_0x00461750 | 0.0% | Pending From 1319211ea1cc201d04cc8935b7ef71929b5e14e6 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 02:52:57 +0100 Subject: [PATCH 77/85] drafts: move MenuItemActionHandler_MapEditorProperties_MainButtons to the ready PR MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons (0x00443070) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round31-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...andler_MapEditorProperties_MainButtons.cpp | 380 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 381 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp deleted file mode 100644 index b1e7e60586..0000000000 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp +++ /dev/null @@ -1,380 +0,0 @@ -#include "../MapEditorProperties.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/Units/TroopValueState.func.hpp" -#include "OpenSHC/Map/Units/UnitsState.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" -#include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/IO/FileResourceType.hpp" -#include "OpenSHC/Map/MapType2.hpp" -#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/UI/Enums/MenuViewType.hpp" -#include "OpenSHC/string-literals.hpp" - -#include "OpenSHC/Globals/DAT_00b960f4.hpp" -#include "OpenSHC/Globals/DAT_AICState.hpp" -#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapDefinedData.hpp" -#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MenuTextInputState.hpp" -#include "OpenSHC/Globals/DAT_PathFindingState.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/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/FilePackagerObj.hpp" -#include "OpenSHC/Globals/INT_00b95b74.hpp" -#include "OpenSHC/Globals/INT_00b95f68.hpp" -#include "OpenSHC/Globals/INT_00b960e4.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00443070 - void MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons(int param_1, ...) - { - byte(*pabVar1)[10]; - byte* pbVar2; - char cVar3; - char cVar4; - char cVar5; - int iVar6; - int* piVar7; - int* piVar8; - if ((DAT_MenuTextInputState::instance.currentModalDialog == UI::Enums::MMT_NO_MENU) - && (DAT_MenuModalComposition1::instance.activeModalDialogID == UI::Enums::MMT_NONE)) { - DAT_TileMapState::instance.unitPlacementCount = 1; - switch (param_1) { - case 2: - DAT_MenuTextInputState::instance.field_0x9c = 1; - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_LOAD_MAP); - return; - case 3: - if ((!DAT_GameCore::instance.U2_mapType_singleOrMulti) - || (DAT_GameCore::instance.mapLoadedForEditor)) { - MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::determineScenarioMissionTypeAndResetEvents, - DAT_MapPropertiesState::ptr)(); - DAT_MenuTextInputState::instance.field_0x9c = 1; - DAT_MenuTextInputState::instance.field_0xa4 = 0; - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, - DAT_MenuTextInputState::ptr)(OpenSHC::UI::Enums::MMT_SAVE_MAP); - INT_00b960e4::instance = 1; - return; - } - break; - case 4: - INT_00b960e4::instance = 0; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_NEW_MAP_MAPTYPE, 0); - return; - case 5: - if (INT_00b95f68::instance) { - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 43; - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(UI::Enums::MMT_QUIT_DIALOG); - return; - } - DAT_GameCore::instance.isTimeHalted2 = 0; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_CUSTOM_SCENARIOS, 0); - return; - case 6: - if (DAT_GameCore::instance.mapLoadedForEditor) { - INT_00b95f68::instance = 1; - DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; - DAT_GameCore::instance.gameMode_2 = Game::GM_EDITOR; - DAT_GameCore::instance.missionNumber1to20 = 27; - MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); - for (int i = 0; i < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); ++i) { - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[i] = -1; - } - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1; - if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType == 237) { - if (DAT_GameCore::instance.U2_mapType_singleOrMulti < 1) - goto LAB_00443214; - DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 239; - } else if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType != 239) - goto LAB_00443214; - if (!DAT_GameCore::instance.U2_mapType_singleOrMulti) { - DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.tabType = 237; - } - LAB_00443214: - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_MAP_EDITOR_LANDSCAPING, 0); - return; - } - break; - case 9: - MACRO_CALL(UI::MenuItems::MapEditorProperties_Func:: - MenuItemActionHandler_MapEditorProperties_MapDescriptionBox)(); - return; - case 25: - if ((DAT_GameCore::instance.U2_mapType_singleOrMulti != 1) - && (DAT_GameCore::instance.mapLoadedForEditor)) { - INT_00b95f68::instance = 1; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_EDIT_SCENARIO, 0); - return; - } - break; - case 31: - if (DAT_GameCore::instance.mapLoadedForEditor) { - DAT_GameCore::instance.missionNumber1to20 = 27; - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); - MACRO_CALL_MEMBER( - UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); - MACRO_CALL_MEMBER( - UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); - MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( - IO::FRT_MAPS, STR_AutoBackupMap); - FilePackagerObj::instance.loadAndSaveBarFunc - = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); - MACRO_CALL_MEMBER(IO::FilePackager_Func::writeMapOrSaveFile, FilePackagerObj::ptr)( - DAT_MapDefinedData::instance.MapSectionAddressArray); - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_SIEGE) { - DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[1] = 1; - DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[2] = 2; - } - DAT_MenuTextInputState::instance.DAT_SomeTextArrayIndex = 9; - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - DAT_GameSynchronyState::instance.currentPlayerSlotID = 1; - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[1] = 1; - DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; - DAT_GameCore::instance.gameMode_2 = Game::GM_BUILDERUnk; - DAT_GameCore::instance.field_0x6c = 1; - DAT_GameState::instance.mapAndTime.difficulty = 1; - DAT_GameCore::instance.section1095 = 0; - MACRO_CALL_MEMBER( - Map::Units::TroopValueState_Func::clearAttackInfo, DAT_TroopValueState::ptr)(); - MACRO_CALL_MEMBER(AI::AICState_Func::recomputeAIZonerLayer, DAT_AICState::ptr)(); - ++DAT_TroopValueState::instance.attackInfo.inv_count; - if (49 < DAT_TroopValueState::instance.attackInfo.inv_count) { - DAT_TroopValueState::instance.attackInfo.inv_count = 1; - } - MACRO_CALL_MEMBER(Map::Units::TroopValueState_Func::initializeAttackWaveSlot, - DAT_TroopValueState::ptr)(DAT_TroopValueState::instance.attackInfo.inv_count, 1); - cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[0]; - DAT_TroopValueState::instance.attackInfo - .attackWavePlayerIDArray[DAT_TroopValueState::instance.attackInfo.inv_count] = 2; - cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[1]; - pabVar1 = DAT_TroopValueState::instance.attackInfo.someSinglePlayerScore - + DAT_TroopValueState::instance.attackInfo.inv_count; - (*pabVar1)[0] = (*pabVar1)[0] + cVar3; - cVar5 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[3]; - pbVar2 = DAT_TroopValueState::instance.attackInfo - .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] - + 1; - *pbVar2 += cVar4; - cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[2]; - pbVar2 = DAT_TroopValueState::instance.attackInfo - .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] - + 2; - *pbVar2 += cVar5; - cVar4 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[4]; - pbVar2 = DAT_TroopValueState::instance.attackInfo - .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] - + 3; - *pbVar2 += cVar3; - cVar3 = (char)DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[5]; - pbVar2 = DAT_TroopValueState::instance.attackInfo - .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] - + 4; - *pbVar2 += cVar4; - pbVar2 = DAT_TroopValueState::instance.attackInfo - .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count] - + 8; - *pbVar2 += cVar3; - DAT_GameState::instance.mapAndTime.siegeInformation.archers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[0]; - piVar7 = DAT_MapPropertiesState::instance.SEC_StartingResources; - piVar8 = DAT_GameState::instance.mapAndTime.startGoods; - for (iVar6 = 25; iVar6 != 0; --iVar6) { - *piVar8 = *piVar7; - ++piVar7; - ++piVar8; - } - DAT_GameState::instance.mapAndTime.startGoods[7] - = DAT_GameState::instance.mapAndTime.startGoods[8]; - DAT_GameState::instance.mapAndTime.siegeInformation.pikemen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[3]; - DAT_GameState::instance.mapAndTime.siegeInformation.spearmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[2]; - DAT_GameState::instance.mapAndTime.siegeInformation.crossbowmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[1]; - DAT_GameState::instance.mapAndTime.siegeInformation.knights - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[6]; - DAT_GameState::instance.mapAndTime.siegeInformation.swordsmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[5]; - DAT_GameState::instance.mapAndTime.siegeInformation.macemen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[4]; - DAT_GameState::instance.mapAndTime.siegeInformation.monks - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[9]; - DAT_GameState::instance.mapAndTime.siegeInformation.engineers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[8]; - DAT_GameState::instance.mapAndTime.siegeInformation.laddermen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[7]; - DAT_GameState::instance.mapAndTime.siegeInformation.slingers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[12]; - DAT_GameState::instance.mapAndTime.siegeInformation.slaves - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[11]; - DAT_GameState::instance.mapAndTime.siegeInformation.arabianArchers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[10]; - DAT_GameState::instance.mapAndTime.siegeInformation.arabianSwordsmen - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[15]; - DAT_GameState::instance.mapAndTime.siegeInformation.horseArchers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[14]; - DAT_GameState::instance.mapAndTime.siegeInformation.assassins - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[13]; - DAT_GameState::instance.mapAndTime.siegeInformation.field_0x48 - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[18]; - DAT_GameState::instance.mapAndTime.siegeInformation.fireBallistas - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[17]; - DAT_GameState::instance.mapAndTime.siegeInformation.fireThrowers - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[16]; - DAT_GameState::instance.mapAndTime.startGoods[8] = 0; - DAT_GameState::instance.mapAndTime.siegeInformation.field_0x4c - = DAT_MapPropertiesState::instance.SEC_SiegeInformation[19]; - DAT_GameState::instance.mapAndTime.startingPopularity - = DAT_MapPropertiesState::instance.SEC_StartingPopularity * 10; - MACRO_CALL_MEMBER(Game::GameStateStructures_Func::setMonthAndYear, DAT_GameState::ptr)( - DAT_MapPropertiesState::instance.SEC_StartingMonth, - DAT_MapPropertiesState::instance.SEC_StartingYear); - MACRO_CALL_MEMBER( - Game::GameStateStructures_Func::clearEnemyRelatedStructures, DAT_GameState::ptr)(); - DAT_GameState::instance.mapAndTime.mercRecruitable[3] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[3]; - DAT_GameCore::instance.xbowProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_XbowProducible_save; - DAT_GameCore::instance.bowProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_BowProducible_save; - DAT_GameCore::instance.pikeProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_PikeProducible_save; - DAT_GameState::instance.mapAndTime.mercRecruitable[2] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[2]; - DAT_GameState::instance.mapAndTime.euroRecruitable[4] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.macemen; - DAT_GameState::instance.mapAndTime.mercRecruitable[4] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[4]; - DAT_GameState::instance.mapAndTime.euroRecruitable[5] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.swordsmen; - DAT_GameCore::instance.spearProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_SpearProducible_save; - DAT_GameState::instance.mapAndTime.mercRecruitable[5] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[5]; - DAT_GameState::instance.mapAndTime.mercRecruitable[0] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[0]; - DAT_GameState::instance.mapAndTime.euroRecruitable[6] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.knights; - DAT_GameCore::instance.swordProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_SwordProducible_save; - DAT_GameCore::instance.maceProducible_logic - = (int)DAT_MapPropertiesState::instance.SEC_MaceProducible_save; - DAT_GameState::instance.mapAndTime.mercRecruitable[1] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[1]; - DAT_GameState::instance.mapAndTime.mercRecruitable[6] - = (int)DAT_MapPropertiesState::instance.SEC_MercRecruitable[6]; - DAT_GameState::instance.mapAndTime.euroRecruitable[0] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.archers; - DAT_GameState::instance.mapAndTime.euroRecruitable[1] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.crossbowmen; - DAT_GameState::instance.mapAndTime.euroRecruitable[2] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.spearmen; - DAT_GameState::instance.mapAndTime.euroRecruitable[3] - = (int)DAT_MapPropertiesState::instance.barracksRecruitability.recruitability.pikemen; - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_0 - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[0] != 0); - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_b - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[1] != 0); - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_2 - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[2] != 0); - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_b - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[3] != 0); - if (DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0) { - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 1; - } - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_4 - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[4] != 0); - if (DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0) { - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; - } - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[5] != 0); - if (DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0) { - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a = 1; - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; - } - DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c - = (int)(DAT_GameState::instance.mapAndTime.euroRecruitable[6] != 0); - DAT_GameState::instance.mapAndTime.countUpTo201 = 0; - MACRO_CALL_MEMBER( - Map::MapPropertiesState_Func::importTradingCosts, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(Map::Units::UnitsState_Func::deselectAllUnitsOneByOne, DAT_UnitsState::ptr)(); - MACRO_CALL_MEMBER( - Map::Units::UnitsState_Func::clearSelectionCountsAndPlayerIDs, DAT_UnitsState::ptr)(); - DAT_GameCore::instance.buildmenuMenuTabToSwitchTo.tabType = UI::Enums::BASMTT_HUNTERSHUT; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_BUILD_MENU, 0); - return; - } - break; - case -6: - DAT_GameCore::instance.mapU3EndInt = 1; - break; - case -5: - DAT_GameCore::instance.mapU3EndInt = 0; - return; - case -4: - DAT_GameCore::instance.mapU4Int3_balanced = 1; - return; - case -3: - DAT_GameCore::instance.mapU4Int3_balanced = 0; - return; - case -2: - iVar6 = INT_00b95b74::instance - 231; - if ((DAT_00b960f4::instance < iVar6) - && (DAT_00b960f4::instance = DAT_00b960f4::instance + 14, iVar6 < DAT_00b960f4::instance)) { - DAT_00b960f4::instance = iVar6; - return; - } - break; - case -1: - DAT_00b960f4::instance -= 14; - if (DAT_00b960f4::instance < 0) { - DAT_00b960f4::instance = 0; - return; - } - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 63efc029c9..800a776df4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14157,7 +14157,7 @@ SHC_3BB0A8C1_0x0044305C | 0.0% | Pending SHC_3BB0A8C1_0x00443060 | 0.0% | Pending -SHC_3BB0A8C1_0x00443070 | 53.2% | compiles again, mechanical pass; structure +SHC_3BB0A8C1_0x00443070 | 0.0% | Pending SHC_3BB0A8C1_0x00443778 | 0.0% | Pending From 76eb7a717caed6a322ffb69557cfbe0bd043244d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 03:58:31 +0100 Subject: [PATCH 78/85] drafts: move MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk to the ready PR General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk (0x00494950) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round32-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...General_LaunchOrQuitMultiplayerGameUnk.cpp | 370 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 371 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp deleted file mode 100644 index e0a9ade9ca..0000000000 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk.cpp +++ /dev/null @@ -1,370 +0,0 @@ -// disable deprecation warnings for strcpy and strcat -#pragma warning(disable : 4996) - -#include "../General.func.hpp" - -#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" -#include "OpenSHC/Game/GameCore.func.hpp" -#include "OpenSHC/Game/Skirmish.func.hpp" -#include "OpenSHC/Game/Skirmish/SkirmishLobbySetupStructure.func.hpp" -#include "OpenSHC/IO/FilePackager.func.hpp" -#include "OpenSHC/IO/ResourceManager.func.hpp" -#include "OpenSHC/Input/MouseState.func.hpp" -#include "OpenSHC/Map.func.hpp" -#include "OpenSHC/Map/MapPropertiesState.func.hpp" -#include "OpenSHC/Map/TileMapState.func.hpp" -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/UI/Actions.func.hpp" -#include "OpenSHC/UI/MenuItems/CustomScenarios.func.hpp" -#include "OpenSHC/UI/MenuItems/HistoricCampaignSelect.func.hpp" -#include "OpenSHC/UI/MenuItems/MainMenu.func.hpp" -#include "OpenSHC/UI/MenuModalComposition.func.hpp" -#include "OpenSHC/UI/MenuTextInputState.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" -#include "OpenSHC/UI/Rendering/WindowAndDirectDraw.func.hpp" -#include "OpenSHC/Commands/GameCommandType.hpp" -#include "OpenSHC/DE/SHCDE/eMusicIDs.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/Game/GameMode2.hpp" -#include "OpenSHC/Game/GameModeInt.hpp" -#include "OpenSHC/Game/TrailType.hpp" -#include "OpenSHC/IO/FileResourceType.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/string-macros.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MapDefinedData.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_MouseState.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_ResourceManager.hpp" -#include "OpenSHC/Globals/DAT_SoundEffectsHelperData1.hpp" -#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" -#include "OpenSHC/Globals/DAT_TileMapState.hpp" -#include "OpenSHC/Globals/DAT_VideoBikQueue.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" -#include "OpenSHC/Globals/FilePackagerObj.hpp" -#include "OpenSHC/Globals/SEC_SkirmishLobbySetupStructure.hpp" -#include "OpenSHC/Globals/UI_MissionModeIntent.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using UI::Enums::MenuViewType; - - // FUNCTION: STRONGHOLDCRUSADER 0x00494950 - void General::MenuItemActionHandler_General_LaunchOrQuitMultiplayerGameUnk(int param_1, ...) - { - OpenSHC::Game::GameModeInt GVar1; - char* pcVar2; - char* pcVar3; - MenuViewType menuID; - GVar1 = DAT_GameSynchronyState::instance.currentGameMode; - if (param_1 != 22) { - if (param_1 == 23) { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 1; - MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); - } - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { - DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerDeathRelated = 0; - MACRO_CALL_MEMBER( - Map::MapPropertiesState_Func::activateScenarioTypeEvents, DAT_MapPropertiesState::ptr)(); - MACRO_CALL_MEMBER(Map::MapPropertiesState_Func::createScenarioEventForNextMonth, - DAT_MapPropertiesState::ptr)(); - DAT_GameCore::instance.section1095 = 2; - } - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - goto LAB_00495061; - } - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 44) { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 43) { - DAT_GameCore::instance.isTimeHalted2 = 0; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_CUSTOM_SCENARIOS, 0); - goto LAB_00494b4a; - } - switch (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter) { - case 7: - break; - case 9: - MACRO_CALL_MEMBER( - Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); - DAT_WindowAndDirectDraw::instance.postWindowCloseMessage = 1; - DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - case 30: - if ((DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) - && (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SKIRMISH_SINGLE_PLAYER)) { - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = DAT_GameCore::instance.mapTimeInTicks; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 - = MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeSomeHashOnUnitArray, - DAT_GameSynchronyState::ptr)(); - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 0; - MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(Commands::GCT_SAVE); - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 32; - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateModalDialogAndClearText, - DAT_MenuTextInputState::ptr)(UI::Enums::MMT_PROGRESS_BAR_BOX); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - case -7: - for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { - DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] - = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; - } - break; - default: - goto switchD_00494a01_caseD_fffffffa; - } - } else { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter < 50) { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 49) { - MACRO_CALL_MEMBER( - Map::MapPropertiesState_Func::spawnInvasionEventAttackWave, DAT_MapPropertiesState::ptr)(); - } else { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 44) { - // restart game - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition3::ptr)(UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER( - Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); - DAT_SoundEffectsHelperData1::instance.SEC_Section1079.musicState = 1; - MACRO_CALL_MEMBER( - Audio::MSS::SoundSystem_Func::setSomeSoundTime, DAT_SoundSystemState::ptr)(); - MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::setupVolumeAndSoundID, - DAT_SoundSystemState::ptr)(DE::SHCDE::MUSIC_TUNE_NARR1); - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER) { - if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { - if (DAT_GameCore::instance.isSkirmishTrail != TRUE) { - MACRO_CALL_MEMBER( - Game::Skirmish::SkirmishLobbySetupStructure_Func::restoreSkirmishLobbySetup, - SEC_SkirmishLobbySetupStructure::ptr)(); - MACRO_CALL(UI::Actions_Func::LaunchSkirmishGame)(0); - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_BUILD_MENU, 0); - MACRO_CALL_MEMBER( - Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - if (DAT_GameCore::instance.currentTrailType == Game::TT_EXTREME) { - if (DAT_GameCore::instance.extremeTrailProgress < 20) { - MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( - DAT_GameCore::instance.extremeTrailProgress); - MACRO_CALL_MEMBER( - Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - } else if (DAT_GameCore::instance.currentTrailType == Game::TT_WARCHEST) { - if (DAT_GameCore::instance.warchestTrailProgress < 30) { - MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( - DAT_GameCore::instance.warchestTrailProgress); - MACRO_CALL_MEMBER( - Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - } else if (DAT_GameCore::instance.skirmishTrailProgress < 50) { - MACRO_CALL(Game::Skirmish_Func::SetupSkirmishMode)( - DAT_GameCore::instance.skirmishTrailProgress); - MACRO_CALL_MEMBER( - Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - goto LAB_00495061; - } - } else { - if (DAT_GameCore::instance.gameMode_2 == Game::GM_BUILDERUnk) { - DAT_GameCore::instance.currentMenuViewType - = UI::Enums::MVT_UNKNOWN_49_DOES_NOTHINGUnk; - MACRO_CALL(Map_Func::ResetSomeValuesFunctionUnk)(); - MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, - DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, - DAT_WindowAndDirectDraw::instance.resolutionY, - (ushort)((int)(COL_BLACK::instance.shortValue))); - MACRO_CALL(UI::Actions_Func::LaunchSinglePlayerGameUnk)(1); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { - MACRO_CALL_MEMBER(Game::GameCore_Func::removeJesterAndLadyUnitsInCertainMissions, - DAT_GameCore::ptr)(); - } - if (DAT_GameCore::instance.gameMode_2 == Game::GM_ECONOMIC_CAMPAIGN_SH1) { - MACRO_CALL_MEMBER(Game::GameCore_Func::removeLadyAndJester, DAT_GameCore::ptr)(); - } - } - DAT_GameCore::instance.gameSuspended = 0; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_SCENARIO_DESCRIPTION, 0); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 47) { - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_MISSION_FINISHED_TRANSITION, 0); - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - DAT_GameCore::instance.section1095 = 0; - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - } - switchD_00494a01_caseD_fffffffa: - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 1000) { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter == 2000) { - // ".map" - strcat(DAT_GameSynchronyState::instance.unknownMapName_01, S__MAP_005A2294); - MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( - IO::FRT_MAPS, (char const*)((int)(DAT_GameSynchronyState::instance.unknownMapName_01))); - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; - MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(Commands::GCT_START_OR_STOP_SEND_MAP_FILEUnk); - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::popModalDialog, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - goto switchD_00494a01_caseD_fffffffa; - } - } - if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_MULTIPLAYER) { - MACRO_CALL_MEMBER( - Synchrony::GameSynchronyState_Func::initMultiplayerLobbyState, DAT_GameSynchronyState::ptr)(); - return; - } - MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::disconnectDPlay, DAT_GameSynchronyState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - DAT_VideoBikQueue::instance.storedMessages_0x924 = 0; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( - UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( - UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition3::ptr)( - UI::Enums::MMT_NONE, FALSE); - MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::stopAllActiveSounds, DAT_SoundSystemState::ptr)(); - DAT_GameCore::instance.currentlyInGameUnk_0xa4 = FALSE; - if (DAT_GameCore::instance.field_0x6c) { - DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = 31; - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition1::ptr)( - UI::Enums::MMT_PROGRESS_BAR_BOX, FALSE); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::renderMenuModal, DAT_MenuModalComposition1::ptr)(); - DAT_WindowAndDirectDraw::instance.pendingBltMode = 1; - MACRO_CALL_MEMBER( - UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, DAT_WindowAndDirectDraw::ptr)(0); - MACRO_CALL_MEMBER(IO::ResourceManager_Func::resolveResourceFileName, DAT_ResourceManager::ptr)( - IO::FRT_MAPS, STR_AutoBackupMap); - FilePackagerObj::instance.loadAndSaveBarFunc = MACRO_CALL(UI::Rendering_Func::RenderLoadAndSaveBar); - MACRO_CALL_MEMBER(IO::FilePackager_Func::readMapOrSavFile, FilePackagerObj::ptr)( - DAT_MapDefinedData::instance.MapSectionAddressArray); - MACRO_CALL_MEMBER(Map::TileMapState_Func::prepareMap, DAT_TileMapState::ptr)(); - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_MAP_EDITOR_PROPERTIES, 0); - DAT_GameCore::instance.field_0x6c = 0; - goto LAB_0049504b; - } - if (!UI_MissionModeIntent::instance) { - if (DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter != 7) { - menuID = UI::Enums::MVT_SINGLEPLAYER_MAP_CHOICE; - goto LAB_00495046; - } - if (GVar1 == Game::GM_SOLITARY) { - if (DAT_GameCore::instance.gameMode_2 != Game::GM_BUILDERUnk) { - menuID = UI::Enums::MVT_MAIN_MENU; - goto LAB_00495046; - } - if (DAT_MapPropertiesState::instance.SEC_U3_MapType2_1 == Map::MT_INVASION) { - MACRO_CALL(UI::MenuItems::CustomScenarios_Func::MenuItemActionHandler_CustomScenarios_Main)(4); - } else { - MACRO_CALL(UI::MenuItems::MainMenu_Func::MenuItemActionHandler_MainMenu_Main)(3); - } - } else if (GVar1 == Game::GM_SKIRMISH_SINGLE_PLAYER) { - if (DAT_GameCore::instance.gameMode_2 != Game::GM_CAMPAIGN_MISSION) { - if (!DAT_GameCore::instance.isSkirmishTrail) { - menuID = UI::Enums::MVT_UNKNOWN_61_RETURN_TO_SKIRMISH_MENUUnk; - } else { - DAT_GameCore::instance.gameSuspended = 0; - menuID = UI::Enums::MVT_CRUSADE_MAP; - } - goto LAB_00495046; - } - MACRO_CALL( - UI::MenuItems::HistoricCampaignSelect_Func::MenuItemActionHandler_HistoricCampaignSelect_Main)( - 4); - } else { - DAT_GameSynchronyState::instance.nextModalDialog = UI::Enums::MMT_CHOOSE_NETWORK_SERVICE_PROVIDER; - DAT_GameCore::instance.gameMode_2 = Game::GM_SKIRMISH_AND_MULTIPLAYER; - DAT_GameCore::instance.xbowProducible_logic = 1; - DAT_GameCore::instance.pikeProducible_logic = 1; - DAT_GameCore::instance.swordProducible_logic = 1; - DAT_GameCore::instance.bowProducible_logic = 1; - DAT_GameCore::instance.spearProducible_logic = 1; - DAT_GameCore::instance.maceProducible_logic = 1; - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( - UI::Enums::MVT_MP_CONNECTION, 0); - for (int i = 0; i < countof(DAT_BlendingDefinedData::instance.PlayerSlotUnitColor); ++i) { - DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[i] - = DAT_BlendingDefinedData::instance.DefaultPlayerSlotUnitColor[i]; - } - } - } else { - if (DAT_GameCore::instance.gameMode_2 == Game::GM_CAMPAIGN_MISSION) { - menuID = UI::Enums::MVT_HISTORIC_MISSION_SELECT; - } else { - menuID = UI::Enums::MVT_UNUSED_ECONOMIC_MISSION_SELECTUnk; - } - LAB_00495046: - MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)(menuID, 0); - } - LAB_0049504b: - if (DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU) { - LAB_00494b4a: - MACRO_CALL_MEMBER( - UI::MenuTextInputState_Func::clearAnyOtherModalDialogs, DAT_MenuTextInputState::ptr)(); - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - return; - } - MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::meth_0x4917c0, DAT_MenuTextInputState::ptr)(); - LAB_00495061: - MACRO_CALL_MEMBER(Input::MouseState_Func::resetMouseState2, DAT_MouseState::ptr)(); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 800a776df4..912dbd8e47 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -24113,7 +24113,7 @@ SHC_3BB0A8C1_0x004948C0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00494920 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00494950 | 64.2% | strcat intrinsic, mechanical pass; structure +SHC_3BB0A8C1_0x00494950 | 0.0% | Pending SHC_3BB0A8C1_0x00494DB0 | 0.0% | Pending From 3919ea8646aed96f7c9b4d543814f199d6b641e5 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 05:33:20 +0100 Subject: [PATCH 79/85] drafts: move MenuItemActionHandler_NewEventCondition_Main to the ready PR NewEventCondition::MenuItemActionHandler_NewEventCondition_Main (0x004B9620) is rewritten on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round33-100: its code is the original's, recorded as 100% (reccmp shows 99.8, one resolved address is named differently on the two sides). Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...emActionHandler_NewEventCondition_Main.cpp | 384 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 385 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp b/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp deleted file mode 100644 index 21fb189c27..0000000000 --- a/src/OpenSHC/UI/MenuItems/NewEventCondition/MenuItemActionHandler_NewEventCondition_Main.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "../NewEventCondition.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_MissionAestheticsDefinedData.hpp" -#include "OpenSHC/Globals/DAT_UnitsState.hpp" -#include "OpenSHC/Globals/DAT_UnknownTime_01.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x004B9620 - void NewEventCondition::MenuItemActionHandler_NewEventCondition_Main(int param_1, ...) - { - ushort* puVar1; - short* destination; - byte* pbVar2; - short sVar3; - byte(*pabVar4)[100]; - DWORD DVar5; - char* pcVar6; - int iVar7; - int iVar8; - if (param_1 < 1001) { - if (param_1 == 1000) { - sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex] - < (int)sVar3) { - *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 - 1; - return; - } - } else { - switch (param_1) { - case 19: - *(undefined1*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 15) = 0; - return; - case 37: - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 15) - != '\0') { - iVar8 = 1; - pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 19); - while (*pcVar6 == '\0') { - ++iVar8; - pcVar6 += 4; - if (39 < iVar8) { - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); - return; - } - } - *(undefined1*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 15) = 0; - } - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, - DAT_MenuModalComposition1::ptr)(UI::Enums::MMT_NEW_EVENT, FALSE); - return; - case 104: - puVar1 = (ushort*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + 8); - *puVar1 ^= 1; - return; - case 190: - case 191: - case 192: - case 193: - case 194: - case 195: - case 196: - case 197: - case 198: - case 199: - case 200: - case 201: - case 202: - case 203: - case 204: - case 205: - case 206: - case 207: - case 208: - case 209: - param_1 -= 64; - case 106: - case 107: - case 108: - case 109: - case 110: - case 111: - case 112: - case 113: - case 114: - case 115: - case 116: - case 117: - case 118: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - DAT_MapPropertiesState::instance.invasionTroopIndex = param_1 - 106; - *(undefined1*)((int)DAT_MapPropertiesState::instance.buildingAvailabilityRelatedFlags - + DAT_MapPropertiesState::instance.currentEventID * 228 + param_1 * 4 + 511) = 1; - DAT_UnknownTime_01::instance = 0; - if ((int)*(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) - < DAT_MissionAestheticsDefinedData::instance - .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { - *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) - = (short)DAT_MissionAestheticsDefinedData::instance - .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex]; - } - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex] - != 0) { - destination = (short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); - MACRO_CALL_MEMBER( - UI::MenuModalComposition_Func::setSliderParameters2, DAT_MenuModalComposition2::ptr)( - DAT_MissionAestheticsDefinedData::instance - .EventConditionMinValue[DAT_MapPropertiesState::instance.invasionTroopIndex], - (dword)((int)(DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex])), - (dword)((int)((int)*destination)), (dword)((int)(destination)), - MACRO_CALL(UI::Helpers_Func::CaptureCurrentTimeToUnknownTime01)); - MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::setExtraActiveModalDialog, - DAT_MenuModalComposition2::ptr)(UI::Enums::MMT_OVERLAY_SLIDER, - (int)((int)(DAT_ButtonX::instance + 58)), (int)((int)(DAT_ButtonY::instance + 28))); - return; - } - } - } - } else if (param_1 < 2003) { - if (param_1 < 2001) { - if (param_1 == 1001) { - sVar3 = *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12); - if ((int)sVar3 < DAT_MissionAestheticsDefinedData::instance - .EventConditionMaxValue[DAT_MapPropertiesState::instance.invasionTroopIndex]) { - *(short*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 12) = sVar3 + 1; - return; - } - } else if (param_1 == 2000) { - iVar8 = 0; - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - != 0) { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 1) { - iVar7 - = (int)*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); - pbVar2 = (byte*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); - if (*(int*)DAT_MissionAestheticsDefinedData::instance - .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] - != iVar7) { - pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - + DAT_MapPropertiesState::instance.invasionTroopIndex; - do { - pabVar4 = (byte(*)[100])(*pabVar4 + 4); - ++iVar8; - } while (*(int*)*pabVar4 != iVar7); - } - if (iVar8 - 1 < 0) { - pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - + DAT_MapPropertiesState::instance.invasionTroopIndex; - iVar8 = 0; - do { - iVar7 = iVar8; - if (*(int*)*pabVar4 == -1) { - *pbVar2 - = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex - 1] - [iVar7 * 4 + 96]; - goto LAB_004b98bd; - } - pabVar4 = (byte(*)[100])(*pabVar4 + 4); - iVar8 = iVar7 + 1; - } while (iVar7 + 1 < 100); - *pbVar2 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar7 * 4 + 4]; - } else { - *pbVar2 - = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex - 1][iVar8 * 4 + 96]; - } - } - LAB_004b98bd: - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 2) { - pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); - --*pcVar6; - if (*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) - < '\0') { - *(undefined1*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 4; - } - } - } - } - } else { - iVar8 = 0; - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - != 0) { - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 1) { - iVar7 = (int)*(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); - if (!iVar7) { - *(undefined1*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 10; - iVar7 = 10; - } - if (*(int*)DAT_MissionAestheticsDefinedData::instance - .EventConditionOptionValues[DAT_MapPropertiesState::instance.invasionTroopIndex] - != iVar7) { - pabVar4 = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - + DAT_MapPropertiesState::instance.invasionTroopIndex; - do { - pabVar4 = (byte(*)[100])(*pabVar4 + 4); - ++iVar8; - } while (*(int*)*pabVar4 != iVar7); - } - if (*(int*)(DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex] - + iVar8 * 4 + 4) - == -1) { - *(byte*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) - = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex][0]; - } else { - *(byte*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) - = DAT_MissionAestheticsDefinedData::instance.EventConditionOptionValues - [DAT_MapPropertiesState::instance.invasionTroopIndex][iVar8 * 4 + 4]; - } - } - if (DAT_MissionAestheticsDefinedData::instance - .EventConditionParamKind[DAT_MapPropertiesState::instance.invasionTroopIndex] - == 2) { - pcVar6 = (char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14); - *pcVar6 += '\x01'; - if ('\x04' < *(char*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14)) { - *(undefined1*)((int)&DAT_MapPropertiesState::instance - .scenarioEvents[DAT_MapPropertiesState::instance.currentEventID] - .data - + DAT_MapPropertiesState::instance.invasionTroopIndex * 4 + 14) = 0; - return; - } - } - } - } - } else { - switch (param_1) { - case 5190: - case 5191: - case 5192: - case 5193: - case 5194: - case 5195: - case 5196: - case 5197: - case 5198: - case 5199: - case 5200: - case 5201: - case 5202: - case 5203: - case 5204: - case 5205: - case 5206: - case 5207: - case 5208: - case 5209: - param_1 -= 64; - case 5106: - case 5107: - case 5108: - case 5109: - case 5110: - case 5111: - case 5112: - case 5113: - case 5114: - case 5115: - case 5116: - case 5117: - case 5118: - case 5119: - case 5120: - case 5121: - case 5122: - case 5123: - case 5124: - case 5125: - if ((DAT_MenuModalComposition2::instance.activeModalDialogID == UI::Enums::MMT_NONE) - && ((DVar5 = timeGetTime(), - 1000 < DVar5 - DAT_UnknownTime_01::instance || (!DAT_UnknownTime_01::instance)))) { - DAT_UnknownTime_01::instance = 0; - ((char*)&DAT_UnitsState::instance.units[2491] - + 995)[(DAT_MapPropertiesState::instance.currentEventID * 57 + param_1) * 4] = 0; - return; - } - } - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 912dbd8e47..4e77f25912 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -27641,7 +27641,7 @@ SHC_3BB0A8C1_0x004B9530 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B9610 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B9620 | 64.0% | compiles again, mechanical pass; structure +SHC_3BB0A8C1_0x004B9620 | 0.0% | Pending SHC_3BB0A8C1_0x004B9AA8 | 0.0% | Pending From 356f8247d7de905a292851b705264dc1ff56349d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 10:05:13 +0100 Subject: [PATCH 80/85] reimplement: SHC_3BB0A8C1_0x00443A30 94.7% rewritten from the listing; six behaviour fixes; four instructions left MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback, 23.3% to 94.7% (66.1% normalized), written from the original's listing. gynt's draft: 093895284 at 23.29% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems, whose status line records 23.3%; his reimpl/UI-MenuItems-development records 23.3% too ("Reimplemented, asm differs"; the newest commit on the file there is 8725ec523). Our draft (3f2ac05c3, then 5fca8b920) was his code with a mechanical pass. The function is the landscaping view's callback in the map editor. It handles the mouse's event (lowered view, map rotation, zoom, flat view), switches the "people left to place" element, previews the mapper under the mouse while no button is down, and on a left click queues the mapper's command: one switch over currentMapperCommand, 33 blocks through the byte table at 0x0044432C and the jump table at 0x004442A4 and two (340, 341) through compares. Every block fills the command's params (x, y, the brush size or a constant, two more) and calls queueCommand. Six behaviour fixes, each visible in the draft's own listing: - Event 5 (the flat view) returned right after toggleFlatView. The original goes on: it sets the handled flag and runs the rest (0x00443AE8 falls into 0x00443AED). - The "people left to place" element was switched with `2300 < unitCount`. The original has `>= 2300` (cmp with 0x8fc, jl at 0x00443AFD). - No return after HandleWallTerrainMouseDrag: the original leaves through it (a tail jump at 0x00443B1C). - No return after storeXYAndResetMouseState: the same (0x00443B31). - No return after renderWallPlacementPreview: the original returns (0x00443BF2); the draft ran on into the click part. - The river, foam and ripple case had no return after its first queueCommand: for the river and the ripple it queued their GCT_SET_TERRAIN and then a second one with param 4 = 16, the foam's. The original queues once on each path: the foam's call at 0x00443F7D with a ret at 0x00443F85, the other two's at 0x00443FA9 with a ret at 0x00443FB1. What the match needed. The counts are differing lines out of the original's 508 instructions in our own exact listing compare (operands, jump landings and the jump table included), not reccmp numbers: - The two 0 / 1 arguments are an if / else with a call in each arm (resetupViewport(0) / (1), and the element's call with 1 / 0). The compiler shares the call and pushes the constant in each arm, and with that it keeps 0, 1 and 2 in ebx, esi and edi for the function's first half, as the original does. As conditional expressions it emits sete / setge and the constant registers are gone: 678 against 43. - Two pairs of tile variables: a const pair for the click's start and copies for the snapped tile. With one pair x and y stay in edi and esi and the compiler merges every case into one tail (393 instructions, 386 lines). - The click part's locals are read in the order snap, orientation, tile y, tile x: 43 to 39. - The switch is on the field, and the cases read the field again. With a local the command sits in edx instead of esi through all the cases: 39 to 8. - Every case is written out in full, params in the order 0 to 4, then the call and a return. The shapes of the original's cases come from that by themselves: the scratch register for the brush size rotates from case to case (eax, ecx, edx); with eax the x store comes first, with ecx the y store; and the compiler shares the cases' tails with the last case's code (0x00444266 to 0x00444298), which 16 jumps enter at four places. Cases with a constant in place of the brush size do not advance the rotation. Left: four instructions in two places of the click part, 8 lines of that compare. - The second leftClickStart test (0x00443C1C) compares with ebx, the zero register, in the original and with an immediate 0 in ours. In ours the load of the orientation into ebx counts as coming first. - The logic layer's index goes through eax in the original and through edx in ours: three instructions (0x00443C5B, 0x00443C62 and 0x00443C6E). Tried for the first: the test as a truth test, through a local copy (BOOLEnum, bool, int), the four locals in every order and with other types, and the locals assigned in both arms of the test, all four or any subset. Only the last form gives the compare with ebx, and then the orientation's load comes after the tile's two (in all 24 orders). Tried for the second, without any change: the index in a local, through a helper, with the operands the other way round, in the variable that later holds x, the valid test in a local or as one condition with the logic test, and xyAreValid called without the macro. A /GL build with the nine finished callees reads 54.7%, and xyAreValid's body visible as an inline copy changes nothing, so neither is the cause. The reccmp diff has 82 lines: these four instructions, and every jump over them and every jump table entry after them, which the one byte of the longer compare shifts. Measured in a narrow build on main 3458fea34 of this file as committed and the nine finished functions it calls, struct resolvers and their resolvers on: xyAreValid, setupMouseTileXY, queueCommand, HandleWallTerrainMouseDrag, storeXYAndResetMouseState, CheckDisplayElementByIDAndSetForUnlimitedDisplay, resetupViewport, toggleFlatView and setMapRotation. Seven of them read 100.0; queueCommand (99.1) and resetupViewport (43.8) read what they read in main's own all-on build. No all-on build was run for this commit. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- ...EditorLandscaping_QueueCommandCallback.cpp | 725 ++++++++++-------- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 396 insertions(+), 331 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp index 543fe2a970..ca645081f7 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp @@ -8,9 +8,12 @@ #include "OpenSHC/UI/Helpers.func.hpp" #include "OpenSHC/Commands/GameCommandType.hpp" #include "OpenSHC/Commands/MappersEnum.hpp" -#include "OpenSHC/Commands/MappersEnumInt.hpp" +#include "OpenSHC/Map/Enums/LoweredViewTransition.hpp" +#include "OpenSHC/Map/Enums/MapOrientation.hpp" +#include "OpenSHC/Map/Enums/MapOrientationInt.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic1.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic2.hpp" #include "OpenSHC/UI/Enums/DisplayElementID.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" #include "OpenSHC/Globals/DAT_ModifierKeyState.hpp" @@ -26,417 +29,479 @@ namespace OpenSHC { namespace UI { namespace MenuItems { - using OpenSHC::Commands::GameCommandType; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - // FUNCTION: STRONGHOLDCRUSADER 0x00443A30 void MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback() { - BOOLEnum BVar3; - bool bVar4; - GameCommandType commandType; + // the mouse's event: 1, 3, 4 and 5 are handled here and set the flag that a right click's end then clears if (DAT_MouseState::instance.mouseBasedEvent == 1) { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(3); - LAB_00443aed: + MACRO_CALL_MEMBER(Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)( + Map::Enums::LVT_LOWER); INT_00b9844c::instance = 1; - } else { - if (((DAT_MouseState::instance.rightClickState) && (DAT_MouseState::instance.mouseBasedEvent != 2)) - || (DAT_ModifierKeyState::instance.ctrl != 0 && (DAT_ModifierKeyState::instance.downArrow != 0)) - || DAT_ModifierKeyState::instance.v != 0) { - if (DAT_MouseState::instance.mouseBasedEvent == 3) { - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( - DAT_MouseState::instance.mapOrientationCopy3); - } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { - DAT_MouseState::instance.field_0x198 = 2; - MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, - DAT_ViewportRenderState::ptr)( - (uint)(DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk == 0)); - DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; - DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; - } else { - if (DAT_MouseState::instance.mouseBasedEvent != 5) - goto LAB_00443af3; - DAT_MouseState::instance.field_0x19c = 2; - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( - DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); - return; - } - goto LAB_00443aed; + } else if ((!DAT_MouseState::instance.rightClickState || DAT_MouseState::instance.mouseBasedEvent == 2) + && (DAT_ModifierKeyState::instance.ctrl == 0 || DAT_ModifierKeyState::instance.downArrow == 0) + && DAT_ModifierKeyState::instance.v == 0) { + MACRO_CALL_MEMBER(Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)( + Map::Enums::LVT_RAISE); + } else if (DAT_MouseState::instance.mouseBasedEvent == 3) { + MACRO_CALL_MEMBER(Map::TileMapState_Func::setMapRotation, DAT_TileMapState::ptr)( + DAT_MouseState::instance.mapOrientationCopy3); + INT_00b9844c::instance = 1; + } else if (DAT_MouseState::instance.mouseBasedEvent == 4) { + DAT_MouseState::instance.field_0x198 = 2; + // a call in each arm (as one call with `zoomed ? 0 : 1` the match is lost) + if (DAT_ViewportRenderState::instance.viewportState.isZoomedOutUnk) { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(0); + } else { + MACRO_CALL_MEMBER( + OpenSHC::Rendering::ViewportRenderState_Func::resetupViewport, DAT_ViewportRenderState::ptr)(1); } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::triggerLoweredView, DAT_TileMapState::ptr)(4); + DAT_WindowAndDirectDraw::instance.unk_resetViewportRelated = 2; + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + INT_00b9844c::instance = 1; + } else if (DAT_MouseState::instance.mouseBasedEvent == 5) { + DAT_MouseState::instance.field_0x19c = 2; + MACRO_CALL_MEMBER(Map::TileMapState_Func::toggleFlatView, DAT_TileMapState::ptr)( + DAT_TileMapState::instance.flatViewToggleValue1 ^ 1); + INT_00b9844c::instance = 1; } - LAB_00443af3: - MACRO_CALL(OpenSHC::UI::DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( - OpenSHC::UI::Enums::DEID_PEOPLE_LEFT_TO_PLACE, - (dword)((int)(2300 < (int)DAT_UnitsState::instance.unitCount))); - if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { - MACRO_CALL(OpenSHC::UI::Helpers_Func::HandleWallTerrainMouseDrag)(); + // a call in each arm, as above + if (DAT_UnitsState::instance.unitCount >= 2300) { + MACRO_CALL(DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + Enums::DEID_PEOPLE_LEFT_TO_PLACE, 1); + } else { + MACRO_CALL(DisplayElements_Func::CheckDisplayElementByIDAndSetForUnlimitedDisplay)( + Enums::DEID_PEOPLE_LEFT_TO_PLACE, 0); + } + if (DAT_TileMapState::instance.currentMapperCommand == Commands::M_MAPPER_RIPPLE) { + MACRO_CALL(Helpers_Func::HandleWallTerrainMouseDrag)(); + return; } if (DAT_ViewportRenderState::instance.viewportState.field_0x0 == 0) { - MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + MACRO_CALL_MEMBER(Input::MouseState_Func::storeXYAndResetMouseState, DAT_MouseState::ptr)(); + return; } - if (DAT_MouseState::instance.rightClickStop != 0) { + // a right click ends: the mapper command goes, unless the click was one of the events handled above + if (DAT_MouseState::instance.rightClickStop) { if (INT_00b9844c::instance == 0) { - DAT_TileMapState::instance.currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL; + DAT_TileMapState::instance.currentMapperCommand = Commands::M_MAPPER_NULL; return; } INT_00b9844c::instance = 0; } + // no left button: only the preview under the mouse if (!DAT_MouseState::instance.leftClickState) { MACRO_CALL_MEMBER( OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( + MACRO_CALL_MEMBER(Map::TileMapState_Func::noop1, DAT_TileMapState::ptr)( DAT_ViewportRenderState::instance.viewportState.mouseFlatTile); - 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 (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_NULL) { + if (DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_BIGROCK1 + && DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_BIGROCK2 + && DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_BIGROCK3 + && DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_BIGROCK4 + && DAT_TileMapState::instance.currentMapperCommand != Commands::M_MAPPER_BIGROCK5) { + if (DAT_TileMapState::instance.currentMapperCommand == Commands::M_MAPPER_NULL) { return; } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderPreviewMapperWithBrush, - DAT_TileMapState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, - (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), + MACRO_CALL_MEMBER(Map::TileMapState_Func::renderPreviewMapperWithBrush, DAT_TileMapState::ptr)( + DAT_ViewportRenderState::instance.viewportState.mouseTileX, + DAT_ViewportRenderState::instance.viewportState.mouseTileY, DAT_TileMapState::instance.currentMapperCommand); return; } - MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::renderWallPlacementPreview, DAT_TileMapState::ptr)( + MACRO_CALL_MEMBER(Map::TileMapState_Func::renderWallPlacementPreview, DAT_TileMapState::ptr)( DAT_ViewportRenderState::instance.viewportState.mouseTileX, - (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY), - (short)(DAT_TileMapState::instance.rockFlagStartNumber - + DAT_TileMapState::instance.unknownBrushRelated * 4)); + DAT_ViewportRenderState::instance.viewportState.mouseTileY, + DAT_TileMapState::instance.rockFlagStartNumber + + DAT_TileMapState::instance.unknownBrushRelated * 4); + return; } - if ((DAT_MouseState::instance.leftClickStart == 0) - && (DAT_ViewportRenderState::instance.viewportState.previousMouseTile - == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile)) { + // the left button is down: go on when the click starts or the mouse has reached another tile + if (!DAT_MouseState::instance.leftClickStart + && DAT_ViewportRenderState::instance.viewportState.previousMouseTile + == DAT_ViewportRenderState::instance.viewportState.mouseFlatTile) { return; } DAT_ViewportRenderState::instance.viewportState.previousMouseTile = DAT_ViewportRenderState::instance.viewportState.mouseFlatTile; MACRO_CALL_MEMBER( OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); - int iVar2 = DAT_ViewportRenderState::instance.viewportState.mouseTileY; - int _clickedX = DAT_ViewportRenderState::instance.viewportState.mouseTileX; - int iVar1 = DAT_TileMapState::instance.editorSnapToMode; - int _orientation = DAT_TileMapState::instance.mapOrientation; - if (DAT_MouseState::instance.leftClickStart != 0) { - DAT_TileMapState::instance.DAT_ClickedTileX - = DAT_ViewportRenderState::instance.viewportState.mouseTileX; - DAT_TileMapState::instance.DAT_ClickedTileY - = DAT_ViewportRenderState::instance.viewportState.mouseTileY; - BVar3 = MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::xyAreValid, - DAT_ViewportRenderState::ptr)(DAT_ViewportRenderState::instance.viewportState.mouseTileX, - (uint)(DAT_ViewportRenderState::instance.viewportState.mouseTileY)); - if ((BVar3) - && (DAT_TileMapState::instance.editorAffectType = 0, - (DAT_TileMapState::instance - .LogicLayer[DAT_ViewportRenderState::instance.translationMatrix[iVar2].addXgetTile - + _clickedX] - & 0x41) - != 0)) { - DAT_TileMapState::instance.editorAffectType = 1; + // read in this order (another order loses the match); x and y below are the snapped tile + int const snap = DAT_TileMapState::instance.editorSnapToMode; + Map::Enums::MapOrientationInt const orientation = DAT_TileMapState::instance.mapOrientation; + int const tileY = DAT_ViewportRenderState::instance.viewportState.mouseTileY; + int const tileX = DAT_ViewportRenderState::instance.viewportState.mouseTileX; + // the click starts: its tile is kept, and whether it is on sea or on the unnamed 0x40 kind + if (DAT_MouseState::instance.leftClickStart) { + DAT_TileMapState::instance.DAT_ClickedTileX = tileX; + DAT_TileMapState::instance.DAT_ClickedTileY = tileY; + if (MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::xyAreValid, + DAT_ViewportRenderState::ptr)(tileX, tileY)) { + DAT_TileMapState::instance.editorAffectType = 0; + if (DAT_TileMapState::instance + .LogicLayer[DAT_ViewportRenderState::instance.translationMatrix[tileY].addXgetTile + tileX] + & (Map::LogicHelpers::L_SEA | Map::LogicHelpers::L_UNNAMED_0x40)) { + DAT_TileMapState::instance.editorAffectType = 1; + } } } - int _clickedY = DAT_TileMapState::instance.DAT_ClickedTileY; - if ((_orientation == 0) || (_orientation == 4)) { - if (iVar1 != 1) { - bVar4 = iVar1 == 2; - goto LAB_00443cb1; + // copies: with one pair of variables every case below is merged into the last one + int x = tileX; + int y = tileY; + // snapping keeps the clicked tile's y or x; the two modes change places with the map's orientation + if (orientation != Map::Enums::MO_NORTH && orientation != Map::Enums::MO_SOUTH) { + if (snap == 2) { + y = DAT_TileMapState::instance.DAT_ClickedTileY; + } else if (snap == 1) { + x = DAT_TileMapState::instance.DAT_ClickedTileX; } - } else if (iVar1 != 2) { - bVar4 = iVar1 == 1; - LAB_00443cb1: - _clickedY = iVar2; - if (bVar4) { - _clickedX = DAT_TileMapState::instance.DAT_ClickedTileX; - } - } - if (340 < (int)DAT_TileMapState::instance.currentMapperCommand) { - if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_SCRUBGRASS) { - return; + } else { + if (snap == 1) { + y = DAT_TileMapState::instance.DAT_ClickedTileY; + } else if (snap == 2) { + x = DAT_TileMapState::instance.DAT_ClickedTileX; } - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = -128; - goto LAB_00444270; - } - if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_DUNES) { - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; } + // the field, not a local (a local loses the match) switch (DAT_TileMapState::instance.currentMapperCommand) { - case OpenSHC::Commands::M_MAPPER_DELETE: + // every case in full; the compiler shares the tails by itself + case Commands::M_MAPPER_DELETE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_UNIT_ERASE); + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_UNIT_ERASE); return; - case OpenSHC::Commands::M_MAPPER_RAISE: + case Commands::M_MAPPER_RAISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_RAISE_LAND); - return; - case OpenSHC::Commands::M_MAPPER_MOUNTAIN: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LAND; - commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; - break; - case OpenSHC::Commands::M_MAPPER_HILL: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_LOWER; - commandType = OpenSHC::Commands::GCT_RAISE_LAND2Unk; - break; - case OpenSHC::Commands::M_MAPPER_LOWER: + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_RAISE_LAND); + return; + case Commands::M_MAPPER_MOUNTAIN: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 5; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_RAISE_LAND2Unk); + return; + case Commands::M_MAPPER_HILL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 3; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_RAISE_LAND2Unk); + return; + case Commands::M_MAPPER_LOWER: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -1; - commandType = OpenSHC::Commands::GCT_RAISE_LAND; - goto LAB_0044427c; - case OpenSHC::Commands::M_MAPPER_LAND: + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_RAISE_LAND); + return; + case Commands::M_MAPPER_LAND: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_LAND); + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_LAND); return; - case OpenSHC::Commands::M_MAPPER_SEA: + case Commands::M_MAPPER_SEA: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_BEACH: - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; - goto LAB_00444270; - case OpenSHC::Commands::M_MAPPER_EQUALISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_SEA; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_BEACH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_BEACH; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_EQUALISE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_EQUALIZE); + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_TERRAIN_EQUALIZE); return; - case OpenSHC::Commands::M_MAPPER_PLAIN1: + case Commands::M_MAPPER_PLAIN1: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 4; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_CREATE_PLATEAU); - return; - case OpenSHC::Commands::M_MAPPER_PLAIN2: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 8; - commandType = OpenSHC::Commands::GCT_CREATE_PLATEAU; - goto LAB_0044427c; - case OpenSHC::Commands::M_MAPPER_MIN: - case OpenSHC::Commands::M_MAPPER_MAX: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.mapperMax; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L2_PLATEAU_MEDIUM; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_CREATE_PLATEAU); + return; + case Commands::M_MAPPER_PLAIN2: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_TERRAIN_MIN_MAX); - return; - case OpenSHC::Commands::M_MAPPER_BIGROCK1: - case OpenSHC::Commands::M_MAPPER_BIGROCK2: - case OpenSHC::Commands::M_MAPPER_BIGROCK3: - case OpenSHC::Commands::M_MAPPER_BIGROCK4: - case OpenSHC::Commands::M_MAPPER_BIGROCK5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L2_PLATEAU_HIGH; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_CREATE_PLATEAU); + return; + case Commands::M_MAPPER_MIN: + case Commands::M_MAPPER_MAX: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.mapperMax; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_TERRAIN_MIN_MAX); + return; + // rockFlagStartNumber counts on with every rock placed and starts again after 3 + case Commands::M_MAPPER_BIGROCK1: + case Commands::M_MAPPER_BIGROCK2: + case Commands::M_MAPPER_BIGROCK3: + case Commands::M_MAPPER_BIGROCK4: + case Commands::M_MAPPER_BIGROCK5: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = Commands::M_MAPPER_BIGROCKS; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = DAT_TileMapState::instance.rockFlagStartNumber + DAT_TileMapState::instance.unknownBrushRelated * 4; - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 20; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk); + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); ++DAT_TileMapState::instance.rockFlagStartNumber; - if (4 <= (int)DAT_TileMapState::instance.rockFlagStartNumber) { + if ((int)DAT_TileMapState::instance.rockFlagStartNumber >= 4) { DAT_TileMapState::instance.rockFlagStartNumber = 0; } return; - case OpenSHC::Commands::M_MAPPER_ROCKY: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 128; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - goto LAB_0044427a; - case OpenSHC::Commands::M_MAPPER_STONES: + case Commands::M_MAPPER_ROCKY: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 64; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_RIVER: - case OpenSHC::Commands::M_MAPPER_FOAM: - case OpenSHC::Commands::M_MAPPER_RIPPLE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_ROCKY; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_STONES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_STONES_OR_DRIVEN_SANDUnk; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + // param 4 is the river's kind: 0 river, 16 foam, 32 ripple; a ripple takes the brush size 1 + case Commands::M_MAPPER_RIVER: + case Commands::M_MAPPER_FOAM: + case Commands::M_MAPPER_RIPPLE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1048576; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_RIVER; DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - if (DAT_TileMapState::instance.currentMapperCommand != OpenSHC::Commands::M_MAPPER_FOAM) { - if (DAT_TileMapState::instance.currentMapperCommand == OpenSHC::Commands::M_MAPPER_RIPPLE) { - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_AREA; - } - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + if (DAT_TileMapState::instance.currentMapperCommand == Commands::M_MAPPER_FOAM) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; } - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_FORD: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 2097152; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - goto LAB_0044427a; - case OpenSHC::Commands::M_MAPPER_BOULDERS: + if (DAT_TileMapState::instance.currentMapperCommand == Commands::M_MAPPER_RIPPLE) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 32; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = 1; + } + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_FORD: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 131072; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_FORD; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); return; - case OpenSHC::Commands::M_MAPPER_PEBBLES: + case Commands::M_MAPPER_BOULDERS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 262144; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_BOULDERS; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); return; - case OpenSHC::Commands::M_MAPPER_IRON: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 524288; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - goto LAB_0044427a; - case OpenSHC::Commands::M_MAPPER_OIL: + case Commands::M_MAPPER_PEBBLES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = -2147483648; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_PEBBLES; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); return; - case OpenSHC::Commands::M_MAPPER_MARSH: + case Commands::M_MAPPER_IRON: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 536870912; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_DUGMOAT: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; - LAB_0044427a: - commandType = OpenSHC::Commands::GCT_SET_TERRAIN; - LAB_0044427c: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_IRON; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_OIL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - break; - case OpenSHC::Commands::M_MAPPER_UNDUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_OIL; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_MARSH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 1073741824; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 3; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_DIRT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_MARSH; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_NONE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_DUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 2; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_GRASS: - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 16; - LAB_00444270: - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - goto LAB_0044427a; - case OpenSHC::Commands::M_MAPPER_SCRUB: + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_MOAT; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_EARTH_AND_STONES; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_UNDUGMOAT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_MOAT; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_MOAT_UNDUG; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_DIRT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_EARTH_AND_STONES; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_GRASS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_OASIS_GRASS; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + case Commands::M_MAPPER_SCRUB: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_SCRUB; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + // a tree's, a shrub's and an animal's kind is its mapper value + case Commands::M_MAPPER_CHESTNUT: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = Commands::M_MAPPER_CHESTNUT; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = 1; - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, - DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_SET_TERRAIN); - return; - case OpenSHC::Commands::M_MAPPER_CHESTNUT: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_CHESTNUT; - DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; - break; - case OpenSHC::Commands::M_MAPPER_OAK: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_OAK; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); + return; + case Commands::M_MAPPER_OAK: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = Commands::M_MAPPER_OAK; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; - break; - case OpenSHC::Commands::M_MAPPER_SHRUB1A: - case OpenSHC::Commands::M_MAPPER_SHRUB1B: - case OpenSHC::Commands::M_MAPPER_SHRUB1C: - case OpenSHC::Commands::M_MAPPER_SHRUB1D: - case OpenSHC::Commands::M_MAPPER_SHRUB1E: - case OpenSHC::Commands::M_MAPPER_SHRUB2A: - case OpenSHC::Commands::M_MAPPER_SHRUB2B: - case OpenSHC::Commands::M_MAPPER_SHRUB2C: - case OpenSHC::Commands::M_MAPPER_SHRUB2D: - case OpenSHC::Commands::M_MAPPER_SHRUB2E: - case OpenSHC::Commands::M_MAPPER_SHRUB3A: - case OpenSHC::Commands::M_MAPPER_SHRUB3B: - case OpenSHC::Commands::M_MAPPER_SHRUB3C: - case OpenSHC::Commands::M_MAPPER_SHRUB3D: + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); + return; + case Commands::M_MAPPER_SHRUB1A: + case Commands::M_MAPPER_SHRUB1B: + case Commands::M_MAPPER_SHRUB1C: + case Commands::M_MAPPER_SHRUB1D: + case Commands::M_MAPPER_SHRUB1E: + case Commands::M_MAPPER_SHRUB2A: + case Commands::M_MAPPER_SHRUB2B: + case Commands::M_MAPPER_SHRUB2C: + case Commands::M_MAPPER_SHRUB2D: + case Commands::M_MAPPER_SHRUB2E: + case Commands::M_MAPPER_SHRUB3A: + case Commands::M_MAPPER_SHRUB3B: + case Commands::M_MAPPER_SHRUB3C: + case Commands::M_MAPPER_SHRUB3D: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.currentMapperCommand; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; - break; - case OpenSHC::Commands::M_MAPPER_PINE: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_PINE; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); + return; + case Commands::M_MAPPER_PINE: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = Commands::M_MAPPER_PINE; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; - break; - case OpenSHC::Commands::M_MAPPER_BIRCH: - DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = OpenSHC::Commands::M_MAPPER_BIRCH; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); + return; + case Commands::M_MAPPER_BIRCH: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = Commands::M_MAPPER_BIRCH; DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = 0; - commandType = OpenSHC::Commands::GCT_PLACE_TREE_OR_ROCKUnk; - break; - case OpenSHC::Commands::M_MAPPER_DEER: - case OpenSHC::Commands::M_MAPPER_LION: - case OpenSHC::Commands::M_MAPPER_RABBIT: - case OpenSHC::Commands::M_MAPPER_CAMEL: - case OpenSHC::Commands::M_MAPPER_CROW_SEAGULL: - case OpenSHC::Commands::M_MAPPER_SEAGULL: + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_PLACE_TREE_OR_ROCKUnk); + return; + case Commands::M_MAPPER_DEER: + case Commands::M_MAPPER_LION: + case Commands::M_MAPPER_RABBIT: + case Commands::M_MAPPER_CAMEL: + case Commands::M_MAPPER_CROW_SEAGULL: + case Commands::M_MAPPER_SEAGULL: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.currentMapperCommand; - commandType = OpenSHC::Commands::GCT_CREATE_ANIMAL; - break; - default: + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_CREATE_ANIMAL); + return; + case Commands::M_MAPPER_DUNES: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = Map::LogicHelpers::L2_STONES_OR_DRIVEN_SANDUnk; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); + return; + // stored as -128: the thick scrub's 128 as a signed char + case Commands::M_MAPPER_SCRUBGRASS: + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = x; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = y; + DAT_GameSynchronyState::instance.DAT_GameCommandParam2 = DAT_TileMapState::instance.editorActiveBrush; + DAT_GameSynchronyState::instance.DAT_GameCommandParam3 = Map::LogicHelpers::L_NONE; + DAT_GameSynchronyState::instance.DAT_GameCommandParam4 = (char)Map::LogicHelpers::L2_THICK_SCRUB; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + Commands::GCT_SET_TERRAIN); return; } - DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = _clickedX; - DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = _clickedY; - MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( - commandType); } } diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 4e77f25912..7ebb9de913 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14351,7 +14351,7 @@ SHC_3BB0A8C1_0x00443A2D | 0.0% | Pending SHC_3BB0A8C1_0x00443A2E | 0.0% | Pending -SHC_3BB0A8C1_0x00443A30 | 23.3% | gynt's draft, mechanical pass; register allocation and structure +SHC_3BB0A8C1_0x00443A30 | 94.7% | rewritten from the listing; left: one compare (ebx in the original) and the logic layer index's register (eax in the original) SHC_3BB0A8C1_0x004442A4 | 0.0% | Pending From dd901ee881b4be7390a23006ba29d5d2b8143f3d Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 10:06:22 +0100 Subject: [PATCH 81/85] drafts: move MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons to the ready PR LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons (0x00427810) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round35-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Fable 5.2 --- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 357 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 358 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp diff --git a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp deleted file mode 100644 index 8263d7eec2..0000000000 --- a/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp +++ /dev/null @@ -1,357 +0,0 @@ -#include "../LobbyMenu.func.hpp" - -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Helpers.func.hpp" -#include "OpenSHC/UI/Rendering.func.hpp" -#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" -#include "OpenSHC/AI/AITypeA.hpp" -#include "OpenSHC/DE/SHCDE/eTextSections.hpp" -#include "OpenSHC/Game/GameMode.hpp" -#include "OpenSHC/IO/Graphics/GmID.hpp" -#include "OpenSHC/Rendering/Colors/BGR24.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" -#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" - -#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_MouseState.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" -#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::Rendering::Colors::BGR24; - using OpenSHC::Text::TextAlignment; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x00427810 - void LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons(int param_1, ...) - { - int iVar3; - int iVar4; - int iVar6; - BOOLEnum BVar2 = MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)(); - if (BVar2) { - return; - } - if (param_1 == 0) { - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar4 = (iVar3 / 32) + 32; - BVar2 = FALSE; - int iVar10 = 19; - BGR24 BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; - TextAlignment TVar7 = OpenSHC::Text::TTA_LEFT; - iVar3 = DAT_ButtonX::instance; - iVar6 = DAT_ButtonY::instance; - // added by script: "Players" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 28), - iVar3, iVar6, TVar7, BVar9, iVar10, BVar2, iVar4); - if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar6 = (iVar3 / 32) + 32; - BVar2 = FALSE; - iVar10 = 19; - BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; - TVar7 = OpenSHC::Text::TTA_CENTER; - iVar4 = DAT_ButtonX::instance + 335; - iVar3 = DAT_ButtonY::instance; - // added by script: "Status" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 29), - iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); - } - if (!DAT_GameSynchronyState::instance.isHost) { - return; - } - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar6 = (iVar3 / 32) + 32; - BVar2 = FALSE; - iVar10 = 19; - BVar9 = OpenSHC::Rendering::Colors::COL_C2F0EB; - TVar7 = OpenSHC::Text::TTA_CENTER; - iVar4 = DAT_ButtonX::instance + 370; - iVar3 = DAT_ButtonY::instance; - // added by script: "Eject" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 91), - iVar4, iVar3, TVar7, BVar9, iVar10, BVar2, iVar6); - } - if (10 < param_1) { - iVar3 - = (int)*(char*)((int)DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer + param_1 + 26); - DAT_ButtonUnknownZero::instance = TRUE; - if (iVar3 < 1) { - return; - } - byte bVar1 = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]; - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if ('\0' < (char)bVar1) { - if ((bVar1 == 1) || (bVar1 == 3)) { - iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; - while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { - iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 204, - iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, - (iVar4 / 32) + 32); - iVar6 += 20; - } - } else { - iVar6 = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; - while (iVar6 < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350) { - iVar4 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 205, - iVar6, (int)(DAT_ButtonY::instance), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, - (iVar4 / 32) + 32); - iVar6 += 20; - } - } - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE - && 27 - < DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth - && DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth - < 350 - && (int)DAT_ButtonY::instance <= DAT_MouseState::instance.screenSpaceY - && DAT_MouseState::instance.screenSpaceY < (int)DAT_ButtonY::instance + 20) { - if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - iVar6 = 403; - } else if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { - iVar6 = 405; - } else { - iVar6 = 404; - } - // added by script: "Computer Opponent" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar6, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); - if ('\0' < (char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3]) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, - (int)((char)DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[iVar3] + 405), - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 145, - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, TRUE); - } - } - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, - OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 60, - OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); - } - } - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { - return; - } - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, - (int)(DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9 + 230), - (int)(DAT_ButtonX::instance + 10), (int)(DAT_ButtonY::instance + 5), 70, - OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); - return; - } - if (0 < param_1) { - iVar3 = (int)(char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[param_1]; - DAT_ButtonUnknownZero::instance = TRUE; - if (iVar3 < 1) { - return; - } - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER - && (iVar3 == DAT_GameSynchronyState::instance.DAT_HostPlayerSlotID - || ((DAT_GameSynchronyState::instance.isHost - && (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID))))) { - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 138, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 36, (int)(DAT_ButtonY::instance - 2), - (iVar6 / 32) + 32); - } - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 469, - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, (int)(DAT_ButtonY::instance), - (iVar6 / 32) + 32); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1) { - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, - (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 231 - + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 9), - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, - OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); - } - iVar6 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - DAT_TextManagerObject::instance.field_0x30 = 1; - if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, - DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, - OpenSHC::Rendering::Colors::COL_C2F0EB, 19, (iVar6 / 32) + 32); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, - DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 5), 280, - OpenSHC::Rendering::Colors::COL_7CAAAF, 19, (iVar6 / 32) + 32); - } - } - if (-10 < param_1) { - if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { - return; - } - iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1089092 - param_1)); - DAT_ButtonUnknownZero::instance = FALSE; - if (iVar3 < 1) { - return; - } - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { - if (iVar3 != DAT_GameSynchronyState::instance.currentPlayerSlotID) { - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } - DAT_CurrentButtonGmDataIndex::instance - = 207 - (uint)(DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[iVar3] != 0); - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( - (iVar3 / 32) + 32); - return; - } - if (DAT_GameSynchronyState::instance.currentAIArray[iVar3] == OpenSHC::AI::AITA_NULL) { - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - DAT_CurrentButtonGmDataIndex::instance = 627; - switch (DAT_GameSynchronyState::instance.currentAIArray[iVar3]) { - case OpenSHC::AI::AITA_RAT: - case OpenSHC::AI::AITA_SNAKE: - case OpenSHC::AI::AITA_PIG: - case OpenSHC::AI::AITA_WOLF: - case OpenSHC::AI::AITA_RICHARD: - case OpenSHC::AI::AITA_FREDERICK: - case OpenSHC::AI::AITA_PHILIPP: - case OpenSHC::AI::AITA_SHERIFF: - case OpenSHC::AI::AITA_MARSHAL: - case OpenSHC::AI::AITA_ABBOT: - DAT_CurrentButtonGmDataIndex::instance = 626; - } - DAT_ButtonX::instance -= 6; - DAT_ButtonY::instance -= 3; - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( - (iVar3 / 32) + 32); - } - if (param_1 < -199) { - DAT_ButtonUnknownZero::instance = FALSE; - if (!DAT_GameSynchronyState::instance.isHost) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - iVar3 = (int)*(char*)((int)DAT_GameSynchronyState::ptr + (1088892 - param_1)); - if (iVar3 < 1) { - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { - if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_GameSynchronyState::instance.slotActionPending[iVar3] != 0) { - DAT_ButtonUnknownZero::instance = FALSE; - return; - } - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( - (iVar3 / 32) + 32); - } - if (iVar3 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - BVar2 = MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3); - if (!BVar2) { - return; - } - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( - (iVar3 / 32) + 32); - } - if (param_1 == -101) { - DAT_ButtonUnknownZero::instance = TRUE; - if ((DAT_GameSynchronyState::instance.isHost) - && (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE)) { - for (int iVar3 = 1; iVar3 < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); - ++iVar3) { - if ((char)DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[iVar3] < '\x01') - goto LAB_00427f46; - } - } - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } else { - if (param_1 == -102) { - if (!DAT_GameSynchronyState::instance.isHost) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE - && DAT_MenuModalComposition1::instance.activeModalDialogID - != OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT - && DAT_MenuModalComposition1::instance.activeModalDialogID - != OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) - goto LAB_00427f4c; - } else { - if (param_1 != -103) - goto LAB_00427f4c; - if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { - DAT_ButtonUnknownZero::instance = TRUE; - } - } - LAB_00427f46: - DAT_ButtonUnknownZero::instance = FALSE; - } - LAB_00427f4c: - if (!DAT_GameSynchronyState::instance.isHost) { - return; - } - iVar3 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)((iVar3 / 32) + 32); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 7ebb9de913..723724ba0d 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6819,7 +6819,7 @@ SHC_3BB0A8C1_0x004276F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00427740 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00427810 | 58.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x00427810 | 0.0% | Pending SHC_3BB0A8C1_0x00427CB2 | 0.0% | Pending From 98ffddb86010abb1158721560a848c9e47e1ac63 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 10:33:46 +0100 Subject: [PATCH 82/85] drafts: move MenuItemRenderFunction_Allies_Main to the ready PR Allies::MenuItemRenderFunction_Allies_Main (0x004AC7A0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round36-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_Allies_Main.cpp | 438 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 439 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp diff --git a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp deleted file mode 100644 index 74127600a8..0000000000 --- a/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp +++ /dev/null @@ -1,438 +0,0 @@ -#include "../Allies.func.hpp" - -#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" -#include "OpenSHC/Text/TextManager.func.hpp" -#include "OpenSHC/UI/Rendering.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/WindowsHelper/Enums/BOOLEnum.hpp" - -#include "OpenSHC/Globals/COL_BLACK.hpp" -#include "OpenSHC/Globals/DAT_00df42b0.hpp" -#include "OpenSHC/Globals/DAT_00df51f0.hpp" -#include "OpenSHC/Globals/DAT_00df51f4.hpp" -#include "OpenSHC/Globals/DAT_AlliesCount.hpp" -#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonH.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonX.hpp" -#include "OpenSHC/Globals/DAT_ButtonY.hpp" -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_LastTeamMemberIndex.hpp" -#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" -#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" -#include "OpenSHC/Globals/DAT_SomeTeamMemberPlayerIDArray.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - using OpenSHC::DE::SHCDE::eTextSections; - using OpenSHC::WindowsHelper::Enums::BOOLEnum; - - // FUNCTION: STRONGHOLDCRUSADER 0x004AC7A0 - void Allies::MenuItemRenderFunction_Allies_Main(int param_1, ...) - { - BOOLEnum BVar1; - int iVar4; - int iVar5; - int iVar6; - int iVar7; - eTextSections textOffsetIndex; - int xParam; - int iVar2; - int iVar3; - if (param_1 == 100) { - return; - } - if (DAT_AlliesCount::instance < 1 && param_1 != -1) { - DAT_ButtonUnknownZero::instance = TRUE; - DAT_ButtonCurrentlyInteracting::instance = FALSE; - } - if ((param_1 == 110) || (param_1 == 111)) { - if (((DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .requestStateUnk - != 1) - || ((iVar3 = DAT_GameState::instance - .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerID_askerUnk, - DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] == -1 - || (iVar3 - != DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance])))) - && DAT_GameState::instance - .playerDataArray - [DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]] - .isNotNervousByEnemyTroopValue - == 0) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - DAT_ButtonUnknownZero::instance = FALSE; - MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); - } - if (param_1 == 200) { - if (DAT_00df51f4::instance == 0) { - return; - } - DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_MAP_GAME; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, DAT_00df51f0::instance, (int)(DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance), OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_B8EEFB, 0, - 18, FALSE); - DAT_TextManagerObject::instance.textSurfaceTarget = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - } - DAT_ButtonUnknownZero::instance = FALSE; - if (19 < (uint)param_1) { - MACRO_CALL( - OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); - if (!DAT_ButtonCurrentlyInteracting::instance) { - return; - } - if (param_1 == 20) { - DAT_00df51f4::instance = 1; - DAT_00df51f0::instance = 5; - } - if (param_1 == 21) { - DAT_00df51f4::instance = 1; - DAT_00df51f0::instance = 6; - } - if (param_1 != 22) { - return; - } - DAT_00df51f4::instance = 1; - DAT_00df51f0::instance = 7; - } - if (6 >= param_1) { - if (param_1 == 1) { - DAT_00df51f4::instance = 0; - } - iVar3 = param_1 - 1; - if (DAT_AlliesCount::instance <= iVar3) { - DAT_ButtonUnknownZero::instance = FALSE; - } - iVar6 = 0; - iVar2 = DAT_SomeTeamMemberPlayerIDArray::instance[iVar3]; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar2] == -1) { - iVar6 = DAT_GameSynchronyState::instance.currentAIArray[iVar2]; - } - if (iVar3 == DAT_LastTeamMemberIndex::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar2 + 546, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - if (iVar6 == 0) { - if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 539, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - } else if (DAT_GameCore::instance.lordIcons[iVar2] == 1) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 540, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - } else if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace, - DAT_TextureRenderCoreObject::ptr)( - iVar2 + 19, (int)(DAT_ButtonX::instance + 4), (int)(DAT_ButtonY::instance + 4)); - } - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar6 + 522, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - } - } else { - if (iVar6 == 0) { - if (DAT_GameCore::instance.lordIcons[iVar2] == 0) { - iVar6 = 539; - } else { - if (DAT_GameCore::instance.lordIcons[iVar2] != 1) { - if (0 < DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[iVar2 + 19]) { - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, - 541, (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk, - DAT_TextureRenderCoreObject::ptr)(iVar2 + 19, (int)(DAT_ButtonX::instance + 4), - (int)(DAT_ButtonY::instance + 4), 12); - } - goto LAB_004aca47; - } - iVar6 = 540; - } - } else { - iVar6 += 522; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar6, - (int)(DAT_ButtonX::instance), (int)(DAT_ButtonY::instance), 12); - return; - } - LAB_004aca47: - if (iVar3 == DAT_LastTeamMemberIndex::instance) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 514, - (int)(DAT_ButtonX::instance - 6), (int)(DAT_ButtonY::instance - 6), - OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 513, 0); - return; - } - iVar6 = 0; - if (iVar3 != DAT_LastTeamMemberIndex::instance) { - iVar6 = 8; - } - iVar3 - = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .requestedGoodsArray1Unk[iVar2]; - if (iVar3 == 7) { - iVar3 = 8; - } - if (-1 < iVar3 - 2) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar3 + 578, - (int)(DAT_ButtonX::instance + 60), (int)(DAT_ButtonY::instance - 12), - OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); - } - if (DAT_GameState::instance.playerDataArray[iVar2].isNotNervousByEnemyTroopValue != 0) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, - DAT_00df42b0::instance + 578, (int)(DAT_ButtonX::instance + 60), - (int)(DAT_ButtonY::instance + 60), OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, iVar6); - } - if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 1) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 576, - (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), - OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 577, iVar6); - } - if (DAT_GameState::instance.playerDataArray[iVar2].requestStateUnk == 2) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 604, - (int)(DAT_ButtonX::instance - 15), (int)(DAT_ButtonY::instance + 57), - OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 605, iVar6); - } - return; - } - if (param_1 != 10) { - DAT_ButtonUnknownZero::instance = FALSE; - } - iVar3 = DAT_ButtonX::instance; - iVar2 = DAT_ButtonY::instance; - iVar6 = 0; - if (0 < (int)DAT_ButtonH::instance) { - do { - if (iVar6 == 0) { - iVar5 = 1; - } else { - if (iVar6 == DAT_ButtonH::instance - 24) { - iVar5 = 13; - } else { - iVar5 = 7; - } - } - iVar7 = 0; - do { - iVar4 = iVar5; - if (iVar7 == 0) { - LAB_004acbeb: - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4, - iVar7 + iVar3, iVar2 + iVar6, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, iVar4 + 3, - 0); - } else { - if (iVar7 == 624) { - iVar4 = iVar5 + 2; - goto LAB_004acbeb; - return; - } - if (iVar5 != 7) { - iVar4 = iVar5 + 1; - goto LAB_004acbeb; - } - } - iVar7 += 24; - } while (iVar7 < 648); - iVar6 += 24; - } while (iVar6 < (int)DAT_ButtonH::instance); - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, - DAT_PencilRenderCore::ptr)(iVar3 + 24, iVar2 + 24, iVar3 + 623, DAT_ButtonH::instance - 25 + iVar2, 20); - iVar3 = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; - iVar2 = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3]; - if ((iVar2 == -1) - && (BVar1 = MACRO_CALL_MEMBER( - OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(iVar3), - !BVar1)) { - return; - } - iVar7 = DAT_ButtonY::instance; - iVar5 = DAT_ButtonX::instance; - iVar6 = DAT_ButtonX::instance + 24; - if (iVar2 == -1) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, - (int)(DAT_GameSynchronyState::instance.aiVariationArray[iVar3] + 103 - + DAT_GameSynchronyState::instance.currentAIArray[iVar3] * 8), - iVar6, (int)(DAT_ButtonY::instance + 24), OpenSHC::Text::TTA_LEFT, - (uint)(DAT_RenderingDefinedData::instance - .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), - 0, 17, FALSE); - } else { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText, DAT_TextManagerObject::ptr)( - DAT_GameSynchronyState::instance.DAT_PlayerNames[iVar3], iVar6, (int)(DAT_ButtonY::instance + 24), - OpenSHC::Text::TTA_LEFT, - (uint)(DAT_RenderingDefinedData::instance - .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[iVar3]]), - 0, 17, FALSE); - } - iVar2 = (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .requestedGoodsArray1Unk[iVar3]; - if (iVar2 == 7) { - iVar2 = 8; - } - iVar4 = iVar7 + 56; - int bVar8 = -1 < iVar2 - 2; - if (bVar8) { - // added by script: "Requests" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 12, iVar6, iVar4, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - MACRO_CALL_MEMBER( - OpenSHC::Text::TextManager_Func::renderLeftAlignedNumberToScreen, DAT_TextManagerObject::ptr)( - (int)DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .requestedGoodsArray2Unk[iVar3], - iVar5 + 29, iVar4, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, 1); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, iVar2 + 578, - DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6, iVar7 + 48, - OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, 0); - xParam = iVar5 + 69; - textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_GOODS; - } else { - iVar2 = 1; - xParam = iVar6; - textOffsetIndex = OpenSHC::DE::SHCDE::TEXT_ALLIES; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)(textOffsetIndex, - iVar2, xParam, iVar4, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, - (BOOLEnum)bVar8); - iVar2 = iVar7 + 88; - if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 0) { - // added by script: "No Orders" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 2, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - } else { - // added by script: "Orders:" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 16, iVar6, iVar2, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 1) { - // added by script: "Attack" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); - } - if (DAT_GameState::instance.playerDataArray[iVar3].requestStateUnk == 2) { - // added by script: "Defend" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 17, iVar5 + 29, iVar2, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); - } else { - iVar4 = DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk; - if (iVar4 == DAT_GameSynchronyState::instance.currentPlayerSlotID) { - // added by script: "You" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 18, iVar5 + 34, iVar2, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); - } else { - iVar2 = iVar7 + 76; - iVar5 = DAT_TextManagerObject::instance.currentXOffset_0x0 + 10 + iVar6; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar4] == -1) { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)( - OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, - (int)(DAT_GameSynchronyState::instance.currentAIArray - [DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk] - + 700), - iVar5, iVar2); - } else { - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)( - OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar4 + 718, iVar5, iVar2); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, - DAT_TextureRenderCoreObject::ptr)( - DAT_GameState::instance.playerDataArray[iVar3].requestedAttackTargetUnk + 19, iVar5 + 2, - iVar7 + 78); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, - DAT_PencilRenderCore::ptr)( - iVar5, iVar2, iVar5 + 35, iVar7 + 111, (ushort)(COL_BLACK::instance.shortValue)); - } - } - } - } - if (DAT_GameState::instance.playerDataArray[iVar3].isNotNervousByEnemyTroopValue != 0) { - // added by script: "Help Needed!" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 4, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - } - iVar2 = DAT_GameSynchronyState::instance.currentPlayerSlotID; - if (DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .requestStateUnk - != 1) { - return; - } - iVar5 = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] - .playerID_askerUnk; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar5] == -1) { - return; - } - if (iVar5 != iVar3) { - return; - } - // added by script: "Attack" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, iVar6, iVar7 + 120, OpenSHC::Text::TTA_LEFT, - OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); - iVar6 += DAT_TextManagerObject::instance.currentXOffset_0x0 + 10; - iVar3 = DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk; - iVar5 = iVar7 + 115; - if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[iVar3] != -1) { - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( - OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, - DAT_TextureRenderCoreObject::ptr)( - DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk + 19, iVar6 + 2, - iVar7 + 117); - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( - iVar6, iVar5, iVar6 + 35, iVar7 + 150, (ushort)(COL_BLACK::instance.shortValue)); - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, iVar3 + 718, iVar6, iVar5); - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, - (int)(DAT_GameSynchronyState::instance - .currentAIArray[DAT_GameState::instance.playerDataArray[iVar2].requestedAttackTargetUnk] - + 700), - iVar6, iVar5); - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 723724ba0d..44289c4494 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -25795,7 +25795,7 @@ SHC_3BB0A8C1_0x004AC650 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AC6E0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004AC7A0 | 52.8% | gynt's draft, mechanical pass; structure +SHC_3BB0A8C1_0x004AC7A0 | 0.0% | Pending SHC_3BB0A8C1_0x004AD110 | 0.0% | Pending From b2502134f0edd455c6a89eb26c762b72d78192d2 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 10:53:46 +0100 Subject: [PATCH 83/85] drafts: move MenuItemRenderFunction_General_AdvancedGameOptions to the ready PR General::MenuItemRenderFunction_General_AdvancedGameOptions (0x00428AC0) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34 and goes out with the ready branch reimpl/UI-B-round37-100. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...erFunction_General_AdvancedGameOptions.cpp | 424 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 425 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp diff --git a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp b/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp deleted file mode 100644 index b6a8ef527c..0000000000 --- a/src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_AdvancedGameOptions.cpp +++ /dev/null @@ -1,424 +0,0 @@ -#include "../General.func.hpp" - -#include "OpenSHC/Text/TextManager.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/Game/GameMode.hpp" -#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" -#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" -#include "OpenSHC/Text/TextAlignment.hpp" -#include "OpenSHC/UI/Enums/MenuModalType.hpp" - -#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" -#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" -#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" -#include "OpenSHC/Globals/DAT_ButtonUnknownZero.hpp" -#include "OpenSHC/Globals/DAT_ButtonW.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_MenuModalComposition1.hpp" -#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" -#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // The 23 `((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 0x20` below are each a signed - // `iVar1 / 32`, and undiv.py rewrites them, but measured: raw match 40.4% -> 24.6%. The - // opcodes are unchanged - the division frees a register, MSVC then picks ebx where the - // original uses edi, and every instruction after it is renamed. Normalized match rises - // 41.1% -> 48.1%, so the division is arguably the closer stream; it is kept in the shift - // form only because the raw percentage is the gate. Retry together with whatever fixes - // this function's register allocation. - // FUNCTION: STRONGHOLDCRUSADER 0x00428AC0 - void General::MenuItemRenderFunction_General_AdvancedGameOptions(int param_1, ...) - { - int iVar1; - uint _color; - int iVar2; - if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_LOAD_MAP - || DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_SEND_MAP_TO - || DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_RECEIVE_MAP_FROM) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_SKIRMISH_PLAY_OPTIONS) { - if (param_1 != -1000 && param_1 != -10 && param_1 != -11 && param_1 != -12 && param_1 != -13 - && param_1 != -14 && param_1 != 99 && param_1 != 100 && param_1 != 83 && param_1 != 109 - && param_1 != 82 && param_1 != 94) { - return; - } - } else { - if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_ROUNDTABLE) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_BASIC_AI_LORD_SELECT) { - return; - } - if (DAT_MenuModalComposition1::instance.activeModalDialogID - == OpenSHC::UI::Enums::MMT_EXTENDED_AI_LORD_SELECT) { - return; - } - } - if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { - if (param_1 == 93) { - return; - } - if (param_1 == 31) { - return; - } - } - if ((param_1 == 103) - && (DAT_ButtonUnknownZero::instance = 0, - DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (!DAT_GameSynchronyState::instance.isHost) { - if (param_1 == 103) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (param_1 == 93) { - return; - } - } - if (param_1 == -1) { - DAT_ButtonUnknownZero::instance = TRUE; - return; - } - if (param_1 != 103) { - if ((!DAT_ButtonCurrentlyInteracting::instance) || (!DAT_GameSynchronyState::instance.isHost)) { - MACRO_CALL_MEMBER( - OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderNonInteractingButtonBackground, - AlphaAndButtonSurfaceObj::ptr)(DAT_ButtonBackgroundBlendStrength::instance); - _color = OpenSHC::Rendering::Colors::COL_C2F0EB; - } else { - _color = OpenSHC::Rendering::Colors::COL_CCFAFF; - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, - AlphaAndButtonSurfaceObj::ptr)( - DAT_ButtonBackgroundBlendStrength::instance, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); - } - } - if (param_1 == 31) { - iVar2 = DAT_GameSynchronyState::instance.skirmishTechLevel / 2; - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "Tech Level" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 85, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "Early" "Middle" "Late" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar2 + 79, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 36) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "Win: Regicide" / "Win: 10000 Gold" / "Win: 3" / "Win: 4" / "Win: 5" / .... - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, - (int)(DAT_GameSynchronyState::instance.skirmishWinCondition + 36), - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 83) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "Troops" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 86, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - iVar1 = 83; - // "Free" - if (DAT_GameSynchronyState::instance.skirmishTroopsCostGold != 0) { - // "Cost Gold" - iVar1 = 84; - } - iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 109) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // Fog of War - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 109, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - if (DAT_GameState::instance.mapAndTime.skirmishFogOfWar == 0) { - // OFF - iVar1 = 95; - } else { - // Please Wait - iVar1 = (DAT_GameState::instance.mapAndTime.skirmishFogOfWar != 1) + 109; - } - iVar2 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, iVar1, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar2 + (iVar2 >> 0x1f & 0x1fU)) >> 5) + 32); - return; - } - if (param_1 == -1000) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, 17, - (int)((int)DAT_ButtonW::instance / 2 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_CENTER, _color, 18, FALSE, ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 103) { - MACRO_CALL(OpenSHC::UI::MenuItems::General_Func:: - MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface)(); - } - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; - if (param_1 == -10) { - // No Cow Throwing - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 5, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); - iVar1 = DAT_GameSynchronyState::instance.skirmishNoCowThrowing; - LAB_00428ffd: - if (iVar1 != 0) { - iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; - iVar2 = 206; - goto LAB_00429039; - } - } else { - if (param_1 == -11) { - // "No Dogs" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 6, - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, - _color, 18, FALSE, iVar1); - iVar1 = DAT_GameSynchronyState::instance.skirmishNoDogs; - LAB_00429086: - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (iVar1 == 0) { - iVar1 = 208; - } else { - iVar1 = 206; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, - (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - if (param_1 == -13) { - // "Extreme mode" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 13, - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, - _color, 18, FALSE, iVar1); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; - if (DAT_GameSynchronyState::instance.skirmishExtremeMode == 0) { - iVar1 = 208; - } else { - iVar1 = 206; - } - MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, - DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, iVar1, - (int)(DAT_ButtonW::instance - 50 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance)); - DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue - = OpenSHC::Rendering::Enums::RT_MAP_GAME; - } - if (param_1 != -14) { - if (param_1 != 99) { - if (param_1 == -12) { - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 7, - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 0) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 1) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 2) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 3) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting == 4) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 8, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishNoRushSetting != 5) { - return; - } - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - // "1 Hour" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 9, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, param_1, - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); - if (param_1 == 14) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, - DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishStartGold, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 15) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, - DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishDefaultPopularity, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 82) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, - DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.skirmishGameSpeedLevel, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 == 94) { - if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 0) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 95, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 5) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 96, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes == 10) { - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 97, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (DAT_GameSynchronyState::instance.skirmishAutoSaveEveryMinutes != 20) { - return; - } - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 98, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, - ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32); - } - if (param_1 != 100) { - return; - } - iVar1 = (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32; - iVar1 = ((int)(iVar1 + (iVar1 >> 0x1f & 0x1fU)) >> 5) + 32; - // "Alliances" - if (DAT_GameSynchronyState::instance.skirmishAlliances == 0) { - // "Anytime" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 101, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_RIGHT, - OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); - } - // "Start only" - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText2, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 102, - (int)(DAT_ButtonW::instance - 20 + DAT_ButtonX::instance), (int)(DAT_ButtonY::instance + 7), - OpenSHC::Text::TTA_RIGHT, OpenSHC::Rendering::Colors::COL_B8E6F5, 0, 18, FALSE, iVar1); - return; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, - DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 99, - (int)(DAT_ButtonX::instance + 20), (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, - _color, 18, FALSE, iVar1); - iVar1 = DAT_GameSynchronyState::instance.skirmishStrongWalls; - goto LAB_00429086; - } - MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextFromTextGroup, DAT_TextManagerObject::ptr)( - OpenSHC::DE::SHCDE::TEXT_SKIRMISH_MISC, 14, (int)(DAT_ButtonX::instance + 20), - (int)(DAT_ButtonY::instance + 7), OpenSHC::Text::TTA_LEFT, _color, 18, FALSE, iVar1); - iVar1 = DAT_GameSynchronyState::instance.skirmishExtremeMode; - if (DAT_GameSynchronyState::instance.skirmishExtremeMode2 != 0) - goto LAB_00428ffd; - } - iVar2 = 208; - iVar1 = DAT_ButtonW::instance - 50 + DAT_ButtonX::instance; - LAB_00429039: - 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_ICONS3, iVar2, iVar1, (int)(DAT_ButtonY::instance)); - 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 44289c4494..def944a8d1 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -6889,7 +6889,7 @@ SHC_3BB0A8C1_0x00428A50 | 0.0% | Pending SHC_3BB0A8C1_0x00428A60 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00428AC0 | 42.5% | gynt's draft, mechanical pass; register allocation and structure +SHC_3BB0A8C1_0x00428AC0 | 0.0% | Pending SHC_3BB0A8C1_0x00429630 | 100.0% | Reimplemented From cc33a2bc193b003219c1cec4e17a1db3af81a762 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 13:49:28 +0100 Subject: [PATCH 84/85] reimplement: SHC_3BB0A8C1_0x00443A30 99.5% the orientation is read in both arms of the click test MapEditorLandscaping::MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback, on top of 356f8247d (our rewrite from the listing with gynt's draft; his draft: 093895284 at 23.29% on his fork's reimpl/UI-MenuItems, and the newest commit on the file on his reimpl/UI-MenuItems-development is 8725ec523): the orientation is no longer read in front of the second leftClickStart test but in each arm of it. Read in front of the test, it took ebx, so the test compared with an immediate 0; read in the arms, the test compares with ebx, the zero register, as the original's does (0x00443C1C). The code does the same: in both arms the field is read before anything there can change it. 94.7% to 99.5% (66.1% to 89.2% normalized). Our exact listing compare (operands, jump landings and the jump table) still counts 8 differing lines, but other ones: the compare is the original's length again, so every jump over it and every jump table entry after it lands where the original's does, and reccmp's diff goes from 82 lines to 8. Left, the 8 lines of that compare: - The compiler loads the orientation into ebx after the tile's y and x (0x00443C3A); the original loads it second, after the snap mode (0x00443C28). The load waits for the compare that reads ebx and then goes behind every load that was ready before it. Not moved by: the reads in the arms in all six orders, other orders of the reads in front of the test, the tile's y and x or the snap mode read in the arms too, different orders in the two arms, or the test negated with its arms swapped. - The logic layer's index goes through edx where the original has eax (0x00443C5B, 0x00443C62 and 0x00443C6E), as before. Not moved by: the index or the logic value in a local, the valid test's result in a local, or x and y given their values elsewhere. Measured in a narrow build on main 3458fea34 of this file as committed and the nine finished functions it calls, struct resolvers and their resolvers on, as for 356f8247d. No all-on build was run for this commit. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...ionHandler_MapEditorLandscaping_QueueCommandCallback.cpp | 6 +++++- status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp index ca645081f7..409cb8e3d2 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorLandscaping/MenuItemActionHandler_MapEditorLandscaping_QueueCommandCallback.cpp @@ -128,11 +128,13 @@ namespace UI { OpenSHC::Rendering::ViewportRenderState_Func::setupMouseTileXY, DAT_ViewportRenderState::ptr)(); // read in this order (another order loses the match); x and y below are the snapped tile int const snap = DAT_TileMapState::instance.editorSnapToMode; - Map::Enums::MapOrientationInt const orientation = DAT_TileMapState::instance.mapOrientation; + // read in each arm of the click test (read in front of it, the match drops) + Map::Enums::MapOrientationInt orientation; int const tileY = DAT_ViewportRenderState::instance.viewportState.mouseTileY; int const tileX = DAT_ViewportRenderState::instance.viewportState.mouseTileX; // the click starts: its tile is kept, and whether it is on sea or on the unnamed 0x40 kind if (DAT_MouseState::instance.leftClickStart) { + orientation = DAT_TileMapState::instance.mapOrientation; DAT_TileMapState::instance.DAT_ClickedTileX = tileX; DAT_TileMapState::instance.DAT_ClickedTileY = tileY; if (MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::xyAreValid, @@ -144,6 +146,8 @@ namespace UI { DAT_TileMapState::instance.editorAffectType = 1; } } + } else { + orientation = DAT_TileMapState::instance.mapOrientation; } // copies: with one pair of variables every case below is merged into the last one int x = tileX; diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index def944a8d1..1d9fc18b1f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -14351,7 +14351,7 @@ SHC_3BB0A8C1_0x00443A2D | 0.0% | Pending SHC_3BB0A8C1_0x00443A2E | 0.0% | Pending -SHC_3BB0A8C1_0x00443A30 | 94.7% | rewritten from the listing; left: one compare (ebx in the original) and the logic layer index's register (eax in the original) +SHC_3BB0A8C1_0x00443A30 | 99.5% | rewritten from the listing; left: the orientation is loaded after the tile (second in the original) and the logic layer index's register (eax in the original) SHC_3BB0A8C1_0x004442A4 | 0.0% | Pending From 86e650ba7751760e2bad7b34ffb106acac8b83eb Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 22 Nov 2026 14:47:47 +0100 Subject: [PATCH 85/85] drafts: move the scribe's animation step to the ready PR InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange (0x00433370) reaches reccmp 100.0 (normalized 100.0) on main 3458fea34, off the /GL list and on it, and goes out with the ready branch reimpl/UI-A-scribe-100 (f9fabb0343). The last difference, the zero in ebp, went away with the animation phase written as the global itself at each use instead of a local copied from it and stored back. Its file leaves this draft and its status line goes back to main's. Co-Authored-By: Claude Opus 5.5 --- ...nGameMenu_ProcessScribeAnimationChange.cpp | 128 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 129 deletions(-) delete mode 100644 src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp diff --git a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp b/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp deleted file mode 100644 index 4219609fe6..0000000000 --- a/src/OpenSHC/UI/MenuItems/InGameMenu/MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "../InGameMenu.func.hpp" - -#include "OpenSHC/Game/GameMode2.hpp" - -#include "OpenSHC/Globals/DAT_GameCore.hpp" -#include "OpenSHC/Globals/DAT_GameState.hpp" -#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" -#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" - -namespace OpenSHC { -namespace UI { - namespace MenuItems { - - // FUNCTION: STRONGHOLDCRUSADER 0x00433370 - void InGameMenu::MenuItemActionHandler_InGameMenu_ProcessScribeAnimationChange(int button, ...) - { - if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR - || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT) { - return; - } - int const slot = DAT_GameSynchronyState::instance.currentPlayerSlotID; - int phase; - int frame; - if (DAT_GameCore::instance.taxesSettingUnk != 0) { - DWORD const now = timeGetTime(); - if ((int)(now - DAT_GameCore::instance.taxestimeUnk) < 60) { - return; - } - phase = DAT_GameCore::instance.scribeAnimationPhase; - DAT_GameCore::instance.taxestimeUnk = now; - switch (phase) { - case 2: { - int const target = (100 - DAT_GameState::instance.playerDataArray[slot].popularity / 100) / 10 + 1; - frame = DAT_GameCore::instance.scribeAnimationFrame; - if (frame > 11) { - frame = 6; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else if (frame > target) { - --frame; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else if (frame < target) { - ++frame; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else { - DAT_GameCore::instance.taxesSettingUnk = 0; - } - break; - } - case 1: - ++DAT_GameCore::instance.scribeAnimationFrame2; - frame = DAT_GameCore::instance.scribeAnimationFrame; - break; - case 0: - frame = DAT_GameCore::instance.scribeAnimationFrame; - if (frame < 6) { - ++frame; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else if (frame > 6) { - --frame; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else { - phase = 1; - DAT_GameCore::instance.scribeAnimationPhase = phase; - } - break; - default: - frame = DAT_GameCore::instance.scribeAnimationFrame; - break; - } - } else { - phase = DAT_GameCore::instance.scribeAnimationPhase; - frame = DAT_GameCore::instance.scribeAnimationFrame; - } - switch (DAT_GameCore::instance.taxesSettingUnk) { - case 0: - frame = (100 - DAT_GameState::instance.playerDataArray[slot].popularity / 100) / 10 + 1; - DAT_GameCore::instance.scribeAnimationFrame = frame; - break; - case 1: - if (phase == 1) { - if (DAT_RenderingDefinedData::instance - .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2] - != 0) { - frame = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames1[DAT_GameCore::instance.scribeAnimationFrame2]; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else { - DAT_GameCore::instance.taxesSettingUnk = 0; - } - } - break; - case 2: - if (phase == 1) { - if (DAT_RenderingDefinedData::instance - .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2] - != 0) { - frame = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames2[DAT_GameCore::instance.scribeAnimationFrame2]; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else { - DAT_GameCore::instance.taxesSettingUnk = 0; - } - } - break; - case 3: - if (phase == 1) { - if (DAT_RenderingDefinedData::instance - .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2] - != 0) { - frame = DAT_RenderingDefinedData::instance - .ScribeAnimationFrames3[DAT_GameCore::instance.scribeAnimationFrame2]; - DAT_GameCore::instance.scribeAnimationFrame = frame; - } else { - DAT_GameCore::instance.taxesSettingUnk = 0; - } - } - break; - } - if (DAT_GameCore::instance.scribeAnimationFrameCopy != frame - || DAT_GameState::instance.mapAndTime.monthChanged != 0) { - DAT_GameCore::instance.countdown = 1; - DAT_GameCore::instance.scribeAnimationFrameCopy = frame; - } - } - - } -} -} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 1d9fc18b1f..ab631e43ef 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -11089,7 +11089,7 @@ SHC_3BB0A8C1_0x00433230 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00433260 | 0.0% | Pending -SHC_3BB0A8C1_0x00433370 | 93.3% | only the zero's register differs: ebp where the original has ebx +SHC_3BB0A8C1_0x00433370 | 0.0% | Pending SHC_3BB0A8C1_0x00433550 | 0.0% | Pending