From 40d6f3579a23c50a5570de3f511a407924703ec1 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 29 Apr 2008 01:18:47 +0000 Subject: [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 --- pokemod/Move.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'pokemod/Move.cpp') diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 20e49c21..1c676eac 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -368,20 +368,23 @@ int Move::effectCount() const MoveEffect* Move::newEffect() { - m_effects.append(new MoveEffect(this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MoveEffect(this, newEffectId())); } MoveEffect* Move::newEffect(const QDomElement& xml) { - m_effects.append(new MoveEffect(xml, this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MoveEffect(xml, this, newEffectId())); } MoveEffect* Move::newEffect(const MoveEffect& effect) { - m_effects.append(new MoveEffect(effect, this, newEffectId())); - return m_effects[effectCount() - 1]; + return newEffect(new MoveEffect(effect, this, newEffectId())); +} + +MoveEffect* Move::newEffect(MoveEffect* effect) +{ + m_effects.append(effect); + return effect; } void Move::deleteEffect(const int index) throw(IndexException) @@ -428,3 +431,9 @@ Move& Move::operator=(const Move& rhs) COPY_SUB(MoveEffect, effects); return *this; } + +void Move::clear() +{ + while (effectCount()) + deleteEffect(0); +} -- cgit