mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
[Server] Reuse Cell deletion code in CellController
This commit is contained in:
parent
b62969d3cf
commit
0ba8a407bc
1 changed files with 3 additions and 6 deletions
|
@ -112,12 +112,11 @@ void CellController::removeCell(Cell *cell)
|
|||
if (cell == nullptr)
|
||||
return;
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnCellUnload")>(cell->getDescription().c_str());
|
||||
|
||||
for (auto it = cells.begin(); it != cells.end();)
|
||||
{
|
||||
if (*it != nullptr && *it == cell)
|
||||
{
|
||||
Script::Call<Script::CallbackIdentity("OnCellUnload")>(cell->getDescription().c_str());
|
||||
LOG_APPEND(Log::LOG_INFO, "- Removing %s from CellController", cell->getDescription().c_str());
|
||||
|
||||
delete *it;
|
||||
|
@ -134,10 +133,8 @@ void CellController::removePlayer(Cell *cell, Player *player)
|
|||
|
||||
if (cell->players.empty())
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "- Deleting empty cell from memory: %s", cell->getDescription().c_str());
|
||||
auto it = find(cells.begin(), cells.end(), cell);
|
||||
delete *it;
|
||||
cells.erase(it);
|
||||
LOG_APPEND(Log::LOG_INFO, "- Cell %s has no players left", cell->getDescription().c_str());
|
||||
removeCell(cell);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue