diff options
author | Fate <fate-tmw@googlemail.com> | 2008-12-09 09:42:59 -0700 |
---|---|---|
committer | Fate <fate-tmw@googlemail.com> | 2008-12-09 09:42:59 -0700 |
commit | 5de95ae6a741ac8549a9e51be4a3872e91764d24 (patch) | |
tree | cce603d128c9ccf7c53eced54a424a3a66e27bbc /src | |
parent | caee40df5da03eb2db6ed8d528f1561ef9bcbd34 (diff) | |
download | mana-client-5de95ae6a741ac8549a9e51be4a3872e91764d24.tar.gz mana-client-5de95ae6a741ac8549a9e51be4a3872e91764d24.tar.bz2 mana-client-5de95ae6a741ac8549a9e51be4a3872e91764d24.tar.xz mana-client-5de95ae6a741ac8549a9e51be4a3872e91764d24.zip |
Defer re-adding of particles to next call to Being::logic() to avoid crash
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 16 | ||||
-rw-r--r-- | src/being.h | 1 | ||||
-rw-r--r-- | src/statuseffect.cpp | 6 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2be72360..68b1a791 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -78,7 +78,8 @@ Being::Being(int id, int job, Map *map): mSpriteIDs(VECTOREND_SPRITE, 0), mSpriteColors(VECTOREND_SPRITE, ""), mStatusParticleEffects(&mStunParticleEffects, false), - mChildParticleEffects(&mStatusParticleEffects, false) + mChildParticleEffects(&mStatusParticleEffects, false), + mMustResetParticles(false) { setMap(map); @@ -216,6 +217,7 @@ void Being::setMap(Map *map) // Clear particle effect list because child particles became invalid mChildParticleEffects.clear(); + mMustResetParticles = true; // Reset status particles on next redraw } void Being::controlParticle(Particle *particle) @@ -390,9 +392,21 @@ void Being::logic() } } + // Restart status/particle effects, if needed + if (mMustResetParticles) { + mMustResetParticles = false; + for (std::set<int>::iterator it = mStatusEffects.begin(); + it != mStatusEffects.end(); it++) { + const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true); + if (effect && effect->particleEffectIsPersistent()) + updateStatusEffect(*it, true); + } + } + // Update particle effects mChildParticleEffects.setPositions((float) mPx + 16.0f, (float) mPy + 32.0f); + } void Being::draw(Graphics *graphics, int offsetX, int offsetY) const diff --git a/src/being.h b/src/being.h index de558f83..d7f78753 100644 --- a/src/being.h +++ b/src/being.h @@ -460,6 +460,7 @@ class Being : public Sprite static int instances; /**< Number of Being instances */ static ImageSet *emotionSet; /**< Emoticons used by beings */ + bool mMustResetParticles; /**< Reset particle status effects on next redraw? */ }; #endif diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 8aeb66c6..6397f615 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -30,7 +30,8 @@ #define STATUS_EFFECTS_FILE "status-effects.xml" -StatusEffect::StatusEffect() +StatusEffect::StatusEffect() : + mPersistentParticleEffect(false) {} StatusEffect::~StatusEffect() @@ -156,13 +157,12 @@ void StatusEffect::load() startEffect->mParticleEffect = XML::getProperty(node, "start-particle", ""); startEffect->mIcon = XML::getProperty(node, "icon", ""); startEffect->mAction = XML::getProperty(node, "action", ""); + startEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no"; endEffect->mMessage = XML::getProperty(node, "end-message", ""); endEffect->mSFXEffect = XML::getProperty(node, "end-audio", ""); endEffect->mParticleEffect = XML::getProperty(node, "end-particle", ""); - endEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no"; - (*the_map)[1][index] = startEffect; (*the_map)[0][index] = endEffect; } |