summaryrefslogtreecommitdiff
path: root/src/game-server/being.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-05-27 23:26:19 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-01-09 17:12:15 +0100
commit0b339e547b77f80d6e81313bfb38249ce8995553 (patch)
treef22fee0142f72042430ace070a6e6ef4493e7c39 /src/game-server/being.cpp
parent16074a7c2c8197a061281a6880ddbc3967d8ea0c (diff)
downloadmanaserv-0b339e547b77f80d6e81313bfb38249ce8995553.tar.gz
manaserv-0b339e547b77f80d6e81313bfb38249ce8995553.tar.bz2
manaserv-0b339e547b77f80d6e81313bfb38249ce8995553.tar.xz
manaserv-0b339e547b77f80d6e81313bfb38249ce8995553.zip
Replaced EventListener with signals based on libsigc++
This replaces the rather hard to understand event dispatcher with a probably even harder to understand templated library, but fortunately we can rely on the available documentation. Hopefully it will also help with the readability of our code and with adding additional signals to other classes. Added libsigc++ to README and Travis CI configuration. Reviewed-by: Erik Schilling
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r--src/game-server/being.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index ea7540ca..9ce19d76 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -27,7 +27,6 @@
#include "game-server/attributemanager.h"
#include "game-server/character.h"
#include "game-server/collisiondetection.h"
-#include "game-server/eventlistener.h"
#include "game-server/mapcomposite.h"
#include "game-server/effect.h"
#include "game-server/skillmanager.h"
@@ -58,6 +57,9 @@ Being::Being(EntityType type):
Attribute(*it1->second)));
}
+
+ signal_inserted.connect(sigc::mem_fun(this, &Being::inserted));
+
// TODO: Way to define default base values?
// Should this be handled by the virtual modifiedAttribute?
// URGENT either way
@@ -177,14 +179,7 @@ void Being::died()
// reset target
mTarget = NULL;
- for (Listeners::iterator i = mListeners.begin(),
- i_end = mListeners.end(); i != i_end;)
- {
- const EventListener &l = **i;
- ++i; // In case the listener removes itself from the list on the fly.
- if (l.dispatch->died)
- l.dispatch->died(&l, this);
- }
+ signal_died.emit(this);
}
void Being::processAttacks()
@@ -512,6 +507,11 @@ bool Being::removeModifier(unsigned attr, double value, unsigned layer,
return ret;
}
+void Being::setGender(BeingGender gender)
+{
+ mGender = gender;
+}
+
void Being::setAttribute(unsigned id, double value)
{
AttributeMap::iterator ret = mAttributes.find(id);
@@ -743,20 +743,13 @@ void Being::update()
processAttacks();
}
-void Being::inserted()
+void Being::inserted(Entity *)
{
- Actor::inserted();
-
// Reset the old position, since after insertion it is important that it is
// in sync with the zone that we're currently present in.
mOld = getPosition();
}
-void Being::setGender(BeingGender gender)
-{
- mGender = gender;
-}
-
void Being::processAttack(Attack &attack)
{
performAttack(mTarget, attack.getAttackInfo()->getDamage());