fix(character): GetEditorLevel is a local message of the client

GetEditorLevel (627) is one the client only sends to its own objects: its
character component answers it, and the message is never written to or
read from the network. The world no longer reads it from a client or
sends an answer. The editor level still reaches the client with the
character and in its save.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-11 07:01:43 -06:00
parent 260fe08508
commit 132a4a31a6
6 changed files with 2 additions and 62 deletions

View File

@@ -205,7 +205,6 @@ json ToJson(const GameMessages::ReportBug& m);
json ToJson(const GameMessages::VerifyAck& m);
json ToJson(const GameMessages::Help& m);
json ToJson(const GameMessages::DisplayGuildCreateBox& m);
json ToJson(const GameMessages::GetEditorLevel& m);
json ToJson(const GameMessages::OpenPropertyVendor& m);
json ToJson(const GameMessages::OpenPropertyManagement& m);
json ToJson(const GameMessages::DownloadPropertyData& m);
@@ -1815,12 +1814,6 @@ json ToJson(const GameMessages::DisplayGuildCreateBox& m) {
j["bShow"] = ToJson(m.bShow);
return j;
}
json ToJson(const GameMessages::GetEditorLevel& m) {
json j = json::object();
j["editorEnabled"] = ToJson(m.editorEnabled);
j["editorLevel"] = ToJson(m.editorLevel);
return j;
}
json ToJson(const GameMessages::OpenPropertyVendor& m) {
json j = json::object();
return j;
@@ -2751,7 +2744,6 @@ const std::vector<Entry>& Entries() {
{ MessageType::Game::VERIFY_ACK, eDirection::TO_CLIENT, "VerifyAck", &ReadWith<GameMessages::VerifyAck> },
{ MessageType::Game::HELP, eDirection::TO_CLIENT, "Help", &ReadWith<GameMessages::Help> },
{ MessageType::Game::DISPLAY_GUILD_CREATE_BOX, eDirection::TO_CLIENT, "DisplayGuildCreateBox", &ReadWith<GameMessages::DisplayGuildCreateBox> },
{ MessageType::Game::GET_EDITOR_LEVEL, eDirection::TO_SERVER, "GetEditorLevel", &ReadWith<GameMessages::GetEditorLevel> },
{ MessageType::Game::OPEN_PROPERTY_VENDOR, eDirection::TO_CLIENT, "OpenPropertyVendor", &ReadWith<GameMessages::OpenPropertyVendor> },
{ MessageType::Game::OPEN_PROPERTY_MANAGEMENT, eDirection::TO_CLIENT, "OpenPropertyManagement", &ReadWith<GameMessages::OpenPropertyManagement> },
{ MessageType::Game::DOWNLOAD_PROPERTY_DATA, eDirection::TO_CLIENT, "DownloadPropertyData", &ReadWith<GameMessages::DownloadPropertyData> },

View File

@@ -225,7 +225,6 @@ namespace {
{ TOGGLE_GHOST_REFERENCE_OVERRIDE, []() { return std::make_unique<ToggleGhostReferenceOverride>(); } },
{ SET_GHOST_REFERENCE_POSITION, []() { return std::make_unique<SetGhostReferencePosition>(); } },
{ MODIFY_GHOSTING_DISTANCE, []() { return std::make_unique<ModifyGhostingDistance>(); } },
{ GET_EDITOR_LEVEL, []() { return std::make_unique<GetEditorLevel>(); } },
};
};

View File

@@ -267,28 +267,4 @@ namespace GameMessages {
bool DisplayGuildCreateBox::Deserialize(RakNet::BitStream& bitStream) {
return bitStream.Read(bShow);
}
void GetEditorLevel::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(editorEnabled);
bitStream.Write(editorLevel);
}
bool GetEditorLevel::Deserialize(RakNet::BitStream& bitStream) {
// A question: whatever it carries is not needed to answer it
if (bitStream.GetNumberOfUnreadBits() < 33) return true;
return bitStream.Read(editorEnabled) && bitStream.Read(editorLevel);
}
void GetEditorLevel::Handle(Entity& entity, const SystemAddress& sysAddr) {
// Only about the asker's own character
auto* const player = PlayerManager::GetPlayer(sysAddr);
if (!player || player != &entity) return;
const auto* const character = entity.GetComponent<CharacterComponent>();
if (!character) return;
GetEditorLevel answer;
answer.target = entity.GetObjectID();
answer.editorEnabled = character->GetEditorEnabled();
answer.editorLevel = character->GetEditorLevel();
answer.SendToClient(sysAddr);
}
}

View File

@@ -193,18 +193,6 @@ namespace GameMessages {
bool bShow{ true };
};
// Client -> server, and the server's answer to that client: whether the client's level editor is on for the
// player and at which level (the character's editor level, 0 for none). What a client sends is not used.
struct GetEditorLevel : public NetGameMsg {
GetEditorLevel() : NetGameMsg(MessageType::Game::GET_EDITOR_LEVEL) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
bool editorEnabled{ false };
int32_t editorLevel{ 0 };
};
}
#endif // PLAYERMESSAGES_H

View File

@@ -158,4 +158,5 @@ answered as any other: its player is here, so the world is sent to it again. The
clients to the new instance as any world reload does; a client with its editor on loses its connection there.
A character's editor level is told to the client in the character's save (`edit`), with the character (the editor
flag and level after the GM level) and in answer to the GetEditorLevel game message.
flag and level after the GM level). GetEditorLevel (627) is one of the client's local messages, answered by its own
character component; it is never sent over the network.

View File

@@ -439,19 +439,3 @@ TEST_F(CharacterSaveFieldsTests, EditorLevelIsSerializedAfterTheGmLevel) {
EXPECT_EQ(gmBlock(eGameMasterLevel::CIVILIAN), (std::pair<bool, uint8_t>{ false, 0 }));
}
// GetEditorLevel's answer: one bit, then the level as 32 bits
TEST_F(CharacterSaveFieldsTests, GetEditorLevelAnswerLayout) {
GameMessages::GetEditorLevel answer;
answer.editorEnabled = true;
answer.editorLevel = 9;
RakNet::BitStream stream;
answer.Serialize(stream);
EXPECT_EQ(stream.GetNumberOfBitsUsed(), 33u);
GameMessages::GetEditorLevel read;
ASSERT_TRUE(read.Deserialize(stream));
EXPECT_TRUE(read.editorEnabled);
EXPECT_EQ(read.editorLevel, 9);
// A question with nothing in it reads too
RakNet::BitStream empty;
EXPECT_TRUE(GameMessages::GetEditorLevel().Deserialize(empty));
}