From b829f0252a3b9a7c0be81f4366ebcbabc1763a36 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 20 Feb 2017 01:47:39 +0200 Subject: [PATCH] [Server] Don't crash server every time a player disconnects --- apps/openmw-mp/Cell.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index fb28d9ef4..aecffe3c6 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -169,7 +169,9 @@ void CellController::removePlayer(Cell *cell, Player *player) void CellController::deletePlayer(Player *player) { - for_each (player->getCells().begin(), player->getCells().end(), [&player](Cell *cell) { + std::deque playerCells = player->getCells(); + + for_each(playerCells.begin(), playerCells.end(), [&player](Cell *cell) { for (auto it = cell->begin(); it != cell->end(); ++it) { if (*it == player)