From 47b7c71c731966a285948c375b1ac971aae5453a Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Sun, 19 Feb 2023 10:42:59 +0100 Subject: [PATCH] Remove unused functions --- apps/openmw/mwbase/world.hpp | 2 -- apps/openmw/mwscript/globalscripts.cpp | 3 +- apps/openmw/mwworld/worldimp.cpp | 5 --- apps/openmw/mwworld/worldimp.hpp | 2 -- apps/openmw/mwworld/worldmodel.cpp | 45 -------------------------- apps/openmw/mwworld/worldmodel.hpp | 9 ------ 6 files changed, 2 insertions(+), 64 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index c239d5b5e6..d408166841 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -199,8 +199,6 @@ namespace MWBase virtual MWWorld::Ptr searchPtrViaActorId(int actorId) = 0; ///< Search is limited to the active cells. - virtual MWWorld::Ptr searchPtrViaRefNum(const ESM::RefId& id, const ESM::RefNum& refNum) = 0; - virtual MWWorld::Ptr findContainer(const MWWorld::ConstPtr& ptr) = 0; ///< Return a pointer to a liveCellRef which contains \a ptr. /// \note Search is limited to the active cells. diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 4a7fdf5f2c..f35f74a063 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -12,6 +12,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/scriptmanager.hpp" #include "../mwbase/world.hpp" +#include "../mwworld/worldmodel.hpp" #include "interpretercontext.hpp" @@ -62,7 +63,7 @@ namespace if (pair.second.empty()) return MWWorld::Ptr(); else if (pair.first.hasContentFile()) - return MWBase::Environment::get().getWorld()->searchPtrViaRefNum(pair.second, pair.first); + return MWBase::Environment::get().getWorldModel()->getPtr(pair.first); return MWBase::Environment::get().getWorld()->searchPtr(pair.second, false); } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cf46f1b2bb..4fe4503dd5 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -728,11 +728,6 @@ namespace MWWorld return mWorldScene->searchPtrViaActorId(actorId); } - Ptr World::searchPtrViaRefNum(const ESM::RefId& id, const ESM::RefNum& refNum) - { - return mWorldModel.getPtr(id, refNum); - } - struct FindContainerVisitor { ConstPtr mContainedPtr; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index bb5a5d89b6..476a92eea7 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -286,8 +286,6 @@ namespace MWWorld Ptr searchPtrViaActorId(int actorId) override; ///< Search is limited to the active cells. - Ptr searchPtrViaRefNum(const ESM::RefId& id, const ESM::RefNum& refNum) override; - MWWorld::Ptr findContainer(const MWWorld::ConstPtr& ptr) override; ///< Return a pointer to a liveCellRef which contains \a ptr. /// \note Search is limited to the active cells. diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 35b67133f0..84e4e493f4 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -377,37 +377,6 @@ MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name) return Ptr(); } -MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& id, const ESM::RefNum& refNum) -{ - for (auto& pair : mInteriors) - { - Ptr ptr = getPtr(pair.second, id, refNum); - if (!ptr.isEmpty()) - return ptr; - } - for (auto& pair : mExteriors) - { - Ptr ptr = getPtr(pair.second, id, refNum); - if (!ptr.isEmpty()) - return ptr; - } - return Ptr(); -} - -MWWorld::Ptr MWWorld::WorldModel::getPtr(CellStore& cellStore, const ESM::RefId& id, const ESM::RefNum& refNum) -{ - if (cellStore.getState() == CellStore::State_Unloaded) - cellStore.preload(); - if (cellStore.getState() == CellStore::State_Preloaded) - { - if (cellStore.hasId(id)) - cellStore.load(); - else - return Ptr(); - } - return cellStore.searchViaRefNum(refNum); -} - void MWWorld::WorldModel::getExteriorPtrs(const ESM::RefId& name, std::vector& out) { const MWWorld::Store& cells = mStore.get(); @@ -422,20 +391,6 @@ void MWWorld::WorldModel::getExteriorPtrs(const ESM::RefId& name, std::vector& out) -{ - const MWWorld::Store& cells = mStore.get(); - for (MWWorld::Store::iterator iter = cells.intBegin(); iter != cells.intEnd(); ++iter) - { - CellStore* cellStore = getCellStore(&(*iter)); - - Ptr ptr = getPtrAndCache(name, *cellStore); - - if (!ptr.isEmpty()) - out.push_back(ptr); - } -} - std::vector MWWorld::WorldModel::getAll(const ESM::RefId& id) { PtrCollector visitor; diff --git a/apps/openmw/mwworld/worldmodel.hpp b/apps/openmw/mwworld/worldmodel.hpp index aa21eedc2d..7e740dfe3f 100644 --- a/apps/openmw/mwworld/worldmodel.hpp +++ b/apps/openmw/mwworld/worldmodel.hpp @@ -56,8 +56,6 @@ namespace MWWorld CellStore* getCellStore(const ESM::Cell* cell); Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore); - Ptr getPtr(CellStore& cellStore, const ESM::RefId& id, const ESM::RefNum& refNum); - void writeCell(ESM::ESMWriter& writer, CellStore& cell) const; std::unordered_map mPtrIndex; @@ -95,8 +93,6 @@ namespace MWWorld /// @note name must be lower case Ptr getPtr(const ESM::RefId& name); - Ptr getPtr(const ESM::RefId& id, const ESM::RefNum& refNum); - template void forEachLoadedCellStore(Fn&& fn) { @@ -111,11 +107,6 @@ namespace MWWorld /// @note name must be lower case void getExteriorPtrs(const ESM::RefId& name, std::vector& out); - /// Get all Ptrs referencing \a name in interior cells - /// @note Due to the current implementation of getPtr this only supports one Ptr per cell. - /// @note name must be lower case - void getInteriorPtrs(const ESM::RefId& name, std::vector& out); - std::vector getAll(const ESM::RefId& id); int countSavedGameRecords() const;