diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-25 12:55:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-25 12:55:31 +0300 |
commit | 5f97d3fd31bb5a17037610342ea09c21da9c47d3 (patch) | |
tree | ad32a4c8835c6b9273414e3b412c44e41270e708 /src | |
parent | da457cf152d5aff51d859c18d3668682348dbf7a (diff) | |
download | plus-5f97d3fd31bb5a17037610342ea09c21da9c47d3.tar.gz plus-5f97d3fd31bb5a17037610342ea09c21da9c47d3.tar.bz2 plus-5f97d3fd31bb5a17037610342ea09c21da9c47d3.tar.xz plus-5f97d3fd31bb5a17037610342ea09c21da9c47d3.zip |
change vars and methods to const.
Diffstat (limited to 'src')
-rw-r--r-- | src/animatedsprite.cpp | 34 | ||||
-rw-r--r-- | src/animatedsprite.h | 10 | ||||
-rw-r--r-- | src/animationdelayload.cpp | 7 | ||||
-rw-r--r-- | src/animationdelayload.h | 2 | ||||
-rw-r--r-- | src/animationparticle.cpp | 6 | ||||
-rw-r--r-- | src/animationparticle.h | 4 | ||||
-rw-r--r-- | src/auctionmanager.cpp | 9 | ||||
-rw-r--r-- | src/auctionmanager.h | 6 |
8 files changed, 41 insertions, 37 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 19884f141..8b47d3af3 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -35,7 +35,7 @@ bool AnimatedSprite::mEnableCache = false; -AnimatedSprite::AnimatedSprite(SpriteDef *sprite): +AnimatedSprite::AnimatedSprite(SpriteDef *const sprite): mDirection(DIRECTION_DOWN), mLastTime(0), mFrameIndex(0), @@ -60,29 +60,29 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant) { - ResourceManager *resman = ResourceManager::getInstance(); - SpriteDef *s = resman->getSprite(filename, variant); + ResourceManager *const resman = ResourceManager::getInstance(); + SpriteDef *const s = resman->getSprite(filename, variant); if (!s) return nullptr; - AnimatedSprite *as = new AnimatedSprite(s); + AnimatedSprite *const as = new AnimatedSprite(s); s->decRef(); return as; } AnimatedSprite *AnimatedSprite::delayedLoad(const std::string &filename, - int variant) + const int variant) { if (!mEnableCache) return load(filename, variant); - ResourceManager *resman = ResourceManager::getInstance(); - Resource *res = resman->getFromCache(filename, variant); + ResourceManager *const resman = ResourceManager::getInstance(); + Resource *const res = resman->getFromCache(filename, variant); if (res) { res->decRef(); return load(filename, variant); } - AnimatedSprite *as = new AnimatedSprite(nullptr); + AnimatedSprite *const as = new AnimatedSprite(nullptr); as->setDelayLoad(filename, variant); return as; } @@ -105,7 +105,7 @@ AnimatedSprite::~AnimatedSprite() bool AnimatedSprite::reset() { - bool ret = mFrameIndex !=0 || mFrameTime != 0 || mLastTime != 0; + const bool ret = mFrameIndex !=0 || mFrameTime != 0 || mLastTime != 0; mFrameIndex = 0; mFrameTime = 0; @@ -128,12 +128,12 @@ bool AnimatedSprite::play(std::string spriteAction) return true; } - Action *action = mSprite->getAction(spriteAction, mNumber); + Action *const action = mSprite->getAction(spriteAction, mNumber); if (!action) return false; mAction = action; - Animation *animation = mAction->getAnimation(mDirection); + Animation *const animation = mAction->getAnimation(mDirection); if (animation && animation != mAnimation && animation->getLength() > 0) { @@ -156,11 +156,11 @@ bool AnimatedSprite::update(int time) if (time <= mLastTime || !mAnimation) return false; - unsigned int dt = time - mLastTime; + const unsigned int dt = time - mLastTime; mLastTime = time; - Animation *animation = mAnimation; - Frame *frame = mFrame; + const Animation *const animation = mAnimation; + const Frame *const frame = mFrame; if (!updateCurrentAnimation(dt)) { @@ -206,7 +206,7 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) { for (size_t i = 0; i < mAnimation->getLength(); i ++) { - Frame *frame = &mAnimation->mFrames[i]; + const Frame *const frame = &mAnimation->mFrames[i]; if (frame->type == Frame::LABEL && mFrame->nextAction == frame->nextAction) { @@ -286,7 +286,7 @@ bool AnimatedSprite::setSpriteDirection(SpriteDirection direction) if (!mAction) return false; - Animation *animation = mAction->getAnimation(mDirection); + Animation *const animation = mAction->getAnimation(mDirection); if (animation && animation != mAnimation && animation->getLength() > 0) { @@ -381,7 +381,7 @@ bool AnimatedSprite::updateNumber(unsigned num) } void AnimatedSprite::setDelayLoad(const std::string &filename, - int variant) + const int variant) { if (mDelayLoad) { diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 4f4caff16..583d5c034 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -42,7 +42,7 @@ class AnimatedSprite : public Sprite * Constructor. * @param sprite the sprite to animate */ - AnimatedSprite(SpriteDef *sprite); + AnimatedSprite(SpriteDef *const sprite); /** * An helper function, which will request the sprite to animate @@ -55,7 +55,7 @@ class AnimatedSprite : public Sprite int variant = 0); static AnimatedSprite *delayedLoad(const std::string &filename, - int variant = 0); + const int variant = 0); virtual ~AnimatedSprite(); @@ -92,16 +92,16 @@ class AnimatedSprite : public Sprite void clearDelayLoad(); - void setSprite(SpriteDef *sprite) + void setSprite(SpriteDef *const sprite) { mSprite = sprite; } - static void setEnableCache(bool b) + static void setEnableCache(const bool b) { mEnableCache = b; } private: bool updateCurrentAnimation(unsigned int dt); - void setDelayLoad(const std::string &filename, int variant); + void setDelayLoad(const std::string &filename, const int variant); SpriteDirection mDirection; /**< The sprite direction. */ int mLastTime; /**< The last time update was called. */ diff --git a/src/animationdelayload.cpp b/src/animationdelayload.cpp index 0ce50ec2c..79334d69b 100644 --- a/src/animationdelayload.cpp +++ b/src/animationdelayload.cpp @@ -27,7 +27,8 @@ #include "debug.h" AnimationDelayLoad::AnimationDelayLoad(const std::string &fileName, - int variant, AnimatedSprite *sprite) : + const int variant, + AnimatedSprite *const sprite) : mFileName(fileName), mVariant(variant), mSprite(sprite), @@ -53,8 +54,8 @@ void AnimationDelayLoad::load() { if (mSprite) { - ResourceManager *resman = ResourceManager::getInstance(); - SpriteDef *s = resman->getSprite(mFileName, mVariant); + ResourceManager *const resman = ResourceManager::getInstance(); + SpriteDef *const s = resman->getSprite(mFileName, mVariant); if (!s) return; mSprite->setSprite(s); diff --git a/src/animationdelayload.h b/src/animationdelayload.h index b6b8a3321..91dffe4f3 100644 --- a/src/animationdelayload.h +++ b/src/animationdelayload.h @@ -29,7 +29,7 @@ class AnimationDelayLoad { public: AnimationDelayLoad(const std::string &fileName, - int variant, AnimatedSprite *sprite); + const int variant, AnimatedSprite *const sprite); ~AnimationDelayLoad(); diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index c1bf251af..6943cab57 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -27,13 +27,15 @@ #include "debug.h" -AnimationParticle::AnimationParticle(Map *map, Animation *animation): +AnimationParticle::AnimationParticle(Map *const map, + Animation *const animation) : ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animation)) { } -AnimationParticle::AnimationParticle(Map *map, XmlNodePtr animationNode, +AnimationParticle::AnimationParticle(Map *const map, + XmlNodePtr const animationNode, const std::string& dyePalettes): ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) diff --git a/src/animationparticle.h b/src/animationparticle.h index 933f2d164..b284e9fa4 100644 --- a/src/animationparticle.h +++ b/src/animationparticle.h @@ -34,9 +34,9 @@ class SimpleAnimation; class AnimationParticle : public ImageParticle { public: - AnimationParticle(Map *map, Animation *animation); + AnimationParticle(Map *const map, Animation *const animation); - AnimationParticle(Map *map, XmlNodePtr animationNode, + AnimationParticle(Map *const map, XmlNodePtr const animationNode, const std::string& dyePalettes = std::string()); ~AnimationParticle(); diff --git a/src/auctionmanager.cpp b/src/auctionmanager.cpp index 03068c607..9b35ff877 100644 --- a/src/auctionmanager.cpp +++ b/src/auctionmanager.cpp @@ -61,19 +61,20 @@ void AuctionManager::init() auctionManager = new AuctionManager(); } -void AuctionManager::send(std::string msg) +void AuctionManager::send(const std::string &msg) { if (Net::getChatHandler()) Net::getChatHandler()->privateMessage("AuctionBot", msg); } -bool AuctionManager::processAuctionMessage(std::string msg) +/* +bool AuctionManager::processAuctionMessage(const std::string &msg) { if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - return false; } +*/ void AuctionManager::clear() { @@ -83,7 +84,7 @@ void AuctionManager::reload() { } -void AuctionManager::sendMail(std::string mail) +void AuctionManager::sendMail(const std::string &mail) { if (Net::getChatHandler()) Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + mail); diff --git a/src/auctionmanager.h b/src/auctionmanager.h index 35b233abf..a98e36a9c 100644 --- a/src/auctionmanager.h +++ b/src/auctionmanager.h @@ -36,9 +36,9 @@ class AuctionManager static void init(); - void send(std::string msg); + static void send(const std::string &msg); - bool processAuctionMessage(std::string msg); +// static bool processAuctionMessage(const std::string &msg); static bool getEnableAuctionBot() { return mEnableAuctionBot; } @@ -47,7 +47,7 @@ class AuctionManager void reload(); - void sendMail(std::string mail); + static void sendMail(const std::string &mail); private: static bool mEnableAuctionBot; |