From 206c9cc3574ff709e1577128df0e73a7e2f48d6a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 5 May 2017 04:58:44 +0300 Subject: [PATCH] [Client] Use CellController pointers to make code easier to read --- apps/openmw/mwmp/Cell.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index d820a9531..ad0692cd2 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -27,6 +27,7 @@ void Cell::updateLocal(bool forceUpdate) { if (localActors.empty()) return; + CellController *cellController = Main::get().getCellController(); ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList(); actorList->reset(); @@ -44,17 +45,17 @@ void Cell::updateLocal(bool forceUpdate) std::string mapIndex = it->first; // If the cell this actor has moved to is under our authority, move them to it - if (Main::get().getCellController()->hasLocalAuthority(actor->cell)) + if (cellController->hasLocalAuthority(actor->cell)) { LOG_APPEND(Log::LOG_INFO, "- Moving LocalActor %s to our authority in %s", mapIndex.c_str(), actor->cell.getDescription().c_str()); - Cell *newCell = Main::get().getCellController()->getCell(actor->cell); + Cell *newCell = cellController->getCell(actor->cell); newCell->localActors[mapIndex] = actor; - Main::get().getCellController()->setLocalActorRecord(mapIndex, newCell->getDescription()); + cellController->setLocalActorRecord(mapIndex, newCell->getDescription()); } else { LOG_APPEND(Log::LOG_INFO, "- Deleting LocalActor %s which is no longer under our authority", mapIndex.c_str(), getDescription().c_str()); - Main::get().getCellController()->removeLocalActorRecord(mapIndex); + cellController->removeLocalActorRecord(mapIndex); delete actor; } @@ -233,6 +234,7 @@ void Cell::readCellChange(ActorList& actorList) initializeDedicatedActors(actorList); BaseActor baseActor; + CellController *cellController = Main::get().getCellController(); for (unsigned int i = 0; i < actorList.count; i++) { @@ -247,21 +249,21 @@ void Cell::readCellChange(ActorList& actorList) LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedActor %s moved to %s", mapIndex.c_str(), actor->cell.getDescription().c_str()); - MWWorld::CellStore *newStore = Main::get().getCellController()->getCellStore(actor->cell); + MWWorld::CellStore *newStore = cellController->getCellStore(actor->cell); actor->setCell(newStore); - // If the cell this actor has moved to is active, move them to it - if (Main::get().getCellController()->isInitializedCell(actor->cell)) + // If the cell this actor has moved to is active and not under our authority, move them to it + if (cellController->isInitializedCell(actor->cell)) { LOG_APPEND(Log::LOG_INFO, "- Moving DedicatedActor %s to our active cell %s", mapIndex.c_str(), actor->cell.getDescription().c_str()); - Cell *newCell = Main::get().getCellController()->getCell(actor->cell); + Cell *newCell = cellController->getCell(actor->cell); newCell->dedicatedActors[mapIndex] = actor; - Main::get().getCellController()->setDedicatedActorRecord(mapIndex, newCell->getDescription()); + cellController->setDedicatedActorRecord(mapIndex, newCell->getDescription()); } else { LOG_APPEND(Log::LOG_INFO, "- Deleting DedicatedActor %s which is no longer in an active cell", mapIndex.c_str(), getDescription().c_str()); - Main::get().getCellController()->removeDedicatedActorRecord(mapIndex); + cellController->removeDedicatedActorRecord(mapIndex); delete actor; }