Permalink
Browse files

Core/Chat: Implement CMSG_MESSAGECHAT_ADDON_X depending on type

  • Loading branch information...
1 parent e16ac6f commit 7cc49aa0ab4b86260b0844b924f787ac63783c6e @DDuarte DDuarte committed Dec 21, 2011
View
138 src/server/game/Server/Protocol/Handlers/ChatHandler.cpp
@@ -63,12 +63,12 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
return true;
}
-void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
+void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
uint32 type = 0;
uint32 lang;
- switch(recv_data.GetOpcode())
+ switch(recvData.GetOpcode())
{
case CMSG_MESSAGECHAT_SAY:
type = CHAT_MSG_SAY;
@@ -119,17 +119,17 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
// type = CHAT_MSG_RAID_WARNING;
// break;
default:
- sLog->outDetail("HandleMessagechatOpcode : Unknown chat opcode (%u)", recv_data.GetOpcode());
- recv_data.hexlike();
+ sLog->outDetail("HandleMessagechatOpcode : Unknown chat opcode (%u)", recvData.GetOpcode());
+ recvData.hexlike();
return;
}
- recv_data >> lang;
+ recvData >> lang;
if (type >= MAX_CHAT_MSG_TYPE)
{
sLog->outError("CHAT: Wrong message type received: %u", type);
- recv_data.rfinish();
+ recvData.rfinish();
return;
}
@@ -142,7 +142,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
- recv_data.rfinish();
+ recvData.rfinish();
return;
}
if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id))
@@ -161,7 +161,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
- recv_data.rfinish();
+ recvData.rfinish();
return;
}
}
@@ -171,7 +171,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
{
std::string msg = "";
- recv_data >> msg;
+ recvData >> msg;
if (msg.empty())
return;
@@ -226,7 +226,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
{
std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
- recv_data.rfinish(); // Prevent warnings
+ recvData.rfinish(); // Prevent warnings
return;
}
@@ -237,7 +237,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER)
{
std::string msg="";
- recv_data >> msg;
+ recvData >> msg;
SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName());
return;
@@ -259,19 +259,19 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
case CHAT_MSG_RAID_WARNING:
case CHAT_MSG_BATTLEGROUND:
case CHAT_MSG_BATTLEGROUND_LEADER:
- recv_data >> msg;
+ recvData >> msg;
break;
case CHAT_MSG_WHISPER:
- recv_data >> to;
- recv_data >> msg;
+ recvData >> to;
+ recvData >> msg;
break;
case CHAT_MSG_CHANNEL:
- recv_data >> channel;
- recv_data >> msg;
+ recvData >> channel;
+ recvData >> msg;
break;
case CHAT_MSG_AFK:
case CHAT_MSG_DND:
- recv_data >> msg;
+ recvData >> msg;
ignoreChecks = true;
break;
}
@@ -534,6 +534,110 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
}
}
+void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recvData)
+{
+ Player* sender = GetPlayer();
+ ChatMsg type;
+
+ switch (recvData.GetOpcode())
+ {
+ case CMSG_MESSAGECHAT_ADDON_BATTLEGROUND:
+ type = CHAT_MSG_BATTLEGROUND;
+ break;
+ case CMSG_MESSAGECHAT_ADDON_GUILD:
+ type = CHAT_MSG_GUILD;
+ break;
+ case CMSG_MESSAGECHAT_ADDON_PARTY:
+ type = CHAT_MSG_PARTY;
+ break;
+ case CMSG_MESSAGECHAT_ADDON_RAID:
+ type = CHAT_MSG_RAID;
+ break;
+ case CMSG_MESSAGECHAT_ADDON_WHISPER:
+ type = CHAT_MSG_WHISPER;
+ break;
+ default:
+ sLog->outDetail("HandleAddonMessagechatOpcode: Unknown addon chat opcode (%u)", recvData.GetOpcode());
+ recvData.hexlike();
+ return;
+ }
+
+ std::string message = "";
+ std::string prefix = "";
+ std::string targetName = "";
+
+ if (type == CHAT_MSG_WHISPER)
+ recvData >> prefix >> targetName >> message;
+ else
+ recvData >> message >> prefix;
+
+ // Logging enabled?
+ if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
+ {
+ if (message.empty())
+ return;
+
+ // Weird way to log stuff...
+ sScriptMgr->OnPlayerChat(sender, CHAT_MSG_ADDON, LANG_ADDON, message);
+ }
+
+ // Disabled addon channel?
+ if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL))
+ return;
+
+ switch (type)
+ {
+ case CHAT_MSG_BATTLEGROUND:
+ {
+ Group* group = sender->GetGroup();
+ if (!group || !group->isBGGroup())
+ return;
+
+ WorldPacket data;
+ ChatHandler::FillMessageData(&data, this, type, LANG_ADDON, "", 0, message.c_str(), NULL);
+ group->BroadcastPacket(&data, false);
+ break;
+ }
+ case CHAT_MSG_GUILD:
+ {
+ if (sender->GetGuildId())
+ if (Guild* guild = sGuildMgr->GetGuildById(sender->GetGuildId()))
+ guild->BroadcastToGuild(this, false, message, LANG_ADDON);
+ break;
+ }
+ case CHAT_MSG_WHISPER:
+ {
+ if (!normalizePlayerName(targetName))
+ break;
+ Player* receiver = sObjectAccessor->FindPlayerByName(targetName.c_str());
+ if (!receiver)
+ break;
+
+ sender->Whisper(message, LANG_ADDON, receiver->GetGUID());
+ break;
+ }
+ // Messages sent to "RAID" while in a party will get delivered to "PARTY"
+ case CHAT_MSG_PARTY:
+ case CHAT_MSG_RAID:
+ {
+
+ Group* group = sender->GetGroup();
+ if (!group || group->isBGGroup())
+ break;
+
+ WorldPacket data;
+ ChatHandler::FillMessageData(&data, this, type, LANG_ADDON, "", 0, message.c_str(), NULL);
+ group->BroadcastPacket(&data, true, -1, group->GetMemberGroup(sender->GetGUID()));
+ break;
+ }
+ default:
+ {
+ sLog->outError("HandleAddonMessagechatOpcode: unknown addon message type %u", type);
+ break;
+ }
+ }
+}
+
void WorldSession::HandleEmoteOpcode(WorldPacket & recv_data)
{
if (!GetPlayer()->isAlive() || GetPlayer()->HasUnitState(UNIT_STAT_DIED))
View
6 src/server/game/Server/Protocol/Opcodes.cpp
@@ -191,7 +191,11 @@ void InitOpcodes()
//DEFINE_OPCODE_HANDLER(SMSG_GUILD_EVENT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
//DEFINE_OPCODE_HANDLER(SMSG_GUILD_COMMAND_RESULT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
//DEFINE_OPCODE_HANDLER(UMSG_UPDATE_GUILD, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
- //DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_X, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleMessagechatOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_BATTLEGROUND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAddonMessagechatOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_GUILD, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAddonMessagechatOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_PARTY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAddonMessagechatOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_RAID, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAddonMessagechatOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_ADDON_WHISPER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAddonMessagechatOpcode );
//DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_AFK, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleMessagechatOpcode );
//DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_BATTLEGROUND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleMessagechatOpcode );
//DEFINE_OPCODE_HANDLER(CMSG_MESSAGECHAT_BATTLEGROUND_LEADER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleMessagechatOpcode );
View
1 src/server/game/Server/WorldSession.h
@@ -694,6 +694,7 @@ class WorldSession
bool processChatmessageFurtherAfterSecurityChecks(std::string&, uint32);
void HandleMessagechatOpcode(WorldPacket& recvPacket);
+ void HandleAddonMessagechatOpcode(WorldPacket& recvPacket);
void SendPlayerNotFoundNotice(std::string name);
void SendPlayerAmbiguousNotice(std::string name);
void SendWrongFactionNotice();

0 comments on commit 7cc49aa

Please sign in to comment.