From deb10919ab2654e95d02ed105b72982329ed8b69 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 26 Feb 2017 19:45:04 +0200 Subject: [PATCH] [Server] Delete cells that become empty when a player disconnects --- apps/openmw-mp/Cell.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index 21a9700b1..850f17821 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -229,24 +229,10 @@ void CellController::deletePlayer(Player *player) LOG_APPEND(Log::LOG_INFO, "- Iterating through Cells from Player %s", player->npc.mName.c_str()); - for_each(player->getCells()->begin(), player->getCells()->end(), [&player](Cell *cell) + for (auto it = player->getCells()->begin(); player->getCells()->size() != 0; ++it) { - LOG_APPEND(Log::LOG_INFO, "-- Found Cell %s", - cell->getDescription().c_str()); - - for (auto it = cell->begin(); it != cell->end(); ++it) - { - if (*it == player) - { - LOG_APPEND(Log::LOG_INFO, "-- Deleting %s from Cell %s", - player->npc.mName.c_str(), - cell->getDescription().c_str()); - - cell->players.erase(it); - break; - } - } - }); + removePlayer(*it, player); + } } void CellController::update(Player *player)