summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-17 23:26:59 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-17 23:26:59 +0300
commit7e0a97d2521b9ce57003176e82a0b5564aa003c2 (patch)
tree5b2cfe1afe09bea1063f783050c1fb549daee76d /src
parentf68cbf700a99f2f184715a5b8025bcb4b6525391 (diff)
downloadmv-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.gz
mv-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.bz2
mv-7e0a97d2521b9ce57003176e82a0b5564aa003c2.tar.xz
mv-7e0a97d2521b9ce57003176e82a0b5564aa003c2.zip
Fix more code style and additional warnings.
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp6
-rw-r--r--src/being.cpp8
-rw-r--r--src/being.h4
-rw-r--r--src/configuration.cpp9
-rw-r--r--src/dropshortcut.cpp5
-rw-r--r--src/dropshortcut.h6
-rw-r--r--src/graphics.cpp63
-rw-r--r--src/graphics.h24
-rw-r--r--src/gui/beingpopup.cpp2
-rw-r--r--src/gui/changeemaildialog.cpp4
-rw-r--r--src/gui/changepassworddialog.cpp4
-rw-r--r--src/gui/charcreatedialog.cpp7
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/gui/ministatuswindow.cpp20
-rw-r--r--src/gui/outfitwindow.cpp8
-rw-r--r--src/gui/outfitwindow.h2
-rw-r--r--src/gui/popupmenu.cpp7
-rw-r--r--src/gui/registerdialog.cpp8
-rw-r--r--src/gui/skilldialog.cpp9
-rw-r--r--src/gui/statuswindow.cpp37
-rw-r--r--src/gui/unregisterdialog.cpp4
-rw-r--r--src/gui/updaterwindow.cpp7
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp7
-rw-r--r--src/gui/widgets/setupitem.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/guichan/include/guichan/sdl/sdlpixel.hpp74
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp69
-rw-r--r--src/itemshortcut.cpp4
-rw-r--r--src/itemshortcut.h2
-rw-r--r--src/localplayer.cpp24
-rw-r--r--src/localplayer.h2
-rw-r--r--src/mumblemanager.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp10
-rw-r--r--src/net/ea/guildhandler.cpp2
-rw-r--r--src/net/ea/loginhandler.cpp2
-rw-r--r--src/net/ea/playerhandler.cpp119
-rw-r--r--src/net/ea/playerhandler.h4
-rw-r--r--src/net/ea/specialhandler.cpp6
-rw-r--r--src/net/messagein.cpp4
-rw-r--r--src/net/playerhandler.h5
-rw-r--r--src/net/tmwa/beinghandler.cpp6
-rw-r--r--src/net/tmwa/messagein.cpp2
-rw-r--r--src/net/tmwa/messageout.cpp4
-rw-r--r--src/net/tmwa/npchandler.cpp2
-rw-r--r--src/net/tmwa/partyhandler.cpp8
-rw-r--r--src/net/tmwa/tradehandler.cpp2
-rw-r--r--src/opengl1graphics.cpp10
-rw-r--r--src/opengl1graphics.h12
-rw-r--r--src/openglgraphics.cpp10
-rw-r--r--src/openglgraphics.h11
-rw-r--r--src/playerinfo.cpp36
-rw-r--r--src/playerinfo.h21
-rw-r--r--src/resources/dye.cpp5
-rw-r--r--src/resources/monsterdb.cpp3
-rw-r--r--src/resources/openglimagehelper.cpp6
-rw-r--r--src/resources/openglimagehelper.h2
-rw-r--r--src/resources/sdlimagehelper.cpp6
-rw-r--r--src/spellmanager.cpp16
-rw-r--r--src/textcommand.h8
-rw-r--r--src/utils/base64.cpp12
-rw-r--r--src/utils/stringutils.cpp4
62 files changed, 435 insertions, 342 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 8cdede262..9d933ad72 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -1136,8 +1136,10 @@ void ActorSpriteManager::heal(Being* target)
}
}
// magic levels < 2
- else if (PlayerInfo::getStatEffective(340) < 2
- || PlayerInfo::getStatEffective(341) < 2)
+ else if (PlayerInfo::getStatEffective(
+ static_cast<PlayerInfo::Attribute>(340)) < 2
+ || PlayerInfo::getStatEffective(
+ static_cast<PlayerInfo::Attribute>(341)) < 2)
{
if (PlayerInfo::getAttribute(PlayerInfo::MP) >= 6)
{
diff --git a/src/being.cpp b/src/being.cpp
index 2d276a72c..6f0ac307b 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -434,7 +434,7 @@ void Being::setDestination(int dstX, int dstY)
Path thisPath = mMap->findPixelPath(static_cast<int>(mPos.x),
static_cast<int>(mPos.y), dest.x, dest.y,
static_cast<int>(getCollisionRadius()),
- static_cast<int>(getWalkMask()));
+ static_cast<unsigned char>(getWalkMask()));
if (thisPath.empty())
{
@@ -1166,7 +1166,7 @@ void Being::setDirection(uint8_t direction)
{
dir = DIRECTION_LEFT;
}
- mSpriteDirection = dir;
+ mSpriteDirection = static_cast<uint8_t>(dir);
CompoundSprite::setSpriteDirection(dir);
recalcSpritesOrder();
@@ -2648,7 +2648,7 @@ void Being::updatePercentHP()
}
}
-int Being::genderToInt(Gender sex)
+uint8_t Being::genderToInt(Gender sex)
{
switch (sex)
{
@@ -2663,7 +2663,7 @@ int Being::genderToInt(Gender sex)
}
}
-Gender Being::intToGender(int sex)
+Gender Being::intToGender(uint8_t sex)
{
switch (sex)
{
diff --git a/src/being.h b/src/being.h
index f678e7f1d..1d9e1691d 100644
--- a/src/being.h
+++ b/src/being.h
@@ -787,9 +787,9 @@ class Being : public ActorSprite, public ConfigListener
int getSpriteID(int slot);
- static int genderToInt(Gender sex);
+ static uint8_t genderToInt(Gender sex);
- static Gender intToGender(int sex);
+ static Gender intToGender(uint8_t sex);
protected:
/**
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 684468997..defa38812 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -507,8 +507,9 @@ float Configuration::getFloatValue(const std::string &key) const
else if (itdef->second->getType()
== VariableData::DATA_STRING)
{
- defaultValue = atof((static_cast<StringData*>(
- itdef->second))->getData().c_str());
+ defaultValue = static_cast<float>(atof((
+ static_cast<StringData*>(
+ itdef->second))->getData().c_str()));
}
else if (itdef->second->getType()
== VariableData::DATA_BOOL)
@@ -526,8 +527,8 @@ float Configuration::getFloatValue(const std::string &key) const
else if (itdef->second->getType()
== VariableData::DATA_INT)
{
- defaultValue = (static_cast<IntData*>(
- itdef->second))->getData();
+ defaultValue = static_cast<float>((static_cast<IntData*>(
+ itdef->second))->getData());
}
}
else
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index fc370d47f..b0202f04d 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -64,7 +64,8 @@ void DropShortcut::load(bool oldConfig)
for (int i = 0; i < DROP_SHORTCUT_ITEMS; i++)
{
int itemId = cfg->getValue("drop" + toString(i), -1);
- int itemColor = cfg->getValue("dropColor" + toString(i), -1);
+ unsigned char itemColor = static_cast<unsigned char>(
+ cfg->getValue("dropColor" + toString(i), -1));
if (itemId != -1)
{
@@ -102,7 +103,7 @@ void DropShortcut::dropFirst()
return;
const int itemId = getItem(0);
- const int itemColor = getItemColor(0);
+ const unsigned char itemColor = getItemColor(0);
if (itemId > 0)
{
diff --git a/src/dropshortcut.h b/src/dropshortcut.h
index ea11f34e0..b9a8db7c7 100644
--- a/src/dropshortcut.h
+++ b/src/dropshortcut.h
@@ -61,7 +61,7 @@ class DropShortcut
int getItem(int index) const
{ return mItems[index]; }
- int getItemColor(int index) const
+ unsigned char getItemColor(int index) const
{ return mItemColors[index]; }
/**
@@ -151,9 +151,9 @@ class DropShortcut
bool dropItem(int cnt = 1);
int mItems[DROP_SHORTCUT_ITEMS];
- int mItemColors[DROP_SHORTCUT_ITEMS];
+ unsigned char mItemColors[DROP_SHORTCUT_ITEMS];
int mItemSelected;
- int mItemColorSelected;
+ unsigned char mItemColorSelected;
int mLastDropIndex;
};
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 0ccfd706c..43e73f236 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -266,8 +266,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs,
if (!(mTarget = SDL_SetVideoMode(w, h, bpp, getSoftwareFlags())))
return false;
- mRect.w = mTarget->w;
- mRect.h = mTarget->h;
+ mRect.w = static_cast<uint16_t>(mTarget->w);
+ mRect.h = static_cast<uint16_t>(mTarget->h);
return videoInfo();
}
@@ -365,7 +365,7 @@ bool Graphics::drawImage(const Image *image, int x, int y)
{
if (image)
{
- return drawImage(image, 0, 0, x, y,
+ return drawImage2(image, 0, 0, x, y,
image->mBounds.w, image->mBounds.h, false);
}
else
@@ -418,8 +418,8 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
return returnValue;
}
-bool Graphics::drawImage(const Image *image, int srcX, int srcY,
- int dstX, int dstY, int width, int height, bool)
+bool Graphics::drawImage2(const Image *image, int srcX, int srcY,
+ int dstX, int dstY, int width, int height, bool)
{
// Check that preconditions for blitting are met.
if (!mTarget || !image || !image->mSDLSurface)
@@ -903,7 +903,7 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (srcx < 0)
{
w += srcx;
- dstrect->x -= srcx;
+ dstrect->x -= static_cast<int16_t>(srcx);
srcx = 0;
}
maxw = src->w - srcx;
@@ -915,7 +915,7 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (srcy < 0)
{
h += srcy;
- dstrect->y -= srcy;
+ dstrect->y -= static_cast<int16_t>(srcy);
srcy = 0;
}
maxh = src->h - srcy;
@@ -939,7 +939,7 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (dx > 0)
{
w -= dx;
- dstrect->x += dx;
+ dstrect->x += static_cast<int16_t>(dx);
srcx += dx;
}
dx = dstrect->x + w - clip->x - clip->w;
@@ -950,7 +950,7 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (dy > 0)
{
h -= dy;
- dstrect->y += dy;
+ dstrect->y += static_cast<int16_t>(dy);
srcy += dy;
}
dy = dstrect->y + h - clip->y - clip->h;
@@ -960,10 +960,12 @@ int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect,
if (w > 0 && h > 0)
{
- srcrect->x = srcx;
- srcrect->y = srcy;
- srcrect->w = dstrect->w = w;
- srcrect->h = dstrect->h = h;
+ srcrect->x = static_cast<int16_t>(srcx);
+ srcrect->y = static_cast<int16_t>(srcy);
+ srcrect->w = static_cast<int16_t>(w);
+ dstrect->w = static_cast<int16_t>(w);
+ srcrect->h = static_cast<int16_t>(h);
+ dstrect->h = static_cast<int16_t>(h);
return 1;
// return SDL_LowerBlit(src, &sr, dst, dstrect);
@@ -1000,7 +1002,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
const int bpp = mTarget->format->BytesPerPixel;
uint32_t pixel = SDL_MapRGB(mTarget->format,
- mColor.r, mColor.g, mColor.b);
+ static_cast<uint8_t>(mColor.r), static_cast<uint8_t>(mColor.g),
+ static_cast<uint8_t>(mColor.b));
switch (bpp)
{
@@ -1010,7 +1013,7 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
uint8_t *p = static_cast<uint8_t *>(mTarget->pixels)
+ y * mTarget->pitch;
for (x = x1; x < x2; x++)
- *(p + x) = pixel;
+ *(p + x) = static_cast<uint8_t>(pixel);
}
break;
case 2:
@@ -1022,8 +1025,9 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
{
uint8_t *p = p0 + x * 2;
*reinterpret_cast<uint16_t *>(p) = gcn::SDLAlpha16(
- pixel, *reinterpret_cast<uint32_t *>(p),
- mColor.a, mTarget->format);
+ static_cast<uint16_t>(pixel),
+ *reinterpret_cast<uint16_t *>(p),
+ static_cast<uint8_t>(mColor.a), mTarget->format);
}
}
break;
@@ -1042,13 +1046,13 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
{
uint8_t *p = p0 + x * 3;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = (p[2] * ca + cb) >> 8;
- p[1] = (p[1] * ca + cg) >> 8;
- p[0] = (p[0] * ca + cr) >> 8;
+ p[2] = static_cast<uint8_t>((p[2] * ca + cb) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * ca + cg) >> 8);
+ p[0] = static_cast<uint8_t>((p[0] * ca + cr) >> 8);
#else
- p[0] = (p[0] * ca + cb) >> 8;
- p[1] = (p[1] * ca + cg) >> 8;
- p[2] = (p[2] * ca + cr) >> 8;
+ p[0] = static_cast<uint8_t>((p[0] * ca + cb) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * ca + cg) >> 8);
+ p[2] = static_cast<uint8_t>((p[2] * ca + cr) >> 8);
#endif
}
}
@@ -1135,13 +1139,16 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle)
else
{
SDL_Rect rect;
- rect.x = area.x;
- rect.y = area.y;
- rect.w = area.width;
- rect.h = area.height;
+ rect.x = static_cast<int16_t>(area.x);
+ rect.y = static_cast<int16_t>(area.y);
+ rect.w = static_cast<uint16_t>(area.width);
+ rect.h = static_cast<uint16_t>(area.height);
uint32_t color = SDL_MapRGBA(mTarget->format,
- mColor.r, mColor.g, mColor.b, mColor.a);
+ static_cast<int8_t>(mColor.r),
+ static_cast<int8_t>(mColor.g),
+ static_cast<int8_t>(mColor.b),
+ static_cast<int8_t>(mColor.a));
SDL_FillRect(mTarget, &rect, color);
}
}
diff --git a/src/graphics.h b/src/graphics.h
index ffa9a3c73..06461efe4 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -150,17 +150,6 @@ class Graphics : public gcn::SDLGraphics
int desiredWidth, int desiredHeight,
bool useColor = false);
- /**
- * Blits an image onto the screen.
- *
- * @return <code>true</code> if the image was blitted properly
- * <code>false</code> otherwise.
- */
- virtual bool drawImage(const Image *image,
- int srcX, int srcY,
- int dstX, int dstY,
- int width, int height,
- bool useColor);
virtual void drawImagePattern(const Image *image,
int x, int y,
@@ -306,6 +295,19 @@ class Graphics : public gcn::SDLGraphics
int mHeight;
protected:
+ /**
+ * Blits an image onto the screen.
+ *
+ * @return <code>true</code> if the image was blitted properly
+ * <code>false</code> otherwise.
+ */
+ virtual bool drawImage2(const Image *image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height,
+ bool useColor);
+
+
void setMainFlags(int w, int h, int bpp, bool fs,
bool hwaccel, bool resize, bool noFrame);
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 879b50245..ad019e9a6 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -149,7 +149,7 @@ void BeingPopup::show(int x, int y, Being *b)
if (b->getPvpRank() > 0)
{
- label3->setCaption(strprintf(_("Pvp rank: %d"), b->getPvpRank()));
+ label3->setCaption(strprintf(_("Pvp rank: %u"), b->getPvpRank()));
label3->adjustSize();
}
else
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 125266b9a..47fc27a92 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -130,14 +130,14 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
// First email address too short
errorMsg << strprintf(_("The new email address needs to be at "
- "least %d characters long."), min);
+ "least %u characters long."), min);
error = 1;
}
else if (newFirstEmail.length() > max - 1 )
{
// First email address too long
errorMsg << strprintf(_("The new email address needs to be "
- "less than %d characters long."), max);
+ "less than %u characters long."), max);
error = 1;
}
else if (newFirstEmail != newSecondEmail)
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 5f233df77..657bf8fd9 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -118,14 +118,14 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
{
// First password too short
errorMsg << strprintf(_("The new password needs to be at least"
- " %d characters long."), min);
+ " %u characters long."), min);
error = 2;
}
else if (newFirstPass.length() > max - 1 )
{
// First password too long
errorMsg << strprintf(_("The new password needs to be less "
- "than %d characters long."), max);
+ "than %u characters long."), max);
error = 2;
}
else if (newFirstPass != newSecondPass)
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 5611efa4c..b71b812d2 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -63,7 +63,7 @@ const static Being::Action actions[] =
Being::STAND, Being::SIT, Being::MOVE, Being::ATTACK, Being::DEAD
};
-const static int directions[] =
+const static uint8_t directions[] =
{
Being::DOWN, Being::RIGHT, Being::UP, Being::LEFT
};
@@ -282,7 +282,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
#endif
Net::getCharHandler()->newCharacter(getName(), characterSlot,
- mFemale->isSelected(), mHairStyle, mHairColor, mRace, atts);
+ mFemale->isSelected(), mHairStyle, mHairColor,
+ static_cast<uint16_t>(mRace), atts);
}
else
{
@@ -543,7 +544,7 @@ void CharCreateDialog::updateRace()
mRace = -100 - id;
}
- mPlayer->setSubtype(mRace);
+ mPlayer->setSubtype(static_cast<uint16_t>(mRace));
const ItemInfo &item = ItemDB::get(id);
mRaceNameLabel->setCaption(item.getName());
mRaceNameLabel->adjustSize();
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 1ea40a207..fc30fbc04 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -961,7 +961,8 @@ void ChatWindow::processEvent(Channels channel, const DepricatedEvent &event)
if (id == Net::getPlayerHandler()->getJobLocation())
{
std::pair<int, int> exp
- = PlayerInfo::getStatExperience(id);
+ = PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(id));
if (event.getInt("oldValue1") > exp.first
|| !event.getInt("oldValue2"))
{
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 54ededd41..cc374d386 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -297,17 +297,17 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
> PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED))
{
mTextPopup->show(x + getX(), y + getY(),
- event.getSource()->getId(), strprintf("%u/%u",
+ event.getSource()->getId(), strprintf("%d/%d",
PlayerInfo::getAttribute(PlayerInfo::EXP),
PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)));
}
else
{
mTextPopup->show(x + getX(), y + getY(),
- event.getSource()->getId(), strprintf("%u/%u",
+ event.getSource()->getId(), strprintf("%d/%d",
PlayerInfo::getAttribute(PlayerInfo::EXP),
PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)),
- strprintf("%s: %u", _("Need"),
+ strprintf("%s: %d", _("Need"),
PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)
- PlayerInfo::getAttribute(PlayerInfo::EXP)));
}
@@ -316,14 +316,14 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
else if (event.getSource() == mHpBar)
{
mTextPopup->show(x + getX(), y + getY(), event.getSource()->getId(),
- strprintf("%u/%u", PlayerInfo::getAttribute(PlayerInfo::HP),
+ strprintf("%d/%d", PlayerInfo::getAttribute(PlayerInfo::HP),
PlayerInfo::getAttribute(PlayerInfo::MAX_HP)));
mStatusPopup->hide();
}
else if (event.getSource() == mMpBar)
{
mTextPopup->show(x + getX(), y + getY(), event.getSource()->getId(),
- strprintf("%u/%u", PlayerInfo::getAttribute(PlayerInfo::MP),
+ strprintf("%d/%d", PlayerInfo::getAttribute(PlayerInfo::MP),
PlayerInfo::getAttribute(PlayerInfo::MAX_MP)));
mStatusPopup->hide();
}
@@ -336,21 +336,21 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
{
mTextPopup->show(x + getX(), y + getY(),
event.getSource()->getId(),
- strprintf("%u/%u", exp.first, exp.second));
+ strprintf("%d/%d", exp.first, exp.second));
}
else
{
mTextPopup->show(x + getX(), y + getY(),
event.getSource()->getId(),
- strprintf("%u/%u", exp.first, exp.second),
- strprintf("%s: %u", _("Need"), exp.second - exp.first));
+ strprintf("%d/%d", exp.first, exp.second),
+ strprintf("%s: %d", _("Need"), exp.second - exp.first));
}
mStatusPopup->hide();
}
else if (event.getSource() == mWeightBar)
{
mTextPopup->show(x + getX(), y + getY(), event.getSource()->getId(),
- strprintf("%u/%u", PlayerInfo::getAttribute(
+ strprintf("%d/%d", PlayerInfo::getAttribute(
PlayerInfo::TOTAL_WEIGHT),
PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT)));
mStatusPopup->hide();
@@ -365,7 +365,7 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
mTextPopup->show(x + getX(), y + getY(),
event.getSource()->getId(),
- strprintf("%u/%u", usedSlots, maxSlots));
+ strprintf("%d/%d", usedSlots, maxSlots));
}
mStatusPopup->hide();
}
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index eaf511a17..277ef904a 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -142,10 +142,10 @@ void OutfitWindow::load(bool oldConfig)
std::string buf;
std::stringstream ss(outfit);
- std::vector<int> tokens;
+ std::vector<unsigned char> tokens;
while (ss >> buf)
- tokens.push_back(atoi(buf.c_str()));
+ tokens.push_back(static_cast<unsigned char>(atoi(buf.c_str())));
for (int i = 0; i < static_cast<int>(tokens.size())
&& i < OUTFIT_ITEM_COUNT; i++)
@@ -160,7 +160,7 @@ void OutfitWindow::load(bool oldConfig)
tokens.clear();
while (ss2 >> buf)
- tokens.push_back(atoi(buf.c_str()));
+ tokens.push_back(static_cast<unsigned char>(atoi(buf.c_str())));
for (int i = 0; i < static_cast<int>(tokens.size())
&& i < OUTFIT_ITEM_COUNT; i++)
@@ -373,7 +373,7 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
return;
}
const int itemId = mItems[mCurrentOutfit][index];
- const int itemColor = mItemColors[mCurrentOutfit][index];
+ const unsigned char itemColor = mItemColors[mCurrentOutfit][index];
if (itemId < 0)
{
Window::mouseDragged(event);
diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h
index 6881bdbc6..2ce281b45 100644
--- a/src/gui/outfitwindow.h
+++ b/src/gui/outfitwindow.h
@@ -129,7 +129,7 @@ class OutfitWindow : public Window, gcn::ActionListener
unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
bool mItemsUnequip[OUTFITS_COUNT];
int mItemSelected;
- int mItemColorSelected;
+ unsigned char mItemColorSelected;
int mCurrentOutfit;
int mAwayOutfit;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index c8351914f..2df651ab1 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -276,14 +276,15 @@ void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings)
if (being && !being->getName().empty())
{
mBrowserBox->addRow(strprintf("@@player_%u|%s >@@",
- being->getId(), (being->getName()
+ static_cast<unsigned>(being->getId()), (being->getName()
+ being->getGenderSignWithSpace()).c_str()));
}
else if (actor->getType() == ActorSprite::FLOOR_ITEM)
{
FloorItem *floorItem = static_cast<FloorItem*>(actor);
mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@",
- actor->getId(), floorItem->getName().c_str()));
+ static_cast<unsigned>(actor->getId()),
+ floorItem->getName().c_str()));
}
}
mBrowserBox->addRow("##3---");
@@ -648,7 +649,7 @@ void PopupMenu::showChangePos(int x, int y)
for (PositionsMap::const_iterator itr = map.begin(),
itr_end = map.end(); itr != itr_end; ++itr)
{
- mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@",
+ mBrowserBox->addRow(strprintf("@@guild-pos-%u|%s@@",
itr->first, itr->second.c_str()));
}
mBrowserBox->addRow("cancel", _("Cancel"));
diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp
index 895d841b6..988d4c718 100644
--- a/src/gui/registerdialog.cpp
+++ b/src/gui/registerdialog.cpp
@@ -184,7 +184,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
{
// Name too short
errorMsg = strprintf
- (_("The username needs to be at least %d characters long."),
+ (_("The username needs to be at least %u characters long."),
minUser);
error = 1;
}
@@ -192,7 +192,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
{
// Name too long
errorMsg = strprintf
- (_("The username needs to be less than %d characters long."),
+ (_("The username needs to be less than %u characters long."),
maxUser);
error = 1;
}
@@ -200,7 +200,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
{
// Pass too short
errorMsg = strprintf
- (_("The password needs to be at least %d characters long."),
+ (_("The password needs to be at least %u characters long."),
minPass);
error = 2;
}
@@ -208,7 +208,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
{
// Pass too long
errorMsg = strprintf
- (_("The password needs to be less than %d characters long."),
+ (_("The password needs to be less than %u characters long."),
maxPass);
error = 2;
}
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 47de3b381..aa8ea716f 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -561,10 +561,13 @@ void SkillInfo::setIcon(const std::string &iconPath)
void SkillInfo::update()
{
- int baseLevel = PlayerInfo::getStatBase(id);
- int effLevel = PlayerInfo::getStatEffective(id);
+ int baseLevel = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(id));
+ int effLevel = PlayerInfo::getStatEffective(
+ static_cast<PlayerInfo::Attribute>(id));
- std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(id));
if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
{
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 267bd9cfc..73d95c54b 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -360,11 +360,12 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
if (mJobLvlLabel)
{
- int lvl = PlayerInfo::getStatBase(id);
+ int lvl = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(id));
int oldExp = event.getInt("oldValue1");
- std::pair<int, int> exp
- = PlayerInfo::getStatExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(id));
if (!lvl)
{
@@ -378,7 +379,8 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
{
lvl = (exp.second - 20000) / 150;
blocked = true;
- PlayerInfo::setStatBase(id, lvl);
+ PlayerInfo::setStatBase(
+ static_cast<PlayerInfo::Attribute>(id), lvl);
blocked = false;
}
}
@@ -389,8 +391,10 @@ void StatusWindow::processEvent(Channels channel A_UNUSED,
lvl ++;
blocked = true;
PlayerInfo::setStatExperience(
- id, exp.first, 20000 + lvl * 150);
- PlayerInfo::setStatBase(id, lvl);
+ static_cast<PlayerInfo::Attribute>(id),
+ exp.first, 20000 + lvl * 150);
+ PlayerInfo::setStatBase(
+ static_cast<PlayerInfo::Attribute>(id), lvl);
blocked = false;
}
@@ -573,7 +577,8 @@ void StatusWindow::updateJobBar(ProgressBar *bar, bool percent)
void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent)
{
- std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(id));
updateProgressBar(bar, exp.first, exp.second, percent);
}
@@ -758,8 +763,10 @@ AttrDisplay::~AttrDisplay()
std::string AttrDisplay::update()
{
- int base = PlayerInfo::getStatBase(mId);
- int bonus = PlayerInfo::getStatMod(mId);
+ int base = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(mId));
+ int bonus = PlayerInfo::getStatMod(
+ static_cast<PlayerInfo::Attribute>(mId));
std::string value = toString(base + bonus);
if (bonus)
value += strprintf("=%d%+d", base, bonus);
@@ -845,8 +852,10 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) + 1;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- int newbase = PlayerInfo::getStatBase(mId) - 1;
- PlayerInfo::setStatBase(mId, newbase);
+ int newbase = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(mId)) - 1;
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ mId), newbase);
Net::getPlayerHandler()->decreaseAttribute(mId);
}
@@ -864,8 +873,10 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
PlayerInfo::CHAR_POINTS) - cnt;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints);
- int newbase = PlayerInfo::getStatBase(mId) + cnt;
- PlayerInfo::setStatBase(mId, newbase);
+ int newbase = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(mId)) + cnt;
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ mId), newbase);
for (unsigned f = 0; f < mInc->getClickCount(); f ++)
{
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index 6887ffbb8..e2aa24321 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -118,7 +118,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
if (password.length() < min)
{
// Pass too short
- errorMsg << strprintf(_("The password needs to be at least %d "
+ errorMsg << strprintf(_("The password needs to be at least %u "
"characters long."), min);
error = true;
}
@@ -126,7 +126,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
{
// Pass too long
errorMsg << strprintf(_("The password needs to be less than "
- "%d characters long."), max);
+ "%u characters long."), max);
error = true;
}
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 43185b418..154594e60 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -615,9 +615,10 @@ void UpdaterWindow::logic()
mProgressBar->setProgress(mDownloadProgress);
if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size())
{
- mProgressBar->setText(strprintf("%d/%d", mUpdateIndex
- + mUpdateIndexOffset + 1, static_cast<int>(mUpdateFiles.size())
- + static_cast<int>(mTempUpdateFiles.size()) + 1));
+ mProgressBar->setText(strprintf("%u/%u", mUpdateIndex
+ + mUpdateIndexOffset + 1, static_cast<unsigned>(
+ mUpdateFiles.size()) + static_cast<int>(
+ mTempUpdateFiles.size()) + 1));
}
else
{
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index d6d31871b..fca1af17f 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -185,7 +185,7 @@ void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event)
return;
const int itemId = dropShortcut->getItem(index);
- const int itemColor = dropShortcut->getItemColor(index);
+ const unsigned char itemColor = dropShortcut->getItemColor(index);
if (itemId < 0)
return;
@@ -288,7 +288,7 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event)
return;
const int itemId = dropShortcut->getItem(index);
- const int itemColor = dropShortcut->getItemColor(index);
+ const unsigned char itemColor = dropShortcut->getItemColor(index);
if (itemId < 0)
return;
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 714435d21..735cea43d 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -140,7 +140,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
const int itemId = itemShortcut[mNumber]->getItem(i);
- const int itemColor = itemShortcut[mNumber]->getItemColor(i);
+ const unsigned char itemColor = itemShortcut[mNumber]->getItemColor(i);
if (itemId < 0)
continue;
@@ -245,7 +245,8 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
return;
const int itemId = itemShortcut[mNumber]->getItem(index);
- const int itemColor = itemShortcut[mNumber]->getItemColor(index);
+ const unsigned char itemColor = itemShortcut[mNumber]->
+ getItemColor(index);
if (itemId < 0)
return;
@@ -365,7 +366,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
return;
const int itemId = itemShortcut[mNumber]->getItem(index);
- const int itemColor = itemShortcut[mNumber]->getItemColor(index);
+ const unsigned char itemColor = itemShortcut[mNumber]->getItemColor(index);
if (itemId < 0)
return;
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 7f539d79f..bbc809747 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -848,7 +848,7 @@ void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED)
void SetupItemSlider2::updateLabel()
{
- int val = mSlider->getValue() - mMin;
+ int val = static_cast<int>(mSlider->getValue()) - mMin;
if (val < 0)
val = 0;
else if (val >= static_cast<signed>(mValues->size()))
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 8f543e3bf..3d106f9a2 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -174,7 +174,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
if ((val >= '0' && val <= '9') || (val == '-' && !mCaretPosition))
{
char buf[2];
- buf[0] = val;
+ buf[0] = static_cast<char>(val);
buf[1] = 0;
mText.insert(mCaretPosition, std::string(buf));
mCaretPosition += 1;
diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp
index 23298ef37..0aaa3c5fb 100644
--- a/src/guichan/include/guichan/sdl/sdlpixel.hpp
+++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp
@@ -1,4 +1,4 @@
-/* _______ __ __ __ ______ __ __ _______ __ __
+/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
@@ -68,7 +68,7 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
unsigned int color = 0;
@@ -124,33 +124,35 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
- Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
+ Uint32 pixel = SDL_MapRGB(surface->format,
+ static_cast<uint8_t>(color.r), static_cast<uint8_t>(color.g),
+ static_cast<uint8_t>(color.b));
switch (bpp)
{
case 1:
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
break;
case 2:
- *reinterpret_cast<Uint16*>(p) = pixel;
+ *reinterpret_cast<uint16_t*>(p) = static_cast<uint16_t>(pixel);
break;
case 3:
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
- p[0] = (pixel >> 16) & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = pixel & 0xff;
+ p[0] = static_cast<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel) & 0xff);
}
else
{
- p[0] = pixel & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = (pixel >> 16) & 0xff;
+ p[0] = static_cast<uint8_t>((pixel) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
}
break;
@@ -232,54 +234,50 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ Uint8 *p = static_cast<uint8_t*>(surface->pixels)
+ y * surface->pitch + x * bpp;
- Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
+ Uint32 pixel = SDL_MapRGB(surface->format, static_cast<uint8_t>(color.r),
+ static_cast<uint8_t>(color.g), static_cast<uint8_t>(color.b));
switch (bpp)
{
case 1:
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
break;
case 2:
- *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel,
- *reinterpret_cast<Uint32*>(p), color.a, surface->format);
+ *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
+ static_cast<unsigned short>(pixel),
+ *reinterpret_cast<unsigned short*>(p),
+ static_cast<unsigned char>(color.a), surface->format);
break;
case 3:
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
- unsigned int r = (p[0] * (255 - color.a)
- + color.r * color.a) >> 8;
- unsigned int g = (p[1] * (255 - color.a)
- + color.g * color.a) >> 8;
- unsigned int b = (p[2] * (255 - color.a)
- + color.b * color.a) >> 8;
-
- p[2] = b;
- p[1] = g;
- p[0] = r;
+ p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
+ + color.r * color.a) >> 8);
}
else
{
- unsigned int r = (p[2] * (255 - color.a)
- + color.r * color.a) >> 8;
- unsigned int g = (p[1] * (255 - color.a)
- + color.g * color.a) >> 8;
- unsigned int b = (p[0] * (255 - color.a)
- + color.b * color.a) >> 8;
-
- p[0] = b;
- p[1] = g;
- p[2] = r;
+ p[0] = static_cast<uint8_t>((p[0] * (255 - color.a)
+ + color.b * color.a) >> 8);
+ p[1] = static_cast<uint8_t>((p[1] * (255 - color.a)
+ + color.g * color.a) >> 8);
+ p[2] = static_cast<uint8_t>((p[2] * (255 - color.a)
+ + color.r * color.a) >> 8);
}
break;
case 4:
*reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<Uint32*>(p), color.a);
+ *reinterpret_cast<Uint32*>(p),
+ static_cast<unsigned char>(color.a));
break;
default:
break;
diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp
index e50017c38..0be0bfe59 100644
--- a/src/guichan/sdl/sdlgraphics.cpp
+++ b/src/guichan/sdl/sdlgraphics.cpp
@@ -97,10 +97,10 @@ namespace gcn
bool result = Graphics::pushClipArea(area);
const ClipRectangle& carea = mClipStack.top();
- rect.x = carea.x;
- rect.y = carea.y;
- rect.w = carea.width;
- rect.h = carea.height;
+ rect.x = static_cast<int16_t>(carea.x);
+ rect.y = static_cast<int16_t>(carea.y);
+ rect.w = static_cast<int16_t>(carea.width);
+ rect.h = static_cast<int16_t>(carea.height);
SDL_SetClipRect(mTarget, &rect);
@@ -116,10 +116,10 @@ namespace gcn
const ClipRectangle& carea = mClipStack.top();
SDL_Rect rect;
- rect.x = carea.x;
- rect.y = carea.y;
- rect.w = carea.width;
- rect.h = carea.height;
+ rect.x = static_cast<int16_t>(carea.x);
+ rect.y = static_cast<int16_t>(carea.y);
+ rect.w = static_cast<int16_t>(carea.width);
+ rect.h = static_cast<int16_t>(carea.height);
SDL_SetClipRect(mTarget, &rect);
}
@@ -213,21 +213,21 @@ namespace gcn
+ y * mTarget->pitch + x1 * bpp;
uint32_t pixel = SDL_MapRGB(mTarget->format,
- mColor.r,
- mColor.g,
- mColor.b);
+ static_cast<uint8_t>(mColor.r),
+ static_cast<uint8_t>(mColor.g),
+ static_cast<uint8_t>(mColor.b));
switch (bpp)
{
case 1:
for (; x1 <= x2; ++x1)
- *(p++) = pixel;
+ *(p++) = static_cast<uint8_t>(pixel);
break;
case 2:
{
uint16_t* q = reinterpret_cast<uint16_t*>(p);
for (; x1 <= x2; ++x1)
- *(q++) = pixel;
+ *(q++) = static_cast<uint8_t>(pixel);
break;
}
@@ -236,9 +236,9 @@ namespace gcn
{
for (; x1 <= x2; ++x1)
{
- p[0] = (pixel >> 16) & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = pixel & 0xff;
+ p[0] = static_cast<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>(pixel & 0xff);
p += 3;
}
}
@@ -246,9 +246,9 @@ namespace gcn
{
for (; x1 <= x2; ++x1)
{
- p[0] = pixel & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = (pixel >> 16) & 0xff;
+ p[0] = static_cast<uint8_t>(pixel & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
p += 3;
}
}
@@ -261,12 +261,13 @@ namespace gcn
{
if (mAlpha)
{
- *q = SDLAlpha32(pixel, *q, mColor.a);
+ *q = SDLAlpha32(pixel, *q,
+ static_cast<unsigned char>(mColor.a));
q++;
}
else
{
- *(q++) = pixel;
+ *(q++) = static_cast<uint8_t>(pixel);
}
}
break;
@@ -325,15 +326,17 @@ namespace gcn
uint8_t *p = static_cast<uint8_t*>(mTarget->pixels)
+ y1 * mTarget->pitch + x * bpp;
- uint32_t pixel = SDL_MapRGB(mTarget->format, mColor.r,
- mColor.g, mColor.b);
+ uint32_t pixel = SDL_MapRGB(mTarget->format,
+ static_cast<uint8_t>(mColor.r),
+ static_cast<uint8_t>(mColor.g),
+ static_cast<uint8_t>(mColor.b));
switch (bpp)
{
case 1:
for (; y1 <= y2; ++y1)
{
- *p = pixel;
+ *p = static_cast<uint8_t>(pixel);
p += mTarget->pitch;
}
break;
@@ -341,7 +344,8 @@ namespace gcn
case 2:
for (; y1 <= y2; ++ y1)
{
- *reinterpret_cast<uint16_t*>(p) = pixel;
+ *reinterpret_cast<uint16_t*>(p)
+ = static_cast<uint16_t>(pixel);
p += mTarget->pitch;
}
break;
@@ -351,9 +355,9 @@ namespace gcn
{
for (; y1 <= y2; ++y1)
{
- p[0] = (pixel >> 16) & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = pixel & 0xff;
+ p[0] = static_cast<uint8_t>((pixel >> 16) & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>(pixel & 0xff);
p += mTarget->pitch;
}
}
@@ -361,9 +365,9 @@ namespace gcn
{
for (; y1 <= y2; ++y1)
{
- p[0] = pixel & 0xff;
- p[1] = (pixel >> 8) & 0xff;
- p[2] = (pixel >> 16) & 0xff;
+ p[0] = static_cast<uint8_t>(pixel & 0xff);
+ p[1] = static_cast<uint8_t>((pixel >> 8) & 0xff);
+ p[2] = static_cast<uint8_t>((pixel >> 16) & 0xff);
p += mTarget->pitch;
}
}
@@ -375,7 +379,8 @@ namespace gcn
if (mAlpha)
{
*reinterpret_cast<uint32_t*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<uint32_t*>(p), mColor.a);
+ *reinterpret_cast<uint32_t*>(p),
+ static_cast<unsigned char>(mColor.a));
}
else
{
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index aa78065c9..ce6aedb59 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -75,7 +75,7 @@ void ItemShortcut::load(bool oldConfig)
for (int i = 0; i < SHORTCUT_ITEMS; i++)
{
int itemId = cfg->getValue(name + toString(i), -1);
- int itemColor = cfg->getValue(color + toString(i), 1);
+ unsigned char itemColor = cfg->getValue(color + toString(i), 1);
mItems[i] = itemId;
mItemColors[i] = itemColor;
@@ -122,7 +122,7 @@ void ItemShortcut::useItem(int index)
return;
int itemId = mItems[index];
- int itemColor = mItemColors[index];
+ unsigned char itemColor = mItemColors[index];
if (itemId >= 0)
{
if (itemId < SPELL_MIN_ID)
diff --git a/src/itemshortcut.h b/src/itemshortcut.h
index 55c6d1165..6367ba6e8 100644
--- a/src/itemshortcut.h
+++ b/src/itemshortcut.h
@@ -144,7 +144,7 @@ class ItemShortcut
int mItems[SHORTCUT_ITEMS]; /**< The items. */
unsigned char mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
int mItemSelected;
- int mItemColorSelected;
+ unsigned char mItemColorSelected;
int mNumber;
};
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index e4de6ad1e..b998a5ee2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1700,8 +1700,8 @@ void LocalPlayer::processEvent(Channels channel,
int id = event.getInt("id");
if (id == Net::getPlayerHandler()->getJobLocation())
{
- std::pair<int, int> exp
- = PlayerInfo::getStatExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(id));
if (event.getInt("oldValue1") > exp.first
|| !event.getInt("oldValue2"))
{
@@ -1755,7 +1755,7 @@ void LocalPlayer::move(int dX, int dY)
moveTo(mX + dX, mY + dY);
}
-void LocalPlayer::moveToTarget(unsigned int dist)
+void LocalPlayer::moveToTarget(int dist)
{
bool gotPos(false);
Path debugPath;
@@ -1764,7 +1764,7 @@ void LocalPlayer::moveToTarget(unsigned int dist)
const Vector &playerPos = getPosition();
unsigned int limit(0);
- if (static_cast<int>(dist) == -1)
+ if (dist == -1)
{
dist = mMoveToTargetType;
if (mMoveToTargetType == 0)
@@ -1810,7 +1810,7 @@ void LocalPlayer::moveToTarget(unsigned int dist)
mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0);
}
- if (debugPath.size() < dist)
+ if (debugPath.size() < static_cast<unsigned>(dist))
return;
limit = static_cast<int>(debugPath.size()) - dist;
gotPos = true;
@@ -1936,7 +1936,7 @@ std::string LocalPlayer::getCrazyMoveTypeString()
{
if (mCrazyMoveType < crazyMoveTypeSize - 1)
{
- return strprintf(_("(%d) crazy move number %d"),
+ return strprintf(_("(%u) crazy move number %u"),
mCrazyMoveType, mCrazyMoveType);
}
else if (mCrazyMoveType == crazyMoveTypeSize - 1)
@@ -2057,12 +2057,12 @@ std::string LocalPlayer::getQuickDropCounterString()
{
if (mQuickDropCounter > 9)
{
- return strprintf("(%c) drop counter %d",
- 'a' + mQuickDropCounter - 10, mQuickDropCounter);
+ return strprintf("(%c) drop counter %u", static_cast<char>(
+ 'a' + mQuickDropCounter - 10), mQuickDropCounter);
}
else
{
- return strprintf("(%d) drop counter %d",
+ return strprintf("(%u) drop counter %u",
mQuickDropCounter, mQuickDropCounter);
}
}
@@ -3255,8 +3255,10 @@ void LocalPlayer::tryMagic(std::string spell, int baseMagic,
if (!chatWindow)
return;
- if (PlayerInfo::getStatEffective(340) >= baseMagic
- && PlayerInfo::getStatEffective(342) >= schoolMagic)
+ if (PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
+ 340)) >= baseMagic
+ && PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
+ 342)) >= schoolMagic)
{
if (PlayerInfo::getAttribute(PlayerInfo::MP) >= mana)
{
diff --git a/src/localplayer.h b/src/localplayer.h
index af54fa6b7..1de8fd765 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -309,7 +309,7 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void move(int dX, int dY);
- void moveToTarget(unsigned int dist = -1);
+ void moveToTarget(int dist = -1);
void moveToHome();
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index 7e857a52b..424bf5c98 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -109,7 +109,7 @@ void MumbleManager::init()
#elif defined BSD4_4
#else
char memName[256];
- snprintf(memName, 256, "/MumbleLink.%d", getuid());
+ snprintf(memName, 256, "/MumbleLink.%u", getuid());
int shmfd = shm_open(memName, O_RDWR, S_IRUSR | S_IWUSR);
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index c5d722db5..0e4fefa21 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -116,7 +116,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
return;
int id;
- short job, speed, gender;
+ short job, speed;
+ uint8_t gender;
uint16_t headTop, headMid, headBottom;
uint16_t shoes, gloves;
uint16_t weapon, shield;
@@ -335,8 +336,8 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible)
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
(statusEffects >> 16) & 0xffff));
- dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
-
+ dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ statusEffects & 0xffff));
}
void BeingHandler::processBeingMove2(Net::MessageIn &msg)
@@ -761,7 +762,8 @@ void BeingHandler::processPlaterStatusChange(Net::MessageIn &msg)
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
(statusEffects >> 16) & 0xffff));
- dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
+ dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ statusEffects & 0xffff));
}
void BeingHandler::processBeingStatusChange(Net::MessageIn &msg)
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 75fc5af56..7c2361531 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -251,7 +251,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg)
m->setOnline(online);
m->setID(id);
m->setCharId(charId);
- m->setGender(Being::intToGender(gender));
+ m->setGender(Being::intToGender(static_cast<uint8_t>(gender)));
m->setLevel(level);
m->setExp(exp);
m->setPos(pos);
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index d35e5a0d5..2a7afb189 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -195,7 +195,7 @@ void LoginHandler::processLoginData(Net::MessageIn &msg)
// msg.skip(30); // unknown
// reserve bits for future usage
- mToken.sex = Being::intToGender(msg.readInt8() & 3);
+ mToken.sex = Being::intToGender(static_cast<uint8_t>(msg.readInt8() & 3));
for (int i = 0; i < worldCount; i++)
{
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 4c6e894c9..130b31046 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -362,48 +362,60 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
break;
case 0x0029:
- PlayerInfo::setStatBase(EA_ATK, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_ATK), value);
PlayerInfo::updateAttrs();
break;
case 0x002a:
- PlayerInfo::setStatMod(EA_ATK, value);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ EA_ATK), value);
PlayerInfo::updateAttrs();
break;
case 0x002b:
- PlayerInfo::setStatBase(EA_MATK, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_MATK), value);
break;
case 0x002c:
- PlayerInfo::setStatMod(EA_MATK, value);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ EA_MATK), value);
break;
case 0x002d:
- PlayerInfo::setStatBase(EA_DEF, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_DEF), value);
break;
case 0x002e:
- PlayerInfo::setStatMod(EA_DEF, value);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ EA_DEF), value);
break;
case 0x002f:
- PlayerInfo::setStatBase(EA_MDEF, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_MDEF), value);
break;
case 0x0030:
- PlayerInfo::setStatMod(EA_MDEF, value);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ EA_MDEF), value);
break;
case 0x0031:
- PlayerInfo::setStatBase(EA_HIT, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_HIT), value);
break;
case 0x0032:
- PlayerInfo::setStatBase(EA_FLEE, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_FLEE), value);
break;
case 0x0033:
- PlayerInfo::setStatMod(EA_FLEE, value);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ EA_FLEE), value);
break;
case 0x0034:
- PlayerInfo::setStatBase(EA_CRIT, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_CRIT), value);
break;
case 0x0035:
@@ -414,7 +426,8 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
break;
case 0x0037:
- PlayerInfo::setStatBase(EA_JOB, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ EA_JOB), value);
break;
case 500:
@@ -445,8 +458,10 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::EXP, msg.readInt32());
break;
case 0x0002:
- PlayerInfo::setStatExperience(EA_JOB, msg.readInt32(),
- PlayerInfo::getStatExperience(EA_JOB).second);
+ PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>(
+ EA_JOB), msg.readInt32(),
+ PlayerInfo::getStatExperience(static_cast<PlayerInfo::Attribute>(
+ EA_JOB)).second);
break;
case 0x0014:
{
@@ -470,8 +485,9 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::EXP_NEEDED, msg.readInt32());
break;
case 0x0017:
- PlayerInfo::setStatExperience(EA_JOB,
- PlayerInfo::getStatExperience(EA_JOB).first,
+ PlayerInfo::setStatExperience(static_cast<PlayerInfo::Attribute>(
+ EA_JOB), PlayerInfo::getStatExperience(
+ static_cast<PlayerInfo::Attribute>(EA_JOB)).first,
msg.readInt32());
break;
default:
@@ -486,8 +502,10 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
int base = msg.readInt32();
int bonus = msg.readInt32();
- PlayerInfo::setStatBase(type, base, false);
- PlayerInfo::setStatMod(type, bonus);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ type), base, false);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(
+ type), bonus);
if (type == EA_ATK || type == PlayerInfo::ATTACK_DELAY)
PlayerInfo::updateAttrs();
}
@@ -500,14 +518,15 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
if (ok != 1)
{
- int oldValue = PlayerInfo::getStatBase(type);
+ int oldValue = PlayerInfo::getStatBase(
+ static_cast<PlayerInfo::Attribute>(type));
int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS);
points += oldValue - value;
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, points);
SERVER_NOTICE(_("Cannot raise skill!"))
}
- PlayerInfo::setStatBase(type, value);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(type), value);
}
void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
@@ -515,69 +534,80 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16());
int val = msg.readInt8();
- PlayerInfo::setStatBase(EA_STR, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_STR), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_STR, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(EA_AGI, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_AGI), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_AGI, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(EA_VIT, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_VIT), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_VIT, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(EA_INT, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_INT), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_INT, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(EA_DEX, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEX), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_DEX, msg.readInt8());
else
msg.readInt8();
val = msg.readInt8();
- PlayerInfo::setStatBase(EA_LUK, val);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_LUK), val);
if (statusWindow)
statusWindow->setPointsNeeded(EA_LUK, msg.readInt8());
else
msg.readInt8();
- PlayerInfo::setStatBase(EA_ATK, msg.readInt16(), false);
- PlayerInfo::setStatMod(EA_ATK, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_ATK),
+ msg.readInt16(), false);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_ATK),
+ msg.readInt16());
PlayerInfo::updateAttrs();
val = msg.readInt16();
- PlayerInfo::setStatBase(EA_MATK, val, false);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MATK),
+ val, false);
val = msg.readInt16();
- PlayerInfo::setStatMod(EA_MATK, val);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MATK), val);
- PlayerInfo::setStatBase(EA_DEF, msg.readInt16(), false);
- PlayerInfo::setStatMod(EA_DEF, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_DEF),
+ msg.readInt16(), false);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_DEF),
+ msg.readInt16());
- PlayerInfo::setStatBase(EA_MDEF, msg.readInt16(), false);
- PlayerInfo::setStatMod(EA_MDEF, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_MDEF),
+ msg.readInt16(), false);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_MDEF),
+ msg.readInt16());
- PlayerInfo::setStatBase(EA_HIT, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_HIT),
+ msg.readInt16());
- PlayerInfo::setStatBase(EA_FLEE, msg.readInt16(), false);
- PlayerInfo::setStatMod(EA_FLEE, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_FLEE),
+ msg.readInt16(), false);
+ PlayerInfo::setStatMod(static_cast<PlayerInfo::Attribute>(EA_FLEE),
+ msg.readInt16());
- PlayerInfo::setStatBase(EA_CRIT, msg.readInt16());
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(EA_CRIT),
+ msg.readInt16());
msg.readInt16(); // manner
}
@@ -635,17 +665,18 @@ void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg)
bool PlayerHandler::canUseMagic() const
{
- return PlayerInfo::getStatEffective(EA_MATK) > 0;
+ return PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
+ EA_MATK)) > 0;
}
-int PlayerHandler::getJobLocation() const
+PlayerInfo::Attribute PlayerHandler::getJobLocation() const
{
- return EA_JOB;
+ return static_cast<PlayerInfo::Attribute>(EA_JOB);
}
-int PlayerHandler::getAttackLocation() const
+PlayerInfo::Attribute PlayerHandler::getAttackLocation() const
{
- return EA_ATK;
+ return static_cast<PlayerInfo::Attribute>(EA_ATK);
}
} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index d0402ecfc..3e9d14804 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -47,9 +47,9 @@ class PlayerHandler : public Net::PlayerHandler
Vector getDefaultWalkSpeed() const;
- int getJobLocation() const;
+ PlayerInfo::Attribute getJobLocation() const;
- int getAttackLocation() const;
+ PlayerInfo::Attribute getAttackLocation() const;
void processWalkResponse(Net::MessageIn &msg);
diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp
index dd0284ae8..7a760c5b4 100644
--- a/src/net/ea/specialhandler.cpp
+++ b/src/net/ea/specialhandler.cpp
@@ -94,7 +94,8 @@ void SpecialHandler::processPlayerSkills(Net::MessageIn &msg)
msg.skip(24); // 0 unused
int up = msg.readInt8();
- PlayerInfo::setStatBase(skillId, level);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ skillId), level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
@@ -111,7 +112,8 @@ void SpecialHandler::processPlayerSkillUp(Net::MessageIn &msg)
int range = msg.readInt16();
int up = msg.readInt8();
- PlayerInfo::setStatBase(skillId, level);
+ PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>(
+ skillId), level);
if (skillDialog)
{
if (!skillDialog->updateSkill(skillId, range, up))
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 0af0e389f..377cca6d3 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -50,7 +50,7 @@ MessageIn::MessageIn(const char *data, unsigned int length):
unsigned char MessageIn::readInt8()
{
- unsigned char value = -1;
+ unsigned char value = static_cast<unsigned char>(-1);
if (mPos < mLength)
value = static_cast<unsigned char>(mData[mPos]);
@@ -121,7 +121,7 @@ void MessageIn::readCoordinates(uint16_t &x, uint16_t &y, uint8_t &direction)
temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
y = static_cast<unsigned short>(temp >> 4);
- serverDir = data[2] & 0x000f;
+ serverDir = static_cast<uint8_t>(data[2] & 0x000f);
direction = fromServerDirection(serverDir);
}
mPos += 3;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 187059c02..c6a67afb2 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -25,6 +25,7 @@
#include "being.h"
#include "flooritem.h"
+#include "playerinfo.h"
namespace Net
{
@@ -65,9 +66,9 @@ class PlayerHandler
virtual bool canCorrectAttributes() const = 0;
- virtual int getJobLocation() const = 0;
+ virtual PlayerInfo::Attribute getJobLocation() const = 0;
- virtual int getAttackLocation() const = 0;
+ virtual PlayerInfo::Attribute getAttackLocation() const = 0;
virtual Vector getDefaultWalkSpeed() const = 0;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 855972b95..dc815bf1c 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -518,7 +518,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
msg.readInt8(); // karma
// reserving bit for future usage
- dstBeing->setGender(Being::intToGender(msg.readInt8() & 3));
+ dstBeing->setGender(Being::intToGender(
+ static_cast<uint8_t>(msg.readInt8() & 3)));
// Set these after the gender, as the sprites may be gender-specific
dstBeing->setSprite(SPRITE_WEAPON, weapon, "", 1, true);
@@ -647,7 +648,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
dstBeing->setStunMode(stunMode);
dstBeing->setStatusEffectBlock(0, static_cast<uint16_t>(
(statusEffects >> 16) & 0xffff));
- dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
+ dstBeing->setStatusEffectBlock(16, static_cast<uint16_t>(
+ statusEffects & 0xffff));
if (msgType == 3 && dstBeing->getType() == Being::PLAYER)
dstBeing->setMoveTime();
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
index 698d7211c..2b65a2a3a 100644
--- a/src/net/tmwa/messagein.cpp
+++ b/src/net/tmwa/messagein.cpp
@@ -77,7 +77,7 @@ int MessageIn::readInt32()
}
mPos += 4;
PacketCounters::incInBytes(4);
- DEBUGLOG(strprintf("readInt32: %u", value));
+ DEBUGLOG(strprintf("readInt32: %u", static_cast<unsigned>(value)));
return value;
}
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index 9e9e264eb..57cbceca3 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -91,7 +91,9 @@ static_cast<unsigned short>(w)) >> 8))
void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
unsigned char direction)
{
- DEBUGLOG(strprintf("writeCoordinates: %u,%u %u", x, y, direction));
+ DEBUGLOG(strprintf("writeCoordinates: %u,%u %u",
+ static_cast<unsigned>(x), static_cast<unsigned>(y),
+ static_cast<unsigned>(direction)));
char *data = mData + mPos;
mNetwork->mOutSize += 3;
mPos += 3;
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index be58f0bc5..c086cc7e4 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -302,7 +302,7 @@ void NpcHandler::processNpcCommand(Net::MessageIn &msg, int npcId)
{
mDialog->setAvatarDirection(
Net::MessageIn::fromServerDirection(
- msg.readInt32())); // direction
+ static_cast<uint8_t>(msg.readInt32()))); // direction
}
break;
case 8: // set avatar action
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index d1429a815..74826e5cd 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -193,8 +193,8 @@ void PartyHandler::setShareExperience(PartyShare share)
return;
MessageOut outMsg(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(share);
- outMsg.writeInt16(mShareItems);
+ outMsg.writeInt16(static_cast<int16_t>(share));
+ outMsg.writeInt16(static_cast<int16_t>(mShareItems));
}
void PartyHandler::setShareItems(PartyShare share)
@@ -203,8 +203,8 @@ void PartyHandler::setShareItems(PartyShare share)
return;
MessageOut outMsg(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(mShareExp);
- outMsg.writeInt16(share);
+ outMsg.writeInt16(static_cast<int16_t>(mShareExp));
+ outMsg.writeInt16(static_cast<int16_t>(share));
}
} // namespace TmwAthena
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index d4c1e1e08..f572e6cff 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -109,7 +109,7 @@ void TradeHandler::respond(bool accept)
PlayerInfo::setTrading(false);
MessageOut outMsg(CMSG_TRADE_RESPONSE);
- outMsg.writeInt8(accept ? 3 : 4);
+ outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4));
}
void TradeHandler::addItem(Item *item, int amount)
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index 1d5273ffe..88079c2bd 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -140,9 +140,9 @@ static inline void drawRescaledQuad(Image *image, int srcX, int srcY,
}
-bool OpenGL1Graphics::drawImage(const Image *image, int srcX, int srcY,
- int dstX, int dstY,
- int width, int height, bool useColor)
+bool OpenGL1Graphics::drawImage2(const Image *image, int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height, bool useColor)
{
if (!image)
return false;
@@ -198,8 +198,8 @@ bool OpenGL1Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
// Just draw the image normally when no resizing is necessary,
if (width == desiredWidth && height == desiredHeight)
{
- return drawImage(image, srcX, srcY, dstX, dstY,
- width, height, useColor);
+ return drawImage2(image, srcX, srcY, dstX, dstY,
+ width, height, useColor);
}
// When the desired image is smaller than the current one,
diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h
index a9fc95722..5c4d7ffb7 100644
--- a/src/opengl1graphics.h
+++ b/src/opengl1graphics.h
@@ -44,12 +44,6 @@ class OpenGL1Graphics : public Graphics
bool setVideoMode(int w, int h, int bpp, bool fs,
bool hwaccel, bool resize, bool noFrame);
- bool drawImage(const Image *image,
- int srcX, int srcY,
- int dstX, int dstY,
- int width, int height,
- bool useColor);
-
/**
* Draws a resclaled version of the image
*/
@@ -127,6 +121,12 @@ class OpenGL1Graphics : public Graphics
static GLuint mLastImage;
protected:
+ bool drawImage2(const Image *image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height,
+ bool useColor);
+
void setTexturingAndBlending(bool enable);
private:
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index e53f4e11b..4edcb089d 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -206,9 +206,9 @@ static inline void drawRescaledQuad(Image *image,
}
-bool OpenGLGraphics::drawImage(const Image *image, int srcX, int srcY,
- int dstX, int dstY,
- int width, int height, bool useColor)
+bool OpenGLGraphics::drawImage2(const Image *image, int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height, bool useColor)
{
if (!image)
return false;
@@ -264,8 +264,8 @@ bool OpenGLGraphics::drawRescaledImage(Image *image, int srcX, int srcY,
// Just draw the image normally when no resizing is necessary,
if (width == desiredWidth && height == desiredHeight)
{
- return drawImage(image, srcX, srcY, dstX, dstY,
- width, height, useColor);
+ return drawImage2(image, srcX, srcY, dstX, dstY,
+ width, height, useColor);
}
// When the desired image is smaller than the current one,
diff --git a/src/openglgraphics.h b/src/openglgraphics.h
index 3eaf19045..f0d0078a1 100644
--- a/src/openglgraphics.h
+++ b/src/openglgraphics.h
@@ -47,11 +47,6 @@ class OpenGLGraphics : public Graphics
bool setVideoMode(int w, int h, int bpp, bool fs,
bool hwaccel, bool resize, bool noFrame);
- bool drawImage(const Image *image,
- int srcX, int srcY,
- int dstX, int dstY,
- int width, int height,
- bool useColor);
/**
* Draws a resclaled version of the image
@@ -147,6 +142,12 @@ class OpenGLGraphics : public Graphics
static GLuint mLastImage;
protected:
+ bool drawImage2(const Image *image,
+ int srcX, int srcY,
+ int dstX, int dstY,
+ int width, int height,
+ bool useColor);
+
void setTexturingAndBlending(bool enable);
void logString(const char *format, GLenum num);
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index eaf6e1350..d00eb217d 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -87,7 +87,7 @@ void triggerStat(int id, const std::string &changed, int old1, int old2)
// --- Attributes -------------------------------------------------------------
-int getAttribute(int id)
+int getAttribute(Attribute id)
{
IntMap::const_iterator it = mData.mAttributes.find(id);
if (it != mData.mAttributes.end())
@@ -96,7 +96,7 @@ int getAttribute(int id)
return 0;
}
-void setAttribute(int id, int value, bool notify)
+void setAttribute(Attribute id, int value, bool notify)
{
int old = mData.mAttributes[id];
mData.mAttributes[id] = value;
@@ -106,7 +106,7 @@ void setAttribute(int id, int value, bool notify)
// --- Stats ------------------------------------------------------------------
-int getStatBase(int id)
+int getStatBase(Attribute id)
{
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -115,7 +115,7 @@ int getStatBase(int id)
return 0;
}
-void setStatBase(int id, int value, bool notify)
+void setStatBase(Attribute id, int value, bool notify)
{
int old = mData.mStats[id].base;
mData.mStats[id].base = value;
@@ -123,7 +123,7 @@ void setStatBase(int id, int value, bool notify)
triggerStat(id, "base", old);
}
-int getStatMod(int id)
+int getStatMod(Attribute id)
{
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -132,7 +132,7 @@ int getStatMod(int id)
return 0;
}
-void setStatMod(int id, int value, bool notify)
+void setStatMod(Attribute id, int value, bool notify)
{
int old = mData.mStats[id].mod;
mData.mStats[id].mod = value;
@@ -140,7 +140,7 @@ void setStatMod(int id, int value, bool notify)
triggerStat(id, "mod", old);
}
-int getStatEffective(int id)
+int getStatEffective(Attribute id)
{
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
@@ -149,7 +149,7 @@ int getStatEffective(int id)
return 0;
}
-std::pair<int, int> getStatExperience(int id)
+std::pair<int, int> getStatExperience(Attribute id)
{
StatMap::const_iterator it = mData.mStats.find(id);
int a, b;
@@ -166,7 +166,7 @@ std::pair<int, int> getStatExperience(int id)
return std::pair<int, int>(a, b);
}
-void setStatExperience(int id, int have, int need, bool notify)
+void setStatExperience(Attribute id, int have, int need, bool notify)
{
Stat &stat = mData.mStats[id];
@@ -294,15 +294,21 @@ void updateAttrs()
int attr = Net::getPlayerHandler()->getAttackLocation();
if (attr != -1 && getStatBase(ATTACK_DELAY))
{
- setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000 / getStatBase(
- ATTACK_DELAY), false);
- setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000 / getStatBase(
- ATTACK_DELAY), true);
+ setStatBase(static_cast<PlayerInfo::Attribute>(ATTACK_SPEED),
+ getStatBase(static_cast<PlayerInfo::Attribute>(attr))
+ * 1000 / getStatBase(
+ static_cast<PlayerInfo::Attribute>(ATTACK_DELAY)), false);
+ setStatMod(static_cast<PlayerInfo::Attribute>(ATTACK_SPEED),
+ getStatMod(static_cast<PlayerInfo::Attribute>(attr))
+ * 1000 / getStatBase(
+ static_cast<PlayerInfo::Attribute>(ATTACK_DELAY)), true);
}
else
{
- setStatBase(ATTACK_SPEED, 0, false);
- setStatMod(ATTACK_SPEED, 0, true);
+ setStatBase(static_cast<PlayerInfo::Attribute>(
+ ATTACK_SPEED), 0, false);
+ setStatMod(static_cast<PlayerInfo::Attribute>(
+ ATTACK_SPEED), 0, true);
}
}
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 4298a45b5..36a8bb799 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -103,55 +103,56 @@ namespace PlayerInfo
/**
* Returns the value of the given attribute.
*/
- int getAttribute(int id);
+ int getAttribute(Attribute id);
/**
* Changes the value of the given attribute.
*/
- void setAttribute(int id, int value, bool notify = true);
+ void setAttribute(Attribute id, int value, bool notify = true);
// --- Stats ------------------------------------------------------------------
/**
* Returns the base value of the given stat.
*/
- int getStatBase(int id);
+ int getStatBase(Attribute id);
/**
* Changes the base value of the given stat.
*/
- void setStatBase(int id, int value, bool notify = true);
+ void setStatBase(Attribute id, int value, bool notify = true);
/**
* Returns the modifier for the given stat.
*/
- int getStatMod(int id);
+ int getStatMod(Attribute id);
/**
* Changes the modifier for the given stat.
*/
- void setStatMod(int id, int value, bool notify = true);
+ void setStatMod(Attribute id, int value, bool notify = true);
/**
* Returns the current effective value of the given stat. Effective is base
* + mod
*/
- int getStatEffective(int id);
+ int getStatEffective(Attribute id);
/**
* Changes the level of the given stat.
*/
- void setStatLevel(int id, int value, bool notify = true);
+ void setStatLevel(Attribute id, int value, bool notify = true);
/**
* Returns the experience of the given stat.
*/
- std::pair<int, int> getStatExperience(int id);
+ std::pair<int, int> getStatExperience(Attribute id);
/**
* Changes the experience of the given stat.
*/
- void setStatExperience(int id, int have, int need, bool notify = true);
+ void setStatExperience(Attribute id, int have,
+ int need, bool notify = true);
// --- Inventory / Equipment --------------------------------------------------
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index 316dff9f3..df26ec1b7 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -54,8 +54,9 @@ DyePalette::DyePalette(const std::string &description, int8_t blockSize)
for (int i = 0, colorIdx = 0; i < blockSize && colorIdx < dyePalateSize;
i +=2, colorIdx ++)
{
- color.value[colorIdx] = (hexDecode(description[pos + i]) << 4)
- + hexDecode(description[pos + i + 1]);
+ color.value[colorIdx] = static_cast<unsigned char>((
+ hexDecode(description[pos + i]) << 4)
+ + hexDecode(description[pos + i + 1]));
}
mColors.push_back(color);
pos += blockSize;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index d76585fd2..427db8f19 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -106,7 +106,8 @@ void MonsterDB::load()
else if (walkStr == "walkswim" || walkStr == "swimwalk")
block = Map::BLOCKMASK_AIR;
- currentInfo->setWalkMask(Map::BLOCKMASK_WALL | block);
+ currentInfo->setWalkMask(static_cast<unsigned char>(
+ Map::BLOCKMASK_WALL | block));
if (currentInfo->getMaxHP())
currentInfo->setStaticMaxHP(true);
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index aec68f32a..ae3b55741 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -125,7 +125,7 @@ Resource *OpenGLImageHelper::load(SDL_RWops *rw, Dye const &dye)
Image *OpenGLImageHelper::load(SDL_Surface *tmpImage)
{
- return _GLload(tmpImage);
+ return glLoad(tmpImage);
}
Image *OpenGLImageHelper::createTextSurface(SDL_Surface *tmpImage, float alpha)
@@ -133,7 +133,7 @@ Image *OpenGLImageHelper::createTextSurface(SDL_Surface *tmpImage, float alpha)
if (!tmpImage)
return nullptr;
- Image *img = _GLload(tmpImage);
+ Image *img = glLoad(tmpImage);
if (img)
img->setAlpha(alpha);
return img;
@@ -155,7 +155,7 @@ int OpenGLImageHelper::powerOfTwo(int input)
return value >= mTextureSize ? mTextureSize : value;
}
-Image *OpenGLImageHelper::_GLload(SDL_Surface *tmpImage)
+Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage)
{
if (!tmpImage)
return nullptr;
diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h
index b27409040..edba4cdef 100644
--- a/src/resources/openglimagehelper.h
+++ b/src/resources/openglimagehelper.h
@@ -112,7 +112,7 @@ class OpenGLImageHelper : public ImageHelper
*/
int powerOfTwo(int input);
- Image *_GLload(SDL_Surface *tmpImage);
+ Image *glLoad(SDL_Surface *tmpImage);
static int mUseOpenGL;
static int mTextureSize;
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 78094b211..5463abfeb 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -154,7 +154,8 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *tmpImage, float alpha)
uint32_t c = (static_cast<uint32_t*>(tmpImage->pixels))[i];
unsigned v = (c & fmt->Amask) >> fmt->Ashift;
- uint8_t a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
+ uint8_t a = static_cast<uint8_t>((v << fmt->Aloss)
+ + (v >> (8 - (fmt->Aloss << 1))));
uint8_t a2 = static_cast<uint8_t>(static_cast<float>(a) * alpha);
@@ -241,7 +242,8 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage)
{
unsigned v = ((static_cast<uint32_t*>(tmpImage->pixels))[i]
& fmt->Amask) >> fmt->Ashift;
- uint8_t a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
+ uint8_t a = static_cast<uint8_t>((v << fmt->Aloss)
+ + (v >> (8 - (fmt->Aloss << 1))));
if (a != 255)
hasAlpha = true;
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 222004347..548fc94c1 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -138,9 +138,11 @@ void SpellManager::invoke(int spellId)
if (spell->getCommandType() == TEXT_COMMAND_TEXT
|| (Net::getPlayerHandler()->canUseMagic()
- && PlayerInfo::getStatEffective(SKILL_MAGIC) >= spell->getBaseLvl()
+ && PlayerInfo::getStatEffective(static_cast<PlayerInfo::Attribute>(
+ SKILL_MAGIC)) >= static_cast<signed>(spell->getBaseLvl())
&& PlayerInfo::getStatEffective(
- spell->getSchool()) >= spell->getSchoolLvl()
+ static_cast<PlayerInfo::Attribute>(spell->getSchool()))
+ >= static_cast<signed>(spell->getSchoolLvl())
&& PlayerInfo::getAttribute(PlayerInfo::MP) >= spell->getMana()))
{
Being* target = player_node->getTarget();
@@ -336,10 +338,12 @@ void SpellManager::save()
if (spell->getCommand() != "" && spell->getSymbol() != "")
{
serverConfig.setValue("commandShortcutFlags" + toString(i),
- strprintf("%u %u %u %u %u %u", spell->getCommandType(),
- spell->getTargetType(), spell->getBaseLvl(),
- spell->getSchool(), spell->getSchoolLvl(),
- spell->getMana()));
+ strprintf("%u %u %u %u %u %u", static_cast<unsigned>(
+ spell->getCommandType()), static_cast<unsigned>(
+ spell->getTargetType()), spell->getBaseLvl(),
+ static_cast<unsigned>(spell->getSchool()),
+ spell->getSchoolLvl(), static_cast<unsigned>(
+ spell->getMana())));
}
else
{
diff --git a/src/textcommand.h b/src/textcommand.h
index 7cab06317..3d95b06bd 100644
--- a/src/textcommand.h
+++ b/src/textcommand.h
@@ -109,10 +109,10 @@ class TextCommand
MagicSchool getSchool() const
{ return mSchool; }
- int getBaseLvl() const
+ unsigned getBaseLvl() const
{ return mBaseLvl; }
- int getSchoolLvl() const
+ unsigned getSchoolLvl() const
{ return mSchoolLvl; }
TextCommandType getCommandType() const
@@ -169,8 +169,8 @@ class TextCommand
unsigned int mId;
int mMana;
MagicSchool mSchool;
- int mBaseLvl;
- int mSchoolLvl;
+ unsigned mBaseLvl;
+ unsigned mSchoolLvl;
TextCommandType mCommandType;
Image *mImage;
};
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index cd7d59cdb..094cd6227 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -128,18 +128,18 @@ unsigned char *php3_base64_decode(const unsigned char *string,
switch (i % 4)
{
case 0:
- result[j] = ch << 2;
+ result[j] = static_cast<unsigned char>(ch << 2);
break;
case 1:
- result[j++] |= ch >> 4;
- result[j] = (ch & 0x0f) << 4;
+ result[j++] |= static_cast<unsigned char>(ch >> 4);
+ result[j] = static_cast<unsigned char>((ch & 0x0f) << 4);
break;
case 2:
- result[j++] |= ch >>2;
- result[j] = (ch & 0x03) << 6;
+ result[j++] |= static_cast<unsigned char>(ch >>2);
+ result[j] = static_cast<unsigned char>((ch & 0x03) << 6);
break;
case 3:
- result[j++] |= ch;
+ result[j++] |= static_cast<unsigned char>(ch);
break;
default:
break;
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 1808ea173..d55e4e650 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -267,7 +267,7 @@ std::string extractNameFromSprite(std::string str)
pos2 = pos3;
}
if (pos2 == std::string::npos)
- pos2 = -1;
+ pos2 = static_cast<size_t>(-1);
int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
if (size > 0)
@@ -290,7 +290,7 @@ std::string removeSpriteIndex(std::string str)
pos2 = pos3;
}
if (pos2 == std::string::npos)
- pos2 = -1;
+ pos2 = static_cast<size_t>(-1);
int size = static_cast<int>(pos1) - static_cast<int>(pos2) - 1;
if (size > 0)