From 2934987f78a556e0451bc8498f597af37169b51a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 10:52:34 +0200 Subject: [PATCH] Issue #356: Some CreatureStats cleanup --- apps/openmw/mwmechanics/creaturestats.cpp | 172 +++++++++++++++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 178 ---------------------- 2 files changed, 172 insertions(+), 178 deletions(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 49e5bb3900..0d8dab0f52 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -75,4 +75,176 @@ namespace MWMechanics return store.gameSettings.find ("fFatigueBase")->getFloat() - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); } + + const Stat &CreatureStats::getAttribute(int index) const + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + return mAttributes[index]; + } + + const DynamicStat &CreatureStats::getHealth() const + { + return mDynamic[0]; + } + + const DynamicStat &CreatureStats::getMagicka() const + { + return mDynamic[1]; + } + + const DynamicStat &CreatureStats::getFatigue() const + { + return mDynamic[2]; + } + + const Spells &CreatureStats::getSpells() const + { + return mSpells; + } + + const ActiveSpells &CreatureStats::getActiveSpells() const + { + return mActiveSpells; + } + + const MagicEffects &CreatureStats::getMagicEffects() const + { + return mMagicEffects; + } + + int CreatureStats::getLevel() const + { + return mLevel; + } + + int CreatureStats::getHello() const + { + return mHello; + } + + int CreatureStats::getFight() const + { + return mFight; + } + + int CreatureStats::getFlee() const + { + return mFlee; + } + + int CreatureStats::getAlarm() const + { + return mAlarm; + } + + Stat &CreatureStats::getAttribute(int index) + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + return mAttributes[index]; + } + + DynamicStat &CreatureStats::getHealth() + { + return mDynamic[0]; + } + + DynamicStat &CreatureStats::getMagicka() + { + return mDynamic[1]; + } + + DynamicStat &CreatureStats::getFatigue() + { + return mDynamic[2]; + } + + DynamicStat &CreatureStats::getDynamic(int index) + { + if (index < 0 || index > 2) { + throw std::runtime_error("dynamic stat index is out of range"); + } + return mDynamic[index]; + } + + Spells &CreatureStats::getSpells() + { + return mSpells; + } + + void CreatureStats::setSpells(const Spells &spells) + { + mSpells = spells; + } + + ActiveSpells &CreatureStats::getActiveSpells() + { + return mActiveSpells; + } + + MagicEffects &CreatureStats::getMagicEffects() + { + return mMagicEffects; + } + + void CreatureStats::setAttribute(int index, const Stat &value) + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + mAttributes[index] = value; + } + + void CreatureStats::setHealth(const DynamicStat &value) + { + mDynamic[0] = value; + } + + void CreatureStats::setMagicka(const DynamicStat &value) + { + mDynamic[1] = value; + } + + void CreatureStats::setFatigue(const DynamicStat &value) + { + mDynamic[2] = value; + } + + void CreatureStats::setLevel(int level) + { + mLevel = level; + } + + void CreatureStats::setActiveSpells(const ActiveSpells &active) + { + mActiveSpells = active; + } + + void CreatureStats::setMagicEffects(const MagicEffects &effects) + { + mMagicEffects = effects; + } + + void CreatureStats::setHello(int value) + { + mHello = value; + } + + void CreatureStats::setFight(int value) + { + mFight = value; + } + + void CreatureStats::setFlee(int value) + { + mFlee = value; + } + + void CreatureStats::setAlarm(int value) + { + mAlarm = value; + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index bb6ec94515..d8d0f957a1 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -110,184 +110,6 @@ namespace MWMechanics float getFatigueTerm() const; ///< Return effective fatigue }; - - // Inline const getters - - inline const Stat & - CreatureStats::getAttribute(int index) const { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - return mAttributes[index]; - } - - inline const DynamicStat & - CreatureStats::getHealth() const { - return mDynamic[0]; - } - - inline const DynamicStat & - CreatureStats::getMagicka() const { - return mDynamic[1]; - } - - inline const DynamicStat & - CreatureStats::getFatigue() const { - return mDynamic[2]; - } - - inline const Spells & - CreatureStats::getSpells() const { - return mSpells; - } - - inline const ActiveSpells & - CreatureStats::getActiveSpells() const { - return mActiveSpells; - } - - inline const MagicEffects & - CreatureStats::getMagicEffects() const { - return mMagicEffects; - } - - inline int - CreatureStats::getLevel() const { - return mLevel; - } - - inline int - CreatureStats::getHello() const { - return mHello; - } - - inline int - CreatureStats::getFight() const { - return mFight; - } - - inline int - CreatureStats::getFlee() const { - return mFlee; - } - - inline int - CreatureStats::getAlarm() const { - return mAlarm; - } - - // Inline non-const getters - - inline Stat & - CreatureStats::getAttribute(int index) { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - return mAttributes[index]; - } - - inline DynamicStat & - CreatureStats::getHealth() { - return mDynamic[0]; - } - - inline DynamicStat & - CreatureStats::getMagicka() { - return mDynamic[1]; - } - - inline DynamicStat & - CreatureStats::getFatigue() { - return mDynamic[2]; - } - - inline DynamicStat & - CreatureStats::getDynamic(int index) { - if (index < 0 || index > 2) { - throw std::runtime_error("dynamic stat index is out of range"); - } - return mDynamic[index]; - } - - inline Spells & - CreatureStats::getSpells() { - return mSpells; - } - - inline void - CreatureStats::setSpells(const Spells &spells) { - mSpells = spells; - } - - inline ActiveSpells & - CreatureStats::getActiveSpells() { - return mActiveSpells; - } - - inline MagicEffects & - CreatureStats::getMagicEffects() { - return mMagicEffects; - } - - // Inline setters - - inline void - CreatureStats::setAttribute(int index, const Stat &value) { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - mAttributes[index] = value; - } - - inline void - CreatureStats::setHealth(const DynamicStat &value) { - mDynamic[0] = value; - } - - inline void - CreatureStats::setMagicka(const DynamicStat &value) { - mDynamic[1] = value; - } - - inline void - CreatureStats::setFatigue(const DynamicStat &value) { - mDynamic[2] = value; - } - - inline void - CreatureStats::setLevel(int level) { - mLevel = level; - } - - inline void - CreatureStats::setActiveSpells(const ActiveSpells &active) { - mActiveSpells = active; - } - - inline void - CreatureStats::setMagicEffects(const MagicEffects &effects) { - mMagicEffects = effects; - } - - inline void - CreatureStats::setHello(int value) { - mHello = value; - } - - inline void - CreatureStats::setFight(int value) { - mFight = value; - } - - inline void - CreatureStats::setFlee(int value) { - mFlee = value; - } - - inline void - CreatureStats::setAlarm(int value) { - mAlarm = value; - } } #endif