mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +00:00
Merge pull request #3065 from akortunov/master
Move container unresolving to the separate method
This commit is contained in:
commit
21a235f173
2 changed files with 22 additions and 20 deletions
|
@ -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…
Reference in a new issue