From 3d5950f790dd5e6baf59e00f1cf6fe3143acde70 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 9 Oct 2021 12:27:17 +0200 Subject: [PATCH] Remove active effects from spells that no longer exist --- apps/openmw/mwmechanics/activespells.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 6ad6ef369e..fc35e40b74 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -1,5 +1,7 @@ #include "activespells.hpp" +#include + #include #include @@ -234,7 +236,17 @@ namespace MWMechanics bool remove = false; if(spellIt->mType == ESM::ActiveSpells::Type_Ability || spellIt->mType == ESM::ActiveSpells::Type_Permanent) - remove = !spells.hasSpell(spellIt->mId); + { + try + { + remove = !spells.hasSpell(spellIt->mId); + } + catch(const std::runtime_error& e) + { + remove = true; + Log(Debug::Error) << "Removing active effect: " << e.what(); + } + } else if(spellIt->mType == ESM::ActiveSpells::Type_Enchantment) { const auto& store = ptr.getClass().getInventoryStore(ptr);