aboutsummaryrefslogtreecommitdiff
path: root/src/game/World.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/World.cpp')
-rw-r--r--src/game/World.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 47598dafc65..5b36e3d4d9c 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -2273,6 +2273,23 @@ void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 te
}
}
+void World::SendGlobalGMMessage(WorldPacket *packet, WorldSession *self, uint32 team)
+{
+ SessionMap::iterator itr;
+ for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++)
+ {
+ if (itr->second &&
+ itr->second->GetPlayer() &&
+ itr->second->GetPlayer()->IsInWorld() &&
+ itr->second != self &&
+ itr->second->GetSecurity() >SEC_PLAYER &&
+ (team == 0 || itr->second->GetPlayer()->GetTeam() == team) )
+ {
+ itr->second->SendPacket(packet);
+ }
+ }
+}
+
/// Send a System Message to all players (except self if mentioned)
void World::SendWorldText(int32 string_id, ...)
{
@@ -2327,6 +2344,60 @@ void World::SendWorldText(int32 string_id, ...)
delete data_cache[i][j];
}
+void World::SendGMText(int32 string_id, ...)
+{
+ std::vector<std::vector<WorldPacket*> > data_cache; // 0 = default, i => i-1 locale index
+
+ for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
+ {
+ if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() )
+ continue;
+
+ uint32 loc_idx = itr->second->GetSessionDbLocaleIndex();
+ uint32 cache_idx = loc_idx+1;
+
+ std::vector<WorldPacket*>* data_list;
+
+ // create if not cached yet
+ if(data_cache.size() < cache_idx+1 || data_cache[cache_idx].empty())
+ {
+ if(data_cache.size() < cache_idx+1)
+ data_cache.resize(cache_idx+1);
+
+ data_list = &data_cache[cache_idx];
+
+ char const* text = objmgr.GetTrinityString(string_id,loc_idx);
+
+ char buf[1000];
+
+ va_list argptr;
+ va_start( argptr, string_id );
+ vsnprintf( buf,1000, text, argptr );
+ va_end( argptr );
+
+ char* pos = &buf[0];
+
+ while(char* line = ChatHandler::LineFromMessage(pos))
+ {
+ WorldPacket* data = new WorldPacket();
+ ChatHandler::FillMessageData(data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL);
+ data_list->push_back(data);
+ }
+ }
+ else
+ data_list = &data_cache[cache_idx];
+
+ for(int i = 0; i < data_list->size(); ++i)
+ if(itr->second->GetSecurity()>0)
+ itr->second->SendPacket((*data_list)[i]);
+ }
+
+ // free memory
+ for(int i = 0; i < data_cache.size(); ++i)
+ for(int j = 0; j < data_cache[i].size(); ++j)
+ delete data_cache[i][j];
+}
+
/// Send a System Message to all players (except self if mentioned)
void World::SendGlobalText(const char* text, WorldSession *self)
{