From c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 6 May 2015 18:37:06 +0300 Subject: Add strong typed bool type Enable. --- src/being/actorsprite.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/being/actorsprite.cpp') diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 88418be1a..b305b35a7 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -120,9 +120,9 @@ void ActorSprite::logic() FOR_EACH (std::set::const_iterator, it, mStatusEffects) { const StatusEffect *const effect - = StatusEffect::getStatusEffect(*it, true); + = StatusEffect::getStatusEffect(*it, Enable_true); if (effect && effect->particleEffectIsPersistent()) - updateStatusEffect(*it, true); + updateStatusEffect(*it, Enable_true); } } @@ -174,14 +174,15 @@ struct EffectDescription final std::string mSFXEffect; }; -void ActorSprite::setStatusEffect(const int index, const bool active) +void ActorSprite::setStatusEffect(const int index, const Enable active) { - const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end(); + const Enable wasActive = fromBool( + mStatusEffects.find(index) != mStatusEffects.end(), Enable); if (active != wasActive) { updateStatusEffect(index, active); - if (active) + if (active == Enable_true) mStatusEffects.insert(index); else mStatusEffects.erase(index); @@ -197,28 +198,33 @@ void ActorSprite::setStatusEffectBlock(const int offset, offset + i); if (index != -1) - setStatusEffect(index, (newEffects & (1 << i)) > 0); + { + setStatusEffect(index, + fromBool((newEffects & (1 << i)) > 0, Enable)); + } } } void ActorSprite::updateStunMode(const int oldMode, const int newMode) { - handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1); - handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1); + handleStatusEffect(StatusEffect::getStatusEffect( + oldMode, Enable_false), -1); + handleStatusEffect(StatusEffect::getStatusEffect( + newMode, Enable_true), -1); } -void ActorSprite::updateStatusEffect(const int index, const bool newStatus) +void ActorSprite::updateStatusEffect(const int index, const Enable newStatus) { StatusEffect *const effect = StatusEffect::getStatusEffect( index, newStatus); if (!effect) return; if (effect->isPoison() && getType() == ActorType::Player) - setPoison(newStatus); + setPoison(newStatus == Enable_true); else if (effect->isCart() && localPlayer == this) - setHaveCart(newStatus); + setHaveCart(newStatus == Enable_true); else if (effect->isRiding()) - setRiding(newStatus); + setRiding(newStatus == Enable_true); handleStatusEffect(effect, index); } -- cgit v1.2.3-70-g09d2