summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-13 12:20:19 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-13 12:20:19 +0300
commitf0b7627b7d88c1d5bb484961377114b210c8dd53 (patch)
treea978c3b8eca88759fa71b5fc34112f4bea9bbcec /src/resources
parentd9be27bba8941260500066cdd43ebb016356bc67 (diff)
downloadplus-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.gz
plus-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.bz2
plus-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.xz
plus-f0b7627b7d88c1d5bb484961377114b210c8dd53.zip
Fix code style.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/beinginfo.cpp2
-rw-r--r--src/resources/db/palettedb.cpp9
-rw-r--r--src/resources/dye.cpp48
-rw-r--r--src/resources/dyepalette.cpp32
-rw-r--r--src/resources/fboinfo.h2
-rw-r--r--src/resources/imagewriter.cpp2
-rw-r--r--src/resources/iteminfo.cpp2
7 files changed, 54 insertions, 43 deletions
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 757de8238..e3cf9bb91 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -154,7 +154,7 @@ const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
if (!vect || vect->empty())
return emptySound;
else
- return vect->at(rand() % vect->size());
+ return vect->at(static_cast<unsigned int>(rand()) % vect->size());
}
const Attack *BeingInfo::getAttack(const int id) const
diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp
index 8ec238336..08c8ec85d 100644
--- a/src/resources/db/palettedb.cpp
+++ b/src/resources/db/palettedb.cpp
@@ -82,13 +82,14 @@ void PaletteDB::loadPalette()
if (line.empty() || line[0] == '#')
continue;
- unsigned int r;
- unsigned int g;
- unsigned int b;
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
- if (sscanf(line.c_str(), "%10u %10u %10u\t%100s",
+ if (sscanf(line.c_str(), "%10hhu %10hhu %10hhu\t%100s",
&r, &g, &b, name) == 4)
{
+ name[100] = 0;
mColors[name] = DyeColor(r, g, b);
}
}
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index ea66b2b6b..3b83780c5 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -162,23 +162,25 @@ void Dye::normalDye(uint32_t *restrict pixels, const int bufSize) const
#endif
if (!alpha)
continue;
- int color[3];
+ unsigned int color[3];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p) & 255;
- color[1] = (p >> 8) & 255;
- color[2] = (p >> 16) & 255;
+ color[0] = (p) & 255U;
+ color[1] = (p >> 8U) & 255U;
+ color[2] = (p >> 16U) & 255U;
#else
- color[0] = (p >> 24) & 255;
- color[1] = (p >> 16) & 255;
- color[2] = (p >> 8) & 255;
+ color[0] = (p >> 24U) & 255U;
+ color[1] = (p >> 16U) & 255U;
+ color[2] = (p >> 8U) & 255U;
#endif
- const int cmax = std::max(color[0], std::max(color[1], color[2]));
+ const unsigned int cmax = std::max(
+ color[0], std::max(color[1], color[2]));
if (cmax == 0)
continue;
- const int cmin = std::min(color[0], std::min(color[1], color[2]));
- const int intensity = color[0] + color[1] + color[2];
+ const unsigned int cmin = std::min(
+ color[0], std::min(color[1], color[2]));
+ const unsigned int intensity = color[0] + color[1] + color[2];
if (cmin != cmax && (cmin != 0 || (intensity != cmax
&& intensity != 2 * cmax)))
@@ -187,7 +189,7 @@ void Dye::normalDye(uint32_t *restrict pixels, const int bufSize) const
continue;
}
- const int i = (color[0] != 0) | ((color[1] != 0) << 1)
+ const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1)
| ((color[2] != 0) << 2);
if (mDyePalettes[i - 1])
@@ -217,23 +219,25 @@ void Dye::normalOGLDye(uint32_t *restrict pixels, const int bufSize) const
#endif
if (!alpha)
continue;
- int color[3];
+ unsigned int color[3];
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- color[0] = (p >> 24) & 255;
- color[1] = (p >> 16) & 255;
- color[2] = (p >> 8) & 255;
+ color[0] = (p >> 24U) & 255U;
+ color[1] = (p >> 16U) & 255U;
+ color[2] = (p >> 8U) & 255U;
#else
- color[0] = (p) & 255;
- color[1] = (p >> 8) & 255;
- color[2] = (p >> 16) & 255;
+ color[0] = (p) & 255U;
+ color[1] = (p >> 8U) & 255U;
+ color[2] = (p >> 16U) & 255U;
#endif
- const int cmax = std::max(color[0], std::max(color[1], color[2]));
+ const unsigned int cmax = std::max(
+ color[0], std::max(color[1], color[2]));
if (cmax == 0)
continue;
- const int cmin = std::min(color[0], std::min(color[1], color[2]));
- const int intensity = color[0] + color[1] + color[2];
+ const unsigned int cmin = std::min(
+ color[0], std::min(color[1], color[2]));
+ const unsigned int intensity = color[0] + color[1] + color[2];
if (cmin != cmax && (cmin != 0 || (intensity != cmax
&& intensity != 2 * cmax)))
@@ -242,7 +246,7 @@ void Dye::normalOGLDye(uint32_t *restrict pixels, const int bufSize) const
continue;
}
- const int i = (color[0] != 0) | ((color[1] != 0) << 1)
+ const unsigned int i = (color[0] != 0) | ((color[1] != 0) << 1)
| ((color[2] != 0) << 2);
if (mDyePalettes[i - 1])
diff --git a/src/resources/dyepalette.cpp b/src/resources/dyepalette.cpp
index f20af9086..4c62abd1c 100644
--- a/src/resources/dyepalette.cpp
+++ b/src/resources/dyepalette.cpp
@@ -234,11 +234,11 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
const DyeColor &col2 = *it;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[2] << 16)
- | (col.value[1] << 8) | (col.value[0]);
+ const unsigned int coldata = (col.value[2] << 16U)
+ | (col.value[1] << 8U) | (col.value[0]);
#else
- const unsigned int coldata = (col.value[2] << 8)
- | (col.value[1] << 16) | (col.value[0] << 24);
+ const unsigned int coldata = (col.value[2] << 8U)
+ | (col.value[1] << 16U) | (col.value[0] << 24U);
#endif
// logger->log("coldata: %08x", coldata);
if (data == coldata)
@@ -280,11 +280,15 @@ void DyePalette::replaceAColor(uint32_t *restrict pixels,
const DyeColor &col2 = *it;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[3] << 24)
- | (col.value[2] << 16) | (col.value[1] << 8) | (col.value[0]);
+ const unsigned int coldata = (col.value[3] << 24U)
+ | (col.value[2] << 16U)
+ | (col.value[1] << 8U)
+ | (col.value[0]);
#else
- const unsigned int coldata = (col.value[3]) | (col.value[2] << 8)
- | (col.value[1] << 16) | (col.value[0] << 24);
+ const unsigned int coldata = (col.value[3])
+ | (col.value[2] << 8U)
+ | (col.value[1] << 16U) |
+ (col.value[0] << 24U);
#endif
if (data == coldata)
@@ -378,11 +382,15 @@ void DyePalette::replaceAOGLColor(uint32_t *restrict pixels,
const DyeColor &col2 = *it;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned int coldata = (col.value[0] << 24)
- | (col.value[1] << 16) | (col.value[2] << 8) | col.value[3];
+ const unsigned int coldata = (col.value[0] << 24U)
+ | (col.value[1] << 16U)
+ | (col.value[2] << 8U)
+ | col.value[3];
#else
- const unsigned int coldata = (col.value[0]) | (col.value[1] << 8)
- | (col.value[2] << 16) | (col.value[3] << 24);
+ const unsigned int coldata = (col.value[0])
+ | (col.value[1] << 8U)
+ | (col.value[2] << 16U)
+ | (col.value[3] << 24U);
#endif
if (data == coldata)
{
diff --git a/src/resources/fboinfo.h b/src/resources/fboinfo.h
index 9ba4efd43..6d723ca6a 100644
--- a/src/resources/fboinfo.h
+++ b/src/resources/fboinfo.h
@@ -26,8 +26,6 @@
#include "render/graphics.h"
-#include "resources/fboinfo.h"
-
#ifdef ANDROID
#include <GLES/gl.h>
#include <GLES/glext.h>
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index 9ff87c758..1f71d97a3 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -24,7 +24,7 @@
#include "logger.h"
-#include <stdlib.h>
+#include <cstdlib>
#include <png.h>
#include <SDL_video.h>
#include <string>
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 8e1284fad..55ca5f44d 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -152,7 +152,7 @@ const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const
if (i == mSounds.end())
return empty;
- return (!i->second.empty()) ? i->second[rand()
+ return (!i->second.empty()) ? i->second[static_cast<unsigned int>(rand())
% i->second.size()] : empty;
}