summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resources/action.cpp6
-rw-r--r--src/resources/action.h6
-rw-r--r--src/resources/ambientlayer.cpp15
-rw-r--r--src/resources/ambientlayer.h9
-rw-r--r--src/resources/animation.cpp17
-rw-r--r--src/resources/animation.h17
-rw-r--r--src/resources/beinginfo.cpp12
-rw-r--r--src/resources/beinginfo.h25
-rw-r--r--src/resources/chardb.cpp7
-rw-r--r--src/resources/chardb.h3
-rw-r--r--src/resources/colordb.cpp18
-rw-r--r--src/resources/colordb.h5
-rw-r--r--src/resources/dye.cpp59
-rw-r--r--src/resources/dye.h14
-rw-r--r--src/resources/emotedb.cpp32
-rw-r--r--src/resources/emotedb.h9
-rw-r--r--src/resources/image.cpp23
-rw-r--r--src/resources/image.h19
-rw-r--r--src/resources/imagehelper.cpp10
-rw-r--r--src/resources/imagehelper.h12
-rw-r--r--src/resources/imageset.cpp6
-rw-r--r--src/resources/imageset.h10
-rw-r--r--src/resources/imagewriter.cpp3
-rw-r--r--src/resources/imagewriter.h2
-rw-r--r--src/resources/itemdb.cpp93
-rw-r--r--src/resources/itemdb.h4
-rw-r--r--src/resources/iteminfo.cpp44
-rw-r--r--src/resources/iteminfo.h56
-rw-r--r--src/resources/mapdb.cpp6
-rw-r--r--src/resources/mapdb.h2
-rw-r--r--src/resources/openglimagehelper.cpp3
-rw-r--r--src/resources/openglimagehelper.h3
32 files changed, 291 insertions, 259 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index 2c1c5d080..5e70f5f4b 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -65,17 +65,17 @@ Animation *Action::getAnimation(int direction) const
return (i == mAnimations.end()) ? nullptr : i->second;
}
-void Action::setAnimation(int direction, Animation *animation)
+void Action::setAnimation(const int direction, Animation *const animation)
{
mAnimations[direction] = animation;
}
-void Action::setLastFrameDelay(int delay)
+void Action::setLastFrameDelay(const int delay)
{
for (AnimationIter it = mAnimations.begin(),
it_end = mAnimations.end(); it != it_end; ++ it)
{
- Animation *animation = (*it).second;
+ Animation *const animation = (*it).second;
if (!animation)
continue;
animation->setLastFrameDelay(delay);
diff --git a/src/resources/action.h b/src/resources/action.h
index 4492902b5..7b6494c99 100644
--- a/src/resources/action.h
+++ b/src/resources/action.h
@@ -38,17 +38,17 @@ class Action
~Action();
- void setAnimation(int direction, Animation *animation);
+ void setAnimation(const int direction, Animation *const animation);
Animation *getAnimation(int direction) const;
unsigned getNumber() const
{ return mNumber; }
- void setNumber(unsigned n)
+ void setNumber(const unsigned n)
{ mNumber = n; }
- void setLastFrameDelay(int delay);
+ void setLastFrameDelay(const int delay);
protected:
typedef std::map<int, Animation*> Animations;
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index e51160efe..9e919297b 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -29,8 +29,9 @@
#include "debug.h"
-AmbientLayer::AmbientLayer(Image *img, float parallax,
- float speedX, float speedY, bool keepRatio):
+AmbientLayer::AmbientLayer(Image *const img, const float parallax,
+ const float speedX, const float speedY,
+ const bool keepRatio) :
mImage(img), mParallax(parallax),
mPosX(0), mPosY(0),
mSpeedX(speedX), mSpeedY(speedY),
@@ -47,7 +48,7 @@ AmbientLayer::AmbientLayer(Image *img, float parallax,
{
// Rescale the overlay to keep the ratio as if we were on
// the default resolution...
- Image *rescaledOverlay = ResourceManager::getInstance()->
+ Image *const rescaledOverlay = ResourceManager::getInstance()->
getRescaled(mImage, static_cast<int>(mImage->mBounds.w)
/ defaultScreenWidth * mainGraphics->mWidth,
static_cast<int>(mImage->mBounds.h)
@@ -73,7 +74,7 @@ AmbientLayer::~AmbientLayer()
}
}
-void AmbientLayer::update(int timePassed, float dx, float dy)
+void AmbientLayer::update(const int timePassed, const float dx, const float dy)
{
if (!mImage)
return;
@@ -86,8 +87,8 @@ void AmbientLayer::update(int timePassed, float dx, float dy)
mPosX += dx * mParallax;
mPosY += dy * mParallax;
- int imgW = mImage->mBounds.w;
- int imgH = mImage->mBounds.h;
+ const int imgW = mImage->mBounds.w;
+ const int imgH = mImage->mBounds.h;
// Wrap values
while (mPosX > imgW)
@@ -101,7 +102,7 @@ void AmbientLayer::update(int timePassed, float dx, float dy)
mPosY += static_cast<float>(imgH);
}
-void AmbientLayer::draw(Graphics *graphics, int x, int y)
+void AmbientLayer::draw(Graphics *const graphics, const int x, const int y) const
{
if (!mImage)
return;
diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h
index 54a764841..e0593ce4f 100644
--- a/src/resources/ambientlayer.h
+++ b/src/resources/ambientlayer.h
@@ -38,14 +38,15 @@ class AmbientLayer
* @param keepRatio rescale the image to keep
* the same ratio than in 800x600 resolution mode.
*/
- AmbientLayer(Image *img, float parallax,
- float speedX, float speedY, bool keepRatio = false);
+ AmbientLayer(Image *const img, const float parallax,
+ const float speedX, const float speedY,
+ const bool keepRatio = false);
~AmbientLayer();
- void update(int timePassed, float dx, float dy);
+ void update(const int timePassed, const float dx, const float dy);
- void draw(Graphics *graphics, int x, int y);
+ void draw(Graphics *const graphics, const int x, const int y) const;
private:
Image *mImage;
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 63e73df55..7c69e1372 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -33,8 +33,9 @@ Animation::Animation():
{
}
-void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY,
- int rand)
+void Animation::addFrame(Image *const image, const int delay,
+ const int offsetX, const int offsetY,
+ const int rand)
{
Frame frame
= { image, delay, offsetX, offsetY, rand, Frame::ANIMATION, "" };
@@ -42,7 +43,7 @@ void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY,
mDuration += delay;
}
-void Animation::addTerminator(int rand)
+void Animation::addTerminator(const int rand)
{
addFrame(nullptr, 0, 0, 0, rand);
}
@@ -52,31 +53,31 @@ bool Animation::isTerminator(const Frame &candidate)
return (!candidate.image && candidate.type == Frame::ANIMATION);
}
-void Animation::addJump(std::string name, int rand)
+void Animation::addJump(const std::string &name, const int rand)
{
Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name };
mFrames.push_back(frame);
}
-void Animation::addLabel(std::string name)
+void Animation::addLabel(const std::string &name)
{
Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name };
mFrames.push_back(frame);
}
-void Animation::addGoto(std::string name, int rand)
+void Animation::addGoto(const std::string &name, const int rand)
{
Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name };
mFrames.push_back(frame);
}
-void Animation::addPause(int delay, int rand)
+void Animation::addPause(const int delay, const int rand)
{
Frame frame = { nullptr, delay, 0, 0, rand, Frame::PAUSE, "" };
mFrames.push_back(frame);
}
-void Animation::setLastFrameDelay(int delay)
+void Animation::setLastFrameDelay(const int delay)
{
for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend();
it != it_end; ++ it)
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 3b9b5f2ea..ab2d83c4c 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -66,14 +66,15 @@ class Animation
/**
* Appends a new animation at the end of the sequence.
*/
- void addFrame(Image *image, int delay, int offsetX, int offsetY,
- int rand);
+ void addFrame(Image *const image, const int delay,
+ const int offsetX, const int offsetY,
+ const int rand);
/**
* Appends an animation terminator that states that the animation
* should not loop.
*/
- void addTerminator(int rand);
+ void addTerminator(const int rand);
/**
* Returns the length of this animation in frames.
@@ -81,15 +82,15 @@ class Animation
size_t getLength() const
{ return mFrames.size(); }
- void addJump(std::string name, int rand);
+ void addJump(const std::string &name, const int rand);
- void addLabel(std::string name);
+ void addLabel(const std::string &name);
- void addGoto(std::string name, int rand);
+ void addGoto(const std::string &name, const int rand);
- void addPause(int delay, int rand);
+ void addPause(const int delay, const int rand);
- void setLastFrameDelay(int delay);
+ void setLastFrameDelay(const int delay);
/**
* Determines whether the given animation frame is a terminator.
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 1f2bd3e9a..1559f594c 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -86,7 +86,7 @@ void BeingInfo::setTargetCursorSize(const std::string &size)
}
}
-void BeingInfo::addSound(SoundEvent event, const std::string &filename)
+void BeingInfo::addSound(const SoundEvent event, const std::string &filename)
{
if (mSounds.find(event) == mSounds.end())
mSounds[event] = new StringVect;
@@ -95,23 +95,23 @@ void BeingInfo::addSound(SoundEvent event, const std::string &filename)
mSounds[event]->push_back("sfx/" + filename);
}
-const std::string &BeingInfo::getSound(SoundEvent event) const
+const std::string &BeingInfo::getSound(const SoundEvent event) const
{
static std::string emptySound("");
- SoundEvents::const_iterator i = mSounds.find(event);
+ const SoundEvents::const_iterator i = mSounds.find(event);
return (i == mSounds.end() || !i->second) ? emptySound :
i->second->at(rand() % i->second->size());
}
-const Attack *BeingInfo::getAttack(int type) const
+const Attack *BeingInfo::getAttack(const int type) const
{
- Attacks::const_iterator i = mAttacks.find(type);
+ const Attacks::const_iterator i = mAttacks.find(type);
return (i == mAttacks.end()) ? empty : (*i).second;
}
-void BeingInfo::addAttack(int id, std::string action,
+void BeingInfo::addAttack(const int id, std::string action,
const std::string &particleEffect,
const std::string &missileParticle)
{
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 5dde6b84e..130cb26ea 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -89,23 +89,24 @@ class BeingInfo
void setTargetCursorSize(const std::string &size);
- void setTargetCursorSize(ActorSprite::TargetCursorSize targetSize)
+ void setTargetCursorSize(const ActorSprite::TargetCursorSize
+ targetSize)
{ mTargetCursorSize = targetSize; }
ActorSprite::TargetCursorSize getTargetCursorSize() const
{ return mTargetCursorSize; }
- void addSound(SoundEvent event, const std::string &filename);
+ void addSound(const SoundEvent event, const std::string &filename);
- const std::string &getSound(SoundEvent event) const;
+ const std::string &getSound(const SoundEvent event) const;
- void addAttack(int id, std::string action,
+ void addAttack(const int id, std::string action,
const std::string &particleEffect,
const std::string &missileParticle);
- const Attack *getAttack(int type) const;
+ const Attack *getAttack(const int type) const;
- void setWalkMask(unsigned char mask)
+ void setWalkMask(const unsigned char mask)
{ mWalkMask = mask; }
/**
@@ -114,25 +115,25 @@ class BeingInfo
unsigned char getWalkMask() const
{ return mWalkMask; }
- void setBlockType(Map::BlockType blockType)
+ void setBlockType(const Map::BlockType blockType)
{ mBlockType = blockType; }
Map::BlockType getBlockType() const
{ return mBlockType; }
- void setTargetOffsetX(int n)
+ void setTargetOffsetX(const int n)
{ mTargetOffsetX = n; }
int getTargetOffsetX() const
{ return mTargetOffsetX; }
- void setTargetOffsetY(int n)
+ void setTargetOffsetY(const int n)
{ mTargetOffsetY = n; }
int getTargetOffsetY() const
{ return mTargetOffsetY; }
- void setMaxHP(int n)
+ void setMaxHP(const int n)
{ mMaxHP = n; }
int getMaxHP() const
@@ -141,10 +142,10 @@ class BeingInfo
bool isStaticMaxHP() const
{ return mStaticMaxHP; }
- void setStaticMaxHP(bool n)
+ void setStaticMaxHP(const bool n)
{ mStaticMaxHP = n; }
- void setTargetSelection(bool n)
+ void setTargetSelection(const bool n)
{ mTargetSelection = n; }
bool isTargetSelection() const
diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp
index 6ee5f964f..23a1066ce 100644
--- a/src/resources/chardb.cpp
+++ b/src/resources/chardb.cpp
@@ -45,7 +45,7 @@ void CharDB::load()
unload();
XML::Document *doc = new XML::Document("charcreation.xml");
- XmlNodePtr root = doc->rootNode();
+ const XmlNodePtr root = doc->rootNode();
if (!root || !xmlNameEqual(root, "chars"))
{
@@ -72,7 +72,7 @@ void CharDB::load()
}
else if (xmlNameEqual(node, "item"))
{
- int id = XML::getProperty(node, "id", 0);
+ const int id = XML::getProperty(node, "id", 0);
if (id > 0)
mDefaultItems.push_back(id);
}
@@ -83,7 +83,8 @@ void CharDB::load()
mLoaded = true;
}
-void CharDB::loadMinMax(XmlNodePtr node, unsigned *min, unsigned *max)
+void CharDB::loadMinMax(const XmlNodePtr node,
+ unsigned *const min, unsigned *const max)
{
*min = XML::getProperty(node, "min", 1);
*max = XML::getProperty(node, "max", 10);
diff --git a/src/resources/chardb.h b/src/resources/chardb.h
index d0628fbdf..5d133da00 100644
--- a/src/resources/chardb.h
+++ b/src/resources/chardb.h
@@ -44,7 +44,8 @@ namespace CharDB
*/
void unload();
- void loadMinMax(XmlNodePtr node, unsigned *min, unsigned *max);
+ void loadMinMax(const XmlNodePtr node,
+ unsigned *const min, unsigned *const max);
unsigned getMinHairColor();
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 7f7e0f0db..f105061d2 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -45,7 +45,7 @@ void ColorDB::load()
if (serverVersion >= 1)
loadColorLists();
- ColorListsIterator it = mColorLists.find("hair");
+ const ColorListsIterator it = mColorLists.find("hair");
if (it != mColorLists.end())
mHairColorsSize = static_cast<int>((*it).second.size());
else
@@ -55,7 +55,7 @@ void ColorDB::load()
void ColorDB::loadHair()
{
std::map <int, ItemColor> colors;
- ColorListsIterator it = mColorLists.find("hair");
+ const ColorListsIterator it = mColorLists.find("hair");
if (it != mColorLists.end())
colors = it->second;
@@ -90,7 +90,7 @@ void ColorDB::loadHair()
{
if (xmlNameEqual(node, "color"))
{
- int id = XML::getProperty(node, "id", 0);
+ const int id = XML::getProperty(node, "id", 0);
if (colors.find(id) != colors.end())
logger->log("ColorDB: Redefinition of dye ID %d", id);
@@ -109,7 +109,7 @@ void ColorDB::loadHair()
void ColorDB::loadColorLists()
{
XML::Document *doc = new XML::Document("itemcolors.xml");
- XmlNodePtr root = doc->rootNode();
+ const XmlNodePtr root = doc->rootNode();
if (!root)
{
delete doc;
@@ -125,7 +125,7 @@ void ColorDB::loadColorLists()
continue;
std::map <int, ItemColor> colors;
- ColorListsIterator it = mColorLists.find(name);
+ const ColorListsIterator it = mColorLists.find(name);
if (it != mColorLists.end())
colors = it->second;
@@ -155,19 +155,19 @@ void ColorDB::unload()
mLoaded = false;
}
-std::string &ColorDB::getHairColorName(int id)
+std::string &ColorDB::getHairColorName(const int id)
{
if (!mLoaded)
load();
- ColorListsIterator it = mColorLists.find("hair");
+ const ColorListsIterator it = mColorLists.find("hair");
if (it == mColorLists.end())
{
logger->log1("ColorDB: Error, hair colors list empty");
return mFail;
}
- ColorIterator i = (*it).second.find(id);
+ const ColorIterator i = (*it).second.find(id);
if (i == (*it).second.end())
{
@@ -187,7 +187,7 @@ int ColorDB::getHairSize()
std::map <int, ColorDB::ItemColor> *ColorDB::getColorsList(std::string name)
{
- ColorListsIterator it = mColorLists.find(name);
+ const ColorListsIterator it = mColorLists.find(name);
if (it != mColorLists.end())
return &it->second;
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index 27ca6173a..fd479d00a 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -39,7 +39,8 @@ namespace ColorDB
color("")
{ }
- ItemColor(int id0, std::string name0, std::string color0)
+ ItemColor(const int id0, const std::string &name0,
+ const std::string &color0)
{
this->id = id0;
this->name = name0;
@@ -68,7 +69,7 @@ namespace ColorDB
*/
void unload();
- std::string &getHairColorName(int id);
+ std::string &getHairColorName(const int id);
int getHairSize();
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index cfa796fec..4cedafd4e 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -29,7 +29,7 @@
#include "debug.h"
-DyePalette::DyePalette(const std::string &description, int8_t blockSize)
+DyePalette::DyePalette(const std::string &description, const int8_t blockSize)
{
const int size = static_cast<int>(description.length());
if (size == 0)
@@ -72,7 +72,7 @@ DyePalette::DyePalette(const std::string &description, int8_t blockSize)
logger->log("Error, invalid embedded palette: %s", description.c_str());
}
-int DyePalette::hexDecode(char c)
+int DyePalette::hexDecode(const char c)
{
if ('0' <= c && c <= '9')
return c - '0';
@@ -84,7 +84,7 @@ int DyePalette::hexDecode(char c)
return 0;
}
-void DyePalette::getColor(int intensity, int color[3]) const
+void DyePalette::getColor(const int intensity, int color[3]) const
{
if (intensity == 0)
{
@@ -98,8 +98,8 @@ void DyePalette::getColor(int intensity, int color[3]) const
if (last == 0)
return;
- int i = intensity * last / 255;
- int t = intensity * last % 255;
+ const int i = intensity * last / 255;
+ const int t = intensity * last % 255;
int j = t != 0 ? i : i - 1;
@@ -107,9 +107,9 @@ void DyePalette::getColor(int intensity, int color[3]) const
j = 0;
// Get the exact color if any, the next color otherwise.
- int r2 = mColors[j].value[0],
- g2 = mColors[j].value[1],
- b2 = mColors[j].value[2];
+ const int r2 = mColors[j].value[0];
+ const int g2 = mColors[j].value[1];
+ const int b2 = mColors[j].value[2];
if (t == 0)
{
@@ -151,8 +151,8 @@ void DyePalette::getColor(double intensity, int color[3]) const
intensity = intensity * static_cast<double>(mColors.size() - 1);
// Color indices
- int i = static_cast<int>(floor(intensity));
- int j = static_cast<int>(ceil(intensity));
+ const int i = static_cast<int>(floor(intensity));
+ const int j = static_cast<int>(ceil(intensity));
if (i == j)
{
@@ -164,15 +164,15 @@ void DyePalette::getColor(double intensity, int color[3]) const
}
intensity -= i;
- double rest = 1 - intensity;
+ const double rest = 1 - intensity;
// Get the colors
- int r1 = mColors[i].value[0],
- g1 = mColors[i].value[1],
- b1 = mColors[i].value[2],
- r2 = mColors[j].value[0],
- g2 = mColors[j].value[1],
- b2 = mColors[j].value[2];
+ const int r1 = mColors[i].value[0];
+ const int g1 = mColors[i].value[1];
+ const int b1 = mColors[i].value[2];
+ const int r2 = mColors[j].value[0];
+ const int g2 = mColors[j].value[1];
+ const int b2 = mColors[j].value[2];
// Perform the interpolation.
color[0] = static_cast<int>(rest * r1 + intensity * r2);
@@ -180,10 +180,10 @@ void DyePalette::getColor(double intensity, int color[3]) const
color[2] = static_cast<int>(rest * b1 + intensity * b2);
}
-void DyePalette::replaceSColor(uint8_t *color) const
+void DyePalette::replaceSColor(uint8_t *const color) const
{
std::vector<Color>::const_iterator it = mColors.begin();
- std::vector<Color>::const_iterator it_end = mColors.end();
+ const std::vector<Color>::const_iterator it_end = mColors.end();
while (it != it_end)
{
const Color &col = *it;
@@ -203,10 +203,10 @@ void DyePalette::replaceSColor(uint8_t *color) const
}
}
-void DyePalette::replaceAColor(uint8_t *color) const
+void DyePalette::replaceAColor(uint8_t *const color) const
{
std::vector<Color>::const_iterator it = mColors.begin();
- std::vector<Color>::const_iterator it_end = mColors.end();
+ const std::vector<Color>::const_iterator it_end = mColors.end();
while (it != it_end)
{
const Color &col = *it;
@@ -227,10 +227,10 @@ void DyePalette::replaceAColor(uint8_t *color) const
}
}
-void DyePalette::replaceSOGLColor(uint8_t *color) const
+void DyePalette::replaceSOGLColor(uint8_t *const color) const
{
std::vector<Color>::const_iterator it = mColors.begin();
- std::vector<Color>::const_iterator it_end = mColors.end();
+ const std::vector<Color>::const_iterator it_end = mColors.end();
while (it != it_end)
{
const Color &col = *it;
@@ -250,10 +250,10 @@ void DyePalette::replaceSOGLColor(uint8_t *color) const
}
}
-void DyePalette::replaceAOGLColor(uint8_t *color) const
+void DyePalette::replaceAOGLColor(uint8_t *const color) const
{
std::vector<Color>::const_iterator it = mColors.begin();
- std::vector<Color>::const_iterator it_end = mColors.end();
+ const std::vector<Color>::const_iterator it_end = mColors.end();
while (it != it_end)
{
const Color &col = *it;
@@ -332,12 +332,12 @@ Dye::~Dye()
void Dye::update(int color[3]) const
{
- int cmax = std::max(color[0], std::max(color[1], color[2]));
+ const int cmax = std::max(color[0], std::max(color[1], color[2]));
if (cmax == 0)
return;
- int cmin = std::min(color[0], std::min(color[1], color[2]));
- int intensity = color[0] + color[1] + color[2];
+ const int cmin = std::min(color[0], std::min(color[1], color[2]));
+ const int intensity = color[0] + color[1] + color[2];
if (cmin != cmax && (cmin != 0 || (intensity != cmax
&& intensity != 2 * cmax)))
@@ -346,7 +346,8 @@ void Dye::update(int color[3]) const
return;
}
- int i = (color[0] != 0) | ((color[1] != 0) << 1) | ((color[2] != 0) << 2);
+ const int i = (color[0] != 0) | ((color[1] != 0) << 1)
+ | ((color[2] != 0) << 2);
if (mDyePalettes[i - 1])
mDyePalettes[i - 1]->getColor(cmax, color);
diff --git a/src/resources/dye.h b/src/resources/dye.h
index 7e5ba6c99..cd5e58093 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -44,13 +44,13 @@ class DyePalette
* The string is either a file name or a sequence of hexadecimal RGB
* values separated by ',' and starting with '#'.
*/
- DyePalette(const std::string &pallete, int8_t blockSize);
+ DyePalette(const std::string &pallete, const int8_t blockSize);
/**
* Gets a pixel color depending on its intensity. First color is
* implicitly black (0, 0, 0).
*/
- void getColor(int intensity, int color[3]) const;
+ void getColor(const int intensity, int color[3]) const;
/**
* Gets a pixel color depending on its intensity.
@@ -60,24 +60,24 @@ class DyePalette
/**
* replace colors for SDL for S dye.
*/
- void replaceSColor(uint8_t *color) const;
+ void replaceSColor(uint8_t *const color) const;
/**
* replace colors for SDL for S dye.
*/
- void replaceAColor(uint8_t *color) const;
+ void replaceAColor(uint8_t *const color) const;
/**
* replace colors for OpenGL for S dye.
*/
- void replaceSOGLColor(uint8_t *color) const;
+ void replaceSOGLColor(uint8_t *const color) const;
/**
* replace colors for OpenGL for A dye.
*/
- void replaceAOGLColor(uint8_t *color) const;
+ void replaceAOGLColor(uint8_t *const color) const;
- int hexDecode(char c);
+ static int hexDecode(const char c);
private:
struct Color
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index 4f3da8fa9..14e3a96b5 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -45,7 +45,7 @@ void EmoteDB::load()
mLastEmote = 0;
- EmoteSprite *unknownSprite = new EmoteSprite;
+ EmoteSprite *const unknownSprite = new EmoteSprite;
unknownSprite->sprite = AnimatedSprite::load(
paths.getStringValue("spriteErrorFile"));
unknownSprite->name = "unknown";
@@ -68,7 +68,7 @@ void EmoteDB::load()
if (!xmlNameEqual(emoteNode, "emote"))
continue;
- int id = XML::getProperty(emoteNode, "id", -1);
+ const int id = XML::getProperty(emoteNode, "id", -1);
// skip hight images
if (id > 19 || (Client::isTmw() && id > 13))
continue;
@@ -80,7 +80,7 @@ void EmoteDB::load()
continue;
}
- EmoteInfo *currentInfo = new EmoteInfo;
+ EmoteInfo *const currentInfo = new EmoteInfo;
for_each_xml_child_node(spriteNode, emoteNode)
{
@@ -89,7 +89,7 @@ void EmoteDB::load()
if (xmlNameEqual(spriteNode, "sprite"))
{
- EmoteSprite *currentSprite = new EmoteSprite;
+ EmoteSprite *const currentSprite = new EmoteSprite;
std::string file = paths.getStringValue("sprites")
+ (std::string) reinterpret_cast<const char*>(
spriteNode->xmlChildrenNode->content);
@@ -127,16 +127,16 @@ void EmoteDB::load()
if (!xmlNameEqual(emoteNode, "emote"))
continue;
- int id = XML::getProperty(emoteNode, "id", -1);
+ const int id = XML::getProperty(emoteNode, "id", -1);
if (id == -1)
{
logger->log1("Emote Database: Emote with missing ID in "
"manaplus_emotes.xml!");
continue;
}
- int altId = XML::getProperty(emoteNode, "altid", -1);
+ const int altId = XML::getProperty(emoteNode, "altid", -1);
- EmoteInfo *currentInfo = new EmoteInfo;
+ EmoteInfo *const currentInfo = new EmoteInfo;
for_each_xml_child_node(spriteNode, emoteNode)
{
@@ -145,7 +145,7 @@ void EmoteDB::load()
if (xmlNameEqual(spriteNode, "sprite"))
{
- EmoteSprite *currentSprite = new EmoteSprite;
+ EmoteSprite *const currentSprite = new EmoteSprite;
std::string file = paths.getStringValue("sprites")
+ (std::string) reinterpret_cast<const char*>(
spriteNode->xmlChildrenNode->content);
@@ -204,9 +204,9 @@ void EmoteDB::unload()
mLoaded = false;
}
-const EmoteInfo *EmoteDB::get(int id, bool allowNull)
+const EmoteInfo *EmoteDB::get(const int id, const bool allowNull)
{
- EmoteInfos::const_iterator i = mEmoteInfos.find(id);
+ const EmoteInfos::const_iterator i = mEmoteInfos.find(id);
if (i == mEmoteInfos.end())
{
@@ -221,26 +221,26 @@ const EmoteInfo *EmoteDB::get(int id, bool allowNull)
}
}
-const AnimatedSprite *EmoteDB::getAnimation(int id, bool allowNull)
+const AnimatedSprite *EmoteDB::getAnimation(const int id, const bool allowNull)
{
- const EmoteInfo *info = get(id, allowNull);
+ const EmoteInfo *const info = get(id, allowNull);
if (!info)
return nullptr;
return info->sprites.front()->sprite;
}
-const AnimatedSprite *EmoteDB::getAnimation2(int id, bool allowNull)
+const AnimatedSprite *EmoteDB::getAnimation2(int id, const bool allowNull)
{
- EmoteToEmote::const_iterator it = mEmotesAlt.find(id);
+ const EmoteToEmote::const_iterator it = mEmotesAlt.find(id);
if (it != mEmotesAlt.end())
id = (*it).second;
return getAnimation(id, allowNull);
}
-const EmoteSprite *EmoteDB::getSprite(int id, bool allowNull)
+const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
{
- const EmoteInfo *info = get(id, allowNull);
+ const EmoteInfo *const info = get(id, allowNull);
if (!info)
return nullptr;
diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h
index 847f3f0ee..50742d7b5 100644
--- a/src/resources/emotedb.h
+++ b/src/resources/emotedb.h
@@ -53,13 +53,14 @@ namespace EmoteDB
void unload();
- const EmoteInfo *get(int id, bool allowNull = false);
+ const EmoteInfo *get(const int id, const bool allowNull = false);
- const AnimatedSprite *getAnimation(int id, bool allowNull = false);
+ const AnimatedSprite *getAnimation(const int id,
+ const bool allowNull = false);
- const AnimatedSprite *getAnimation2(int id, bool allowNull = false);
+ const AnimatedSprite *getAnimation2(int id, const bool allowNull = false);
- const EmoteSprite *getSprite(int id, bool allowNull = false);
+ const EmoteSprite *getSprite(const int id, const bool allowNull = false);
const int &getLast();
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 3b91b3f31..33b97b633 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -43,7 +43,8 @@
#include "debug.h"
-Image::Image(SDL_Surface *image, bool hasAlphaChannel0, uint8_t *alphaChannel):
+Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
+ uint8_t *const alphaChannel) :
mAlpha(1.0f),
mHasAlphaChannel(hasAlphaChannel0),
mSDLSurface(image),
@@ -79,8 +80,8 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel0, uint8_t *alphaChannel):
}
#ifdef USE_OPENGL
-Image::Image(GLuint glimage, int width, int height,
- int texWidth, int texHeight):
+Image::Image(const GLuint glimage, const int width, const int height,
+ const int texWidth, const int texHeight) :
mAlpha(1.0f),
mHasAlphaChannel(true),
mSDLSurface(nullptr),
@@ -117,7 +118,7 @@ Image::~Image()
void Image::SDLCleanCache()
{
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
for (std::map<float, SDL_Surface*>::iterator
i = mAlphaCache.begin(), i_end = mAlphaCache.end();
@@ -158,7 +159,7 @@ void Image::unload()
#endif
}
-bool Image::hasAlphaChannel()
+bool Image::hasAlphaChannel() const
{
if (mLoaded)
return mHasAlphaChannel;
@@ -171,9 +172,10 @@ bool Image::hasAlphaChannel()
return false;
}
-SDL_Surface *Image::getByAlpha(float alpha)
+SDL_Surface *Image::getByAlpha(const float alpha)
{
- std::map<float, SDL_Surface*>::const_iterator it = mAlphaCache.find(alpha);
+ const std::map<float, SDL_Surface*>::const_iterator
+ it = mAlphaCache.find(alpha);
if (it != mAlphaCache.end())
return (*it).second;
return nullptr;
@@ -262,10 +264,10 @@ void Image::setAlpha(float alpha)
for (int i = i1; i <= i2; i++)
{
// Only change the pixel if it was visible at load time...
- uint8_t sourceAlpha = mAlphaChannel[i];
+ const uint8_t sourceAlpha = mAlphaChannel[i];
if (sourceAlpha > 0)
{
- uint8_t a = static_cast<uint8_t>(
+ const uint8_t a = static_cast<uint8_t>(
static_cast<float>(sourceAlpha) * mAlpha);
uint32_t c = (static_cast<uint32_t*>(
@@ -317,7 +319,8 @@ Image* Image::SDLgetScaledImage(const int width, const int height) const
return scaledImage;
}
-Image *Image::getSubImage(int x, int y, int width, int height)
+Image *Image::getSubImage(const int x, const int y,
+ const int width, const int height)
{
// Create a new clipped sub-image
#ifdef USE_OPENGL
diff --git a/src/resources/image.h b/src/resources/image.h
index 4798c87af..2ba7890ab 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -96,7 +96,7 @@ class Image : public Resource
* Tells if the image has got an alpha channel
* @return true if it's true, false otherwise.
*/
- bool hasAlphaChannel();
+ bool hasAlphaChannel() const;
/**
* Sets the alpha value of this image.
@@ -115,7 +115,8 @@ class Image : public Resource
* @return <code>NULL</code> if creation failed and a valid
* object otherwise.
*/
- virtual Image *getSubImage(int x, int y, int width, int height);
+ virtual Image *getSubImage(const int x, const int y,
+ const int width, const int height);
// SDL only public functions
@@ -156,13 +157,13 @@ class Image : public Resource
bool isAlphaVisible() const
{ return mIsAlphaVisible; }
- void setAlphaVisible(bool b)
+ void setAlphaVisible(const bool b)
{ mIsAlphaVisible = b; }
bool isAlphaCalculated() const
{ return mIsAlphaCalculated; }
- void setAlphaCalculated(bool b)
+ void setAlphaCalculated(const bool b)
{ mIsAlphaCalculated = b; }
SDL_Rect mBounds;
@@ -182,10 +183,10 @@ class Image : public Resource
// -----------------------
/** SDL Constructor */
- Image(SDL_Surface *image, bool hasAlphaChannel = false,
- uint8_t *alphaChannel = nullptr);
+ Image(SDL_Surface *const image, const bool hasAlphaChannel = false,
+ uint8_t *const alphaChannel = nullptr);
- SDL_Surface *getByAlpha(float alpha);
+ SDL_Surface *getByAlpha(const float alpha);
SDL_Surface *mSDLSurface;
@@ -205,8 +206,8 @@ class Image : public Resource
/**
* OpenGL Constructor.
*/
- Image(GLuint glimage, int width, int height,
- int texWidth, int texHeight);
+ Image(const GLuint glimage, const int width, const int height,
+ const int texWidth, const int texHeight);
GLuint mGLImage;
int mTexWidth, mTexHeight;
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index 49442ec53..7ddf3221a 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -40,9 +40,9 @@ ImageHelper *imageHelper = nullptr;
bool ImageHelper::mEnableAlpha = true;
-Resource *ImageHelper::load(SDL_RWops *rw)
+Resource *ImageHelper::load(SDL_RWops *const rw)
{
- SDL_Surface *tmpImage = IMG_Load_RW(rw, 1);
+ SDL_Surface *const tmpImage = IMG_Load_RW(rw, 1);
if (!tmpImage)
{
@@ -50,13 +50,13 @@ Resource *ImageHelper::load(SDL_RWops *rw)
return nullptr;
}
- Image *image = load(tmpImage);
+ Image *const image = load(tmpImage);
SDL_FreeSurface(tmpImage);
return image;
}
-SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface* tmpImage)
+SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage)
{
if (!tmpImage)
return nullptr;
@@ -96,7 +96,7 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface* tmpImage)
return SDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE);
}
-void ImageHelper::dumpSurfaceFormat(SDL_Surface *image)
+void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image) const
{
if (image->format)
{
diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h
index 7e2bee20d..27132b7d9 100644
--- a/src/resources/imagehelper.h
+++ b/src/resources/imagehelper.h
@@ -54,7 +54,7 @@ class ImageHelper
* @return <code>NULL</code> if an error occurred, a valid pointer
* otherwise.
*/
- Resource *load(SDL_RWops *rw);
+ Resource *load(SDL_RWops *const rw);
#ifdef __GNUC__
virtual Resource *load(SDL_RWops *rw, Dye const &dye) = 0;
@@ -72,19 +72,19 @@ class ImageHelper
virtual Image *load(SDL_Surface *)
{ return nullptr; }
- virtual Image *createTextSurface(SDL_Surface *tmpImage,
- float alpha)
+ virtual Image *createTextSurface(SDL_Surface *const tmpImage,
+ const float alpha)
{ return nullptr; }
virtual int useOpenGL()
{ return 0; }
#endif
- SDL_Surface *convertTo32Bit(SDL_Surface* tmpImage);
+ static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage);
- void dumpSurfaceFormat(SDL_Surface *image);
+ void dumpSurfaceFormat(const SDL_Surface *const image) const;
- static void setEnableAlpha(bool n)
+ static void setEnableAlpha(const bool n)
{ mEnableAlpha = n; }
protected:
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 4b63d0883..538b27c84 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -30,8 +30,8 @@
#include "debug.h"
-ImageSet::ImageSet(Image *img, int width, int height,
- int margin, int spacing) :
+ImageSet::ImageSet(Image *const img, const int width, const int height,
+ const int margin, const int spacing) :
mWidth(width),
mHeight(height),
mOffsetX(0),
@@ -56,7 +56,7 @@ ImageSet::~ImageSet()
delete_all(mImages);
}
-Image* ImageSet::get(size_type i) const
+Image* ImageSet::get(const size_type i) const
{
if (i >= mImages.size())
{
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index aef4bf694..4ff138d7f 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -38,7 +38,8 @@ class ImageSet : public Resource
/**
* Cuts the passed image in a grid of sub images.
*/
- ImageSet(Image *img, int w, int h, int margin = 0, int spacing = 0);
+ ImageSet(Image *const img, const int w, const int h,
+ const int margin = 0, const int spacing = 0);
/**
* Destructor.
@@ -58,7 +59,8 @@ class ImageSet : public Resource
{ return mHeight; }
typedef std::vector<Image*>::size_type size_type;
- Image* get(size_type i) const;
+
+ Image* get(const size_type i) const;
size_type size() const
{ return mImages.size(); }
@@ -66,13 +68,13 @@ class ImageSet : public Resource
int getOffsetX() const
{ return mOffsetX; }
- void setOffsetX(int n)
+ void setOffsetX(const int n)
{ mOffsetX = n; }
int getOffsetY() const
{ return mOffsetY; }
- void setOffsetY(int n)
+ void setOffsetY(const int n)
{ mOffsetY = n; }
private:
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index f452a9050..2b8b8a7d9 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -35,7 +35,8 @@
#include "debug.h"
-bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
+bool ImageWriter::writePNG(SDL_Surface *const surface,
+ const std::string &filename)
{
if (!surface)
return false;
diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h
index ca8150694..20705d26f 100644
--- a/src/resources/imagewriter.h
+++ b/src/resources/imagewriter.h
@@ -27,6 +27,6 @@ struct SDL_Surface;
class ImageWriter
{
public:
- static bool writePNG(SDL_Surface *surface,
+ static bool writePNG(SDL_Surface *const surface,
const std::string &filename);
};
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 03894d8bc..5905ef578 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -45,12 +45,14 @@ namespace
}
// Forward declarations
-static void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node);
-static void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node);
-static void loadFloorSprite(SpriteDisplay *display, XmlNodePtr node);
-static void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode);
-static void loadOrderSprite(ItemInfo *itemInfo, XmlNodePtr node,
- bool drawAfter);
+static void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node);
+static void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node);
+static void loadFloorSprite(SpriteDisplay *const display,
+ const XmlNodePtr node);
+static void loadReplaceSprite(ItemInfo *const itemInfo,
+ const XmlNodePtr replaceNode);
+static void loadOrderSprite(ItemInfo *const itemInfo, const XmlNodePtr node,
+ const bool drawAfter);
static int parseSpriteName(std::string name);
static int parseDirectionName(std::string name);
@@ -171,7 +173,7 @@ void ItemDB::load()
mUnknown->addTag(mTags["All"]);
XML::Document doc("items.xml");
- XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "items"))
{
@@ -185,7 +187,7 @@ void ItemDB::load()
if (!xmlNameEqual(node, "item"))
continue;
- int id = XML::getProperty(node, "id", 0);
+ const int id = XML::getProperty(node, "id", 0);
if (id == 0)
{
@@ -198,8 +200,8 @@ void ItemDB::load()
}
std::string typeStr = XML::getProperty(node, "type", "other");
- int weight = XML::getProperty(node, "weight", 0);
- int view = XML::getProperty(node, "view", 0);
+ const int weight = XML::getProperty(node, "weight", 0);
+ const int view = XML::getProperty(node, "view", 0);
std::string name = XML::langProperty(node, "name", "");
std::string image = XML::getProperty(node, "image", "");
@@ -208,7 +210,7 @@ void ItemDB::load()
std::string attackAction = XML::getProperty(node, "attack-action", "");
std::string drawBefore = XML::getProperty(node, "drawBefore", "");
std::string drawAfter = XML::getProperty(node, "drawAfter", "");
- int maxFloorOffset = XML::getIntProperty(
+ const int maxFloorOffset = XML::getIntProperty(
node, "maxFloorOffset", 32, 0, 32);
std::string colors;
if (serverVersion >= 1)
@@ -233,14 +235,14 @@ void ItemDB::load()
tags[1] = XML::getProperty(node, "tag2", "");
tags[2] = XML::getProperty(node, "tag3", "");
- int drawPriority = XML::getProperty(node, "drawPriority", 0);
+ const int drawPriority = XML::getProperty(node, "drawPriority", 0);
- int attackRange = XML::getProperty(node, "attack-range", 0);
+ const int attackRange = XML::getProperty(node, "attack-range", 0);
std::string missileParticle = XML::getProperty(
node, "missile-particle", "");
- int hitEffectId = XML::getProperty(node, "hit-effect-id",
+ const int hitEffectId = XML::getProperty(node, "hit-effect-id",
paths.getIntValue("hitEffectId"));
- int criticalEffectId = XML::getProperty(node, "critical-hit-effect-id",
+ const int criticalEffectId = XML::getProperty(node, "critical-hit-effect-id",
paths.getIntValue("criticalHitEffectId"));
SpriteDisplay display;
@@ -250,7 +252,7 @@ void ItemDB::load()
else
display.floor = image;
- ItemInfo *itemInfo = new ItemInfo;
+ ItemInfo *const itemInfo = new ItemInfo;
itemInfo->setId(id);
itemInfo->setName(name.empty() ? _("unnamed") : name);
itemInfo->setDescription(description);
@@ -311,7 +313,7 @@ void ItemDB::load()
std::string effect;
for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++ i)
{
- int value = XML::getProperty(node, fields[i][0], 0);
+ const int value = XML::getProperty(node, fields[i][0], 0);
if (!value)
continue;
if (!effect.empty())
@@ -321,7 +323,7 @@ void ItemDB::load()
for (std::vector<Stat>::const_iterator it = extraStats.begin(),
it_end = extraStats.end(); it != it_end; ++it)
{
- int value = XML::getProperty(node, it->tag.c_str(), 0);
+ const int value = XML::getProperty(node, it->tag.c_str(), 0);
if (!value)
continue;
if (!effect.empty())
@@ -410,7 +412,8 @@ void ItemDB::load()
{
temp = normalize(name);
- NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
+ const NamedItemInfos::const_iterator
+ itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
{
mNamedItemInfos[temp] = itemInfo;
@@ -478,22 +481,22 @@ void ItemDB::unload()
mLoaded = false;
}
-bool ItemDB::exists(int id)
+bool ItemDB::exists(const int id)
{
if (!mLoaded)
return false;
- ItemInfos::const_iterator i = mItemInfos.find(id);
+ const ItemInfos::const_iterator i = mItemInfos.find(id);
return i != mItemInfos.end();
}
-const ItemInfo &ItemDB::get(int id)
+const ItemInfo &ItemDB::get(const int id)
{
if (!mLoaded)
load();
- ItemInfos::const_iterator i = mItemInfos.find(id);
+ const ItemInfos::const_iterator i = mItemInfos.find(id);
if (i == mItemInfos.end())
{
@@ -509,7 +512,8 @@ const ItemInfo &ItemDB::get(const std::string &name)
if (!mLoaded)
load();
- NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name));
+ const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
+ normalize(name));
if (i == mNamedItemInfos.end())
{
@@ -647,7 +651,7 @@ int parseDirectionName(std::string name)
return id;
}
-void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node)
+void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node)
{
const std::string gender = XML::getProperty(node, "gender", "unisex");
const std::string filename = reinterpret_cast<const char*>(
@@ -662,7 +666,7 @@ void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node)
itemInfo->setSprite(filename, GENDER_OTHER, race);
}
-void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node)
+void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node)
{
std::string event = XML::getProperty(node, "event", "");
std::string filename = reinterpret_cast<const char*>(
@@ -683,13 +687,13 @@ void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node)
}
}
-void loadFloorSprite(SpriteDisplay *display, XmlNodePtr floorNode)
+void loadFloorSprite(SpriteDisplay *const display, const XmlNodePtr floorNode)
{
for_each_xml_child_node(spriteNode, floorNode)
{
if (xmlNameEqual(spriteNode, "sprite"))
{
- SpriteReference *currentSprite = new SpriteReference;
+ SpriteReference *const currentSprite = new SpriteReference;
currentSprite->sprite = reinterpret_cast<const char*>(
spriteNode->xmlChildrenNode->content);
currentSprite->variant
@@ -705,10 +709,10 @@ void loadFloorSprite(SpriteDisplay *display, XmlNodePtr floorNode)
}
}
-void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
+void loadReplaceSprite(ItemInfo *const itemInfo, const XmlNodePtr replaceNode)
{
std::string removeSprite = XML::getProperty(replaceNode, "sprite", "");
- int direction = parseDirectionName(XML::getProperty(
+ const int direction = parseDirectionName(XML::getProperty(
replaceNode, "direction", "all"));
itemInfo->setRemoveSprites();
@@ -719,7 +723,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
{
for (int f = 0; f < 10; f ++)
{
- std::map<int, int> *mapList
+ std::map<int, int> *const mapList
= itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), f);
if (!mapList)
@@ -728,8 +732,8 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
{
if (xmlNameEqual(itemNode, "item"))
{
- int from = XML::getProperty(itemNode, "from", 0);
- int to = XML::getProperty(itemNode, "to", 1);
+ const int from = XML::getProperty(itemNode, "from", 0);
+ const int to = XML::getProperty(itemNode, "to", 1);
(*mapList)[from] = to;
}
@@ -750,8 +754,8 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
{
if (xmlNameEqual(itemNode, "item"))
{
- int from = XML::getProperty(itemNode, "from", 0);
- int to = XML::getProperty(itemNode, "to", 1);
+ const int from = XML::getProperty(itemNode, "from", 0);
+ const int to = XML::getProperty(itemNode, "to", 1);
std::map<int, int> *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), DIRECTION_DOWN);
if (mapList)
@@ -783,8 +787,8 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
{
if (xmlNameEqual(itemNode, "item"))
{
- int from = XML::getProperty(itemNode, "from", 0);
- int to = XML::getProperty(itemNode, "to", 1);
+ const int from = XML::getProperty(itemNode, "from", 0);
+ const int to = XML::getProperty(itemNode, "to", 1);
std::map<int, int> *mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), DIRECTION_UP);
if (mapList)
@@ -805,7 +809,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
}
default:
{
- std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ std::map<int, int> *const mapList = itemInfo->addReplaceSprite(
parseSpriteName(removeSprite), direction);
if (!mapList)
return;
@@ -813,8 +817,8 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
{
if (xmlNameEqual(itemNode, "item"))
{
- int from = XML::getProperty(itemNode, "from", 0);
- int to = XML::getProperty(itemNode, "to", 1);
+ const int from = XML::getProperty(itemNode, "from", 0);
+ const int to = XML::getProperty(itemNode, "to", 1);
(*mapList)[from] = to;
}
}
@@ -823,12 +827,13 @@ void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode)
}
}
-void loadOrderSprite(ItemInfo *itemInfo, XmlNodePtr node, bool drawAfter)
+void loadOrderSprite(ItemInfo *const itemInfo, const XmlNodePtr node,
+ const bool drawAfter)
{
- int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
- int priority = XML::getProperty(node, "priority", 0);
+ const int sprite = parseSpriteName(XML::getProperty(node, "name", ""));
+ const int priority = XML::getProperty(node, "priority", 0);
- int direction = parseDirectionName(XML::getProperty(
+ const int direction = parseDirectionName(XML::getProperty(
node, "direction", "all"));
if (drawAfter)
itemInfo->setDrawAfter(direction, sprite);
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 6fa05ac29..1e6de3929 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -47,9 +47,9 @@ namespace ItemDB
const StringVect &getTags();
- bool exists(int id);
+ bool exists(const int id);
- const ItemInfo &get(int id);
+ const ItemInfo &get(const int id);
const ItemInfo &get(const std::string &name);
// Items database
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index ed3e95e4e..e72893d12 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -101,7 +101,8 @@ ItemInfo::~ItemInfo()
mSpriteToItemReplaceMap[f] = nullptr;
}
-const std::string &ItemInfo::getSprite(Gender gender, int race) const
+const std::string &ItemInfo::getSprite(const Gender gender,
+ const int race) const
{
if (mView)
{
@@ -134,12 +135,13 @@ void ItemInfo::setAttackAction(std::string attackAction)
mAttackAction = attackAction;
}
-void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
+void ItemInfo::addSound(const EquipmentSoundEvent event,
+ const std::string &filename)
{
mSounds[event].push_back(paths.getStringValue("sfx") + filename);
}
-const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
+const std::string &ItemInfo::getSound(const EquipmentSoundEvent event) const
{
static const std::string empty;
std::map<EquipmentSoundEvent, StringVect>::const_iterator i;
@@ -151,7 +153,8 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty;
}
-std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
+std::map<int, int> *ItemInfo::addReplaceSprite(const int sprite,
+ const int direction)
{
if (direction < 0 || direction >= 10)
return nullptr;
@@ -189,12 +192,12 @@ void ItemInfo::setColorsList(std::string name)
}
}
-std::string ItemInfo::getDyeColorsString(int color) const
+std::string ItemInfo::getDyeColorsString(const int color) const
{
if (!mColors || mColorList.empty())
return "";
- std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <int, ColorDB::ItemColor>::const_iterator
it = mColors->find(color);
if (it == mColors->end())
return "";
@@ -202,23 +205,23 @@ std::string ItemInfo::getDyeColorsString(int color) const
return it->second.color;
}
-const std::string ItemInfo::getDescription(unsigned char color) const
+const std::string ItemInfo::getDescription(const unsigned char color) const
{
return replaceColors(mDescription, color);
}
-const std::string ItemInfo::getName(unsigned char color) const
+const std::string ItemInfo::getName(const unsigned char color) const
{
return replaceColors(mName, color);
}
const std::string ItemInfo::replaceColors(std::string str,
- unsigned char color) const
+ const unsigned char color) const
{
std::string name;
if (mColors && !mColorList.empty())
{
- std::map <int, ColorDB::ItemColor>::const_iterator
+ const std::map <int, ColorDB::ItemColor>::const_iterator
it = mColors->find(color);
if (it == mColors->end())
name = "unknown";
@@ -237,12 +240,12 @@ const std::string ItemInfo::replaceColors(std::string str,
return replaceAll(str, "%Color%", name);
}
-SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
+SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(const int direction) const
{
if (direction < 0 || direction >= 10)
return nullptr;
- SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
+ SpriteToItemMap *const spMap = mSpriteToItemReplaceMap[direction];
if (spMap)
return spMap;
if (direction == DIRECTION_UPLEFT || direction == DIRECTION_UPRIGHT)
@@ -254,7 +257,8 @@ SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
return nullptr;
}
-void ItemInfo::setSpriteOrder(int *ptr, int direction, int n, int def)
+void ItemInfo::setSpriteOrder(int *const ptr, const int direction,
+ const int n, const int def) const
{
if (direction == -1)
{
@@ -285,36 +289,36 @@ void ItemInfo::setSpriteOrder(int *ptr, int direction, int n, int def)
ptr[direction] = n;
}
-void ItemInfo::setDrawBefore(int direction, int n)
+void ItemInfo::setDrawBefore(const int direction, const int n)
{
setSpriteOrder(&mDrawBefore[0], direction, n);
}
-void ItemInfo::setDrawAfter(int direction, int n)
+void ItemInfo::setDrawAfter(const int direction, const int n)
{
setSpriteOrder(&mDrawAfter[0], direction, n);
}
-void ItemInfo::setDrawPriority(int direction, int n)
+void ItemInfo::setDrawPriority(const int direction, const int n)
{
setSpriteOrder(&mDrawPriority[0], direction, n, 0);
}
-int ItemInfo::getDrawBefore(int direction) const
+int ItemInfo::getDrawBefore(const int direction) const
{
if (direction < 0 || direction >= 10)
return -1;
return mDrawBefore[direction];
}
-int ItemInfo::getDrawAfter(int direction) const
+int ItemInfo::getDrawAfter(const int direction) const
{
if (direction < 0 || direction >= 10)
return -1;
return mDrawAfter[direction];
}
-int ItemInfo::getDrawPriority(int direction) const
+int ItemInfo::getDrawPriority(const int direction) const
{
if (direction < 0 || direction >= 10)
return 0;
@@ -322,7 +326,7 @@ int ItemInfo::getDrawPriority(int direction) const
}
void ItemInfo::setSprite(const std::string &animationFile,
- Gender gender, int race)
+ const Gender gender, const int race)
{
mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile;
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 655bc049c..9a81d65e9 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -109,7 +109,7 @@ class ItemInfo
~ItemInfo();
- void setId(int id)
+ void setId(const int id)
{ mId = id; }
int getId() const
@@ -121,7 +121,7 @@ class ItemInfo
const std::string &getName() const
{ return mName; }
- const std::string getName(unsigned char color) const;
+ const std::string getName(const unsigned char color) const;
void setParticleEffect(const std::string &particleEffect)
{ mParticle = particleEffect; }
@@ -141,7 +141,7 @@ class ItemInfo
const std::string &getDescription() const
{ return mDescription; }
- const std::string getDescription(unsigned char color) const;
+ const std::string getDescription(const unsigned char color) const;
void setEffect(const std::string &effect)
{ mEffect = effect; }
@@ -149,13 +149,13 @@ class ItemInfo
const std::string &getEffect() const
{ return mEffect; }
- void setType(ItemType type)
+ void setType(const ItemType type)
{ mType = type; }
ItemType getType() const
{ return mType; }
- void setWeight(int weight)
+ void setWeight(const int weight)
{ mWeight = weight; }
int getWeight() const
@@ -164,13 +164,14 @@ class ItemInfo
int getView() const
{ return mView; }
- void setView(int view)
+ void setView(const int view)
{ mView = view; }
void setSprite(const std::string &animationFile,
- Gender gender, int race);
+ const Gender gender, const int race);
- const std::string &getSprite(Gender gender, int race) const;
+ const std::string &getSprite(const Gender gender,
+ const int race) const;
void setAttackAction(std::string attackAction);
@@ -181,13 +182,13 @@ class ItemInfo
const std::string &getMissileParticleFile() const
{ return mMissileParticleFile; }
- void setHitEffectId(int s)
+ void setHitEffectId(const int s)
{ mHitEffectId = s; }
int getHitEffectId() const
{ return mHitEffectId; }
- void setCriticalHitEffectId(int s)
+ void setCriticalHitEffectId(const int s)
{ mCriticalHitEffectId = s; }
int getCriticalHitEffectId() const
@@ -199,31 +200,33 @@ class ItemInfo
int getAttackRange() const
{ return mAttackRange; }
- void setAttackRange(int r)
+ void setAttackRange(const int r)
{ mAttackRange = r; }
- void addSound(EquipmentSoundEvent event, const std::string &filename);
+ void addSound(const EquipmentSoundEvent event,
+ const std::string &filename);
- const std::string &getSound(EquipmentSoundEvent event) const;
+ const std::string &getSound(const EquipmentSoundEvent event) const;
- int getDrawBefore(int direction) const;
+ int getDrawBefore(const int direction) const;
- void setDrawBefore(int direction, int n);
+ void setDrawBefore(const int direction, const int n);
- int getDrawAfter(int direction) const;
+ int getDrawAfter(const int direction) const;
- void setDrawAfter(int direction, int n);
+ void setDrawAfter(const int direction, int n);
- int getDrawPriority(int direction) const;
+ int getDrawPriority(const int direction) const;
- void setDrawPriority(int direction, int n);
+ void setDrawPriority(const int direction, const int n);
- void setSpriteOrder(int *ptr, int direction, int n, int def = -1);
+ void setSpriteOrder(int *const ptr, const int direction,
+ const int n, const int def = -1) const;
std::map<int, int> getTags() const
{ return mTags; }
- void addTag(int tag)
+ void addTag(const int tag)
{ mTags[tag] = 1; }
void setRemoveSprites()
@@ -232,7 +235,7 @@ class ItemInfo
bool isRemoveSprites() const
{ return mIsRemoveSprites; }
- void setMaxFloorOffset(int i)
+ void setMaxFloorOffset(const int i)
{ maxFloorOffset = i; }
int getMaxFloorOffset() const
@@ -245,13 +248,14 @@ class ItemInfo
int getReplaceToSpriteId(int id) const;
- std::map<int, int> *addReplaceSprite(int sprite, int direction);
+ std::map<int, int> *addReplaceSprite(const int sprite,
+ const int direction);
- SpriteToItemMap *getSpriteToItemReplaceMap(int directions) const;
+ SpriteToItemMap *getSpriteToItemReplaceMap(const int directions) const;
// std::string getDyeString(int color) const;
- std::string getDyeColorsString(int color) const;
+ std::string getDyeColorsString(const int color) const;
void setColorsList(std::string name);
@@ -259,7 +263,7 @@ class ItemInfo
{ return !mColorList.empty(); }
const std::string replaceColors(std::string str,
- unsigned char color) const;
+ const unsigned char color) const;
int mDrawBefore[10];
int mDrawAfter[10];
diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp
index 465faeba3..3c4347301 100644
--- a/src/resources/mapdb.cpp
+++ b/src/resources/mapdb.cpp
@@ -41,7 +41,7 @@ void MapDB::load()
XML::Document *doc = new XML::Document(
paths.getStringValue("maps") + "remap.xml");
- XmlNodePtr root = doc->rootNode();
+ const XmlNodePtr root = doc->rootNode();
if (!root)
{
delete doc;
@@ -78,9 +78,9 @@ void MapDB::unload()
mLoaded = false;
}
-std::string MapDB::getMapName(std::string name)
+std::string MapDB::getMapName(const std::string &name)
{
- MapIterator it = mMaps.find(name);
+ const MapIterator it = mMaps.find(name);
if (it != mMaps.end())
return it->second;
diff --git a/src/resources/mapdb.h b/src/resources/mapdb.h
index d249a5cc6..0d13428ee 100644
--- a/src/resources/mapdb.h
+++ b/src/resources/mapdb.h
@@ -40,7 +40,7 @@ namespace MapDB
*/
void unload();
- std::string getMapName(std::string name);
+ std::string getMapName(const std::string &name);
// Maps DB
typedef std::map<std::string, std::string> Maps;
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 841f9b3ae..865f5f63f 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -128,7 +128,8 @@ Image *OpenGLImageHelper::load(SDL_Surface *tmpImage)
return glLoad(tmpImage);
}
-Image *OpenGLImageHelper::createTextSurface(SDL_Surface *tmpImage, float alpha)
+Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
+ const float alpha)
{
if (!tmpImage)
return nullptr;
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index edba4cdef..9b8813f78 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -74,7 +74,8 @@ class OpenGLImageHelper : public ImageHelper
*/
Image *load(SDL_Surface *);
- Image *createTextSurface(SDL_Surface *tmpImage, float alpha);
+ Image *createTextSurface(SDL_Surface *const tmpImage,
+ const float alpha);
// OpenGL only public functions