Merge branch 'container-regressions' into 'master'

Fix container regressions

See merge request OpenMW/openmw!346

(cherry picked from commit b0aee6f83d4cddb0116284b197913f9687dd9cee)

95e7a22d fix container regressions
pull/593/head
AnyOldName3 4 years ago committed by psi29a
parent de7bafcbbd
commit df178ed97c

@ -230,36 +230,38 @@ namespace MWGui
{ {
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
// Copy mPtr because onTakeAllButtonClicked closes the window which resets the reference
MWWorld::Ptr ptr = mPtr;
onTakeAllButtonClicked(mTakeButton); onTakeAllButtonClicked(mTakeButton);
if (mPtr.getClass().isPersistent(mPtr)) if (ptr.getClass().isPersistent(ptr))
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
else else
{ {
MWMechanics::CreatureStats& creatureStats = mPtr.getClass().getCreatureStats(mPtr); MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
// If we dispose corpse before end of death animation, we should update death counter counter manually. // If we dispose corpse before end of death animation, we should update death counter counter manually.
// Also we should run actor's script - it may react on actor's death. // Also we should run actor's script - it may react on actor's death.
if (creatureStats.isDead() && !creatureStats.isDeathAnimationFinished()) if (creatureStats.isDead() && !creatureStats.isDeathAnimationFinished())
{ {
creatureStats.setDeathAnimationFinished(true); creatureStats.setDeathAnimationFinished(true);
MWBase::Environment::get().getMechanicsManager()->notifyDied(mPtr); MWBase::Environment::get().getMechanicsManager()->notifyDied(ptr);
const std::string script = mPtr.getClass().getScript(mPtr); const std::string script = ptr.getClass().getScript(ptr);
if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled()) if (!script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
{ {
MWScript::InterpreterContext interpreterContext (&mPtr.getRefData().getLocals(), mPtr); MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
} }
// Clean up summoned creatures as well // Clean up summoned creatures as well
std::map<ESM::SummonKey, int>& creatureMap = creatureStats.getSummonedCreatureMap(); std::map<ESM::SummonKey, int>& creatureMap = creatureStats.getSummonedCreatureMap();
for (const auto& creature : creatureMap) for (const auto& creature : creatureMap)
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mPtr, creature.second); MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(ptr, creature.second);
creatureMap.clear(); creatureMap.clear();
} }
MWBase::Environment::get().getWorld()->deleteObject(mPtr); MWBase::Environment::get().getWorld()->deleteObject(ptr);
} }
mPtr = MWWorld::Ptr(); mPtr = MWWorld::Ptr();

@ -30,17 +30,17 @@ namespace Misc
float Rng::rollProbability(Seed& seed) float Rng::rollProbability(Seed& seed)
{ {
return std::uniform_real_distribution<float>(0, 1 - std::numeric_limits<float>::epsilon())(sSeed.mGenerator); return std::uniform_real_distribution<float>(0, 1 - std::numeric_limits<float>::epsilon())(seed.mGenerator);
} }
float Rng::rollClosedProbability(Seed& seed) float Rng::rollClosedProbability(Seed& seed)
{ {
return std::uniform_real_distribution<float>(0, 1)(sSeed.mGenerator); return std::uniform_real_distribution<float>(0, 1)(seed.mGenerator);
} }
int Rng::rollDice(int max, Seed& seed) int Rng::rollDice(int max, Seed& seed)
{ {
return max > 0 ? std::uniform_int_distribution<int>(0, max - 1)(sSeed.mGenerator) : 0; return max > 0 ? std::uniform_int_distribution<int>(0, max - 1)(seed.mGenerator) : 0;
} }
unsigned int Rng::generateDefaultSeed() unsigned int Rng::generateDefaultSeed()

Loading…
Cancel
Save