Merge pull request #3065 from akortunov/master

Move container unresolving to the separate method
pull/593/head
Bret Curtis 4 years ago committed by GitHub
commit 21a235f173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

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

Loading…
Cancel
Save