From 4cffca0da71771d0d51ba4cd4842d2d93aa2946e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 2 Oct 2012 21:38:23 +0300 Subject: Fix some conversions. --- src/gui/charcreatedialog.cpp | 3 ++- src/gui/minimap.cpp | 8 ++++---- src/gui/npcdialog.cpp | 2 +- src/gui/npcdialog.h | 2 +- src/gui/questswindow.cpp | 4 ++-- src/gui/whoisonline.cpp | 4 ++-- src/guichan/color.cpp | 6 +++--- src/guichan/sdl/sdlgraphics.cpp | 4 ++-- src/net/tmwa/charserverhandler.cpp | 6 ++++-- src/utils/mathutils.h | 2 +- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 37839c7ee..d029b7083 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -96,7 +96,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mCreateButton(new Button(_("Create"), "create", this)), mCancelButton(new Button(_("Cancel"), "cancel", this)), mRace(0), - mPlayer(new Being(0, ActorSprite::PLAYER, mRace, nullptr)), + mPlayer(new Being(0, ActorSprite::PLAYER, static_cast(mRace), + nullptr)), mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml")), mSlot(slot), mAction(0), diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 5ed18f84e..1289fcd40 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -228,11 +228,11 @@ void Minimap::draw(gcn::Graphics *graphics) mMapImage->mBounds.h > a.height) { const Vector &p = player_node->getPosition(); - mMapOriginX = (a.width / 2) - (static_cast(p.x - + viewport->getCameraRelativeX()) * mWidthProportion) / 32; + mMapOriginX = (a.width / 2) - (p.x + static_cast( + viewport->getCameraRelativeX()) * mWidthProportion) / 32; - mMapOriginY = (a.height / 2) - (static_cast(p.y - + viewport->getCameraRelativeY()) * mHeightProportion) / 32; + mMapOriginY = (a.height / 2) - (p.y + static_cast( + viewport->getCameraRelativeY()) * mHeightProportion) / 32; const int minOriginX = a.width - mMapImage->mBounds.w; const int minOriginY = a.height - mMapImage->mBounds.h; diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 35c219846..57501a35f 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -690,7 +690,7 @@ void NpcDialog::restoreCamera() mCameraMode = -1; } -void NpcDialog::showAvatar(const int avatarId) +void NpcDialog::showAvatar(const uint16_t avatarId) { const bool needShow = (avatarId != 0); if (needShow) diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 86b6bdabd..be021d50f 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -192,7 +192,7 @@ class NpcDialog final : public Window, public gcn::ActionListener, void refocus(); - void showAvatar(const int avatarId); + void showAvatar(const uint16_t avatarId); void setAvatarDirection(const uint8_t direction); diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index 66a7d50cf..c9e05cd14 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -331,9 +331,9 @@ void QuestsWindow::rebuild(const bool playSound) } if (updatedQuest == -1) - updatedQuest = mQuestLinks.size() - 1; + updatedQuest = static_cast(mQuestLinks.size() - 1); else if (updatedQuest >= static_cast(mQuestLinks.size())) - updatedQuest = mQuestLinks.size() - 1; + updatedQuest = static_cast(mQuestLinks.size() - 1); if (updatedQuest >= 0) { mQuestsListBox->setSelected(updatedQuest); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index d3fcfa451..b522b8157 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -409,8 +409,8 @@ void WhoIsOnline::loadWebList() if (!mShowLevel) level = 0; - OnlinePlayer *player = new OnlinePlayer(nick, 255, level, - GENDER_UNSPECIFIED, -1); + OnlinePlayer *player = new OnlinePlayer(nick, + static_cast(255), level, GENDER_UNSPECIFIED, -1); mOnlinePlayers.insert(player); mOnlineNicks.insert(nick); diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp index 7cc3b887a..87d110b63 100644 --- a/src/guichan/color.cpp +++ b/src/guichan/color.cpp @@ -106,9 +106,9 @@ namespace gcn Color Color::operator*(const float value) const { - Color result(static_cast(r * value), - static_cast(g * value), - static_cast(b * value), + Color result(static_cast(static_cast(r) * value), + static_cast(static_cast(g) * value), + static_cast(static_cast(b) * value), a); result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index 952be9093..482642e30 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -596,8 +596,8 @@ namespace gcn const ClipRectangle& top = mClipStack.top(); - destination.x += top.xOffset; - destination.y += top.yOffset; + destination.x += static_cast(top.xOffset); + destination.y += static_cast(top.yOffset); SDL_BlitSurface(surface, &source, mTarget, &destination); } diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 4e3763042..e8c9dfaff 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -217,10 +217,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, const int hat = msg.readInt16(); // head option top const int topClothes = msg.readInt16(); - const int hairColor = msg.readInt16(); + int hairColor = msg.readInt16(); + if (hairColor > 255) + hairColor = 255; tempPlayer->setSprite(SPRITE_HAIR, hairStyle * -1, ItemDB::get(-hairStyle).getDyeColorsString(hairColor)); - tempPlayer->setHairColor(hairColor); + tempPlayer->setHairColor(static_cast(hairColor)); const int misc2 = msg.readInt16(); tempPlayer->setName(msg.readString(24)); diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index caed0d2f8..aa6dcecea 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -116,7 +116,7 @@ inline float weightedAverage(const float n1, const float n2, const float w) inline int roundDouble(const double v) { - return (v > 0.0) ? (v + 0.5) : (v - 0.5); + return (v > 0.0) ? static_cast(v + 0.5) : static_cast(v - 0.5); } inline int powerOfTwo(const int input) -- cgit v1.2.3-60-g2f50