From 47b7c71c731966a285948c375b1ac971aae5453a Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Sun, 19 Feb 2023 10:42:59 +0100 Subject: [PATCH 1/2] 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; From 1c2f24d1cad3cc9395d0e76c75765d4f6ef7fa06 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Sun, 19 Feb 2023 12:47:33 +0100 Subject: [PATCH 2/2] Remove unused searchInContainers in WorldModel::getPtr --- apps/openmw/mwworld/worldimp.cpp | 2 +- apps/openmw/mwworld/worldmodel.cpp | 5 +---- apps/openmw/mwworld/worldmodel.hpp | 6 +----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4fe4503dd5..555df2bbf1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -680,7 +680,7 @@ namespace MWWorld { // TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is // in) - Ptr ptr = mWorldModel.getPtr(name, *cellstore, false); + Ptr ptr = mWorldModel.getPtr(name, *cellstore); if (!ptr.isEmpty()) return ptr; diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 84e4e493f4..4157c42b15 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -294,7 +294,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellByPosition( return getInterior(cellNameInSameWorldSpace); } -MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name, CellStore& cell, bool searchInContainers) +MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name, CellStore& cell) { if (cell.getState() == CellStore::State_Unloaded) cell.preload(); @@ -314,9 +314,6 @@ MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name, CellStore& cell if (!ptr.isEmpty() && MWWorld::CellStore::isAccessible(ptr.getRefData(), ptr.getCellRef())) return ptr; - if (searchInContainers) - return cell.searchInContainer(name); - return Ptr(); } diff --git a/apps/openmw/mwworld/worldmodel.hpp b/apps/openmw/mwworld/worldmodel.hpp index 7e740dfe3f..52f426f854 100644 --- a/apps/openmw/mwworld/worldmodel.hpp +++ b/apps/openmw/mwworld/worldmodel.hpp @@ -86,11 +86,7 @@ namespace MWWorld Ptr getPtr(const ESM::RefNum& refNum) const; - Ptr getPtr(const ESM::RefId& name, CellStore& cellStore, bool searchInContainers = false); - ///< \param searchInContainers Only affect loaded cells. - /// @note name must be lower case - - /// @note name must be lower case + Ptr getPtr(const ESM::RefId& name, CellStore& cellStore); Ptr getPtr(const ESM::RefId& name); template