mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
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>
122 lines
3.3 KiB
C++
122 lines
3.3 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
TEST(LUString33Test, SerializeWriteTestOld) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 33; i++) testString += "a";
|
|
for (const auto& c : testString) bitStream.Write(c);
|
|
std::string result;
|
|
char c;
|
|
while (bitStream.Read(c)) result += c;
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeWriteTestOldPartial) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 15; i++) testString += "a";
|
|
for (const auto& c : testString) bitStream.Write(c);
|
|
for (int i = 0; i < 18; i++) bitStream.Write<char>(0);
|
|
std::string result;
|
|
char c;
|
|
int nulls = 18;
|
|
while (bitStream.Read(c)){
|
|
if (c == 0) {
|
|
nulls--;
|
|
continue;
|
|
}
|
|
result += c;
|
|
}
|
|
ASSERT_EQ(nulls, 0);
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeWriteTestNew) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 33; i++) testString += "a";
|
|
bitStream.Write(LUString(testString, 33));
|
|
std::string result;
|
|
char c;
|
|
while (bitStream.Read(c)) result += c;
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeWriteTestNewPartial) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 15; i++) testString += "a";
|
|
bitStream.Write(LUString(testString, 33));
|
|
std::string result;
|
|
char c;
|
|
int nulls = 18;
|
|
while (bitStream.Read(c)){
|
|
if (c == 0) {
|
|
nulls--;
|
|
continue;
|
|
}
|
|
result += c;
|
|
}
|
|
ASSERT_EQ(nulls, 0);
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeReadTestOld) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 33; i++) testString += "a";
|
|
for (const auto& c : testString) bitStream.Write(c);
|
|
std::string result;
|
|
char c;
|
|
while (bitStream.Read(c)) result += c;
|
|
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeReadTestOldPartial) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 15; i++) testString += "a";
|
|
for (const auto& c : testString) bitStream.Write(c);
|
|
for (int i = 0; i < 18; i++) bitStream.Write<char>(0);
|
|
std::string result;
|
|
char c;
|
|
int nulls = 18;
|
|
while (bitStream.Read(c)){
|
|
if (c == 0) {
|
|
nulls--;
|
|
continue;
|
|
}
|
|
result += c;
|
|
}
|
|
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
|
ASSERT_EQ(nulls, 0);
|
|
ASSERT_EQ(result, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeReadTestNew) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 33; i++) testString += "a";
|
|
bitStream.Write(LUString(testString, 33));
|
|
LUString result;
|
|
ASSERT_EQ(result.size, 33);
|
|
ASSERT_TRUE(bitStream.Read(result));
|
|
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
|
ASSERT_EQ(result.string, testString);
|
|
}
|
|
|
|
TEST(LUString33Test, SerializeReadTestNewPartial) {
|
|
RakNet::BitStream bitStream;
|
|
std::string testString;
|
|
for (int i = 0; i < 15; i++) testString += "a";
|
|
bitStream.Write(LUString(testString, 33));
|
|
LUString result;
|
|
ASSERT_EQ(result.size, 33);
|
|
ASSERT_TRUE(bitStream.Read(result));
|
|
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 0);
|
|
ASSERT_EQ(result.string, testString);
|
|
}
|