From d8b48f6cf49794060990419368675ff8fff98aee Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 1 Apr 2018 07:11:43 +0300 Subject: [PATCH] [Client] Remove redundant container methods from CellController --- apps/openmw/mwgui/container.cpp | 6 +++-- apps/openmw/mwmp/CellController.cpp | 42 ----------------------------- apps/openmw/mwmp/CellController.hpp | 3 --- 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 5fd46f9b3..c2d80b839 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -11,6 +11,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalPlayer.hpp" #include "../mwmp/WorldEvent.hpp" #include "../mwmp/CellController.hpp" /* @@ -217,7 +218,7 @@ namespace MWGui Mark this container as open for multiplayer logic purposes */ - mwmp::Main::get().getCellController()->openContainer(container); + mwmp::Main::get().getLocalPlayer()->storeCurrentContainer(container); /* End of tes3mp addition */ @@ -269,7 +270,8 @@ namespace MWGui Mark this container as closed for multiplayer logic purposes */ - mwmp::Main::get().getCellController()->closeContainer(mPtr); + mwmp::Main::get().getLocalPlayer()->clearCurrentContainer(); + mwmp::Main::get().getLocalPlayer()->updateInventory(); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index eb89f7b45..cca055a7f 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -345,48 +345,6 @@ bool CellController::isSameCell(const ESM::Cell& cell, const ESM::Cell& otherCel return false; } -void CellController::openContainer(const MWWorld::Ptr &container) -{ - // Record this as the player's current open container - Main::get().getLocalPlayer()->storeCurrentContainer(container); - - const auto &cellRef = container.getCellRef(); - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is opened", - cellRef.getRefId().c_str(), cellRef.getRefNum().mIndex); - - for (const auto &ptr : container.getClass().getContainerStore(container)) - { - int count = ptr.getRefData().getCount(); - const std::string &name = ptr.getCellRef().getRefId(); - - LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d", name.c_str(), count); - - /*if (::Misc::StringUtils::ciEqual(name, "gold_001")) - cont.remove("gold_001", count, container);*/ - } -} - -void CellController::closeContainer(const MWWorld::Ptr &container) -{ - Main::get().getLocalPlayer()->clearCurrentContainer(); - - // If the player died while in a container, the container's Ptr could be invalid now - if (!container.isEmpty()) - { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is closed.", container.getCellRef().getRefId().c_str(), - container.getCellRef().getRefNum().mIndex); - - MWWorld::ContainerStore &cont = container.getClass().getContainerStore(container); - for (const auto &ptr : cont) - { - LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d", ptr.getCellRef().getRefId().c_str(), - ptr.getRefData().getCount()); - } - } - - Main::get().getLocalPlayer()->updateInventory(); -} - int CellController::getCellSize() const { return 8192; diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index 78777913e..d93989e9d 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -60,9 +60,6 @@ namespace mwmp bool isSameCell(const ESM::Cell& cell, const ESM::Cell& otherCell); - void openContainer(const MWWorld::Ptr& container); - void closeContainer(const MWWorld::Ptr& container); - int getCellSize() const; private: