summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-21 13:30:39 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-21 13:30:39 +0300
commit1fcc02e803d83ae8415ff44f9696cb215f475daa (patch)
tree3c4ccb5160624db095a139cb5a81a982e156d81c /src
parent126fa885664da8a8de86f3a38c04469f7006e447 (diff)
downloadplus-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.gz
plus-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.bz2
plus-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.xz
plus-1fcc02e803d83ae8415ff44f9696cb215f475daa.zip
fix signed shifts.
Diffstat (limited to 'src')
-rw-r--r--src/being/playerrelations.h16
-rw-r--r--src/gui/base/color.cpp39
-rw-r--r--src/gui/base/color.hpp15
-rw-r--r--src/gui/theme.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/net/ea/inventoryhandler.cpp2
-rw-r--r--src/net/eathena/messageout.cpp2
-rw-r--r--src/net/messagein.cpp4
-rw-r--r--src/net/tmwa/messageout.cpp2
-rw-r--r--src/render/sdlgraphics.h2
-rw-r--r--src/resources/dye.cpp2
-rw-r--r--src/resources/dye.h2
-rw-r--r--src/utils/mathutils.h6
-rw-r--r--src/utils/stringutils.cpp2
-rw-r--r--src/utils/stringutils.h2
15 files changed, 53 insertions, 47 deletions
diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h
index 3543d4221..c9a884d2e 100644
--- a/src/being/playerrelations.h
+++ b/src/being/playerrelations.h
@@ -35,14 +35,14 @@ class PlayerRelationsListener;
struct PlayerRelation final
{
- static const unsigned int EMOTE = (1 << 0);
- static const unsigned int SPEECH_FLOAT = (1 << 1);
- static const unsigned int SPEECH_LOG = (1 << 2);
- static const unsigned int WHISPER = (1 << 3);
- static const unsigned int TRADE = (1 << 4);
- static const unsigned int INVISIBLE = (1 << 5);
- static const unsigned int BLACKLIST = (1 << 6);
- static const unsigned int ENEMY = (1 << 7);
+ static const unsigned int EMOTE = (1U << 0);
+ static const unsigned int SPEECH_FLOAT = (1U << 1);
+ static const unsigned int SPEECH_LOG = (1U << 2);
+ static const unsigned int WHISPER = (1U << 3);
+ static const unsigned int TRADE = (1U << 4);
+ static const unsigned int INVISIBLE = (1U << 5);
+ static const unsigned int BLACKLIST = (1U << 6);
+ static const unsigned int ENEMY = (1U << 7);
static const unsigned int RELATIONS_NR = 7;
static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR];
diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp
index 764259efc..485367e6d 100644
--- a/src/gui/base/color.cpp
+++ b/src/gui/base/color.cpp
@@ -72,22 +72,25 @@
namespace gcn
{
Color::Color() :
- r(0),
- g(0),
- b(0),
- a(255)
+ r(0U),
+ g(0U),
+ b(0U),
+ a(255U)
{
}
- Color::Color(const int color) :
+ Color::Color(const unsigned int color) :
r((color >> 16) & 0xFF),
g((color >> 8) & 0xFF),
b(color & 0xFF),
- a(255)
+ a(255U)
{
}
- Color::Color(const int ar, const int ag, const int ab, const int aa) :
+ Color::Color(const unsigned int ar,
+ const unsigned int ag,
+ const unsigned int ab,
+ const unsigned int aa) :
r(ar),
g(ag),
b(ab),
@@ -100,11 +103,11 @@ namespace gcn
Color result(r + color.r,
g + color.g,
b + color.b,
- 255);
+ 255U);
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -114,11 +117,11 @@ namespace gcn
Color result(r - color.r,
g - color.g,
b - color.b,
- 255);
+ 255U);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -130,9 +133,9 @@ namespace gcn
static_cast<int>(static_cast<float>(b) * value),
a);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp
index c32adb2e9..781b2cb60 100644
--- a/src/gui/base/color.hpp
+++ b/src/gui/base/color.hpp
@@ -93,7 +93,7 @@ namespace gcn
*
* @param color The color to initialise the object with.
*/
- explicit Color(const int color);
+ explicit Color(const unsigned int color);
/**
* Constructor. The default alpha value is 255.
@@ -104,7 +104,10 @@ namespace gcn
* @param a Alpha, used for transparency. A value of 0 means
* totaly transparent, 255 is totaly opaque.
*/
- Color(const int r, const int g, const int b, const int a = 255);
+ Color(const unsigned int r,
+ const unsigned int g,
+ const unsigned int b,
+ const unsigned int a = 255);
/**
* Adds the RGB values of two colors together. The values will be
@@ -169,23 +172,23 @@ namespace gcn
/**
* Holds the red color component (range 0-255).
*/
- int r;
+ unsigned int r;
/**
* Holds the green color component (range 0-255).
*/
- int g;
+ unsigned int g;
/**
* Holds the blue color component (range 0-255).
*/
- int b;
+ unsigned int b;
/**
* Holds the alpha color component. A value of 0 means totally
* transparent while a value of 255 is considered opaque.
*/
- int a;
+ unsigned int a;
};
} // namespace gcn
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 4218aff7c..2a1b0d624 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -982,7 +982,7 @@ static gcn::Color readColor(const std::string &description)
return Palette::BLACK;
}
- int v = 0;
+ unsigned int v = 0;
for (int i = 1; i < 7; ++i)
{
signed const char c = description[i];
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index c30045c02..0d4d53dd3 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -251,7 +251,7 @@ void TextField::keyPressed(KeyEvent &keyEvent)
}
if (len > 1)
- buf[0] |= static_cast<char>(255 << (8 - len));
+ buf[0] |= static_cast<char>(255U << (8 - len));
mText.insert(mCaretPosition, std::string(buf, buf + len));
mCaretPosition += len;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 3f4eb9228..d64050e1a 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -160,7 +160,7 @@ int InventoryHandler::getSlot(const int eAthenaSlot) const
if (eAthenaSlot & 0x8000)
return Equipment::EQUIP_PROJECTILE_SLOT;
- int mask = 1;
+ unsigned int mask = 1;
int position = 0;
while (!(eAthenaSlot & mask))
{
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 3ac6a417e..ff16f5dd0 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -96,7 +96,7 @@ void MessageOut::writeCoordinates(const uint16_t x,
mNetwork->mOutSize += 3;
mPos += 3;
- int16_t temp = x;
+ uint16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 9d9c68b94..81340ba33 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -115,7 +115,7 @@ void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y,
if (mPos + 3 <= mLength)
{
const char *const data = mData + mPos;
- int16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
+ uint16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
x = static_cast<uint16_t>(temp >> 6);
temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
y = static_cast<uint16_t>(temp >> 4);
@@ -147,7 +147,7 @@ void MessageIn::readCoordinatePair(uint16_t &restrict srcX,
if (mPos + 5 <= mLength)
{
const char *const data = mData + mPos;
- int16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
+ uint16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
dstX = static_cast<uint16_t>(temp >> 2);
dstY = MAKEWORD(data[4], data[3] & 0x0003);
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 8dfbf2bd7..8c3ecb5ec 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -98,7 +98,7 @@ void MessageOut::writeCoordinates(const uint16_t x,
mNetwork->mOutSize += 3;
mPos += 3;
- int16_t temp = x;
+ uint16_t temp = x;
temp <<= 6;
data[0] = 0;
data[1] = 1;
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 17b54db92..484b24e31 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -166,7 +166,7 @@ class SDLGraphics final : public Graphics
void drawVLine(int x, int y1, int y2);
uint32_t mOldPixel;
- int mOldAlpha;
+ unsigned int mOldAlpha;
private:
void inline calcImageRect(ImageVertexes *const vert,
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index a1d925a1f..4f9e8a738 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -88,7 +88,7 @@ DyePalette::DyePalette(const std::string &description,
logger->log("Error, invalid embedded palette: %s", description.c_str());
}
-int DyePalette::hexDecode(const signed char c)
+unsigned int DyePalette::hexDecode(const signed char c)
{
if ('0' <= c && c <= '9')
return c - '0';
diff --git a/src/resources/dye.h b/src/resources/dye.h
index a68839e47..b6003624b 100644
--- a/src/resources/dye.h
+++ b/src/resources/dye.h
@@ -82,7 +82,7 @@ class DyePalette final
void replaceAOGLColor(uint32_t *restrict pixels,
const int bufSize) const;
- static int hexDecode(const signed char c) A_WARN_UNUSED;
+ static unsigned int hexDecode(const signed char c) A_WARN_UNUSED;
private:
std::vector<DyeColor> mColors;
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 545a1cc4b..f5a3dc102 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -70,7 +70,7 @@ inline float fastSqrt(const float x) A_WARN_UNUSED;
constexpr inline float weightedAverage(const float n1, const float n2,
const float w) A_WARN_UNUSED;
constexpr inline int roundDouble(const double v) A_WARN_UNUSED;
-inline int powerOfTwo(const int input) A_WARN_UNUSED;
+inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED;
inline uint16_t getCrc16(const std::string &str)
{
@@ -123,9 +123,9 @@ constexpr inline int roundDouble(const double v)
return (v > 0.0) ? static_cast<int>(v + 0.5) : static_cast<int>(v - 0.5);
}
-inline int powerOfTwo(const int input)
+inline int powerOfTwo(const unsigned int input)
{
- int value = 1;
+ unsigned int value = 1;
while (value < input)
value <<= 1;
return value;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 224c2a8e8..f47f724a8 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(const int address)
+const char *ipToString(const uint32_t address)
{
static char asciiIP[18];
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 4a73b3e58..7cf924d98 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -90,7 +90,7 @@ std::string toStringPrint(const unsigned int val);
* @param address the address to convert to a string
* @return the string representation of the address
*/
-const char *ipToString(const int address) A_WARN_UNUSED;
+const char *ipToString(const uint32_t address) A_WARN_UNUSED;
/**
* A safe version of sprintf that returns a std::string of the result.