mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-02 21:04:20 +00:00
feat: make gm registration simpler and safer (#1932)
* gm registration re-work * fix errors Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * remove duplicate message * Remove duplicate function * add null check --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -13,9 +13,9 @@ GhostComponent::GhostComponent(Entity* parent, const int32_t componentID) : Comp
|
||||
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);
|
||||
RegisterMsg(&GhostComponent::OnToggleGMInvis);
|
||||
RegisterMsg(&GhostComponent::OnGetGMInvis);
|
||||
RegisterMsg(&GhostComponent::MsgGetObjectReportInfo);
|
||||
}
|
||||
|
||||
GhostComponent::~GhostComponent() {
|
||||
@@ -88,15 +88,17 @@ void GhostComponent::GhostEntity(LWOOBJID id) {
|
||||
m_ObservedEntities.erase(id);
|
||||
}
|
||||
|
||||
bool GhostComponent::OnToggleGMInvis(GameMessages::GameMsg& msg) {
|
||||
// TODO: disabled for now while bugs are fixed
|
||||
return false;
|
||||
auto& gmInvisMsg = static_cast<GameMessages::ToggleGMInvis&>(msg);
|
||||
bool GhostComponent::OnToggleGMInvis(GameMessages::ToggleGMInvis& gmInvisMsg) {
|
||||
gmInvisMsg.bStateOut = !m_IsGMInvisible;
|
||||
m_IsGMInvisible = !m_IsGMInvisible;
|
||||
LOG_DEBUG("GM Invisibility toggled to: %s", m_IsGMInvisible ? "true" : "false");
|
||||
gmInvisMsg.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
auto* thisUser = UserManager::Instance()->GetUser(m_Parent->GetSystemAddress());
|
||||
if (!thisUser) {
|
||||
LOG("Unable to find user for entity %llu when toggling GM invisibility!", m_Parent->GetObjectID());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& player : PlayerManager::GetAllPlayers()) {
|
||||
if (!player || player->GetObjectID() == m_Parent->GetObjectID()) continue;
|
||||
auto* toUser = UserManager::Instance()->GetUser(player->GetSystemAddress());
|
||||
@@ -117,9 +119,8 @@ bool GhostComponent::OnToggleGMInvis(GameMessages::GameMsg& msg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GhostComponent::OnGetGMInvis(GameMessages::GameMsg& msg) {
|
||||
bool GhostComponent::OnGetGMInvis(GameMessages::GetGMInvis& gmInvisMsg) {
|
||||
LOG_DEBUG("GM Invisibility requested: %s", m_IsGMInvisible ? "true" : "false");
|
||||
auto& gmInvisMsg = static_cast<GameMessages::GetGMInvis&>(msg);
|
||||
// TODO: disabled for now while bugs are fixed
|
||||
// gmInvisMsg.bGMInvis = m_IsGMInvisible;
|
||||
// return gmInvisMsg.bGMInvis;
|
||||
@@ -127,8 +128,7 @@ bool GhostComponent::OnGetGMInvis(GameMessages::GameMsg& msg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GhostComponent::MsgGetObjectReportInfo(GameMessages::GameMsg& msg) {
|
||||
auto& reportMsg = static_cast<GameMessages::GetObjectReportInfo&>(msg);
|
||||
bool GhostComponent::MsgGetObjectReportInfo(GameMessages::GetObjectReportInfo& reportMsg) {
|
||||
auto& cmptType = reportMsg.info->PushDebug("Ghost");
|
||||
cmptType.PushDebug<AMFIntValue>("Component ID") = GetComponentID();
|
||||
cmptType.PushDebug<AMFBoolValue>("Is GM Invis") = false;
|
||||
|
||||
Reference in New Issue
Block a user