diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/being.cpp | 23 | ||||
-rw-r--r-- | src/game-server/being.hpp | 4 | ||||
-rw-r--r-- | src/game-server/character.cpp | 2 |
3 files changed, 18 insertions, 11 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index a85cc974..e9b1e3c8 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -317,10 +317,17 @@ void Being::applyStatusEffect(int id, int timer) if (mAction == DEAD) return; - Status newStatus; - newStatus.status = StatusManager::getStatus(id); - newStatus.time = timer; - mStatus[id] = newStatus; + if (StatusEffect *statusEffect = StatusManager::getStatus(id)) + { + Status newStatus; + newStatus.status = statusEffect; + newStatus.time = timer; + mStatus[id] = newStatus; + } + else + { + LOG_ERROR("No status effect with ID " << id); + } } void Being::removeStatusEffect(int id) @@ -328,9 +335,9 @@ void Being::removeStatusEffect(int id) setStatusEffectTime(id, 0); } -bool Being::hasStatusEffect(int id) +bool Being::hasStatusEffect(int id) const { - StatusEffects::iterator it = mStatus.begin(); + StatusEffects::const_iterator it = mStatus.begin(); while (it != mStatus.end()) { if (it->second.status->getId() == id) @@ -340,9 +347,9 @@ bool Being::hasStatusEffect(int id) return false; } -unsigned Being::getStatusEffectTime(int id) +unsigned Being::getStatusEffectTime(int id) const { - StatusEffects::iterator it = mStatus.find(id); + StatusEffects::const_iterator it = mStatus.find(id); if (it != mStatus.end()) return it->second.time; else return 0; } diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp index d0ca4be3..35c3bb62 100644 --- a/src/game-server/being.hpp +++ b/src/game-server/being.hpp @@ -308,12 +308,12 @@ class Being : public Actor /** * Returns true if the being has a status effect */ - bool hasStatusEffect(int id); + bool hasStatusEffect(int id) const; /** * Returns the time of the status effect if in effect, or 0 if not */ - unsigned getStatusEffectTime(int id); + unsigned getStatusEffectTime(int id) const; /** * Changes the time of the status effect (if in effect) diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index f351edb3..99a6bcfd 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -126,7 +126,7 @@ void Character::update() mStatusEffects.clear(); StatusEffects::iterator it = mStatus.begin(); - while(it != mStatus.end()) + while (it != mStatus.end()) { mStatusEffects[it->first] = it->second.time; it++; |