aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Texts/CreatureTextMgr.cpp
diff options
context:
space:
mode:
authorRat <none@none>2010-10-25 18:25:21 +0200
committerRat <none@none>2010-10-25 18:25:21 +0200
commite4c27a2ffa58bd62f8e3d78067e5bc312c2e3c42 (patch)
tree539533c77eee8fa2f5089b238106a0d69c0fea71 /src/server/game/Texts/CreatureTextMgr.cpp
parenta792e3d67ca3e93fff07940a30b53d33ff28973a (diff)
Core/TextMgr: updated with new funtions for future useage
--HG-- branch : trunk
Diffstat (limited to 'src/server/game/Texts/CreatureTextMgr.cpp')
-rwxr-xr-xsrc/server/game/Texts/CreatureTextMgr.cpp73
1 files changed, 58 insertions, 15 deletions
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp
index cdcccaab0e6..fe0cf904f94 100755
--- a/src/server/game/Texts/CreatureTextMgr.cpp
+++ b/src/server/game/Texts/CreatureTextMgr.cpp
@@ -108,7 +108,7 @@ void CreatureTextMgr::LoadCreatureTexts()
sLog.outString(">> Loaded %u Creature Texts for %u Creatures.", TextCount, CreatureCount);
}
-uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid, ChatType msgtype, Language language, TextRange range, uint32 sound)
+uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid, ChatType msgtype, Language language, TextRange range, uint32 sound, Team team, bool gmOnly)
{
if (!source)
return 0;
@@ -183,25 +183,25 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp
uint32 finalSound = sound ? sound : (*iter).sound;
if (finalSound)
- SendSound(source, finalSound, finalType, whisperGuid, range);
-
- SendChatString(source, (*iter).text.c_str(), finalType, finalLang, whisperGuid, range);
- if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f))
- SetRepeatId(source, textGroup, (*iter).id);
+ SendSound(source, finalSound, finalType, whisperGuid, range, team, gmOnly);
if ((*iter).emote)
SendEmote(source, (*iter).emote);
+ SendChatString(source, (*iter).text.c_str(), finalType, finalLang, whisperGuid, range, team, gmOnly);
+ if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f))
+ SetRepeatId(source, textGroup, (*iter).id);
+
return (*iter).duration;
}
-void CreatureTextMgr::SendSound(Creature* source,uint32 sound, ChatType msgtype, uint64 whisperGuid, TextRange range)
+void CreatureTextMgr::SendSound(Creature* source,uint32 sound, ChatType msgtype, uint64 whisperGuid, TextRange range, Team team, bool gmOnly)
{
if (!sound || !source)
return;
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound);
- SendChatPacket(&data, source, msgtype, whisperGuid, range);
+ SendChatPacket(&data, source, msgtype, whisperGuid, range, team, gmOnly);
}
void CreatureTextMgr::SendEmote(Creature* source, uint32 emote)
{
@@ -248,14 +248,14 @@ CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 te
return ids;
}
-void CreatureTextMgr::SendChatString(WorldObject* source, char const* text, ChatType msgtype, Language language, uint64 whisperGuid, TextRange range) const
+void CreatureTextMgr::SendChatString(WorldObject* source, char const* text, ChatType msgtype, Language language, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const
{
if (!source)
return;
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildMonsterChat(&data, source, msgtype, text, language, whisperGuid);//build our packet
- SendChatPacket(&data, source, msgtype, whisperGuid, range);//send our packet
+ SendChatPacket(&data, source, msgtype, whisperGuid, range, team, gmOnly);//send our packet
}
void CreatureTextMgr::BuildMonsterChat(WorldPacket *data, WorldObject* source, ChatType msgtype, char const* text, Language language, uint64 whisperGuid) const
@@ -316,7 +316,7 @@ void CreatureTextMgr::BuildMonsterChat(WorldPacket *data, WorldObject* source, C
*data << (uint8)0; // ChatTag
}
-void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, ChatType msgtype, uint64 whisperGuid, TextRange range) const
+void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, ChatType msgtype, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const
{
if (!source)
return;
@@ -335,7 +335,7 @@ void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, Cha
case CHAT_TYPE_WHISPER:
case CHAT_TYPE_BOSS_WHISPER:
{
- if (range == TEXT_RANGE_NORMAL)
+ if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly
{
Player *player = sObjectMgr.GetPlayer(whisperGuid);
if (!player || !player->GetSession())
@@ -357,8 +357,12 @@ void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, Cha
uint32 areaId = source->GetAreaId();
Map::PlayerList const& pList = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
- if (itr->getSource()->GetAreaId() == areaId)
+ if (itr->getSource()->GetAreaId() == areaId && (!team || (team && itr->getSource()->GetTeam() == team)) && (!gmOnly || itr->getSource()->isGameMaster()))
+ {
+ if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
+ data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
(itr->getSource())->GetSession()->SendPacket(data);
+ }
}
return;
case TEXT_RANGE_ZONE:
@@ -366,20 +370,39 @@ void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, Cha
uint32 zoneId = source->GetZoneId();
Map::PlayerList const& pList = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
- if (itr->getSource()->GetZoneId() == zoneId)
+ if (itr->getSource()->GetZoneId() == zoneId && (!team || (team && itr->getSource()->GetTeam() == team)) && (!gmOnly || itr->getSource()->isGameMaster()))
+ {
+ if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
+ data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
(itr->getSource())->GetSession()->SendPacket(data);
+ }
}
return;
case TEXT_RANGE_MAP:
{
Map::PlayerList const& pList = source->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
+ {
+ if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
+ data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID()));
+ if (!team || (team && itr->getSource()->GetTeam() == team) && (!gmOnly || itr->getSource()->isGameMaster()))
(itr->getSource())->GetSession()->SendPacket(data);
+ }
}
return;
case TEXT_RANGE_WORLD:
{
- sWorld.SendGlobalMessage(data);
+ const SessionMap smap = sWorld.GetAllSessions();
+ for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
+ {
+ if (Player* plr = (*iter).second->GetPlayer())
+ {
+ if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid
+ data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(plr->GetGUID()));
+ if (plr->GetSession() && (!team || (team && plr->GetTeam() == team)) && (!gmOnly || plr->isGameMaster()))
+ plr->GetSession()->SendPacket(data);
+ }
+ }
}
return;
case TEXT_RANGE_NORMAL:
@@ -388,3 +411,23 @@ void CreatureTextMgr::SendChatPacket(WorldPacket *data, WorldObject* source, Cha
}
source->SendMessageToSetInRange(data, dist, true);
}
+
+bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup)
+{
+ if (!sourceEntry)
+ return false;
+ CreatureTextMap::const_iterator sList = mTextMap.find(sourceEntry);
+ if (sList == mTextMap.end())
+ {
+ sLog.outErrorDb("CreatureTextMgr::TextExist: Could not find Text for Creature (entry %u) in 'creature_text' table.", sourceEntry);
+ return false;
+ }
+ CreatureTextHolder TextHolder = (*sList).second;
+ CreatureTextHolder::const_iterator itr = TextHolder.find(textGroup);
+ if (itr == TextHolder.end())
+ {
+ sLog.outErrorDb("CreatureTextMgr::TextExist: Could not find TextGroup %u for Creature (entry %u).",uint32(textGroup), sourceEntry);
+ return false;
+ }
+ return true;
+} \ No newline at end of file