diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-05 12:33:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-05 15:48:51 +0300 |
commit | 126b1470842302537b0bc5e4527cf7fd540a9125 (patch) | |
tree | 8d98425338e7a7f01add71d762fba147fc097fc2 /src/animatedsprite.cpp | |
parent | f6920653c7a958528df248ff61c372a0bd3d4f1d (diff) | |
download | ManaVerse-126b1470842302537b0bc5e4527cf7fd540a9125.tar.gz ManaVerse-126b1470842302537b0bc5e4527cf7fd540a9125.tar.bz2 ManaVerse-126b1470842302537b0bc5e4527cf7fd540a9125.tar.xz ManaVerse-126b1470842302537b0bc5e4527cf7fd540a9125.zip |
Add checks and const to animatedsprites and related classes.
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r-- | src/animatedsprite.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
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() |