[Server] Don't crash server every time a player disconnects. Again.

pull/163/head
Koncord 8 years ago
parent 13a47b400d
commit ec4d016100

@ -169,9 +169,8 @@ void CellController::removePlayer(Cell *cell, Player *player)
void CellController::deletePlayer(Player *player)
{
std::deque<Cell *> playerCells = player->getCells();
for_each(playerCells.begin(), playerCells.end(), [&player](Cell *cell) {
for_each(player->getCells()->begin(), player->getCells()->end(), [&player](Cell *cell) {
for (auto it = cell->begin(); it != cell->end(); ++it)
{
if (*it == player)

@ -138,16 +138,16 @@ std::chrono::steady_clock::time_point Player::getLastAttackerTime()
return lastAttackerTime;
}
CellController::TContainer Player::getCells()
CellController::TContainer *Player::getCells()
{
return cells;
return &cells;
}
void Player::sendToLoaded(mwmp::PlayerPacket *myPacket)
{
std::list <Player*> plList;
for (auto cell : getCells())
for (auto cell : *getCells())
for (auto pl : *cell)
plList.push_back(pl);
@ -165,7 +165,7 @@ void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func)
{
std::list <Player*> plList;
for (auto cell : getCells())
for (auto cell : *getCells())
for (auto pl : *cell)
plList.push_back(pl);

@ -70,7 +70,7 @@ public:
virtual ~Player();
CellController::TContainer getCells();
CellController::TContainer *getCells();
void sendToLoaded(mwmp::PlayerPacket *myPacket);
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);

Loading…
Cancel
Save