From b19a1c6d50c2c0f4233972f20c9354efca5ccb66 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 5 Mar 2016 18:59:53 +0300 Subject: Change calculated speed in being from float to int. --- src/being/being.cpp | 24 ++++++++++-------------- src/being/being.h | 4 ++-- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/being/being.cpp b/src/being/being.cpp index fadf254a9..2e1302fb7 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1704,15 +1704,15 @@ void Being::nextTile() restrict2 return; } - mActionTime += CAST_S32(mSpeed / 10); + mActionTime += mSpeed / 10; if ((mType != ActorType::Player || mUseDiagonal) && mX != pos.x && mY != pos.y) { - mSpeed = static_cast(mWalkSpeed) * 1.4F; + mSpeed = mWalkSpeed * 14 / 10; } else { - mSpeed = static_cast(mWalkSpeed); + mSpeed = mWalkSpeed; } if (mX != pos.x || mY != pos.y) @@ -1783,11 +1783,8 @@ void Being::logic() restrict2 case BeingAction::MOVE: { - if (static_cast(get_elapsed_time( - mActionTime)) >= mSpeed) - { + if (get_elapsed_time(mActionTime) >= mSpeed) nextTile(); - } break; } @@ -1855,9 +1852,10 @@ void Being::logic() restrict2 if (frameCount < 10) frameCount = 10; - if (!isAlive() && mSpeed && gameHandler->removeDeadBeings() - && CAST_S32 ((static_cast(get_elapsed_time(mActionTime)) - / mSpeed)) >= frameCount) + if (!isAlive() && + mSpeed && + gameHandler->removeDeadBeings() && + get_elapsed_time(mActionTime) / mSpeed >= frameCount) { if (mType != ActorType::Player && actorManager) actorManager->destroy(this); @@ -2172,10 +2170,8 @@ int Being::getOffset(const signed char pos, const int time = get_elapsed_time(mActionTime); offset = (pos == BeingDirection::LEFT && neg == BeingDirection::RIGHT) ? - CAST_S32((static_cast(time) - * static_cast(mMap->getTileWidth())) / mSpeed) : - CAST_S32((static_cast(time) - * static_cast(mMap->getTileHeight())) / mSpeed); + (time * mMap->getTileWidth() / mSpeed) : + (time * mMap->getTileHeight() / mSpeed); } // We calculate the offset _from_ the _target_ location diff --git a/src/being/being.h b/src/being/being.h index c9bb2eca7..ce1b27ebd 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -405,7 +405,7 @@ class Being notfinal : public ActorSprite, * Sets the walk speed in pixels per second. */ void setWalkSpeed(const int speed) restrict2 - { mWalkSpeed = speed; mSpeed = static_cast(speed); } + { mWalkSpeed = speed; mSpeed = speed; } /** * Gets the walk speed in pixels per second. @@ -1097,7 +1097,7 @@ class Being notfinal : public ActorSprite, * @see MILLISECONDS_IN_A_TICK */ int mWalkSpeed; - float mSpeed; + int mSpeed; std::string mIp; int *restrict mSpriteRemap A_NONNULLPOINTER; int *restrict mSpriteHide A_NONNULLPOINTER; -- cgit v1.2.3-60-g2f50