mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 18:39:59 +00:00
Use CellStore::mStore instead of MWBase::Environment::get()
This commit is contained in:
parent
df57f8004b
commit
947e8f0e94
@ -210,10 +210,8 @@ namespace
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void readReferenceCollection(ESM::ESMReader& reader, MWWorld::CellRefList<T>& collection, const ESM::CellRef& cref,
|
void readReferenceCollection(ESM::ESMReader& reader, MWWorld::CellRefList<T>& collection, const ESM::CellRef& cref,
|
||||||
const std::map<int, int>& contentFileMap, MWWorld::CellStore* cellstore)
|
const std::map<int, int>& contentFileMap, const MWWorld::ESMStore& esmStore, MWWorld::CellStore* cellstore)
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
|
||||||
|
|
||||||
using StateType = typename RecordToState<T>::StateType;
|
using StateType = typename RecordToState<T>::StateType;
|
||||||
StateType state;
|
StateType state;
|
||||||
state.mRef = cref;
|
state.mRef = cref;
|
||||||
@ -759,18 +757,16 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ReferenceInvocable>
|
template <typename ReferenceInvocable>
|
||||||
static void visitCell4References(const ESM4::Cell& cell, ESM::ReadersCache& readers, ReferenceInvocable&& invocable)
|
static void visitCell4References(
|
||||||
|
const ESM4::Cell& cell, const ESMStore& esmStore, ESM::ReadersCache& readers, ReferenceInvocable&& invocable)
|
||||||
{
|
{
|
||||||
for (const ESM4::Reference* ref :
|
for (const ESM4::Reference* ref : esmStore.get<ESM4::Reference>().getByCell(cell.mId))
|
||||||
MWBase::Environment::get().getESMStore()->get<ESM4::Reference>().getByCell(cell.mId))
|
|
||||||
{
|
|
||||||
invocable(*ref);
|
invocable(*ref);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::listRefs(const ESM4::Cell& cell)
|
void CellStore::listRefs(const ESM4::Cell& cell)
|
||||||
{
|
{
|
||||||
visitCell4References(cell, mReaders, [&](const ESM4::Reference& ref) { mIds.push_back(ref.mBaseObj); });
|
visitCell4References(cell, mStore, mReaders, [&](const ESM4::Reference& ref) { mIds.push_back(ref.mBaseObj); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::listRefs()
|
void CellStore::listRefs()
|
||||||
@ -834,7 +830,7 @@ namespace MWWorld
|
|||||||
|
|
||||||
void CellStore::loadRefs(const ESM4::Cell& cell, std::map<ESM::RefNum, ESM::RefId>& refNumToID)
|
void CellStore::loadRefs(const ESM4::Cell& cell, std::map<ESM::RefNum, ESM::RefId>& refNumToID)
|
||||||
{
|
{
|
||||||
visitCell4References(cell, mReaders, [&](const ESM4::Reference& ref) { loadRef(ref, false); });
|
visitCell4References(cell, mStore, mReaders, [&](const ESM4::Reference& ref) { loadRef(ref, false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::loadRefs()
|
void CellStore::loadRefs()
|
||||||
@ -999,7 +995,7 @@ namespace MWWorld
|
|||||||
ESM::CellRef cref;
|
ESM::CellRef cref;
|
||||||
cref.loadId(reader, true);
|
cref.loadId(reader, true);
|
||||||
|
|
||||||
int type = MWBase::Environment::get().getESMStore()->find(cref.mRefID);
|
int type = mStore.find(cref.mRefID);
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)";
|
Log(Debug::Warning) << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)";
|
||||||
@ -1020,7 +1016,7 @@ namespace MWWorld
|
|||||||
recNameSwitcher(x, static_cast<ESM::RecNameInts>(type),
|
recNameSwitcher(x, static_cast<ESM::RecNameInts>(type),
|
||||||
[&reader, this, &cref, &contentFileMap, &foundCorrespondingStore](auto& store) {
|
[&reader, this, &cref, &contentFileMap, &foundCorrespondingStore](auto& store) {
|
||||||
foundCorrespondingStore = true;
|
foundCorrespondingStore = true;
|
||||||
readReferenceCollection(reader, store, cref, contentFileMap, this);
|
readReferenceCollection(reader, store, cref, contentFileMap, mStore, this);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1091,14 +1087,11 @@ namespace MWWorld
|
|||||||
return mFogState.get();
|
return mFogState.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearCorpse(const MWWorld::Ptr& ptr)
|
static void clearCorpse(const MWWorld::Ptr& ptr, const ESMStore& store)
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
const MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||||
static const float fCorpseClearDelay = MWBase::Environment::get()
|
static const float fCorpseClearDelay
|
||||||
.getESMStore()
|
= store.get<ESM::GameSetting>().find("fCorpseClearDelay")->mValue.getFloat();
|
||||||
->get<ESM::GameSetting>()
|
|
||||||
.find("fCorpseClearDelay")
|
|
||||||
->mValue.getFloat();
|
|
||||||
if (creatureStats.isDead() && creatureStats.isDeathAnimationFinished() && !ptr.getClass().isPersistent(ptr)
|
if (creatureStats.isDead() && creatureStats.isDeathAnimationFinished() && !ptr.getClass().isPersistent(ptr)
|
||||||
&& creatureStats.getTimeOfDeath() + fCorpseClearDelay
|
&& creatureStats.getTimeOfDeath() + fCorpseClearDelay
|
||||||
<= MWBase::Environment::get().getWorld()->getTimeStamp())
|
<= MWBase::Environment::get().getWorld()->getTimeStamp())
|
||||||
@ -1176,11 +1169,8 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
if (mState == State_Loaded)
|
if (mState == State_Loaded)
|
||||||
{
|
{
|
||||||
static const int iMonthsToRespawn = MWBase::Environment::get()
|
static const int iMonthsToRespawn
|
||||||
.getESMStore()
|
= mStore.get<ESM::GameSetting>().find("iMonthsToRespawn")->mValue.getInteger();
|
||||||
->get<ESM::GameSetting>()
|
|
||||||
.find("iMonthsToRespawn")
|
|
||||||
->mValue.getInteger();
|
|
||||||
if (MWBase::Environment::get().getWorld()->getTimeStamp() - mLastRespawn > 24 * 30 * iMonthsToRespawn)
|
if (MWBase::Environment::get().getWorld()->getTimeStamp() - mLastRespawn > 24 * 30 * iMonthsToRespawn)
|
||||||
{
|
{
|
||||||
mLastRespawn = MWBase::Environment::get().getWorld()->getTimeStamp();
|
mLastRespawn = MWBase::Environment::get().getWorld()->getTimeStamp();
|
||||||
@ -1196,14 +1186,14 @@ namespace MWWorld
|
|||||||
it != get<ESM::Creature>().mList.end(); ++it)
|
it != get<ESM::Creature>().mList.end(); ++it)
|
||||||
{
|
{
|
||||||
Ptr ptr = getCurrentPtr(&*it);
|
Ptr ptr = getCurrentPtr(&*it);
|
||||||
clearCorpse(ptr);
|
clearCorpse(ptr, mStore);
|
||||||
ptr.getClass().respawn(ptr);
|
ptr.getClass().respawn(ptr);
|
||||||
}
|
}
|
||||||
for (CellRefList<ESM::NPC>::List::iterator it(get<ESM::NPC>().mList.begin());
|
for (CellRefList<ESM::NPC>::List::iterator it(get<ESM::NPC>().mList.begin());
|
||||||
it != get<ESM::NPC>().mList.end(); ++it)
|
it != get<ESM::NPC>().mList.end(); ++it)
|
||||||
{
|
{
|
||||||
Ptr ptr = getCurrentPtr(&*it);
|
Ptr ptr = getCurrentPtr(&*it);
|
||||||
clearCorpse(ptr);
|
clearCorpse(ptr, mStore);
|
||||||
ptr.getClass().respawn(ptr);
|
ptr.getClass().respawn(ptr);
|
||||||
}
|
}
|
||||||
for (CellRefList<ESM::CreatureLevList>::List::iterator it(get<ESM::CreatureLevList>().mList.begin());
|
for (CellRefList<ESM::CreatureLevList>::List::iterator it(get<ESM::CreatureLevList>().mList.begin());
|
||||||
@ -1256,8 +1246,7 @@ namespace MWWorld
|
|||||||
if (enchantmentId.empty())
|
if (enchantmentId.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ESM::Enchantment* enchantment
|
const ESM::Enchantment* enchantment = mStore.get<ESM::Enchantment>().search(enchantmentId);
|
||||||
= MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(enchantmentId);
|
|
||||||
if (!enchantment)
|
if (!enchantment)
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item "
|
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user