refactor(Core/Player): add helper method for PLAYER_FLAGS_DEVELOPER (#4395)
Co-Authored-By: ForesterDev <11771800+ForesterDev@users.noreply.github.com>
This commit is contained in:
@@ -2210,7 +2210,7 @@ uint8 Player::GetChatTag() const
|
|||||||
tag |= CHAT_TAG_DND;
|
tag |= CHAT_TAG_DND;
|
||||||
if (isAFK())
|
if (isAFK())
|
||||||
tag |= CHAT_TAG_AFK;
|
tag |= CHAT_TAG_AFK;
|
||||||
if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
|
if (IsDeveloper())
|
||||||
tag |= CHAT_TAG_DEV;
|
tag |= CHAT_TAG_DEV;
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
|||||||
@@ -1173,6 +1173,9 @@ public:
|
|||||||
void CleanupAfterTaxiFlight();
|
void CleanupAfterTaxiFlight();
|
||||||
void ContinueTaxiFlight();
|
void ContinueTaxiFlight();
|
||||||
// mount_id can be used in scripting calls
|
// mount_id can be used in scripting calls
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsDeveloper() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); }
|
||||||
|
void SetDeveloper(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER, on); }
|
||||||
[[nodiscard]] bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
|
[[nodiscard]] bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; }
|
||||||
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
|
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
|
||||||
[[nodiscard]] bool IsGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
|
[[nodiscard]] bool IsGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
|
||||||
|
|||||||
@@ -331,29 +331,27 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleDevCommand(ChatHandler* handler, char const* args)
|
static bool HandleDevCommand(ChatHandler* handler, char const* enable)
|
||||||
{
|
{
|
||||||
if (!*args)
|
Player* player = handler->GetSession()->GetPlayer();
|
||||||
|
|
||||||
|
if (!*enable)
|
||||||
{
|
{
|
||||||
if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
|
handler->GetSession()->SendNotification(player->IsDeveloper() ? LANG_DEV_ON : LANG_DEV_OFF);
|
||||||
handler->GetSession()->SendNotification(LANG_DEV_ON);
|
|
||||||
else
|
|
||||||
handler->GetSession()->SendNotification(LANG_DEV_OFF);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string argstr = (char*)args;
|
std::string enablestr = (char*)enable;
|
||||||
|
|
||||||
if (argstr == "on")
|
if (enablestr == "on")
|
||||||
{
|
{
|
||||||
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
|
player->SetDeveloper(true);
|
||||||
handler->GetSession()->SendNotification(LANG_DEV_ON);
|
handler->GetSession()->SendNotification(LANG_DEV_ON);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (enablestr == "off")
|
||||||
if (argstr == "off")
|
|
||||||
{
|
{
|
||||||
handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
|
player->SetDeveloper(false);
|
||||||
handler->GetSession()->SendNotification(LANG_DEV_OFF);
|
handler->GetSession()->SendNotification(LANG_DEV_OFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public:
|
|||||||
|
|
||||||
if (handler->GetSession())
|
if (handler->GetSession())
|
||||||
if (Player* p = handler->GetSession()->GetPlayer())
|
if (Player* p = handler->GetSession()->GetPlayer())
|
||||||
if (p->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
|
if (p->IsDeveloper())
|
||||||
handler->PSendSysMessage("DEV wavg: %ums, nsmax: %ums, nsavg: %ums. LFG avg: %ums, max: %ums.", avgDiffTracker.getTimeWeightedAverage(), devDiffTracker.getMax(), devDiffTracker.getAverage(), lfgDiffTracker.getAverage(), lfgDiffTracker.getMax());
|
handler->PSendSysMessage("DEV wavg: %ums, nsmax: %ums, nsavg: %ums. LFG avg: %ums, max: %ums.", avgDiffTracker.getTimeWeightedAverage(), devDiffTracker.getMax(), devDiffTracker.getAverage(), lfgDiffTracker.getAverage(), lfgDiffTracker.getMax());
|
||||||
|
|
||||||
//! Can't use sWorld->ShutdownMsg here in case of console command
|
//! Can't use sWorld->ShutdownMsg here in case of console command
|
||||||
|
|||||||
Reference in New Issue
Block a user