diff --git a/Source/Client/Application/ApplicationMessages.cpp b/Source/Client/Application/ApplicationMessages.cpp index c392c55b..229147d8 100644 --- a/Source/Client/Application/ApplicationMessages.cpp +++ b/Source/Client/Application/ApplicationMessages.cpp @@ -1,6 +1,7 @@ #include "Client/Application/ApplicationMessages.h" #include "Client/Application/ApplicationWindow.h" -#include "Client/Input/LanguageTC.h" +#include "Client/Application/Launcher.h" +#include "Client/Input/InputCharset.h" #include "Contents/Configuration/ServiceOptions.h" #include @@ -8,38 +9,36 @@ // OFFSET: 0x00E57380 // FUNCTION: fn_24357 -void ApplicationMessages::Pump() { +void PumpApplicationMessages() { MSG message; while (PeekMessageA(&message, nullptr, 0, 0, PM_REMOVE)) { if (message.message == WM_KEYDOWN && message.wParam == VK_PROCESSKEY) { - const UINT key = ImmGetVirtualKey(message.hwnd); - if (this->traditional) { - this->traditional->Key(static_cast(key)); - } + typedef void(__thiscall * KeyHandler)(InputCharset*, UINT); + (*reinterpret_cast(g_serverLanguage))[3](g_serverLanguage, ImmGetVirtualKey(message.hwnd)); } TranslateMessage(&message); DispatchMessageA(&message); } - if (this->dragging == 1) { + if (g_windowDragging == true) { POINT point; GetCursorPos(&point); - const int deltaX = point.x - this->dragStart.x; - const int deltaY = point.y - this->dragStart.y; + const int deltaX = point.x - g_windowDragStart.x; + const int deltaY = point.y - g_windowDragStart.y; if (deltaX != 0 || deltaY != 0) { MoveWindow( - this->window, this->dragRectangle.left + deltaX, this->dragRectangle.top + deltaY, this->dragRectangle.right - this->dragRectangle.left, - this->dragRectangle.bottom - this->dragRectangle.top, TRUE + hWnd, g_windowDragRect.left + deltaX, g_windowDragRect.top + deltaY, g_windowDragRect.right - g_windowDragRect.left, + g_windowDragRect.bottom - g_windowDragRect.top, TRUE ); } if ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) == 0) { - this->dragging = 0; - if (this->service.Get(ServiceOption::ConfineCursor) != 0) { - ClipApplicationCursor(this->window); + g_windowDragging = false; + if (g_serviceOptions.Get(ServiceOption::ConfineCursor) != 0) { + ClipApplicationCursor(hWnd); } } } diff --git a/Source/Client/Application/ApplicationMessages.h b/Source/Client/Application/ApplicationMessages.h index f98b857d..12da5728 100644 --- a/Source/Client/Application/ApplicationMessages.h +++ b/Source/Client/Application/ApplicationMessages.h @@ -1,20 +1,6 @@ #ifndef RAGNAROK_SOURCE_CLIENT_APPLICATION_APPLICATIONMESSAGES_H #define RAGNAROK_SOURCE_CLIENT_APPLICATION_APPLICATIONMESSAGES_H -#include - -struct CLanguageTC; -struct ServiceOptions; - -struct ApplicationMessages { - HWND& window; - unsigned char& dragging; - POINT& dragStart; - RECT& dragRectangle; - CLanguageTC* const& traditional; - ServiceOptions& service; - - void Pump(); -}; +void PumpApplicationMessages(); #endif diff --git a/Source/Client/Application/Launcher.h b/Source/Client/Application/Launcher.h index 3465b71c..29ec3e24 100644 --- a/Source/Client/Application/Launcher.h +++ b/Source/Client/Application/Launcher.h @@ -19,6 +19,9 @@ extern char g_launchAccountName[0x1F4]; extern char g_launchAccountPassword[24]; extern char g_launchAccountSex; extern bool g_launchPassCommandLine; +extern bool g_windowDragging; +extern RECT g_windowDragRect; +extern POINT g_windowDragStart; __declspec(noinline) HANDLE StartClientProcess(char* program); diff --git a/Source/Client/Mode/CMode.h b/Source/Client/Mode/CMode.h index 43995468..caae93cc 100644 --- a/Source/Client/Mode/CMode.h +++ b/Source/Client/Mode/CMode.h @@ -15,7 +15,7 @@ public: /* 0004 */ int cursorType; /* 0008 */ std::uint32_t cursorFrame; /* 000C */ int pendingCursorType; - /* 0010 */ int unknown_0010; + /* 0010 */ int fadeInRequested; /* 0014 */ int running; /* 0018 */ int unknown_0018; /* 001C */ UIWindow* tooltip; @@ -42,6 +42,7 @@ public: std::uint32_t ClearTooltip(); void TakeScreenshot(); void DrawCursor(); + void DrawFadeIn(); void DrawTexture(const tagRECT& rect, int angle, float rhw, std::uint32_t color, CTexture* texture, TextureRegion region); }; diff --git a/Source/Client/Mode/GameMode.cpp b/Source/Client/Mode/GameMode.cpp index 04092aa1..5a1b45d9 100644 --- a/Source/Client/Mode/GameMode.cpp +++ b/Source/Client/Mode/GameMode.cpp @@ -3366,7 +3366,7 @@ void CGameMode::InitializeState() { g_navigationManager.UpdateGround(); g_overrideColor = 0; - this->unknown_0010 = 1; + this->fadeInRequested = 1; this->cursorOffsetX = 0.0f; this->cursorOffsetY = 0.0f; *reinterpret_cast(this->unknown_00D8) = 0; diff --git a/Source/Client/Mode/LoginMode.cpp b/Source/Client/Mode/LoginMode.cpp index 789edfc0..e7685ac5 100644 --- a/Source/Client/Mode/LoginMode.cpp +++ b/Source/Client/Mode/LoginMode.cpp @@ -5,7 +5,6 @@ #include "Client/Application/Launcher.h" #include "Archive/PakRegistry.h" #include "Client/Input/Mouse.h" -#include "Client/ModeFade.h" #include "Client/Stove/StoveMgr.h" #include "Client/ModeFadeOut.h" #include "Client/Application/ErrorDialog.h" @@ -49,7 +48,6 @@ #include "UI/Window/UINewSelectCharWnd.h" #include "UI/Window/UISelCharForUServerWnd.h" #include "UI/Window/WindowDialogs.h" -#include "UI/Window/WindowFrameUpdate.h" #include "Utility/Async/NAsyncWorkMgr.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/GGHashMgr.h" @@ -318,7 +316,6 @@ int g_restoreSurfaces; // GLOBAL: gl_25384 int g_isAppActive; -void sub_E57380(); int sub_C7F5A0(); static_assert(sizeof(CharacterSlotsPacket) == 0x1D); @@ -987,7 +984,7 @@ void CLoginMode::Slot5(int value) { GetRagConnection().UpdateStatus(); } - reinterpret_cast(this)->Pump(); + PumpApplicationMessages(); this->PollNetworkStatus(); SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast(&GetRagConnection()), g_session.m_aid); g_mouse.Update(); @@ -1011,7 +1008,7 @@ void CLoginMode::Slot5(int value) { if (sub_C7F5A0()) { g_renderer->ClearDepth(1); - reinterpret_cast(&g_windowMgr)->Update(); + g_windowMgr.UpdateFrameWindows(); if (g_serviceType == 0 || g_serviceType == 4 || g_serviceType == 8 || g_serviceType == 9 || g_serviceType == 3 || g_serviceType == 10 || g_serviceType == 1 || g_serviceType == 11 || g_serviceType == 12 || g_serviceType == 5 || g_serviceType == 7 || g_serviceType == 14 || g_serviceType == 20) { @@ -1024,7 +1021,7 @@ void CLoginMode::Slot5(int value) { } g_windowMgr.DrawWindows(); this->DrawCursor(); - reinterpret_cast(this)->Draw(); + this->DrawFadeIn(); if (g_renderer->Draw()) { g_renderer->Present(1); } @@ -1130,7 +1127,7 @@ void CLoginMode::SubD97B20(int) { // OFFSET: 0x00D97D30 // FUNCTION: fn_22305 void CLoginMode::Update() { - reinterpret_cast(this)->Pump(); + PumpApplicationMessages(); this->PollNetworkStatus(); SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast(&GetRagConnection()), g_session.m_aid); g_mouse.Update(); @@ -1161,7 +1158,7 @@ void CLoginMode::Update() { if (sub_C7F5A0()) { g_renderer->ClearDepth(1); - reinterpret_cast(&g_windowMgr)->Update(); + g_windowMgr.UpdateFrameWindows(); if (g_serviceType == 0 || g_serviceType == 4 || g_serviceType == 8 || g_serviceType == 9 || g_serviceType == 3 || g_serviceType == 10 || g_serviceType == 1 || g_serviceType == 11 || g_serviceType == 12 || g_serviceType == 5 || g_serviceType == 7 || g_serviceType == 14 || g_serviceType == 20 || g_serviceType == 15) { @@ -1174,7 +1171,7 @@ void CLoginMode::Update() { } g_windowMgr.DrawWindows(); this->DrawCursor(); - reinterpret_cast(this)->Draw(); + this->DrawFadeIn(); g_renderer->Draw(); g_renderer->Present(1); } @@ -2277,7 +2274,7 @@ void CLoginMode::ShowLoginError(int code, int argument) { // OFFSET: 0x00D8C6A0 // FUNCTION: fn_22258 CLoginMode::CLoginMode() : wallpaperName(), unknown_6F1C(), unknown_6F2C(), unknown_6F38(), unknown_6F50(), mapStates() { - this->unknown_0010 = 1; + this->fadeInRequested = 1; this->unknown_6F10 = timeGetTime() + 12000; this->savedInlineCharset = g_inlineCharset; g_inlineCharset = 0; diff --git a/Source/Client/Mode/ModeCursor.cpp b/Source/Client/Mode/ModeCursor.cpp index fb54db8c..b136c680 100644 --- a/Source/Client/Mode/ModeCursor.cpp +++ b/Source/Client/Mode/ModeCursor.cpp @@ -21,7 +21,7 @@ CMode::CMode() { this->screenshotRequested = 0; this->cursorOffsetX = 0.0f; this->cursorOffsetY = 0.0f; - this->unknown_0010 = 0; + this->fadeInRequested = 0; } // OFFSET: 0x00AD75E0 diff --git a/Source/Client/ModeFade.cpp b/Source/Client/ModeFade.cpp index 273a09e7..a24a5871 100644 --- a/Source/Client/ModeFade.cpp +++ b/Source/Client/ModeFade.cpp @@ -1,6 +1,9 @@ #include "Client/ModeFade.h" +#include "Client/Mode/CMode.h" #include "Contents/Sound/SoundMgr.h" #include "Render/Primitives/AlphaRectangle.h" +#include "Render/Renderer.h" +#include "Render/TextureQuad.h" #include @@ -9,18 +12,18 @@ std::uint32_t g_modeFadeTick = 0; // OFFSET: 0x00AD6740 // FUNCTION: fn_17842 -void ModeFade::Draw() { - if (this->requested != 0) { +void CMode::DrawFadeIn() { + if (this->fadeInRequested != 0) { g_modeFadeTick = timeGetTime(); g_soundMgr->FadeIn(); - this->requested = 0; + this->fadeInRequested = 0; } const std::uint32_t elapsed = timeGetTime() - g_modeFadeTick; if (elapsed < 255) { DrawAlphaRectangle( - this->primitives, this->queues, 0, 0, this->screenWidth, this->screenHeight, (255 - elapsed) << 24, this->depthAlpha, this->depthStart, - this->depthEnd + g_renderer->primitives, g_renderer->queues, 0, 0, g_renderer->viewport.width, g_renderer->viewport.height, (255 - elapsed) << 24, + g_renderer->fog.supported != 0, g_depthStart, g_depthEnd ); } } diff --git a/Source/Client/ModeFade.h b/Source/Client/ModeFade.h index 60d9f589..9e8cac5b 100644 --- a/Source/Client/ModeFade.h +++ b/Source/Client/ModeFade.h @@ -3,23 +3,6 @@ #include -class RenderPrimitivePool; -class TextureCache; -struct RenderQueues; - extern std::uint32_t g_modeFadeTick; -struct ModeFade { - int& requested; - RenderPrimitivePool& primitives; - RenderQueues& queues; - const int& screenWidth; - const int& screenHeight; - const bool& depthAlpha; - const float& depthStart; - const float& depthEnd; - - void Draw(); -}; - #endif diff --git a/Source/Contents/World/WorldModelLoading.cpp b/Source/Contents/World/WorldModelLoading.cpp index 7a375e19..4f1c78a4 100644 --- a/Source/Contents/World/WorldModelLoading.cpp +++ b/Source/Contents/World/WorldModelLoading.cpp @@ -1,3 +1,4 @@ +#include "Client/Application/ApplicationMessages.h" #include "Contents/Models/ModelActor.h" #include "Contents/Ground/TerrainHeight.h" #include "Contents/World/WorldModelLoading.h" @@ -27,7 +28,6 @@ #include #include -void sub_E57380(); // GLOBAL: gl_24754 float g_worldLightDirection[3]; @@ -326,7 +326,7 @@ void CWorld::InitWorld() { if (g_renderer->Draw()) { g_renderer->Present(0); } - sub_E57380(); + PumpApplicationMessages(); } reinterpret_cast(g_modeMgr.GetGameMode()) diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index a9f5fec9..c683bb42 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -483,6 +483,7 @@ public: void ClearWindow01B8(); void ClearUnknown04DC(); int ProcessMouse(); + void UpdateFrameWindows(); bool CloseWindow(int id); void CloseWindowExcept251(int id); void RecordWindowPacket(int argument); diff --git a/Source/UI/Window/WindowFrameUpdate.cpp b/Source/UI/Window/WindowFrameUpdate.cpp index 9aabc542..042f614c 100644 --- a/Source/UI/Window/WindowFrameUpdate.cpp +++ b/Source/UI/Window/WindowFrameUpdate.cpp @@ -1,21 +1,20 @@ -#include "Client/Browser/BrowserRegistry.h" #include "Client/Browser/WebBrowser.h" #include "UI/Window/UIWindow.h" -#include "UI/Window/WindowFrameUpdate.h" +#include "UI/Window/UIWindowMgr.h" // OFFSET: 0x00AA26C0 // FUNCTION: fn_17215 -void WindowFrameUpdate::Update() { +void UIWindowMgr::UpdateFrameWindows() { for (auto window = this->rendered.begin(); window != this->rendered.end(); ++window) { (*window)->Slot19(); } - for (auto browser = this->browsers.browsers.begin(); browser != this->browsers.browsers.end();) { + for (auto browser = this->browsers.begin(); browser != this->browsers.end();) { if (browser->second) { browser->second->Poll(); } - if (this->browsers.browsers.empty()) { + if (this->browsers.empty()) { break; }