feat(character): the editor level is the account's GM level, and the client is told it

A character's editor level is its account's GM level for accounts at editor_gm_level
or above, and 0 for everyone else (it was 1 or 0). It is written as the save's edit
attribute, sent with the character after the GM level (the editor flag, then the
level) and given in answer to the GetEditorLevel game message.

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 ca7d166c0b
commit dbe0722095
9 changed files with 139 additions and 35 deletions

View File

@@ -204,6 +204,7 @@ 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);
@@ -1806,6 +1807,12 @@ 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;
@@ -2724,6 +2731,7 @@ 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

@@ -222,6 +222,7 @@ 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>(); } },
};
};
@@ -270,8 +271,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
}
// The Happy Flower editor's messages, logged always until the server handles them (what a client sends while editing)
const bool isHappyFlower = messageID == MessageType::Game::GET_EDITOR_LEVEL
|| (messageID >= MessageType::Game::HF_ATTRIBUTES_PUSH && messageID <= MessageType::Game::HF_GETS_WANT_PATH);
const bool isHappyFlower = messageID >= MessageType::Game::HF_ATTRIBUTES_PUSH && messageID <= MessageType::Game::HF_GETS_WANT_PATH;
if (isHappyFlower) LOG("Received unhandled Happy Flower GM: %4i, %s", messageID, StringifiedEnum::ToString(messageID).data());
else LOG_DEBUG("Received Unknown GM with ID: %4i, %s", messageID, StringifiedEnum::ToString(messageID).data());
}

View File

@@ -1,5 +1,7 @@
#include "PlayerMessages.h"
#include "PlayerManager.h"
#include "Logger.h"
#include "BitStreamUtils.h"
#include "Character.h"
@@ -265,4 +267,28 @@ 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,6 +193,18 @@ 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