From 25e5bacc00d0a80506b6e63820e2b2ebc0540ae1 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 28 Oct 2026 19:10:27 +0000 Subject: [PATCH] Decompile fn_22268 (SendClientKeepalive) Batch #1568 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_22268 SendClientKeepalive: logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Network/ClientKeepalive.cpp --- Source/Network/ClientKeepalive.cpp | 32 ++++++++++++++++++++++++++++++ Source/Network/ClientKeepalive.h | 11 ++++++++++ data/compile.json | 1 + 3 files changed, 44 insertions(+) create mode 100644 Source/Network/ClientKeepalive.cpp create mode 100644 Source/Network/ClientKeepalive.h diff --git a/Source/Network/ClientKeepalive.cpp b/Source/Network/ClientKeepalive.cpp new file mode 100644 index 00000000..789fbba5 --- /dev/null +++ b/Source/Network/ClientKeepalive.cpp @@ -0,0 +1,32 @@ +#include "Network/ClientKeepalive.h" +#include "Network/Connection/Connection.h" +#include "Network/Packets/PacketLengths.h" + +#include + +namespace { +#pragma pack(push, 1) + struct KeepalivePacket { + /* 0000 */ std::int16_t id; + /* 0002 */ std::uint32_t accountId; + }; +#pragma pack(pop) + static_assert(sizeof(KeepalivePacket) == 6); +} + +// 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) { + return; + } + + if (timeGetTime() > nextPingTime) { + nextPingTime = timeGetTime() + 12000; + + KeepalivePacket packet; + packet.id = 0x0187; + packet.accountId = accountId; + connection.Send(lengths.FixedLength(packet.id), &packet); + } +} diff --git a/Source/Network/ClientKeepalive.h b/Source/Network/ClientKeepalive.h new file mode 100644 index 00000000..c04ef8cb --- /dev/null +++ b/Source/Network/ClientKeepalive.h @@ -0,0 +1,11 @@ +#ifndef RAGNAROK_SOURCE_NETWORK_CLIENTKEEPALIVE_H +#define RAGNAROK_SOURCE_NETWORK_CLIENTKEEPALIVE_H + +#include + +class CConnection; +class PacketLengths; + +void SendClientKeepalive(int subMode, std::uint32_t& nextPingTime, CConnection& connection, const PacketLengths& lengths, const std::uint32_t& accountId); + +#endif diff --git a/data/compile.json b/data/compile.json index a1eed001..63324a03 100644 --- a/data/compile.json +++ b/data/compile.json @@ -443,6 +443,7 @@ "Source/File/MapName.cpp": 1, "Source/File/ResourcePath.cpp": 1, "Source/File/ShortcutFilename.cpp": 1, + "Source/Network/ClientKeepalive.cpp": 0, "Source/Network/Connection/Connection.cpp": 0, "Source/Network/Connection/ConnectionBuffer.cpp": 0, "Source/Network/Connection/ConnectionRuntime.cpp": 0,