[Server] Some fixes to sendToNearest & doForNearest

pull/158/head
Koncord 8 years ago
parent 033472d939
commit cce49e355a

@ -143,28 +143,36 @@ CellController::TContainer Player::getCells()
void Player::sendToNearest(mwmp::PlayerPacket *myPacket) void Player::sendToNearest(mwmp::PlayerPacket *myPacket)
{ {
std::list <Player*> plList;
for(auto cell : getCells()) for(auto cell : getCells())
{ for (auto pl : *cell)
for(auto pl : *cell) plList.push_back(pl);
{
if(pl == this)
continue;
myPacket->Send(this, pl->guid); plList.sort();
} plList.unique();
for(auto pl : plList)
{
if(pl == this) continue;
myPacket->Send(this, pl->guid);
} }
} }
void Player::doForNearest(std::function<void (Player *pl, Player *other)> func) void Player::doForNearest(std::function<void (Player *pl, Player *other)> func)
{ {
std::list <Player*> plList;
for(auto cell : getCells()) for(auto cell : getCells())
{ for (auto pl : *cell)
for(auto pl : *cell) plList.push_back(pl);
{
if(pl == this)
continue;
func(this, pl); plList.sort();
} plList.unique();
for(auto pl : plList)
{
if(pl == this) continue;
func(this, pl);
} }
} }

Loading…
Cancel
Save