From 6419386c4c382753509425826ee609dd07d4ae72 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 18 Sep 2013 22:39:29 +0300 Subject: add const to other files. --- src/being/localplayer.cpp | 4 ++-- src/gui/buydialog.cpp | 2 +- src/gui/inventorywindow.cpp | 2 +- src/gui/widgets/setuptouchitem.cpp | 2 +- src/guild.cpp | 2 +- src/party.cpp | 2 +- src/resources/iteminfo.h | 2 +- src/resources/resource.h | 2 +- src/resources/sounddb.cpp | 2 +- src/resources/spritedef.cpp | 2 +- src/resources/spritedef.h | 2 +- src/resources/wallpaper.cpp | 2 +- src/simpleanimation.cpp | 4 ++-- src/spellmanager.cpp | 4 ++-- src/test/testmain.cpp | 5 ++--- src/utils/base64.cpp | 2 +- src/utils/physfstools.cpp | 2 +- src/utils/sdl2helper.cpp | 2 +- src/utils/sdl2helper.h | 2 +- src/utils/sdlhelper.cpp | 15 ++++++++------- src/utils/sdlhelper.h | 13 +++++++------ 21 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 4d42bc717..04bb2603a 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1978,7 +1978,7 @@ void LocalPlayer::changeAttackWeaponType() &LocalPlayer::getAttackWeaponTypeString, 1); } -static const char *attackWeaponTypeStrings[] = +static const char *const attackWeaponTypeStrings[] = { // TRANSLATORS: switch attack type in status bar N_("(?) attack"), @@ -2238,7 +2238,7 @@ void LocalPlayer::changeAwayMode() } } -static const char *awayModeStrings[] = +static const char *const awayModeStrings[] = { // TRANSLATORS: away type in status bar N_("(O) on keyboard"), diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index c370ecfd3..ce7c32ba2 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -50,7 +50,7 @@ #include "debug.h" -static const char *SORT_NAME_BUY[7] = +static const char *const SORT_NAME_BUY[7] = { // TRANSLATORS: buy dialog sort type. N_("unsorted"), diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 7a1645148..e497f5782 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -63,7 +63,7 @@ #include "debug.h" -static const char *SORT_NAME_INVENTORY[6] = +static const char *const SORT_NAME_INVENTORY[6] = { // TRANSLATORS: inventory sort mode N_("default"), diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index d8d6eda9a..b62e1e550 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -31,7 +31,7 @@ #include "debug.h" -static class SortTouchActionFunctor final +static const class SortTouchActionFunctor final { public: bool operator() (const SetupActionData *const data1, diff --git a/src/guild.cpp b/src/guild.cpp index 12fbe78a4..3b80022ae 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -28,7 +28,7 @@ #include "debug.h" -static class SortGuildFunctor final +static const class SortGuildFunctor final { public: bool operator() (const GuildMember *const m1, diff --git a/src/party.cpp b/src/party.cpp index b6594672a..2f747e752 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -27,7 +27,7 @@ #include "debug.h" -static class SortPartyFunctor final +static const class SortPartyFunctor final { public: bool operator() (const PartyMember *const p1, diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 7e2dd1bff..01522ef7b 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -295,7 +295,7 @@ class ItemInfo final Cursor::Cursor getPickupCursor() const A_WARN_UNUSED { return mPickupCursor; } - void setProtected(bool b) + void setProtected(const bool b) { mProtected = b; } bool isProtected() const diff --git a/src/resources/resource.h b/src/resources/resource.h index a60d6765c..cdcac1b8f 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -96,7 +96,7 @@ class Resource bool isProtected() const { return mProtected; } - void setNotCount(bool b) + void setNotCount(const bool b) { mNotCount = b; } #ifdef DEBUG_DUMP_LEAKS diff --git a/src/resources/sounddb.cpp b/src/resources/sounddb.cpp index 71e1a01e4..7b0d078e1 100644 --- a/src/resources/sounddb.cpp +++ b/src/resources/sounddb.cpp @@ -39,7 +39,7 @@ void SoundDB::load() unload(); XML::Document *doc = new XML::Document(paths.getStringValue("soundsFile")); - XmlNodePtr root = doc->rootNode(); + const XmlNodePtr root = doc->rootNode(); if (!root || !xmlNameEqual(root, "sounds")) { diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 78c456878..89450486d 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -493,7 +493,7 @@ bool SpriteDef::addSequence(const int start, const int end, const int delay, const int offsetX, const int offsetY, const int variant_offset, int repeat, const int rand, - ImageSet *const imageSet, + const ImageSet *const imageSet, Animation *const animation) const { if (!imageSet || !animation) diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 26c768776..6ef64bbae 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -163,7 +163,7 @@ class SpriteDef final : public Resource const int offsetX, const int offsetY, const int variant_offset, int repeat, const int rand, - ImageSet *const imageSet, + const ImageSet *const imageSet, Animation *const animation) const; private: diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 0bbbbfa2a..513e1c8fc 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -93,7 +93,7 @@ void Wallpaper::loadWallpapers() { wallpaperData.clear(); initDefaultWallpaperPaths(); - char **imgs = PhysFs::enumerateFiles(wallpaperPath.c_str()); + char **const imgs = PhysFs::enumerateFiles(wallpaperPath.c_str()); for (char **i = imgs; *i; i++) { diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index de0050fa4..e0623c937 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -155,8 +155,8 @@ void SimpleAnimation::initializeAnimation(const XmlNodePtr animationNode, if (!imagePath.empty() && !dyePalettes.empty()) Dye::instantiate(imagePath, dyePalettes); - ImageSet *const imageset = ResourceManager::getInstance()->getImageSet( - XML::getProperty(animationNode, "imageset", ""), + const ImageSet *const imageset = ResourceManager::getInstance() + ->getImageSet(XML::getProperty(animationNode, "imageset", ""), XML::getProperty(animationNode, "width", 0), XML::getProperty(animationNode, "height", 0)); diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index b72d8ec40..2038c478a 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -55,7 +55,7 @@ TextCommand* SpellManager::getSpell(const int spellId) const if (spellId < 0 || static_cast(spellId) >= mSpells.size()) return nullptr; - std::map::const_iterator + const std::map::const_iterator it = mSpells.find(spellId); return it != mSpells.end() ? (*it).second : nullptr; @@ -404,7 +404,7 @@ void SpellManager::swap(const int id1, const int id2) mSpells[id2] = spell1; // swap id - int tmp = spell1->getId(); + const int tmp = spell1->getId(); spell1->setId(spell2->getId()); spell2->setId(tmp); diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index f3e61b29e..4c45af989 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -87,7 +87,7 @@ int TestMain::exec(const bool testAudio) rescaleTest[2] = -1; std::string info; - int videoDetectTest = invokeTest("99"); + const int videoDetectTest = invokeTest("99"); if (!videoDetectTest) detectMode = readValue2(99); @@ -190,7 +190,7 @@ int TestMain::exec(const bool testAudio) } int batchSize = 256; -/* + // if OpenGL mode is fast mode we can try detect max batch sizes if (openGLMode == RENDER_NORMAL_OPENGL) { @@ -199,7 +199,6 @@ int TestMain::exec(const bool testAudio) if (batchSize < 256) batchSize = 256; } -*/ // if OpenGL implimentation is not good, disable it. if (!(detectMode & 15)) diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index ebdfcb7c3..4e1061b6e 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -42,7 +42,7 @@ static char base64_table[] = 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0' }; -static char base64_pad = '='; +static const char base64_pad = '='; unsigned char *php3_base64_encode(const unsigned char *const string, int length, int *const ret_length) diff --git a/src/utils/physfstools.cpp b/src/utils/physfstools.cpp index 38f3a408f..cf87fa9ab 100644 --- a/src/utils/physfstools.cpp +++ b/src/utils/physfstools.cpp @@ -61,7 +61,7 @@ namespace PhysFs return PHYSFS_isDirectory(fname); } - void freeList(void *listVar) + void freeList(void *const listVar) { PHYSFS_freeList(listVar); } diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp index eb8179a8b..b36fd8733 100644 --- a/src/utils/sdl2helper.cpp +++ b/src/utils/sdl2helper.cpp @@ -88,7 +88,7 @@ bool SDL::getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info) } SDL_Thread *SDL::createThread(SDL_ThreadFunction fn, - const char *name, void *data) + const char *const name, void *const data) { return SDL_CreateThread(fn, name, data); } diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h index f8dd40270..869fc1d21 100644 --- a/src/utils/sdl2helper.h +++ b/src/utils/sdl2helper.h @@ -49,7 +49,7 @@ namespace SDL bool getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info); SDL_Thread *createThread(SDL_ThreadFunction fn, - const char *name, void *data); + const char *const name, void *const data); } // namespace SDL #endif // USE_SDL2 diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp index 691a5238e..0034ee0e8 100644 --- a/src/utils/sdlhelper.cpp +++ b/src/utils/sdlhelper.cpp @@ -34,7 +34,7 @@ bool SDL::getAllVideoModes(StringVect &modeList) { /* Get available fullscreen/hardware modes */ - SDL_Rect **const modes = SDL_ListModes(nullptr, + SDL_Rect *const *const modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE); /* Check which modes are available */ @@ -62,24 +62,24 @@ bool SDL::getAllVideoModes(StringVect &modeList) } } -void SDL::SetWindowTitle(SDL_Surface *const window A_UNUSED, +void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED, const char *const title) { SDL_WM_SetCaption(title, nullptr); } -void SDL::SetWindowIcon(SDL_Surface *const window A_UNUSED, +void SDL::SetWindowIcon(const SDL_Surface *const window A_UNUSED, SDL_Surface *const icon) { SDL_WM_SetIcon(icon, nullptr); } -void SDL::grabInput(SDL_Surface *const window A_UNUSED, const bool grab) +void SDL::grabInput(const SDL_Surface *const window A_UNUSED, const bool grab) { SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); } -void SDL::setGamma(SDL_Surface *const window A_UNUSED, const float gamma) +void SDL::setGamma(const SDL_Surface *const window A_UNUSED, const float gamma) { SDL_SetGamma(gamma, gamma, gamma); } @@ -89,14 +89,15 @@ void SDL::setVsync(const int val) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val); } -bool SDL::getWindowWMInfo(SDL_Surface *const window A_UNUSED, +bool SDL::getWindowWMInfo(const SDL_Surface *const window A_UNUSED, SDL_SysWMinfo *const info) { return SDL_GetWMInfo(info); } SDL_Thread *SDL::createThread(int (SDLCALL *fn)(void *), - const char *name A_UNUSED, void *data) + const char *const name A_UNUSED, + void *const data) { return SDL_CreateThread(fn, data); } diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h index 70f266788..29d8241e3 100644 --- a/src/utils/sdlhelper.h +++ b/src/utils/sdlhelper.h @@ -38,23 +38,24 @@ namespace SDL { bool getAllVideoModes(StringVect &modeList); - void SetWindowTitle(SDL_Surface *const window, + void SetWindowTitle(const SDL_Surface *const window, const char *const title); - void SetWindowIcon(SDL_Surface *const window A_UNUSED, + void SetWindowIcon(const SDL_Surface *const window A_UNUSED, SDL_Surface *const icon); - void grabInput(SDL_Surface *const window A_UNUSED, const bool grab); + void grabInput(const SDL_Surface *const window A_UNUSED, const bool grab); - void setGamma(SDL_Surface *const window A_UNUSED, const float gamma); + void setGamma(const SDL_Surface *const window A_UNUSED, const float gamma); void setVsync(const int val); - bool getWindowWMInfo(SDL_Surface *const window A_UNUSED, + bool getWindowWMInfo(const SDL_Surface *const window A_UNUSED, SDL_SysWMinfo *const info); SDL_Thread *createThread(int (SDLCALL *fn)(void *), - const char *name A_UNUSED, void *data); + const char *const name A_UNUSED, + void *const data); } // namespace SDL #endif // USE_SDL2 -- cgit v1.2.3-60-g2f50