Maintenance: [forced, admin decision] Resubmission of returned batch 10026 rebased on c246e79d: also renames the CMode+0x10 write in

Batch #10033 by ragnarok-clanker: forced by an admin (0 lower score(s), 6 changed function(s)); checked with 479 compiled unit(s), including every includer of Source/Client/Application/ApplicationMessages.h, Source/Client/Application/Launcher.h, Source/Client/Mode/CMode.h, Source/Client/ModeFade.h, Source/UI/Window/UIWindowMgr.h.
This commit is contained in:
ragnarok-clanker 2026-11-02 14:34:46 +00:00
commit 30cdd441a1
12 changed files with 43 additions and 71 deletions

View file

@ -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 <cstdint>
@ -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<int>(key));
}
typedef void(__thiscall * KeyHandler)(InputCharset*, UINT);
(*reinterpret_cast<KeyHandler**>(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);
}
}
}

View file

@ -1,20 +1,6 @@
#ifndef RAGNAROK_SOURCE_CLIENT_APPLICATION_APPLICATIONMESSAGES_H
#define RAGNAROK_SOURCE_CLIENT_APPLICATION_APPLICATIONMESSAGES_H
#include <windows.h>
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

View file

@ -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);

View file

@ -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);
};

View file

@ -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<int*>(this->unknown_00D8) = 0;

View file

@ -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<ApplicationMessages*>(this)->Pump();
PumpApplicationMessages();
this->PollNetworkStatus();
SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast<const PacketLengths*>(&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<WindowFrameUpdate*>(&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<ModeFade*>(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<ApplicationMessages*>(this)->Pump();
PumpApplicationMessages();
this->PollNetworkStatus();
SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast<const PacketLengths*>(&GetRagConnection()), g_session.m_aid);
g_mouse.Update();
@ -1161,7 +1158,7 @@ void CLoginMode::Update() {
if (sub_C7F5A0()) {
g_renderer->ClearDepth(1);
reinterpret_cast<WindowFrameUpdate*>(&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<ModeFade*>(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;

View file

@ -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

View file

@ -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 <timeapi.h>
@ -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
);
}
}

View file

@ -3,23 +3,6 @@
#include <cstdint>
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

View file

@ -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 <timeapi.h>
#include <windows.h>
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<const ::TerrainHeight*>(g_modeMgr.GetGameMode())

View file

@ -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);

View file

@ -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;
}