summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-31 16:54:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 03:56:16 +0300
commit761682b6254a3d43e65ff45e07683c61afa6f1e4 (patch)
tree2ee462840f3aadb1e96bfa5c6784ec2cc0d2861a /src/resources
parenta39f63cdfa5ce15b22f294a8bb1db3a036ce462d (diff)
downloadplus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.gz
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.bz2
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.xz
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.zip
Last part of fixes.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/dye.cpp12
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/resourcemanager.cpp2
-rw-r--r--src/resources/spritedef.cpp2
-rw-r--r--src/resources/wallpaper.cpp19
5 files changed, 15 insertions, 22 deletions
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 3b2d20054..a4e101ff8 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -236,10 +236,10 @@ Dye::Dye(const std::string &description)
if (description.empty())
return;
- std::string::size_type next_pos = 0, length = description.length();
+ size_t next_pos = 0, length = description.length();
do
{
- std::string::size_type pos = next_pos;
+ size_t pos = next_pos;
next_pos = description.find(';', pos);
if (next_pos == std::string::npos)
@@ -313,7 +313,7 @@ void Dye::update(int color[3]) const
void Dye::instantiate(std::string &target, const std::string &palettes)
{
- std::string::size_type next_pos = target.find('|');
+ size_t next_pos = target.find('|');
if (next_pos == std::string::npos || palettes.empty())
return;
@@ -322,10 +322,10 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
std::ostringstream s;
s << target.substr(0, next_pos);
- std::string::size_type last_pos = target.length(), pal_pos = 0;
+ size_t last_pos = target.length(), pal_pos = 0;
do
{
- std::string::size_type pos = next_pos;
+ size_t pos = next_pos;
next_pos = target.find(';', pos);
if (next_pos == std::string::npos)
@@ -333,7 +333,7 @@ void Dye::instantiate(std::string &target, const std::string &palettes)
if (next_pos == pos + 1 && pal_pos != std::string::npos)
{
- std::string::size_type pal_next_pos = palettes.find(';', pal_pos);
+ size_t pal_next_pos = palettes.find(';', pal_pos);
s << target[pos] << ':';
if (pal_next_pos == std::string::npos)
{
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 894ce7984..72d1aa9eb 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -298,7 +298,7 @@ void ItemDB::load()
itemInfo->setColorsList(colors);
std::string effect;
- for (int i = 0; i < int(sizeof(fields) / sizeof(fields[0])); ++i)
+ for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); ++ i)
{
int value = XML::getProperty(node, fields[i][0], 0);
if (!value)
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 03f0e9770..12ad310ed 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -443,7 +443,7 @@ struct DyedImageLoader
return nullptr;
std::string path = rl->path;
- std::string::size_type p = path.find('|');
+ size_t p = path.find('|');
Dye *d = nullptr;
if (p != std::string::npos)
{
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 8daee7e9b..3411b70c4 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -76,7 +76,7 @@ unsigned SpriteDef::findNumber(unsigned num) const
SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
- std::string::size_type pos = animationFile.find('|');
+ size_t pos = animationFile.find('|');
std::string palettes;
if (pos != std::string::npos)
palettes = animationFile.substr(pos + 1);
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index d4537e963..7b89bed6e 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -149,21 +149,14 @@ std::string Wallpaper::getWallpaper(int width, int height)
wallPaperVector.push_back(wp.filename);
}
+ // If we've got more than one occurence of a valid wallpaper...
if (!wallPaperVector.empty())
{
- // If we've got more than one occurence of a valid wallpaper...
- if (!wallPaperVector.empty())
- {
- // Return randomly a wallpaper between vector[0] and
- // vector[vector.size() - 1]
- srand(static_cast<unsigned>(time(nullptr)));
- return wallPaperVector[int(static_cast<double>(
- wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
- }
- else // If there at least one, we return it
- {
- return wallPaperVector[0];
- }
+ // Return randomly a wallpaper between vector[0] and
+ // vector[vector.size() - 1]
+ srand(static_cast<unsigned>(time(nullptr)));
+ return wallPaperVector[int(static_cast<double>(
+ wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
}
// Return the backup file if everything else failed...