From b33e604a61f4465a5b3124fae44d96208cafd089 Mon Sep 17 00:00:00 2001 From: Koncord Date: Fri, 24 Feb 2017 12:33:59 +0800 Subject: [PATCH] [Server] Set sendToLoaded function as constant Add assertions for CellController singleton --- apps/openmw-mp/Cell.cpp | 8 +++++--- apps/openmw-mp/Cell.hpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index 79d6fc98c..0e060b080 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -32,16 +32,16 @@ void Cell::removePlayer(Player *player) } } -Cell::TPlayers Cell::getPlayers() +Cell::TPlayers Cell::getPlayers() const { return players; } -void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent) +void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent) const { std::list plList; - for (auto pl :getPlayers()) + for (auto pl : players) plList.push_back(pl); plList.sort(); @@ -73,6 +73,7 @@ CellController *CellController::sThis = nullptr; void CellController::create() { + assert(!sThis); sThis = new CellController; } @@ -85,6 +86,7 @@ void CellController::destroy() CellController *CellController::get() { + assert(sThis); return sThis; } diff --git a/apps/openmw-mp/Cell.hpp b/apps/openmw-mp/Cell.hpp index 5ddeddbb4..26eb26bc6 100644 --- a/apps/openmw-mp/Cell.hpp +++ b/apps/openmw-mp/Cell.hpp @@ -61,8 +61,8 @@ public: void addPlayer(Player *player); void removePlayer(Player *player); - TPlayers getPlayers(); - void sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent); + TPlayers getPlayers() const; + void sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent) const; std::string getDescription() const;