summaryrefslogtreecommitdiff
path: root/src/game-server/being.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-29 14:17:22 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-29 14:17:22 +0000
commit26b3e1094d85ef89c90376688000836c8ee43979 (patch)
treef934d936d7c8319e742e946a6bb5f37ab7289b30 /src/game-server/being.cpp
parentb82bf7df7053a78d51706a5a017d61f564e4677e (diff)
downloadmanaserv-26b3e1094d85ef89c90376688000836c8ee43979.tar.gz
manaserv-26b3e1094d85ef89c90376688000836c8ee43979.tar.bz2
manaserv-26b3e1094d85ef89c90376688000836c8ee43979.tar.xz
manaserv-26b3e1094d85ef89c90376688000836c8ee43979.zip
Replaced event system. Fixed race condition between quest variable recovery and character removal.
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r--src/game-server/being.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index bc690231..7c09d97e 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -26,7 +26,7 @@
#include "defines.h"
#include "game-server/collisiondetection.hpp"
-#include "game-server/deathlistener.hpp"
+#include "game-server/eventlistener.hpp"
#include "game-server/mapcomposite.hpp"
#include "utils/logger.h"
@@ -43,18 +43,6 @@ Being::Being(int type, int id):
}
}
-Being::~Being()
-{
- // Notify death listeners
- DeathListeners::iterator i_end = mDeathListeners.end();
- DeathListeners::iterator i;
- for (i = mDeathListeners.begin(); i != i_end; ++i)
- {
- (*i)->deleted(this);
- }
-
-}
-
int Being::damage(Object *, Damage const &damage)
{
if (mAction == DEAD) return 0;
@@ -122,13 +110,13 @@ int Being::damage(Object *, Damage const &damage)
{
HP.mod -= HPloss;
modifiedAttribute(BASE_ATTR_HP);
- if (HP.base + HP.mod == 0) die();
+ if (HP.base + HP.mod == 0) died();
}
return HPloss;
}
-void Being::die()
+void Being::died()
{
if (mAction == DEAD) return;
@@ -137,12 +125,12 @@ void Being::die()
// dead beings stay where they are
clearDestination();
- // Notify death listeners
- DeathListeners::iterator i_end = mDeathListeners.end();
- DeathListeners::iterator i;
- for (i = mDeathListeners.begin(); i != i_end; ++i)
+ for (Listeners::iterator i = mListeners.begin(),
+ i_end = mListeners.end(); i != i_end;)
{
- (*i)->died(this);
+ EventListener const &l = **i;
+ ++i; // In case the listener removes itself from the list on the fly.
+ if (l.dispatch->died) l.dispatch->died(&l, this);
}
}