void World::SendWorldMessage(const char *channel, std::string chat, uint64 guid, WorldSession *self)
{
/*
Why is this function needed?
tobe able to send a message you need a valid ingame GUID
snce the IRC client isnt logged in we cant properly send message
or it would result in non existing players
also i didnt manage to figure out how to get the sessions in my own clas
so this function was born
*/
SessionMap::iterator itr;
for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++)
{
// Loop thru all online sessions
if (itr->second && itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld() && itr->second != self)
{
// check if the player is in the world
if(ChannelMgr* cMgr = channelMgr(itr->second->GetPlayer()->GetTeam()))
{
// check if the player is grouped
if(Channel *chn = cMgr->GetChannel(channel, itr->second->GetPlayer()))
{
// if the player is on our channel
WorldPacket data;
data.Initialize(SMSG_MESSAGECHAT);
data << (uint8)14;
data << (uint32)0;
data << guid;
data << (uint32)0;
data << channel;
data << guid;
data << (uint32) (strlen(chat.c_str()) + 1);
data << chat.c_str();
data << (uint8)0;
itr->second->SendPacket(&data);
}
}
}
}
}