Merge branch 'worldmodel' into 'master'

[Refactoring] Remove unused code related to mwworld/worldmodel

See merge request OpenMW/openmw!2761
update_gitlab_rules
psi29a 2 years ago
commit a2d8390713

@ -199,8 +199,6 @@ namespace MWBase
virtual MWWorld::Ptr searchPtrViaActorId(int actorId) = 0; virtual MWWorld::Ptr searchPtrViaActorId(int actorId) = 0;
///< Search is limited to the active cells. ///< 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; virtual MWWorld::Ptr findContainer(const MWWorld::ConstPtr& ptr) = 0;
///< Return a pointer to a liveCellRef which contains \a ptr. ///< Return a pointer to a liveCellRef which contains \a ptr.
/// \note Search is limited to the active cells. /// \note Search is limited to the active cells.

@ -12,6 +12,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/scriptmanager.hpp" #include "../mwbase/scriptmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/worldmodel.hpp"
#include "interpretercontext.hpp" #include "interpretercontext.hpp"
@ -62,7 +63,7 @@ namespace
if (pair.second.empty()) if (pair.second.empty())
return MWWorld::Ptr(); return MWWorld::Ptr();
else if (pair.first.hasContentFile()) 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); return MWBase::Environment::get().getWorld()->searchPtr(pair.second, false);
} }
}; };

@ -680,7 +680,7 @@ namespace MWWorld
{ {
// TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is // TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is
// in) // in)
Ptr ptr = mWorldModel.getPtr(name, *cellstore, false); Ptr ptr = mWorldModel.getPtr(name, *cellstore);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
return ptr; return ptr;
@ -728,11 +728,6 @@ namespace MWWorld
return mWorldScene->searchPtrViaActorId(actorId); return mWorldScene->searchPtrViaActorId(actorId);
} }
Ptr World::searchPtrViaRefNum(const ESM::RefId& id, const ESM::RefNum& refNum)
{
return mWorldModel.getPtr(id, refNum);
}
struct FindContainerVisitor struct FindContainerVisitor
{ {
ConstPtr mContainedPtr; ConstPtr mContainedPtr;

@ -286,8 +286,6 @@ namespace MWWorld
Ptr searchPtrViaActorId(int actorId) override; Ptr searchPtrViaActorId(int actorId) override;
///< Search is limited to the active cells. ///< 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; MWWorld::Ptr findContainer(const MWWorld::ConstPtr& ptr) override;
///< Return a pointer to a liveCellRef which contains \a ptr. ///< Return a pointer to a liveCellRef which contains \a ptr.
/// \note Search is limited to the active cells. /// \note Search is limited to the active cells.

@ -294,7 +294,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellByPosition(
return getInterior(cellNameInSameWorldSpace); 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) if (cell.getState() == CellStore::State_Unloaded)
cell.preload(); 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())) if (!ptr.isEmpty() && MWWorld::CellStore::isAccessible(ptr.getRefData(), ptr.getCellRef()))
return ptr; return ptr;
if (searchInContainers)
return cell.searchInContainer(name);
return Ptr(); return Ptr();
} }
@ -377,37 +374,6 @@ MWWorld::Ptr MWWorld::WorldModel::getPtr(const ESM::RefId& name)
return Ptr(); 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<MWWorld::Ptr>& out) void MWWorld::WorldModel::getExteriorPtrs(const ESM::RefId& name, std::vector<MWWorld::Ptr>& out)
{ {
const MWWorld::Store<ESM::Cell>& cells = mStore.get<ESM::Cell>(); const MWWorld::Store<ESM::Cell>& cells = mStore.get<ESM::Cell>();
@ -422,20 +388,6 @@ void MWWorld::WorldModel::getExteriorPtrs(const ESM::RefId& name, std::vector<MW
} }
} }
void MWWorld::WorldModel::getInteriorPtrs(const ESM::RefId& name, std::vector<MWWorld::Ptr>& out)
{
const MWWorld::Store<ESM::Cell>& cells = mStore.get<ESM::Cell>();
for (MWWorld::Store<ESM::Cell>::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::Ptr> MWWorld::WorldModel::getAll(const ESM::RefId& id) std::vector<MWWorld::Ptr> MWWorld::WorldModel::getAll(const ESM::RefId& id)
{ {
PtrCollector visitor; PtrCollector visitor;

@ -56,8 +56,6 @@ namespace MWWorld
CellStore* getCellStore(const ESM::Cell* cell); CellStore* getCellStore(const ESM::Cell* cell);
Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore); 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; void writeCell(ESM::ESMWriter& writer, CellStore& cell) const;
std::unordered_map<ESM::RefNum, Ptr> mPtrIndex; std::unordered_map<ESM::RefNum, Ptr> mPtrIndex;
@ -88,15 +86,9 @@ namespace MWWorld
Ptr getPtr(const ESM::RefNum& refNum) const; Ptr getPtr(const ESM::RefNum& refNum) const;
Ptr getPtr(const ESM::RefId& name, CellStore& cellStore, bool searchInContainers = false); Ptr getPtr(const ESM::RefId& name, CellStore& cellStore);
///< \param searchInContainers Only affect loaded cells.
/// @note name must be lower case
/// @note name must be lower case
Ptr getPtr(const ESM::RefId& name); Ptr getPtr(const ESM::RefId& name);
Ptr getPtr(const ESM::RefId& id, const ESM::RefNum& refNum);
template <typename Fn> template <typename Fn>
void forEachLoadedCellStore(Fn&& fn) void forEachLoadedCellStore(Fn&& fn)
{ {
@ -111,11 +103,6 @@ namespace MWWorld
/// @note name must be lower case /// @note name must be lower case
void getExteriorPtrs(const ESM::RefId& name, std::vector<MWWorld::Ptr>& out); void getExteriorPtrs(const ESM::RefId& name, std::vector<MWWorld::Ptr>& 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<MWWorld::Ptr>& out);
std::vector<MWWorld::Ptr> getAll(const ESM::RefId& id); std::vector<MWWorld::Ptr> getAll(const ESM::RefId& id);
int countSavedGameRecords() const; int countSavedGameRecords() const;

Loading…
Cancel
Save