From b40e24c50c5461892911d30ed997b49fc1d07ba0 Mon Sep 17 00:00:00 2001 From: Miroslav Puda Date: Mon, 27 May 2013 20:23:04 +0200 Subject: [PATCH] Refactorization --- apps/openmw/mwgui/enchantingdialog.cpp | 12 +++---- apps/openmw/mwmechanics/enchanting.cpp | 44 +++++++++++++------------- apps/openmw/mwmechanics/enchanting.hpp | 2 +- components/esm/defs.hpp | 8 ++--- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index 7f71716ed..0db577de2 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -61,7 +61,7 @@ namespace MWGui void EnchantingDialog::updateLabels() { std::stringstream enchantCost; - enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantCost(); + enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantPoints(); mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast(mEnchanting.getMaxEnchantValue())); mCharge->setCaption(boost::lexical_cast(mEnchanting.getGemCharge())); @@ -74,19 +74,19 @@ namespace MWGui switch(mEnchanting.getCastStyle()) { - case ESM::CS_CastOnce: + case ESM::CastingStyle_CastOnce: mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once")); mAddEffectDialog.constantEffect=false; break; - case ESM::CS_WhenStrikes: + case ESM::CastingStyle_WhenStrikes: mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes")); mAddEffectDialog.constantEffect=false; break; - case ESM::CS_WhenUsed: + case ESM::CastingStyle_WhenUsed: mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used")); mAddEffectDialog.constantEffect=false; break; - case ESM::CS_ConstantEffect: + case ESM::CastingStyle_ConstantEffect: mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant")); mAddEffectDialog.constantEffect=true; break; @@ -280,7 +280,7 @@ namespace MWGui return; } - if (mEnchanting.getEnchantCost() > mEnchanting.getMaxEnchantValue()) + if (mEnchanting.getEnchantPoints() > mEnchanting.getMaxEnchantValue()) { MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage29}"); return; diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 821df8fba..5be0d83e7 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -12,7 +12,7 @@ namespace MWMechanics { Enchanting::Enchanting(): - mCastStyle(ESM::CS_CastOnce) + mCastStyle(ESM::CastingStyle_CastOnce) {} void Enchanting::setOldItem(MWWorld::Ptr oldItem) @@ -74,12 +74,12 @@ namespace MWMechanics MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 1); } - if(mCastStyle==ESM::CS_ConstantEffect) + if(mCastStyle==ESM::CastingStyle_ConstantEffect) { enchantment.mData.mCharge=0; } enchantment.mData.mType = mCastStyle; - enchantment.mData.mCost = getEnchantCost(); + enchantment.mData.mCost = getEnchantPoints(); enchantment.mEffects = mEffectList; const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment); @@ -102,7 +102,7 @@ namespace MWMechanics { if (itemEmpty()) { - mCastStyle = ESM::CS_WhenUsed; + mCastStyle = ESM::CastingStyle_WhenUsed; return; } @@ -112,12 +112,12 @@ namespace MWMechanics { // Armor or Clothing switch(mCastStyle) { - case ESM::CS_WhenUsed: + case ESM::CastingStyle_WhenUsed: if (powerfulSoul) - mCastStyle = ESM::CS_ConstantEffect; + mCastStyle = ESM::CastingStyle_ConstantEffect; return; default: // takes care of Constant effect too - mCastStyle = ESM::CS_WhenUsed; + mCastStyle = ESM::CastingStyle_WhenUsed; return; } } @@ -125,28 +125,28 @@ namespace MWMechanics { // Weapon switch(mCastStyle) { - case ESM::CS_WhenStrikes: - mCastStyle = ESM::CS_WhenUsed; + case ESM::CastingStyle_WhenStrikes: + mCastStyle = ESM::CastingStyle_WhenUsed; return; - case ESM::CS_WhenUsed: + case ESM::CastingStyle_WhenUsed: if (powerfulSoul) - mCastStyle = ESM::CS_ConstantEffect; + mCastStyle = ESM::CastingStyle_ConstantEffect; else - mCastStyle = ESM::CS_WhenStrikes; + mCastStyle = ESM::CastingStyle_WhenStrikes; return; default: // takes care of Constant effect too - mCastStyle = ESM::CS_WhenStrikes; + mCastStyle = ESM::CastingStyle_WhenStrikes; return; } } else if(mObjectType == typeid(ESM::Book).name()) { // Scroll or Book - mCastStyle = ESM::CS_CastOnce; + mCastStyle = ESM::CastingStyle_CastOnce; return; } // Fail case - mCastStyle = ESM::CS_CastOnce; + mCastStyle = ESM::CastingStyle_CastOnce; } /* @@ -163,7 +163,7 @@ namespace MWMechanics * * Formula on UESPWiki is not entirely correct. */ - float Enchanting::getEnchantCost() const + float Enchanting::getEnchantPoints() const { if (mEffectList.mList.empty()) // No effects added, cost = 0 @@ -184,7 +184,7 @@ namespace MWMechanics magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax; area = (it->mArea == 0) ? 1 : it->mArea; - if (mCastStyle == ESM::CS_ConstantEffect) + if (mCastStyle == ESM::CastingStyle_ConstantEffect) { magnitudeCost = (magMin + magMax) * baseCost * 2.5; } @@ -209,10 +209,10 @@ namespace MWMechanics float Enchanting::getCastCost() const { - if (mCastStyle == ESM::CS_ConstantEffect) + if (mCastStyle == ESM::CastingStyle_ConstantEffect) return 0; - const float enchantCost = getEnchantCost(); + const float enchantCost = getEnchantPoints(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player); int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified(); @@ -233,7 +233,7 @@ namespace MWMechanics return 0; float priceMultipler = MWBase::Environment::get().getWorld()->getStore().get().find ("fEnchantmentValueMult")->getFloat(); - int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantCost() * priceMultipler), true); + int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantPoints() * priceMultipler), true); return price; } @@ -290,8 +290,8 @@ namespace MWMechanics (0.25 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()) + (0.125 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified())); - float chance2 = 2.5 * getEnchantCost(); - if(mCastStyle==ESM::CS_ConstantEffect) + float chance2 = 2.5 * getEnchantPoints(); + if(mCastStyle==ESM::CastingStyle_ConstantEffect) { float constantChance = MWBase::Environment::get().getWorld()->getStore().get().find ("fEnchantmentConstantChanceMult")->getFloat(); chance2 /= constantChance; diff --git a/apps/openmw/mwmechanics/enchanting.hpp b/apps/openmw/mwmechanics/enchanting.hpp index fefabd308..4321e5bd6 100644 --- a/apps/openmw/mwmechanics/enchanting.hpp +++ b/apps/openmw/mwmechanics/enchanting.hpp @@ -36,7 +36,7 @@ namespace MWMechanics bool create(); //Return true if created, false if failed. void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object) int getCastStyle() const; - float getEnchantCost() const; + float getEnchantPoints() const; float getCastCost() const; int getEnchantPrice() const; float getMaxEnchantValue() const; diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 7586413a6..cf7b586fc 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -26,10 +26,10 @@ enum RangeType // Casting style (in enchanting) enum CastingStyle { - CS_CastOnce = 0, - CS_WhenStrikes = 1, - CS_WhenUsed = 2, - CS_ConstantEffect = 3 + CastingStyle_CastOnce = 0, + CastingStyle_WhenStrikes = 1, + CastingStyle_WhenUsed = 2, + CastingStyle_ConstantEffect = 3 }; #pragma pack(push)