1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 03:15:32 +00:00

Move container unresolving to the separate method

This commit is contained in:
Andrei Kortunov 2021-04-14 23:03:35 +04:00
parent 4f72fa2615
commit db1428de18
2 changed files with 22 additions and 20 deletions

View file

@ -75,27 +75,13 @@ namespace
MWWorld::ResolutionListener::~ResolutionListener()
{
if(!mStore.mModified && mStore.mResolved && !mStore.mPtr.isEmpty())
try
{
try
{
for(const auto&& ptr : mStore)
ptr.getRefData().setCount(0);
}
catch(const std::exception& e)
{
Log(Debug::Warning) << "Failed to clear temporary container contents of " << mStore.mPtr.get<ESM::Container>()->mBase->mId << ": " << e.what();
}
mStore.fillNonRandom(mStore.mPtr.get<ESM::Container>()->mBase->mInventory, "", mStore.mSeed);
try
{
addScripts(mStore, mStore.mPtr.mCell);
}
catch(const std::exception& e)
{
Log(Debug::Warning) << "Failed to restart item scripts inside " << mStore.mPtr.get<ESM::Container>()->mBase->mId << ": " << e.what();
}
mStore.mResolved = false;
mStore.unresolve();
}
catch(const std::exception& e)
{
Log(Debug::Error) << "Failed to clear temporary container contents of " << mStore.mPtr.get<ESM::Container>()->mBase->mId << ": " << e.what();
}
}
@ -662,6 +648,21 @@ MWWorld::ResolutionHandle MWWorld::ContainerStore::resolveTemporarily()
return {listener};
}
void MWWorld::ContainerStore::unresolve()
{
if (mModified)
return;
if (mResolved && !mPtr.isEmpty())
{
for(const auto&& ptr : *this)
ptr.getRefData().setCount(0);
fillNonRandom(mPtr.get<ESM::Container>()->mBase->mInventory, "", mSeed);
addScripts(*this, mPtr.mCell);
mResolved = false;
}
}
float MWWorld::ContainerStore::getWeight() const
{
if (!mWeightUpToDate)

View file

@ -250,6 +250,7 @@ namespace MWWorld
void resolve();
ResolutionHandle resolveTemporarily();
void unresolve();
friend class ContainerStoreIteratorBase<Ptr>;
friend class ContainerStoreIteratorBase<ConstPtr>;