feat(master): an edit mode flag on a private instance, down to its world server

CreatePrivateZone carries editMode as one more byte, written only when set, so
a plain private zone is sent as before. Master keeps it on the instance, starts
the world server with -editmode 1, and gives a private instance's replacement
(a reload or a live update) the same flag. Nothing sets it yet.

A capped string now skips the characters it cut, so what follows it is read
from the right place. A request to join a private instance that is still
starting is answered once its world server is ready, instead of at once with
an address nothing listens on yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 17:34:13 -06:00
parent 78b2c0f406
commit 4cf0909d52
12 changed files with 68 additions and 14 deletions

View File

@@ -237,6 +237,32 @@ TEST(MasterPacketsTests, PrivateZonesMatchLegacy) {
}
}
// The edit mode flag of a private zone: one more byte, only when set, and read after a password of any length
TEST(MasterPacketsTests, CreatePrivateZoneEditMode) {
for (const auto& password : g_Strings) {
MasterPackets::CreatePrivateZone plain;
plain.zoneID = 1100;
plain.password = password;
MasterPackets::CreatePrivateZone edit = plain;
edit.editMode = 1;
RakNet::BitStream plainStream; LoadPayload(plainStream, plain);
RakNet::BitStream editStream; LoadPayload(editStream, edit);
EXPECT_EQ(editStream.GetNumberOfUnreadBits(), plainStream.GetNumberOfUnreadBits() + 8);
MasterPackets::CreatePrivateZone readPlain;
readPlain.editMode = 1;
ASSERT_TRUE(readPlain.Deserialize(plainStream));
EXPECT_EQ(readPlain.editMode, 0);
MasterPackets::CreatePrivateZone readEdit;
ASSERT_TRUE(readEdit.Deserialize(editStream));
EXPECT_EQ(readEdit.editMode, 1);
EXPECT_EQ(readEdit.zoneID, 1100u);
EXPECT_EQ(readEdit.password, password.substr(0, MasterPackets::CreatePrivateZone::MAX_PASSWORD_LENGTH));
}
}
TEST(MasterPacketsTests, WorldStateMatchesLegacy) {
for (const LWOMAPID zone : { static_cast<LWOMAPID>(0), static_cast<LWOMAPID>(1100), static_cast<LWOMAPID>(0xFFFF) }) {
for (const LWOINSTANCEID instance : { static_cast<LWOINSTANCEID>(0), static_cast<LWOINSTANCEID>(3), static_cast<LWOINSTANCEID>(0xFFFF) }) {