From ebb035bb12bb00cde1559621aa4e14a90feb6810 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 04:18:01 +0100 Subject: [PATCH 1/3] headers: MenuItemActionHandler_MapEditorProperties_MapDescriptionBox takes (int param_1, ...) MenuItemActionHandler_MapEditorProperties_MainButtons (0x00443070) calls the handler at 0x0042EDF0 with one argument and cleans the stack itself (push of the 0 it keeps in ebp, call, add esp, 4, from 0x004436D8). The handler is a menu item's action handler: its address stands in the menu item at 0x005EE8FC, two dwords in front of that item's render function 0x0042EBC0, and nowhere else in the image. So it gets the parameter list that MainButtons' handler and the two render functions of this header have, (int param_1, ...), and not (). Changed: the declaration in MapEditorProperties.hpp and the resolver's type in MapEditorProperties.func.hpp. The definition's signature follows in the next commit; the branch builds from there on. Co-Authored-By: Claude Fable 5.2 --- src/OpenSHC/UI/MenuItems/MapEditorProperties.func.hpp | 2 +- src/OpenSHC/UI/MenuItems/MapEditorProperties.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties.func.hpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties.func.hpp index 6c39b4b330..a0f5f6cad7 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties.func.hpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties.func.hpp @@ -26,7 +26,7 @@ namespace UI { MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox) MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox; - MACRO_FUNCTION_RESOLVER(void(__cdecl*)(), false, Address::SHC_3BB0A8C1_0x0042EDF0, + MACRO_FUNCTION_RESOLVER(void(__cdecl*)(int param_1, ...), false, Address::SHC_3BB0A8C1_0x0042EDF0, &OpenSHC::UI::MenuItems::MapEditorProperties:: MenuItemActionHandler_MapEditorProperties_MapDescriptionBox) MenuItemActionHandler_MapEditorProperties_MapDescriptionBox; diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties.hpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties.hpp index 999e89bd7f..5e99652177 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties.hpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties.hpp @@ -20,7 +20,7 @@ namespace UI { void __cdecl MenuItemRenderFunction_MapEditorProperties_MapDescriptionBox(int param_1, ...); - void __cdecl MenuItemActionHandler_MapEditorProperties_MapDescriptionBox(); + void __cdecl MenuItemActionHandler_MapEditorProperties_MapDescriptionBox(int param_1, ...); void __cdecl MenuItemActionHandler_MapEditorProperties_MapDescriptionScrollbar( int param_1, int param_2, int* minValue, int* maxValue, int* currentValue); From c94dc3a45124e55ba586ad69a02f08ce3b57eedd Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 04:18:01 +0100 Subject: [PATCH 2/3] fix: MenuItemActionHandler_MapEditorProperties_MapDescriptionBox's definition follows its header The header commit before this one gives the handler at 0x0042EDF0 the parameter list (int param_1, ...). The definition takes (int unused, ...) now. The handler does not read the parameter and is cdecl, so its code is unchanged: reccmp 100.0 (normalized 100.0) as before. Co-Authored-By: Claude Fable 5.2 --- ...uItemActionHandler_MapEditorProperties_MapDescriptionBox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MapDescriptionBox.cpp b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MapDescriptionBox.cpp index 07afff3462..67101d6313 100644 --- a/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MapDescriptionBox.cpp +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MapDescriptionBox.cpp @@ -18,7 +18,7 @@ namespace UI { namespace MenuItems { // FUNCTION: STRONGHOLDCRUSADER 0x0042EDF0 - void MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MapDescriptionBox() + void MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MapDescriptionBox(int unused, ...) { if (!DAT_GameCore::instance.U2_mapType_singleOrMulti || !DAT_GameCore::instance.mapLoadedForEditor || DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU From 8f6c2821529f1b6df64afe8917977cbdc321b19f Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 04:18:01 +0100 Subject: [PATCH 3/3] reimplement: SHC_3BB0A8C1_0x00443070 100.0% Reimplemented MapEditorProperties::MenuItemActionHandler_MapEditorProperties_MainButtons, rewritten from the original's listing. gynt's draft: 39d2799f3 at 48.43% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems-development, whose status line records 48.4%; the newest commit on the file there is dd1a7c48c. Our draft (59372c9e0, then d79d89dc8 and 6202bb00f; 53.2% in the draft PR #328) was his code with a mechanical pass. The function handles the buttons of the map editor's properties view: two early exits while a dialog is open, then one switch over the button's parameter (-6 to 31), dispatched through the byte table at 0x004437B4 and the jump table at 0x00443778. Button 31 starts a game on the edited map and copies the scenario's settings into the game state; that case is two thirds of the function. What decided the match: - The cases stand in the original's order: 2, 3, 4, 5, 6, 31, 9, 25, -1 to -6. The draft had 9 and 25 in front of 31 and the negative ones from -6 to -1. - The seven euro and seven mercenary recruitable values are copied by one loop over the index with both copies in it; the compiler unrolls it completely. Pair by pair is the order that gives the original's registers: the first four euro values end in eax, ecx, edx and esi and stay there for the tests behind the loop, the first two mercenary values go through edx, the third through esi and everything later through edi. A loop for each array gives other registers (quick_diff 0.9900 -> 0.9576). The draft had the twenty short copies in the order of the original's instructions, which the compiler does not keep. - The six weapon flags are copied in front of that loop, in the scenario's order (behind it: 0.9712 -> 0.9262 with the copies written out). - The nine euroRecruitableCopy flags are cleared in front of the loop and set behind it by seven ifs. Cleared behind the loop, the first four copies' stores move in front of the clears (0.9900 -> 0.9800). The draft set them by `= (int)(x != 0)`. - The starting goods are copied by a loop over the 25 entries, which the compiler turns into the original's rep movsd. With memcpy it reads the next statement's value (startGoods[RT_PARTIALPITCH]) from the scenario's array and loads it before the copy, where the original reads the copied entry afterwards (0.9900 -> 0.9875). - The twenty siege unit counts are copied one by one in ascending order; the original's instructions run in threes backwards, which is the compiler's scheduling of exactly that order. - Button 6's tab test is two ifs: the feature tab becomes its multiplayer version on a multiplayer map and the multiplayer version becomes the feature tab on a single-player one. The draft's gotos compile to the same listing (measured on this text). - Button 9 calls the description box's handler with 0, which the two commits before this one allow. Names: the landscaping tab's 237 and 239 are Commands::M_MAPPER_SUB_MODE_FEATURE and M_MAPPER_SUB_MODE_FEATURE_MP, written through buildMenuTab (main's MenuItemActionHandler_MapEditorLandscaping_CategoryButtons does the first half of this swap, on its parameter, with the same names); the build menu's 10 is UI::Enums::BMTT_CASTLE (the draft's BASMTT_HUNTERSHUT has the same value in the other enum of the union); the text index 9 is OpenSHC::Text::TAIT_NINE__FILTER_B as main stores it into the same field; startGoods' entries 7 and 8 are Game::Resources::RT_PITCH and RT_PARTIALPITCH, as main indexes SEC_StartingResources; INT_00b960e4 takes TRUE and FALSE as main writes it. The parameter is called button and the case labels stay numbers, with a comment for each button or pair of buttons, as in main's MenuItemRenderFunction_MapEditorProperties_MainButtons for the same buttons. The description's scroll-down is written flat, as main's SingleplayerMapChoice handler has the same scroll; nested it compiles to the same code. quick_diff ends at 0.9900 with four hunks that are its own printing (three stores into TileMapState fields shown as [G]+G, the operands of rep movsd). Narrow build with those two commits and the two finished callees the function refers to in the sources list, their resolvers on (the description box's handler, and RenderLoadAndSaveBar, whose address it stores): reccmp 100.0, normalized 100.0, and both callees stay at 100.0. Without RenderLoadAndSaveBar's file in the list the stored address shows as a trampoline on our side: one line, 99.8 (95.2 normalized). Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- ...andler_MapEditorProperties_MainButtons.cpp | 361 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 362 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..5c0324a01d --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/MapEditorProperties/MenuItemActionHandler_MapEditorProperties_MainButtons.cpp @@ -0,0 +1,361 @@ +#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/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Map/MapType2.hpp" +#include "OpenSHC/Text/TextArrayIndexType.hpp" +#include "OpenSHC/UI/Enums/BuildMenuTabType.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_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 button, ...) + { + // nothing while a dialog is open + if (DAT_MenuTextInputState::instance.currentModalDialog != UI::Enums::MMT_NO_MENU) { + return; + } + if (DAT_MenuModalComposition1::instance.activeModalDialogID != UI::Enums::MMT_NONE) { + return; + } + DAT_TileMapState::instance.unitPlacementCount = 1; + switch (button) { + case 2: + // load a map + DAT_MenuTextInputState::instance.field_0x9c = 1; + MACRO_CALL_MEMBER(UI::MenuTextInputState_Func::activateLoadOrSaveMapUI, DAT_MenuTextInputState::ptr)( + UI::Enums::MMT_LOAD_MAP); + return; + case 3: + // save the map; a multiplayer map only once one is loaded in the editor + if (DAT_GameCore::instance.U2_mapType_singleOrMulti != 0 + && !DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + 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)( + UI::Enums::MMT_SAVE_MAP); + INT_00b960e4::instance = TRUE; + return; + case 4: + // new map + INT_00b960e4::instance = FALSE; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_NEW_MAP_MAPTYPE, 0); + return; + case 5: + // "Main Menu": through the quit dialog once editing has started + 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: + // edit the landscape + if (!DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + INT_00b95f68::instance = TRUE; + 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; + // the feature tab has a multiplayer version; the one that fits the map is opened + if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab + == Commands::M_MAPPER_SUB_MODE_FEATURE + && DAT_GameCore::instance.U2_mapType_singleOrMulti >= 1) { + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab + = Commands::M_MAPPER_SUB_MODE_FEATURE_MP; + } + if (DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab + == Commands::M_MAPPER_SUB_MODE_FEATURE_MP + && DAT_GameCore::instance.U2_mapType_singleOrMulti == 0) { + DAT_GameCore::instance.landscapingmenuMenuTabToSwitchTo.buildMenuTab + = Commands::M_MAPPER_SUB_MODE_FEATURE; + } + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_MAP_EDITOR_LANDSCAPING, 0); + return; + case 31: + // play the map: back it up, then start a game from the scenario's settings + if (!DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + 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); + // "auto_backup_map.map" + 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 = OpenSHC::Text::TAIT_NINE__FILTER_B; + 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 (DAT_TroopValueState::instance.attackInfo.inv_count >= 50) { + 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); + DAT_TroopValueState::instance.attackInfo + .attackWavePlayerIDArray[DAT_TroopValueState::instance.attackInfo.inv_count] = 2; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][0] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[0]; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][1] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[1]; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][2] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[3]; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][3] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[2]; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][4] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[4]; + DAT_TroopValueState::instance.attackInfo + .someSinglePlayerScore[DAT_TroopValueState::instance.attackInfo.inv_count][8] + += DAT_MapPropertiesState::instance.SEC_Section1067.siegeEngineCounts[5]; + // a loop (with memcpy the compiler reads the next statement's value from the scenario's array) + for (int i = 0; i < countof(DAT_GameState::instance.mapAndTime.startGoods); ++i) { + DAT_GameState::instance.mapAndTime.startGoods[i] + = DAT_MapPropertiesState::instance.SEC_StartingResources[i]; + } + DAT_GameState::instance.mapAndTime.startGoods[Game::Resources::RT_PITCH] + = DAT_GameState::instance.mapAndTime.startGoods[Game::Resources::RT_PARTIALPITCH]; + DAT_GameState::instance.mapAndTime.startGoods[Game::Resources::RT_PARTIALPITCH] = 0; + DAT_GameState::instance.mapAndTime.siegeInformation.archers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[0]; + DAT_GameState::instance.mapAndTime.siegeInformation.crossbowmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[1]; + DAT_GameState::instance.mapAndTime.siegeInformation.spearmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[2]; + DAT_GameState::instance.mapAndTime.siegeInformation.pikemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[3]; + DAT_GameState::instance.mapAndTime.siegeInformation.macemen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[4]; + DAT_GameState::instance.mapAndTime.siegeInformation.swordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[5]; + DAT_GameState::instance.mapAndTime.siegeInformation.knights + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[6]; + DAT_GameState::instance.mapAndTime.siegeInformation.laddermen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[7]; + DAT_GameState::instance.mapAndTime.siegeInformation.engineers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[8]; + DAT_GameState::instance.mapAndTime.siegeInformation.monks + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[9]; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[10]; + DAT_GameState::instance.mapAndTime.siegeInformation.slaves + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[11]; + DAT_GameState::instance.mapAndTime.siegeInformation.slingers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[12]; + DAT_GameState::instance.mapAndTime.siegeInformation.assassins + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[13]; + DAT_GameState::instance.mapAndTime.siegeInformation.horseArchers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[14]; + DAT_GameState::instance.mapAndTime.siegeInformation.arabianSwordsmen + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[15]; + DAT_GameState::instance.mapAndTime.siegeInformation.fireThrowers + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[16]; + DAT_GameState::instance.mapAndTime.siegeInformation.fireBallistas + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[17]; + DAT_GameState::instance.mapAndTime.siegeInformation.field_0x48 + = DAT_MapPropertiesState::instance.SEC_SiegeInformation[18]; + 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)(); + // in front of the recruitable loop (behind it the loop's copies take other registers) + DAT_GameCore::instance.xbowProducible_logic = DAT_MapPropertiesState::instance.SEC_XbowProducible_save; + DAT_GameCore::instance.bowProducible_logic = DAT_MapPropertiesState::instance.SEC_BowProducible_save; + DAT_GameCore::instance.pikeProducible_logic = DAT_MapPropertiesState::instance.SEC_PikeProducible_save; + DAT_GameCore::instance.spearProducible_logic + = DAT_MapPropertiesState::instance.SEC_SpearProducible_save; + DAT_GameCore::instance.swordProducible_logic + = DAT_MapPropertiesState::instance.SEC_SwordProducible_save; + DAT_GameCore::instance.maceProducible_logic = DAT_MapPropertiesState::instance.SEC_MaceProducible_save; + // cleared in front of the loop (behind it the first four copies' stores move in front of these) + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_0 = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_b = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_2 = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_b = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_4 = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 0; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_c = 0; + // one loop for both (a loop each changes the registers) + for (int i = 0; i < countof(DAT_GameState::instance.mapAndTime.euroRecruitable); ++i) { + DAT_GameState::instance.mapAndTime.euroRecruitable[i] + = DAT_MapPropertiesState::instance.barracksRecruitability.array.barracksRecruitability[i]; + DAT_GameState::instance.mapAndTime.mercRecruitable[i] + = DAT_MapPropertiesState::instance.SEC_MercRecruitable[i]; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[0]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_0 = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[1]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_b = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[2]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_2 = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[3]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_b = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[4]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_4 = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_1_a = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[5]) { + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_6_a = 1; + DAT_GameState::instance.mapAndTime.euroRecruitableCopy_index_3_a_and_6_b = 1; + } + if (DAT_GameState::instance.mapAndTime.euroRecruitable[6]) { + 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 = 1; + } + 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.buildMenuTab = UI::Enums::BMTT_CASTLE; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_BUILD_MENU, 0); + return; + case 9: + // the description's "Edit" + MACRO_CALL(MapEditorProperties_Func::MenuItemActionHandler_MapEditorProperties_MapDescriptionBox)(0); + return; + case 25: + // "Edit Scenario": only for a single-player map loaded in the editor + if (DAT_GameCore::instance.U2_mapType_singleOrMulti == 1 + || !DAT_GameCore::instance.mapLoadedForEditor) { + return; + } + INT_00b95f68::instance = TRUE; + MACRO_CALL_MEMBER(Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + UI::Enums::MVT_EDIT_SCENARIO, 0); + return; + case -1: + // the description's up arrow + DAT_00b960f4::instance -= 14; + if (DAT_00b960f4::instance < 0) { + DAT_00b960f4::instance = 0; + } + return; + case -2: { + // the description's down arrow + int const limit = INT_00b95b74::instance - 231; + if (DAT_00b960f4::instance >= limit) { + return; + } + DAT_00b960f4::instance += 14; + if (DAT_00b960f4::instance > limit) { + DAT_00b960f4::instance = limit; + } + return; + } + case -3: + // a multiplayer map's pair for mapU4Int3_balanced: -3 clears it, -4 sets it + DAT_GameCore::instance.mapU4Int3_balanced = 0; + return; + case -4: + DAT_GameCore::instance.mapU4Int3_balanced = 1; + return; + case -5: + // a single-player invasion map's pair for mapU3EndInt: -5 clears it, -6 sets it + DAT_GameCore::instance.mapU3EndInt = 0; + return; + case -6: + DAT_GameCore::instance.mapU3EndInt = 1; + return; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..edd87adb6c 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 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00443778 | 0.0% | Pending