Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2005, 5:27:49 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: faster and easier unsubscribe function implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/event/event_handler.cc

    r4419 r4420  
    127127      for(int i = 0; i < ES_NUMBER; ++i)
    128128        {
    129           for(int j = 0; j < SDLK_LAST; ++j)
     129          for(int j = 0; j < EV_NUMBER; ++j)
    130130            {
    131131              this->listeners[i][j] = NULL;
     
    135135  else
    136136    {
    137       for(int j = 0; j < SDLK_LAST; ++j)
     137      for(int j = 0; j < EV_NUMBER; ++j)
    138138        {
    139139          this->listeners[state][j] = NULL;
     140        }
     141    }
     142}
     143
     144void EventHandler::unsubscribe(EventListener* el, elState state)
     145{
     146  if( state == ES_ALL)
     147    {
     148      for(int i = 0; i < ES_NUMBER; ++i)
     149        {
     150          for(int j = 0; j < EV_NUMBER; ++j)
     151            {
     152              if( this->listeners[i][j] == el )
     153                this->listeners[i][j] = NULL;
     154            }
     155        }
     156    }
     157  else
     158    {
     159      for(int j = 0; j < EV_NUMBER; ++j)
     160        {
     161          if( this->listeners[state][j] == el )
     162            this->listeners[state][j] = NULL;
    140163        }
    141164    }
Note: See TracChangeset for help on using the changeset viewer.