From e4adf9e064f6c684665021d4709c0b270dc75ab0 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Fri, 15 Aug 2025 16:29:13 +0200 Subject: [PATCH] Don't use ESM::Spell::mData::mCost directly --- apps/openmw/mwgui/spellbuyingwindow.cpp | 2 +- apps/openmw/mwgui/tooltips.cpp | 3 +-- apps/openmw/mwmechanics/security.cpp | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 4a9f118d75..bdd4525c24 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -78,7 +78,7 @@ namespace MWGui toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Spell", spell.mId.serialize()); - toAdd->setUserString("SpellCost", std::to_string(spell.mData.mCost)); + toAdd->setUserString("SpellCost", "true"); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick); mSpellsWidgetMap.insert(std::make_pair(toAdd, spell.mId)); if (price <= playerGold) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 76bfa18d5e..7233c6508d 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -247,8 +247,7 @@ namespace MWGui info.text = "#{sSchool}: " + MyGUI::TextIterator::toTagsString(school->mName).asUTF8(); } } - auto cost = focus->getUserString("SpellCost"); - if (!cost.empty() && cost != "0") + if (focus->getUserString("SpellCost") == "true") info.text += MWGui::ToolTips::getValueString(MWMechanics::calcSpellCost(*spell), "#{sCastCost}"); info.effects = std::move(effects); diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 0fb8a95699..233856d344 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -11,6 +11,7 @@ #include "../mwbase/world.hpp" #include "creaturestats.hpp" +#include "spellutil.hpp" namespace MWMechanics { @@ -89,7 +90,7 @@ namespace MWMechanics const ESM::Spell* trapSpell = MWBase::Environment::get().getESMStore()->get().find(trap.getCellRef().getTrap()); - int trapSpellPoints = trapSpell->mData.mCost; + int trapSpellPoints = MWMechanics::calcSpellCost(*trapSpell); float fTrapCostMult = MWBase::Environment::get() .getESMStore()