summaryrefslogtreecommitdiffstats
path: root/src/scripting/script.h
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/scripting/script.h
parent16074a7c2c8197a061281a6880ddbc3967d8ea0c (diff)
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/scripting/script.h')
-rw-r--r--src/scripting/script.h22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/scripting/script.h b/src/scripting/script.h
index 238bc34..8dee23a 100644
--- a/src/scripting/script.h
+++ b/src/scripting/script.h
@@ -23,19 +23,21 @@
#include "common/inventorydata.h"
#include "common/manaserv_protocol.h"
-#include "game-server/eventlistener.h"
#include <list>
#include <string>
#include <vector>
+#include <sigc++/trackable.h>
+
+class Being;
class MapComposite;
class Entity;
/**
* Abstract interface for calling functions written in an external language.
*/
-class Script
+class Script : public sigc::trackable
{
public:
/**
@@ -216,9 +218,6 @@ class Script
MapComposite *getMap() const
{ return mMap; }
- EventListener *getScriptListener()
- { return &mEventListener; }
-
virtual void processDeathEvent(Being *entity) = 0;
virtual void processRemoveEvent(Entity *entity) = 0;
@@ -235,7 +234,6 @@ class Script
private:
MapComposite *mMap;
- EventListener mEventListener; /**< Tracking of being deaths. */
std::vector<Thread*> mThreads;
static Ref mCreateNpcDelayedCallback;
@@ -245,16 +243,4 @@ class Script
friend class Thread;
};
-struct ScriptEventDispatch: EventDispatch
-{
- ScriptEventDispatch()
- {
- typedef EventListenerFactory< Script, &Script::mEventListener > Factory;
- died = &Factory::create< Being, &Script::processDeathEvent >::function;
- removed = &Factory::create< Entity, &Script::processRemoveEvent >::function;
- }
-};
-
-static ScriptEventDispatch scriptEventDispatch;
-
#endif // SCRIPTING_SCRIPT_H