diff options
author | Fate <fate-tmw@googlemail.com> | 2008-12-09 08:37:38 -0700 |
---|---|---|
committer | Fate <fate-tmw@googlemail.com> | 2008-12-09 08:37:38 -0700 |
commit | caee40df5da03eb2db6ed8d528f1561ef9bcbd34 (patch) | |
tree | 898b2f02f0109864aff772567abb2c37d9ab5149 /src | |
parent | b8cca9c48d6ea5a2372e10bbe2a75ae95917db42 (diff) | |
download | mana-caee40df5da03eb2db6ed8d528f1561ef9bcbd34.tar.gz mana-caee40df5da03eb2db6ed8d528f1561ef9bcbd34.tar.bz2 mana-caee40df5da03eb2db6ed8d528f1561ef9bcbd34.tar.xz mana-caee40df5da03eb2db6ed8d528f1561ef9bcbd34.zip |
Status particle effects: when looking up block IDs (effect IDs for other
players), make sure to initialise if needed
Status particle effects: properly delete particles after effect has worn
off
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 12 | ||||
-rw-r--r-- | src/particlecontainer.cpp | 3 | ||||
-rw-r--r-- | src/statuseffect.cpp | 4 | ||||
-rw-r--r-- | src/statuseffect.h | 7 |
4 files changed, 19 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp index 85807b2f..2be72360 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -432,6 +432,7 @@ Being::setStatusEffectBlock(int offset, Uint16 newEffects) { for (int i = 0; i < STATUS_EFFECTS; i++) { int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i); + if (index != -1) setStatusEffect(index, (newEffects & (1 << i)) > 0); } @@ -451,13 +452,12 @@ Being::handleStatusEffect(StatusEffect *effect, int effectId) Particle *particle = effect->getParticle(); - if (particle) { - if (effectId >= 0) - mStatusParticleEffects.setLocally(effectId, particle); - else { - mStunParticleEffects.clearLocally(); + if (effectId >= 0) + mStatusParticleEffects.setLocally(effectId, particle); + else { + mStunParticleEffects.clearLocally(); + if (particle) mStunParticleEffects.addLocally(particle); - } } } diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index ddd99ff2..bf15f1b5 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -130,7 +130,8 @@ void ParticleVector::setLocally(int index, Particle *particle) if (mIndexedElements.size() <= (unsigned) index) mIndexedElements.resize(index + 1, NULL); - particle->disableAutoDelete(); + if (particle) + particle->disableAutoDelete(); mIndexedElements[index] = particle; } diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index eeae45d8..8aeb66c6 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -91,6 +91,7 @@ static std::map<int, int> blockEffectIndexMap; int StatusEffect::blockEffectIndexToEffectIndex(int blockIndex) { + load(); if (blockEffectIndexMap.find(blockIndex) == blockEffectIndexMap.end()) return -1; return blockEffectIndexMap[blockIndex]; @@ -142,6 +143,7 @@ void StatusEffect::load() if (index >= 0 && block_index >= 0) blockEffectIndexMap[block_index] = index; + } else if (xmlStrEqual(node->name, BAD_CAST "stun-effect")) the_map = &stunEffects; @@ -159,6 +161,8 @@ void StatusEffect::load() 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; } diff --git a/src/statuseffect.h b/src/statuseffect.h index 5d18ac92..c720ed97 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -60,6 +60,12 @@ public: */ SpriteAction getAction(); + /** + * Determines whether the particle effect should be restarted when the + * being changes maps + */ + bool particleEffectIsPersistent() const { return mPersistentParticleEffect; } + /** * Retrieves a status effect. @@ -96,6 +102,7 @@ private: std::string mParticleEffect; std::string mIcon; std::string mAction; + bool mPersistentParticleEffect; }; #endif // !defined(STATUS_EFFECT_H) |