From 9a83108fe5a99314bf1e856d52a576d908a42b14 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 11 Aug 2020 04:15:12 +0200 Subject: [PATCH] [Client] Add uninitializeCell() method to CellController --- apps/openmw/mwmp/CellController.cpp | 15 +++++++++++++++ apps/openmw/mwmp/CellController.hpp | 1 + 2 files changed, 16 insertions(+) diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index d04ad1d15..1967237b2 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -103,6 +103,21 @@ void CellController::initializeCell(const ESM::Cell& cell) } } +void CellController::uninitializeCell(const ESM::Cell& cell) +{ + std::string mapIndex = cell.getDescription(); + + // If this key doesn't exist, create it + if (cellsInitialized.count(mapIndex) > 0) + { + mwmp::Cell* mpCell = cellsInitialized.at(mapIndex); + mpCell->uninitializeLocalActors(); + mpCell->uninitializeDedicatedActors(); + delete cellsInitialized.at(mapIndex); + cellsInitialized.erase(mapIndex); + } +} + void CellController::readPositions(ActorList& actorList) { std::string mapIndex = actorList.cell.getDescription(); diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index 6a9093a30..79bc15651 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -20,6 +20,7 @@ namespace mwmp void updateDedicated(float dt); void initializeCell(const ESM::Cell& cell); + void uninitializeCell(const ESM::Cell& cell); void readPositions(mwmp::ActorList& actorList); void readAnimFlags(mwmp::ActorList& actorList);