diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-27 23:44:35 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-28 20:33:23 +0100 |
commit | e896d0b0125b48e12d43d99ace4498e56d968d50 (patch) | |
tree | 5d389506449219e8c91a3fe478d268b764735720 | |
parent | 9b2445c45608e55e91ee32453dff2163d958f7e2 (diff) | |
download | manaserv-e896d0b0125b48e12d43d99ace4498e56d968d50.tar.gz manaserv-e896d0b0125b48e12d43d99ace4498e56d968d50.tar.bz2 manaserv-e896d0b0125b48e12d43d99ace4498e56d968d50.tar.xz manaserv-e896d0b0125b48e12d43d99ace4498e56d968d50.zip |
Fixed bug with erasing the last status effect
It's not nice to use ++ on an iterator that may be std::map::end(),
in my case this caused it to hang indefinitely.
Reviewed-by: Yohann Ferreira
-rw-r--r-- | src/game-server/being.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 6fce57e8..408b8fc0 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -669,8 +669,10 @@ void Being::update() for (AttributeMap::iterator it = mAttributes.begin(); it != mAttributes.end(); ++it) + { if (it->second.tick()) updateDerivedAttributes(it->first); + } // Update and run status effects StatusEffects::iterator it = mStatus.begin(); @@ -682,10 +684,14 @@ void Being::update() if (it->second.time <= 0 || mAction == DEAD) { - mStatus.erase(it); - it = mStatus.begin(); + StatusEffects::iterator removeIt = it; + it++; // bring this iterator to the safety of the next element + mStatus.erase(removeIt); + } + else + { + it++; } - it++; } // Check if being died |