From a84024c101ecd3465428face04ff15033fd52a31 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sat, 21 Nov 2026 11:35:30 +0100 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x00427810 100.0% Reimplemented LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons, rewritten from the original's listing. gynt's draft: f0e6b48ca at 56.46% ("Style pass, asm differs") on his fork's reimpl/UI-MenuItems, whose status line records 56.5%; his reimpl/UI-MenuItems-development records 56.5% too ("Reimplemented, asm differs"; the newest commits on the file there are 8725ec523, a reimplementation commit, and 50849804c, a style commit). Our draft (8c967b43b, then five style commits up to 07a33e2bb; 58.8% in the draft PR #328) was his code with a mechanical pass. The function draws the parts of the lobby's player list, one menu item per call, chosen by the item's number: 0 the three headings; above 10 a seat's row (its group's icons, the help texts under the mouse, and text 402 for a player or the AI lord's text); 1 to 10 a seat's picture, a second one for the host's seat, and the player's or the AI lord's name; -1 to -9 a seat's button; -101 to -103 three single buttons; -200 and below a seat's button for the host. Each range ends in a return; the last three leave through RenderCurrentButtonToScreenMenuWithBlendingUnk. Seven behaviour fixes against the draft. The draft's ranges were separate ifs without an else and partly without a return, so: - For the host, after the headings (0) it ran on into the code for -1 to -9, with the seat at index 0 (visible in the draft's listing: a jmp to that code's single-player test, which returns in a single player skirmish). - After a seat's name (1 to 10) it ran on into the same code with the seat at index -button, before the array, and cleared ButtonUnknownZero again, which the original leaves set. - Above 10 it went on to the AI lord's text after a player's text, and drew it whenever the seat also had an AI type; 1 to 10 it drew the AI lord's text (for a seat without an AI lord too) and then the name. The original draws one of the two: it returns after the player's (0x00427BBE and 0x00427D65) and draws the AI lord's only for a seat that has one. - An AI lord's seat button (-1 to -9, and -200 and below) was drawn twice for the host: after the button the draft ran on to the function's last lines, which draw the current button. The original leaves through the first draw (tail jumps at 0x00427EB7 and 0x00428025). - In the last range a player's seat ran on after its button was drawn too: it then called isAIPlayer with the alpha value in place of the seat's number and could draw the button again. - -102 set ButtonUnknownZero only for someone who is not the host. The original sets it first (0x00427F0E), so for the host it stays set while another dialog is open. - -103 outside a single player skirmish set ButtonUnknownZero, cleared it again and went on to the button. The original returns with it set (0x00427F40 to 0x0042802A). The first two, the AI lord's button and -102 are in the draft's listing; the others are read from its source. What decided the match, each measured with that one thing changed (reccmp in the narrow build described below): - The two headings with an x offset take x through a local. Written in the call, x is loaded late: 96.2% (79.2% normalized). - Where two or three calls differ in one argument, each arm has its own call, and the compiler shares the call: the three help texts (their number in a local: 92.3%, 82.7%) and the two colours of a name (the colour in a local: 92.7%, 83.4%). - A player's seat button takes its picture number, 206 or 207, by if / else. As the draft's `207 - (value != 0)`: 96.2% (82.7%). - The last range is `if (isHost) { ... return; }` with the code for everyone else after it; that code is also -103's exit. With `if (!isHost) { ...; return; }` first: 96.1% (81.8%). - -101 looks for an empty seat with a flag set in the loop. With the loop's index tested after it: 96.8% (85.9%). Measured later with our own exact listing compare against the original's 604 instructions (differing lines, the final text has 0): text 402's two colours take a call in each arm too (the colour in a local and one call: 328; set by if / else: 107), and the group array is read again after the help text's call where the original reads it again (with the `group` local there: 330). These compile to the same listing, and the plainer form stands: the flag in -101 where the draft had a goto into -103's clear; the AI type switched from the field where a local would do; the two icon rows in either order; the picture number by if / else where a conditional expression would do. The text numbers carry their texts from the game's cr.tex (group 79) as comments, and the button pictures 206, 207, 626 and 627 are named from GmDataIndex. Neither changes the listing: this text compiles to the same instructions, line for line, as the text the builds below measured (the tree of 12b9d934e). Measured in a narrow build on main 3458fea34 of that text and the five finished functions it calls, their resolvers on: AModalDialogIsActiveButIsNotQuitting (0x00427210), renderGMWithAlphaMask (0x004557B0), renderGMWithBlending (0x00455390), isAIPlayer (0x004010B0) and RenderCurrentButtonToScreenMenuWithBlendingUnk (0x00464370), which five paths tail-call. reccmp 100.0, normalized 100.0, no diff line. Without the callees' files in the list the function reads 99.4% (100.0% normalized): the tail jumps then go to a trampoline, and four of the five read differently. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...tion_LobbyMenu_PlayerListAndNpcButtons.cpp | 363 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 364 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..81c75e4803 --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/LobbyMenu/MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons.cpp @@ -0,0 +1,363 @@ +#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/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/GmDataIndex.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::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00427810 + void LobbyMenu::MenuItemRenderFunction_LobbyMenu_PlayerListAndNpcButtons(int button, ...) + { + if (MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + return; + } + // 0: the list's three headings + if (button == 0) { + // the fade written the long way round at every call, as the original computes it + // "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), + DAT_ButtonX::instance, DAT_ButtonY::instance, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + // a local for x (with x written in the call the match is lost) + int const statusX = DAT_ButtonX::instance + 335; + // "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), + statusX, DAT_ButtonY::instance, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + // a local for x, as above + int const ejectX = DAT_ButtonX::instance + 370; + // "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), + ejectX, DAT_ButtonY::instance, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 19, FALSE, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // above 10: the row of the seat that is at button - 10 in the round table's order + if (button > 10) { + int const slot = DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[button - 10]; + DAT_ButtonUnknownZero::instance = TRUE; + if (slot < 1) { + return; + } + int const group = DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[slot]; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (group > 0) { + if (group == 1 || group == 3) { + for (int x = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + x < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350; x += 20) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 204, x, + DAT_ButtonY::instance, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22 / 32 + 32); + } + } else { + for (int x = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 28; + x < DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 350; x += 20) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 205, x, + DAT_ButtonY::instance, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 72, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 22 / 32 + 32); + } + } + } + // stored again, as the original does + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE + && DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + >= 28 + && DAT_MouseState::instance.screenSpaceX - DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + < 350 + && DAT_MouseState::instance.screenSpaceY >= DAT_ButtonY::instance + && DAT_MouseState::instance.screenSpaceY < DAT_ButtonY::instance + 20) { + // a call in each arm (with the text's number in a local the match is lost) + if (slot == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // "This is you!" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 403, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); + } else if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + // "Human Opponent" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 404, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); + } else { + // "Computer Opponent" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 405, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 135, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 192, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, FALSE); + } + // read again after the call, as the original does (a local loses the match) + if (DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[slot] > 0) { + // "(In Team 1)" to "(In Team 4)" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + DAT_GameSynchronyState::instance.DAT_PlayerGroupArray[slot] + 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[slot] != -1) { + // a call in each arm (with the colour in a local the match is lost) + if (slot == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // "Human" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 5, 60, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else { + // "Human" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, 402, + DAT_ButtonX::instance + 10, DAT_ButtonY::instance + 5, 60, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + return; + } + if (DAT_GameSynchronyState::instance.currentAIArray[slot] == OpenSHC::AI::AITA_NULL) { + return; + } + // the AI lord's kind, "Rat" (239) to "Abbot" (374) + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + DAT_GameSynchronyState::instance.currentAIArray[slot] * 9 + 230, DAT_ButtonX::instance + 10, + DAT_ButtonY::instance + 5, 70, OpenSHC::Rendering::Colors::COL_7CAAAF, 19, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // 1 to 10: the seat that is at button in the round table's order + if (button > 0) { + int const slot = DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[button]; + DAT_ButtonUnknownZero::instance = TRUE; + if (slot < 1) { + return; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER + && (slot == DAT_GameSynchronyState::instance.DAT_HostPlayerSlotID + || (DAT_GameSynchronyState::instance.isHost + && slot == DAT_GameSynchronyState::instance.currentPlayerSlotID))) { + 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, DAT_ButtonY::instance - 2, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_2, slot + 469, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, DAT_ButtonY::instance, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + DAT_TextManagerObject::instance.field_0x30 = 1; + // a call in each arm (with the colour in a local the match is lost) + if (slot == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[slot], + DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 5, 280, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, + DAT_TextManagerObject::ptr)(DAT_GameSynchronyState::instance.DAT_PlayerNames[slot], + DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 5, 280, + OpenSHC::Rendering::Colors::COL_7CAAAF, 19, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + } + return; + } + if (DAT_GameSynchronyState::instance.currentAIArray[slot] == OpenSHC::AI::AITA_NULL) { + return; + } + // the AI lord's own name, "Duc de Puce" for the first rat + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText4Unk, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_XPLAY_WAITING_ROOM, + DAT_GameSynchronyState::instance.aiVariationArray[slot] + 231 + + DAT_GameSynchronyState::instance.currentAIArray[slot] * 9, + DAT_ButtonX::instance + 20, DAT_ButtonY::instance + 5, 280, OpenSHC::Rendering::Colors::COL_7CAAAF, + 19, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // -1 to -9: the button of the seat at -button; nothing in a single player skirmish + if (button > -10) { + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + return; + } + int const slot = DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[-button]; + DAT_ButtonUnknownZero::instance = FALSE; + if (slot < 1) { + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + if (slot != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + if (DAT_GameSynchronyState::instance.DAT_PlayerSlotArraySomeValue[slot] != 0) { + DAT_CurrentButtonGmDataIndex::instance + = OpenSHC::Rendering::Enums::GDI_INTERFACE_ICONS_2_206_PIC_260; + } else { + DAT_CurrentButtonGmDataIndex::instance + = OpenSHC::Rendering::Enums::GDI_INTERFACE_ICONS_2_207_PIC_262; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + if (DAT_GameSynchronyState::instance.currentAIArray[slot] == OpenSHC::AI::AITA_NULL) { + return; + } + // 626 for the European lords, 627 for the Arabian ones + DAT_CurrentButtonGmDataIndex::instance = OpenSHC::Rendering::Enums::GDI_INTERFACE_ICONS_2_627_PIC_756; + switch (DAT_GameSynchronyState::instance.currentAIArray[slot]) { + 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 + = OpenSHC::Rendering::Enums::GDI_INTERFACE_ICONS_2_626_PIC_755; + break; + } + DAT_ButtonX::instance -= 6; + DAT_ButtonY::instance -= 3; + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // -10 to -199: the buttons -101, -102 and -103; any other number here only draws the button for the host + if (button > -200) { + if (button == -101) { + DAT_ButtonUnknownZero::instance = TRUE; + BOOLEnum emptySeat = FALSE; + if (DAT_GameSynchronyState::instance.isHost + && DAT_MenuModalComposition1::instance.activeModalDialogID == OpenSHC::UI::Enums::MMT_NONE) { + for (int i = 1; i < countof(DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray); ++i) { + if (DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[i] < 1) { + emptySeat = TRUE; + break; + } + } + } + if (emptySeat) { + DAT_ButtonUnknownZero::instance = FALSE; + } else { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + } + } else if (button == -102) { + DAT_ButtonUnknownZero::instance = TRUE; + if (!DAT_GameSynchronyState::instance.isHost) { + 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) { + DAT_ButtonUnknownZero::instance = FALSE; + } + } else if (button == -103) { + if (DAT_GameSynchronyState::instance.currentGameMode != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + DAT_ButtonUnknownZero::instance = FALSE; + } + if (!DAT_GameSynchronyState::instance.isHost) { + return; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + // -200 and below: the seat at -button - 200; the non-host code stands last (first, the match is lost) + DAT_ButtonUnknownZero::instance = FALSE; + if (DAT_GameSynchronyState::instance.isHost) { + int const slot = DAT_GameSynchronyState::instance.DAT_RoundTableOrderArray[-button - 200]; + if (slot < 1) { + return; + } + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[slot] != -1) { + if (slot == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (DAT_GameSynchronyState::instance.slotActionPending[slot] != 0) { + return; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + if (slot == DAT_GameSynchronyState::instance.currentPlayerSlotID) { + DAT_ButtonUnknownZero::instance = TRUE; + return; + } + if (!MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::isAIPlayer, DAT_GameSynchronyState::ptr)(slot)) { + return; + } + MACRO_CALL(OpenSHC::UI::Rendering_Func::RenderCurrentButtonToScreenMenuWithBlendingUnk)( + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 32 / 32 + 32); + return; + } + DAT_ButtonUnknownZero::instance = TRUE; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..71647b2ddf 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 | 0.0% | Pending +SHC_3BB0A8C1_0x00427810 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00427CB2 | 0.0% | Pending