From aa7b57f84f1a2d11e5fe56e653fd2adb58c01097 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 14:30:08 +0100 Subject: [PATCH 1/3] reimplement: SHC_3BB0A8C1_0x00491840 96.5% a register rename in the death check, #414 not settled OptionsMenu::MenuItemRenderFunction_OptionsMenu_Buttons, rewritten from the binary with gynt's draft for the names (979ff3417, 05e10b37b and 4e64ac5e9 on his fork's reimpl/UI-MenuItems, 62.41% there; ce267a968 at 62.54% on his reimpl/UI-MenuItems-development, his newest reimplement commit on the file). gynt's draft measures 0.7698 in quick_diff on main. It draws Load (2), Save (3), Briefing (39) and the other options buttons enabled or greyed, and Restart Mission (44) with its own greyed form. Load, Save and Restart Mission use the same tests as the buttons' click handler (0x00496B80). Briefing is also greyed when field_0x6c is set, which the handler's case 39 does not test. Load from the main menu skips the tests, and the greyed tests are one condition, so the enabled and the greyed draws are each written once, as the original lays them out: written as separate returns MSVC does not merge them (223 instructions against 143), and a greyed flag keeps its test (0.5411). The online tests sit in the condition's `? :` on the game mode; written with gotos into the two draws instead, the code is the same to the byte. The text position goes in locals before the hover test, so the three text calls share their tail (0.8472 -> 0.9650). What is left is a register rename, and #414 is not settled, so the status line records the raw 96.5. reccmp reads 96.5 (normalized 80.0) in a build on main 3458fea34 with the data and its own function resolver on, and diff_triage's register-blind ratio is 1.000 (0.800 before renaming registers). The five line pairs that differ are the player's death check (slot * 0x39f4): the original keeps its temporary in ebx and ours in edi (push, mov, imul, cmp, pop). Same 143 instructions, same mnemonics in the same order, and the same memory operands apart from that temporary as the base register of the cmp at 0x004918BF. Spellings of the read, nesting, an inline helper, the condition order and the enabled block's shape all leave it in edi. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- ...ItemRenderFunction_OptionsMenu_Buttons.cpp | 104 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MenuItems/OptionsMenu/MenuItemRenderFunction_OptionsMenu_Buttons.cpp diff --git a/src/OpenSHC/UI/MenuItems/OptionsMenu/MenuItemRenderFunction_OptionsMenu_Buttons.cpp b/src/OpenSHC/UI/MenuItems/OptionsMenu/MenuItemRenderFunction_OptionsMenu_Buttons.cpp new file mode 100644 index 0000000000..7ff983b35a --- /dev/null +++ b/src/OpenSHC/UI/MenuItems/OptionsMenu/MenuItemRenderFunction_OptionsMenu_Buttons.cpp @@ -0,0 +1,104 @@ +#include "../OptionsMenu.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/AlphaAndButtonSurface.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/AlphaAndButtonSurfaceObj.hpp" +#include "OpenSHC/Globals/DAT_ButtonCurrentlyInteracting.hpp" +#include "OpenSHC/Globals/DAT_ButtonW.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace UI { + namespace MenuItems { + + // FUNCTION: STRONGHOLDCRUSADER 0x00491840 + void OptionsMenu::MenuItemRenderFunction_OptionsMenu_Buttons(int button, ...) + { + // "Load" from the main menu skips the tests: it is always drawn enabled + if (!(button == 2 && DAT_GameCore::instance.currentMenuViewType == OpenSHC::UI::Enums::MVT_MAIN_MENU)) { + // greyed by the player's death, the game mode, or not being the host + if (((button == 2 || button == 3) + && DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + && DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .playerDeathRelated + != 0) + // a ?: on the game mode: written as two tests the mode is read twice, which loses the match + || (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY + ? (button == 39 + && !(DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + && DAT_MapPropertiesState::instance.scenarionMissionType != 0))) + : ((button == 2 + && DAT_GameSynchronyState::instance.currentGameMode + != OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER) + || button == 39 || (button == 3 && !DAT_GameSynchronyState::instance.isHost))) + || ((DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_SIEGE_THAT + || DAT_GameCore::instance.field_0x6c != 0 + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) + && (button == 2 || button == 39 || button == 3))) { + DAT_ButtonCurrentlyInteracting::instance = FALSE; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_7F7F7F, 18, FALSE, 0); + return; + } + // "Restart Mission", for campaign missions, plain scenarios and skirmishes + if (button == 44 + && !(DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION + || DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_ECONOMIC_CAMPAIGN_SH1 + || (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk + && DAT_GameCore::instance.field_0x6c == 0) + || DAT_GameSynchronyState::instance.currentGameMode + == OpenSHC::Game::GM_SKIRMISH_SINGLE_PLAYER)) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderNonInteractingButtonBackground, + AlphaAndButtonSurfaceObj::ptr)(0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, 44, DAT_ButtonW::instance / 2 + DAT_ButtonX::instance, + DAT_ButtonY::instance + 7, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_7F7F7F, + 18, FALSE); + return; + } + } + // enabled + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::AlphaAndButtonSurface_Func::renderBasicButton, + AlphaAndButtonSurfaceObj::ptr)(0, OpenSHC::Rendering::Enums::RT_CONTEXT_BASED); + int const textY = DAT_ButtonY::instance + 7; + int const textX = DAT_ButtonW::instance / 2 + DAT_ButtonX::instance; + if (!DAT_ButtonCurrentlyInteracting::instance) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 4); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_GAME_OPTIONS, button), + textX, textY, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 2); + } + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..2fb0250b25 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -23415,7 +23415,7 @@ SHC_3BB0A8C1_0x004917C0 | 0.0% | Pending SHC_3BB0A8C1_0x00491810 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00491840 | 0.0% | Pending +SHC_3BB0A8C1_0x00491840 | 96.5% | a register rename in the death check, #414 not settled SHC_3BB0A8C1_0x00491A30 | 100.0% | Reimplemented From 07cbe7bbc34188bc7a177ca33851c68d89f39fe1 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 18 Nov 2026 16:37:43 +0100 Subject: [PATCH 2/3] 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 3458fea34 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 is [i]. - 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 (0.9385 against 0.9855 in quick_diff). - The two searches for a map with enough places keep three gotos, because both end in the same block. The style bot reports them (rule 20), so this function waits in a draft for the maintainers' answer. The 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 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 right after the test for -1, which the original does (0x00448950). Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../MenuView_LobbyMenu_DoEveryFrame.cpp | 436 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 437 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..01c943569d --- /dev/null +++ b/src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp @@ -0,0 +1,436 @@ +// 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/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 { + + // 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) { + OpenSHC::WindowsHelper::Enums::BOOLEnum finished = TRUE; + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.mapSendingFileHandles); + ++player) { + if (DAT_GameSynchronyState::instance.mapSendingFileHandles[player] != 0) { + 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 players + = 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)); + strcat(fileName, S__MAP_005A2294); // ".map" + 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 >= players) { + 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; + // stores the value it has just compared: the original has this store + 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]] + < players) { + // a goto out of both searches, which share the block at found as the original does: + // a found index reads 0.9464 in quick_diff and inlined helpers 0.9385, against 0.9938 + 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]] + >= players) { + 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]] + >= players) { + goto found; + } + } + 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] != 0) { + ++occupied; + } + } + + // two rows of four; a single row sits lower + if (occupied <= 4) { + y += 19; + } + // the step to the next place is written in both arms: as one copy after them, the count leaves its register + 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] != 0) { + 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 2fb0250b25..906e9876db 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 From a1aa274aa23541017785847ca659d67367890f44 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Wed, 25 Nov 2026 11:10:55 +0100 Subject: [PATCH 3/3] drafts: move LobbyMenu DoEveryFrame to its ready PR MenuView_LobbyMenu_DoEveryFrame leaves this draft for its ready branch, reimpl/UI-B-lobbydoeveryframe-100 (f1fcf329c). This branch's question about its three gotos is answered: gynt wrote on #396 that the gotos are necessary for the match there. The file goes, and its status line goes back to main's. OptionsMenu Buttons stays here with its #414 question. Co-Authored-By: Claude Opus 5.5 --- .../MenuView_LobbyMenu_DoEveryFrame.cpp | 436 ------------------ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 1 insertion(+), 437 deletions(-) delete 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 deleted file mode 100644 index 01c943569d..0000000000 --- a/src/OpenSHC/UI/MenuViews/LobbyMenu/MenuView_LobbyMenu_DoEveryFrame.cpp +++ /dev/null @@ -1,436 +0,0 @@ -// 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/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 { - - // 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) { - OpenSHC::WindowsHelper::Enums::BOOLEnum finished = TRUE; - for (int player = 1; player < countof(DAT_GameSynchronyState::instance.mapSendingFileHandles); - ++player) { - if (DAT_GameSynchronyState::instance.mapSendingFileHandles[player] != 0) { - 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 players - = 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)); - strcat(fileName, S__MAP_005A2294); // ".map" - 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 >= players) { - 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; - // stores the value it has just compared: the original has this store - 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]] - < players) { - // a goto out of both searches, which share the block at found as the original does: - // a found index reads 0.9464 in quick_diff and inlined helpers 0.9385, against 0.9938 - 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]] - >= players) { - 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]] - >= players) { - goto found; - } - } - 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] != 0) { - ++occupied; - } - } - - // two rows of four; a single row sits lower - if (occupied <= 4) { - y += 19; - } - // the step to the next place is written in both arms: as one copy after them, the count leaves its register - 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] != 0) { - 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 906e9876db..2fb0250b25 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 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x004482F0 | 0.0% | Pending SHC_3BB0A8C1_0x004489F0 | 0.0% | Pending