summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp18
-rw-r--r--src/client.cpp2
-rw-r--r--src/configuration.cpp2
-rw-r--r--src/emoteshortcut.cpp6
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/minimap.cpp13
-rw-r--r--src/gui/skilldialog.cpp2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/inventory.cpp3
-rw-r--r--src/localplayer.cpp60
-rw-r--r--src/map.h2
-rw-r--r--src/mumblemanager.cpp16
-rw-r--r--src/net/download.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp4
-rw-r--r--src/net/manaserv/playerhandler.h4
-rw-r--r--src/net/playerhandler.h4
-rw-r--r--src/net/tmwa/beinghandler.cpp53
-rw-r--r--src/net/tmwa/charserverhandler.cpp5
-rw-r--r--src/net/tmwa/guildhandler.cpp8
-rw-r--r--src/net/tmwa/inventoryhandler.cpp7
-rw-r--r--src/net/tmwa/npchandler.cpp16
-rw-r--r--src/net/tmwa/partyhandler.cpp4
-rw-r--r--src/net/tmwa/playerhandler.cpp26
-rw-r--r--src/net/tmwa/playerhandler.h4
-rw-r--r--src/net/tmwa/specialhandler.cpp16
-rw-r--r--src/net/tmwa/tradehandler.cpp5
-rw-r--r--src/net/worldinfo.h2
-rw-r--r--src/opengl1graphics.cpp41
-rw-r--r--src/particle.cpp51
-rw-r--r--src/particleemitter.cpp31
-rw-r--r--src/resources/iteminfo.cpp2
-rw-r--r--src/spellmanager.cpp6
-rw-r--r--src/utils/base64.cpp2
-rw-r--r--src/utils/mkdir.cpp2
-rw-r--r--src/utils/sha256.cpp2
-rw-r--r--src/utils/stringutils.cpp2
37 files changed, 256 insertions, 174 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 8604f0053..5ea0fca29 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -993,7 +993,7 @@ void Being::setDirection(Uint8 direction)
Uint8 Being::calcDirection() const
{
- int dir = 0;
+ Uint8 dir = 0;
if (mDest.x > mX)
dir |= RIGHT;
else if (mDest.x < mX)
@@ -1007,7 +1007,7 @@ Uint8 Being::calcDirection() const
Uint8 Being::calcDirection(int dstX, int dstY) const
{
- int dir = 0;
+ Uint8 dir = 0;
if (dstX > mX)
dir |= RIGHT;
else if (dstX < mX)
@@ -1162,8 +1162,9 @@ void Being::logic()
case MOVE:
{
- if (getWalkSpeed().x && static_cast<int> ((get_elapsed_time(
- mActionTime) * frameCount) / getWalkSpeed().x)
+ if (getWalkSpeed().x && static_cast<int> ((static_cast<float>(
+ get_elapsed_time(mActionTime)) * static_cast<float>(
+ frameCount)) / static_cast<float>(getWalkSpeed().x))
>= frameCount)
{
nextTile();
@@ -1249,8 +1250,9 @@ void Being::logic()
if (!isAlive() && getWalkSpeed().x
&& Net::getGameHandler()->removeDeadBeings()
- && static_cast<int> ((get_elapsed_time(mActionTime)
- / getWalkSpeed().x) >= static_cast<float>(frameCount)))
+ && static_cast<int> ((static_cast<float>(get_elapsed_time(mActionTime))
+ / static_cast<float>(getWalkSpeed().x)))
+ >= static_cast<int>(frameCount))
{
if (getType() != PLAYER && actorSpriteManager)
actorSpriteManager->destroy(this);
@@ -1866,7 +1868,7 @@ void Being::drawHpBar(Graphics *graphics, int maxHP, int hp, int damage,
if (p <= 0 || p > width)
return;
- int dx = width / p;
+ int dx = static_cast<int>(static_cast<float>(width) / p);
graphics->setColor(userPalette->getColorWithAlpha(color1));
@@ -1908,7 +1910,7 @@ void Being::resetCounters()
void Being::recalcSpritesOrder()
{
// logger->log("recalcSpritesOrder");
- unsigned sz = size();
+ unsigned sz = static_cast<unsigned>(size());
if (sz < 1)
return;
diff --git a/src/client.cpp b/src/client.cpp
index 76a53fdfd..0179c0f51 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -537,7 +537,7 @@ Client::Client(const Options &options):
optionChanged("fpslimit");
- start_time = time(NULL);
+ start_time = static_cast<int>(time(NULL));
// Initialize PlayerInfo
PlayerInfo::init();
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 900a22563..6755e0a4f 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -254,7 +254,7 @@ float Configuration::getFloatValue(const std::string &key) const
}
else
{
- defaultValue = atof(iter->second.c_str());
+ defaultValue = static_cast<float>(atof(iter->second.c_str()));
}
return defaultValue;
}
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
index 9fb64492a..238ae75f5 100644
--- a/src/emoteshortcut.cpp
+++ b/src/emoteshortcut.cpp
@@ -44,12 +44,14 @@ EmoteShortcut::~EmoteShortcut()
void EmoteShortcut::load()
{
- for (int i = 0, j = 0; i <= EmoteDB::getLast() && j < SHORTCUT_EMOTES; i++)
+ for (unsigned char i = 0, j = 0;
+ i <= EmoteDB::getLast() && j < SHORTCUT_EMOTES;
+ i++)
{
const AnimatedSprite* sprite = EmoteDB::getAnimation(i, true);
if (sprite)
{
- mEmotes[j] = i + 1;
+ mEmotes[j] = static_cast<unsigned char>(i + 1);
j ++;
}
}
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 1a8dcc35d..493b5041a 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -103,7 +103,7 @@ void ItemPopup::setItem(const Item *item, bool showImage)
setItem(ii, item->getColor(), showImage);
if (item->getRefine() > 0)
{
- mLastName = item->getId();
+ mLastName = ii.getName();
mLastColor = item->getColor();
if (serverVersion > 0)
{
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index de9d2a150..e5371eaf3 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -208,9 +208,12 @@ void Minimap::draw(gcn::Graphics *graphics)
{
const Vector &p = player_node->getPosition();
mapOriginX = ((a.width) / 2) - static_cast<int>((p.x
- + viewport->getCameraRelativeX()) * mWidthProportion) / 32;
+ + viewport->getCameraRelativeX()) * static_cast<int>(
+ mWidthProportion)) / 32;
+
mapOriginY = ((a.height) / 2) - static_cast<int>((p.y
- + viewport->getCameraRelativeX()) * mHeightProportion) / 32;
+ + viewport->getCameraRelativeX()) * static_cast<int>(
+ mHeightProportion)) / 32;
const int minOriginX = a.width - mMapImage->getWidth();
const int minOriginY = a.height - mMapImage->getHeight();
@@ -304,8 +307,10 @@ void Minimap::draw(gcn::Graphics *graphics)
+ viewport->getCameraRelativeY())
* mHeightProportion) / 32 + mapOriginY;
- const int w = graph->getWidth() * mWidthProportion / 32;
- const int h = graph->getHeight() * mHeightProportion / 32;
+ const int w = static_cast<int>(static_cast<float>(
+ graph->getWidth()) * mWidthProportion / 32);
+ const int h = static_cast<int>(static_cast<float>(
+ graph->getHeight()) * mHeightProportion / 32);
if (w <= a.width)
{
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 4a264e113..fe2325ab8 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -451,7 +451,7 @@ void SkillDialog::addSkill(int id, int level, bool modifiable)
skill->modifiable = modifiable;
skill->visible = false;
skill->model = mDefaultModel;
- skill->skillLevel = level;
+ skill->skillLevel = strprintf(_("Lvl: %d"), level);
skill->update();
mDefaultModel->addSkill(skill);
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index f6762a5cb..683b02fe6 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -162,7 +162,8 @@ void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event)
return;
// const unsigned char emoteId = emoteShortcut->getEmote(index);
- const unsigned char emoteId = index + 1;
+ const unsigned char emoteId
+ = static_cast<unsigned char>(index + 1);
if (emoteId)
{
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 67882deca..7da6f9398 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -156,7 +156,7 @@ void TabbedArea::removeTab(Tab *tab)
}
if (tabIndexToBeSelected >= static_cast<signed>(mTabs.size()))
- tabIndexToBeSelected = mTabs.size() - 1;
+ tabIndexToBeSelected = static_cast<int>(mTabs.size()) - 1;
if (tabIndexToBeSelected < -1)
tabIndexToBeSelected = -1;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 555117638..e410a36ed 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -160,7 +160,8 @@ int Inventory::getFreeSlot() const
{
Item **i = std::find_if(mItems, mItems + mSize,
std::not1(SlotUsed()));
- return (i == mItems + static_cast<int>(mSize)) ? -1 : (i - mItems);
+ return (i == mItems + static_cast<int>(mSize)) ? -1
+ : static_cast<int>(i - mItems);
}
int Inventory::getLastUsedSlot() const
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d544b8ed7..a08eb1265 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -163,7 +163,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mWaitPing = false;
mPingTime = 0;
- PlayerInfo::setStatBase(WALK_SPEED, getWalkSpeed().x);
+ PlayerInfo::setStatBase(WALK_SPEED, static_cast<int>(getWalkSpeed().x));
PlayerInfo::setStatMod(WALK_SPEED, 0);
loadHomes();
@@ -299,13 +299,13 @@ void LocalPlayer::logic()
// TODO: Make this nicer, probably using getPosition() only
const int rangeX =
(Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(mTarget->getPosition().x
- - getPosition().x)) :
+ static_cast<int>(abs(static_cast<int>(mTarget->getPosition().x
+ - getPosition().x))) :
static_cast<int>(abs(mTarget->getTileX() - getTileX()));
const int rangeY =
(Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(mTarget->getPosition().y
- - getPosition().y)) :
+ static_cast<int>(abs(static_cast<int>(mTarget->getPosition().y
+ - getPosition().y))) :
static_cast<int>(abs(mTarget->getTileY() - getTileY()));
const int attackRange = getAttackRange();
@@ -1420,8 +1420,8 @@ bool LocalPlayer::withinAttackRange(Being *target, bool fixDistance,
{
const Vector &targetPos = target->getPosition();
const Vector &pos = getPosition();
- dx = static_cast<int>(abs(targetPos.x - pos.x));
- dy = static_cast<int>(abs(targetPos.y - pos.y));
+ dx = static_cast<int>(abs(static_cast<int>(targetPos.x - pos.x)));
+ dy = static_cast<int>(abs(static_cast<int>(targetPos.y - pos.y)));
}
else
@@ -1445,7 +1445,8 @@ void LocalPlayer::setGotoTarget(Being *target)
mTarget = target;
mGoingToTarget = true;
const Vector &targetPos = target->getPosition();
- setDestination(targetPos.x, targetPos.y);
+ setDestination(static_cast<int>(targetPos.x),
+ static_cast<int>(targetPos.y));
}
else
{
@@ -1734,7 +1735,7 @@ void LocalPlayer::moveToHome()
}
else
{
- navigateTo(pos.x, pos.y);
+ navigateTo(static_cast<int>(pos.x), static_cast<int>(pos.y));
}
}
}
@@ -2898,23 +2899,33 @@ void LocalPlayer::setHome()
std::map<std::string, Vector>::iterator iter = mHomes.find(key);
if (iter != mHomes.end())
- socialWindow->removePortal(pos.x, pos.y);
+ {
+ socialWindow->removePortal(static_cast<int>(pos.x),
+ static_cast<int>(pos.y));
+ }
- if (iter != mHomes.end() && getTileX() == pos.x && getTileY() == pos.y)
+ if (iter != mHomes.end() && getTileX() == static_cast<int>(pos.x)
+ && getTileY() == static_cast<int>(pos.y))
{
- mMap->updatePortalTile("", MapItem::EMPTY, pos.x, pos.y);
+ mMap->updatePortalTile("", MapItem::EMPTY,
+ static_cast<int>(pos.x), static_cast<int>(pos.y));
+
// if (specialLayer)
// specialLayer->setTile(pos.x, pos.y, MapItem::EMPTY);
mHomes.erase(key);
- socialWindow->removePortal(pos.x, pos.y);
+ socialWindow->removePortal(static_cast<int>(pos.x),
+ static_cast<int>(pos.y));
}
else
{
if (specialLayer && iter != mHomes.end())
- specialLayer->setTile(pos.x, pos.y, MapItem::EMPTY);
+ {
+ specialLayer->setTile(static_cast<int>(pos.x),
+ static_cast<int>(pos.y), MapItem::EMPTY);
+ }
- pos.x = getTileX();
- pos.y = getTileY();
+ pos.x = static_cast<float>(getTileX());
+ pos.y = static_cast<float>(getTileY());
mHomes[key] = pos;
mMap->updatePortalTile("home", MapItem::HOME,
getTileX(), getTileY());
@@ -3126,8 +3137,8 @@ void LocalPlayer::navigateTo(int x, int y)
const Vector &playerPos = getPosition();
mShowNavigePath = true;
- mOldX = playerPos.x;
- mOldY = playerPos.y;
+ mOldX = static_cast<int>(playerPos.x);
+ mOldY = static_cast<int>(playerPos.y);
mOldTileX = getTileX();
mOldTileY = getTileY();
mNavigateX = x;
@@ -3154,8 +3165,8 @@ void LocalPlayer::navigateTo(Being *being)
const Vector &playerPos = getPosition();
mShowNavigePath = true;
- mOldX = playerPos.x;
- mOldY = playerPos.y;
+ mOldX = static_cast<int>(playerPos.x);
+ mOldY = static_cast<int>(playerPos.y);
mOldTileX = getTileX();
mOldTileY = getTileY();
mNavigateX = being->getTileX();
@@ -3263,8 +3274,8 @@ void LocalPlayer::updateCoords()
}
}
}
- mOldX = playerPos.x;
- mOldY = playerPos.y;
+ mOldX = static_cast<int>(playerPos.x);
+ mOldY = static_cast<int>(playerPos.y);
mOldTileX = getTileX();
mOldTileY = getTileY();
}
@@ -3674,7 +3685,10 @@ void LocalPlayer::updateNavigateList()
{
Vector pos = mHomes[(*iter).first];
if (pos.x && pos.y)
- mMap->addPortalTile("home", MapItem::HOME, pos.x, pos.y);
+ {
+ mMap->addPortalTile("home", MapItem::HOME,
+ static_cast<int>(pos.x), static_cast<int>(pos.y));
+ }
}
}
}
diff --git a/src/map.h b/src/map.h
index 5cc25cf01..7c606dfbd 100644
--- a/src/map.h
+++ b/src/map.h
@@ -419,7 +419,7 @@ class Map : public Properties, public ConfigListener
MapItem *findPortalXY(int x, int y);
int getActorsCount() const
- { return mActors.size(); }
+ { return static_cast<int>(mActors.size()); }
void setPvpMode(int mode);
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index b21fac2ee..aa2d49959 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -55,18 +55,18 @@ uint16_t MumbleManager::getMapId(std::string mapName)
else
{
mapName = mapName.substr(0, 3) + mapName[4];
- res = atoi(mapName.c_str());
+ res = static_cast<uint16_t>(atoi(mapName.c_str()));
}
return res;
}
void MumbleManager::setMapBase(uint16_t mapid)
{
- mMapBase[0] = 10000. * (mapid & 0x1f);
+ mMapBase[0] = 10000.0f * (mapid & 0x1f);
mapid >>= 5;
- mMapBase[1] = 1000. * (mapid & 0x3f);
+ mMapBase[1] = 1000.0f * (mapid & 0x3f);
mapid >>= 6;
- mMapBase[2] = 10000. * (mapid & 0x1f);
+ mMapBase[2] = 10000.0f * (mapid & 0x1f);
}
void MumbleManager::init()
@@ -204,8 +204,10 @@ void MumbleManager::setPos(int tileX, int tileY, int direction)
// lm->fAvatarPosition
/* tmw coordinates work exactly the other way round */
- mLinkedMemCache.fAvatarPosition[0] = tileX + mMapBase[0];
- mLinkedMemCache.fAvatarPosition[2] = tileY + mMapBase[2];
+ mLinkedMemCache.fAvatarPosition[0] = static_cast<float>(tileX)
+ + mMapBase[0];
+ mLinkedMemCache.fAvatarPosition[2] = static_cast<float>(tileY)
+ + mMapBase[2];
// Same as avatar but for the camera.
// lm->fCameraPosition, fCameraFront, fCameraTop
@@ -260,7 +262,7 @@ void MumbleManager::setServer(const std::string &serverName)
if (!mLinkedMem)
return;
- unsigned size = serverName.size();
+ unsigned size = static_cast<unsigned>(serverName.size());
if (size > sizeof(mLinkedMemCache.context) - 1)
size = sizeof(mLinkedMemCache.context) - 1;
diff --git a/src/net/download.cpp b/src/net/download.cpp
index aa2793ddb..1badf1763 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -90,7 +90,7 @@ unsigned long Download::fadler32(FILE *file)
// Calculate Adler-32 checksum
char *buffer = static_cast<char*>(malloc(fileSize));
- const size_t read = fread(buffer, 1, fileSize, file);
+ const uInt read = static_cast<uInt>(fread(buffer, 1, fileSize, file));
unsigned long adler = adler32(0L, Z_NULL, 0);
adler = adler32(static_cast<uInt>(adler),
reinterpret_cast<Bytef*>(buffer), read);
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 9ea030862..292915581 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -340,7 +340,7 @@ void PlayerHandler::stopAttack()
}
-void PlayerHandler::emote(int emoteId _UNUSED_)
+void PlayerHandler::emote(Uint8 emoteId _UNUSED_)
{
// TODO
}
@@ -359,7 +359,7 @@ void PlayerHandler::decreaseAttribute(int attr)
gameServerConnection->send(msg);
}
-void PlayerHandler::increaseSkill(int skillId _UNUSED_)
+void PlayerHandler::increaseSkill(unsigned short skillId _UNUSED_)
{
// Not used atm
}
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 7b75b88cb..79909d31c 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -54,11 +54,11 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void attack(int id, bool keep = false);
void stopAttack();
- void emote(int emoteId);
+ void emote(Uint8 emoteId);
void increaseAttribute(int attr);
void decreaseAttribute(int attr);
- void increaseSkill(int skillId);
+ void increaseSkill(unsigned short skillId);
void pickUp(FloorItem *floorItem);
void setDirection(char direction);
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 1862dea58..524340458 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -40,13 +40,13 @@ class PlayerHandler
virtual void stopAttack() = 0;
- virtual void emote(int emoteId) = 0;
+ virtual void emote(Uint8 emoteId) = 0;
virtual void increaseAttribute(int attr) = 0;
virtual void decreaseAttribute(int attr) = 0;
- virtual void increaseSkill(int skillId) = 0;
+ virtual void increaseSkill(unsigned short skillId) = 0;
virtual void pickUp(FloorItem *floorItem) = 0;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index f066db0bd..05f10854a 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -359,7 +359,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
msg.readInt16();
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff);
+ dstBeing->setStatusEffectBlock(0, static_cast<Uint16>(
+ (statusEffects >> 16) & 0xffff));
dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
break;
@@ -649,7 +650,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
switch (type)
{
case 0: // change race
- dstBeing->setSubtype(id);
+ dstBeing->setSubtype(static_cast<Uint16>(id));
break;
case 1: // eAthena LOOK_HAIR
dstBeing->setSpriteID(SPRITE_HAIR, id *-1);
@@ -661,15 +662,18 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
player_node->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 3: // Change lower headgear for eAthena, pants for us
- dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color, id2);
+ dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES);
break;
case 4: // Change upper headgear for eAthena, hat for us
- dstBeing->setSprite(SPRITE_HAT, id, color, id2);
+ dstBeing->setSprite(SPRITE_HAT, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_HAT);
break;
case 5: // Change middle headgear for eathena, armor for us
- dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color, id2);
+ dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES);
break;
case 6: // eAthena LOOK_HAIR_COLOR
@@ -678,35 +682,45 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
case 8: // eAthena LOOK_SHIELD
if (!config.getBoolValue("hideShield"))
- dstBeing->setSprite(SPRITE_SHIELD, id, color, id2);
+ {
+ dstBeing->setSprite(SPRITE_SHIELD, id, color,
+ static_cast<unsigned char>(id2));
+ }
player_node->imitateOutfit(dstBeing, SPRITE_SHIELD);
break;
case 9: // eAthena LOOK_SHOES
- dstBeing->setSprite(SPRITE_SHOE, id, color, id2);
+ dstBeing->setSprite(SPRITE_SHOE, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_SHOE);
break;
case 10: // LOOK_GLOVES
- dstBeing->setSprite(SPRITE_GLOVES, id, color, id2);
+ dstBeing->setSprite(SPRITE_GLOVES, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_GLOVES);
break;
case 11: // LOOK_CAPE
- dstBeing->setSprite(SPRITE_CAPE, id, color, id2);
+ dstBeing->setSprite(SPRITE_CAPE, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_CAPE);
break;
case 12:
- dstBeing->setSprite(SPRITE_MISC1, id, color, id2);
+ dstBeing->setSprite(SPRITE_MISC1, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_MISC1);
break;
case 13:
- dstBeing->setSprite(SPRITE_MISC2, id, color, id2);
+ dstBeing->setSprite(SPRITE_MISC2, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_MISC2);
break;
case 14:
- dstBeing->setSprite(SPRITE_EVOL1, id, color, id2);
+ dstBeing->setSprite(SPRITE_EVOL1, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_EVOL1);
break;
case 15:
- dstBeing->setSprite(SPRITE_EVOL2, id, color, id2);
+ dstBeing->setSprite(SPRITE_EVOL2, id, color,
+ static_cast<unsigned char>(id2));
player_node->imitateOutfit(dstBeing, SPRITE_EVOL2);
break;
default:
@@ -955,14 +969,9 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
int dir = dstBeing->calcDirection(dstX, dstY);
if (dir && dstBeing->getDirection() != dir)
- {
- dstBeing->setDirectionDelayed(dir);
-// dstBeing->clearPath();
-// dstBeing->reset();
- }
+ dstBeing->setDirectionDelayed(static_cast<Uint8>(dir));
}
-
if (player_node->getCurrentAction() != Being::STAND)
player_node->imitateAction(dstBeing, Being::STAND);
if (player_node->getDirection() != dstBeing->getDirection())
@@ -1040,7 +1049,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
}
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff);
+ dstBeing->setStatusEffectBlock(0, static_cast<Uint16>(
+ (statusEffects >> 16) & 0xffff));
dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
if (msg.getId() == SMSG_PLAYER_MOVE
@@ -1105,7 +1115,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
msg.readInt8(); // Unused?
dstBeing->setStunMode(stunMode);
- dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff);
+ dstBeing->setStatusEffectBlock(0, static_cast<Uint16>(
+ (statusEffects >> 16) & 0xffff));
dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff);
break;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 2265afb84..c714c6043 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -82,7 +82,10 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg)
msg.skip(2); // Length word
int slots = msg.readInt16();
if (slots > 0 && slots < 30)
- loginData.characterSlots = slots;
+ {
+ loginData.characterSlots
+ = static_cast<short unsigned int>(slots);
+ }
bool version = msg.readInt8() == 1 && serverVersion > 0;
msg.skip(17); // Unused
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index ed738df4f..198dafeca 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -136,7 +136,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
msg.readInt8(); // Unused
std::string guildName = msg.readString(24);
- Guild *g = Guild::getGuild(guildId);
+ Guild *g = Guild::getGuild(static_cast<short int>(guildId));
if (!g)
break;
@@ -219,7 +219,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
_("Guild castle: %s"), castle.c_str()), BY_SERVER);
}
- Guild *g = Guild::getGuild(guildId);
+ Guild *g = Guild::getGuild(static_cast<short int>(guildId));
if (!g)
break;
g->setName(name);
@@ -703,8 +703,8 @@ void GuildHandler::chat(int guildId _UNUSED_, const std::string &text)
std::string str = player_node->getName() + " : " + text;
MessageOut msg(CMSG_GUILD_MESSAGE);
- msg.writeInt16(str.size() + 4);
- msg.writeString(str, str.length());
+ msg.writeInt16(static_cast<Uint16>(str.size() + 4));
+ msg.writeString(str, static_cast<int>(str.length()));
}
void GuildHandler::memberList(int guildId _UNUSED_)
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 203edaa26..e5ccc9110 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -158,7 +158,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
int number, flag;
int index, amount, itemId, equipType, arrow, refine;
- int identified, cards[4], itemType;
+ int cards[4], itemType;
+ unsigned char identified;
Inventory *inventory = 0;
if (player_node)
inventory = PlayerInfo::getInventory();
@@ -632,14 +633,14 @@ void InventoryHandler::moveItem(int source, int slot, int amount,
if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
{
MessageOut outMsg(CMSG_MOVE_TO_STORAGE);
- outMsg.writeInt16(slot + INVENTORY_OFFSET);
+ outMsg.writeInt16(static_cast<Sint16>(slot + INVENTORY_OFFSET));
outMsg.writeInt32(amount);
}
else if (source == Inventory::STORAGE
&& destination == Inventory::INVENTORY)
{
MessageOut outMsg(CSMG_MOVE_FROM_STORAGE);
- outMsg.writeInt16(slot + STORAGE_OFFSET);
+ outMsg.writeInt16(static_cast<Sint16>(slot + STORAGE_OFFSET));
outMsg.writeInt32(amount);
}
}
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index f085da68c..f70e8cd03 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -189,9 +189,9 @@ void NpcHandler::integerInput(int npcId, int value)
void NpcHandler::stringInput(int npcId, const std::string &value)
{
MessageOut outMsg(CMSG_NPC_STR_RESPONSE);
- outMsg.writeInt16(value.length() + 9);
+ outMsg.writeInt16(static_cast<Sint16>(value.length() + 9));
outMsg.writeInt32(npcId);
- outMsg.writeString(value, value.length());
+ outMsg.writeString(value, static_cast<int>(value.length()));
outMsg.writeInt8(0); // Prevent problems with string reading
}
@@ -228,16 +228,16 @@ void NpcHandler::buyItem(int beingId _UNUSED_, int itemId,
if (serverVersion > 0)
{
outMsg.writeInt16(10); // One item (length of packet)
- outMsg.writeInt16(amount);
- outMsg.writeInt16(itemId);
+ outMsg.writeInt16(static_cast<Sint16>(amount));
+ outMsg.writeInt16(static_cast<Sint16>(itemId));
outMsg.writeInt8(color);
outMsg.writeInt8(0);
}
else
{
outMsg.writeInt16(8); // One item (length of packet)
- outMsg.writeInt16(amount);
- outMsg.writeInt16(itemId);
+ outMsg.writeInt16(static_cast<Sint16>(amount));
+ outMsg.writeInt16(static_cast<Sint16>(itemId));
}
}
@@ -245,8 +245,8 @@ void NpcHandler::sellItem(int beingId _UNUSED_, int itemId, int amount)
{
MessageOut outMsg(CMSG_NPC_SELL_REQUEST);
outMsg.writeInt16(8); // One item (length of packet)
- outMsg.writeInt16(itemId + INVENTORY_OFFSET);
- outMsg.writeInt16(amount);
+ outMsg.writeInt16(static_cast<Sint16>(itemId + INVENTORY_OFFSET));
+ outMsg.writeInt16(static_cast<Sint16>(amount));
}
void NpcHandler::endShopping(int beingId _UNUSED_)
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index bd9766c4b..10d2a20f0 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -538,8 +538,8 @@ void PartyHandler::kick(const std::string &name)
void PartyHandler::chat(const std::string &text)
{
MessageOut outMsg(CMSG_PARTY_MESSAGE);
- outMsg.writeInt16(text.length() + 4);
- outMsg.writeString(text, text.length());
+ outMsg.writeInt16(static_cast<Sint16>(text.length() + 4));
+ outMsg.writeString(text, static_cast<int>(text.length()));
}
void PartyHandler::requestPartyMembers()
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 55908093f..6078dd761 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -137,7 +137,8 @@ static const char *randomDeathMessage()
N_("You're pining for the fjords.")
};
- const int random = rand() % (sizeof(deadMsg) / sizeof(deadMsg[0]));
+ const int random = static_cast<int>(rand() % (sizeof(deadMsg)
+ / sizeof(deadMsg[0])));
return gettext(deadMsg[random]);
}
@@ -228,10 +229,12 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
Map *map = game->getCurrentMap();
if (map)
{
- scrollOffsetX = (x - player_node->getTileX())
- * map->getTileWidth();
- scrollOffsetY = (y - player_node->getTileY())
- * map->getTileHeight();
+ scrollOffsetX = static_cast<float>((x
+ - player_node->getTileX())
+ * map->getTileWidth());
+ scrollOffsetY = static_cast<float>((y
+ - player_node->getTileY())
+ * map->getTileHeight());
}
}
@@ -260,7 +263,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
switch (type)
{
case 0x0000:
- player_node->setWalkSpeed(Vector(value, value, 0));
+ player_node->setWalkSpeed(Vector(static_cast<float>(
+ value), static_cast<float>(value), 0));
PlayerInfo::setStatBase(WALK_SPEED, value);
PlayerInfo::setStatMod(WALK_SPEED, 0);
break;
@@ -644,7 +648,7 @@ void PlayerHandler::stopAttack()
MessageOut outMsg(CMSG_PLAYER_STOP_ATTACK);
}
-void PlayerHandler::emote(int emoteId)
+void PlayerHandler::emote(Uint8 emoteId)
{
MessageOut outMsg(CMSG_PLAYER_EMOTE);
outMsg.writeInt8(emoteId);
@@ -655,7 +659,7 @@ void PlayerHandler::increaseAttribute(int attr)
if (attr >= STR && attr <= LUK)
{
MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST);
- outMsg.writeInt16(attr);
+ outMsg.writeInt16(static_cast<Sint16>(attr));
outMsg.writeInt8(1);
}
}
@@ -665,7 +669,7 @@ void PlayerHandler::decreaseAttribute(int attr _UNUSED_)
// Supported by eA?
}
-void PlayerHandler::increaseSkill(int skillId)
+void PlayerHandler::increaseSkill(unsigned short skillId)
{
if (PlayerInfo::getAttribute(SKILL_POINTS) <= 0)
return;
@@ -693,7 +697,9 @@ void PlayerHandler::setDirection(char direction)
void PlayerHandler::setDestination(int x, int y, int direction)
{
MessageOut outMsg(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeCoordinates(x, y, direction);
+ outMsg.writeCoordinates(static_cast<short unsigned int>(x),
+ static_cast<short unsigned int>(y),
+ static_cast<unsigned char>(direction));
}
void PlayerHandler::changeAction(Being::Action action)
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 095a00d94..f77bd11b8 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -46,11 +46,11 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
void attack(int id, bool keep = false);
void stopAttack();
- void emote(int emoteId);
+ void emote(Uint8 emoteId);
void increaseAttribute(int attr);
void decreaseAttribute(int attr);
- void increaseSkill(int skillId);
+ void increaseSkill(unsigned short skillId);
void pickUp(FloorItem *floorItem);
void setDirection(char direction);
diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp
index f632248ab..586f5fe00 100644
--- a/src/net/tmwa/specialhandler.cpp
+++ b/src/net/tmwa/specialhandler.cpp
@@ -256,24 +256,24 @@ void SpecialHandler::use(int id _UNUSED_)
void SpecialHandler::use(int id, int level, int beingId)
{
MessageOut outMsg(CMSG_SKILL_USE_BEING);
- outMsg.writeInt16(level);
- outMsg.writeInt16(id);
- outMsg.writeInt16(beingId);
+ outMsg.writeInt16(static_cast<Sint16>(level));
+ outMsg.writeInt16(static_cast<Sint16>(id));
+ outMsg.writeInt16(static_cast<Sint16>(beingId));
}
void SpecialHandler::use(int id, int level, int x, int y)
{
MessageOut outMsg(CMSG_SKILL_USE_POSITION);
- outMsg.writeInt16(level);
- outMsg.writeInt16(id);
- outMsg.writeInt16(x);
- outMsg.writeInt16(y);
+ outMsg.writeInt16(static_cast<Sint16>(level));
+ outMsg.writeInt16(static_cast<Sint16>(id));
+ outMsg.writeInt16(static_cast<Sint16>(x));
+ outMsg.writeInt16(static_cast<Sint16>(y));
}
void SpecialHandler::use(int id, const std::string &map)
{
MessageOut outMsg(CMSG_SKILL_USE_MAP);
- outMsg.writeInt16(id);
+ outMsg.writeInt16(static_cast<Sint16>(id));
outMsg.writeString(map, 16);
}
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 581031f23..b7cf70661 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -208,7 +208,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
else
{
tradeWindow->addItem2(type, false, amount, refine,
- identify, false);
+ static_cast<unsigned char>(identify), false);
}
}
}
@@ -325,7 +325,8 @@ void TradeHandler::addItem(Item *item, int amount)
return;
MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET);
+ outMsg.writeInt16(static_cast<Sint16>(
+ item->getInvIndex() + INVENTORY_OFFSET));
outMsg.writeInt32(amount);
}
diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h
index 3e0548336..b02e9fa21 100644
--- a/src/net/worldinfo.h
+++ b/src/net/worldinfo.h
@@ -31,7 +31,7 @@ struct WorldInfo
int address;
std::string name;
short port;
- short online_users;
+ int online_users;
std::string updateHost;
};
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp
index 03742ccb3..3dfe06ecf 100644
--- a/src/opengl1graphics.cpp
+++ b/src/opengl1graphics.cpp
@@ -121,11 +121,13 @@ static inline void drawQuad(Image *image,
if (image->getTextureType() == GL_TEXTURE_2D)
{
// Find OpenGL normalized texture coordinates.
- float texX1 = srcX / static_cast<float>(image->getTextureWidth());
- float texY1 = srcY / static_cast<float>(image->getTextureHeight());
- float texX2 = (srcX + width) / static_cast<float>(
+ float texX1 = static_cast<float>(srcX)
+ / static_cast<float>(image->getTextureWidth());
+ float texY1 = static_cast<float>(srcY)
+ / static_cast<float>(image->getTextureHeight());
+ float texX2 = static_cast<float>(srcX + width) / static_cast<float>(
image->getTextureWidth());
- float texY2 = (srcY + height) / static_cast<float>(
+ float texY2 = static_cast<float>(srcY + height) / static_cast<float>(
image->getTextureHeight());
glTexCoord2f(texX1, texY1);
@@ -157,11 +159,13 @@ static inline void drawRescaledQuad(Image *image, int srcX, int srcY,
if (image->getTextureType() == GL_TEXTURE_2D)
{
// Find OpenGL normalized texture coordinates.
- float texX1 = srcX / static_cast<float>(image->getTextureWidth());
- float texY1 = srcY / static_cast<float>(image->getTextureHeight());
- float texX2 = (srcX + width) / static_cast<float>(
+ float texX1 = static_cast<float>(srcX)
+ / static_cast<float>(image->getTextureWidth());
+ float texY1 = static_cast<float>(srcY)
+ / static_cast<float>(image->getTextureHeight());
+ float texX2 = static_cast<float>(srcX + width) / static_cast<float>(
image->getTextureWidth());
- float texY2 = (srcY + height) / static_cast<float>(
+ float texY2 = static_cast<float>(srcY + height) / static_cast<float>(
image->getTextureHeight());
glTexCoord2f(texX1, texY1);
@@ -383,7 +387,8 @@ void OpenGL1Graphics::drawRescaledImagePattern(Image *image, int x, int y,
glEnd();
- glColor4ub(mColor.r, mColor.g, mColor.b, mColor.a);
+ glColor4ub(static_cast<GLubyte>(mColor.r), static_cast<GLubyte>(mColor.g),
+ static_cast<GLubyte>(mColor.b), static_cast<GLubyte>(mColor.a));
}
void OpenGL1Graphics::updateScreen()
@@ -525,12 +530,12 @@ void OpenGL1Graphics::drawLine(int x1, int y1, int x2, int y2)
setTexturingAndBlending(false);
glBegin(GL_LINES);
- glVertex2f(x1 + 0.5f, y1 + 0.5f);
- glVertex2f(x2 + 0.5f, y2 + 0.5f);
+ glVertex2f(static_cast<float>(x1) + 0.5f, static_cast<float>(y1) + 0.5f);
+ glVertex2f(static_cast<float>(x2) + 0.5f, static_cast<float>(y2) + 0.5f);
glEnd();
glBegin(GL_POINTS);
- glVertex2f(x2 + 0.5f, y2 + 0.5f);
+ glVertex2f(static_cast<float>(x2) + 0.5f, static_cast<float>(y2) + 0.5f);
glEnd();
}
@@ -593,10 +598,14 @@ void OpenGL1Graphics::drawRectangle(const gcn::Rectangle& rect, bool filled)
setTexturingAndBlending(false);
glBegin(filled ? GL_QUADS : GL_LINE_LOOP);
- glVertex2f(rect.x + offset, rect.y + offset);
- glVertex2f(rect.x + rect.width - offset, rect.y + offset);
- glVertex2f(rect.x + rect.width - offset, rect.y + rect.height - offset);
- glVertex2f(rect.x + offset, rect.y + rect.height - offset);
+ glVertex2f(static_cast<float>(rect.x) + offset,
+ static_cast<float>(rect.y) + offset);
+ glVertex2f(static_cast<float>(rect.x + rect.width) - offset,
+ static_cast<float>(rect.y) + offset);
+ glVertex2f(static_cast<float>(rect.x + rect.width) - offset,
+ static_cast<float>(rect.y + rect.height) - offset);
+ glVertex2f(static_cast<float>(rect.x) + offset,
+ static_cast<float>(rect.y + rect.height) - offset);
glEnd();
}
diff --git a/src/particle.cpp b/src/particle.cpp
index 9ecd8e65d..807bca084 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -140,8 +140,8 @@ bool Particle::update()
+ static_cast<float>(fabs(dist.z));
break;
default:
- invHypotenuse = 1.0f / sqrt(
- dist.x * dist.x + dist.y * dist.y + dist.z * dist.z);
+ invHypotenuse = 1.0f / static_cast<float>(sqrt(
+ dist.x * dist.x + dist.y * dist.y + dist.z * dist.z));
break;
}
@@ -156,12 +156,12 @@ bool Particle::update()
if (mRandomness > 0)
{
- mVelocity.x += (rand() % mRandomness - rand()
- % mRandomness) / 1000.0f;
- mVelocity.y += (rand() % mRandomness - rand()
- % mRandomness) / 1000.0f;
- mVelocity.z += (rand() % mRandomness - rand()
- % mRandomness) / 1000.0f;
+ mVelocity.x += static_cast<float>((rand() % mRandomness - rand()
+ % mRandomness)) / 1000.0f;
+ mVelocity.y += static_cast<float>((rand() % mRandomness - rand()
+ % mRandomness)) / 1000.0f;
+ mVelocity.z += static_cast<float>((rand() % mRandomness - rand()
+ % mRandomness)) / 1000.0f;
}
mVelocity.z -= mGravity;
@@ -327,12 +327,12 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
}
// Read and set the basic properties of the particle
- float offsetX = XML::getFloatProperty(
- effectChildNode, "position-x", 0);
- float offsetY = XML::getFloatProperty(
- effectChildNode, "position-y", 0);
- float offsetZ = XML::getFloatProperty(
- effectChildNode, "position-z", 0);
+ float offsetX = static_cast<float>(XML::getFloatProperty(
+ effectChildNode, "position-x", 0));
+ float offsetY = static_cast<float>(XML::getFloatProperty(
+ effectChildNode, "position-y", 0));
+ float offsetZ = static_cast<float>(XML::getFloatProperty(
+ effectChildNode, "position-z", 0));
Vector position (mPos.x + static_cast<float>(pixelX) + offsetX,
mPos.y + static_cast<float>(pixelY) + offsetY,
mPos.z + offsetZ);
@@ -363,23 +363,28 @@ Particle *Particle::addEffect(const std::string &particleEffectFile,
char deathEffectConditions = 0x00;
if (XML::getBoolProperty(emitterNode, "on-floor", true))
{
- deathEffectConditions += Particle::DEAD_FLOOR;
+ deathEffectConditions += static_cast<char>(
+ Particle::DEAD_FLOOR);
}
if (XML::getBoolProperty(emitterNode, "on-sky", true))
{
- deathEffectConditions += Particle::DEAD_SKY;
+ deathEffectConditions += static_cast<char>(
+ Particle::DEAD_SKY);
}
if (XML::getBoolProperty(emitterNode, "on-other", false))
{
- deathEffectConditions += Particle::DEAD_OTHER;
+ deathEffectConditions += static_cast<char>(
+ Particle::DEAD_OTHER);
}
if (XML::getBoolProperty(emitterNode, "on-impact", true))
{
- deathEffectConditions += Particle::DEAD_IMPACT;
+ deathEffectConditions += static_cast<char>(
+ Particle::DEAD_IMPACT);
}
if (XML::getBoolProperty(emitterNode, "on-timeout", true))
{
- deathEffectConditions += Particle::DEAD_TIMEOUT;
+ deathEffectConditions += static_cast<char>(
+ Particle::DEAD_TIMEOUT);
}
newParticle->setDeathEffect(
deathEffect, deathEffectConditions);
@@ -398,9 +403,11 @@ Particle *Particle::addTextSplashEffect(const std::string &text, int x, int y,
{
Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
newParticle->moveTo(static_cast<float>(x), static_cast<float>(y));
- newParticle->setVelocity(((rand() % 100) - 50) / 200.0f, // X
- ((rand() % 100) - 50) / 200.0f, // Y
- ((rand() % 100) / 200.0f) + 4.0f); // Z
+ newParticle->setVelocity(
+ static_cast<float>((rand() % 100) - 50) / 200.0f, // X
+ static_cast<float>((rand() % 100) - 50) / 200.0f, // Y
+ (static_cast<float>((rand() % 100)) / 200.0f) + 4.0f); // Z
+
newParticle->setGravity(0.1f);
newParticle->setBounce(0.5f);
newParticle->setLifetime(200);
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index f1bb81d59..cd42fd865 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -357,15 +357,30 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target,
propertyNode->xmlChildrenNode->content);
mDeathEffectConditions = 0x00;
if (XML::getBoolProperty(propertyNode, "on-floor", true))
- mDeathEffectConditions += Particle::DEAD_FLOOR;
+ {
+ mDeathEffectConditions += static_cast<char>(
+ Particle::DEAD_FLOOR);
+ }
if (XML::getBoolProperty(propertyNode, "on-sky", true))
- mDeathEffectConditions += Particle::DEAD_SKY;
+ {
+ mDeathEffectConditions += static_cast<char>(
+ Particle::DEAD_SKY);
+ }
if (XML::getBoolProperty(propertyNode, "on-other", false))
- mDeathEffectConditions += Particle::DEAD_OTHER;
+ {
+ mDeathEffectConditions += static_cast<char>(
+ Particle::DEAD_OTHER);
+ }
if (XML::getBoolProperty(propertyNode, "on-impact", true))
- mDeathEffectConditions += Particle::DEAD_IMPACT;
+ {
+ mDeathEffectConditions += static_cast<char>(
+ Particle::DEAD_IMPACT);
+ }
if (XML::getBoolProperty(propertyNode, "on-timeout", true))
- mDeathEffectConditions += Particle::DEAD_TIMEOUT;
+ {
+ mDeathEffectConditions += static_cast<char>(
+ Particle::DEAD_TIMEOUT);
+ }
}
}
}
@@ -570,6 +585,8 @@ void ParticleEmitter::adjustSize(int w, int h)
// adjust the output so that the particle density stays the same
float outputFactor = static_cast<float>(newArea)
/ static_cast<float>(oldArea);
- mOutput.minVal *= static_cast<float>(outputFactor);
- mOutput.maxVal *= static_cast<float>(outputFactor);
+ mOutput.minVal = static_cast<int>(static_cast<float>(
+ mOutput.minVal) * outputFactor);
+ mOutput.maxVal = static_cast<int>(static_cast<float>(
+ mOutput.maxVal) * outputFactor);
}
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 70f183d0e..09813c43f 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -139,7 +139,7 @@ const std::string ItemInfo::replaceColors(std::string str,
str = replaceAll(str, "%color%", name);
if (name.size() > 0)
- name[0] = toupper(name[0]);
+ name[0] = static_cast<char>(toupper(name[0]));
return replaceAll(str, "%Color%", name);
}
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index ef630fc67..31451c09a 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -198,19 +198,19 @@ std::string SpellManager::parseCommand(std::string command,
bool found = false;
- int idx = command.find("<TARGET>");
+ int idx = static_cast<int>(command.find("<TARGET>"));
if (idx >= 0)
{
found = true;
command = replaceAll(command, "<TARGET>", name);
}
- idx = command.find("<TARGETID>");
+ idx = static_cast<int>(command.find("<TARGETID>"));
if (idx >= 0)
{
found = true;
command = replaceAll(command, "<TARGETID>", id);
}
- idx = command.find("<TARGETORSELF>");
+ idx = static_cast<int>(command.find("<TARGETORSELF>"));
if (idx >= 0)
{
found = true;
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index c7f34a5d9..cdd928105 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -119,7 +119,7 @@ unsigned char *php3_base64_decode(const unsigned char *string,
chp = strchr(base64_table, ch);
if (!chp)
continue;
- ch = chp - base64_table;
+ ch = static_cast<int>(chp - base64_table);
switch(i % 4)
{
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index 26456ede2..e71bd4892 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -48,7 +48,7 @@ int mkdir_r(const char *pathname)
strncpy(tmp, pathname, sizeof(tmp) - 1);
tmp[PATH_MAX - 1] = '\0';
- int len = strlen(tmp);
+ int len = static_cast<int>(strlen(tmp));
// terminate the pathname with '/'
if (tmp[len - 1] != '/')
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index 80126479a..b38bbb7db 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -290,5 +290,5 @@ std::string SHA256Hash(const char *src, int len)
std::string sha256(const std::string &string)
{
- return SHA256Hash(string.c_str(), string.length());
+ return SHA256Hash(string.c_str(), static_cast<int>(string.length()));
}
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index b5c2abd3e..02bba8599 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -338,7 +338,7 @@ void replaceSpecialChars(std::string &text)
if (idx >= text.size())
break;
- unsigned f;
+ size_t f;
for (f = idx; f < text.size(); f ++)
{
if (text[f] < '0' || text[f] > '9')