summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-14 18:03:19 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-14 18:03:19 +0100
commit18f418c5cbd169be1b8e65c823e0b07d2d8db197 (patch)
treead98ff929cf43690acb80f69e317fb5dcb8ff4f3 /src/particle.cpp
parent69d62451a7a582e3906a7c9328ae14e4bba5ccfa (diff)
downloadmana-18f418c5cbd169be1b8e65c823e0b07d2d8db197.tar.gz
mana-18f418c5cbd169be1b8e65c823e0b07d2d8db197.tar.bz2
mana-18f418c5cbd169be1b8e65c823e0b07d2d8db197.tar.xz
mana-18f418c5cbd169be1b8e65c823e0b07d2d8db197.zip
Code reformatting
I wish I had never fallen for this weird style, and I hope removing it will prevent others from introducing new code like this. :-) (cherry picked from eAthena branch, commit 68760426532b9ca4c6939d7a7b8faa1586ee82e0) Conflicts: src/being.cpp src/being.h src/gui/tabbedcontainer.cpp src/particle.cpp src/particle.h
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp75
1 files changed, 33 insertions, 42 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index 8a15a132..c6e242bd 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -68,12 +68,21 @@ Particle::Particle(Map *map):
mMomentum(1.0f)
{
Particle::particleCount++;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
+Particle::~Particle()
+{
+ // Remove from map sprite list
+ if (mMap)
+ mMap->removeSprite(mSpriteIterator);
+ // Delete child emitters and child particles
+ clear();
+ Particle::particleCount--;
+}
-void
-Particle::setupEngine()
+void Particle::setupEngine()
{
Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
@@ -82,17 +91,17 @@ Particle::setupEngine()
logger->log("Particle engine set up");
}
-void Particle::draw(Graphics *, int, int) const {}
+void Particle::draw(Graphics *, int, int) const
+{
+}
-bool
-Particle::update()
+bool Particle::update()
{
- if (!mMap) return false;
+ if (!mMap)
+ return false;
if (mLifetimeLeft == 0)
- {
mAlive = false;
- }
Vector oldPos = mPos;
@@ -222,9 +231,8 @@ Particle::update()
return true;
}
-Particle*
-Particle::addEffect(const std::string &particleEffectFile,
- int pixelX, int pixelY, int rotation)
+Particle *Particle::addEffect(const std::string &particleEffectFile,
+ int pixelX, int pixelY, int rotation)
{
Particle *newParticle = NULL;
@@ -298,11 +306,9 @@ Particle::addEffect(const std::string &particleEffectFile,
return newParticle;
}
-
-Particle*
-Particle::addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y)
+Particle *Particle::addTextSplashEffect(const std::string &text,
+ int colorR, int colorG, int colorB,
+ gcn::Font *font, int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB,
font);
@@ -320,11 +326,10 @@ Particle::addTextSplashEffect(const std::string &text,
return newParticle;
}
-Particle*
-Particle::addTextRiseFadeOutEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font,
- int x, int y)
+Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
+ int colorR, int colorG, int colorB,
+ gcn::Font *font,
+ int x, int y)
{
Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB, font);
newParticle->setPosition(x, y, 0);
@@ -339,32 +344,18 @@ Particle::addTextRiseFadeOutEffect(const std::string &text,
return newParticle;
}
-void
-Particle::setMap(Map *map)
+void Particle::setMap(Map *map)
{
mMap = map;
- if (mMap) setSpriteIterator(mMap->addSprite(this));
+ if (mMap)
+ setSpriteIterator(mMap->addSprite(this));
}
-
-Particle::~Particle()
-{
- // Remove from map sprite list
- if (mMap) mMap->removeSprite(mSpriteIterator);
- // Delete child emitters and child particles
- clear();
- Particle::particleCount--;
-}
-
-
-void
-Particle::clear()
+void Particle::clear()
{
- std::for_each(mChildEmitters.begin(), mChildEmitters.end(),
- make_dtor(mChildEmitters));
+ delete_all(mChildEmitters);
mChildEmitters.clear();
- std::for_each(mChildParticles.begin(), mChildParticles.end(),
- make_dtor(mChildParticles));
+ delete_all(mChildParticles);
mChildParticles.clear();
}