From c0a738cec6d698ea179d2d20ff6f4783cc7bb4e9 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 11:44:32 +0100 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x004AC7A0 100.0% Reimplemented Allies::MenuItemRenderFunction_Allies_Main, rewritten from the original's listing. gynt's draft: 1f983fe1c at 52.27% ("reordered stores") on his fork's reimpl/UI-MenuItems-development, whose status line records 52.3% (the newest commit on the file there is dd1a7c48c, a style commit); his reimpl/UI-MenuItems has 8533b1700 at 47.09%, status line 47.1% ("Style pass, asm differs"). Our draft (89a680f85, then f8721e5a9 and 07a33e2bb; 52.8% in the draft PR #328) was his code with a mechanical pass. The function draws the allies screen, one menu item per call, chosen by the item's number: 1 to 6 an ally's portrait with its signs (the resource it asks for, help needed, its orders); 10 the panel, its frame tile by tile and the selected ally's name, request, orders and help text; 200 the help line, whose text items 20 to 22 choose while the mouse is on them; the items above 19 and -1 a plain button; 110 and 111 the selected ally's button, shown while it needs help or has asked you to attack. Without allies every item but -1 is off. Behaviour fixes against the draft, each in the draft's own listing. Most of its ranges were separate ifs without a return, so: - Without allies it set the two flags and went on to draw the item. The original returns (0x004AC7D6). - 110 and 111 ran on after their button into the code for 200 and the rest, which drew the plain button too. The original leaves through the first (a tail jump at 0x004AD0FC). - 200 ran on after the help line, cleared ButtonUnknownZero and drew the plain button. The original returns after the text (0x004AC841). - 7 to 19 other than 10, and 22 while the mouse is on it, drew the panel. The original returns for them (jne at 0x004ACB92 to the return at 0x004ACB89, 0x004AD0AA). - A portrait item past the number of allies cleared ButtonUnknownZero and went on with that index. The original returns (jge at 0x004AC86C). - An unselected ally's portrait returned after its picture when it showed lord icon 0 or 1 or an AI lord, so the signs on it were not drawn. The original goes on to the signs (0x004ACA42 falls into 0x004ACA47). - The selected ally's portrait returned after its frame: no signs either (0x004ACA77 falls into 0x004ACA7C). - The ally's request that you attack: with a player as the target the draft drew the face and its frame, then the target's picture a second time and an AI lord's picture over them. The original returns after the frame (0x004AD012). What decided the match. The counts are differing lines of our own exact listing compare against the original's 702 instructions (operands with the original's addresses and every jump's landing), each with that one thing changed from the final code, which has 0: - The parameter is reused: the portrait steps it to the ally's index, copies that, and then stores the ally's player ID in it; the panel stores the selected ally's player ID in it too. A variable of its own for the player: 281; for the index: 169; for the panel's player: 13. The code reuses `button` for both, as AlliesOrder_Main on main does. - The resource asked for is counted from wood on in a statement of its own (`resource -= RT_WOOD`), in both places. Inside the test: 155 and 123. - The code for the items above 19 stands after the portraits' and the panel's (before them: 62), and the panel's after the portraits' (before them: 577). - The portrait's blend (8 for the unselected ones) by if. As a conditional expression: 88. - An unselected portrait's picture with a call in each arm. Its number in a local and one call: 80. - Smaller: the panel's resource test `< 0` with the "no request" text first (the other way: 8), the player's ID read once into a local (twice: 12), the target picture's x before its y (20), new variables for the last picture's position rather than changing x and y (4), the frame's row number with no first value (7 as its first value: 36), the target's picture called in each arm of its test, in both places (called once before the test: 73 and 41). These gave the same code, and the plainer form stands: 110 and 111 first with a return (the original has their code at the end), their flag by an early return or by if / else, the AI lord's text number's operands in either order, the frame's row number by if / else or by conditional expressions, the range test 0 to 19 as two compares or as one unsigned compare, the step to the index as `button--` or `-= 1`, the frame's middle columns skipped by an else-if or by a nested if, `button` written directly or named through a reference, and 20 to 22 as an else-if chain or as ifs that each return. The text numbers carry their texts from the game's cr.tex (TEXT_ALLIES) as comments. Neither they nor the other comments change the listing: this code compiles to the same instructions, line for line, as the code the narrow build with the callees and the full build measured (0aae52a5f's). Measured in a narrow build on main 3458fea34 of that code and the eight finished functions it calls, struct resolvers and their resolvers on: renderGM (0x00455300), drawBitmapFace (0x0044CD40), renderGMWithBlending (0x00455390), renderGMWithAlphaMask (0x004557B0), renderFacesSmallUnk (0x0044CE00), isAIPlayer (0x004010B0), RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk (0x004640D0) and RenderButtonImageWithBlending (0x004641A0), which 110 and 111 tail-call. reccmp 100.0, normalized 100.0, no diff line. The two of them on main's /GL list read lower in that build (RenderCurrentNotActiveButton... 54.8, RenderButtonImageWithBlending 58.3), as their own callees are not in it. With only this file, as committed, in the list, the callees' resolvers off, the function reads 100.0 (100.0 normalized) too. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuItemRenderFunction_Allies_Main.cpp | 430 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 431 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..665d4bdfbd --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/Allies/MenuItemRenderFunction_Allies_Main.cpp @@ -0,0 +1,430 @@ +#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/Game/Resources/ResourceType.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/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 { + + // FUNCTION: STRONGHOLDCRUSADER 0x004AC7A0 + void Allies::MenuItemRenderFunction_Allies_Main(int button, ...) + { + if (button == 100) { + return; + } + // without allies every item but -1 is off + if (DAT_AlliesCount::instance < 1 && button != -1) { + DAT_ButtonUnknownZero::instance = TRUE; + DAT_ButtonCurrentlyInteracting::instance = FALSE; + return; + } + if (button == 110 || button == 111) { + // 110 and 111: the selected ally's button, shown while it needs help or has asked you to attack + int const player = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + if ((DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestStateUnk + == 1 + && DAT_GameSynchronyState::instance.currentPlayerFullIDArray[DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk] + != -1 + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerID_askerUnk + == player) + || DAT_GameState::instance.playerDataArray[player].isNotNervousByEnemyTroopValue) { + DAT_ButtonUnknownZero::instance = FALSE; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderButtonImageWithBlending)(); + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + // 200: the help line; 20 to 22 choose its text + if (button == 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, DAT_ButtonX::instance, + 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; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + if (button >= 0 && button <= 19) { + // up to 6: the portrait of the ally at button - 1 + if (button <= 6) { + if (button == 1) { + DAT_00df51f4::instance = 0; + } + // button becomes the index, then the ally's player ID (a variable of its own loses the match) + button--; + if (button >= DAT_AlliesCount::instance) { + return; + } + int const index = button; + button = DAT_SomeTeamMemberPlayerIDArray::instance[index]; + int ai = 0; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[button] == -1) { + ai = DAT_GameSynchronyState::instance.currentAIArray[button]; + } + // the selected ally's portrait is drawn plain, the others blended + // a call in each arm (one call with the picture's number in a local loses the match) + if (index == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, button + 546, + DAT_ButtonX::instance, DAT_ButtonY::instance); + if (ai == 0) { + if (DAT_GameCore::instance.lordIcons[button] == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 539, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } else if (DAT_GameCore::instance.lordIcons[button] == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 540, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } else if (DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[button + 19] > 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 541, + DAT_ButtonX::instance, DAT_ButtonY::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFace, + DAT_TextureRenderCoreObject::ptr)( + button + 19, DAT_ButtonX::instance + 4, DAT_ButtonY::instance + 4); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, ai + 522, + DAT_ButtonX::instance, DAT_ButtonY::instance); + } + } else if (ai == 0) { + if (DAT_GameCore::instance.lordIcons[button] == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 539, + DAT_ButtonX::instance, DAT_ButtonY::instance, 12); + } else if (DAT_GameCore::instance.lordIcons[button] == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 540, + DAT_ButtonX::instance, DAT_ButtonY::instance, 12); + } else if (DAT_TextureRenderCoreObject::instance.bitmapFaceSizes[button + 19] > 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 541, + DAT_ButtonX::instance, DAT_ButtonY::instance, 12); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::drawBitmapFaceWithBlendUnk, + DAT_TextureRenderCoreObject::ptr)( + button + 19, DAT_ButtonX::instance + 4, DAT_ButtonY::instance + 4, 12); + } + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, ai + 522, + DAT_ButtonX::instance, DAT_ButtonY::instance, 12); + } + if (index == DAT_LastTeamMemberIndex::instance) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 514, + DAT_ButtonX::instance - 6, DAT_ButtonY::instance - 6, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 513, 0); + } + // the signs: resource, help, orders; the blend by if (a conditional expression loses the match) + int blend = 0; + if (index != DAT_LastTeamMemberIndex::instance) { + blend = 8; + } + int resource + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[button]; + if (resource == OpenSHC::Game::Resources::RT_PITCH) { + resource = OpenSHC::Game::Resources::RT_PARTIALPITCH; + } + // counted from wood on, in a statement of its own (inside the test the match is lost) + resource -= OpenSHC::Game::Resources::RT_WOOD; + if (resource >= 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + resource + 580, DAT_ButtonX::instance + 60, DAT_ButtonY::instance - 12, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, blend); + } + if (DAT_GameState::instance.playerDataArray[button].isNotNervousByEnemyTroopValue) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, + DAT_00df42b0::instance + 578, DAT_ButtonX::instance + 60, DAT_ButtonY::instance + 60, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, blend); + } + if (DAT_GameState::instance.playerDataArray[button].requestStateUnk == 1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 576, + DAT_ButtonX::instance - 15, DAT_ButtonY::instance + 57, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 577, blend); + } + if (DAT_GameState::instance.playerDataArray[button].requestStateUnk == 2) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 604, + DAT_ButtonX::instance - 15, DAT_ButtonY::instance + 57, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 605, blend); + } + return; + } + if (button != 10) { + return; + } + // 10: the panel; its frame tile by tile, then the selected ally's state in it + int const buttonX = DAT_ButtonX::instance; + int const buttonY = DAT_ButtonY::instance; + for (int rowY = 0; rowY < DAT_ButtonH::instance; rowY += 24) { + // no first value (7 as its first value loses the match) + int row; + if (rowY == 0) { + row = 1; + } else if (rowY == DAT_ButtonH::instance - 24) { + row = 13; + } else { + row = 7; + } + for (int columnX = 0; columnX < 648; columnX += 24) { + int picture = row; + if (columnX != 0) { + if (columnX == 624) { + picture = row + 2; + } else if (row == 7) { + continue; + } else { + picture = row + 1; + } + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, picture, + columnX + buttonX, buttonY + rowY, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + picture + 3, 0); + } + } + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + buttonX + 24, buttonY + 24, buttonX + 623, DAT_ButtonH::instance + buttonY - 25, 20); + // button takes the ally's player ID here too, as above + button = DAT_SomeTeamMemberPlayerIDArray::instance[DAT_LastTeamMemberIndex::instance]; + // its full ID read once (read twice, the match is lost) + int const fullID = DAT_GameSynchronyState::instance.currentPlayerFullIDArray[button]; + if (fullID == -1 + && !MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(button)) { + return; + } + // the player's name, or the AI lord's + int y = DAT_ButtonY::instance + 24; + int const x = DAT_ButtonX::instance + 24; + if (fullID != -1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameText, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[button], x, y, OpenSHC::Text::TTA_LEFT, + DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[button]], + 0, 17, FALSE); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + DAT_GameSynchronyState::instance.aiVariationArray[button] + 103 + + DAT_GameSynchronyState::instance.currentAIArray[button] * 8, + x, y, OpenSHC::Text::TTA_LEFT, + DAT_RenderingDefinedData::instance + .ColorTable1[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[button]], + 0, 17, FALSE); + } + // the resource it asks for: "Requests", the amount, the resource's picture and its name + int resource + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray1Unk[button]; + if (resource == OpenSHC::Game::Resources::RT_PITCH) { + resource = OpenSHC::Game::Resources::RT_PARTIALPITCH; + } + resource -= OpenSHC::Game::Resources::RT_WOOD; + y += 32; + // tested this way round (the other way, the match is lost) + if (resource < 0) { + // "No Goods Requested" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 1, x, y, 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_ALLIES, 12, x, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderLeftAlignedNumberToScreen, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .requestedGoodsArray2Unk[button], + x + 5, y, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, resource + 580, + DAT_TextManagerObject::instance.currentXOffset_0x0 + x + 10, y - 8, + OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, 603, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, resource + OpenSHC::Game::Resources::RT_WOOD, x + 45, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } + // its orders: "No Orders", or "Orders:", "Attack" or "Defend", and the target: "You" or a picture + y += 32; + if (DAT_GameState::instance.playerDataArray[button].requestStateUnk == 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 2, x, y, 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_ALLIES, 16, x, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + if (DAT_GameState::instance.playerDataArray[button].requestStateUnk == 1) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, x + 5, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } + if (DAT_GameState::instance.playerDataArray[button].requestStateUnk == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 17, x + 5, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else if (DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk + == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 18, x + 10, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE); + } else { + // a face in a frame, or an AI lord's picture; x before y (the other order loses the match) + int const iconX = DAT_TextManagerObject::instance.currentXOffset_0x0 + x + 10; + int const iconY = y - 12; + // the picture in each arm (called once before the test, the match is lost) + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray + [DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk] + != -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk + 718, iconX, + iconY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk + 19, + iconX + 2, iconY + 2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)( + iconX, iconY, iconX + 35, iconY + 35, COL_BLACK::instance.shortValue); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk + 718, iconX, + iconY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameSynchronyState::instance.currentAIArray + [DAT_GameState::instance.playerDataArray[button].requestedAttackTargetUnk] + + 700, + iconX, iconY); + } + } + } + // "Help Needed!" + y += 32; + if (DAT_GameState::instance.playerDataArray[button].isNotNervousByEnemyTroopValue) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 4, x, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + } + // this ally's request that you attack: "Attack" and the target's picture + int const own = DAT_GameSynchronyState::instance.currentPlayerSlotID; + if (DAT_GameState::instance.playerDataArray[own].requestStateUnk != 1) { + return; + } + if (DAT_GameSynchronyState::instance + .currentPlayerFullIDArray[DAT_GameState::instance.playerDataArray[own].playerID_askerUnk] + == -1) { + return; + } + if (DAT_GameState::instance.playerDataArray[own].playerID_askerUnk != button) { + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_ALLIES, 10, x, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE); + // new variables (changing x and y loses the match) + int const iconX = DAT_TextManagerObject::instance.currentXOffset_0x0 + x + 10; + int const iconY = y - 5; + // the picture in each arm, as above + if (DAT_GameSynchronyState::instance + .currentPlayerFullIDArray[DAT_GameState::instance.playerDataArray[own].requestedAttackTargetUnk] + != -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameState::instance.playerDataArray[own].requestedAttackTargetUnk + 718, iconX, iconY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)( + DAT_GameState::instance.playerDataArray[own].requestedAttackTargetUnk + 19, iconX + 2, + iconY + 2); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + iconX, iconY, iconX + 35, iconY + 35, COL_BLACK::instance.shortValue); + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameState::instance.playerDataArray[own].requestedAttackTargetUnk + 718, iconX, iconY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameSynchronyState::instance + .currentAIArray[DAT_GameState::instance.playerDataArray[own].requestedAttackTargetUnk] + + 700, + iconX, iconY); + return; + } + // above 19, and -1: a plain button (moved before the portraits, the match is lost) + MACRO_CALL( + OpenSHC::UI::Rendering_Func::RenderCurrentNotActiveButtonWithPossibleAlphaTexOnCurrentSurfaceUnk)(); + if (!DAT_ButtonCurrentlyInteracting::instance) { + return; + } + if (button == 20) { + DAT_00df51f4::instance = 1; + // "Set Orders" + DAT_00df51f0::instance = 5; + } else if (button == 21) { + DAT_00df51f4::instance = 1; + // "Send Goods" + DAT_00df51f0::instance = 6; + } else if (button == 22) { + DAT_00df51f4::instance = 1; + // "Request Goods" + DAT_00df51f0::instance = 7; + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..dc50a106d2 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 | 0.0% | Pending +SHC_3BB0A8C1_0x004AC7A0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004AD110 | 0.0% | Pending