[Server] Some fixes to sendToNearest & doForNearest

This commit is contained in:
Koncord 2017-02-19 18:44:52 +08:00
parent 033472d939
commit cce49e355a

View file

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