From 9fe21fcd8883b37bdc30224822e6e42afb35b8f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 7 Feb 2016 16:18:13 +0300 Subject: Replace most static_cast to shorter versions from defines. --- src/being/actor.h | 6 +-- src/being/actorsprite.cpp | 26 +++++------ src/being/actorsprite.h | 4 +- src/being/being.cpp | 58 ++++++++++++------------ src/being/being.h | 8 ++-- src/being/compoundsprite.cpp | 6 +-- src/being/crazymoves.cpp | 8 ++-- src/being/localplayer.cpp | 102 +++++++++++++++++++++--------------------- src/being/playerrelations.cpp | 10 ++--- 9 files changed, 114 insertions(+), 114 deletions(-) (limited to 'src/being') diff --git a/src/being/actor.h b/src/being/actor.h index ab79c6935..3e004c419 100644 --- a/src/being/actor.h +++ b/src/being/actor.h @@ -83,19 +83,19 @@ class Actor notfinal * Returns the pixels X coordinate of the actor. */ int getPixelX() const A_WARN_UNUSED - { return static_cast(mPos.x); } + { return CAST_S32(mPos.x); } /** * Returns the pixel Y coordinate of the actor. */ virtual int getPixelY() const A_WARN_UNUSED - { return static_cast(mPos.y); } + { return CAST_S32(mPos.y); } /** * Returns the pixel Y coordinate of the actor for sorting only. */ virtual int getSortPixelY() const A_WARN_UNUSED - { return static_cast(mPos.y) - mYDiff; } + { return CAST_S32(mPos.y) - mYDiff; } /** * Returns the x coordinate in tiles of the actor. diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index d31bb9317..02da33367 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -47,12 +47,12 @@ #include "debug.h" #define for_each_cursors() \ - for (int size = static_cast(TargetCursorSize::SMALL); \ - size < static_cast(TargetCursorSize::NUM_TC); \ + for (int size = CAST_S32(TargetCursorSize::SMALL); \ + size < CAST_S32(TargetCursorSize::NUM_TC); \ size ++) \ { \ - for (int type = static_cast(TargetCursorType::NORMAL); \ - type < static_cast(TargetCursorType::NUM_TCT); \ + for (int type = CAST_S32(TargetCursorType::NORMAL); \ + type < CAST_S32(TargetCursorType::NUM_TCT); \ type ++) \ #define end_foreach } @@ -60,8 +60,8 @@ static const unsigned int STATUS_EFFECTS = 32; AnimatedSprite *ActorSprite::targetCursor - [static_cast(TargetCursorType::NUM_TCT)] - [static_cast(TargetCursorSize::NUM_TC)]; + [CAST_SIZE(TargetCursorType::NUM_TCT)] + [CAST_SIZE(TargetCursorSize::NUM_TC)]; bool ActorSprite::loaded = false; ActorSprite::ActorSprite(const BeingId id) : @@ -163,19 +163,19 @@ void ActorSprite::setTargetType(const TargetCursorTypeT type) } else { - const size_t sz = static_cast(getTargetCursorSize()); - mUsedTargetCursor = targetCursor[static_cast(type)][sz]; + const size_t sz = CAST_SIZE(getTargetCursorSize()); + mUsedTargetCursor = targetCursor[CAST_S32(type)][sz]; if (mUsedTargetCursor) { - static const int targetWidths[static_cast( + static const int targetWidths[CAST_SIZE( TargetCursorSize::NUM_TC)] = {0, 0, 0}; - static const int targetHeights[static_cast( + static const int targetHeights[CAST_SIZE( TargetCursorSize::NUM_TC)] = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize}; - mCursorPaddingX = static_cast(targetWidths[sz]); - mCursorPaddingY = static_cast(targetHeights[sz]); + mCursorPaddingX = CAST_S32(targetWidths[sz]); + mCursorPaddingY = CAST_S32(targetHeights[sz]); } } } @@ -219,7 +219,7 @@ void ActorSprite::setStatusEffectBlock(const int offset, const std::string str = strprintf( "Error: unknown effect by block-index. " "Offset: %d, effect int: %d, i: %u", - offset, static_cast(newEffects), i); + offset, CAST_S32(newEffects), i); logger->log(str); DebugMessageListener::distributeEvent(str); } diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 314fff9fb..2ca5065ef 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -225,8 +225,8 @@ class ActorSprite notfinal : public CompoundSprite, public Actor /** Animated target cursors. */ static AnimatedSprite *targetCursor - [static_cast(TargetCursorType::NUM_TCT)] - [static_cast(TargetCursorSize::NUM_TC)]; + [CAST_SIZE(TargetCursorType::NUM_TCT)] + [CAST_SIZE(TargetCursorSize::NUM_TC)]; static bool loaded; diff --git a/src/being/being.cpp b/src/being/being.cpp index 2de362365..50875878b 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -517,8 +517,8 @@ void Being::setPosition(const Vector &restrict pos) restrict2 if (mText) { - mText->adviseXY(static_cast(pos.x), - static_cast(pos.y) - getHeight() - mText->getHeight() - 6, + mText->adviseXY(CAST_S32(pos.x), + CAST_S32(pos.y) - getHeight() - mText->getHeight() - 6, mMoveNames); } } @@ -581,11 +581,11 @@ void Being::setSpeech(const std::string &restrict text, { const size_t sz = mSpeech.size(); if (sz < 200) - time = static_cast(SPEECH_TIME - 300 + (3 * sz)); + time = CAST_S32(SPEECH_TIME - 300 + (3 * sz)); } - if (time < static_cast(SPEECH_MIN_TIME)) - time = static_cast(SPEECH_MIN_TIME); + if (time < CAST_S32(SPEECH_MIN_TIME)) + time = CAST_S32(SPEECH_MIN_TIME); // Check for links size_t start = mSpeech.find('['); @@ -620,8 +620,8 @@ void Being::setSpeech(const std::string &restrict text, if (!mSpeech.empty()) { - mSpeechTime = time <= static_cast(SPEECH_MAX_TIME) - ? time : static_cast(SPEECH_MAX_TIME); + mSpeechTime = time <= CAST_S32(SPEECH_MAX_TIME) + ? time : CAST_S32(SPEECH_MAX_TIME); } const int speech = mSpeechType; @@ -1545,7 +1545,7 @@ void Being::setAction(const BeingActionT &restrict action, case BeingAction::PRESTAND: default: logger->log("Being::setAction unknown action: " - + toString(static_cast(action))); + + toString(CAST_U32(action))); break; } @@ -1696,7 +1696,7 @@ void Being::nextTile() restrict2 return; } - mActionTime += static_cast(mSpeed / 10); + mActionTime += CAST_S32(mSpeed / 10); if ((mType != ActorType::Player || mUseDiagonal) && mX != pos.x && mY != pos.y) { @@ -1752,7 +1752,7 @@ void Being::logic() restrict2 sprite->update(time); } - int frameCount = static_cast(getFrameCount()); + int frameCount = CAST_S32(getFrameCount()); switch (mAction) { @@ -1845,7 +1845,7 @@ void Being::logic() restrict2 frameCount = 10; if (!isAlive() && mSpeed && gameHandler->removeDeadBeings() - && static_cast ((static_cast(get_elapsed_time(mActionTime)) + && CAST_S32 ((static_cast(get_elapsed_time(mActionTime)) / mSpeed)) >= frameCount) { if (mType != ActorType::Player && actorManager) @@ -1882,7 +1882,7 @@ void Being::petLogic() restrict2 const int time = tick_time; const int thinkTime = mInfo->getThinkTime(); - if (abs(static_cast(mMoveTime) - time) < thinkTime) + if (abs(CAST_S32(mMoveTime) - time) < thinkTime) return; mMoveTime = time; @@ -2161,9 +2161,9 @@ int Being::getOffset(const signed char pos, const int time = get_elapsed_time(mActionTime); offset = (pos == BeingDirection::LEFT && neg == BeingDirection::RIGHT) ? - static_cast((static_cast(time) + CAST_S32((static_cast(time) * static_cast(mMap->getTileWidth())) / mSpeed) : - static_cast((static_cast(time) + CAST_S32((static_cast(time) * static_cast(mMap->getTileHeight())) / mSpeed); } @@ -2440,7 +2440,7 @@ void Being::updateSprite(const unsigned int slot, if (!charServerHandler || slot >= charServerHandler->maxSprite()) return; - if (slot >= static_cast(mSpriteIDs.size())) + if (slot >= CAST_U32(mSpriteIDs.size())) mSpriteIDs.resize(slot + 1, 0); if (slot && mSpriteIDs[slot] == id) @@ -2458,16 +2458,16 @@ void Being::setSprite(const unsigned int slot, if (!charServerHandler || slot >= charServerHandler->maxSprite()) return; - if (slot >= static_cast(size())) + if (slot >= CAST_U32(size())) ensureSize(slot + 1); - if (slot >= static_cast(mSpriteIDs.size())) + if (slot >= CAST_U32(mSpriteIDs.size())) mSpriteIDs.resize(slot + 1, 0); - if (slot >= static_cast(mSpriteColors.size())) + if (slot >= CAST_U32(mSpriteColors.size())) mSpriteColors.resize(slot + 1, ""); - if (slot >= static_cast(mSpriteColorsIds.size())) + if (slot >= CAST_U32(mSpriteColorsIds.size())) mSpriteColorsIds.resize(slot + 1, ItemColor_one); // disabled for now, because it may broke replace/reorder sprites logic @@ -2654,7 +2654,7 @@ void Being::reReadConfig() mHideErased = config.getBoolValue("hideErased"); mMoveNames = fromBool(config.getBoolValue("moveNames"), Move); mUseDiagonal = config.getBoolValue("useDiagonalSpeed"); - mShowBadges = static_cast(config.getIntValue("showBadges")); + mShowBadges = CAST_U8(config.getIntValue("showBadges")); mUpdateConfigTime = cur_time; } @@ -2783,7 +2783,7 @@ void Being::setGender(const GenderT gender) restrict2 // Reload all subsprites for (unsigned int i = 0; - i < static_cast(mSpriteIDs.size()); + i < CAST_U32(mSpriteIDs.size()); i++) { if (mSpriteIDs.at(i) != 0) @@ -2901,7 +2901,7 @@ void Being::drawSprites(Graphics *restrict const graphics, void Being::drawSpritesSDL(Graphics *restrict const graphics, int posX, int posY) const restrict2 { - const unsigned int sz = static_cast(size()); + const unsigned int sz = CAST_U32(size()); for (unsigned int f = 0; f < sz; f ++) { const int rSprite = mSpriteHide[mSpriteRemap[f]]; @@ -3134,7 +3134,7 @@ void Being::recalcSpritesOrder() restrict2 for (size_t slot = 0; slot < sz; slot ++) { - slotRemap.push_back(static_cast(slot)); + slotRemap.push_back(CAST_S32(slot)); if (spriteIdSize <= slot) continue; @@ -3177,7 +3177,7 @@ void Being::recalcSpritesOrder() restrict2 mSpriteHide[remSprite] = repIt->second; if (repIt->second != 1) { - if (static_cast(remSprite) + if (CAST_U32(remSprite) != hairSlot) { setSprite(remSprite, repIt->second, @@ -3299,7 +3299,7 @@ void Being::recalcSpritesOrder() restrict2 const int val = slotRemap.at(slot); int id = 0; - if (static_cast(spriteIdSize) > val) + if (CAST_S32(spriteIdSize) > val) id = mSpriteIDs[val]; int idx = -1; @@ -3404,7 +3404,7 @@ int Being::searchSlotValue(const std::vector &restrict slotRemap, for (size_t slot = 0; slot < sz; slot ++) { if (slotRemap[slot] == val) - return static_cast(slot); + return CAST_S32(slot); } return getNumberOfLayers() - 1; } @@ -3461,7 +3461,7 @@ void Being::undressItemById(const int id) restrict2 { if (id == mSpriteIDs[f]) { - setSprite(static_cast(f), 0); + setSprite(CAST_U32(f), 0); break; } } @@ -3677,7 +3677,7 @@ GenderT Being::intToGender(const uint8_t sex) int Being::getSpriteID(const int slot) const restrict2 { - if (slot < 0 || static_cast(slot) >= mSpriteIDs.size()) + if (slot < 0 || CAST_SIZE(slot) >= mSpriteIDs.size()) return -1; return mSpriteIDs[slot]; @@ -3685,7 +3685,7 @@ int Being::getSpriteID(const int slot) const restrict2 ItemColor Being::getSpriteColor(const int slot) const restrict2 { - if (slot < 0 || static_cast(slot) >= mSpriteColorsIds.size()) + if (slot < 0 || CAST_SIZE(slot) >= mSpriteColorsIds.size()) return ItemColor_one; return mSpriteColorsIds[slot]; diff --git a/src/being/being.h b/src/being/being.h index c91cac5b9..ee073977b 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -286,7 +286,7 @@ class Being notfinal : public ActorSprite, * Get number of guilds the being belongs to. */ int16_t getNumberOfGuilds() const restrict2 A_WARN_UNUSED - { return static_cast(mGuilds.size()); } + { return CAST_S16(mGuilds.size()); } bool isInParty() const restrict2 noexcept A_WARN_UNUSED { return mParty; } @@ -301,7 +301,7 @@ class Being notfinal : public ActorSprite, { return mParty; } int getSpritesCount() const restrict2 A_WARN_UNUSED - { return static_cast(size()); } + { return CAST_S32(size()); } /** * Sets visible equipments for this being. @@ -891,8 +891,8 @@ class Being notfinal : public ActorSprite, void setPath(const Path &restrict path) restrict2; int getSortPixelY() const restrict2 override A_WARN_UNUSED - { return static_cast(mPos.y) - mYDiff - mSortOffsetY; } -// { return static_cast(mPos.y) - mYDiff - mSortOffsetY + 16; } + { return CAST_S32(mPos.y) - mYDiff - mSortOffsetY; } +// { return CAST_S32(mPos.y) - mYDiff - mSortOffsetY + 16; } void setMap(Map *restrict const map) restrict2 override; diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index df3cfcec0..110870c07 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -232,7 +232,7 @@ int CompoundSprite::getNumberOfLayers() const if (mImage || mAlphaImage) return 1; else - return static_cast(size()); + return CAST_S32(size()); } unsigned int CompoundSprite::getCurrentFrame() const @@ -312,7 +312,7 @@ void CompoundSprite::ensureSize(size_t layerCount) */ unsigned int CompoundSprite::getCurrentFrame(unsigned int layer) const { - if (layer >= static_cast(mSprites.size())) + if (layer >= CAST_U32(mSprites.size())) return 0; const Sprite *const s = getSprite(layer); @@ -327,7 +327,7 @@ unsigned int CompoundSprite::getCurrentFrame(unsigned int layer) const */ unsigned int CompoundSprite::getFrameCount(unsigned int layer) { - if (layer >= static_cast(mSprites.size())) + if (layer >= CAST_U32(mSprites.size())) return 0; const Sprite *const s = getSprite(layer); diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp index 34441d6e6..3eb3fd3f4 100644 --- a/src/being/crazymoves.cpp +++ b/src/being/crazymoves.cpp @@ -738,17 +738,17 @@ void CrazyMoves::crazyMoveAe() if (emo == '?') { srand(tick_time); - emoteId = static_cast( + emoteId = CAST_U8( 1 + (rand() % EmoteDB::size())); } else { if (emo >= '0' && emo <= '9') - emoteId = static_cast(emo - '0' + 1); + emoteId = CAST_U8(emo - '0' + 1); else if (emo >= 'a' && emo <= 'z') - emoteId = static_cast(emo - 'a' + 11); + emoteId = CAST_U8(emo - 'a' + 11); else if (emo >= 'A' && emo <= 'Z') - emoteId = static_cast(emo - 'A' + 37); + emoteId = CAST_U8(emo - 'A' + 37); } if (mMoveProgram[settings.crazyMoveState - 1] == 'e') localPlayer->emote(emoteId); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 1d0fd92aa..f59af9c10 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -190,7 +190,7 @@ LocalPlayer::LocalPlayer(const BeingId id, mNameColor = nullptr; PlayerInfo::setStatBase(Attributes::WALK_SPEED, - static_cast(getWalkSpeed().x)); + CAST_S32(getWalkSpeed().x)); PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0); loadHomes(); @@ -300,9 +300,9 @@ void LocalPlayer::logic() else { // Find whether target is in range - const int rangeX = static_cast( + const int rangeX = CAST_S32( abs(mTarget->getTileX() - getTileX())); - const int rangeY = static_cast( + const int rangeY = CAST_S32( abs(mTarget->getTileY() - getTileY())); const int attackRange = getAttackRange(); const TargetCursorTypeT targetType @@ -391,7 +391,7 @@ void LocalPlayer::setAction(const BeingActionT &action, Being::setAction(action, attackType); #ifdef USE_MUMBLE if (mumbleManager) - mumbleManager->setAction(static_cast(action)); + mumbleManager->setAction(CAST_S32(action)); #endif } @@ -498,8 +498,8 @@ bool LocalPlayer::pickUp(FloorItem *const item) { const Vector &playerPos = getPosition(); const Path debugPath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, item->getTileX(), item->getTileY(), getBlockWalkMask(), 0); if (!debugPath.empty()) navigateTo(item->getTileX(), item->getTileY()); @@ -684,13 +684,13 @@ void LocalPlayer::stopWalking(const bool sendToServer) mWalkingDir = 0; mPickUpTarget = nullptr; - setDestination(static_cast(getPosition().x), - static_cast(getPosition().y)); + setDestination(CAST_S32(getPosition().x), + CAST_S32(getPosition().y)); if (sendToServer) { playerHandler->setDestination( - static_cast(getPosition().x), - static_cast(getPosition().y), -1); + CAST_S32(getPosition().x), + CAST_S32(getPosition().y), -1); } setAction(BeingAction::STAND); } @@ -968,8 +968,8 @@ bool LocalPlayer::withinAttackRange(const Being *const target, if (fixDistance && range == 1) range = 2; - dx = static_cast(abs(target->getTileX() - mX)); - dy = static_cast(abs(target->getTileY() - mY)); + dx = CAST_S32(abs(target->getTileX() - mX)); + dy = CAST_S32(abs(target->getTileY() - mY)); return !(dx > range || dy > range); } @@ -1005,7 +1005,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect, { mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i); if (miniStatusWindow) - miniStatusWindow->eraseIcon(static_cast(i)); + miniStatusWindow->eraseIcon(CAST_S32(i)); } else { @@ -1023,7 +1023,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect, if (mStatusEffectIcons[i] == effectId) { if (miniStatusWindow) - miniStatusWindow->setIcon(static_cast(i), sprite); + miniStatusWindow->setIcon(CAST_S32(i), sprite); found = true; break; } @@ -1031,7 +1031,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect, if (!found) { // add new - const int offset = static_cast(mStatusEffectIcons.size()); + const int offset = CAST_S32(mStatusEffectIcons.size()); if (miniStatusWindow) miniStatusWindow->setIcon(offset, sprite); mStatusEffectIcons.push_back(effectId); @@ -1228,9 +1228,9 @@ void LocalPlayer::moveToTarget(int dist) { if (mMap) { - debugPath = mMap->findPath(static_cast( + debugPath = mMap->findPath(CAST_S32( playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, mTarget->getTileX(), mTarget->getTileY(), getBlockWalkMask(), @@ -1238,9 +1238,9 @@ void LocalPlayer::moveToTarget(int dist) } const size_t sz = debugPath.size(); - if (sz < static_cast(dist)) + if (sz < CAST_SIZE(dist)) return; - limit = static_cast(sz) - dist; + limit = CAST_S32(sz) - dist; gotPos = true; } else if (mNavigateX || mNavigateY) @@ -1295,13 +1295,13 @@ void LocalPlayer::moveToHome() if (mX == pos.x && mY == pos.y) { playerHandler->setDestination( - static_cast(pos.x), - static_cast(pos.y), - static_cast(mDirection)); + CAST_S32(pos.x), + CAST_S32(pos.y), + CAST_S32(mDirection)); } else { - navigateTo(static_cast(pos.x), static_cast(pos.y)); + navigateTo(CAST_S32(pos.x), CAST_S32(pos.y)); } } } @@ -1416,11 +1416,11 @@ bool LocalPlayer::isReachable(Being *const being, const Vector &playerPos = getPosition(); const Path debugPath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, being->getTileX(), being->getTileY(), getBlockWalkMask(), maxCost); - being->setDistance(static_cast(debugPath.size())); + being->setDistance(CAST_S32(debugPath.size())); if (!debugPath.empty()) { being->setReachable(Reachable::REACH_YES); @@ -1704,26 +1704,26 @@ void LocalPlayer::setHome() if (iter != mHomes.end()) { - socialWindow->removePortal(static_cast(pos.x), - static_cast(pos.y)); + socialWindow->removePortal(CAST_S32(pos.x), + CAST_S32(pos.y)); } - if (iter != mHomes.end() && mX == static_cast(pos.x) - && mY == static_cast(pos.y)) + if (iter != mHomes.end() && mX == CAST_S32(pos.x) + && mY == CAST_S32(pos.y)) { mMap->updatePortalTile("", MapItemType::EMPTY, - static_cast(pos.x), static_cast(pos.y)); + CAST_S32(pos.x), CAST_S32(pos.y)); mHomes.erase(key); - socialWindow->removePortal(static_cast(pos.x), - static_cast(pos.y)); + socialWindow->removePortal(CAST_S32(pos.x), + CAST_S32(pos.y)); } else { if (iter != mHomes.end()) { - specialLayer->setTile(static_cast(pos.x), - static_cast(pos.y), MapItemType::EMPTY); + specialLayer->setTile(CAST_S32(pos.x), + CAST_S32(pos.y), MapItemType::EMPTY); } pos.x = static_cast(mX); @@ -1958,8 +1958,8 @@ bool LocalPlayer::navigateTo(const int x, const int y) const Vector &playerPos = getPosition(); mShowNavigePath = true; - mOldX = static_cast(playerPos.x); - mOldY = static_cast(playerPos.y); + mOldX = CAST_S32(playerPos.x); + mOldY = CAST_S32(playerPos.y); mOldTileX = mX; mOldTileY = mY; mNavigateX = x; @@ -1967,8 +1967,8 @@ bool LocalPlayer::navigateTo(const int x, const int y) mNavigateId = BeingId_zero; mNavigatePath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, x, y, getBlockWalkMask(), 0); if (mDrawPath) @@ -2042,9 +2042,9 @@ void LocalPlayer::updateCoords() if (!tmpLayer) return; - const int x = static_cast(playerPos.x - mapTileSize / 2) + const int x = CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize; - const int y = static_cast(playerPos.y - mapTileSize) + const int y = CAST_S32(playerPos.y - mapTileSize) / mapTileSize; if (mNavigateId != BeingId_zero) { @@ -2090,8 +2090,8 @@ void LocalPlayer::updateCoords() } } } - mOldX = static_cast(playerPos.x); - mOldY = static_cast(playerPos.y); + mOldX = CAST_S32(playerPos.x); + mOldY = CAST_S32(playerPos.y); mOldTileX = mX; mOldTileY = mY; } @@ -2132,16 +2132,16 @@ int LocalPlayer::getPathLength(const Being *const being) const if (mTargetOnlyReachable) { const Path debugPath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, being->getTileX(), being->getTileY(), getBlockWalkMask(), 0); - return static_cast(debugPath.size()); + return CAST_S32(debugPath.size()); } else { - const int dx = static_cast(abs(being->mX - mX)); - const int dy = static_cast(abs(being->mY - mY)); + const int dx = CAST_S32(abs(being->mX - mX)); + const int dy = CAST_S32(abs(being->mY - mY)); if (dx > dy) return dx; return dy; @@ -2513,8 +2513,8 @@ void LocalPlayer::fixAttackTarget() const Vector &playerPos = getPosition(); const Path debugPath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, + CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize, + CAST_S32(playerPos.y - mapTileSize) / mapTileSize, mTarget->getTileX(), mTarget->getTileY(), getBlockWalkMask(), 0); @@ -2548,7 +2548,7 @@ void LocalPlayer::updateNavigateList() if (pos.x && pos.y) { mMap->addPortalTile("home", MapItemType::HOME, - static_cast(pos.x), static_cast(pos.y)); + CAST_S32(pos.x), CAST_S32(pos.y)); } } } diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index d124ba1dd..d996b03e3 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -86,7 +86,7 @@ namespace return nullptr; cobj->setValue(NAME, value.first); cobj->setValue(RELATION, toString( - static_cast(value.second->mRelation))); + CAST_S32(value.second->mRelation))); return cobj; } @@ -105,7 +105,7 @@ namespace if (!(*container)[name]) { const int v = cobj->getValueInt(RELATION, - static_cast(Relation::NEUTRAL)); + CAST_S32(Relation::NEUTRAL)); (*container)[name] = new PlayerRelation( static_cast(v)); @@ -175,7 +175,7 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex( for (size_t i = 0; i < sz; i++) { if ((*strategies)[i]->mShortName == name) - return static_cast(i); + return CAST_S32(i); } return -1; @@ -191,7 +191,7 @@ void PlayerRelationsManager::load(const bool oldConfig) clear(); mPersistIgnores = cfg->getValue(PERSIST_IGNORE_LIST, 1); - mDefaultPermissions = static_cast(cfg->getValue(DEFAULT_PERMISSIONS, + mDefaultPermissions = CAST_S32(cfg->getValue(DEFAULT_PERMISSIONS, mDefaultPermissions)); const std::string ignore_strategy_name = cfg->getValue( @@ -271,7 +271,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( { const PlayerRelation *const r = (*it).second; unsigned int permissions = PlayerRelation::RELATION_PERMISSIONS[ - static_cast(r->mRelation)]; + CAST_S32(r->mRelation)]; switch (r->mRelation) { -- cgit v1.2.3-70-g09d2