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,