Decompile fn_22266 (CLoginMode::SubD8D500)

Batch #13669 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_22266 CLoginMode::SubD8D500: logic confirmed by peer review

Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-06 21:14:57 +00:00
commit 2bf070d8cc
4 changed files with 58 additions and 50 deletions

View file

@ -98,6 +98,7 @@ class CLoginMode : public CMode {
public:
CLoginMode();
void SubD97780(int value);
void SendKeepalive();
/* 0058 */ int charParams[6];
/* 0070 */ int unknown_0070;
/* 0074 */ int unknown_0074;

View file

@ -30,7 +30,6 @@
#include "Contents/Schedule/PartialShutDownSchedule.h"
#include "Contents/Schedule/TimeScheduler.h"
#include "Contents/Sound/SoundMgr.h"
#include "Network/ClientKeepalive.h"
#include "Network/Connection/Connection.h"
#include "Network/Packets/PacketLengths.h"
#include "Render/DeviceContext/DCSurface.h"
@ -397,7 +396,6 @@ void CLoginMode::SubD8D4F0(int) {
// FUNCTION: fn_22266
void CLoginMode::SubD8D500(const char* packet) {
UIWindow* window = g_windowMgr.window_03D4;
int message;
switch (*reinterpret_cast<const int*>(packet + 2)) {
case 0:
g_windowMgr.Confirm(LookupMessage(0x4BE), 0, true, false, 0, "Message", 280, 120, 0);
@ -406,8 +404,10 @@ void CLoginMode::SubD8D500(const char* packet) {
}
return;
case 1:
message = 0x4C2;
break;
if (g_windowMgr.Confirm(LookupMessage(0x4C2), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
return;
case 2:
if (g_windowMgr.Confirm(LookupMessage(0x4C3), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
return;
@ -417,27 +417,46 @@ void CLoginMode::SubD8D500(const char* packet) {
}
return;
case 3:
message = 0x4BF;
break;
if (g_windowMgr.Confirm(LookupMessage(0x4BF), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
return;
case 4:
message = 0x4C4;
goto retry;
if (g_windowMgr.Confirm(LookupMessage(0x4C4), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
return;
}
if (window) {
window->SendMsg(nullptr, 6, 0x15F, 0, 0, 0);
}
return;
case 5:
message = 0x7E6;
break;
if (g_windowMgr.Confirm(LookupMessage(0x7E6), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
return;
case 6:
message = 0x7E7;
break;
if (g_windowMgr.Confirm(LookupMessage(0x7E7), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
return;
case 7:
message = 0x7EB;
goto retry;
if (g_windowMgr.Confirm(LookupMessage(0x7EB), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
return;
}
if (window) {
window->SendMsg(nullptr, 6, 0x15F, 0, 0, 0);
}
return;
case 8:
message = 0x7EC;
goto retry;
if (g_windowMgr.Confirm(LookupMessage(0x7EC), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
return;
}
if (window) {
window->SendMsg(nullptr, 6, 0x15F, 0, 0, 0);
}
return;
case 9:
message = 0x7ED;
retry:
if (g_windowMgr.Confirm(LookupMessage(message), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
if (g_windowMgr.Confirm(LookupMessage(0x7ED), 0, true, true, 0, "Message", 280, 120, 0) != 0xB8) {
return;
}
if (window) {
@ -445,15 +464,13 @@ void CLoginMode::SubD8D500(const char* packet) {
}
return;
case 10:
message = 0x7E8;
break;
if (g_windowMgr.Confirm(LookupMessage(0x7E8), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
return;
default:
return;
}
if (g_windowMgr.Confirm(LookupMessage(message), 0, true, true, 0, "Message", 280, 120, 0) == 0xB8 && g_windowMgr.window_03DC) {
g_windowMgr.CloseWindow(0x80);
}
}
// OFFSET: 0x00D8E1D0
@ -965,20 +982,15 @@ void CLoginMode::End() {
// OFFSET: 0x00D975C0
// FUNCTION: fn_22301
void CLoginMode::Slot5(int value) {
if (value == 0) {
if (this->running == 0) {
return;
}
if (g_modalImmediate != 0) {
return;
}
} else {
if (value != 0) {
GetRagConnection().UpdateStatus();
} else if (this->running == 0 || g_modalImmediate != 0) {
return;
}
PumpApplicationMessages();
this->PollNetworkStatus();
SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast<const PacketLengths*>(&GetRagConnection()), g_session.m_aid);
this->SendKeepalive();
g_mouse.Update();
g_windowMgr.ProcessMouse();
if (this->running != 0) {
@ -1121,7 +1133,7 @@ void CLoginMode::SubD97B20(int) {
void CLoginMode::Update() {
PumpApplicationMessages();
this->PollNetworkStatus();
SendClientKeepalive(this->cursorType, this->unknown_6F10, GetRagConnection(), *reinterpret_cast<const PacketLengths*>(&GetRagConnection()), g_session.m_aid);
this->SendKeepalive();
g_mouse.Update();
g_windowMgr.ProcessMouse();
if (this->running != 0) {
@ -1928,7 +1940,7 @@ char g_loginFailCount;
// OFFSET: 0x00D91790
// FUNCTION: fn_22289
void CLoginMode::ShowLoginError(int code, int argument) {
std::string message;
std::string message("");
if (code != 0x12) {
GetRagConnection().Close();
}

View file

@ -1,4 +1,5 @@
#include "Network/ClientKeepalive.h"
#include "Client/Mode/CLoginMode.h"
#include "Client/Session.h"
#include "Network/Connection/Connection.h"
#include "Network/Packets/PacketLengths.h"
@ -16,17 +17,18 @@ namespace {
// OFFSET: 0x00D8D960
// FUNCTION: fn_22268
void SendClientKeepalive(int subMode, std::uint32_t& nextPingTime, CConnection& connection, const PacketLengths& lengths, const std::uint32_t& accountId) {
if (subMode != 7 && subMode != 8 && subMode != 11 && subMode != 19) {
void CLoginMode::SendKeepalive() {
if (this->cursorType != 7 && this->cursorType != 8 && this->cursorType != 11 && this->cursorType != 19) {
return;
}
if (timeGetTime() > nextPingTime) {
nextPingTime = timeGetTime() + 12000;
if (timeGetTime() > this->unknown_6F10) {
this->unknown_6F10 = timeGetTime() + 12000;
KeepalivePacket packet;
packet.id = 0x0187;
packet.accountId = accountId;
connection.Send(lengths.FixedLength(packet.id), &packet);
packet.accountId = g_session.m_aid;
CRagConnection& connection = GetRagConnection();
connection.Send(reinterpret_cast<const PacketLengths*>(&GetRagConnection())->FixedLength(packet.id), &packet);
}
}

View file

@ -1,11 +1,4 @@
#ifndef RAGNAROK_SOURCE_NETWORK_CLIENTKEEPALIVE_H
#define RAGNAROK_SOURCE_NETWORK_CLIENTKEEPALIVE_H
#include <cstdint>
class CConnection;
class PacketLengths;
void SendClientKeepalive(int subMode, std::uint32_t& nextPingTime, CConnection& connection, const PacketLengths& lengths, const std::uint32_t& accountId);
#endif