mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 01:35:27 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user