From 77cb438714963b70cee791ec5d592cf1c5fda2fb Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 5 Oct 2015 15:41:07 +0200 Subject: [PATCH 1/2] Fix potential case smashing issue --- apps/openmw/mwmechanics/spells.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 6d7673a59..330d78a20 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -312,7 +312,7 @@ namespace MWMechanics bool Spells::canUsePower(const std::string &power) const { - std::map::const_iterator it = mUsedPowers.find(power); + std::map::const_iterator it = mUsedPowers.find(Misc::StringUtils::lowerCase(power)); if (it == mUsedPowers.end() || it->second + 24 <= MWBase::Environment::get().getWorld()->getTimeStamp()) return true; else @@ -321,7 +321,7 @@ namespace MWMechanics void Spells::usePower(const std::string &power) { - mUsedPowers[power] = MWBase::Environment::get().getWorld()->getTimeStamp(); + mUsedPowers[Misc::StringUtils::lowerCase(power)] = MWBase::Environment::get().getWorld()->getTimeStamp(); } void Spells::readState(const ESM::SpellState &state) From 7b6fe149f2770de7d019696b6e2f6d0bbb670c6e Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 5 Oct 2015 15:41:43 +0200 Subject: [PATCH 2/2] getSpellSuccessChance return 0 for used powers (Fixes #2944) --- apps/openmw/mwmechanics/spellcasting.cpp | 7 +++++++ apps/openmw/mwworld/worldimp.cpp | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 6d6b9d950..70d097687 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -123,6 +123,9 @@ namespace MWMechanics } } + if (spell->mData.mType == ESM::Spell::ST_Power) + return stats.getSpells().canUsePower(spell->mId) ? 100 : 0; + if (spell->mData.mType != ESM::Spell::ST_Spell) return 100; @@ -817,6 +820,10 @@ namespace MWMechanics sndMgr->playSound3D(mCaster, "Spell Failure " + schools[school], 1.0f, 1.0f); return false; } + + // A power can be used once per 24h + if (spell->mData.mType == ESM::Spell::ST_Power) + stats.getSpells().usePower(spell->mId); } if (mCaster == getPlayer() && spellIncreasesSkill(spell)) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 585786136..d994a35ee 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2660,10 +2660,6 @@ namespace MWWorld { const ESM::Spell* spell = getStore().get().find(selectedSpell); - // A power can be used once per 24h - if (spell->mData.mType == ESM::Spell::ST_Power) - stats.getSpells().usePower(spell->mId); - cast.cast(spell); } else if (actor.getClass().hasInventoryStore(actor))