summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-09-30 17:38:31 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-05-08 14:03:04 +0000
commit38d3ba1441afbf5a7657e2ba2173a1f69eae1e11 (patch)
tree73a4aa4442fe0aa3e87bffd60be6926f7c9cc53e
parent3f630c76de06a0cbda163342b5ae0bf166aaad9f (diff)
downloadmana-38d3ba1441afbf5a7657e2ba2173a1f69eae1e11.tar.gz
mana-38d3ba1441afbf5a7657e2ba2173a1f69eae1e11.tar.bz2
mana-38d3ba1441afbf5a7657e2ba2173a1f69eae1e11.tar.xz
mana-38d3ba1441afbf5a7657e2ba2173a1f69eae1e11.zip
Removed map from particle constructors
-rw-r--r--src/animationparticle.cpp8
-rw-r--r--src/animationparticle.h7
-rw-r--r--src/game.cpp2
-rw-r--r--src/imageparticle.cpp3
-rw-r--r--src/imageparticle.h4
-rw-r--r--src/particle.cpp22
-rw-r--r--src/particle.h12
-rw-r--r--src/particleemitter.cpp10
-rw-r--r--src/rotationalparticle.cpp8
-rw-r--r--src/rotationalparticle.h7
-rw-r--r--src/textparticle.cpp3
-rw-r--r--src/textparticle.h2
12 files changed, 41 insertions, 47 deletions
diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp
index feb34cca..07aa47f9 100644
--- a/src/animationparticle.cpp
+++ b/src/animationparticle.cpp
@@ -25,15 +25,15 @@
#include "utils/time.h"
-AnimationParticle::AnimationParticle(Map *map, Animation animation):
- ImageParticle(map, nullptr),
+AnimationParticle::AnimationParticle(Animation animation):
+ ImageParticle(nullptr),
mAnimation(std::move(animation))
{
}
-AnimationParticle::AnimationParticle(Map *map, XML::Node animationNode,
+AnimationParticle::AnimationParticle(XML::Node animationNode,
const std::string &dyePalettes):
- ImageParticle(map, nullptr),
+ ImageParticle(nullptr),
mAnimation(animationNode, dyePalettes)
{
}
diff --git a/src/animationparticle.h b/src/animationparticle.h
index 162eb192..cc60a73a 100644
--- a/src/animationparticle.h
+++ b/src/animationparticle.h
@@ -31,10 +31,9 @@ class Map;
class AnimationParticle : public ImageParticle
{
public:
- AnimationParticle(Map *map, Animation animation);
-
- AnimationParticle(Map *map, XML::Node animationNode,
- const std::string &dyePalettes = std::string());
+ explicit AnimationParticle(Animation animation);
+ explicit AnimationParticle(XML::Node animationNode,
+ const std::string &dyePalettes = std::string());
~AnimationParticle() override;
diff --git a/src/game.cpp b/src/game.cpp
index a6764fcf..22363457 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -128,7 +128,7 @@ static void initEngines()
channelManager = new ChannelManager;
effectManager = new EffectManager;
- particleEngine = new Particle(nullptr);
+ particleEngine = new Particle;
Particle::setupEngine();
Event::trigger(Event::GameChannel, Event::EnginesInitialized);
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp
index 86f955c0..712169dc 100644
--- a/src/imageparticle.cpp
+++ b/src/imageparticle.cpp
@@ -25,8 +25,7 @@
#include "resources/image.h"
-ImageParticle::ImageParticle(Map *map, Image *image):
- Particle(map),
+ImageParticle::ImageParticle(Image *image):
mImageRef(image)
{
mImage = mImageRef;
diff --git a/src/imageparticle.h b/src/imageparticle.h
index 0f135c33..67a00998 100644
--- a/src/imageparticle.h
+++ b/src/imageparticle.h
@@ -37,11 +37,9 @@ class ImageParticle : public Particle
/**
* Constructor. The image is reference counted by this particle.
*
- * @param map the map this particle appears on
* @param image an Image instance, may not be NULL
*/
- ImageParticle(Map *map, Image *image);
-
+ explicit ImageParticle(Image *image);
~ImageParticle() override;
/**
diff --git a/src/particle.cpp b/src/particle.cpp
index cb79c86f..0cd680e8 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -54,9 +54,8 @@ int Particle::emitterSkip = 1;
bool Particle::enabled = true;
const float Particle::PARTICLE_SKY = 800.0f;
-Particle::Particle(Map *map)
+Particle::Particle()
{
- setMap(map);
Particle::particleCount++;
}
@@ -241,7 +240,8 @@ void Particle::moveTo(float x, float y)
Particle *Particle::createChild()
{
- auto *newParticle = new Particle(mMap);
+ auto *newParticle = new Particle;
+ newParticle->setMap(mMap);
mChildParticles.push_back(newParticle);
return newParticle;
}
@@ -280,12 +280,12 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
// Animation
if ((node = effectChildNode.findFirstChildByName("animation")))
{
- newParticle = new AnimationParticle(mMap, node, dyePalettes);
+ newParticle = new AnimationParticle(node, dyePalettes);
}
// Rotational
else if ((node = effectChildNode.findFirstChildByName("rotation")))
{
- newParticle = new RotationalParticle(mMap, node, dyePalettes);
+ newParticle = new RotationalParticle(node, dyePalettes);
}
// Image
else if ((node = effectChildNode.findFirstChildByName("image")))
@@ -295,14 +295,16 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
Dye::instantiate(imageSrc, dyePalettes);
auto img = resman->getImage(imageSrc);
- newParticle = new ImageParticle(mMap, img);
+ newParticle = new ImageParticle(img);
}
// Other
else
{
- newParticle = new Particle(mMap);
+ newParticle = new Particle;
}
+ newParticle->setMap(mMap);
+
// Read and set the basic properties of the particle
float offsetX = effectChildNode.getFloatProperty("position-x", 0);
float offsetY = effectChildNode.getFloatProperty("position-y", 0);
@@ -365,7 +367,8 @@ Particle *Particle::addTextSplashEffect(const std::string &text, int x, int y,
const gcn::Color *color,
gcn::Font *font, bool outline)
{
- Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
+ Particle *newParticle = new TextParticle(text, color, font, outline);
+ newParticle->setMap(mMap);
newParticle->moveTo(x, y);
newParticle->setVelocity(((rand() % 100) - 50) / 200.0f, // X
((rand() % 100) - 50) / 200.0f, // Y
@@ -385,7 +388,8 @@ Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
const gcn::Color *color,
gcn::Font *font, bool outline)
{
- Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
+ Particle *newParticle = new TextParticle(text, color, font, outline);
+ newParticle->setMap(mMap);
newParticle->moveTo(x, y);
newParticle->setVelocity(0.0f, 0.0f, 0.5f);
newParticle->setGravity(0.0015f);
diff --git a/src/particle.h b/src/particle.h
index a130a36e..529223bf 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -58,13 +58,7 @@ class Particle : public Actor
static int emitterSkip; /**< Duration of pause between two emitter updates in ticks */
static bool enabled; /**< true when non-crucial particle effects are disabled */
- /**
- * Constructor.
- *
- * @param map the map this particle will add itself to, may be NULL
- */
- Particle(Map *map);
-
+ Particle();
~Particle() override;
/**
@@ -132,7 +126,7 @@ class Particle : public Actor
* Sets the position in 3 dimensional space in pixels relative to map.
*/
void moveTo(const Vector &pos)
- { moveBy (pos - mPos);}
+ { moveBy(pos - mPos); }
/**
* Sets the position in 2 dimensional space in pixels relative to map.
@@ -142,7 +136,7 @@ class Particle : public Actor
/**
* Changes the particle position relative
*/
- void moveBy (const Vector &change);
+ void moveBy(const Vector &change);
/**
* Sets the time in game ticks until the particle is destroyed.
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 4954d317..525c5a60 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -313,21 +313,23 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick)
Particle *newParticle;
if (mParticleImage)
{
- newParticle = new ImageParticle(mMap, mParticleImage);
+ newParticle = new ImageParticle(mParticleImage);
}
else if (mParticleRotation.getLength() > 0)
{
- newParticle = new RotationalParticle(mMap, mParticleRotation);
+ newParticle = new RotationalParticle(mParticleRotation);
}
else if (mParticleAnimation.getLength() > 0)
{
- newParticle = new AnimationParticle(mMap, mParticleAnimation);
+ newParticle = new AnimationParticle(mParticleAnimation);
}
else
{
- newParticle = new Particle(mMap);
+ newParticle = new Particle;
}
+ newParticle->setMap(mMap);
+
Vector position(mParticlePosX.value(tick),
mParticlePosY.value(tick),
mParticlePosZ.value(tick));
diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp
index cdd7de61..81d68898 100644
--- a/src/rotationalparticle.cpp
+++ b/src/rotationalparticle.cpp
@@ -24,14 +24,14 @@
#define PI 3.14159265
-RotationalParticle::RotationalParticle(Map *map, Animation animation):
- ImageParticle(map, nullptr),
+RotationalParticle::RotationalParticle(Animation animation):
+ ImageParticle(nullptr),
mAnimation(std::move(animation))
{}
-RotationalParticle::RotationalParticle(Map *map, XML::Node animationNode,
+RotationalParticle::RotationalParticle(XML::Node animationNode,
const std::string &dyePalettes):
- ImageParticle(map, nullptr),
+ ImageParticle(nullptr),
mAnimation(animationNode, dyePalettes)
{}
diff --git a/src/rotationalparticle.h b/src/rotationalparticle.h
index bc7d1a6d..ea045388 100644
--- a/src/rotationalparticle.h
+++ b/src/rotationalparticle.h
@@ -33,10 +33,9 @@ class SimpleAnimation;
class RotationalParticle : public ImageParticle
{
public:
- RotationalParticle(Map *map, Animation animation);
-
- RotationalParticle(Map *map, XML::Node animationNode,
- const std::string &dyePalettes = std::string());
+ explicit RotationalParticle(Animation animation);
+ explicit RotationalParticle(XML::Node animationNode,
+ const std::string &dyePalettes = std::string());
~RotationalParticle() override;
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index eb477217..67e9b9b9 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -25,10 +25,9 @@
#include <guichan/color.hpp>
-TextParticle::TextParticle(Map *map, const std::string &text,
+TextParticle::TextParticle(const std::string &text,
const gcn::Color *color,
gcn::Font *font, bool outline):
- Particle(map),
mText(text),
mTextFont(font),
mColor(color),
diff --git a/src/textparticle.h b/src/textparticle.h
index 89a8e90c..3a91f45f 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -26,7 +26,7 @@
class TextParticle : public Particle
{
public:
- TextParticle(Map *map, const std::string &text,
+ TextParticle(const std::string &text,
const gcn::Color* color,
gcn::Font *font, bool outline = false);