fix: saving gm invis for non gms (#1940)

This commit is contained in:
David Markowitz
2025-11-18 20:04:07 -08:00
committed by GitHub
parent ea86a708e4
commit a713216540
2 changed files with 4 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ public:
std::string& GetSessionKey() { return m_SessionKey; }
SystemAddress& GetSystemAddress() { return m_SystemAddress; }
eGameMasterLevel GetMaxGMLevel() { return m_MaxGMLevel; }
eGameMasterLevel GetMaxGMLevel() const { return m_MaxGMLevel; }
uint32_t GetLastCharID() { return m_LastCharID; }
void SetLastCharID(uint32_t newCharID) { m_LastCharID = newCharID; }

View File

@@ -12,7 +12,7 @@ GhostComponent::GhostComponent(Entity* parent, const int32_t componentID) : Comp
m_GhostReferencePoint = NiPoint3Constant::ZERO;
m_GhostOverridePoint = NiPoint3Constant::ZERO;
m_GhostOverride = false;
RegisterMsg<GameMessages::ToggleGMInvis>(this, &GhostComponent::OnToggleGMInvis);
RegisterMsg<GameMessages::GetGMInvis>(this, &GhostComponent::OnGetGMInvis);
RegisterMsg<GameMessages::GetObjectReportInfo>(this, &GhostComponent::MsgGetObjectReportInfo);
@@ -43,7 +43,8 @@ void GhostComponent::UpdateXml(tinyxml2::XMLDocument& doc) {
auto* ghstElement = objElement->FirstChildElement("ghst");
if (ghstElement) objElement->DeleteChild(ghstElement);
// Only save if GM invisible
if (!m_IsGMInvisible) return;
const auto* const user = UserManager::Instance()->GetUser(m_Parent->GetSystemAddress());
if (!m_IsGMInvisible || !user || user->GetMaxGMLevel() < eGameMasterLevel::FORUM_MODERATOR) return;
ghstElement = objElement->InsertNewChildElement("ghst");
if (ghstElement) ghstElement->SetAttribute("i", m_IsGMInvisible);
}