diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-06 18:37:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-06 18:37:06 +0300 |
commit | c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31 (patch) | |
tree | ac124c630bc17ef10a8885a49fbb387f7091d15d /src/being | |
parent | 88697bc3503090194877b241b987ddc751034166 (diff) | |
download | manaverse-c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31.tar.gz manaverse-c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31.tar.bz2 manaverse-c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31.tar.xz manaverse-c25141f02a5b3dcddcc93ca5d2bd2fcdad5efb31.zip |
Add strong typed bool type Enable.
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/actorsprite.cpp | 30 | ||||
-rw-r--r-- | src/being/actorsprite.h | 6 |
2 files changed, 22 insertions, 14 deletions
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<int>::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); } diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 7b5da3aa7..f5d4f0214 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -22,6 +22,8 @@ #ifndef BEING_ACTORSPRITE_H #define BEING_ACTORSPRITE_H +#include "enums/simpletypes.h" + #include "resources/map/blocktype.h" #include "resources/map/mapconsts.h" @@ -118,7 +120,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor mStunMode = stunMode; } - void setStatusEffect(const int index, const bool active); + void setStatusEffect(const int index, const Enable active); /** * A status effect block is a 16 bit mask of status effects. We assign @@ -186,7 +188,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor * Notify self that a status effect has flipped. * The new flag is passed. */ - virtual void updateStatusEffect(const int index, const bool newStatus); + virtual void updateStatusEffect(const int index, const Enable newStatus); /** * Handle an update to a status or stun effect |