summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-16 15:02:46 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-16 15:02:46 +0300
commit8ae877cf5d4abd2c97d299c5067c6d2f77dd2811 (patch)
tree7d557177a681aa8ddc4331d22bf0f1d126cb4051
parent8c2820ce9a67bf6e0691e4d72804a2dd1a2a3eac (diff)
downloadmanaplus-8ae877cf5d4abd2c97d299c5067c6d2f77dd2811.tar.gz
manaplus-8ae877cf5d4abd2c97d299c5067c6d2f77dd2811.tar.bz2
manaplus-8ae877cf5d4abd2c97d299c5067c6d2f77dd2811.tar.xz
manaplus-8ae877cf5d4abd2c97d299c5067c6d2f77dd2811.zip
Add nonnull attributes to particle classes.
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/particle/animationparticle.h3
-rw-r--r--src/particle/imageparticle.h3
-rw-r--r--src/particle/particle.h9
-rw-r--r--src/particle/particleemitter.h3
-rw-r--r--src/particle/particletimer.h6
-rw-r--r--src/particle/rotationalparticle.cpp3
-rw-r--r--src/particle/rotationalparticle.h2
-rw-r--r--src/particle/textparticle.cpp3
-rw-r--r--src/particle/textparticle.h14
10 files changed, 25 insertions, 23 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 101b0ef67..ccd28c79f 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -754,7 +754,7 @@ void Being::takeDamage(Being *restrict const attacker,
ChatMsgType::BY_PLAYER);
}
}
- if (font && particleEngine)
+ if (font && particleEngine && color)
{
// Show damage number
particleEngine->addTextSplashEffect(damage,
diff --git a/src/particle/animationparticle.h b/src/particle/animationparticle.h
index e6c2d1de0..112c1f10a 100644
--- a/src/particle/animationparticle.h
+++ b/src/particle/animationparticle.h
@@ -33,7 +33,8 @@ class SimpleAnimation;
class AnimationParticle final : public ImageParticle
{
public:
- explicit AnimationParticle(Animation *restrict const animation);
+ explicit AnimationParticle(Animation *restrict const animation)
+ A_NONNULL(2);
explicit AnimationParticle(XmlNodePtrConst animationNode,
const std::string &restrict dyePalettes
diff --git a/src/particle/imageparticle.h b/src/particle/imageparticle.h
index b1b0556d8..0fdac0d60 100644
--- a/src/particle/imageparticle.h
+++ b/src/particle/imageparticle.h
@@ -63,7 +63,8 @@ class ImageParticle notfinal : public Particle
static StringIntMap imageParticleCountByName;
protected:
- Image *restrict mImage; /**< The image used for this particle. */
+ /**< The image used for this particle. */
+ Image *restrict mImage;
};
#endif // PARTICLE_IMAGEPARTICLE_H
diff --git a/src/particle/particle.h b/src/particle/particle.h
index eff89553e..323e1c171 100644
--- a/src/particle/particle.h
+++ b/src/particle/particle.h
@@ -123,7 +123,8 @@ class Particle notfinal : public Actor
const int x, const int y,
const Color *restrict const color,
Font *restrict const font,
- const bool outline = false) restrict2;
+ const bool outline = false)
+ restrict2 A_NONNULL(5, 6);
/**
* Creates a standalone text particle.
@@ -133,12 +134,12 @@ class Particle notfinal : public Actor
const Color *restrict const color,
Font *restrict const font,
const bool outline = false)
- restrict2;
+ restrict2 A_NONNULL(5, 6);
/**
* Adds an emitter to the particle.
*/
- void addEmitter(ParticleEmitter *const emitter) restrict2
+ void addEmitter(ParticleEmitter *const emitter) restrict2 A_NONNULL(2)
{ mChildEmitters.push_back(emitter); }
/**
@@ -222,7 +223,7 @@ class Particle notfinal : public Actor
*/
void setDestination(Particle *restrict const target,
const float accel,
- const float moment) restrict2 noexcept
+ const float moment) restrict2 noexcept A_NONNULL(2)
{ mTarget = target; mAcceleration = accel; mMomentum = moment; }
/**
diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h
index 054c5333b..493024d50 100644
--- a/src/particle/particleemitter.h
+++ b/src/particle/particleemitter.h
@@ -47,7 +47,8 @@ class ParticleEmitter final
Particle *const target,
Map *const map,
const int rotation = 0,
- const std::string& dyePalettes = std::string());
+ const std::string& dyePalettes = std::string())
+ A_NONNULL(3);
/**
* Copy Constructor (necessary for reference counting of particle images)
diff --git a/src/particle/particletimer.h b/src/particle/particletimer.h
index 8cca683b5..1550935d8 100644
--- a/src/particle/particletimer.h
+++ b/src/particle/particletimer.h
@@ -28,14 +28,14 @@ class Particle;
struct ParticleTimer final
{
ParticleTimer(Particle *const particle0,
- const int endTime0) :
+ const int endTime0) A_NONNULL(2) :
particle(particle0),
endTime(endTime0)
{
}
- Particle *particle;
- int endTime;
+ Particle *const particle;
+ const int endTime;
};
#endif // PARTICLE_PARTICLETIMER_H
diff --git a/src/particle/rotationalparticle.cpp b/src/particle/rotationalparticle.cpp
index f5b4606ee..945517fba 100644
--- a/src/particle/rotationalparticle.cpp
+++ b/src/particle/rotationalparticle.cpp
@@ -53,9 +53,6 @@ RotationalParticle::~RotationalParticle()
bool RotationalParticle::update() restrict2
{
- if (!mAnimation)
- return false;
-
// TODO: cache velocities to avoid spamming atan2()
const int size = mAnimation->getLength();
diff --git a/src/particle/rotationalparticle.h b/src/particle/rotationalparticle.h
index 23263332d..db9c4ed89 100644
--- a/src/particle/rotationalparticle.h
+++ b/src/particle/rotationalparticle.h
@@ -47,7 +47,7 @@ class RotationalParticle final : public ImageParticle
private:
/**< Used animation for this particle */
- SimpleAnimation *restrict mAnimation;
+ SimpleAnimation *restrict mAnimation A_NONNULLPOINTER;
};
#endif // PARTICLE_ROTATIONALPARTICLE_H
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index 274ba39cc..9acfb4110 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -47,9 +47,6 @@ void TextParticle::draw(Graphics *restrict const graphics,
const int offsetX,
const int offsetY) const restrict2
{
- if (!mColor || !mTextFont)
- return;
-
BLOCK_START("TextParticle::draw")
if (!isAlive())
{
diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h
index 7064a5358..e13b2e13c 100644
--- a/src/particle/textparticle.h
+++ b/src/particle/textparticle.h
@@ -34,7 +34,7 @@ class TextParticle final : public Particle
TextParticle(const std::string &text,
const Color *restrict const color,
Font *restrict const font,
- const bool outline = false);
+ const bool outline = false) A_NONNULL(3, 4);
A_DELETE_COPY(TextParticle)
@@ -55,11 +55,15 @@ class TextParticle final : public Particle
{ return CAST_S32(mPos.y + mPos.z); }
private:
- std::string mText; /**< Text of the particle. */
- Font *restrict mTextFont; /**< Font used for drawing the text. */
- const Color *restrict mColor; /**< Color used for drawing the text. */
+ /**< Text of the particle. */
+ std::string mText;
+ /**< Font used for drawing the text. */
+ Font *restrict mTextFont A_NONNULLPOINTER;
+ /**< Color used for drawing the text. */
+ const Color *restrict mColor A_NONNULLPOINTER;
int mTextWidth;
- bool mOutline; /**< Make the text better readable */
+ /**< Make the text better readable */
+ bool mOutline;
};
#endif // PARTICLE_TEXTPARTICLE_H