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/particle/imageparticle.cpp | 4 ++-- src/particle/particle.cpp | 12 ++++++------ src/particle/particle.h | 4 ++-- src/particle/particleemitter.cpp | 18 +++++++++--------- src/particle/particlevector.cpp | 6 +++--- src/particle/textparticle.cpp | 8 ++++---- src/particle/textparticle.h | 4 ++-- 7 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src/particle') diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp index 651c879d7..d6914eafc 100644 --- a/src/particle/imageparticle.cpp +++ b/src/particle/imageparticle.cpp @@ -75,9 +75,9 @@ void ImageParticle::draw(Graphics *restrict const graphics, if (mAlive != AliveStatus::ALIVE || !mImage) return; - const int screenX = static_cast(mPos.x) + const int screenX = CAST_S32(mPos.x) + offsetX - mImage->mBounds.w / 2; - const int screenY = static_cast(mPos.y) - static_cast(mPos.z) + const int screenY = CAST_S32(mPos.y) - CAST_S32(mPos.z) + offsetY - mImage->mBounds.h / 2; // Check if on screen diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index f22f11252..73cbb4b0d 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -223,7 +223,7 @@ bool Particle::update() restrict2 if (mAlive != AliveStatus::ALIVE && mAlive != AliveStatus::DEAD_LONG_AGO) { - if ((static_cast(mAlive) & mDeathEffectConditions) + if ((CAST_U32(mAlive) & mDeathEffectConditions) > 0x00 && !mDeathEffect.empty()) { Particle *restrict const deathEffect = particleEngine->addEffect( @@ -396,27 +396,27 @@ Particle *Particle::addEffect(const std::string &restrict particleEffectFile, char deathEffectConditions = 0x00; if (XML::getBoolProperty(emitterNode, "on-floor", true)) { - deathEffectConditions += static_cast( + deathEffectConditions += CAST_S8( AliveStatus::DEAD_FLOOR); } if (XML::getBoolProperty(emitterNode, "on-sky", true)) { - deathEffectConditions += static_cast( + deathEffectConditions += CAST_S8( AliveStatus::DEAD_SKY); } if (XML::getBoolProperty(emitterNode, "on-other", false)) { - deathEffectConditions += static_cast( + deathEffectConditions += CAST_S8( AliveStatus::DEAD_OTHER); } if (XML::getBoolProperty(emitterNode, "on-impact", true)) { - deathEffectConditions += static_cast( + deathEffectConditions += CAST_S8( AliveStatus::DEAD_IMPACT); } if (XML::getBoolProperty(emitterNode, "on-timeout", true)) { - deathEffectConditions += static_cast( + deathEffectConditions += CAST_S8( AliveStatus::DEAD_TIMEOUT); } newParticle->setDeathEffect( diff --git a/src/particle/particle.h b/src/particle/particle.h index 9c2cb1a09..72c40493d 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -94,13 +94,13 @@ class Particle notfinal : public Actor * Necessary for sorting with the other sprites. */ int getPixelY() const restrict2 override A_WARN_UNUSED - { return static_cast(mPos.y) - 16; } + { return CAST_S32(mPos.y) - 16; } /** * Necessary for sorting with the other sprites for sorting only. */ int getSortPixelY() const restrict2 override A_WARN_UNUSED - { return static_cast(mPos.y) - 16; } + { return CAST_S32(mPos.y) - 16; } /** * Creates a blank particle as a child of the current particle diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp index a512cff94..d82282060 100644 --- a/src/particle/particleemitter.cpp +++ b/src/particle/particleemitter.cpp @@ -323,27 +323,27 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtrConst emitterNode, mDeathEffectConditions = 0x00; if (XML::getBoolProperty(propertyNode, "on-floor", true)) { - mDeathEffectConditions += static_cast( + mDeathEffectConditions += CAST_S8( AliveStatus::DEAD_FLOOR); } if (XML::getBoolProperty(propertyNode, "on-sky", true)) { - mDeathEffectConditions += static_cast( + mDeathEffectConditions += CAST_S8( AliveStatus::DEAD_SKY); } if (XML::getBoolProperty(propertyNode, "on-other", false)) { - mDeathEffectConditions += static_cast( + mDeathEffectConditions += CAST_S8( AliveStatus::DEAD_OTHER); } if (XML::getBoolProperty(propertyNode, "on-impact", true)) { - mDeathEffectConditions += static_cast( + mDeathEffectConditions += CAST_S8( AliveStatus::DEAD_IMPACT); } if (XML::getBoolProperty(propertyNode, "on-timeout", true)) { - mDeathEffectConditions += static_cast( + mDeathEffectConditions += CAST_S8( AliveStatus::DEAD_TIMEOUT); } } @@ -593,8 +593,8 @@ void ParticleEmitter::adjustSize(const int w, const int h) return; // new dimensions are illegal // calculate the old rectangle - const int oldArea = static_cast( - mParticlePosX.maxVal - mParticlePosX.minVal) * static_cast( + const int oldArea = CAST_S32( + mParticlePosX.maxVal - mParticlePosX.minVal) * CAST_S32( mParticlePosX.maxVal - mParticlePosY.minVal); if (oldArea == 0) { @@ -610,8 +610,8 @@ void ParticleEmitter::adjustSize(const int w, const int h) // adjust the output so that the particle density stays the same const float outputFactor = static_cast(newArea) / static_cast(oldArea); - mOutput.minVal = static_cast(static_cast( + mOutput.minVal = CAST_S32(static_cast( mOutput.minVal) * outputFactor); - mOutput.maxVal = static_cast(static_cast( + mOutput.maxVal = CAST_S32(static_cast( mOutput.maxVal) * outputFactor); } diff --git a/src/particle/particlevector.cpp b/src/particle/particlevector.cpp index a09f6d7ae..d0594a2dd 100644 --- a/src/particle/particlevector.cpp +++ b/src/particle/particlevector.cpp @@ -41,7 +41,7 @@ void ParticleVector::setLocally(const int index, Particle *const particle) delLocally(index); - if (mIndexedElements.size() <= static_cast(index)) + if (mIndexedElements.size() <= CAST_SIZE(index)) mIndexedElements.resize(index + 1, nullptr); if (particle) @@ -54,7 +54,7 @@ void ParticleVector::delLocally(const int index) if (index < 0) return; - if (mIndexedElements.size() <= static_cast(index)) + if (mIndexedElements.size() <= CAST_SIZE(index)) return; Particle *const p = mIndexedElements[index]; @@ -68,7 +68,7 @@ void ParticleVector::delLocally(const int index) void ParticleVector::clearLocally() { for (unsigned int i = 0; - i < static_cast(mIndexedElements.size()); + i < CAST_U32(mIndexedElements.size()); i++) { delLocally(i); diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index 8a886f27d..399e00a01 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -55,8 +55,8 @@ void TextParticle::draw(Graphics *restrict const graphics, return; } - const int screenX = static_cast(mPos.x) + offsetX; - const int screenY = static_cast(mPos.y) - static_cast(mPos.z) + const int screenX = CAST_S32(mPos.x) + offsetX; + const int screenY = CAST_S32(mPos.y) - CAST_S32(mPos.z) + offsetY; float alpha = mAlpha * 255.0F; @@ -74,13 +74,13 @@ void TextParticle::draw(Graphics *restrict const graphics, } Color color = *mColor; - color.a = static_cast(alpha); + color.a = CAST_U32(alpha); graphics->setColor(color); if (mOutline) { const Color &restrict color2 = theme->getColor(ThemeColorId::OUTLINE, - static_cast(alpha)); + CAST_S32(alpha)); mTextFont->drawString(graphics, color, color2, mText, diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index 70dbad956..7064a5358 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -48,11 +48,11 @@ class TextParticle final : public Particle // hack to improve text visibility int getPixelY() const restrict2 override final A_WARN_UNUSED - { return static_cast(mPos.y + mPos.z); } + { return CAST_S32(mPos.y + mPos.z); } // hack to improve text visibility (for sorting only) int getSortPixelY() const restrict2 override final A_WARN_UNUSED - { return static_cast(mPos.y + mPos.z); } + { return CAST_S32(mPos.y + mPos.z); } private: std::string mText; /**< Text of the particle. */ -- cgit v1.2.3-70-g09d2