feat(Core/Player): Implement commentator tag (#17449)
* feat(Core/Player): Implement commentator tag * remove redundant session check
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
--
|
||||||
|
DELETE FROM `command` WHERE `name`='commentator';
|
||||||
|
INSERT INTO `command` (`name`, `security`, `help`) VALUES ('commentator', 2, 'Syntax: .commentator [on/off]\r\n\r\nEnable or Disable in game Commentator tag or show current state if on/off not provided.');
|
||||||
@@ -1294,6 +1294,8 @@ 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 (IsCommentator())
|
||||||
|
tag |= CHAT_TAG_COM;
|
||||||
if (IsDeveloper())
|
if (IsDeveloper())
|
||||||
tag |= CHAT_TAG_DEV;
|
tag |= CHAT_TAG_DEV;
|
||||||
|
|
||||||
|
|||||||
@@ -839,7 +839,7 @@ enum PlayerChatTag
|
|||||||
CHAT_TAG_AFK = 0x01,
|
CHAT_TAG_AFK = 0x01,
|
||||||
CHAT_TAG_DND = 0x02,
|
CHAT_TAG_DND = 0x02,
|
||||||
CHAT_TAG_GM = 0x04,
|
CHAT_TAG_GM = 0x04,
|
||||||
CHAT_TAG_COM = 0x08, // Commentator
|
CHAT_TAG_COM = 0x08, // Commentator tag. Do not exist in clean client
|
||||||
CHAT_TAG_DEV = 0x10,
|
CHAT_TAG_DEV = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1139,6 +1139,8 @@ public:
|
|||||||
void SendTaxiNodeStatusMultiple();
|
void SendTaxiNodeStatusMultiple();
|
||||||
// mount_id can be used in scripting calls
|
// mount_id can be used in scripting calls
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsCommentator() const { return HasPlayerFlag(PLAYER_FLAGS_COMMENTATOR2); }
|
||||||
|
void SetCommentator(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_COMMENTATOR2, on); }
|
||||||
[[nodiscard]] bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
|
[[nodiscard]] bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
|
||||||
void SetDeveloper(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER, on); }
|
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; }
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ public:
|
|||||||
{
|
{
|
||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
{
|
{
|
||||||
|
{ "commentator", HandleCommentatorCommand, SEC_MODERATOR, Console::No },
|
||||||
{ "dev", HandleDevCommand, SEC_ADMINISTRATOR, Console::No },
|
{ "dev", HandleDevCommand, SEC_ADMINISTRATOR, Console::No },
|
||||||
{ "gps", HandleGPSCommand, SEC_MODERATOR, Console::No },
|
{ "gps", HandleGPSCommand, SEC_MODERATOR, Console::No },
|
||||||
{ "aura", HandleAuraCommand, SEC_GAMEMASTER, Console::No },
|
{ "aura", HandleAuraCommand, SEC_GAMEMASTER, Console::No },
|
||||||
@@ -451,6 +452,51 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HandleCommentatorCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||||
|
{
|
||||||
|
WorldSession* session = handler->GetSession();
|
||||||
|
|
||||||
|
if (!session)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto SetCommentatorMod = [&](bool enable)
|
||||||
|
{
|
||||||
|
session->SendNotification(enable ? "Commentator mode on" : "Commentator mode off");
|
||||||
|
session->GetPlayer()->SetCommentator(enable);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!enableArg)
|
||||||
|
{
|
||||||
|
if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsCommentator())
|
||||||
|
{
|
||||||
|
SetCommentatorMod(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetCommentatorMod(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*enableArg)
|
||||||
|
{
|
||||||
|
SetCommentatorMod(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetCommentatorMod(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
handler->SendSysMessage(LANG_USE_BOL);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool HandleDevCommand(ChatHandler* handler, Optional<bool> enableArg)
|
static bool HandleDevCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||||
{
|
{
|
||||||
WorldSession* session = handler->GetSession();
|
WorldSession* session = handler->GetSession();
|
||||||
@@ -467,32 +513,29 @@ public:
|
|||||||
sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable);
|
sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (WorldSession* session = handler->GetSession())
|
if (!enableArg)
|
||||||
{
|
{
|
||||||
if (!enableArg)
|
if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsDeveloper())
|
||||||
{
|
|
||||||
if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->IsDeveloper())
|
|
||||||
{
|
|
||||||
SetDevMod(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetDevMod(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*enableArg)
|
|
||||||
{
|
{
|
||||||
SetDevMod(true);
|
SetDevMod(true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetDevMod(false);
|
SetDevMod(false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*enableArg)
|
||||||
|
{
|
||||||
|
SetDevMod(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetDevMod(false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handler->SendSysMessage(LANG_USE_BOL);
|
handler->SendSysMessage(LANG_USE_BOL);
|
||||||
|
|||||||
Reference in New Issue
Block a user