From 82fd197c16e74d3efba0957f6fe6218b21c4dc77 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 25 Nov 2026 13:33:30 +0100 Subject: [PATCH] reimplement: SHC_3BB0A8C1_0x004482F0 100.0% Reimplemented LobbyMenu::MenuView_LobbyMenu_DoEveryFrame, rewritten from the binary with gynt's draft for the names (d28341748 at 50.97% on his fork's development; e9e243723 at 54.19% on his reimpl/UI-MenuViews-development; 08c492be8 of 2026-11-02 on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file). reccmp 100.0 (normalized 100.0) on main 709b4294c2 with the data and its own function resolver on; quick_diff reads the draft 0.6142 there. The array index changed with the header. gynt's draft uses DAT_ArrayOfMapIndices[i - 1], which was right on his branch, where the array is declared at offset 0x884 and his loop's counter starts at 0. Main's sync 12854bcf4 (2026-11-04) moved the declared start to 0x880, so the original's 0x01126E28 (0x004487E9, 0x004488B0) is element 0, and the index here ([mapCount], [index]) is one lower than in the draft. - The step to the next face is written in both arms of the loop. As one copy after the arms the count is kept on the stack and every register in the loop moves. - The two searches for a map with enough places keep three gotos, because both end in the same block. gynt on #396 (2026-11-25): "The goto's are necessary for the match. There was no code form that could remove these goto's!" The goto-free forms measured in quick_diff, on an original of 724 instructions (0.9938 is quick_diff's ceiling on this function): gotos, as committed 723 instructions 0.9938 reccmp 100.0 a found index set before a break 730 instructions 0.9464 __forceinline helpers, early returns 740 instructions 0.9385 static or inline helpers, not inlined 688 instructions 0.9391 - The search starts from the sum of scroll offset and selection written out; a local for it swaps a mov and a cmp. - The box's positions are declared with left before right and top before bottom, after the flag is cleared: those six orders tie at 0.9938 in quick_diff and the others read lower. - RelativeSelected = -1 is stored again inside the test for -1, which the original does (0x00448950). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_LobbyMenu_DoEveryFrame.cpp | 442 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp diff --git a/src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp b/src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp new file mode 100644 index 0000000000..861f5f6309 --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp @@ -0,0 +1,442 @@ +// disable deprecation warnings for strcpy and strcat +#pragma warning(disable : 4996) + +#include "../LobbyMenu.func.hpp" + +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/Input/MouseState.func.hpp" +#include "OpenSHC/Synchrony/GameSynchronyState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/MenuItems/LobbyMenu.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/AI/AITypeA.hpp" +#include "OpenSHC/Commands/GameCommandType.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/IO/FileResourceType.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-macros.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_VERY_SOFT_YELLOW.hpp" +#include "OpenSHC/Globals/DAT_00b960dc.hpp" +#include "OpenSHC/Globals/DAT_00b960f4.hpp" +#include "OpenSHC/Globals/DAT_00b960f8.hpp" +#include "OpenSHC/Globals/DAT_ButtonBackgroundBlendStrength.hpp" +#include "OpenSHC/Globals/DAT_GameCore.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_MouseState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/DWORD_00b95b1c.hpp" +#include "OpenSHC/Globals/INT_00b95958.hpp" +#include "OpenSHC/Globals/INT_00b95b74.hpp" +#include "OpenSHC/Globals/INT_00b95f6c.hpp" +#include "OpenSHC/Globals/INT_00b960f0.hpp" +#include "OpenSHC/Globals/INT_00b960fc.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuViews { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004482F0 + void LobbyMenu::MenuView_LobbyMenu_DoEveryFrame() + { + int const now = timeGetTime(); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawGfxOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)(0, + (DAT_WindowAndDirectDraw::instance.resolutionX + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].width) + / 2, + (DAT_WindowAndDirectDraw::instance.resolutionY + - DAT_TextureRenderCoreObject::instance.loadedGfxArray[0].height) + / 2); + + // the menu fades in or out over time + if (DAT_00b960dc::instance != 0 && !DAT_GameSynchronyState::instance.reparseMaps) { + int const elapsed = now - DWORD_00b95b1c::instance; + DAT_GameCore::instance.hasMenuRenderedUnk = 1; + if ((int)DAT_00b960dc::instance < 0) { + DAT_ButtonBackgroundBlendStrength::instance += elapsed / -40; + if (DAT_ButtonBackgroundBlendStrength::instance <= 0) { + DAT_ButtonBackgroundBlendStrength::instance = 0; + DAT_00b960dc::instance = 0; + } + } else { + DAT_ButtonBackgroundBlendStrength::instance += elapsed / 40; + if (DAT_ButtonBackgroundBlendStrength::instance >= 32) { + DAT_ButtonBackgroundBlendStrength::instance = 32; + DAT_GameCore::instance.menuSwitchDelay = 0; + } + } + } + + if (!MACRO_CALL(OpenSHC::UI::Helpers_Func::AModalDialogIsActiveButIsNotQuitting)()) { + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderedBoxWithCustomBlendedBackground, + DAT_PencilRenderCore::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 10, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 5, 552, 216, + DAT_ButtonBackgroundBlendStrength::instance); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 15, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 10, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 557, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 216, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 16 / 32 + 32); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 10, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 227, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 370, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 403, + (DAT_ButtonBackgroundBlendStrength::instance - 32) * 16 / 32 + 32); + if (DAT_ButtonBackgroundBlendStrength::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 10, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 227, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 370, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 403, + COL_VERY_SOFT_YELLOW::instance.shortValue); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + + int const left = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 564; + int const right = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 784; + int const top = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 351; + int const bottom = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 532; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + left, top, right - 20, bottom, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 16 / 32 + 32); + if (DAT_00b960dc::instance == 0) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top - 1, right + 1, top - 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, bottom + 1, right + 1, bottom + 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top + 20, right + 1, top + 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top, left - 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right + 1, top, right + 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right - 20, top, right - 20, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right - 19, bottom - 20, right, bottom - 20, COL_VERY_SOFT_YELLOW::instance.shortValue); + } + } + + // sending the map to the other players: when every file is closed and nobody still asks, reparse + if (DAT_GameSynchronyState::instance.DAT_MapFileReceivingState == 1) { + BOOLEnum finished = TRUE; + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.mapSendingFileHandles); + ++player) { + if (DAT_GameSynchronyState::instance.mapSendingFileHandles[player] != NULL) { + finished = FALSE; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.mapTransferStatePerPlayer[player] == 1 + && DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer[player] != 1) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 + = DAT_GameSynchronyState::instance.mapTransferTicksPerPlayer[player]; + DAT_GameSynchronyState::instance.mapTransferTicksPerPlayer[player]++; + DAT_GameSynchronyState::instance.DAT_GameCommandParam1 = player; + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)((OpenSHC::Commands::GameCommandType)106); + } + } + } + if (finished) { + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + && DAT_GameSynchronyState::instance.mapTransferStatePerPlayer[player] == 1 + && DAT_GameSynchronyState::instance.mapSendRequestStatePerPlayer[player] == 1) { + finished = FALSE; + } + } + if (finished) { + MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog, + DAT_MenuModalComposition1::ptr)(OpenSHC::UI::Enums::MMT_NONE, FALSE); + DAT_GameSynchronyState::instance.DAT_MapFileReceivingState = 0; + DAT_GameSynchronyState::instance.reparseMaps = TRUE; + } + } + } + + // the faces go out one part at a time, more slowly with more than four players + int interval = 250; + if (MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::countActiveHumanPlayers, DAT_GameSynchronyState::ptr)() + > 4) { + interval = 375; + } + if (now - INT_00b960f0::instance > interval) { + 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 ((int)DAT_00b960f8::instance >= 66) { + DAT_00b960f8::instance = 0; + } + } + + if (DAT_MenuTextInputState::instance.currentModalDialog == OpenSHC::UI::Enums::MMT_NO_MENU) { + if (now - INT_00b960fc::instance > 30000) { + INT_00b960fc::instance = now; + if (DAT_GameSynchronyState::instance.isHost) { + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = 0; + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, DAT_GameSynchronyState::ptr)( + OpenSHC::Commands::GCT_TRIGGER_LOBBY_PLAYER_INFORMATION_REFRESH); + } else if (INT_00b95958::instance == 0) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::DisplayMapDescriptionAndAllocatePlayersToSlots)(); + } + } + + if (DAT_GameSynchronyState::instance.reparseMaps) { + int const playerCount + = MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::countOccupiedPlayerSlots, + DAT_GameSynchronyState::ptr)(); + DAT_MouseState::instance.waitCursorToggle = 1; + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetCursorDependingOnProgramState)(); + DAT_GameSynchronyState::instance.reparseMaps = FALSE; + MACRO_CALL_MEMBER( + OpenSHC::IO::ResourceManager_Func::mapNames_syncLoadedMapNames, DAT_ResourceManager::ptr)(); + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected != -1) { + strcpy(DAT_MapNameCache::instance, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected])); + } else { + DAT_MapNameCache::instance[0] = '\0'; + } + + // every map a skirmish can use goes into the list, and to the other players when hosting + int mapCount = 0; + for (int mapID = 0; mapID < DAT_ResourceManager::instance.mapFileCounter; ++mapID) { + char fileName[1008]; + strcpy(fileName, + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::mapNames_getLoadedMapNameForIndex, + DAT_ResourceManager::ptr)(mapID)); + // ".map" + strcat(fileName, S__MAP_005A2294); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::resolveResourceFileName, + DAT_ResourceManager::ptr)(OpenSHC::IO::FRT_MAPS, fileName); + MACRO_CALL_MEMBER(OpenSHC::IO::ResourceManager_Func::loadMapMetaByID, DAT_ResourceManager::ptr)( + mapID); + INT_00b95b74::instance = 0; + DAT_00b960f4::instance = 0; + if (DAT_GameCore::instance.mapType == 1 && DAT_GameCore::instance.mapPlayerCount >= 2) { + DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[mapCount] = mapID; + if (DAT_GameCore::instance.mapU4Int0_2 != 0) { + DAT_GameCore::instance.mapPlayerCount--; + } + DAT_GameSynchronyState::instance.mapPlayerCountArray[mapID] + = DAT_GameCore::instance.mapPlayerCount; + DAT_GameSynchronyState::instance.mapBalanceArray[mapID] + = DAT_GameCore::instance.savedMapBalance; + DAT_GameSynchronyState::instance.mapU4Int0_2Array[mapID] + = DAT_GameCore::instance.mapU4Int0_2; + if (DAT_GameCore::instance.mapPlayerCount >= playerCount) { + DAT_GameSynchronyState::instance.unknownMapRelatedReceivedDataArray[mapID] = 1; + } else { + DAT_GameSynchronyState::instance.unknownMapRelatedReceivedDataArray[mapID] = -1; + } + DAT_GameSynchronyState::instance.DAT_GameCommandParam0 = mapID; + if (DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL_MEMBER(OpenSHC::Synchrony::GameSynchronyState_Func::queueCommand, + DAT_GameSynchronyState::ptr)(OpenSHC::Commands::GCT_LOAD_MAP_HEADER); + } + ++mapCount; + } + } + + DAT_GameCore::instance.descriptionUseStringTable = TRUE; + DAT_GameCore::instance.mapDescUseStringTable = 1; + DAT_GameCore::instance.descriptionStringTableIndex = 0; + DAT_GameCore::instance.mapDescUseStringTableIndex = 0; + DAT_MouseState::instance.waitCursorToggle = 0; + DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber = mapCount; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected == -1) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset = 0; + // -1 is stored again although just compared (dropping the store loses the match) + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = -1; + } + if (mapCount != 0) { + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected == -1) { + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 0; + } + MenuModalTypeInt const openDialog = DAT_MenuModalComposition1::instance.activeModalDialogID; + DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_NONE; + MACRO_CALL( + OpenSHC::UI::MenuItems::LobbyMenu_Func::MenuItemActionHandler_LobbyMenu_MapSelectHeader)( + -(int)DAT_GameSynchronyState::instance.lobbyMapSortOrder); + + // the selected map has too few places: take the next one that fits, wrapping round the list + if (DAT_GameSynchronyState::instance.mapPlayerCountArray[DAT_MenuTextInputState::instance + .DAT_ArrayOfMapIndices[DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected]] + < playerCount) { + // the searches share the block at found (a found index or helpers lose the match) + int index; + for (index = DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + index < DAT_GameSynchronyState::instance.DAT_MapSelectionTotalNumber; ++index) { + if (DAT_GameSynchronyState::instance.mapPlayerCountArray + [DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[index]] + >= playerCount) { + // to the shared block (the match needs the goto) + goto found; + } + } + for (index = 0; index < DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + ++index) { + if (DAT_GameSynchronyState::instance.mapPlayerCountArray + [DAT_MenuTextInputState::instance.DAT_ArrayOfMapIndices[index]] + >= playerCount) { + // to the shared block (the match needs the goto) + goto found; + } + } + // no map fits: past the shared block (the match needs the goto) + goto select; + found: + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected + = index - DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset; + if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected < 0) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + += DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 0; + } else if (DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected > 7) { + DAT_GameSynchronyState::instance.DAT_MapSelectionScrollOffset + += DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected - 7; + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected = 7; + } + } + select: + MACRO_CALL( + OpenSHC::UI::MenuItems::LobbyMenu_Func::MenuItemActionHandler_LobbyMenu_MapSelectTable)( + DAT_GameSynchronyState::instance.DAT_MapSelectionRelativeSelected); + if (!DAT_GameSynchronyState::instance.isHost) { + MACRO_CALL(OpenSHC::UI::Rendering_Func::DisplayMapDescriptionAndAllocatePlayersToSlots)(); + } + DAT_MenuModalComposition1::instance.activeModalDialogID = openDialog; + } + DAT_GameSynchronyState::instance.skirmishRelated1 = -1; + DWORD_00b95b1c::instance = timeGetTime(); + } + + if (DAT_GameSynchronyState::instance.mapExistenceAckCountdown != 0) { + DAT_GameSynchronyState::instance.mapExistenceAckCountdown--; + } + } + + MACRO_CALL_MEMBER( + OpenSHC::Synchrony::GameSynchronyState_Func::compareGameVersions, DAT_GameSynchronyState::ptr)(); + if (DAT_MenuModalComposition1::instance.activeModalDialogID != OpenSHC::UI::Enums::MMT_NONE) { + return; + } + + // the box of the players' faces + INT_00b95f6c::instance = 0; + int const left = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 383; + int const top = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 350; + int const right = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 548; + int const bottom = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 425; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, DAT_PencilRenderCore::ptr)( + left, top, right, bottom, (DAT_ButtonBackgroundBlendStrength::instance - 32) * 16 / 32 + 32); + if (DAT_00b960dc::instance == 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top - 1, right + 1, top - 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, bottom + 1, right + 1, bottom + 1, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + left - 1, top, left - 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + right + 1, top, right + 1, bottom, COL_VERY_SOFT_YELLOW::instance.shortValue); + } + if (MACRO_CALL_MEMBER(OpenSHC::Input::MouseState_Func::isMouseInsideBox, DAT_MouseState::ptr)( + left, top, right - left, bottom - top)) { + INT_00b95f6c::instance = 1; + } + if (DAT_00b960dc::instance != 0) { + return; + } + + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int const firstX = left + 5; + int x = firstX; + int y = top + 1; + int occupied = 0; + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1 + || DAT_GameSynchronyState::instance.currentAIArray[player] != OpenSHC::AI::AITA_NULL) { + ++occupied; + } + } + + // two rows of four; a single row sits lower + if (occupied <= 4) { + y += 19; + } + // the step to the next face is written in both arms (one copy after them loses the match) + int drawn = 0; + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.currentPlayerFullIDArray); + ++player) { + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[player] != -1) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, player + 718, x, y); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderFacesSmallUnk, + DAT_TextureRenderCoreObject::ptr)(player + 19, x + 2, y + 2); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, + DAT_PencilRenderCore::ptr)(x, y, x + 35, y + 35, COL_BLACK::instance.shortValue); + ++drawn; + x += 40; + if (drawn == 4) { + x = firstX; + y += 38; + } + } else if (DAT_GameSynchronyState::instance.currentAIArray[player] != OpenSHC::AI::AITA_NULL) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, player + 718, x, y); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, + DAT_GameSynchronyState::instance.currentAIArray[player] + 700, x, y); + ++drawn; + x += 40; + if (drawn == 4) { + x = firstX; + y += 38; + } + } + } + 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 3a2f5aa3d5..a307ce023f 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -16375,7 +16375,7 @@ SHC_3BB0A8C1_0x00447DC0 | 0.0% | Pending SHC_3BB0A8C1_0x00447FA0 | 0.0% | Pending -SHC_3BB0A8C1_0x004482F0 | 0.0% | Pending +SHC_3BB0A8C1_0x004482F0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004489F0 | 0.0% | Pending