summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/actor.h6
-rw-r--r--src/being/actorsprite.cpp26
-rw-r--r--src/being/actorsprite.h4
-rw-r--r--src/being/being.cpp58
-rw-r--r--src/being/being.h8
-rw-r--r--src/being/compoundsprite.cpp6
-rw-r--r--src/being/crazymoves.cpp8
-rw-r--r--src/being/localplayer.cpp102
-rw-r--r--src/being/playerrelations.cpp10
9 files changed, 114 insertions, 114 deletions
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<int>(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<int>(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<int>(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<int>(TargetCursorSize::SMALL); \
- size < static_cast<int>(TargetCursorSize::NUM_TC); \
+ for (int size = CAST_S32(TargetCursorSize::SMALL); \
+ size < CAST_S32(TargetCursorSize::NUM_TC); \
size ++) \
{ \
- for (int type = static_cast<int>(TargetCursorType::NORMAL); \
- type < static_cast<int>(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<size_t>(TargetCursorType::NUM_TCT)]
- [static_cast<size_t>(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<size_t>(getTargetCursorSize());
- mUsedTargetCursor = targetCursor[static_cast<int>(type)][sz];
+ const size_t sz = CAST_SIZE(getTargetCursorSize());
+ mUsedTargetCursor = targetCursor[CAST_S32(type)][sz];
if (mUsedTargetCursor)
{
- static const int targetWidths[static_cast<size_t>(
+ static const int targetWidths[CAST_SIZE(
TargetCursorSize::NUM_TC)]
= {0, 0, 0};
- static const int targetHeights[static_cast<size_t>(
+ static const int targetHeights[CAST_SIZE(
TargetCursorSize::NUM_TC)]
= {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
- mCursorPaddingX = static_cast<int>(targetWidths[sz]);
- mCursorPaddingY = static_cast<int>(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<int>(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<size_t>(TargetCursorType::NUM_TCT)]
- [static_cast<size_t>(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<int>(pos.x),
- static_cast<int>(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<int>(SPEECH_TIME - 300 + (3 * sz));
+ time = CAST_S32(SPEECH_TIME - 300 + (3 * sz));
}
- if (time < static_cast<int>(SPEECH_MIN_TIME))
- time = static_cast<int>(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<int>(SPEECH_MAX_TIME)
- ? time : static_cast<int>(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<unsigned>(action)));
+ + toString(CAST_U32(action)));
break;
}
@@ -1696,7 +1696,7 @@ void Being::nextTile() restrict2
return;
}
- mActionTime += static_cast<int>(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<int>(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<int> ((static_cast<float>(get_elapsed_time(mActionTime))
+ && CAST_S32 ((static_cast<float>(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<int>(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<int>((static_cast<float>(time)
+ CAST_S32((static_cast<float>(time)
* static_cast<float>(mMap->getTileWidth())) / mSpeed) :
- static_cast<int>((static_cast<float>(time)
+ CAST_S32((static_cast<float>(time)
* static_cast<float>(mMap->getTileHeight())) / mSpeed);
}
@@ -2440,7 +2440,7 @@ void Being::updateSprite(const unsigned int slot,
if (!charServerHandler || slot >= charServerHandler->maxSprite())
return;
- if (slot >= static_cast<unsigned int>(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<unsigned int>(size()))
+ if (slot >= CAST_U32(size()))
ensureSize(slot + 1);
- if (slot >= static_cast<unsigned int>(mSpriteIDs.size()))
+ if (slot >= CAST_U32(mSpriteIDs.size()))
mSpriteIDs.resize(slot + 1, 0);
- if (slot >= static_cast<unsigned int>(mSpriteColors.size()))
+ if (slot >= CAST_U32(mSpriteColors.size()))
mSpriteColors.resize(slot + 1, "");
- if (slot >= static_cast<unsigned int>(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<uint8_t>(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<unsigned int>(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<unsigned int>(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<int>(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<unsigned>(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<int>(spriteIdSize) > val)
+ if (CAST_S32(spriteIdSize) > val)
id = mSpriteIDs[val];
int idx = -1;
@@ -3404,7 +3404,7 @@ int Being::searchSlotValue(const std::vector<int> &restrict slotRemap,
for (size_t slot = 0; slot < sz; slot ++)
{
if (slotRemap[slot] == val)
- return static_cast<int>(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<unsigned int>(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<size_t>(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<size_t>(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<int16_t>(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<int>(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<int>(mPos.y) - mYDiff - mSortOffsetY; }
-// { return static_cast<int>(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<int>(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<unsigned int>(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<unsigned int>(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<unsigned char>(
+ emoteId = CAST_U8(
1 + (rand() % EmoteDB::size()));
}
else
{
if (emo >= '0' && emo <= '9')
- emoteId = static_cast<unsigned char>(emo - '0' + 1);
+ emoteId = CAST_U8(emo - '0' + 1);
else if (emo >= 'a' && emo <= 'z')
- emoteId = static_cast<unsigned char>(emo - 'a' + 11);
+ emoteId = CAST_U8(emo - 'a' + 11);
else if (emo >= 'A' && emo <= 'Z')
- emoteId = static_cast<unsigned char>(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<int>(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<int>(
+ const int rangeX = CAST_S32(
abs(mTarget->getTileX() - getTileX()));
- const int rangeY = static_cast<int>(
+ 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<int>(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<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<int>(getPosition().x),
- static_cast<int>(getPosition().y));
+ setDestination(CAST_S32(getPosition().x),
+ CAST_S32(getPosition().y));
if (sendToServer)
{
playerHandler->setDestination(
- static_cast<int>(getPosition().x),
- static_cast<int>(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<int>(abs(target->getTileX() - mX));
- dy = static_cast<int>(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<int>(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<int>(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<int>(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<int>(
+ debugPath = mMap->findPath(CAST_S32(
playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<size_t>(dist))
+ if (sz < CAST_SIZE(dist))
return;
- limit = static_cast<int>(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<int>(pos.x),
- static_cast<int>(pos.y),
- static_cast<int>(mDirection));
+ CAST_S32(pos.x),
+ CAST_S32(pos.y),
+ CAST_S32(mDirection));
}
else
{
- navigateTo(static_cast<int>(pos.x), static_cast<int>(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<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<int>(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<int>(pos.x),
- static_cast<int>(pos.y));
+ socialWindow->removePortal(CAST_S32(pos.x),
+ CAST_S32(pos.y));
}
- if (iter != mHomes.end() && mX == static_cast<int>(pos.x)
- && mY == static_cast<int>(pos.y))
+ if (iter != mHomes.end() && mX == CAST_S32(pos.x)
+ && mY == CAST_S32(pos.y))
{
mMap->updatePortalTile("", MapItemType::EMPTY,
- static_cast<int>(pos.x), static_cast<int>(pos.y));
+ CAST_S32(pos.x), CAST_S32(pos.y));
mHomes.erase(key);
- socialWindow->removePortal(static_cast<int>(pos.x),
- static_cast<int>(pos.y));
+ socialWindow->removePortal(CAST_S32(pos.x),
+ CAST_S32(pos.y));
}
else
{
if (iter != mHomes.end())
{
- specialLayer->setTile(static_cast<int>(pos.x),
- static_cast<int>(pos.y), MapItemType::EMPTY);
+ specialLayer->setTile(CAST_S32(pos.x),
+ CAST_S32(pos.y), MapItemType::EMPTY);
}
pos.x = static_cast<float>(mX);
@@ -1958,8 +1958,8 @@ bool LocalPlayer::navigateTo(const int x, const int y)
const Vector &playerPos = getPosition();
mShowNavigePath = true;
- mOldX = static_cast<int>(playerPos.x);
- mOldY = static_cast<int>(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<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<int>(playerPos.x - mapTileSize / 2)
+ const int x = CAST_S32(playerPos.x - mapTileSize / 2)
/ mapTileSize;
- const int y = static_cast<int>(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<int>(playerPos.x);
- mOldY = static_cast<int>(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<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<int>(debugPath.size());
+ return CAST_S32(debugPath.size());
}
else
{
- const int dx = static_cast<int>(abs(being->mX - mX));
- const int dy = static_cast<int>(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<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
- static_cast<int>(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<int>(pos.x), static_cast<int>(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<int>(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<int>(Relation::NEUTRAL));
+ CAST_S32(Relation::NEUTRAL));
(*container)[name] = new PlayerRelation(
static_cast<RelationT>(v));
@@ -175,7 +175,7 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
for (size_t i = 0; i < sz; i++)
{
if ((*strategies)[i]->mShortName == name)
- return static_cast<int>(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<int>(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<int>(r->mRelation)];
+ CAST_S32(r->mRelation)];
switch (r->mRelation)
{