summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-04 19:11:53 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-04 19:11:53 +0300
commit3a407bb6b73a186eafd99bcec570f88097c4b2e1 (patch)
treeea57a752c348ba0a883294855ad3c62c16e9749d /src
parent872fc368f7b253f26714fc47323064f270b62b40 (diff)
downloadmanaplus-3a407bb6b73a186eafd99bcec570f88097c4b2e1.tar.gz
manaplus-3a407bb6b73a186eafd99bcec570f88097c4b2e1.tar.bz2
manaplus-3a407bb6b73a186eafd99bcec570f88097c4b2e1.tar.xz
manaplus-3a407bb6b73a186eafd99bcec570f88097c4b2e1.zip
Add const to more classes.
Diffstat (limited to 'src')
-rw-r--r--src/gui/theme.cpp4
-rw-r--r--src/test/testlauncher.cpp26
-rw-r--r--src/test/testlauncher.h9
-rw-r--r--src/test/testmain.cpp18
-rw-r--r--src/test/testmain.h10
-rw-r--r--src/text.cpp23
-rw-r--r--src/text.h28
-rw-r--r--src/textcommand.cpp22
-rw-r--r--src/textcommand.h31
-rw-r--r--src/textmanager.cpp21
-rw-r--r--src/textmanager.h13
-rw-r--r--src/textparticle.cpp12
-rw-r--r--src/textparticle.h6
-rw-r--r--src/textrenderer.h14
-rw-r--r--src/tileset.h6
-rw-r--r--src/units.cpp8
-rw-r--r--src/units.h4
-rw-r--r--src/utils/base64.cpp12
-rw-r--r--src/utils/checkutils.cpp6
-rw-r--r--src/utils/checkutils.h6
-rw-r--r--src/utils/langs.cpp6
-rw-r--r--src/utils/mathutils.h10
-rw-r--r--src/utils/mkdir.cpp4
-rw-r--r--src/utils/mkdir.h2
-rw-r--r--src/utils/mutex.h2
-rw-r--r--src/utils/paths.cpp2
-rw-r--r--src/utils/physfsrwops.cpp17
-rw-r--r--src/utils/process.cpp2
-rw-r--r--src/utils/stringutils.cpp46
-rw-r--r--src/utils/stringutils.h26
-rw-r--r--src/utils/translation/podict.cpp2
-rw-r--r--src/utils/translation/podict.h2
-rw-r--r--src/utils/translation/poparser.cpp11
-rw-r--r--src/utils/translation/poparser.h10
-rw-r--r--src/utils/translation/translationmanager.cpp8
-rw-r--r--src/utils/translation/translationmanager.h6
-rw-r--r--src/utils/xml.cpp36
-rw-r--r--src/utils/xml.h23
-rw-r--r--src/variabledata.h12
-rw-r--r--src/vector.h10
40 files changed, 274 insertions, 242 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index a6b94c4d4..91a6720e0 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -328,7 +328,7 @@ struct SkinParameter
std::string name;
};
-static SkinParameter skinParam[] =
+static const SkinParameter skinParam[] =
{
{0, "top-left-corner"},
{0, "standart"},
@@ -367,7 +367,7 @@ static SkinParameter skinParam[] =
{8, "bottom-right-corner"},
};
-static SkinParameter imageParam[] =
+static const SkinParameter imageParam[] =
{
{0, "closeImage"},
{1, "stickyImageUp"},
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 8538c3e65..c13f52ffb 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -75,12 +75,13 @@ int TestLauncher::exec()
return -1;
}
-int TestLauncher::testBackend()
+int TestLauncher::testBackend() const
{
- Image *img = Theme::getImageFromTheme("graphics/sprites/arrow_up.gif");
+ const Image *const img = Theme::getImageFromTheme(
+ "graphics/sprites/arrow_up.gif");
if (!img)
return 1;
- int cnt = 100;
+ const int cnt = 100;
for (int f = 0; f < cnt; f ++)
{
@@ -92,7 +93,7 @@ int TestLauncher::testBackend()
return 0;
}
-int TestLauncher::testSound()
+int TestLauncher::testSound() const
{
sound.playGuiSfx("system/newmessage.ogg");
sleep(1);
@@ -103,11 +104,11 @@ int TestLauncher::testSound()
return 0;
}
-int TestLauncher::testRescale()
+int TestLauncher::testRescale() const
{
Wallpaper::loadWallpapers();
const std::string wallpaperName = Wallpaper::getWallpaper(800, 600);
- volatile Image *img = Theme::getImageFromTheme(wallpaperName);
+ const volatile Image *const img = Theme::getImageFromTheme(wallpaperName);
if (!img)
return 1;
@@ -132,7 +133,7 @@ int TestLauncher::testFps()
img[4] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png");
int idx = 0;
- int cnt = 20;
+ const int cnt = 20;
gettimeofday(&start, nullptr);
for (int k = 0; k < cnt; k ++)
@@ -155,7 +156,7 @@ int TestLauncher::testFps()
}
gettimeofday(&end, nullptr);
- int tFps = calcFps(&start, &end, cnt);
+ const int tFps = calcFps(&start, &end, cnt);
file << mTest << std::endl;
file << tFps << std::endl;
@@ -179,10 +180,10 @@ int TestLauncher::testInternal()
img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_left.gif");
img[3] = Theme::getImageFromTheme("graphics/sprites/arrow_right.gif");
int idx = 0;
- int mem = mainGraphics->getMemoryUsage();
+ const int mem = mainGraphics->getMemoryUsage();
// int cnt = 5;
- int cnt = 5000;
+ const int cnt = 5000;
gettimeofday(&start, nullptr);
for (int k = 0; k < cnt; k ++)
@@ -204,7 +205,7 @@ int TestLauncher::testInternal()
}
gettimeofday(&end, nullptr);
- int tFps = calcFps(&start, &end, cnt);
+ const int tFps = calcFps(&start, &end, cnt);
file << mTest << std::endl;
file << tFps << std::endl;
file << mem << std::endl;
@@ -221,7 +222,8 @@ int TestLauncher::testVideoDetection()
return 0;
}
-int TestLauncher::calcFps(timeval *start, timeval *end, int calls)
+int TestLauncher::calcFps(const timeval *const start, const timeval *const end,
+ const int calls) const
{
long mtime;
long seconds;
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
index f42e22644..da8534306 100644
--- a/src/test/testlauncher.h
+++ b/src/test/testlauncher.h
@@ -34,13 +34,14 @@ class TestLauncher
int exec();
- int calcFps(timeval *start, timeval *end, int calls);
+ int calcFps(const timeval *const start, const timeval *const end,
+ const int calls) const;
- int testBackend();
+ int testBackend() const;
- int testSound();
+ int testSound() const;
- int testRescale();
+ int testRescale() const;
int testFps();
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index e5fac5100..c6023a53f 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -66,7 +66,7 @@ void TestMain::initConfig()
mConfig.setValue("screenheight", 600);
}
-int TestMain::exec(bool testAudio)
+int TestMain::exec(const bool testAudio)
{
initConfig();
int softwareTest = invokeSoftwareRenderTest("1");
@@ -197,8 +197,8 @@ int TestMain::exec(bool testAudio)
return 0;
}
-void TestMain::writeConfig(int openGLMode, int rescale,
- int sound, std::string info)
+void TestMain::writeConfig(const int openGLMode, const int rescale,
+ const int sound, const std::string &info)
{
mConfig.init(Client::getConfigDirectory() + "/config.xml");
@@ -222,14 +222,14 @@ void TestMain::writeConfig(int openGLMode, int rescale,
mConfig.write();
}
-int TestMain::readValue2(int ver)
+int TestMain::readValue2(const int ver)
{
- int def = readValue(ver, 0);
+ const int def = readValue(ver, 0);
log->log("value for %d = %d", ver, def);
return def;
}
-int TestMain::readValue(int ver, int def)
+int TestMain::readValue(const int ver, int def)
{
std::string tmp;
int var;
@@ -257,14 +257,14 @@ int TestMain::invokeTest(std::string test)
mConfig.setValue("opengl", 0);
mConfig.write();
- int ret = execFileWait(fileName, fileName, "-t", test);
+ const int ret = execFileWait(fileName, fileName, "-t", test);
return ret;
}
int TestMain::invokeTest4()
{
mConfig.setValue("sound", true);
- int ret = invokeTest("4");
+ const int ret = invokeTest("4");
log->log("4: %d", ret);
return ret;
@@ -274,7 +274,7 @@ int TestMain::invokeSoftwareRenderTest(std::string test)
{
mConfig.setValue("opengl", 0);
mConfig.write();
- int ret = execFileWait(fileName, fileName, "-t", test, 30);
+ const int ret = execFileWait(fileName, fileName, "-t", test, 30);
log->log("%s: %d", test.c_str(), ret);
return ret;
}
diff --git a/src/test/testmain.h b/src/test/testmain.h
index 281cdab3a..ddb10c7c4 100644
--- a/src/test/testmain.h
+++ b/src/test/testmain.h
@@ -31,9 +31,9 @@ class TestMain
public:
TestMain();
- int exec(bool testAudio = true);
+ int exec(const bool testAudio = true);
- static int readValue(int ver, int def);
+ static int readValue(const int ver, int def);
Configuration &getConfig()
{ return mConfig; }
@@ -57,10 +57,10 @@ class TestMain
void testsMain();
- void writeConfig(int openGLMode, int rescale,
- int sound, std::string info);
+ void writeConfig(const int openGLMode, const int rescale,
+ const int sound, const std::string &info);
- int readValue2(int ver);
+ int readValue2(const int ver);
Logger *log;
diff --git a/src/text.cpp b/src/text.cpp
index 7af59f47e..29bed5375 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -40,10 +40,10 @@
int Text::mInstances = 0;
ImageRect Text::mBubble;
-Text::Text(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color* color, bool isSpeech,
- gcn::Font *font) :
+Text::Text(const std::string &text, const int x, const int y,
+ const gcn::Graphics::Alignment alignment,
+ const gcn::Color* color, const bool isSpeech,
+ gcn::Font *const font) :
mText(text),
mColor(color),
mIsSpeech(isSpeech)
@@ -116,18 +116,18 @@ Text::~Text()
}
}
-void Text::setColor(const gcn::Color *color)
+void Text::setColor(const gcn::Color *const color)
{
mColor = color;
}
-void Text::adviseXY(int x, int y)
+void Text::adviseXY(const int x, const int y)
{
if (textManager)
textManager->moveText(this, x - mXOffset, y);
}
-void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
+void Text::draw(gcn::Graphics *const graphics, const int xOff, const int yOff)
{
if (mIsSpeech)
{
@@ -141,15 +141,16 @@ void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
*mColor, mFont, !mIsSpeech, true);
}
-FlashText::FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color *color, gcn::Font *font) :
+FlashText::FlashText(const std::string &text, const int x, const int y,
+ const gcn::Graphics::Alignment alignment,
+ const gcn::Color *const color, gcn::Font *const font) :
Text(text, x, y, alignment, color, false, font),
mTime(0)
{
}
-void FlashText::draw(gcn::Graphics *graphics, int xOff, int yOff)
+void FlashText::draw(gcn::Graphics *const graphics,
+ const int xOff, const int yOff)
{
if (mTime)
{
diff --git a/src/text.h b/src/text.h
index f585cca36..e4ad4ab06 100644
--- a/src/text.h
+++ b/src/text.h
@@ -39,17 +39,17 @@ class Text
/**
* Constructor creates a text object to display on the screen.
*/
- Text(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color *color, bool isSpeech = false,
- gcn::Font *font = nullptr);
+ Text(const std::string &text, const int x, const int y,
+ const gcn::Graphics::Alignment alignment,
+ const gcn::Color *const color, const bool isSpeech = false,
+ gcn::Font *const font = nullptr);
/**
* Destructor. The text is removed from the screen.
*/
virtual ~Text();
- void setColor(const gcn::Color *color);
+ void setColor(const gcn::Color *const color);
int getWidth() const
{ return mWidth; }
@@ -60,12 +60,13 @@ class Text
/**
* Allows the originator of the text to specify the ideal coordinates.
*/
- void adviseXY(int x, int y);
+ void adviseXY(const int x, const int y);
/**
* Draws the text.
*/
- virtual void draw(gcn::Graphics *graphics, int xOff, int yOff);
+ virtual void draw(gcn::Graphics *const graphics,
+ const int xOff, const int yOff);
private:
int mX; /**< Actual x-value of left of text written. */
@@ -86,10 +87,10 @@ class Text
class FlashText : public Text
{
public:
- FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color* color,
- gcn::Font *font = nullptr);
+ FlashText(const std::string &text, const int x, const int y,
+ const gcn::Graphics::Alignment alignment,
+ const gcn::Color *const color,
+ gcn::Font *const font = nullptr);
/**
* Remove the text from the screen
@@ -100,13 +101,14 @@ class FlashText : public Text
/**
* Flash the text for so many refreshes.
*/
- void flash(int time)
+ void flash(const int time)
{ mTime = time; }
/**
* Draws the text.
*/
- virtual void draw(gcn::Graphics *graphics, int xOff, int yOff);
+ virtual void draw(gcn::Graphics *const graphics,
+ const int xOff, const int yOff);
private:
int mTime; /**< Time left for flashing */
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 75dcab044..e0153f163 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -33,11 +33,12 @@
#include "debug.h"
-TextCommand::TextCommand(unsigned int id, std::string symbol,
- std::string command, std::string comment,
- SpellTarget type, std::string icon,
- unsigned int basicLvl, MagicSchool school,
- unsigned int schoolLvl, int mana) :
+TextCommand::TextCommand(const unsigned int id, const std::string &symbol,
+ const std::string &command,
+ const std::string &comment,
+ const SpellTarget type, const std::string &icon,
+ const unsigned int basicLvl, const MagicSchool school,
+ const unsigned int schoolLvl, const int mana) :
mCommand(command),
mComment(comment),
mSymbol(symbol),
@@ -55,9 +56,10 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
}
-TextCommand::TextCommand(unsigned int id, std::string symbol,
- std::string command, std::string comment,
- SpellTarget type, std::string icon) :
+TextCommand::TextCommand(const unsigned int id, const std::string &symbol,
+ const std::string &command,
+ const std::string &comment,
+ const SpellTarget type, const std::string &icon) :
mCommand(command),
mComment(comment),
mSymbol(symbol),
@@ -74,7 +76,7 @@ TextCommand::TextCommand(unsigned int id, std::string symbol,
loadImage();
}
-TextCommand::TextCommand(unsigned int id) :
+TextCommand::TextCommand(const unsigned int id) :
mCommand(""),
mComment(""),
mSymbol(""),
@@ -112,7 +114,7 @@ void TextCommand::loadImage()
if (getIcon().empty())
return;
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
SpriteDisplay display = ItemDB::get(getIcon()).getDisplay();
mImage = resman->getImage(paths.getStringValue("itemIcons")
+ display.image);
diff --git a/src/textcommand.h b/src/textcommand.h
index 8a46d73ba..f9b44253b 100644
--- a/src/textcommand.h
+++ b/src/textcommand.h
@@ -61,21 +61,24 @@ class TextCommand
/**
* Constructor.
*/
- TextCommand(unsigned int id, std::string symbol, std::string command,
- std::string comment, SpellTarget type, std::string icon,
- unsigned int basicLvl, MagicSchool school = SKILL_MAGIC,
- unsigned int schoolLvl = 0, int mana = 0);
+ TextCommand(const unsigned int id, const std::string &symbol,
+ const std::string &command,
+ const std::string &comment, const SpellTarget type,
+ const std::string &icon, const unsigned int basicLvl,
+ const MagicSchool school = SKILL_MAGIC,
+ const unsigned int schoolLvl = 0, const int mana = 0);
/**
* Constructor.
*/
- TextCommand(unsigned int id, std::string symbol, std::string command,
- std::string comment, SpellTarget type, std::string icon);
+ TextCommand(const unsigned int id, const std::string &symbol,
+ const std::string &command, const std::string &comment,
+ const SpellTarget type, const std::string &icon);
/**
* Constructor.
*/
- TextCommand(unsigned int id);
+ TextCommand(const unsigned int id);
/**
* Destructor.
@@ -127,28 +130,28 @@ class TextCommand
void setSymbol(std::string symbol)
{ mSymbol = symbol; }
- void setId(unsigned int id)
+ void setId(const unsigned int id)
{ mId = id; }
- void setTargetType(SpellTarget targetType)
+ void setTargetType(const SpellTarget targetType)
{ mTargetType = targetType; }
void setIcon(std::string icon)
{ mIcon = icon; loadImage(); }
- void setMana(unsigned int mana)
+ void setMana(const unsigned int mana)
{ mMana = mana; }
- void setSchool(MagicSchool school)
+ void setSchool(const MagicSchool school)
{ mSchool = school; }
- void setBaseLvl(unsigned int baseLvl)
+ void setBaseLvl(const unsigned int baseLvl)
{ mBaseLvl = baseLvl; }
- void setSchoolLvl(unsigned int schoolLvl)
+ void setSchoolLvl(const unsigned int schoolLvl)
{ mSchoolLvl = schoolLvl; }
- void setCommandType(TextCommandType commandType)
+ void setCommandType(const TextCommandType commandType)
{ mCommandType = commandType; }
bool isEmpty() const
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 3cd36e449..bb0112978 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -33,20 +33,20 @@ TextManager::TextManager()
{
}
-void TextManager::addText(Text *text)
+void TextManager::addText(Text *const text)
{
place(text, nullptr, text->mX, text->mY, text->mHeight);
mTextList.push_back(text);
}
-void TextManager::moveText(Text *text, int x, int y)
+void TextManager::moveText(Text *const text, const int x, const int y)
{
text->mX = x;
text->mY = y;
place(text, text, text->mX, text->mY, text->mHeight);
}
-void TextManager::removeText(const Text *text)
+void TextManager::removeText(const Text *const text)
{
for (TextList::iterator ptr = mTextList.begin(),
pEnd = mTextList.end(); ptr != pEnd; ++ptr)
@@ -63,7 +63,8 @@ TextManager::~TextManager()
{
}
-void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff)
+void TextManager::draw(gcn::Graphics *const graphics,
+ const int xOff, const int yOff)
{
for (TextList::const_iterator bPtr = mTextList.begin(),
ePtr = mTextList.end();
@@ -73,17 +74,17 @@ void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff)
}
}
-void TextManager::place(const Text *textObj, const Text *omit,
- int &x A_UNUSED, int &y, int h)
+void TextManager::place(const Text *const textObj, const Text *const omit,
+ const int &x A_UNUSED, int &y, const int h)
{
- int xLeft = textObj->mX;
- int xRight1 = xLeft + textObj->mWidth;
+ const int xLeft = textObj->mX;
+ const int xRight1 = xLeft + textObj->mWidth;
const int TEST = 50; // Number of lines to test for text
const int nBeings = 50;
bool occupied[TEST]; // is some other text obscuring this line?
std::memset(&occupied, 0, sizeof(occupied)); // set all to false
- int wantedTop = (TEST - h) / 2; // Entry in occupied at top of text
- int occupiedTop = y - wantedTop; // Line in map representing to of occupied
+ const int wantedTop = (TEST - h) / 2; // Entry in occupied at top of text
+ const int occupiedTop = y - wantedTop; // Line in map representing to of occupied
int cnt = 0;
for (TextList::const_iterator ptr = mTextList.begin(),
diff --git a/src/textmanager.h b/src/textmanager.h
index 471274895..8819d31dc 100644
--- a/src/textmanager.h
+++ b/src/textmanager.h
@@ -42,17 +42,17 @@ class TextManager
/**
* Add text to the manager
*/
- void addText(Text *text);
+ void addText(Text *const text);
/**
* Move the text around the screen
*/
- void moveText(Text *text, int x, int y);
+ void moveText(Text *const text, const int x, const int y);
/**
* Remove the text from the manager
*/
- void removeText(const Text *text);
+ void removeText(const Text *const text);
/**
* Destroy the manager
@@ -62,14 +62,15 @@ class TextManager
/**
* Draw the text
*/
- void draw(gcn::Graphics *graphics, int xOff, int yOff);
+ void draw(gcn::Graphics *const graphics,
+ const int xOff, const int yOff);
private:
/**
* Position the text so as to avoid conflict
*/
- void place(const Text *textObj, const Text *omit,
- int &x, int &y, int h);
+ void place(const Text *const textObj, const Text *const omit,
+ const int &x, int &y, const int h);
typedef std::list<Text *> TextList; /**< The container type */
TextList mTextList; /**< The container */
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index d8c0b7a8e..4ee261f82 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -28,9 +28,9 @@
#include "debug.h"
-TextParticle::TextParticle(Map *map, const std::string &text,
- const gcn::Color *color,
- gcn::Font *font, bool outline):
+TextParticle::TextParticle(Map *const map, const std::string &text,
+ const gcn::Color *const color,
+ gcn::Font *const font, const bool outline) :
Particle(map),
mText(text),
mTextFont(font),
@@ -44,8 +44,8 @@ bool TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
if (!isAlive())
return false;
- int screenX = static_cast<int>(mPos.x) + offsetX;
- int screenY = static_cast<int>(mPos.y) - static_cast<int>(mPos.z)
+ const int screenX = static_cast<int>(mPos.x) + offsetX;
+ const int screenY = static_cast<int>(mPos.y) - static_cast<int>(mPos.z)
+ offsetY;
float alpha = mAlpha * 255.0f;
@@ -62,7 +62,7 @@ bool TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
/ static_cast<float>(mFadeIn);
}
- gcn::Color color = *mColor;
+ const gcn::Color color = *mColor;
// color.a = (int)alpha;
TextRenderer::renderText(graphics, mText,
diff --git a/src/textparticle.h b/src/textparticle.h
index f136be78a..55c8eab9d 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -31,9 +31,9 @@ class TextParticle : public Particle
/**
* Constructor.
*/
- TextParticle(Map *map, const std::string &text,
- const gcn::Color* color,
- gcn::Font *font, bool outline = false);
+ TextParticle(Map *const map, const std::string &text,
+ const gcn::Color *const color,
+ gcn::Font *const font, const bool outline = false);
/**
* Draws the particle image.
diff --git a/src/textrenderer.h b/src/textrenderer.h
index 5dd831ddd..e331453fb 100644
--- a/src/textrenderer.h
+++ b/src/textrenderer.h
@@ -35,15 +35,15 @@ class TextRenderer
/**
* Renders a specified text.
*/
- static inline void renderText(gcn::Graphics *graphics,
+ static inline void renderText(gcn::Graphics *const graphics,
const std::string &text,
- int x, int y,
- gcn::Graphics::Alignment align,
+ const int x, const int y,
+ const gcn::Graphics::Alignment align,
const gcn::Color &color,
- gcn::Font *font,
- bool outline = false,
- bool shadow = false,
- int alpha = 255)
+ gcn::Font *const font,
+ const bool outline = false,
+ const bool shadow = false,
+ const int alpha = 255)
{
graphics->setFont(font);
diff --git a/src/tileset.h b/src/tileset.h
index f60e95266..fe269f2d0 100644
--- a/src/tileset.h
+++ b/src/tileset.h
@@ -36,8 +36,8 @@ class Tileset : public ImageSet
/**
* Constructor.
*/
- Tileset(Image *img, int w, int h, int firstGid,
- int margin, int spacing):
+ Tileset(Image *const img, const int w, const int h, const int firstGid,
+ const int margin, const int spacing):
ImageSet(img, w, h, margin, spacing),
mFirstGid(firstGid)
{
@@ -60,7 +60,7 @@ class Tileset : public ImageSet
*/
std::string getProperty(std::string name)
{
- std::map<std::string, std::string>::const_iterator
+ const std::map<std::string, std::string>::const_iterator
it = mProperties.find(name);
if (it == mProperties.end())
return "";
diff --git a/src/units.cpp b/src/units.cpp
index 3c4da47e8..52093c057 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -103,7 +103,7 @@ void Units::loadUnits()
}
XML::Document doc("units.xml");
- XmlNodePtr root = doc.rootNode();
+ const XmlNodePtr root = doc.rootNode();
if (!root || !xmlNameEqual(root, "units"))
{
@@ -173,7 +173,7 @@ void Units::loadUnits()
}
}
-static std::string formatUnit(int value, int type)
+static std::string formatUnit(const int value, const int type)
{
struct UnitDescription ud = units[type];
struct UnitLevel ul;
@@ -252,12 +252,12 @@ static std::string formatUnit(int value, int type)
}
}
-std::string Units::formatCurrency(int value)
+std::string Units::formatCurrency(const int value)
{
return formatUnit(value, UNIT_CURRENCY);
}
-std::string Units::formatWeight(int value)
+std::string Units::formatWeight(const int value)
{
return formatUnit(value, UNIT_WEIGHT);
}
diff --git a/src/units.h b/src/units.h
index ba1f720e3..bc9905779 100644
--- a/src/units.h
+++ b/src/units.h
@@ -36,12 +36,12 @@ class Units
/**
* Formats the given number in the correct currency format.
*/
- static std::string formatCurrency(int value);
+ static std::string formatCurrency(const int value);
/**
* Formats the given number in the correct weight/mass format.
*/
- static std::string formatWeight(int value);
+ static std::string formatWeight(const int value);
};
#endif // UNITS_H
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 094cd6227..52c6821fd 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -44,12 +44,12 @@ static char base64_table[] =
};
static char base64_pad = '=';
-unsigned char *php3_base64_encode(const unsigned char *string,
- int length, int *ret_length)
+unsigned char *php3_base64_encode(const unsigned char *const string,
+ int length, int *const ret_length)
{
const unsigned char *current = string;
int i = 0;
- unsigned char *result = static_cast<unsigned char *>(calloc(
+ unsigned char *const result = static_cast<unsigned char *>(calloc(
((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char), 1));
while (length > 2)
@@ -92,12 +92,12 @@ unsigned char *php3_base64_encode(const unsigned char *string,
}
/* as above, but backwards. :) */
-unsigned char *php3_base64_decode(const unsigned char *string,
- int length, int *ret_length)
+unsigned char *php3_base64_decode(const unsigned char *const string,
+ const int length, int *const ret_length)
{
const unsigned char *current = string;
int ch, i = 0, j = 0, k;
- char *chp;
+ const char *chp;
unsigned char *result = static_cast<unsigned char *>(
calloc(length + 1, 1));
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
index abbc6138a..c943d8f36 100644
--- a/src/utils/checkutils.cpp
+++ b/src/utils/checkutils.cpp
@@ -26,14 +26,16 @@
#include "debug.h"
-bool reportFalseReal(bool val, const char* file, unsigned line)
+bool reportFalseReal(const bool val, const char *const file,
+ const unsigned line)
{
if (!val)
logger->log("Debug: false value at %s:%u", file, line);
return val;
}
-bool reportTrueReal(bool val, const char* file, unsigned line)
+bool reportTrueReal(const bool val, const char *const file,
+ const unsigned line)
{
if (val)
logger->log("Debug: true value at %s:%u", file, line);
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index 6791ff7e0..de5dd8fe2 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -23,8 +23,10 @@
#include <string>
-bool reportFalseReal(bool val, const char* file, unsigned line);
+bool reportFalseReal(const bool val, const char *const file,
+ const unsigned line);
-bool reportTrueReal(bool val, const char* file, unsigned line);
+bool reportTrueReal(const bool val, const char *const file,
+ const unsigned line);
#endif // UTILS_CHECKUTILS_H
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 90a83d6c4..bc2837a27 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -37,7 +37,7 @@ LangVect getLang()
std::string lang = config.getValue("lang", "").c_str();
if (lang.empty())
{
- char *lng = getenv("LANG");
+ const char *const lng = getenv("LANG");
if (!lng)
return langs;
lang = lng;
@@ -58,7 +58,7 @@ std::string getLangSimple()
std::string lang = config.getValue("lang", "").c_str();
if (lang.empty())
{
- char *lng = getenv("LANG");
+ const char *const lng = getenv("LANG");
if (!lng)
return "";
return lng;
@@ -71,7 +71,7 @@ std::string getLangShort()
std::string lang = config.getValue("lang", "").c_str();
if (lang.empty())
{
- char *lng = getenv("LANG");
+ const char *const lng = getenv("LANG");
if (!lng)
return "";
lang = lng;
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 6d5a8339d..7e43a3574 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -27,7 +27,7 @@
#include <stdint.h>
#include <cstring>
-static uint16_t crc_table[256] =
+static const uint16_t crc_table[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@@ -90,7 +90,7 @@ inline uint16_t getCrc16(const std::string &str)
inline float fastInvSqrt(float x)
{
union { int i; float x; } tmp;
- float xhalf = 0.5f * x;
+ const float xhalf = 0.5f * x;
tmp.x = x;
tmp.i = 0x5f375a86 - (tmp.i >> 1);
x = tmp.x;
@@ -98,12 +98,12 @@ inline float fastInvSqrt(float x)
return x;
}
-inline float fastSqrt(float x)
+inline float fastSqrt(const float x)
{
return 1.0f / fastInvSqrt(x);
}
-inline float weightedAverage(float n1, float n2, float w)
+inline float weightedAverage(const float n1, const float n2, const float w)
{
if (w < 0.0f)
return n1;
@@ -114,7 +114,7 @@ inline float weightedAverage(float n1, float n2, float w)
return w * n2 + (1.0f - w) * n1;
}
-inline int roundDouble(double v)
+inline int roundDouble(const double v)
{
return (v > 0.0) ? (v + 0.5) : (v - 0.5);
}
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 05e7d4bd3..e07b3979f 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -40,7 +40,7 @@
#include "debug.h"
#if defined WIN32
-int mkdir_r(const char *pathname)
+int mkdir_r(const char *const pathname)
{
char tmp[PATH_MAX];
char tmp2[PATH_MAX];
@@ -111,7 +111,7 @@ int mkdir_r(const char *pathname)
}
#else
/// Create a directory, making leading components first if necessary
-int mkdir_r(const char *pathname)
+int mkdir_r(const char *const pathname)
{
size_t len = static_cast<int>(strlen(pathname));
char *tmp = new char[len + 2];
diff --git a/src/utils/mkdir.h b/src/utils/mkdir.h
index 8c5ab4ca2..f72548c92 100644
--- a/src/utils/mkdir.h
+++ b/src/utils/mkdir.h
@@ -22,6 +22,6 @@
#ifndef M_MKDIR_H
#define M_MKDIR_H
-int mkdir_r(const char *pathname);
+int mkdir_r(const char *const pathname);
#endif
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
index 61129b4a9..fe560e354 100644
--- a/src/utils/mutex.h
+++ b/src/utils/mutex.h
@@ -84,7 +84,7 @@ inline void Mutex::unlock()
}
-inline MutexLocker::MutexLocker(Mutex *mutex):
+inline MutexLocker::MutexLocker(Mutex *const mutex) :
mMutex(mutex)
{
mMutex->lock();
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp
index 081b642c0..05a00c1ea 100644
--- a/src/utils/paths.cpp
+++ b/src/utils/paths.cpp
@@ -118,7 +118,7 @@ std::string getSelfName()
std::string getSelfName()
{
char buf[257];
- ssize_t sz = readlink("/proc/self/exe", buf, 256);
+ const ssize_t sz = readlink("/proc/self/exe", buf, 256);
if (sz > 0 && sz < 256)
{
buf[sz] = 0;
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index 1afedf2a3..95ba7db82 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -32,7 +32,8 @@
static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
{
- PHYSFS_file *handle = static_cast<PHYSFS_file *>(rw->hidden.unknown.data1);
+ PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ rw->hidden.unknown.data1);
int pos = 0;
if (whence == SEEK_SET)
@@ -41,7 +42,7 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
} /* if */
else if (whence == SEEK_CUR)
{
- PHYSFS_sint64 current = PHYSFS_tell(handle);
+ const PHYSFS_sint64 current = PHYSFS_tell(handle);
if (current == -1)
{
SDL_SetError("Can't find position in file: %s",
@@ -63,7 +64,7 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
} /* else if */
else if (whence == SEEK_END)
{
- PHYSFS_sint64 len = PHYSFS_fileLength(handle);
+ const PHYSFS_sint64 len = PHYSFS_fileLength(handle);
if (len == -1)
{
SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError());
@@ -102,8 +103,9 @@ static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum)
{
- PHYSFS_file *handle = static_cast<PHYSFS_file*>(rw->hidden.unknown.data1);
- PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum);
+ PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ rw->hidden.unknown.data1);
+ const PHYSFS_sint64 rc = PHYSFS_read(handle, ptr, size, maxnum);
if (rc != maxnum)
{
if (!PHYSFS_eof(handle)) /* not EOF? Must be an error. */
@@ -115,8 +117,9 @@ static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum)
static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num)
{
- PHYSFS_file *handle = static_cast<PHYSFS_file*>(rw->hidden.unknown.data1);
- PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num);
+ PHYSFS_file *const handle = static_cast<PHYSFS_file *const>(
+ rw->hidden.unknown.data1);
+ const PHYSFS_sint64 rc = PHYSFS_write(handle, ptr, size, num);
if (rc != num)
SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 36e53c305..a5629fbc9 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -176,7 +176,7 @@ int execFileWait(std::string pathName, std::string name,
}
// monitoring process
- pid_t exited_pid = wait(&status);
+ const pid_t exited_pid = wait(&status);
int ret = -1;
if (exited_pid == pid)
{
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index a4eafda26..2daad464b 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -73,7 +73,7 @@ unsigned int atox(const std::string &str)
return value;
}
-const char *ipToString(int address)
+const char *ipToString(const int address)
{
static char asciiIP[18];
@@ -86,7 +86,7 @@ const char *ipToString(int address)
return asciiIP;
}
-std::string strprintf(char const *format, ...)
+std::string strprintf(char const *const format, ...)
{
char buf[257];
va_list(args);
@@ -139,13 +139,13 @@ std::string removeColors(std::string msg)
int compareStrI(const std::string &a, const std::string &b)
{
std::string::const_iterator itA = a.begin();
- std::string::const_iterator endA = a.end();
+ const std::string::const_iterator endA = a.end();
std::string::const_iterator itB = b.begin();
- std::string::const_iterator endB = b.end();
+ const std::string::const_iterator endB = b.end();
for (; itA < endA, itB < endB; ++itA, ++itB)
{
- int comp = tolower(*itA) - tolower(*itB);
+ const int comp = tolower(*itA) - tolower(*itB);
if (comp)
return comp;
}
@@ -160,7 +160,7 @@ int compareStrI(const std::string &a, const std::string &b)
}
-bool isWordSeparator(char chr)
+bool isWordSeparator(const char chr)
{
return (chr == ' ' || chr == ',' || chr == '.' || chr == '"');
}
@@ -168,7 +168,7 @@ bool isWordSeparator(char chr)
const std::string findSameSubstring(const std::string &str1,
const std::string &str2)
{
- int minLength = str1.length() > str2.length()
+ const int minLength = str1.length() > str2.length()
? static_cast<int>(str2.length()) : static_cast<int>(str1.length());
for (int f = 0; f < minLength; f ++)
{
@@ -222,7 +222,7 @@ size_t findI(std::string text, StringVect &list)
int base = 94;
int start = 33;
-const std::string encodeStr(unsigned int value, unsigned int size)
+const std::string encodeStr(unsigned int value, const unsigned int size)
{
std::string buf;
@@ -269,7 +269,7 @@ std::string extractNameFromSprite(std::string str)
if (pos2 == std::string::npos)
pos2 = static_cast<size_t>(-1);
- int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
+ const int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
if (size > 0)
str = str.substr(pos2 + 1, size);
}
@@ -292,7 +292,7 @@ std::string removeSpriteIndex(std::string str)
if (pos2 == std::string::npos)
pos2 = static_cast<size_t>(-1);
- int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
+ const int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
if (size > 0)
str = str.substr(pos2 + 1, size);
}
@@ -301,16 +301,16 @@ std::string removeSpriteIndex(std::string str)
const char* getSafeUtf8String(std::string text)
{
- int size = static_cast<int>(text.size()) + UTF8_MAX_SIZE;
- char* buf = new char[size];
+ const int size = static_cast<int>(text.size()) + UTF8_MAX_SIZE;
+ char *const buf = new char[size];
memcpy(buf, text.c_str(), text.size());
memset(buf + text.size(), 0, UTF8_MAX_SIZE);
return buf;
}
-void getSafeUtf8String(std::string text, char *buf)
+void getSafeUtf8String(std::string text, char *const buf)
{
- int size = static_cast<int>(text.size()) + UTF8_MAX_SIZE;
+ const int size = static_cast<int>(text.size()) + UTF8_MAX_SIZE;
if (size > 65500)
text = text.substr(0, 65500);
memcpy(buf, text.c_str(), text.size());
@@ -412,7 +412,7 @@ std::string normalize(const std::string &name)
return toLower(trim(normalized));
}
-std::set<int> splitToIntSet(const std::string &text, char separator)
+std::set<int> splitToIntSet(const std::string &text, const char separator)
{
std::set<int> tokens;
std::stringstream ss(text);
@@ -423,7 +423,7 @@ std::set<int> splitToIntSet(const std::string &text, char separator)
return tokens;
}
-std::list<int> splitToIntList(const std::string &text, char separator)
+std::list<int> splitToIntList(const std::string &text, const char separator)
{
std::list<int> tokens;
std::stringstream ss(text);
@@ -436,7 +436,7 @@ std::list<int> splitToIntList(const std::string &text, char separator)
std::list<std::string> splitToStringList(const std::string &text,
- char separator)
+ const char separator)
{
std::list<std::string> tokens;
std::stringstream ss(text);
@@ -448,7 +448,7 @@ std::list<std::string> splitToStringList(const std::string &text,
}
void splitToStringVector(StringVect &tokens, const std::string &text,
- char separator)
+ const char separator)
{
std::stringstream ss(text);
std::string item;
@@ -461,7 +461,7 @@ void splitToStringVector(StringVect &tokens, const std::string &text,
}
void splitToStringSet(std::set<std::string> &tokens, const std::string &text,
- char separator)
+ const char separator)
{
std::stringstream ss(text);
std::string item;
@@ -540,7 +540,7 @@ std::string stringToHexPath(const std::string &str)
return hex;
}
-void deleteCharLeft(std::string &str, unsigned *pos)
+void deleteCharLeft(std::string &str, unsigned *const pos)
{
if (!pos)
return;
@@ -548,14 +548,14 @@ void deleteCharLeft(std::string &str, unsigned *pos)
while (*pos > 0)
{
(*pos)--;
- int v = str[*pos];
+ const int v = str[*pos];
str.erase(*pos, 1);
if ((v & 192) != 128)
break;
}
}
-bool findLast(std::string &str1, std::string str2)
+bool findLast(const std::string &str1, const std::string &str2)
{
const size_t s1 = str1.size();
const size_t s2 = str2.size();
@@ -567,7 +567,7 @@ bool findLast(std::string &str1, std::string str2)
return false;
}
-bool findFirst(std::string &str1, std::string str2)
+bool findFirst(const std::string &str1, const std::string &str2)
{
const size_t s1 = str1.size();
const size_t s2 = str2.size();
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 2ac31dd2b..1fb3d9d23 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -86,12 +86,12 @@ template<typename T> std::string toString(const T &arg)
* @param address the address to convert to a string
* @return the string representation of the address
*/
-const char *ipToString(int address);
+const char *ipToString(const int address);
/**
* A safe version of sprintf that returns a std::string of the result.
*/
-std::string strprintf(char const *, ...)
+std::string strprintf(char const *const format, ...)
#ifdef __GNUC__
/* This attribute is nice: it even works through gettext invokation. For
example, gcc will complain that strprintf(_("%s"), 42) is ill-formed. */
@@ -134,13 +134,13 @@ int compareStrI(const std::string &a, const std::string &b);
/**
* Tells wether the character is a word separator.
*/
-bool isWordSeparator(char chr);
+bool isWordSeparator(const char chr);
size_t findI(std::string str, std::string subStr);
size_t findI(std::string text, StringVect &list);
-const std::string encodeStr(unsigned int value, unsigned int size = 0);
+const std::string encodeStr(unsigned int value, const unsigned int size = 0);
unsigned int decodeStr(const std::string &str);
@@ -150,7 +150,7 @@ std::string removeSpriteIndex(std::string str);
const char* getSafeUtf8String(std::string text);
-void getSafeUtf8String(std::string text, char *buf);
+void getSafeUtf8String(std::string text, char *const buf);
std::string getFileName(std::string path);
@@ -174,18 +174,18 @@ void replaceSpecialChars(std::string &text);
*/
std::string normalize(const std::string &name);
-std::set<int> splitToIntSet(const std::string &text, char separator);
+std::set<int> splitToIntSet(const std::string &text, const char separator);
-std::list<int> splitToIntList(const std::string &text, char separator);
+std::list<int> splitToIntList(const std::string &text, const char separator);
std::list<std::string> splitToStringList(const std::string &text,
- char separator);
+ const char separator);
void splitToStringVector(StringVect &tokens,
- const std::string &text, char separator);
+ const std::string &text, const char separator);
void splitToStringSet(std::set<std::string> &tokens,
- const std::string &text, char separator);
+ const std::string &text, const char separator);
std::string combineDye(std::string file, std::string dye);
@@ -197,11 +197,11 @@ std::list<std::string> unpackList(const std::string &str);
std::string stringToHexPath(const std::string &str);
-void deleteCharLeft(std::string &str, unsigned *pos);
+void deleteCharLeft(std::string &str, unsigned *const pos);
-bool findLast(std::string &str1, std::string str2);
+bool findLast(const std::string &str1, const std::string &str2);
-bool findFirst(std::string &str1, std::string str2);
+bool findFirst(const std::string &str1, const std::string &str2);
bool findCutLast(std::string &str1, std::string str2);
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
index 5b1e2a2f2..ebd0682ed 100644
--- a/src/utils/translation/podict.cpp
+++ b/src/utils/translation/podict.cpp
@@ -47,7 +47,7 @@ const std::string PoDict::getStr(const std::string &str)
return mPoLines[str];
}
-const char *PoDict::getChar(const char *str)
+const char *PoDict::getChar(const char *const str)
{
if (mPoLines.find(str) == mPoLines.end())
return str;
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
index 4c41aadcc..86a09b0d9 100644
--- a/src/utils/translation/podict.h
+++ b/src/utils/translation/podict.h
@@ -35,7 +35,7 @@ class PoDict
const std::string getStr(const std::string &str);
- const char *getChar(const char *str);
+ const char *getChar(const char *const str);
protected:
friend class PoParser;
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
index b2278c741..57d9b1604 100644
--- a/src/utils/translation/poparser.cpp
+++ b/src/utils/translation/poparser.cpp
@@ -40,7 +40,7 @@ PoParser::PoParser() :
void PoParser::openFile(std::string name)
{
- ResourceManager *resman = ResourceManager::getInstance();
+ const ResourceManager *const resman = ResourceManager::getInstance();
int size;
char *buf = static_cast<char*>(resman->loadFile(getFileName(name), size));
@@ -48,7 +48,8 @@ void PoParser::openFile(std::string name)
free(buf);
}
-PoDict *PoParser::load(std::string lang, std::string fileName, PoDict *dict)
+PoDict *PoParser::load(const std::string &lang, const std::string &fileName,
+ PoDict *const dict)
{
logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
@@ -214,7 +215,7 @@ PoDict *PoParser::getEmptyDict()
bool PoParser::checkLang(std::string lang) const
{
// check is po file exists
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
return resman->exists(getFileName(lang));
}
@@ -225,12 +226,12 @@ std::string PoParser::getFileName(std::string lang) const
return strprintf("translations/%s.po", lang.c_str());
}
-PoDict *PoParser::getDict()
+PoDict *PoParser::getDict() const
{
return new PoDict(mLang);
}
-void PoParser::convertStr(std::string &str)
+void PoParser::convertStr(std::string &str) const
{
if (str.empty())
return;
diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h
index 35a9cd772..254c44a34 100644
--- a/src/utils/translation/poparser.h
+++ b/src/utils/translation/poparser.h
@@ -33,9 +33,9 @@ class PoParser
public:
PoParser();
- PoDict *load(std::string lang,
- std::string fileName = "",
- PoDict *dict = nullptr);
+ PoDict *load(const std::string &lang,
+ const std::string &fileName = "",
+ PoDict *const dict = nullptr);
bool checkLang(std::string lang) const;
@@ -57,9 +57,9 @@ class PoParser
std::string getFileName(std::string lang) const;
- PoDict *getDict();
+ PoDict *getDict() const;
- void convertStr(std::string &str);
+ void convertStr(std::string &str) const;
// current lang
std::string mLang;
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 4c811ab60..110353baf 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -57,8 +57,8 @@ void TranslationManager::close()
}
PoDict *TranslationManager::loadLang(LangVect lang,
- std::string subName,
- PoDict *dict)
+ const std::string &subName,
+ PoDict *const dict)
{
std::string name = "";
PoParser parser;
@@ -84,14 +84,14 @@ PoDict *TranslationManager::loadLang(LangVect lang,
}
bool TranslationManager::translateFile(const std::string &fileName,
- PoDict *dict,
+ PoDict *const dict,
StringVect &lines)
{
if (!dict || fileName.empty())
return false;
int contentsLength;
- ResourceManager *resman = ResourceManager::getInstance();
+ const ResourceManager *const resman = ResourceManager::getInstance();
char *fileContents = static_cast<char*>(
resman->loadFile(fileName, contentsLength));
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
index debb555ea..25f88a4c1 100644
--- a/src/utils/translation/translationmanager.h
+++ b/src/utils/translation/translationmanager.h
@@ -31,8 +31,8 @@ class TranslationManager
{
public:
static PoDict *loadLang(StringVect lang,
- std::string subName,
- PoDict *dict = nullptr);
+ const std::string &subName,
+ PoDict *const dict = nullptr);
static void init();
@@ -41,7 +41,7 @@ class TranslationManager
static void loadCurrentLang();
static bool translateFile(const std::string &fileName,
- PoDict *dict,
+ PoDict *const dict,
StringVect &lines);
};
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 0da516cbf..4d434f46a 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -41,14 +41,15 @@ static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
namespace XML
{
- Document::Document(const std::string &filename, bool useResman):
+ Document::Document(const std::string &filename, const bool useResman) :
mDoc(nullptr)
{
int size;
char *data = nullptr;
if (useResman)
{
- ResourceManager *resman = ResourceManager::getInstance();
+ const ResourceManager *const resman
+ = ResourceManager::getInstance();
data = static_cast<char*>(resman->loadFile(
filename.c_str(), size));
}
@@ -89,7 +90,7 @@ namespace XML
}
}
- Document::Document(const char *data, int size)
+ Document::Document(const char *const data, const int size)
{
if (data)
mDoc = xmlParseMemory(data, size);
@@ -108,11 +109,11 @@ namespace XML
return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
}
- int getProperty(XmlNodePtr node, const char* name, int def)
+ int getProperty(const XmlNodePtr node, const char *const name, int def)
{
int &ret = def;
- xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
ret = atoi(reinterpret_cast<char*>(prop));
@@ -122,12 +123,12 @@ namespace XML
return ret;
}
- int getIntProperty(XmlNodePtr node, const char* name, int def,
- int min, int max)
+ int getIntProperty(const XmlNodePtr node, const char *const name, int def,
+ const int min, const int max)
{
int &ret = def;
- xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
ret = atoi(reinterpret_cast<char*>(prop));
@@ -140,11 +141,12 @@ namespace XML
return ret;
}
- double getFloatProperty(XmlNodePtr node, const char* name, double def)
+ double getFloatProperty(const XmlNodePtr node, const char *const name,
+ double def)
{
double &ret = def;
- xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
ret = atof(reinterpret_cast<char*>(prop));
@@ -154,10 +156,10 @@ namespace XML
return ret;
}
- std::string getProperty(XmlNodePtr node, const char *name,
+ std::string getProperty(const XmlNodePtr node, const char *const name,
const std::string &def)
{
- xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
if (prop)
{
std::string val = reinterpret_cast<char*>(prop);
@@ -168,7 +170,7 @@ namespace XML
return def;
}
- std::string langProperty(XmlNodePtr node, const char *name,
+ std::string langProperty(const XmlNodePtr node, const char *const name,
const std::string &def)
{
std::string str = getProperty(node, name, def);
@@ -178,9 +180,10 @@ namespace XML
return translator->getStr(str);
}
- bool getBoolProperty(XmlNodePtr node, const char* name, bool def)
+ bool getBoolProperty(const XmlNodePtr node, const char *const name,
+ const bool def)
{
- xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ const xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
if (xmlStrEqual(prop, BAD_CAST "true" ))
return true;
@@ -189,7 +192,8 @@ namespace XML
return def;
}
- XmlNodePtr findFirstChildByName(XmlNodePtr parent, const char *name)
+ XmlNodePtr findFirstChildByName(const XmlNodePtr parent,
+ const char *const name)
{
for_each_xml_child_node(child, parent)
{
diff --git a/src/utils/xml.h b/src/utils/xml.h
index c5f217c78..cef1ebae2 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -50,7 +50,7 @@ namespace XML
* Constructor that attempts to load the given file through the
* resource manager. Logs errors.
*/
- Document(const std::string &filename, bool useResman = true);
+ Document(const std::string &filename, const bool useResman = true);
/**
* Constructor that attempts to load an XML document from memory.
@@ -59,7 +59,7 @@ namespace XML
* @param data the string to parse as XML
* @param size the length of the string in bytes
*/
- Document(const char *data, int size);
+ Document(const char *const data, const int size);
/**
* Destructor. Frees the loaded XML file.
@@ -79,40 +79,43 @@ namespace XML
/**
* Gets an floating point property from an XmlNodePtr.
*/
- double getFloatProperty(XmlNodePtr node, const char *name, double def);
+ double getFloatProperty(const XmlNodePtr node, const char *const name,
+ double def);
/**
* Gets an integer property from an XmlNodePtr.
*/
- int getProperty(XmlNodePtr node, const char *name, int def);
+ int getProperty(const XmlNodePtr node, const char *const name, int def);
/**
* Gets an integer property from an XmlNodePtr.
*/
- int getIntProperty(XmlNodePtr node, const char* name, int def,
- int min, int max);
+ int getIntProperty(const XmlNodePtr node, const char *const name, int def,
+ const int min, const int max);
/**
* Gets a string property from an XmlNodePtr.
*/
- std::string getProperty(XmlNodePtr node, const char *name,
+ std::string getProperty(const XmlNodePtr node, const char *const name,
const std::string &def);
/**
* Gets a translated string property from an XmlNodePtr.
*/
- std::string langProperty(XmlNodePtr node, const char *name,
+ std::string langProperty(const XmlNodePtr node, const char *const name,
const std::string &def);
/**
* Gets a boolean property from an XmlNodePtr.
*/
- bool getBoolProperty(XmlNodePtr node, const char *name, bool def);
+ bool getBoolProperty(const XmlNodePtr node, const char *const name,
+ const bool def);
/**
* Finds the first child node with the given name
*/
- XmlNodePtr findFirstChildByName(XmlNodePtr parent, const char *name);
+ XmlNodePtr findFirstChildByName(const XmlNodePtr parent,
+ const char *const name);
void initXML();
diff --git a/src/variabledata.h b/src/variabledata.h
index 71c0e8afb..3bb3b7705 100644
--- a/src/variabledata.h
+++ b/src/variabledata.h
@@ -45,7 +45,8 @@ class VariableData
class IntData : public VariableData
{
public:
- IntData(int value) : mData(value)
+ IntData(const int value) :
+ mData(value)
{ }
int getData() const
@@ -61,7 +62,8 @@ class IntData : public VariableData
class StringData : public VariableData
{
public:
- StringData(const std::string &value) : mData(value)
+ StringData(const std::string &value) :
+ mData(value)
{ }
const std::string &getData() const
@@ -77,7 +79,8 @@ class StringData : public VariableData
class FloatData : public VariableData
{
public:
- FloatData(double value) : mData(value)
+ FloatData(const double value) :
+ mData(value)
{ }
double getData() const
@@ -93,7 +96,8 @@ class FloatData : public VariableData
class BoolData : public VariableData
{
public:
- BoolData(bool value) : mData(value)
+ BoolData(const bool value) :
+ mData(value)
{ }
bool getData() const
diff --git a/src/vector.h b/src/vector.h
index 2caf48418..93957a90d 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -46,7 +46,7 @@ class Vector
/**
* Constructor.
*/
- Vector(float x0, float y0, float z0 = 0.0f):
+ Vector(const float x0, const float y0, const float z0 = 0.0f) :
x(x0),
y(y0),
z(z0)
@@ -73,7 +73,7 @@ class Vector
/**
* Scale vector operator.
*/
- Vector operator*(float c) const
+ Vector operator*(const float c) const
{
return Vector(x * c,
y * c,
@@ -83,7 +83,7 @@ class Vector
/**
* In-place scale vector operator.
*/
- Vector &operator*=(float c)
+ Vector &operator*=(const float c)
{
x *= c;
y *= c;
@@ -94,7 +94,7 @@ class Vector
/**
* Scale vector operator.
*/
- Vector operator/(float c) const
+ Vector operator/(const float c) const
{
return Vector(x / c,
y / c,
@@ -104,7 +104,7 @@ class Vector
/**
* In-place scale vector operator.
*/
- Vector &operator/=(float c)
+ Vector &operator/=(const float c)
{
x /= c;
y /= c;