Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3654 in orxonox.OLD


Ignore:
Timestamp:
Mar 25, 2005, 6:47:26 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: altered the list function to make it more performant the world now uses iterators everywhere.

Location:
orxonox/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/command_node.cc

    r3608 r3654  
    281281  if( this->world->command(cmd)) return;
    282282
    283   WorldEntity* entity = bound->enumerate();
     283  tIterator<WorldEntity>* iterator = bound->getIterator();
     284  WorldEntity* entity = iterator->nextElement();
    284285  while( entity != NULL)
    285286    {
    286287      entity->command (cmd); /*no absorbtion of command! strange*/
    287       entity = bound->nextElement();
    288     }
     288      entity = iterator->nextElement();
     289    }
     290  delete iterator;
    289291}
    290292
  • orxonox/trunk/src/lib/util/list.h

    r3653 r3654  
    8787inline T* tIterator<T>::nextElement ()
    8888{
    89   if( this->currentEl == NULL)
    90     {
    91       PRINTF(1)("Iterator has not been initialized - there is no currentEl\n");
     89  if( this->currentEl == NULL || this->currentEl->next == NULL) /* don't turn it the other way or it will give segfaults! */
    9290      return NULL;
    93     }
    9491  if( this->currentEl == this->firstEl)
    9592    {
    9693      this->currentEl = this->currentEl->next;
    97       return this->firstEl->curr;
    98     }
    99   if( this->currentEl->next == NULL)
    100     return NULL;
     94      return this->firstEl->curr; /* if its the first element, don't return second element*/
     95    }
    10196  this->currentEl = this->currentEl->next;
    10297  return this->currentEl->curr;
     
    126121
    127122 private:
    128 
    129123  Uint32 size;
    130124  listElement<T>* first;
    131125  listElement<T>* last;
    132126  listElement<T>* currentEl;
    133 
    134127};
    135128
     
    255248inline tIterator<T>* tList<T>::getIterator()
    256249{
    257   if( this->size == 0) return NULL;
    258250  tIterator<T>* iterator = new tIterator<T>(this->first);
    259251  return iterator;
  • orxonox/trunk/src/story_entities/world.cc

    r3653 r3654  
    755755     
    756756      /* function to let all entities tick (iterate through list) */
    757       WorldEntity* entity;
    758757      float seconds = this->dt / 1000.0;     
    759758      this->gameTime += seconds;
    760       entity = entities->enumerate();
     759      //entity = entities->enumerate();
     760      tIterator<WorldEntity>* iterator = this->entities->getIterator();
     761      WorldEntity* entity = iterator->nextElement();
    761762      while( entity != NULL)
    762763        {
    763764          entity->tick (seconds);
    764           entity = entities->nextElement();
     765          entity = iterator->nextElement();
    765766        }
     767      delete iterator;
    766768      //skySphere->updatePosition(localCamera->absCoordinate);
    767769     
  • orxonox/trunk/src/world_entities/player.cc

    r3631 r3654  
    207207      PRINTF(1)("changing the weapon of the player: deactivate old, activate new\n");
    208208      this->activeWeapon->deactivate();
    209       this->weapons->enumerate();
     209      //this->weapons->enumerate();  FIX: strang weapon change...
    210210      this->activeWeapon = this->weapons->nextElement(this->activeWeapon);
    211211      this->activeWeapon->activate();
Note: See TracChangeset for help on using the changeset viewer.