From 6c47f95677e748e1e2aea4324ab6f1d95824a72a Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 27 Aug 2018 02:17:49 +0300 Subject: [PATCH 1/3] Make RemoveSpellEffects affect permanent spells (bug #3920) Also make it remove the effects but not the spells themselves --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/activespells.cpp | 8 ++++++-- apps/openmw/mwmechanics/spells.cpp | 13 +++++++++++++ apps/openmw/mwmechanics/spells.hpp | 2 ++ apps/openmw/mwscript/statsextensions.cpp | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5453ffb49..f147c7536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Bug #3876: Landscape texture painting is misaligned Bug #3897: Have Goodbye give all choices the effects of Goodbye Bug #3911: [macOS] Typing in the "Content List name" dialog box produces double characters + Bug #3920: RemoveSpellEffects doesn't remove constant effects Bug #3948: AiCombat moving target aiming uses incorrect speed for magic projectiles Bug #3950: FLATTEN_STATIC_TRANSFORMS optimization breaks animated collision shapes Bug #3993: Terrain texture blending map is not upscaled diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 90d29f686..9e523a845 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -197,8 +197,12 @@ namespace MWMechanics void ActiveSpells::removeEffects(const std::string &id) { - mSpells.erase(Misc::StringUtils::lowerCase(id)); - mSpellsChanged = true; + TContainer::iterator spell(mSpells.find(id)); + if (spell != end()); + { + spell->second.mEffects.clear(); + mSpellsChanged = true; + } } void ActiveSpells::visitEffectSources(EffectSourceVisitor &visitor) const diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index ff397f69d..25f301118 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -279,6 +279,19 @@ namespace MWMechanics } } + void Spells::removeEffects(const std::string &id) + { + if (isSpellActive(id)) + { + TContainer::iterator spellIt = mSpells.find(getSpell(id)); + for (long unsigned int i = 0; i != spellIt->first->mEffects.mList.size(); i++) + { + spellIt->second.mPurgedEffects.insert(i); + mSpellsChanged = true; + } + } + } + void Spells::visitEffectSources(EffectSourceVisitor &visitor) const { if (mSpellsChanged) { diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index c1705b38a..e635f4f56 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -124,6 +124,8 @@ namespace MWMechanics bool hasBlightDisease() const; + void removeEffects(const std::string& id); + void visitEffectSources (MWMechanics::EffectSourceVisitor& visitor) const; void readState (const ESM::SpellState& state); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 5df767da8..29160d47e 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -501,6 +501,7 @@ namespace MWScript runtime.pop(); ptr.getClass().getCreatureStats (ptr).getActiveSpells().removeEffects(spellid); + ptr.getClass().getCreatureStats (ptr).getSpells().removeEffects(spellid); } }; From ed1f8f7be7b43d1ca6b1154c7b9f33633835d6c6 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 29 Aug 2018 13:40:37 +0300 Subject: [PATCH 2/3] Remove effects from all active spells with the same ID --- apps/openmw/mwmechanics/activespells.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 9e523a845..57b009689 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -197,11 +197,13 @@ namespace MWMechanics void ActiveSpells::removeEffects(const std::string &id) { - TContainer::iterator spell(mSpells.find(id)); - if (spell != end()); + for (TContainer::iterator spell = mSpells.begin(); spell != mSpells.end(); ++spell) { - spell->second.mEffects.clear(); - mSpellsChanged = true; + if (spell->first == id) + { + spell->second.mEffects.clear(); + mSpellsChanged = true; + } } } From b8ba9092cb1657df934ece8c7d93dae135dab6ea Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 29 Aug 2018 14:09:43 +0300 Subject: [PATCH 3/3] Purge effects from all permanent spells with the same ID --- apps/openmw/mwmechanics/spells.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 25f301118..0a11ed641 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -283,12 +283,18 @@ namespace MWMechanics { if (isSpellActive(id)) { - TContainer::iterator spellIt = mSpells.find(getSpell(id)); - for (long unsigned int i = 0; i != spellIt->first->mEffects.mList.size(); i++) + for (TContainer::iterator spell = mSpells.begin(); spell != mSpells.end(); ++spell) { - spellIt->second.mPurgedEffects.insert(i); - mSpellsChanged = true; + if (spell->first == getSpell(id)) + { + for (long unsigned int i = 0; i != spell->first->mEffects.mList.size(); i++) + { + spell->second.mPurgedEffects.insert(i); + } + } } + + mSpellsChanged = true; } }