Index: trunk/src/lib/event/event_handler.cc
===================================================================
--- trunk/src/lib/event/event_handler.cc	(revision 7677)
+++ trunk/src/lib/event/event_handler.cc	(revision 7756)
@@ -26,6 +26,5 @@
 #include "class_list.h"
 
-using namespace std;
-
+#include <algorithm>
 
 /**
@@ -43,10 +42,8 @@
 
   /* now initialize them all to zero */
-  this->flush(ES_ALL);
   this->withUNICODE(false);
   this->grabEvents(false);
 
   this->state = ES_GAME;
-  this->keyMapper = NULL;
   this->eventsGrabbed = false;
 }
@@ -69,5 +66,5 @@
     for(int j = 0; j < EV_NUMBER; ++j)
     {
-      if( this->listeners[i][j] != NULL)
+      if(!this->listeners[i][j].empty())
       {
         PRINTF(2)("forgot to unsubscribe an EventListener!\n");// %s!\n", this->listeners[i][j]->getName());
@@ -75,6 +72,4 @@
     }
   }
-  delete this->keyMapper;
-
   SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
 
@@ -90,9 +85,5 @@
 void EventHandler::init()
 {
-  if (this->keyMapper == NULL)
-  {
-    this->keyMapper = new KeyMapper();
-    this->keyMapper->loadKeyBindings();
-  }
+  this->keyMapper.loadKeyBindings();
 }
 
@@ -138,5 +129,5 @@
 
 /**
- *  subscribe to an event
+ * @brief subscribe to an event
  * @param el: the event listener that wants to subscribe itself, the listener that will be called when the evetn occures
  * @param state: for which the listener wants to receive events
@@ -153,21 +144,25 @@
   {
     for(unsigned int i = 0; i < ES_NUMBER; i++)
-      if( likely(this->listeners[i][eventType] == NULL))
-        this->listeners[i][eventType] = el;
-      else
-        PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
-  }
-  else
-    if( likely(this->listeners[state][eventType] == NULL))
-    {
-      this->listeners[state][eventType] = el;
-    }
-    else
-      PRINTF(2)("% of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
-}
-
-
-/**
- *  unsubscribe from the EventHandler
+    {
+      if( !likely(this->listeners[i][eventType].empty()))
+      {
+        PRINTF(2)("'%s' of class '%s' tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
+      }
+      this->listeners[i][eventType].push_back(el);
+    }
+  }
+  else
+  {
+    if( likely(!this->listeners[state][eventType].empty()))
+    {
+      PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
+    }
+    this->listeners[state][eventType].push_back(el);
+  }
+}
+
+
+/**
+ * @brief unsubscribe from the EventHandler
  * @param state: the stat in which it has been subscribed
  * @param eventType: the event, that shall be unsubscribed
@@ -181,7 +176,7 @@
   if (state == ES_ALL)
     for (unsigned int i = 0; i < ES_NUMBER; i++)
-      this->listeners[i][eventType] = NULL;
-  else
-    this->listeners[state][eventType] = NULL;
+      this->listeners[i][eventType].clear();
+  else
+    this->listeners[state][eventType].clear();
 }
 
@@ -203,6 +198,7 @@
       for(unsigned int j = 0; j < EV_NUMBER; j++)
       {
-        if( this->listeners[i][j] == el )
-          this->listeners[i][j] = NULL;
+        std::vector<EventListener*>::iterator deller = std::find (this->listeners[i][j].begin(), this->listeners[i][j].end(), el);
+        if( deller != this->listeners[i][j].end())
+          this->listeners[i][j].erase(deller);
       }
     }
@@ -212,9 +208,16 @@
     for(int j = 0; j < EV_NUMBER; j++)
     {
-      if( this->listeners[state][j] == el )
-        this->listeners[state][j] = NULL;
-    }
-  }
-}
+      std::vector<EventListener*>::iterator deller =  std::find (this->listeners[state][j].begin(), this->listeners[state][j].end(), el);
+      if( deller != this->listeners[state][j].end())
+        this->listeners[state][j].erase(deller);
+    }
+  }
+}
+
+bool EventHandler::isSubscribed(elState state, int eventType)
+{
+  return(listeners[state][eventType].empty()) ? false : true;
+};
+
 
 
@@ -231,5 +234,5 @@
       for(int j = 0; j < EV_NUMBER; ++j)
       {
-        this->listeners[i][j] = NULL;
+        this->listeners[i][j].clear();
       }
     }
@@ -239,5 +242,5 @@
     for(int j = 0; j < EV_NUMBER; ++j)
     {
-      this->listeners[state][j] = NULL;
+      this->listeners[state][j].clear();
     }
   }
@@ -344,16 +347,16 @@
     PRINT(4)("=  Got Event nr %i, for state %i", ev.type, this->state);
 
-    listener = this->listeners[this->state][ev.type];
-    if( listener != NULL)
+
+    for (unsigned int i = 0; i < this->listeners[this->state][ev.type].size(); i++)
     {
       PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
       PRINT(4)("=======================================================\n");
-      listener->process(ev);
-    }
-    else
-    {
-      PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
-      PRINT(4)("=======================================================\n");
-    }
+      listeners[this->state][ev.type][i]->process(ev);
+    }
+    /*    else
+        {
+          PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
+          PRINT(4)("=======================================================\n");
+        }*/
   }
 }
@@ -393,6 +396,6 @@
   for(int i = 0; i < ES_NUMBER; ++i)
     for(int j = 0; j < EV_NUMBER; ++j)
-      if( this->listeners[i][j] != NULL)
-        PRINT(0)("Event %d of State %d subscribed to %s (%p)\n", j, i, this->listeners[i][j]->getName(), this->listeners[i][j]);
+      for (unsigned int evl = 0; evl < this->listeners[i][j].size(); evl++)
+        PRINT(0)("Event %d of State %d subscribed to %s (%p)\n", j, i, this->listeners[i][j][evl]->getName(), this->listeners[i][j][evl]);
   PRINT(0)("============================EH=\n");
 }
Index: trunk/src/lib/event/event_handler.h
===================================================================
--- trunk/src/lib/event/event_handler.h	(revision 7677)
+++ trunk/src/lib/event/event_handler.h	(revision 7756)
@@ -12,4 +12,5 @@
 #include "event_def.h"
 #include <stack>
+#include <vector>
 
 // FORWARD DECLARATION
@@ -38,5 +39,5 @@
   void flush(elState state);
   /** @returns true, if the @param state has @param eventType subscribed?? */
-  inline bool isSubscribed(elState state, int eventType) { return(listeners[state][eventType] == NULL)?false:true; };
+  bool isSubscribed(elState state, int eventType);
 
 
@@ -54,13 +55,13 @@
 
  private:
-  static EventHandler*       singletonRef;                    //!< the singleton reference
+  static EventHandler*         singletonRef;                    //!< the singleton reference
 
-  EventListener*             listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners.
-  elState                    state;                           //!< the state of the event handlder.
-  std::stack<short>          stateStack;                      //!< a stack for the States we are in.
-  KeyMapper*                 keyMapper;                       //!< reference to the key mapper.
+  std::vector<EventListener*>  listeners[ES_NUMBER][EV_NUMBER]; //!< a list of registered listeners.
+  elState                      state;                           //!< the state of the event handlder.
+  std::stack<short>            stateStack;                      //!< a stack for the States we are in.
+  KeyMapper                    keyMapper;                       //!< reference to the key mapper.
 
-  bool                       bUNICODE;                        //!< If unicode should be enabled.
-  bool                       eventsGrabbed;                   //!< If the events should be grabbed
+  bool                         bUNICODE;                        //!< If unicode should be enabled.
+  bool                         eventsGrabbed;                   //!< If the events should be grabbed
 };
 
