Issue #314: added return value to addSpell function

actorid
Marc Zinnschlag 13 years ago
parent aa827442e8
commit 83c3972a89

@ -89,7 +89,7 @@ namespace MWMechanics
: mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp())
{}
void ActiveSpells::addSpell (const std::string& id)
bool ActiveSpells::addSpell (const std::string& id)
{
const ESM::EffectList& effects = getEffectList (id);
@ -106,7 +106,7 @@ namespace MWMechanics
}
if (!found)
return;
return false;
TContainer::iterator iter = mSpells.find (id);
@ -119,6 +119,8 @@ namespace MWMechanics
iter->second = std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random);
mSpellsChanged = true;
return true;
}
void ActiveSpells::removeSpell (const std::string& id)

@ -43,9 +43,11 @@ namespace MWMechanics
ActiveSpells();
void addSpell (const std::string& id);
bool addSpell (const std::string& id);
///< Overwrites an existing spell with the same ID. If the spell does not have any
/// non-instant effects, it is ignored.
///
/// \return Has the spell been added?
void removeSpell (const std::string& id);

@ -32,6 +32,11 @@ namespace MWWorld
}
bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id) const
{
return false;
}
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
{
throw std::runtime_error ("class does not have creature stats");

@ -164,6 +164,12 @@ namespace MWWorld
/// effects). Throws an exception, if the object can't hold other objects.
/// (default implementation: throws an exception)
virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id) const;
///< Apply \a id on \a ptr.
/// \return Any effect?
///
/// (default implementation: ignore and return false)
static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown.

Loading…
Cancel
Save