From 336e4db2553ea7fba37166b097e027ed0e2e2820 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 16:32:46 +0000 Subject: [PATCH] Decompile fn_21322 (CGameMode::Run) Batch #8319 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_21322 CGameMode::Run: logic confirmed by peer review Peer-reviewed-by: kyoshi, System4z, dori Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Mode/CGameMode.h | 2 + Source/Client/Mode/GameMode.cpp | 93 +++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/Source/Client/Mode/CGameMode.h b/Source/Client/Mode/CGameMode.h index 36cf205f..a88fa651 100644 --- a/Source/Client/Mode/CGameMode.h +++ b/Source/Client/Mode/CGameMode.h @@ -450,6 +450,8 @@ public: int first, int second, int third, int fourth, int fifth, int sixth, int seventh, int eighth, int ninth, int tenth, int eleventh, int twelfth, int thirteenth, int fourteenth, std::string text, int fifteenth ); + int Run() override; + void TargetActorByAid(int aid); void Slot7(int value) override; void PlaceWindowAtActor(UIWindow* window, CGameActor* actor); void ReceiveSummonHpInit(const unsigned char* buffer); diff --git a/Source/Client/Mode/GameMode.cpp b/Source/Client/Mode/GameMode.cpp index 9ed0ef04..7f5e1599 100644 --- a/Source/Client/Mode/GameMode.cpp +++ b/Source/Client/Mode/GameMode.cpp @@ -1496,3 +1496,96 @@ void CPingLiveSchedule::Process(const std::uint64_t& now) { GetRagConnection().Send(sizeof(packet), &packet); } } + +#include "Client/Application/ApplicationWindow.h" +#include "Client/Mode/CLoginMode.h" +#include "Client/ModeFadeOut.h" +#include "Render/DeviceContext/DCSurface.h" +#include "Render/RenderSystemBase.h" +#include "Resource/ResourceMgr.h" +#include "Security/NProtectGameGuardMgr.h" +#include "Utility/Cipher/XorBytes.h" + +namespace { + +template +class GameModeEncryptedName { +public: + explicit GameModeEncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = source[index]; + } + } + + ~GameModeEncryptedName() { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = 0; + } + } + + const char* Text() { + if (this->m_encrypted) { + utility::XorBytes(this->m_text, Length, Key); + this->m_encrypted = false; + } + + return reinterpret_cast(this->m_text); + } + +private: + /* 0000 */ std::uint8_t m_text[Length]; + bool m_encrypted; +}; + +} + +// OFFSET: 0x00CDEF00 +// FUNCTION: fn_21322 +int CGameMode::Run() { + while (this->running) { + if (g_modalImmediate) { + break; + } + + if (g_windowMgr.modalWindows.empty() || g_windowMgr.modalWindows.back() == nullptr) { + if (!g_windowMgr.persistentWindows.empty()) { + if (g_windowMgr.retainedPersistentWindow) { + for (UIWindow* window : g_windowMgr.persistentWindows) { + g_windowMgr.Schedule(window); + } + g_windowMgr.retainedPersistentWindow = false; + } + g_windowMgr.persistentWindows.clear(); + } + + if (this->pendingCursorType != -1) { + this->cursorType = this->pendingCursorType; + this->cursorFrame = 0; + this->pendingCursorType = -1; + this->Slot7(this->cursorType); + } + } + + if (g_nProtectGameGuardMgr->HasError()) { + GetRagConnection().Close(); + g_modeMgr.Quit(); + std::string message = g_nProtectGameGuardMgr->ErrorMessage(); + if (!message.empty()) { + const std::uint8_t source[] = {0x53, 0x11, 0xF9, 0xA6, 0x8D, 0x7E, 0xA6, 0xD9, 0x1D, 0x06, + 0xEA, 0xA4, 0x9C, 0x5C, 0xB0, 0xCC, 0x4F, 0x25, 0x8B}; + thread_local GameModeEncryptedName name(source); + MessageBoxA(hWnd, message.c_str(), name.Text(), 0); + } + } + + this->Update(); + Sleep(1); + } + + FadeOutMode(*g_renderer, *GetRenderSystemHolder()->system, ResourceMgr::Instance(), 0, false, 0.0f, 0.0f); + return 1; +} + +#include "Client/Input/Mouse.h" + +// OFFSET: 0x00CDFC40