Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4420 in orxonox.OLD


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

orxonox/trunk: faster and easier unsubscribe function implemented

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r4419 r4420  
    171171{
    172172  PRINTF(3)("World::~World() - deleting current world\n");
    173   CommandNode* cn = Orxonox::getInstance()->getLocalInput();
    174   cn->unbind(this->localPlayer);
    175   cn->reset();
     173
     174  this->eventHandler->unsubscribe(this->localPlayer);
    176175
    177176  delete WorldInterface::getInstance();
     
    186185  //delete garbagecollecor
    187186  //delete animator
    188  
    189   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_UP);
    190   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_DOWN);
    191   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_LEFT);
    192   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_RIGHT);
    193   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_FIRE1);
    194   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_NEXT_WEAPON);
    195   this->eventHandler->unsubscribe(ES_GAME, KeyMapper::PEV_PREVIOUS_WEAPON);
    196 
    197187
    198188  LoadClassDescription::printAll();
  • 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    }
  • orxonox/trunk/src/util/event/event_handler.h

    r4419 r4420  
    2828  void subscribe(EventListener* el, elState state, int eventType);
    2929  void unsubscribe(elState state, int eventType);
     30  void unsubscribe(EventListener* el, elState state = ES_ALL);
     31
    3032  void flush(elState state);
    3133
  • orxonox/trunk/src/world_entities/camera.cc

    r4419 r4420  
    5757Camera::~Camera(void)
    5858{
    59   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW0);
    60   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW1);
    61   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW2);
    62   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW3);
    63   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW4);
    64   EventHandler::getInstance()->unsubscribe(ES_GAME, KeyMapper::PEV_VIEW5);
     59  EventHandler::getInstance()->unsubscribe(this);
    6560}
    6661
Note: See TracChangeset for help on using the changeset viewer.