mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
feat(net): VERSION_CONFIRM carries the server's build identifier
After serviceType the reply now sends major, minor, patch, a flags byte (build kind in bits 0-1, dirty in bit 2), the first 32 bits of the commit hash and a u16 length-prefixed build string, instead of the stale fixed ASCII "0.1.3". unknown stays "DLU3". The 1.10.64 client reads only netVersion and serviceType and never checks the length, so the extra bytes are ignored. The build string is optional on read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,15 +52,32 @@ namespace CommonPackets {
|
||||
bitStream.Write(netVersion);
|
||||
bitStream.Write(unknown);
|
||||
bitStream.Write(serviceType);
|
||||
bitStream.Write(trailing);
|
||||
bitStream.Write(versionMajor);
|
||||
bitStream.Write(versionMinor);
|
||||
bitStream.Write(versionPatch);
|
||||
bitStream.Write(buildFlags);
|
||||
for (int shift = 24; shift >= 0; shift -= 8) bitStream.Write<uint8_t>(commitPrefix >> shift);
|
||||
BitStreamUtils::WriteLengthPrefixed<uint16_t>(bitStream, buildString);
|
||||
}
|
||||
|
||||
bool ServerVersionConfirm::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(netVersion));
|
||||
VALIDATE_READ(bitStream.Read(unknown));
|
||||
VALIDATE_READ(bitStream.Read(serviceType));
|
||||
VALIDATE_READ(bitStream.Read(trailing));
|
||||
return true;
|
||||
VALIDATE_READ(bitStream.Read(versionMajor));
|
||||
VALIDATE_READ(bitStream.Read(versionMinor));
|
||||
VALIDATE_READ(bitStream.Read(versionPatch));
|
||||
VALIDATE_READ(bitStream.Read(buildFlags));
|
||||
commitPrefix = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
uint8_t byte{};
|
||||
VALIDATE_READ(bitStream.Read(byte));
|
||||
commitPrefix = (commitPrefix << 8) | byte;
|
||||
}
|
||||
// Older DLU servers stop after the 12 fixed bytes.
|
||||
buildString.clear();
|
||||
if (bitStream.GetNumberOfUnreadBits() == 0) return true;
|
||||
return BitStreamUtils::ReadLengthPrefixed<uint16_t>(bitStream, buildString, MAX_BUILD_STRING_LENGTH);
|
||||
}
|
||||
|
||||
void DisconnectNotify::Serialize(RakNet::BitStream& bitStream) const {
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
#define COMMONPACKETS_H
|
||||
|
||||
#include "BitStreamUtils.h"
|
||||
#include "BuildInfo.h"
|
||||
#include "MessageType/Server.h"
|
||||
#include "RakNetTypes.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
enum class eServerDisconnectIdentifiers : uint32_t;
|
||||
|
||||
@@ -32,17 +34,27 @@ namespace CommonPackets {
|
||||
};
|
||||
|
||||
// Server -> client. The answer to ClientVersionConfirm.
|
||||
// The client (ServerHandShakePacket, 1.10.64) only reads netVersion, unknown and serviceType; the trailing
|
||||
// 8 bytes are what DLU has always sent after them.
|
||||
// The client (1.10.64, PacketHandler_MSG_SERVER_VERSION_CONFIRM) reads only netVersion and serviceType; it never
|
||||
// reads unknown and ignores anything after serviceType (no length check). DLU uses those bytes to say which build
|
||||
// the server is:
|
||||
// u32 netVersion | u32 unknown ("DLU3") | u32 serviceType
|
||||
// | u8 major | u8 minor | u8 patch | u8 flags (bits 0-1 BuildInfo::eBuildKind, bit 2 dirty)
|
||||
// | 4 bytes: first 32 bits of the commit hash, in hash order (a hex dump shows the hash)
|
||||
// | u16 length + build string, e.g. "3.0.0-experimental+g1a2b3c4d-dirty" (optional on read)
|
||||
struct ServerVersionConfirm : public LUBitStream {
|
||||
static constexpr uint32_t DEFAULT_NET_VERSION = 171022;
|
||||
static constexpr uint32_t UNKNOWN_VALUE = 861228100;
|
||||
static constexpr uint64_t TRAILING_VALUE = 219818307120;
|
||||
static constexpr uint32_t UNKNOWN_VALUE = 861228100; // "DLU3"
|
||||
static constexpr uint32_t MAX_BUILD_STRING_LENGTH = 1024;
|
||||
|
||||
uint32_t netVersion = DEFAULT_NET_VERSION;
|
||||
uint32_t unknown = UNKNOWN_VALUE;
|
||||
uint32_t serviceType{}; // The server's ServiceType, written as 4 bytes
|
||||
uint64_t trailing = TRAILING_VALUE;
|
||||
uint8_t versionMajor = BuildInfo::versionMajor;
|
||||
uint8_t versionMinor = BuildInfo::versionMinor;
|
||||
uint8_t versionPatch = BuildInfo::versionPatch;
|
||||
uint8_t buildFlags = BuildInfo::Flags();
|
||||
uint32_t commitPrefix = BuildInfo::CommitPrefix();
|
||||
std::string buildString{ BuildInfo::buildString };
|
||||
|
||||
ServerVersionConfirm() : LUBitStream(ServiceType::COMMON, MessageType::Server::VERSION_CONFIRM) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
|
||||
Reference in New Issue
Block a user