summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-08 22:48:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-08 22:48:11 +0300
commit767b8400fb086616616a298655f0bc2eaf239256 (patch)
tree9d82215887c79c596127506f50daf2ed31c23d8c
parentcd0de3bd2668294ab3174d3b5f032fefc25fa0e8 (diff)
downloadmv-767b8400fb086616616a298655f0bc2eaf239256.tar.gz
mv-767b8400fb086616616a298655f0bc2eaf239256.tar.bz2
mv-767b8400fb086616616a298655f0bc2eaf239256.tar.xz
mv-767b8400fb086616616a298655f0bc2eaf239256.zip
Fix code style in other files.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actormanager.cpp2
-rw-r--r--src/animatedsprite.cpp14
-rw-r--r--src/avatar.h10
-rw-r--r--src/beingequipbackend.cpp2
-rw-r--r--src/client.h47
-rw-r--r--src/game.cpp2
-rw-r--r--src/graphicsmanager.cpp11
-rw-r--r--src/graphicsvertexes.cpp18
-rw-r--r--src/input/keyboardconfig.cpp2
-rw-r--r--src/inventory.cpp4
-rw-r--r--src/item.cpp2
-rw-r--r--src/logger.cpp4
-rw-r--r--src/map.cpp20
-rw-r--r--src/maplayer.cpp8
-rw-r--r--src/particle/particle.cpp3
-rw-r--r--src/particle/particlecontainer.cpp10
-rw-r--r--src/simpleanimation.cpp2
-rw-r--r--src/spellmanager.cpp6
-rw-r--r--src/state.h71
-rw-r--r--src/test/testmain.cpp4
-rw-r--r--src/units.cpp2
23 files changed, 149 insertions, 99 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8cbfca3ba..2c8ddafc6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -637,6 +637,7 @@ SET(SRCS
commands.h
being/compoundsprite.cpp
being/compoundsprite.h
+ being/gender.h
listeners/configlistener.h
configuration.cpp
configuration.h
@@ -772,6 +773,7 @@ SET(SRCS
soundmanager.cpp
soundmanager.h
sprite.h
+ state.h
statuseffect.cpp
statuseffect.h
render/surfacegraphics.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index ef8c6da8e..5b21370cb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -723,6 +723,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
commands.h \
being/compoundsprite.cpp \
being/compoundsprite.h \
+ being/gender.h \
listeners/configlistener.h \
configuration.cpp \
configuration.h \
@@ -856,6 +857,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
soundmanager.cpp \
soundmanager.h \
sprite.h \
+ state.h \
statuseffect.cpp \
statuseffect.h \
render/surfacegraphics.cpp \
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 2d7c3a11b..2c36b972a 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1429,7 +1429,7 @@ void ActorManager::parseLevels(std::string levels) const
being->addToCache();
}
}
- f = static_cast<int>(pos + brkEnd.length());
+ f = static_cast<size_t>(pos + brkEnd.length());
pos = levels.find(brkEnd, f);
}
updatePlayerNames();
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index e1ca0a27d..e3ead0bf4 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -195,15 +195,15 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time)
mFrameTime += time;
- while ((mFrameTime > static_cast<unsigned>(mFrame->delay)
+ while ((mFrameTime > static_cast<unsigned int>(mFrame->delay)
&& mFrame->delay > 0) || (mFrame->type != Frame::ANIMATION
&& mFrame->type != Frame::PAUSE))
{
bool fail(true);
- mFrameTime -= static_cast<unsigned>(mFrame->delay);
+ mFrameTime -= static_cast<unsigned int>(mFrame->delay);
mFrameIndex++;
- if (mFrameIndex >= mAnimation->getLength())
+ if (mFrameIndex >= static_cast<unsigned int>(mAnimation->getLength()))
mFrameIndex = 0;
mFrame = &mAnimation->mFrames[mFrameIndex];
@@ -227,8 +227,11 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time)
&& mFrame->nextAction == frame->nextAction)
{
mFrameIndex = static_cast<unsigned int>(i);
- if (mFrameIndex >= mAnimation->getLength())
+ if (mFrameIndex >= static_cast<unsigned int>(
+ mAnimation->getLength()))
+ {
mFrameIndex = 0;
+ }
mFrame = &mAnimation->mFrames[mFrameIndex];
@@ -262,7 +265,8 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time)
}
else
{
- if (mFrame->rand == 100 || mFrameIndex >= mAnimation->getLength())
+ if (mFrame->rand == 100 || mFrameIndex
+ >= static_cast<unsigned int>(mAnimation->getLength()))
{
fail = false;
}
diff --git a/src/avatar.h b/src/avatar.h
index 60e68a948..f8f8d9941 100644
--- a/src/avatar.h
+++ b/src/avatar.h
@@ -23,10 +23,12 @@
#ifndef AVATAR_H
#define AVATAR_H
-#include "localconsts.h"
+#include "being/gender.h"
#include <string>
+#include "localconsts.h"
+
enum AvatarType
{
AVATAR_PLAYER = 0
@@ -154,10 +156,10 @@ public:
void setCharId(const int id)
{ mCharId = id; }
- int getGender() const A_WARN_UNUSED
+ Gender getGender() const A_WARN_UNUSED
{ return mGender; }
- void setGender(const int g)
+ void setGender(const Gender g)
{ mGender = g; }
int getRace() const A_WARN_UNUSED
@@ -192,7 +194,7 @@ protected:
int mY;
int mType;
int mExp;
- int mGender;
+ Gender mGender;
int mRace;
std::string mIp;
bool mOnline;
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
index 3f5f627a8..72d7f093a 100644
--- a/src/beingequipbackend.cpp
+++ b/src/beingequipbackend.cpp
@@ -36,7 +36,7 @@ BeingEquipBackend::BeingEquipBackend(Being *const being)
{
const size_t sz = being->mSpriteIDs.size();
- for (unsigned f = 0; f < sz; f ++)
+ for (size_t f = 0; f < sz; f ++)
{
const int idx = Net::getInventoryHandler()->
convertFromServerSlot(f);
diff --git a/src/client.h b/src/client.h
index a42334c36..25c5b943f 100644
--- a/src/client.h
+++ b/src/client.h
@@ -23,6 +23,8 @@
#ifndef CLIENT_H
#define CLIENT_H
+#include "state.h"
+
#include "listeners/configlistener.h"
#include "net/serverinfo.h"
@@ -67,51 +69,6 @@ extern std::string errorMessage;
extern ErrorListener errorListener;
extern LoginData loginData;
-/**
- * All client states.
- */
-enum State
-{
- STATE_ERROR = -1,
- STATE_START = 0,
- STATE_CHOOSE_SERVER,
- STATE_CONNECT_SERVER,
- STATE_PRE_LOGIN,
- STATE_LOGIN,
- STATE_LOGIN_ATTEMPT,
- STATE_WORLD_SELECT, // 5
- STATE_WORLD_SELECT_ATTEMPT,
- STATE_UPDATE,
- STATE_LOAD_DATA,
- STATE_GET_CHARACTERS,
- STATE_CHAR_SELECT, // 10
- STATE_CONNECT_GAME,
- STATE_GAME,
- STATE_CHANGE_MAP, // Switch map-server/gameserver
- STATE_LOGIN_ERROR,
- STATE_ACCOUNTCHANGE_ERROR, // 15
- STATE_REGISTER_PREP,
- STATE_REGISTER,
- STATE_REGISTER_ATTEMPT,
- STATE_CHANGEPASSWORD,
- STATE_CHANGEPASSWORD_ATTEMPT, // 20
- STATE_CHANGEPASSWORD_SUCCESS,
- STATE_CHANGEEMAIL,
- STATE_CHANGEEMAIL_ATTEMPT,
- STATE_CHANGEEMAIL_SUCCESS,
- STATE_UNREGISTER, // 25
- STATE_UNREGISTER_ATTEMPT,
- STATE_UNREGISTER_SUCCESS,
- STATE_SWITCH_SERVER,
- STATE_SWITCH_LOGIN,
- STATE_SWITCH_CHARACTER, // 30
- STATE_LOGOUT_ATTEMPT,
- STATE_WAIT,
- STATE_EXIT,
- STATE_FORCE_QUIT,
- STATE_AUTORECONNECT_SERVER = 1000
-};
-
enum PacketTypes
{
PACKET_CHAT = 0,
diff --git a/src/game.cpp b/src/game.cpp
index e4c72b5a9..211a4c2b6 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1088,7 +1088,7 @@ void Game::updateHistory(const SDL_Event &event)
if (!player_node || !player_node->getAttackType())
return;
- if (event.key.keysym.sym != -1)
+ if (static_cast<int>(event.key.keysym.sym) != -1)
{
bool old = false;
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 0770332d9..11db52974 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -217,7 +217,8 @@ int GraphicsManager::detectGraphics()
mode = RENDER_SOFTWARE;
}
- if (mode > 0 && findI(mGlVersionString, "Mesa") != std::string::npos)
+ if (mode != RENDER_SOFTWARE && findI(mGlVersionString, "Mesa")
+ != std::string::npos)
{
// Mesa detected. In latest Mesa look like compression broken.
config.setValue("compresstextures", false);
@@ -229,7 +230,8 @@ int GraphicsManager::detectGraphics()
config.write();
logger->log("detection complete");
- return mode | (1024 * textureSampler) | (2048 * compressTextures);
+ return static_cast<unsigned int>(mode)
+ | (1024 * textureSampler) | (2048 * compressTextures);
}
void GraphicsManager::initGraphics(const bool noOpenGL)
@@ -563,7 +565,8 @@ void GraphicsManager::updateTextureFormat() const
GLint num = 0;
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num);
logger->log("support %d compressed formats", num);
- GLint *const formats = new GLint[num > 10 ? num : 10];
+ GLint *const formats = new GLint[num > 10
+ ? static_cast<size_t>(num) : 10];
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
for (int f = 0; f < num; f ++)
logger->log(" 0x%x", formats[f]);
@@ -1061,7 +1064,7 @@ static CALLBACK void debugCallback(GLenum source, GLenum type, GLuint id,
message.append(" ?").append(toString(type));
break;
}
- char *const buf = new char[length + 1];
+ char *const buf = new char[static_cast<size_t>(length + 1)];
memcpy(buf, text, length);
buf[length] = 0;
message.append(" ").append(buf);
diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp
index f8de08c8f..f15a16d9a 100644
--- a/src/graphicsvertexes.cpp
+++ b/src/graphicsvertexes.cpp
@@ -116,28 +116,28 @@ void NormalOpenGLGraphicsVertexes::init()
GLfloat *NormalOpenGLGraphicsVertexes::switchFloatTexArray()
{
- mFloatTexArray = new GLfloat[vertexBufSize * 4 + 30];
+ mFloatTexArray = new GLfloat[static_cast<size_t>(vertexBufSize * 4 + 30)];
mFloatTexPool.push_back(mFloatTexArray);
return mFloatTexArray;
}
GLint *NormalOpenGLGraphicsVertexes::switchIntVertArray()
{
- mIntVertArray = new GLint[vertexBufSize * 4 + 30];
+ mIntVertArray = new GLint[static_cast<size_t>(vertexBufSize * 4 + 30)];
mIntVertPool.push_back(mIntVertArray);
return mIntVertArray;
}
GLshort *NormalOpenGLGraphicsVertexes::switchShortVertArray()
{
- mShortVertArray = new GLshort[vertexBufSize * 4 + 30];
+ mShortVertArray = new GLshort[static_cast<size_t>(vertexBufSize * 4 + 30)];
mShortVertPool.push_back(mShortVertArray);
return mShortVertArray;
}
GLint *NormalOpenGLGraphicsVertexes::switchIntTexArray()
{
- mIntTexArray = new GLint[vertexBufSize * 4 + 30];
+ mIntTexArray = new GLint[static_cast<size_t>(vertexBufSize * 4 + 30)];
mIntTexPool.push_back(mIntTexArray);
return mIntTexArray;
}
@@ -172,7 +172,8 @@ GLfloat *NormalOpenGLGraphicsVertexes::continueFloatTexArray()
{
if (mFloatTexPool.empty())
{
- mFloatTexArray = new GLfloat[vertexBufSize * 4 + 30];
+ mFloatTexArray = new GLfloat[static_cast<size_t>(
+ vertexBufSize * 4 + 30)];
mFloatTexPool.push_back(mFloatTexArray);
}
else
@@ -186,7 +187,7 @@ GLint *NormalOpenGLGraphicsVertexes::continueIntVertArray()
{
if (mIntVertPool.empty())
{
- mIntVertArray = new GLint[vertexBufSize * 4 + 30];
+ mIntVertArray = new GLint[static_cast<size_t>(vertexBufSize * 4 + 30)];
mIntVertPool.push_back(mIntVertArray);
}
else
@@ -200,7 +201,8 @@ GLshort *NormalOpenGLGraphicsVertexes::continueShortVertArray()
{
if (mShortVertPool.empty())
{
- mShortVertArray = new GLshort[vertexBufSize * 4 + 30];
+ mShortVertArray = new GLshort[static_cast<size_t>(
+ vertexBufSize * 4 + 30)];
mShortVertPool.push_back(mShortVertArray);
}
else
@@ -214,7 +216,7 @@ GLint *NormalOpenGLGraphicsVertexes::continueIntTexArray()
{
if (mIntTexPool.empty())
{
- mIntTexArray = new GLint[vertexBufSize * 4 + 30];
+ mIntTexArray = new GLint[static_cast<size_t>(vertexBufSize * 4 + 30)];
mIntTexPool.push_back(mIntTexArray);
}
else
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
index ee0254b69..8f1df687f 100644
--- a/src/input/keyboardconfig.cpp
+++ b/src/input/keyboardconfig.cpp
@@ -65,7 +65,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event)
return event.key.keysym.scancode;
#else
if (event.key.keysym.sym)
- return event.key.keysym.sym;
+ return static_cast<int>(event.key.keysym.sym);
else if (event.key.keysym.scancode > 1)
return -event.key.keysym.scancode;
return 0;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 6213b44c9..a7adc2289 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -182,7 +182,7 @@ int Inventory::getFreeSlot() const
{
Item **const i = std::find_if(mItems, mItems + mSize,
std::not1(SlotUsed()));
- return (i == mItems + static_cast<int>(mSize)) ? -1
+ return (i == mItems + mSize) ? -1
: static_cast<int>(i - mItems);
}
@@ -280,6 +280,6 @@ void Inventory::resize(const unsigned int newSize)
delete [] mItems;
mSize = newSize;
- mItems = new Item*[mSize];
+ mItems = new Item*[static_cast<size_t>(mSize)];
std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
}
diff --git a/src/item.cpp b/src/item.cpp
index 02c5d0c16..49a6bd7a6 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -71,7 +71,7 @@ void Item::setId(const int id, const unsigned char color)
mColor = color;
// Types 0 and 1 are not equippable items.
- mEquipment = id && getInfo().getType() >= 2;
+ mEquipment = id && static_cast<int>(getInfo().getType()) >= 2;
if (mImage)
mImage->decRef();
diff --git a/src/logger.cpp b/src/logger.cpp
index 21fea14d7..e6aeb0546 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -146,7 +146,7 @@ void Logger::log(const char *const log_text, ...)
if (strlen(log_text) * 3 > size)
size = static_cast<unsigned>(strlen(log_text) * 3);
- char* buf = new char[size + 1];
+ char* buf = new char[static_cast<size_t>(size + 1)];
va_list ap;
// Use a temporary buffer to fill in the variables
@@ -182,7 +182,7 @@ void Logger::log_r(const char *const log_text, ...)
if (strlen(log_text) * 3 > size)
size = static_cast<unsigned>(strlen(log_text) * 3);
- char* buf = new char[size + 1];
+ char* buf = new char[static_cast<size_t>(size + 1)];
va_list ap;
// Use a temporary buffer to fill in the variables
diff --git a/src/map.cpp b/src/map.cpp
index b4112231d..1acfdf711 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -183,8 +183,9 @@ Map::Map(const int width, const int height,
const int size = mWidth * mHeight;
for (int i = 0; i < NB_BLOCKTYPES; i++)
{
- mOccupation[i] = new unsigned[size];
- memset(mOccupation[i], 0, size * sizeof(unsigned));
+ mOccupation[i] = new unsigned[static_cast<size_t>(size)];
+ memset(mOccupation[i], 0, static_cast<size_t>(size)
+ * sizeof(unsigned));
}
config.addListener("OverlayDetail", this);
@@ -679,8 +680,8 @@ void Map::blockTile(const int x, const int y, const BlockType type)
const int tileNum = x + y * mWidth;
- if (mOccupation[type][tileNum] < UINT_MAX &&
- (++mOccupation[type][tileNum]) > 0)
+ if (mOccupation[static_cast<size_t>(type)][tileNum] < UINT_MAX &&
+ (++mOccupation[static_cast<size_t>(type)][tileNum]) > 0)
{
switch (type)
{
@@ -1296,8 +1297,8 @@ void Map::indexTilesets()
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
const size_t sz = (*it)->size();
- if (!s || s->getFirstGid() + sSz
- < (*it)->getFirstGid() + sz)
+ if (!s || static_cast<size_t>(s->getFirstGid()) + sSz
+ < static_cast<size_t>((*it)->getFirstGid()) + sz)
{
s = *it;
sSz = sz;
@@ -1313,7 +1314,7 @@ void Map::indexTilesets()
const int size = static_cast<int>(s->getFirstGid())
+ static_cast<int>(s->size());
mIndexedTilesetsSize = size;
- mIndexedTilesets = new Tileset*[size];
+ mIndexedTilesets = new Tileset*[static_cast<size_t>(size)];
std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr));
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
@@ -1322,7 +1323,7 @@ void Map::indexTilesets()
if (s2)
{
const int start = s2->getFirstGid();
- const int end = static_cast<int>(start + s2->size());
+ const int end = start + static_cast<int>(s2->size());
for (int f = start; f < end; f ++)
{
if (f < size)
@@ -1456,7 +1457,8 @@ void Map::reduce()
while (ri != mLayers.rend())
{
MapLayer *const layer2 = *ri;
- const size_t pos = x + y * layer2->mWidth;
+ const size_t pos = static_cast<size_t>(
+ x + y * layer2->mWidth);
img = layer2->mTiles[pos];
if (img)
{
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index bfecd90d8..97ecc4f93 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -121,7 +121,7 @@ void MapLayer::draw(Graphics *const graphics,
const int py0 = y32 + dy;
- Image **tilePtr = mTiles + startX + yWidth;
+ Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
for (int x = startX; x < endX; x++, tilePtr++)
{
@@ -217,7 +217,7 @@ void MapLayer::updateSDL(const Graphics *const graphics,
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- Image **tilePtr = mTiles + startX + yWidth;
+ Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
for (int x = startX; x < endX; x++, tilePtr++)
{
@@ -282,7 +282,7 @@ void MapLayer::updateOGL(const Graphics *const graphics,
{
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- Image **tilePtr = mTiles + startX + yWidth;
+ Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
for (int x = startX; x < endX; x++, tilePtr++)
{
Image *const img = *tilePtr;
@@ -437,7 +437,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
const int py0 = y32 + dy;
const int py1 = y32 - scrollY;
- Image **tilePtr = mTiles + startX + yWidth;
+ Image **tilePtr = mTiles + static_cast<size_t>(startX + yWidth);
for (int x = startX; x < endX; x++, tilePtr++)
{
const int x32 = x * mapTileSize;
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index c446fa177..d86edf584 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -217,7 +217,8 @@ bool Particle::update()
// create death effect when the particle died
if (mAlive != ALIVE && mAlive != DEAD_LONG_AGO)
{
- if ((mAlive & mDeathEffectConditions) > 0x00 && !mDeathEffect.empty())
+ if ((static_cast<unsigned int>(mAlive) & mDeathEffectConditions)
+ > 0x00 && !mDeathEffect.empty())
{
Particle *const deathEffect = particleEngine->addEffect(
mDeathEffect, 0, 0);
diff --git a/src/particle/particlecontainer.cpp b/src/particle/particlecontainer.cpp
index 07eb36dc4..52179bce8 100644
--- a/src/particle/particlecontainer.cpp
+++ b/src/particle/particlecontainer.cpp
@@ -144,7 +144,7 @@ void ParticleVector::setLocally(const int index, Particle *const particle)
delLocally(index);
- if (mIndexedElements.size() <= static_cast<unsigned>(index))
+ if (mIndexedElements.size() <= static_cast<size_t>(index))
mIndexedElements.resize(index + 1, nullptr);
if (particle)
@@ -157,7 +157,7 @@ void ParticleVector::delLocally(const int index)
if (index < 0)
return;
- if (mIndexedElements.size() <= static_cast<unsigned>(index))
+ if (mIndexedElements.size() <= static_cast<size_t>(index))
return;
Particle *const p = mIndexedElements[index];
@@ -170,8 +170,12 @@ void ParticleVector::delLocally(const int index)
void ParticleVector::clearLocally()
{
- for (unsigned int i = 0; i < mIndexedElements.size(); i++)
+ for (unsigned int i = 0;
+ i < static_cast<unsigned int>(mIndexedElements.size());
+ i++)
+ {
delLocally(i);
+ }
}
void ParticleVector::moveTo(const float x, const float y)
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index a2c765cb8..b067a6de6 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -118,7 +118,7 @@ bool SimpleAnimation::update(const int timePassed)
mAnimationTime -= mCurrentFrame->delay;
mAnimationPhase++;
- if (static_cast<unsigned>(mAnimationPhase) >= mAnimation->getLength())
+ if (static_cast<size_t>(mAnimationPhase) >= mAnimation->getLength())
mAnimationPhase = 0;
mCurrentFrame = &mAnimation->mFrames[mAnimationPhase];
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 0db577a48..aaf7ad302 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -52,7 +52,7 @@ SpellManager::~SpellManager()
TextCommand* SpellManager::getSpell(const int spellId) const
{
- if (spellId < 0 || static_cast<unsigned int>(spellId) >= mSpells.size())
+ if (spellId < 0 || static_cast<size_t>(spellId) >= mSpells.size())
return nullptr;
const std::map<unsigned int, TextCommand*>::const_iterator
@@ -142,8 +142,8 @@ void SpellManager::invoke(const int spellId) const
|| (Net::getPlayerHandler()->canUseMagic()
&& PlayerInfo::getSkillLevel(SKILL_MAGIC)
>= static_cast<signed>(spell->getBaseLvl())
- && PlayerInfo::getSkillLevel(
- spell->getSchool()) >= static_cast<signed>(spell->getSchoolLvl())
+ && PlayerInfo::getSkillLevel(static_cast<int>(
+ spell->getSchool())) >= static_cast<signed>(spell->getSchoolLvl())
&& PlayerInfo::getAttribute(PlayerInfo::MP) >= spell->getMana()))
{
const Being *const target = player_node->getTarget();
diff --git a/src/state.h b/src/state.h
new file mode 100644
index 000000000..381a68cd2
--- /dev/null
+++ b/src/state.h
@@ -0,0 +1,71 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef STATE_H
+#define STATE_H
+
+/**
+ * All client states.
+ */
+enum State
+{
+ STATE_ERROR = -1,
+ STATE_START = 0,
+ STATE_CHOOSE_SERVER,
+ STATE_CONNECT_SERVER,
+ STATE_PRE_LOGIN,
+ STATE_LOGIN,
+ STATE_LOGIN_ATTEMPT,
+ STATE_WORLD_SELECT, // 5
+ STATE_WORLD_SELECT_ATTEMPT,
+ STATE_UPDATE,
+ STATE_LOAD_DATA,
+ STATE_GET_CHARACTERS,
+ STATE_CHAR_SELECT, // 10
+ STATE_CONNECT_GAME,
+ STATE_GAME,
+ STATE_CHANGE_MAP, // Switch map-server/gameserver
+ STATE_LOGIN_ERROR,
+ STATE_ACCOUNTCHANGE_ERROR, // 15
+ STATE_REGISTER_PREP,
+ STATE_REGISTER,
+ STATE_REGISTER_ATTEMPT,
+ STATE_CHANGEPASSWORD,
+ STATE_CHANGEPASSWORD_ATTEMPT, // 20
+ STATE_CHANGEPASSWORD_SUCCESS,
+ STATE_CHANGEEMAIL,
+ STATE_CHANGEEMAIL_ATTEMPT,
+ STATE_CHANGEEMAIL_SUCCESS,
+ STATE_UNREGISTER, // 25
+ STATE_UNREGISTER_ATTEMPT,
+ STATE_UNREGISTER_SUCCESS,
+ STATE_SWITCH_SERVER,
+ STATE_SWITCH_LOGIN,
+ STATE_SWITCH_CHARACTER, // 30
+ STATE_LOGOUT_ATTEMPT,
+ STATE_WAIT,
+ STATE_EXIT,
+ STATE_FORCE_QUIT,
+ STATE_AUTORECONNECT_SERVER = 1000
+};
+
+#endif // STATE_H
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index cae4aa3b7..53703dbc6 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -96,7 +96,7 @@ int TestMain::exec(const bool testAudio)
if (testAudio)
soundTest = invokeTest4();
else
- soundTest = true;
+ soundTest = 1;
info.append(strprintf("%d.%d,%d,%d.", soundTest, softwareTest,
fastOpenGLTest, safeOpenGLTest));
@@ -204,7 +204,7 @@ int TestMain::exec(const bool testAudio)
if (!(detectMode & 15))
openGLMode = RENDER_SOFTWARE;
- writeConfig(openGLMode, rescaleTest[openGLMode],
+ writeConfig(openGLMode, rescaleTest[static_cast<size_t>(openGLMode)],
soundTest, info, batchSize, detectMode);
return 0;
}
diff --git a/src/units.cpp b/src/units.cpp
index ec4084126..63db99273 100644
--- a/src/units.cpp
+++ b/src/units.cpp
@@ -221,7 +221,7 @@ static std::string formatUnit(const int value, const int type)
if (ul.count)
levelAmount /= ul.count;
- amount -= levelAmount * ul.count;
+ amount -= static_cast<double>(levelAmount * ul.count);
if (amount > 0)
{