diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-29 01:18:47 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-29 01:18:47 +0000 |
commit | 40d6f3579a23c50a5570de3f511a407924703ec1 (patch) | |
tree | deba50e4749e2bcdf3bb7ff7bb2aa57ab1121178 /pokemod/Item.cpp | |
parent | 72e08e3222064d72d7a6f1bf9fcb294b22569c06 (diff) | |
download | sigen-40d6f3579a23c50a5570de3f511a407924703ec1.tar.gz sigen-40d6f3579a23c50a5570de3f511a407924703ec1.tar.xz sigen-40d6f3579a23c50a5570de3f511a407924703ec1.zip |
[FIX] Less repetative code in pokemod
[FIX] clear is no longer inline
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@115 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Item.cpp')
-rw-r--r-- | pokemod/Item.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp index 90d0262e..21d3c118 100644 --- a/pokemod/Item.cpp +++ b/pokemod/Item.cpp @@ -213,20 +213,23 @@ int Item::effectCount() const ItemEffect* Item::newEffect() { - m_effects.append(new ItemEffect(this, effectId())); - return m_effects[effectCount() - 1]; + return newEffect(new ItemEffect(this, effectId())); } ItemEffect* Item::newEffect(const QDomElement& xml) { - m_effects.append(new ItemEffect(xml, this, effectId())); - return m_effects[effectCount() - 1]; + return newEffect(new ItemEffect(xml, this, effectId())); } ItemEffect* Item::newEffect(const ItemEffect& effect) { - m_effects.append(new ItemEffect(effect, this, effectId())); - return m_effects[effectCount() - 1]; + return newEffect(new ItemEffect(effect, this, effectId())); +} + +ItemEffect* Item::newEffect(ItemEffect* effect) +{ + m_effects.append(effect); + return effect; } void Item::deleteEffect(const int index) throw(IndexException) @@ -263,3 +266,9 @@ Item& Item::operator=(const Item& rhs) COPY_SUB(ItemEffect, effects); return *this; } + +void Item::clear() +{ + while (effectCount()) + deleteEffect(0); +} |