summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actor.h3
-rw-r--r--src/actorsprite.cpp3
-rw-r--r--src/actorsprite.h4
-rw-r--r--src/animatedsprite.cpp27
-rw-r--r--src/animatedsprite.h13
-rw-r--r--src/being.cpp3
-rw-r--r--src/being.h3
-rw-r--r--src/compoundsprite.cpp7
-rw-r--r--src/compoundsprite.h7
-rw-r--r--src/flooritem.cpp3
-rw-r--r--src/flooritem.h3
-rw-r--r--src/imageparticle.cpp3
-rw-r--r--src/imageparticle.h4
-rw-r--r--src/imagesprite.cpp3
-rw-r--r--src/imagesprite.h7
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h2
-rw-r--r--src/particle.cpp2
-rw-r--r--src/particle.h4
-rw-r--r--src/sprite.h7
-rw-r--r--src/textparticle.cpp3
-rw-r--r--src/textparticle.h4
22 files changed, 69 insertions, 48 deletions
diff --git a/src/actor.h b/src/actor.h
index 392a59dc5..461758b9a 100644
--- a/src/actor.h
+++ b/src/actor.h
@@ -52,7 +52,8 @@ public:
* would support setting a translation offset. It already does this
* partly with the clipping rectangle support.
*/
- virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const = 0;
+ virtual bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const = 0;
/**
* Returns the horizontal size of the actors graphical representation
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index be7fcb165..96afb94c7 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -77,7 +77,8 @@ ActorSprite::~ActorSprite()
}
}
-bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
+bool ActorSprite::draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const
{
FUNC_BLOCK("ActorSprite::draw", 1)
// TODO: Eventually, we probably should fix all sprite offsets so that
diff --git a/src/actorsprite.h b/src/actorsprite.h
index 28d8e8f92..4a9723353 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -86,8 +86,8 @@ public:
virtual Type getType() const A_WARN_UNUSED
{ return UNKNOWN; }
- virtual bool draw(Graphics *graphics,
- int offsetX, int offsetY) const override;
+ virtual bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
virtual bool drawSpriteAt(Graphics *const graphics,
const int x, const int y) const;
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 35b0a265c..8bc324535 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -58,7 +58,8 @@ AnimatedSprite::AnimatedSprite(SpriteDef *const sprite):
play(SpriteAction::STAND);
}
-AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant)
+AnimatedSprite *AnimatedSprite::load(const std::string &filename,
+ const int variant)
{
ResourceManager *const resman = ResourceManager::getInstance();
SpriteDef *const s = resman->getSprite(filename, variant);
@@ -118,7 +119,7 @@ bool AnimatedSprite::reset()
return ret;
}
-bool AnimatedSprite::play(std::string spriteAction)
+bool AnimatedSprite::play(const std::string &spriteAction)
{
if (!mSprite)
{
@@ -146,7 +147,7 @@ bool AnimatedSprite::play(std::string spriteAction)
return false;
}
-bool AnimatedSprite::update(int time)
+bool AnimatedSprite::update(const int time)
{
// Avoid freaking out at first frame or when tick_time overflows
if (time < mLastTime || mLastTime == 0)
@@ -172,7 +173,7 @@ bool AnimatedSprite::update(int time)
return animation != mAnimation || frame != mFrame;
}
-bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
+bool AnimatedSprite::updateCurrentAnimation(const unsigned int time)
{
// move code from Animation::isTerminator(*mFrame)
if (!mFrame || !mAnimation || (!mFrame->image
@@ -264,16 +265,18 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
return true;
}
-bool AnimatedSprite::draw(Graphics *graphics, int posX, int posY) const
+bool AnimatedSprite::draw(Graphics *const graphics,
+ const int posX, const int posY) const
{
FUNC_BLOCK("AnimatedSprite::draw", 1)
if (!mFrame || !mFrame->image)
return false;
- if (mFrame->image->getAlpha() != mAlpha)
- mFrame->image->setAlpha(mAlpha);
+ Image *const image = mFrame->image;
+ if (image->getAlpha() != mAlpha)
+ image->setAlpha(mAlpha);
- return graphics->drawImage(mFrame->image,
+ return graphics->drawImage(image,
posX + mFrame->offsetX,
posY + mFrame->offsetY);
}
@@ -346,8 +349,12 @@ void AnimatedSprite::setAlpha(float alpha)
{
mAlpha = alpha;
- if (mFrame && mFrame->image && mFrame->image->getAlpha() != mAlpha)
- mFrame->image->setAlpha(mAlpha);
+ if (mFrame)
+ {
+ Image *const image = mFrame->image;
+ if (image && image->getAlpha() != mAlpha)
+ image->setAlpha(mAlpha);
+ }
}
void *AnimatedSprite::getHash()
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index c10e655d1..a58098245 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -54,7 +54,7 @@ class AnimatedSprite final : public Sprite
* @param variant the sprite variant
*/
static AnimatedSprite *load(const std::string &filename,
- int variant = 0) A_WARN_UNUSED;
+ const int variant = 0) A_WARN_UNUSED;
static AnimatedSprite *delayedLoad(const std::string &filename,
const int variant = 0)
@@ -62,13 +62,14 @@ class AnimatedSprite final : public Sprite
virtual ~AnimatedSprite();
- bool reset();
+ bool reset() override;
- bool play(std::string action);
+ bool play(const std::string &action) override;
- bool update(int time);
+ bool update(const int time) override;
- bool draw(Graphics* graphics, int posX, int posY) const;
+ bool draw(Graphics *const graphics,
+ const int posX, const int posY) const override;
int getWidth() const A_WARN_UNUSED;
@@ -102,7 +103,7 @@ class AnimatedSprite final : public Sprite
{ mEnableCache = b; }
private:
- bool updateCurrentAnimation(unsigned int dt);
+ bool updateCurrentAnimation(const unsigned int dt);
void setDelayLoad(const std::string &filename, const int variant);
diff --git a/src/being.cpp b/src/being.cpp
index edc177f17..e2452f997 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -2087,7 +2087,8 @@ void Being::talkTo()
Net::getNpcHandler()->talk(mId);
}
-bool Being::draw(Graphics *graphics, int offsetX, int offsetY) const
+bool Being::draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const
{
bool res = true;
if (!mErased)
diff --git a/src/being.h b/src/being.h
index 2441d1418..384741afe 100644
--- a/src/being.h
+++ b/src/being.h
@@ -679,7 +679,8 @@ class Being : public ActorSprite, public ConfigListener
void talkTo();
- bool draw(Graphics *graphics, int offsetX, int offsetY) const;
+ bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
bool drawSpriteAt(Graphics *const graphics,
const int x, const int y) const;
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 45c408b49..ef956d8f4 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -87,7 +87,7 @@ bool CompoundSprite::reset()
return ret;
}
-bool CompoundSprite::play(std::string action)
+bool CompoundSprite::play(const std::string &action)
{
bool ret = false;
@@ -101,7 +101,7 @@ bool CompoundSprite::play(std::string action)
return ret;
}
-bool CompoundSprite::update(int time)
+bool CompoundSprite::update(const int time)
{
bool ret = false;
@@ -115,7 +115,8 @@ bool CompoundSprite::update(int time)
return ret;
}
-bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const
+bool CompoundSprite::draw(Graphics *const graphics,
+ const int posX, const int posY) const
{
FUNC_BLOCK("CompoundSprite::draw", 1)
if (mNeedsRedraw)
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 2e3204d18..aa9b2d7b6 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -61,11 +61,12 @@ public:
virtual bool reset() override;
- virtual bool play(std::string action) override;
+ virtual bool play(const std::string &action) override;
- virtual bool update(int time) override;
+ virtual bool update(const int time) override;
- virtual bool draw(Graphics *graphics, int posX, int posY) const override;
+ virtual bool draw(Graphics *const graphics,
+ const int posX, const int posY) const override;
/**
* Gets the width in pixels of the first sprite in the list.
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 6e7749c07..821a10d20 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -93,7 +93,8 @@ std::string FloorItem::getName() const
return info.getName();
}
-bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const
+bool FloorItem::draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const
{
if (!mMap)
return false;
diff --git a/src/flooritem.h b/src/flooritem.h
index 4e1b78d87..aaf870cf3 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -57,7 +57,8 @@ class FloorItem final : public ActorSprite
Type getType() const override A_WARN_UNUSED
{ return FLOOR_ITEM; }
- bool draw(Graphics *graphics, int offsetX, int offsetY) const override;
+ bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
/**
* Returns the item ID.
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp
index 4eab16fc9..31eba7333 100644
--- a/src/imageparticle.cpp
+++ b/src/imageparticle.cpp
@@ -69,7 +69,8 @@ ImageParticle::~ImageParticle()
setMap(nullptr);
}
-bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
+bool ImageParticle::draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const
{
FUNC_BLOCK("ImageParticle::draw", 1)
if (!isAlive() || !mImage)
diff --git a/src/imageparticle.h b/src/imageparticle.h
index a72063e74..85d08d43f 100644
--- a/src/imageparticle.h
+++ b/src/imageparticle.h
@@ -54,8 +54,8 @@ class ImageParticle : public Particle
/**
* Draws the particle image
*/
- virtual bool draw(Graphics *graphics,
- int offsetX, int offsetY) const override;
+ virtual bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
virtual void setAlpha(const float alpha) override
{ mAlpha = alpha; }
diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp
index 779bcfed8..7d19034e5 100644
--- a/src/imagesprite.cpp
+++ b/src/imagesprite.cpp
@@ -48,7 +48,8 @@ ImageSprite::~ImageSprite()
}
}
-bool ImageSprite::draw(Graphics* graphics, int posX, int posY) const
+bool ImageSprite::draw(Graphics *const graphics,
+ const int posX, const int posY) const
{
FUNC_BLOCK("ImageSprite::draw", 1)
if (!mImage)
diff --git a/src/imagesprite.h b/src/imagesprite.h
index b9eb477d1..294d0264c 100644
--- a/src/imagesprite.h
+++ b/src/imagesprite.h
@@ -40,13 +40,14 @@ public:
bool reset() override
{ return false; }
- bool play(std::string action A_UNUSED) override
+ bool play(const std::string &action A_UNUSED) override
{ return false; }
- bool update(int time A_UNUSED) override
+ bool update(const int time A_UNUSED) override
{ return false; }
- bool draw(Graphics* graphics, int posX, int posY) const override;
+ bool draw(Graphics *const graphics,
+ const int posX, const int posY) const override;
int getWidth() const override A_WARN_UNUSED
{ return mImage ? mImage->getWidth() : 0; }
diff --git a/src/map.cpp b/src/map.cpp
index c6aea4fcb..4f8cab3eb 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -317,7 +317,7 @@ void Map::update(const int ticks)
}
}
-void Map::draw(Graphics *graphics, int scrollX, int scrollY)
+void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
{
if (!player_node)
return;
diff --git a/src/map.h b/src/map.h
index 5bc1ceb65..b433eb349 100644
--- a/src/map.h
+++ b/src/map.h
@@ -186,7 +186,7 @@ class Map final : public Properties, public ConfigListener
* the clipping rectangle set on the Graphics object. However,
* currently the map is always drawn full-screen.
*/
- void draw(Graphics *graphics, int scrollX, int scrollY);
+ void draw(Graphics *const graphics, int scrollX, int scrollY);
/**
* Visualizes collision layer for debugging
diff --git a/src/particle.cpp b/src/particle.cpp
index a14fac698..19d732653 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -101,7 +101,7 @@ void Particle::setupEngine()
logger->log1("Particle engine set up");
}
-bool Particle::draw(Graphics *, int, int) const
+bool Particle::draw(Graphics *const, const int, const int) const
{
return false;
}
diff --git a/src/particle.h b/src/particle.h
index 3a48afbb4..2f4ea77fd 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -107,8 +107,8 @@ class Particle : public Actor
/**
* Draws the particle image.
*/
- virtual bool draw(Graphics *graphics,
- int offsetX, int offsetY) const override;
+ virtual bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
/**
* Necessary for sorting with the other sprites.
diff --git a/src/sprite.h b/src/sprite.h
index 79cad1125..d8b5d989d 100644
--- a/src/sprite.h
+++ b/src/sprite.h
@@ -47,7 +47,7 @@ class Sprite
*
* @returns true if the sprite changed, false otherwise
*/
- virtual bool play(std::string action) = 0;
+ virtual bool play(const std::string &action) = 0;
/**
* Inform the animation of the passed time so that it can output the
@@ -55,13 +55,14 @@ class Sprite
*
* @returns true if the sprite changed, false otherwise
*/
- virtual bool update(int time) = 0;
+ virtual bool update(const int time) = 0;
/**
* Draw the current animation frame at the coordinates given in screen
* pixels.
*/
- virtual bool draw(Graphics* graphics, int posX, int posY) const = 0;
+ virtual bool draw(Graphics *const graphics,
+ const int posX, const int posY) const = 0;
/**
* Gets the width in pixels of the image of the current frame
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index a30e46069..818ac7920 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -43,7 +43,8 @@ TextParticle::TextParticle(Map *const map, const std::string &text,
{
}
-bool TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
+bool TextParticle::draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const
{
BLOCK_START("TextParticle::draw")
if (!isAlive())
diff --git a/src/textparticle.h b/src/textparticle.h
index 9d2f7d956..9882fa22e 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -40,8 +40,8 @@ class TextParticle final : public Particle
/**
* Draws the particle image.
*/
- virtual bool draw(Graphics *graphics,
- int offsetX, int offsetY) const override;
+ virtual bool draw(Graphics *const graphics,
+ const int offsetX, const int offsetY) const override;
// hack to improve text visibility
virtual int getPixelY() const override A_WARN_UNUSED