Skip to content

Instantly share code, notes, and snippets.

@Salja
Last active August 29, 2015 14:09
Show Gist options
  • Save Salja/3ca2a9a39c4763a8f534 to your computer and use it in GitHub Desktop.
Save Salja/3ca2a9a39c4763a8f534 to your computer and use it in GitHub Desktop.
GameMaster Color Chat System Version 1.0
diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
index 9af048a..d94409a 100644
--- a/src/game/ChatHandler.cpp
+++ b/src/game/ChatHandler.cpp
@@ -24,6 +24,7 @@
#include "Opcodes.h"
#include "ObjectMgr.h"
#include "Chat.h"
+#include "Config/Config.h"
#include "Database/DatabaseEnv.h"
#include "ChannelMgr.h"
#include "Group.h"
@@ -182,18 +183,27 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (type == CHAT_MSG_SAY)
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
return;
GetPlayer()->Say(msg, lang);
}
else if (type == CHAT_MSG_EMOTE)
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
if (!sEluna->OnChat(GetPlayer(), type, LANG_UNIVERSAL, msg))
return;
GetPlayer()->TextEmote(msg);
}
else if (type == CHAT_MSG_YELL)
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
return;
GetPlayer()->Yell(msg, lang);
@@ -236,6 +246,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
}
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
sEluna->OnChat(GetPlayer(), type, lang, msg, player);
GetPlayer()->Whisper(msg, lang, player->GetObjectGuid());
@@ -267,6 +280,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
return;
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -297,6 +313,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (GetPlayer()->GetGuildId())
if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()))
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
return;
@@ -326,6 +345,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (GetPlayer()->GetGuildId())
if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()))
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
return;
@@ -361,6 +383,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
return;
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -395,6 +420,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
return;
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -420,6 +448,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
!(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid())))
return;
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -446,6 +477,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (!group || !group->isBGGroup())
return;
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -471,6 +505,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid()))
return;
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
return;
@@ -495,6 +532,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if (Channel* chn = cMgr->GetChannel(channel, _player))
{
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg, chn))
return;
@@ -527,6 +567,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
_player->ToggleAFK();
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
return;
@@ -555,6 +598,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
_player->ToggleDND();
}
+ if (GetPlayer()->isGMChat() && sWorld.getConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED) && !msg.empty())
+ msg = sConfig.GetStringDefault("GM.ChatColor", "") + msg + "|r";
+
// used by eluna
if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
return;
diff --git a/src/game/World.cpp b/src/game/World.cpp
index c509454..91879b9 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -871,6 +871,8 @@ void World::LoadConfigSettings(bool reload)
MMAP::MMapFactory::preventPathfindingOnMaps(ignoreMapIds.c_str());
sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
+ setConfig(CONFIG_BOOL_GM_CHAT_COLOR_ENABLED, "GM.ChatColor.Enabled", false);
+
setConfig(CONFIG_BOOL_ELUNA_ENABLED, "Eluna.Enabled", true);
if (reload)
diff --git a/src/game/World.h b/src/game/World.h
index 2d6651e..71be3b2 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -327,6 +327,7 @@ enum eConfigBoolValues
CONFIG_BOOL_VMAP_INDOOR_CHECK,
CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT,
CONFIG_BOOL_MMAP_ENABLED,
+ CONFIG_BOOL_GM_CHAT_COLOR_ENABLED,
CONFIG_BOOL_ELUNA_ENABLED,
CONFIG_BOOL_PLAYER_COMMANDS,
CONFIG_BOOL_VALUE_COUNT
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 7b6e228..05f7787 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1117,6 +1117,13 @@ Channel.SilentlyGMJoin = 0
# Default: 37800 (50% Transparency)
# 0 (Disabled)
#
+# GM.ChatColor.Enabled
+# Default: 0 (disable)
+# 1 (enable)
+#
+# GM.ChatColor
+# Default: "|cff2998ff"
+#
###################################################################################################################
GM.LoginState = 2
@@ -1130,6 +1137,8 @@ GM.LogTrade = 1
GM.StartLevel = 1
GM.LowerSecurity = 0
GM.InvisibleAura = 37800
+GM.ChatColor.Enabled = 0
+GM.ChatColor = "|cff2998ff"
###################################################################################################################
# VISIBILITY AND RADIUSES
@Salja
Copy link
Author

Salja commented Nov 10, 2014

GameMaster_Color_Chat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment