summaryrefslogtreecommitdiff
path: root/src/particlecontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/particlecontainer.cpp')
-rw-r--r--src/particlecontainer.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 0ebf4bc3..63f89079 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2008 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,15 +24,17 @@
#include "particle.h"
#include "particlecontainer.h"
-ParticleContainer::ParticleContainer(ParticleContainer *parent, bool delParent) :
+
+ParticleContainer::ParticleContainer(ParticleContainer *parent,
+ bool delParent):
mDelParent(delParent),
mNext(parent)
-{};
+{}
ParticleContainer::~ParticleContainer()
{
clearLocally();
- if (mNext && mDelParent)
+ if (mDelParent)
delete mNext;
}
@@ -52,10 +53,12 @@ void ParticleContainer::moveTo(float x, float y)
// -- particle list ----------------------------------------
-ParticleList::ParticleList(ParticleContainer *parent, bool delParent) :
- ParticleContainer(parent, delParent) {};
+ParticleList::ParticleList(ParticleContainer *parent, bool delParent):
+ ParticleContainer(parent, delParent)
+{}
-ParticleList::~ParticleList() {}
+ParticleList::~ParticleList()
+{}
void ParticleList::addLocally(Particle *particle)
{
@@ -71,10 +74,12 @@ void ParticleList::removeLocally(Particle *particle)
{
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end(); it++)
+ {
if (*it == particle) {
(*it)->kill();
mElements.erase(it);
}
+ }
}
void ParticleList::clearLocally()
@@ -82,7 +87,7 @@ void ParticleList::clearLocally()
for (std::list<Particle *>::iterator it = mElements.begin();
it != mElements.end(); it++)
(*it)->kill();
-
+
mElements.clear();
}
@@ -106,10 +111,12 @@ void ParticleList::moveTo(float x, float y)
// -- particle vector ----------------------------------------
-ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent) :
- ParticleContainer(parent, delParent) {};
+ParticleVector::ParticleVector(ParticleContainer *parent, bool delParent):
+ ParticleContainer(parent, delParent)
+{}
-ParticleVector::~ParticleVector() {};
+ParticleVector::~ParticleVector()
+{}
void ParticleVector::setLocally(int index, Particle *particle)
{
@@ -120,6 +127,8 @@ void ParticleVector::setLocally(int index, Particle *particle)
if (mIndexedElements.size() <= (unsigned) index)
mIndexedElements.resize(index + 1, NULL);
+ if (particle)
+ particle->disableAutoDelete();
mIndexedElements[index] = particle;
}
@@ -149,7 +158,7 @@ void ParticleVector::moveTo(float x, float y)
ParticleContainer::moveTo(x, y);
for (std::vector<Particle *>::iterator it = mIndexedElements.begin();
- it != mIndexedElements.end(); it++)
+ it != mIndexedElements.end(); it++) {
if (*it)
{
(*it)->moveTo(x, y);
@@ -160,5 +169,6 @@ void ParticleVector::moveTo(float x, float y)
*it = NULL;
}
}
+ }
}