1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 09:53:50 +00:00

Issue #314: added return value to addSpell function

This commit is contained in:
Marc Zinnschlag 2012-06-24 16:23:43 +02:00
parent aa827442e8
commit 83c3972a89
4 changed files with 18 additions and 3 deletions

View file

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

View file

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

View file

@ -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 MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
{ {
throw std::runtime_error ("class does not have creature stats"); throw std::runtime_error ("class does not have creature stats");

View file

@ -164,6 +164,12 @@ namespace MWWorld
/// effects). Throws an exception, if the object can't hold other objects. /// effects). Throws an exception, if the object can't hold other objects.
/// (default implementation: throws an exception) /// (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); static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown. ///< If there is no class for this \a key, an exception is thrown.