feat(world): the game client's level editor packets

A world server answers the client's level editor: it remembers per connection
whether the editor is on (and never sends such a client a zone load), takes and
gives up the zone's lock, says whether files may be sent, takes them, sends the
zone's files, and reloads the zone. Who may is the same as for the dashboard's zone
file API: the account's editor level against zone_publish_gm_level, the zone's
editors or an admin, and the lock's holder to send files. Files are unpacked,
checked, written and packed on a worker thread, and every request is in the audit
log.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 19:11:29 -06:00
parent e50a2255f8
commit b5de6cf2c9
12 changed files with 1076 additions and 6 deletions

View File

@@ -1146,4 +1146,55 @@ namespace ClientPackets {
}
return true;
}
void SlashPushMapResponse::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(result);
bitStream.Write(fileType);
bitStream.Write(levelFileId);
for (const char16_t character : lockedBy) {
if (character == u'\0') break;
bitStream.Write<uint16_t>(character);
}
bitStream.Write<uint16_t>(0);
}
bool SlashPushMapResponse::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(result));
VALIDATE_READ(bitStream.Read(fileType));
VALIDATE_READ(bitStream.Read(levelFileId));
lockedBy.clear();
for (uint16_t character = 0; ;) {
VALIDATE_READ(bitStream.Read(character));
if (character == 0) break;
lockedBy += static_cast<char16_t>(character);
}
return true;
}
void SlashPullMapResponse::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(fileType);
bitStream.Write(levelFileId);
bitStream.Write(packedFiles.data(), static_cast<uint32_t>(packedFiles.size()));
}
bool SlashPullMapResponse::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(fileType));
VALIDATE_READ(bitStream.Read(levelFileId));
packedFiles.resize(BITS_TO_BYTES(bitStream.GetNumberOfUnreadBits()));
if (!packedFiles.empty()) VALIDATE_READ(bitStream.Read(packedFiles.data(), static_cast<uint32_t>(packedFiles.size())));
return true;
}
void SlashLockMapResponse::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(result);
bitStream.Write(lockedBy);
bitStream.Write(locked);
}
bool SlashLockMapResponse::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(result));
VALIDATE_READ(bitStream.Read(lockedBy));
VALIDATE_READ(bitStream.Read(locked));
return true;
}
}

View File

@@ -705,6 +705,53 @@ namespace ClientPackets {
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
/**
* Answers to the client's level editor (docs/ZonePublish.md). result: 0 allowed, 1 the account's editor level is
* too low, 2 the account is not one of the zone's editors, 3 another account holds the zone's lock (lockedBy
* says who), 4 nothing changed (lock answers only).
*/
// Server -> client. The zone is about to be reloaded from its files. No payload.
struct ImpendingReloadNotify : public LUBitStream {
ImpendingReloadNotify() : LUBitStream(ServiceType::CLIENT, MessageType::Client::IMPENDING_RELOAD_NOTIFY) {}
};
// Server -> client. Whether the client may send the files it asked to (it then sends them when result is 0).
struct SlashPushMapResponse : public LUBitStream {
uint8_t result{};
uint8_t fileType{}; // as asked
int32_t levelFileId{}; // as asked
// Written as UTF-16 characters and a null
std::u16string lockedBy{};
SlashPushMapResponse() : LUBitStream(ServiceType::CLIENT, MessageType::Client::SLASH_PUSH_MAP_RESPONSE) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Server -> client. The zone's files the client asked for (ZoneFilePack).
struct SlashPullMapResponse : public LUBitStream {
uint8_t fileType{};
int32_t levelFileId{};
// Everything after the level file ID
std::string packedFiles{};
SlashPullMapResponse() : LUBitStream(ServiceType::CLIENT, MessageType::Client::SLASH_PULL_MAP_RESPONSE) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Server -> client. How taking or giving up the zone's lock went, and whether the client holds it now.
struct SlashLockMapResponse : public LUBitStream {
uint8_t result{};
LUWString lockedBy{ 33 };
uint8_t locked{};
SlashLockMapResponse() : LUBitStream(ServiceType::CLIENT, MessageType::Client::SLASH_LOCK_MAP_RESPONSE) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
}
#endif // CLIENTPACKETS_H

View File

@@ -89,6 +89,10 @@ json ToJson(const ClientPackets::GuildRemovePlayer& m);
json ToJson(const ClientPackets::GuildLoginLogout& m);
json ToJson(const ClientPackets::GuildData& m);
json ToJson(const ClientPackets::GuildData::Member& m);
json ToJson(const ClientPackets::ImpendingReloadNotify& m);
json ToJson(const ClientPackets::SlashPushMapResponse& m);
json ToJson(const ClientPackets::SlashPullMapResponse& m);
json ToJson(const ClientPackets::SlashLockMapResponse& m);
json ToJson(const CommonPackets::ClientVersionConfirm& m);
json ToJson(const CommonPackets::ServerVersionConfirm& m);
json ToJson(const CommonPackets::DisconnectNotify& m);
@@ -141,6 +145,12 @@ json ToJson(const WorldPackets::HandleFunness& m);
json ToJson(const WorldPackets::RequestUgcManifestInfo& m);
json ToJson(const WorldPackets::UgcDownloadFailed& m);
json ToJson(const WorldPackets::UIHelpTop5& m);
json ToJson(const WorldPackets::HappyFlowerModeNotify& m);
json ToJson(const WorldPackets::SlashReloadMap& m);
json ToJson(const WorldPackets::SlashPushMapRequest& m);
json ToJson(const WorldPackets::SlashPushMap& m);
json ToJson(const WorldPackets::SlashPullMap& m);
json ToJson(const WorldPackets::LockMapRequest& m);
json ToJson(const ChatPackets::WorldRoutePacket& m);
json ToJson(const CDClientReload& m);
json ToJson(const PlayerPositions& m);
@@ -909,6 +919,32 @@ json ToJson(const ClientPackets::GuildData::Member& m) {
j["name"] = ToJson(m.name);
return j;
}
json ToJson(const ClientPackets::ImpendingReloadNotify& m) {
json j = json::object();
return j;
}
json ToJson(const ClientPackets::SlashPushMapResponse& m) {
json j = json::object();
j["result"] = ToJson(m.result);
j["fileType"] = ToJson(m.fileType);
j["levelFileId"] = ToJson(m.levelFileId);
j["lockedBy"] = ToJson(m.lockedBy);
return j;
}
json ToJson(const ClientPackets::SlashPullMapResponse& m) {
json j = json::object();
j["fileType"] = ToJson(m.fileType);
j["levelFileId"] = ToJson(m.levelFileId);
j["packedFiles"] = ToJson(m.packedFiles);
return j;
}
json ToJson(const ClientPackets::SlashLockMapResponse& m) {
json j = json::object();
j["result"] = ToJson(m.result);
j["lockedBy"] = ToJson(m.lockedBy);
j["locked"] = ToJson(m.locked);
return j;
}
json ToJson(const CommonPackets::ClientVersionConfirm& m) {
json j = json::object();
j["netVersion"] = ToJson(m.netVersion);
@@ -1254,6 +1290,39 @@ json ToJson(const WorldPackets::UIHelpTop5& m) {
j["language"] = ToJson(m.language);
return j;
}
json ToJson(const WorldPackets::HappyFlowerModeNotify& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
j["on"] = ToJson(m.on);
return j;
}
json ToJson(const WorldPackets::SlashReloadMap& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
return j;
}
json ToJson(const WorldPackets::SlashPushMapRequest& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
j["fileType"] = ToJson(m.fileType);
j["levelFileId"] = ToJson(m.levelFileId);
return j;
}
json ToJson(const WorldPackets::SlashPushMap& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
j["fileType"] = ToJson(m.fileType);
j["levelFileId"] = ToJson(m.levelFileId);
j["packedFiles"] = ToJson(m.packedFiles);
return j;
}
json ToJson(const WorldPackets::SlashPullMap& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
j["fileType"] = ToJson(m.fileType);
j["levelFileId"] = ToJson(m.levelFileId);
return j;
}
json ToJson(const WorldPackets::LockMapRequest& m) {
json j = ToJson(static_cast<const WorldPackets::WorldLUBitStream&>(m));
j["lock"] = ToJson(m.lock);
return j;
}
json ToJson(const ChatPackets::WorldRoutePacket& m) {
json j = json::object();
j["targetID"] = ToJson(m.targetID);
@@ -1873,6 +1942,10 @@ const std::vector<Entry>& Entries() {
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::GUILD_REMOVE_PLAYER), "GuildRemovePlayer", false, &ReadWith<ClientPackets::GuildRemovePlayer> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::GUILD_LOGIN_LOGOUT), "GuildLoginLogout", false, &ReadWith<ClientPackets::GuildLoginLogout> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::GUILD_DATA), "GuildData", false, &ReadWith<ClientPackets::GuildData> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::IMPENDING_RELOAD_NOTIFY), "ImpendingReloadNotify", false, &ReadWith<ClientPackets::ImpendingReloadNotify> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::SLASH_PUSH_MAP_RESPONSE), "SlashPushMapResponse", false, &ReadWith<ClientPackets::SlashPushMapResponse> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::SLASH_PULL_MAP_RESPONSE), "SlashPullMapResponse", false, &ReadWith<ClientPackets::SlashPullMapResponse> },
{ ServiceType::CLIENT, static_cast<uint32_t>(MessageType::Client::SLASH_LOCK_MAP_RESPONSE), "SlashLockMapResponse", false, &ReadWith<ClientPackets::SlashLockMapResponse> },
{ ServiceType::COMMON, static_cast<uint32_t>(MessageType::Server::VERSION_CONFIRM), "ClientVersionConfirm", true, &ReadWith<CommonPackets::ClientVersionConfirm> },
{ ServiceType::COMMON, static_cast<uint32_t>(MessageType::Server::VERSION_CONFIRM), "ServerVersionConfirm", false, &ReadWith<CommonPackets::ServerVersionConfirm> },
{ ServiceType::COMMON, static_cast<uint32_t>(MessageType::Server::DISCONNECT_NOTIFY), "DisconnectNotify", false, &ReadWith<CommonPackets::DisconnectNotify> },
@@ -1920,6 +1993,12 @@ const std::vector<Entry>& Entries() {
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::REQUEST_UGC_MANIFEST_INFO), "RequestUgcManifestInfo", false, &ReadWith<WorldPackets::RequestUgcManifestInfo> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::UGC_DOWNLOAD_FAILED), "UgcDownloadFailed", false, &ReadWith<WorldPackets::UgcDownloadFailed> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::UI_HELP_TOP_5), "UIHelpTop5", false, &ReadWith<WorldPackets::UIHelpTop5> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::HAPPY_FLOWER_MODE_NOTIFY), "HappyFlowerModeNotify", false, &ReadWith<WorldPackets::HappyFlowerModeNotify> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::SLASH_RELOAD_MAP), "SlashReloadMap", false, &ReadWith<WorldPackets::SlashReloadMap> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::SLASH_PUSH_MAP_REQUEST), "SlashPushMapRequest", false, &ReadWith<WorldPackets::SlashPushMapRequest> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::SLASH_PUSH_MAP), "SlashPushMap", false, &ReadWith<WorldPackets::SlashPushMap> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::SLASH_PULL_MAP), "SlashPullMap", false, &ReadWith<WorldPackets::SlashPullMap> },
{ ServiceType::WORLD, static_cast<uint32_t>(MessageType::World::LOCK_MAP_REQUEST), "LockMapRequest", false, &ReadWith<WorldPackets::LockMapRequest> },
{ ServiceType::CHAT, static_cast<uint32_t>(MessageType::Chat::WORLD_ROUTE_PACKET), "WorldRoutePacket", false, &ReadWith<ChatPackets::WorldRoutePacket> },
{ ServiceType::MASTER, static_cast<uint32_t>(MessageType::Master::CDCLIENT_RELOAD), "CDClientReload", false, &ReadWith<CDClientReload> },
{ ServiceType::MASTER, static_cast<uint32_t>(MessageType::Master::PLAYER_POSITIONS), "PlayerPositions", false, &ReadWith<PlayerPositions> },

View File

@@ -400,4 +400,58 @@ namespace WorldPackets {
VALIDATE_READ(bitStream.Read(language));
return true;
}
void HappyFlowerModeNotify::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(on);
}
bool HappyFlowerModeNotify::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(on));
return true;
}
void SlashPushMapRequest::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(fileType);
bitStream.Write(levelFileId);
}
bool SlashPushMapRequest::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(fileType));
VALIDATE_READ(bitStream.Read(levelFileId));
return true;
}
void SlashPushMap::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(fileType);
bitStream.Write(levelFileId);
bitStream.Write(packedFiles.data(), static_cast<uint32_t>(packedFiles.size()));
}
bool SlashPushMap::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(fileType));
VALIDATE_READ(bitStream.Read(levelFileId));
packedFiles.resize(BITS_TO_BYTES(bitStream.GetNumberOfUnreadBits()));
if (!packedFiles.empty()) VALIDATE_READ(bitStream.Read(packedFiles.data(), static_cast<uint32_t>(packedFiles.size())));
return true;
}
void SlashPullMap::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(fileType);
bitStream.Write(levelFileId);
}
bool SlashPullMap::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(fileType));
VALIDATE_READ(bitStream.Read(levelFileId));
return true;
}
void LockMapRequest::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(lock);
}
bool LockMapRequest::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(lock));
return true;
}
}

View File

@@ -255,6 +255,66 @@ namespace WorldPackets {
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
/**
* The client's level editor (docs/ZonePublish.md). fileType: 0 the whole map, 1 a scene, 2 the terrain, 3 the zone
* file, 4 a scene's triggers; levelFileId names the scene for 1 and 4 and means nothing for the others.
*/
// Client -> server. The client's level editor was started (1) or ended (0). Not answered.
struct HappyFlowerModeNotify : public WorldLUBitStream {
uint8_t on{};
HappyFlowerModeNotify() : WorldLUBitStream(MessageType::World::HAPPY_FLOWER_MODE_NOTIFY) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server. Reload the zone from its files. No payload.
struct SlashReloadMap : public WorldLUBitStream {
SlashReloadMap() : WorldLUBitStream(MessageType::World::SLASH_RELOAD_MAP) {}
};
// Client -> server. Asks whether it may send the zone's files; answered with ClientPackets::SlashPushMapResponse.
struct SlashPushMapRequest : public WorldLUBitStream {
uint8_t fileType{};
int32_t levelFileId{};
SlashPushMapRequest() : WorldLUBitStream(MessageType::World::SLASH_PUSH_MAP_REQUEST) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server. The zone's files (ZoneFilePack), sent after a push request was answered with 0.
struct SlashPushMap : public WorldLUBitStream {
uint8_t fileType{};
int32_t levelFileId{};
// Everything after the level file ID, as sent
std::string packedFiles{};
SlashPushMap() : WorldLUBitStream(MessageType::World::SLASH_PUSH_MAP) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server. Asks for the zone's files; answered with ClientPackets::SlashPullMapResponse.
struct SlashPullMap : public WorldLUBitStream {
uint8_t fileType{};
int32_t levelFileId{};
SlashPullMap() : WorldLUBitStream(MessageType::World::SLASH_PULL_MAP) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
// Client -> server. Take (1) or give up (0) the zone's edit lock; answered with ClientPackets::SlashLockMapResponse.
struct LockMapRequest : public WorldLUBitStream {
uint8_t lock{};
LockMapRequest() : WorldLUBitStream(MessageType::World::LOCK_MAP_REQUEST) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
};
}
#endif // WORLDPACKETS_H