mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-29 07:57:14 +00:00
refactor: remove the packet macros, WriteHeader and PacketUtils
Nothing in the server writes or reads a packet by hand any more, so the helpers for doing so go: - CBITSTREAM, CMSGHEADER, CINSTREAM, CINSTREAM_SKIP_HEADER, SEND_PACKET, SEND_PACKET_BROADCAST and HEADER_SIZE leave dCommonVars.h; - the free BitStreamUtils::WriteHeader (LUBitStream::WriteHeader writes the same bytes) and the unused PacketUtils::SavePacket are deleted. The last raw reads are replaced: WorldServer builds its input stream directly, the master packet logs read the header with LUBitStream::ReadHeader instead of peeking at packet->data[1] and [3], and MessageInspector reads a sent game message's header with the new NetGameMsg::ReadPacketHeader (the counterpart of WritePacket) instead of memcmp/memcpy. packet->data[0] is still compared with RakNet's own connection IDs. The frozen oracles keep using the macros verbatim through the test-only tests/dGameTests/LegacyPacketMacros.h; the HeaderSkip tests, which only tested CINSTREAM_SKIP_HEADER, are removed. docs/PacketArchitecture.md: "where we are" now describes the final state and what still touches raw bytes (RakNet IDs, replica headers, behavior bit streams), and a new section collects the known wire discrepancies found during the conversion, with client addresses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// The byte-equality tests send the same inputs through these and through the new structs and require
|
||||
// identical bytes, so the wire format is pinned even after the production code is deleted.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// were inline in HandleUnUseModel, HandleBBBSaveRequest and WorldServer's level load, wrapped in a function; the
|
||||
// Read* functions are the read sequences of the replaced GameMessages::Handle* functions.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions, verbatim up to
|
||||
// the point where the handler starts using what it read.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// (dGame/dGameMessages/GameMessages.cpp, branched from origin/main 129199e4). Only the namespace changed.
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "Amf3.h"
|
||||
#include "AmfSerialize.h"
|
||||
#include "BitStreamUtils.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions.
|
||||
// SendMoveInventoryBatch is not here: nothing called it, and MoveInventoryBatch follows the client's layout.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// (dGame/dGameMessages/GameMessages.cpp, branched from origin/main 129199e4). Only the namespace changed.
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// (dGame/dGameMessages/GameMessages.cpp, branched from origin/main 129199e4). Only the namespace changed.
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Brick.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// news screen's hot properties). Only the namespace changed. The Read* functions are the read sequences of the
|
||||
// replaced GameMessages::Handle* functions (and PlayerReports' report readers).
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDPropertyTemplateTable.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions, verbatim up to
|
||||
// the point where the handler starts using what it read.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// Each class's Serialize writes the message ID and then the payload; the old senders wrote the CLIENT/GAME_MSG
|
||||
// header and the target object ID before it. The Read* function is the read sequence of the replaced switch case.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BehaviorSlot.h"
|
||||
#include "BitStream.h"
|
||||
#include "BitStreamUtils.h"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// The Read* functions are the read sequences of the replaced GameMessages::Handle* functions, verbatim up to
|
||||
// the point where the handler starts using what it read.
|
||||
|
||||
#include "LegacyPacketMacros.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "dServer.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace {
|
||||
template<typename Legacy>
|
||||
PacketBytes LegacyPacket(LWOOBJID target, Legacy& legacy) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::CLIENT, MessageType::Client::GAME_MSG);
|
||||
LUBitStream(ServiceType::CLIENT, MessageType::Client::GAME_MSG).WriteHeader(bitStream);
|
||||
bitStream.Write(target);
|
||||
legacy.Serialize(bitStream);
|
||||
return FromBitStream(bitStream);
|
||||
@@ -262,7 +262,7 @@ TEST_F(SkillMessagesTests, EchoesBroadcastExceptTheCaster) {
|
||||
const auto caster = ClientAddress();
|
||||
const auto legacy = Capture([&] {
|
||||
RakNet::BitStream bitStreamLocal;
|
||||
BitStreamUtils::WriteHeader(bitStreamLocal, ServiceType::CLIENT, MessageType::Client::GAME_MSG);
|
||||
LUBitStream(ServiceType::CLIENT, MessageType::Client::GAME_MSG).WriteHeader(bitStreamLocal);
|
||||
bitStreamLocal.Write(echo.target);
|
||||
LegacyGameMessages::EchoSyncSkill legacyEcho("ab", 0, 0, true);
|
||||
legacyEcho.Serialize(bitStreamLocal);
|
||||
|
||||
Reference in New Issue
Block a user