diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-29 14:17:22 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-29 14:17:22 +0000 |
commit | 26b3e1094d85ef89c90376688000836c8ee43979 (patch) | |
tree | f934d936d7c8319e742e946a6bb5f37ab7289b30 /src/game-server/thing.hpp | |
parent | b82bf7df7053a78d51706a5a017d61f564e4677e (diff) | |
download | manaserv-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/thing.hpp')
-rw-r--r-- | src/game-server/thing.hpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/game-server/thing.hpp b/src/game-server/thing.hpp index 1fdf584e..2f160d37 100644 --- a/src/game-server/thing.hpp +++ b/src/game-server/thing.hpp @@ -23,6 +23,9 @@ #ifndef _TMWSERV_THING_H_ #define _TMWSERV_THING_H_ +#include <set> + +class EventListener; class MapComposite; /** @@ -43,7 +46,7 @@ enum /** * Base class for in-game objects. Knows only its type and the map is resides - * on. + * on. Provides listeners. */ class Thing { @@ -57,9 +60,9 @@ class Thing {} /** - * Empty virtual destructor. + * Destructor. */ - virtual ~Thing() {} + virtual ~Thing(); /** * Gets type of this thing. @@ -106,6 +109,30 @@ class Thing void setMap(MapComposite *map) { mMap = map; } + /** + * Adds a new listener. + */ + void addListener(EventListener const *); + + /** + * Removes an existing listener. + */ + void removeListener(EventListener const *); + + /** + * Calls all the "inserted" listeners. + */ + virtual void inserted(); + + /** + * Calls all the "removed" listeners. + */ + virtual void removed(); + + protected: + typedef std::set< EventListener const * > Listeners; + Listeners mListeners; /**< List of event listeners. */ + private: MapComposite *mMap; /**< Map the thing is on */ char mType; /**< Type of this thing. */ |