From a919a57e5e2f77da8d93c034f7c151955afb494e Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 30 Sep 2026 04:30:24 -0500 Subject: [PATCH] test(master): server list outdated flags Co-Authored-By: Claude Opus 5.5 --- .../dNetTests/MasterPacketsTests.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/dGameTests/dNetTests/MasterPacketsTests.cpp b/tests/dGameTests/dNetTests/MasterPacketsTests.cpp index f268acded..8b87c8240 100644 --- a/tests/dGameTests/dNetTests/MasterPacketsTests.cpp +++ b/tests/dGameTests/dNetTests/MasterPacketsTests.cpp @@ -371,6 +371,7 @@ TEST(MasterPacketsTests, ServerListMatchesLegacy) { entry.port = instance.port; entry.isPrivate = instance.isPrivate ? 1 : 0; entry.state = static_cast(i % 3); + entry.outdated = i == 1 ? 1 : 0; } response.ugcEnabled = 1; response.ugcOnline = count % 2; @@ -400,6 +401,7 @@ TEST(MasterPacketsTests, ServerListMatchesLegacy) { b.Write(3000 + i); b.Write(LUString(i == 2 ? "192.168.1.20" : "localhost")); } + for (size_t i = 0; i < count; i++) b.Write(i == 1 ? 1 : 0); // each world's outdated flag }), StructPacket(response)); RakNet::BitStream stream; LoadPayload(stream, response); @@ -412,6 +414,7 @@ TEST(MasterPacketsTests, ServerListMatchesLegacy) { EXPECT_EQ(legacy.instances[i].ip, copy.instances[i].ip.string); EXPECT_EQ(legacy.instances[i].isPrivate, copy.instances[i].isPrivate != 0); EXPECT_EQ(static_cast(copy.instances[i].state), i % 3); + EXPECT_EQ(copy.instances[i].outdated, i == 1 ? 1 : 0); } EXPECT_EQ(copy.ugcEnabled, 1); EXPECT_EQ(copy.ugcOnline, count % 2); @@ -659,3 +662,26 @@ TEST(MasterPacketsTests, WorldFilesStatus) { EXPECT_EQ(read.watchSeconds, 5); EXPECT_EQ(read.zones, status.zones); } + +// A master without the outdated flags (written after the endpoints) still reads: nothing is outdated +TEST(MasterPacketsTests, ServerListWithoutOutdatedFlags) { + MasterPackets::ServerListResponse response; + auto& entry = response.instances.emplace_back(); + entry.mapID = 1150; + entry.cloneID = 42; + entry.outdated = 1; + RakNet::BitStream full; + response.Serialize(full); + // Drop the last byte (the one flag) + RakNet::BitStream older; + older.Write(full.GetData(), static_cast(full.GetNumberOfBytesUsed() - 1)); + MasterPackets::ServerListResponse read; + ASSERT_TRUE(read.Deserialize(older)); + ASSERT_EQ(read.instances.size(), 1u); + EXPECT_EQ(read.instances[0].outdated, 0); + RakNet::BitStream again; + response.Serialize(again); + MasterPackets::ServerListResponse withFlag; + ASSERT_TRUE(withFlag.Deserialize(again)); + EXPECT_EQ(withFlag.instances[0].outdated, 1); +}