Hey, i have problem with my loop to sending player info to other clients, when 2 players are connecter everything work okey, but when third connect, to the third player is sending too much packets with players info..., i can't see what's wrong with my loop : o, any ideas?
void Server::SendMapInfo()
{
for( std::list<Client*>::iterator it = clients.begin(); it!= clients.end(); ++it )
{
Client &client = **it;
if(inGameClients.size()>1)
{
for( std::list<Client*>::iterator itt = inGameClients.begin(); itt!= inGameClients.end(); ++itt )
{
Client &temp = **itt;
if(temp.ClientID!=client.ClientID&&client.inGame==true&&temp.inGame==true)
{
//if(temp.Char.X/maps[client.Char.MapID]->tilesize<(client.Char.X/maps[client.Char.MapID]->tilesize-8)
// || temp.Char.X/maps[client.Char.MapID]->tilesize>(client.Char.X/maps[client.Char.MapID]->tilesize+8) )
// {
// if(temp.Char.Y/maps[client.Char.MapID]->tilesize<(client.Char.Y/maps[client.Char.MapID]->tilesize-8)
// || temp.Char.Y/maps[client.Char.MapID]->tilesize>(client.Char.Y/maps[client.Char.MapID]->tilesize+8) )
//{
client.family=Packet::PACKET_WORLD;
client.action=Packet::PACKET_REQUEST;
client.send<<client.family<<client.action<<temp.Char.Name<<temp.ClientID<<temp.Char.X<<temp.Char.Y;
client.Send();
std::string str;
str=std::to_string(temp.ClientID);
str+=" ";
str+=temp.Char.Name;
str+=" ";
str+=std::to_string(temp.Char.X);
str+= " ";
str+=std::to_string(temp.Char.Y);
client.SMsg(str.c_str());
// }
// }
}
}
}
}
}