summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/ambientlayer.cpp8
-rw-r--r--src/resources/animation.h6
-rw-r--r--src/resources/beinginfo.cpp4
-rw-r--r--src/resources/beinginfo.h10
-rw-r--r--src/resources/colordb.h8
-rw-r--r--src/resources/image.cpp10
-rw-r--r--src/resources/itemdb.cpp4
-rw-r--r--src/resources/itemdb.h8
-rw-r--r--src/resources/iteminfo.cpp12
-rw-r--r--src/resources/mapreader.cpp2
-rw-r--r--src/resources/soundeffect.cpp4
-rw-r--r--src/resources/soundeffect.h3
-rw-r--r--src/resources/specialdb.cpp2
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/resources/spritedef.h8
-rw-r--r--src/resources/wallpaper.cpp2
16 files changed, 51 insertions, 42 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 10d70c2c7..319bc5b8c 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax,
if (keepRatio && !mImage->useOpenGL()
/*&& defaultScreenWidth != 0
&& defaultScreenHeight != 0*/
- && graphics->mWidth != defaultScreenWidth
- && graphics->mHeight != defaultScreenHeight)
+ && mainGraphics->mWidth != defaultScreenWidth
+ && mainGraphics->mHeight != defaultScreenHeight)
{
// Rescale the overlay to keep the ratio as if we were on
// the default resolution...
Image *rescaledOverlay = ResourceManager::getInstance()->
getRescaled(mImage, static_cast<int>(mImage->mBounds.w)
- / defaultScreenWidth * graphics->mWidth,
+ / defaultScreenWidth * mainGraphics->mWidth,
static_cast<int>(mImage->mBounds.h)
- / defaultScreenHeight * graphics->mHeight);
+ / defaultScreenHeight * mainGraphics->mHeight);
if (rescaledOverlay)
mImage = rescaledOverlay;
diff --git a/src/resources/animation.h b/src/resources/animation.h
index 0c6f45681..19b17eb54 100644
--- a/src/resources/animation.h
+++ b/src/resources/animation.h
@@ -85,6 +85,12 @@ class Animation
{ return static_cast<unsigned>(mFrames.size()); }
/**
+ * Check for empty animation.
+ */
+ bool empty() const
+ { return mFrames.empty(); }
+
+ /**
* Returns the duration of this animation.
*/
int getDuration() const
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 8beea420d..4aa7515b1 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -94,10 +94,10 @@ void BeingInfo::addSound(SoundEvent event, const std::string &filename)
const std::string &BeingInfo::getSound(SoundEvent event) const
{
- static std::string empty("");
+ static std::string emptySound("");
SoundEvents::const_iterator i = mSounds.find(event);
- return (i == mSounds.end() || !i->second) ? empty :
+ return (i == mSounds.end() || !i->second) ? emptySound :
i->second->at(rand() % i->second->size());
}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index a61483940..b93c11ba6 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -38,12 +38,12 @@ struct Attack
std::string particleEffect;
std::string missileParticle;
- Attack(std::string action, std::string particleEffect,
- std::string missileParticle)
+ Attack(std::string action0, std::string particleEffect0,
+ std::string missileParticle0)
{
- this->action = action;
- this->particleEffect = particleEffect;
- this->missileParticle = missileParticle;
+ action = action0;
+ particleEffect = particleEffect0;
+ missileParticle = missileParticle0;
}
};
diff --git a/src/resources/colordb.h b/src/resources/colordb.h
index ce128578e..83bff57da 100644
--- a/src/resources/colordb.h
+++ b/src/resources/colordb.h
@@ -38,11 +38,11 @@ namespace ColorDB
color("")
{ }
- ItemColor(int id, std::string name, std::string color)
+ ItemColor(int id0, std::string name0, std::string color0)
{
- this->id = id;
- this->name = name;
- this->color = color;
+ this->id = id0;
+ this->name = name0;
+ this->color = color0;
}
int id;
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 802f2ee12..8f5ee1d2d 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -49,12 +49,12 @@ int Image::mTextureSize = 0;
bool Image::mEnableAlphaCache = false;
bool Image::mEnableAlpha = true;
-Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel):
+Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel):
mAlpha(1.0f),
- mHasAlphaChannel(hasAlphaChannel),
+ mHasAlphaChannel(hasAlphaChannel0),
mSDLSurface(image),
mAlphaChannel(alphaChannel),
- mIsAlphaVisible(hasAlphaChannel),
+ mIsAlphaVisible(hasAlphaChannel0),
mIsAlphaCalculated(false)
{
#ifdef USE_OPENGL
@@ -336,7 +336,7 @@ bool Image::hasAlphaChannel()
SDL_Surface *Image::getByAlpha(float alpha)
{
- std::map<float, SDL_Surface*>::iterator it = mAlphaCache.find(alpha);
+ std::map<float, SDL_Surface*>::const_iterator it = mAlphaCache.find(alpha);
if (it != mAlphaCache.end())
return (*it).second;
return 0;
@@ -361,7 +361,7 @@ void Image::setAlpha(float alpha)
{
#ifdef DEBUG_ALPHA_CACHE
logger->log("cleanCache");
- for (std::map<float, SDL_Surface*>::iterator
+ for (std::map<float, SDL_Surface*>::const_iterator
i = mAlphaCache.begin(), i_end = mAlphaCache.end();
i != i_end; ++i)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 733c12958..9ff80de22 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -308,7 +308,7 @@ void ItemDB::load()
effect += " / ";
effect += strprintf(gettext(fields[i][1]), value);
}
- for (std::vector<Stat>::iterator it = extraStats.begin();
+ for (std::vector<Stat>::const_iterator it = extraStats.begin();
it != extraStats.end(); ++it)
{
int value = XML::getProperty(node, it->tag.c_str(), 0);
@@ -361,7 +361,7 @@ void ItemDB::load()
mItemInfos[id] = itemInfo;
if (!name.empty())
{
- std::string temp = normalize(name);
+ temp = normalize(name);
NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 267f60eef..c20961eff 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -68,10 +68,10 @@ namespace ItemDB
struct Stat
{
- Stat(const std::string &tag,
- const std::string &format):
- tag(tag),
- format(format)
+ Stat(const std::string &tag0,
+ const std::string &format0) :
+ tag(tag0),
+ format(format0)
{}
std::string tag;
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index fb4b8ed5e..5b07724a1 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -108,7 +108,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const
}
else
{
- static const std::string empty = "";
+ static const std::string empty("");
std::map<int, std::string>::const_iterator i =
mAnimationFiles.find(gender);
@@ -139,7 +139,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
if (i == mSounds.end())
return empty;
- return i->second.size() > 0 ? i->second[rand() % i->second.size()] : empty;
+ return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty;
}
std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
@@ -185,7 +185,8 @@ std::string ItemInfo::getDyeColorsString(int color) const
if (!mColors || mColorList.empty())
return "";
- std::map <int, ColorDB::ItemColor>::iterator it = mColors->find(color);
+ std::map <int, ColorDB::ItemColor>::const_iterator
+ it = mColors->find(color);
if (it == mColors->end())
return "";
@@ -208,7 +209,8 @@ const std::string ItemInfo::replaceColors(std::string str,
std::string name;
if (mColors && !mColorList.empty())
{
- std::map <int, ColorDB::ItemColor>::iterator it = mColors->find(color);
+ std::map <int, ColorDB::ItemColor>::const_iterator
+ it = mColors->find(color);
if (it == mColors->end())
name = "unknown";
else
@@ -220,7 +222,7 @@ const std::string ItemInfo::replaceColors(std::string str,
}
str = replaceAll(str, "%color%", name);
- if (name.size() > 0)
+ if (!name.empty())
name[0] = static_cast<char>(toupper(name[0]));
return replaceAll(str, "%Color%", name);
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 685d415ff..f702864ea 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -734,7 +734,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
Animation *ani = new Animation;
for (int i = 0; ; i++)
{
- std::map<std::string, int>::iterator iFrame, iDelay;
+ std::map<std::string, int>::const_iterator iFrame, iDelay;
iFrame = tileProperties.find(
"animation-frame" + toString(i));
iDelay = tileProperties.find(
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index 49e7adc31..e8e5d3dbb 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -53,9 +53,9 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
}
}
-bool SoundEffect::play(int loops, int volume)
+bool SoundEffect::play(int loops, int volume, int channel)
{
Mix_VolumeChunk(mChunk, volume);
- return Mix_PlayChannel(-1, mChunk, loops) != -1;
+ return Mix_PlayChannel(channel, mChunk, loops) != -1;
}
diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h
index 80f826646..fdd4bd275 100644
--- a/src/resources/soundeffect.h
+++ b/src/resources/soundeffect.h
@@ -54,11 +54,12 @@ class SoundEffect : public Resource
*
* @param loops Number of times to repeat the playback.
* @param volume Sample playback volume.
+ * @param channel Sample playback channel.
*
* @return <code>true</code> if the playback started properly
* <code>false</code> otherwise.
*/
- virtual bool play(int loops, int volume);
+ virtual bool play(int loops, int volume, int channel = -1);
protected:
/**
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 573ffb2a3..2463da06a 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -123,7 +123,7 @@ void SpecialDB::unload()
SpecialInfo *SpecialDB::get(int id)
{
- SpecialInfos::iterator i = mSpecialInfos.find(id);
+ SpecialInfos::const_iterator i = mSpecialInfos.find(id);
if (i == mSpecialInfos.end())
return NULL;
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index dee93e1e7..2e32f6c5f 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -86,7 +86,7 @@ void SpriteDef::substituteAction(std::string complete, std::string with)
{
if (mActions.find(complete) == mActions.end())
{
- Actions::iterator i = mActions.find(with);
+ Actions::const_iterator i = mActions.find(with);
if (i != mActions.end())
mActions[complete] = i->second;
}
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index 8fa64e7b9..b2939fca1 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -43,10 +43,10 @@ struct SpriteReference
sprite(""), variant(0)
{}
- SpriteReference(std::string sprite, int variant)
+ SpriteReference(std::string sprite0, int variant0)
{
- this->sprite = sprite;
- this->variant = variant;
+ sprite = sprite0;
+ variant = variant0;
}
std::string sprite;
@@ -86,7 +86,7 @@ namespace SpriteAction
static const std::string CAST_MAGIC = "magic";
static const std::string USE_ITEM = "item";
static const std::string SPAWN = "spawn";
- static const std::string INVALID = "";
+ static const std::string INVALID("");
}
enum SpriteDirection
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 09c9f2a04..5cfec3b84 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -137,7 +137,7 @@ void Wallpaper::loadWallpapers()
std::string Wallpaper::getWallpaper(int width, int height)
{
- std::vector<WallpaperData>::iterator iter;
+ std::vector<WallpaperData>::const_iterator iter;
WallpaperData wp;
// Wallpaper filename container