From: Guus Sliepen Date: Sun, 26 Dec 2010 13:07:48 +0000 (+0100) Subject: Make functions const where possible. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b3b9b7dbb136994892bc7dc0bb0cfd57472c7421;p=quix0rs-blobwars.git Make functions const where possible. --- diff --git a/src/CConfig.cpp b/src/CConfig.cpp index ce87a06..ef997bd 100644 --- a/src/CConfig.cpp +++ b/src/CConfig.cpp @@ -43,7 +43,7 @@ void Config::populate(int *data) command[CONTROL::PAUSE] = 0; } -bool Config::isControl(CONTROL::TYPE type) +bool Config::isControl(CONTROL::TYPE type) const { return command[type]; } diff --git a/src/CConfig.h b/src/CConfig.h index 6a6f5f7..e1460ed 100755 --- a/src/CConfig.h +++ b/src/CConfig.h @@ -17,7 +17,7 @@ class Config void populate(); void populate(int *data); - bool isControl(CONTROL::TYPE type); + bool isControl(CONTROL::TYPE type) const; void resetControl(CONTROL::TYPE type); void doPause(); diff --git a/src/CEngine.cpp b/src/CEngine.cpp index 9ab2581..10bdf60 100644 --- a/src/CEngine.cpp +++ b/src/CEngine.cpp @@ -274,12 +274,12 @@ void Engine::getInput() } } -int Engine::getMouseX() +int Engine::getMouseX() const { return mouseX; } -int Engine::getMouseY() +int Engine::getMouseY() const { return mouseY; } @@ -458,7 +458,7 @@ void Engine::setPlayerPosition(int x, int y, int limitLeft, int limitRight, int Math::limitInt(&playerPosY, limitUp, limitDown); } -int Engine::getFrameLoop() +int Engine::getFrameLoop() const { return frameLoop; } @@ -475,7 +475,7 @@ void Engine::doTimeDifference() time2 = SDL_GetTicks(); } -float Engine::getTimeDifference() +float Engine::getTimeDifference() const { return timeDifference; } diff --git a/src/CEngine.h b/src/CEngine.h index d054bb8..4fe6876 100755 --- a/src/CEngine.h +++ b/src/CEngine.h @@ -97,8 +97,8 @@ class Engine { Engine(); void destroy(); void getInput(); - int getMouseX(); - int getMouseY(); + int getMouseX() const; + int getMouseY() const; void setMouse(int x, int y); bool userAccepts(); @@ -114,10 +114,10 @@ class Engine { bool loadData(const char *filename); void reportFontFailure(); void setPlayerPosition(int x, int y, int limitLeft, int limitRight, int limitUp, int limitDown); - int getFrameLoop(); + int getFrameLoop() const; void doFrameLoop(); void doTimeDifference(); - float getTimeDifference(); + float getTimeDifference() const; void resetTimeDifference(); void setInfoMessage(const char *message, int priority, int type); void deleteWidgets(); diff --git a/src/CGame.cpp b/src/CGame.cpp index b75820d..c371ad9 100644 --- a/src/CGame.cpp +++ b/src/CGame.cpp @@ -117,7 +117,7 @@ void Game::setCheckPoint(float x, float y) checkPointY = (int)y; } -void Game::getCheckPoint(float *x, float *y) +void Game::getCheckPoint(float *x, float *y) const { *x = checkPointX; *y = checkPointY; @@ -159,7 +159,7 @@ int Game::getWeaponAccuracy(int weapon) return 0; } -int Game::getTotalBulletsFired() +int Game::getTotalBulletsFired() const { return bulletsFired[0] + bulletsFired[1] + bulletsFired[2] + bulletsFired[3] + bulletsFired[4]; } diff --git a/src/CGame.h b/src/CGame.h index 7e6052b..ac44370 100755 --- a/src/CGame.h +++ b/src/CGame.h @@ -63,14 +63,14 @@ class Game { void destroy(); void incrementMissionTime(); void setCheckPoint(float x, float y); - void getCheckPoint(float *x, float *y); + void getCheckPoint(float *x, float *y) const; void setObjectiveCheckPoint(); void useObjectiveCheckPoint(); void doCombo(); void incBulletsFired(); void incBulletsHit(); int getWeaponAccuracy(int weapon); - int getTotalBulletsFired(); + int getTotalBulletsFired() const; int getTotalAccuracy(); int getMostUsedWeapon(); void totalUpStats(); diff --git a/src/CGraphics.cpp b/src/CGraphics.cpp index 6dde3df..8e21f97 100644 --- a/src/CGraphics.cpp +++ b/src/CGraphics.cpp @@ -159,7 +159,7 @@ void Graphics::setTransparent(SDL_Surface *sprite) SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0)); } -bool Graphics::canShowMedalMessage() +bool Graphics::canShowMedalMessage() const { return (medalMessageTimer <= 0); } @@ -662,17 +662,17 @@ void Graphics::animateSprites() } } -int Graphics::getWaterAnim() +int Graphics::getWaterAnim() const { return waterAnim; } -int Graphics::getSlimeAnim() +int Graphics::getSlimeAnim() const { return slimeAnim; } -int Graphics::getLavaAnim() +int Graphics::getLavaAnim() const { return lavaAnim; } diff --git a/src/CGraphics.h b/src/CGraphics.h index 3ad2c52..325d17f 100755 --- a/src/CGraphics.h +++ b/src/CGraphics.h @@ -75,7 +75,7 @@ class Graphics { Sprite *getSpriteHead(); void setTransparent(SDL_Surface *sprite); void updateScreen(); - bool canShowMedalMessage(); + bool canShowMedalMessage() const; void delay(int time); void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v); void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v); @@ -89,9 +89,9 @@ class Graphics { Sprite *addSprite(const char *name); Sprite *getSprite(const char *name, bool required); void animateSprites(); - int getWaterAnim(); - int getSlimeAnim(); - int getLavaAnim(); + int getWaterAnim() const; + int getSlimeAnim() const; + int getLavaAnim() const; int getLavaAnim(int current); void loadBackground(const char *filename); void putPixel(int x, int y, Uint32 pixel, SDL_Surface *dest); diff --git a/src/CPak.cpp b/src/CPak.cpp index a6811d3..5698fa0 100644 --- a/src/CPak.cpp +++ b/src/CPak.cpp @@ -181,7 +181,7 @@ bool Pak::fileExists(const char *filename) return false; } -unsigned int Pak::getUncompressedSize() +unsigned int Pak::getUncompressedSize() const { return (unsigned int)currentFile->fSize; } diff --git a/src/CPak.h b/src/CPak.h index 7c8c547..b996087 100755 --- a/src/CPak.h +++ b/src/CPak.h @@ -42,6 +42,6 @@ class Pak { void setPakFile(const char *pakFilename); bool unpack(const char *filename, unsigned char **buffer); bool fileExists(const char *filename); - unsigned int getUncompressedSize(); + unsigned int getUncompressedSize() const; }; diff --git a/src/CWeapon.cpp b/src/CWeapon.cpp index 53d962b..9fd8ada 100644 --- a/src/CWeapon.cpp +++ b/src/CWeapon.cpp @@ -37,7 +37,7 @@ void Weapon::setName(const char *name) strlcpy(this->name, name, sizeof this->name); } -int Weapon::getSpeed(int face) +int Weapon::getSpeed(int face) const { return (dx - ((dx * 2) * face)); } diff --git a/src/CWeapon.h b/src/CWeapon.h index 2f0c080..366735b 100755 --- a/src/CWeapon.h +++ b/src/CWeapon.h @@ -30,6 +30,6 @@ class Weapon { Weapon(); void setName(const char *name); - int getSpeed(int face); + int getSpeed(int face) const; };