From d42aa0fad2f04b4e021b20b313ba6c9fb0d4e9d5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 30 Apr 2014 19:53:23 +0300 Subject: Fix code style in being. --- src/being/being.cpp | 12 ++++++------ src/being/being.h | 6 +++--- src/being/compoundsprite.cpp | 4 +++- src/being/localplayer.cpp | 8 ++++---- src/being/playerrelations.cpp | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/being/being.cpp b/src/being/being.cpp index 683bfb6f5..182bf3947 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -179,8 +179,8 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mCriticalHit(0), mPvpRank(0), mNumber(100), - mLook(0), mUsageCounter(1), + mLook(0U), mHairColor(0), mErased(false), mEnemy(false), @@ -1331,7 +1331,7 @@ void Being::nextTile() mActionTime += static_cast(mSpeed / 10); if ((mType != PLAYER || mUseDiagonal) && mX != pos.x && mY != pos.y) - mSpeed = mWalkSpeed.x * 1.4; + mSpeed = static_cast(mWalkSpeed.x * 1.4F); else mSpeed = mWalkSpeed.x; @@ -1535,7 +1535,7 @@ void Being::petLogic() } } - const int walkMask = getWalkMask(); + const unsigned char walkMask = getWalkMask(); if (!mMap->getWalk(dstX, dstY, walkMask)) { if (dstX != dstX0) @@ -1592,7 +1592,7 @@ void Being::petLogic() break; } - int newDir = 0; + uint8_t newDir = 0; switch (directionType) { case 0: @@ -2783,7 +2783,7 @@ int Being::searchSlotValue(const std::vector &slotRemap, for (size_t slot = 0; slot < sz; slot ++) { if (slotRemap[slot] == val) - return slot; + return static_cast(slot); } return getNumberOfLayers() - 1; } @@ -3271,7 +3271,7 @@ void Being::playSfx(const SoundInfo &sound, Being *const being, } } -void Being::setLook(const int look) +void Being::setLook(const uint8_t look) { if (mType == PLAYER) setSubtype(mSubType, look); diff --git a/src/being/being.h b/src/being/being.h index 2521eb0c3..793454ca2 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -895,10 +895,10 @@ class Being : public ActorSprite, public ConfigListener void playSfx(const SoundInfo &sound, Being *const being, const bool main, const int x, const int y) const; - int getLook() const + uint8_t getLook() const { return mLook; } - void setLook(const int look); + void setLook(const uint8_t look); static uint8_t genderToInt(const Gender sex) A_WARN_UNUSED; @@ -1090,8 +1090,8 @@ class Being : public ActorSprite, public ConfigListener int mCriticalHit; unsigned int mPvpRank; unsigned int mNumber; - int mLook; int mUsageCounter; + uint8_t mLook; unsigned char mHairColor; bool mErased; bool mEnemy; diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index 6c159821d..26a2268f3 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -45,11 +45,13 @@ #include "debug.h" +#ifndef USE_SDL2 static const int BUFFER_WIDTH = 100; static const int BUFFER_HEIGHT = 100; - static const unsigned cache_max_size = 10; static const unsigned cache_clean_part = 3; +#endif + bool CompoundSprite::mEnableDelay = true; CompoundSprite::CompoundSprite() : diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index b7747464d..3813f5121 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -966,13 +966,13 @@ void LocalPlayer::handleStatusEffect(StatusEffect *const effect, { // replace sprite or append bool found = false; - const unsigned int sz = mStatusEffectIcons.size(); - for (unsigned int i = 0; i < sz; i++) + const size_t sz = mStatusEffectIcons.size(); + for (size_t i = 0; i < sz; i++) { if (mStatusEffectIcons[i] == effectId) { if (miniStatusWindow) - miniStatusWindow->setIcon(i, sprite); + miniStatusWindow->setIcon(static_cast(i), sprite); found = true; break; } @@ -1167,7 +1167,7 @@ void LocalPlayer::moveToTarget(int dist) mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0); } - const unsigned int sz = debugPath.size(); + const size_t sz = debugPath.size(); if (sz < static_cast(dist)) return; limit = static_cast(sz) - dist; diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index 06815baeb..f1804e2b0 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -173,7 +173,7 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex( for (size_t i = 0; i < sz; i++) { if ((*strategies)[i]->mShortName == name) - return i; + return static_cast(i); } return -1; -- cgit v1.2.3-70-g09d2