summaryrefslogtreecommitdiff
path: root/src/being/actorsprite.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-23 02:14:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-23 02:14:30 +0300
commit6a65a4cf5b6b10839254c0c5846ec2dbfea882f8 (patch)
treecdf1dcc071ab18575defff569d33f3cbc8be0348 /src/being/actorsprite.cpp
parent1a5f8957c707625efbcf36722b057d5eda5a21bb (diff)
downloadmv-6a65a4cf5b6b10839254c0c5846ec2dbfea882f8.tar.gz
mv-6a65a4cf5b6b10839254c0c5846ec2dbfea882f8.tar.bz2
mv-6a65a4cf5b6b10839254c0c5846ec2dbfea882f8.tar.xz
mv-6a65a4cf5b6b10839254c0c5846ec2dbfea882f8.zip
Allow delete untracker being particle effects.
This fix some possible memory leaks.
Diffstat (limited to 'src/being/actorsprite.cpp')
-rw-r--r--src/being/actorsprite.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index f0dfc07ec..3a9c457a4 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -33,6 +33,7 @@
#include "listeners/debugmessagelistener.h"
+#include "particle/particle.h"
#include "particle/particleengine.h"
#include "resources/db/statuseffectdb.h"
@@ -141,9 +142,29 @@ void ActorSprite::setMap(Map *const map)
mMustResetParticles = true; // Reset status particles on next redraw
}
-void ActorSprite::controlParticle(Particle *const particle)
+void ActorSprite::controlAutoParticle(Particle *const particle)
{
- mChildParticleEffects.addLocally(particle);
+ if (particle)
+ {
+ particle->setActor(mId);
+ mChildParticleEffects.addLocally(particle);
+ }
+}
+
+void ActorSprite::controlCustomParticle(Particle *const particle)
+{
+ if (particle)
+ {
+ // The effect may not die without the beings permission or we segfault
+ particle->disableAutoDelete();
+ mChildParticleEffects.addLocally(particle);
+ }
+}
+
+void ActorSprite::controlParticleDeleted(Particle *const particle)
+{
+ if (particle)
+ mChildParticleEffects.removeLocally(particle);
}
void ActorSprite::setTargetType(const TargetCursorTypeT type)
@@ -456,7 +477,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
FOR_EACH (StringVectCIter, itr, display.particles)
{
Particle *const p = particleEngine->addEffect(*itr, 0, 0);
- controlParticle(p);
+ controlAutoParticle(p);
}
}