Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3220 in orxonox.OLD for orxonox/trunk/src/campaign.cc


Ignore:
Timestamp:
Dec 19, 2004, 9:09:36 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: fixed a lot of bugs with StoryEntity management, also cleared up some old unused code

File:
1 edited

Legend:

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

    r3209 r3220  
    4848    want to queue up in the campaign.
    4949*/
    50 void Campaign::addEntity(StoryEntity* se, Uint32 storyID)
     50void Campaign::addEntity(StoryEntity* se, int storyID)
    5151{
    5252  se->setStoryID(storyID);
     
    6060
    6161
    62 void Campaign::removeEntity(Uint32 storyID)
     62void Campaign::removeEntity(int storyID)
    6363{
    6464  this->removeEntity(this->getStoryEntity(storyID));
     
    7878}
    7979
    80 Error Campaign::start(Uint32 storyID = 0)
     80Error Campaign::start(int storyID = 0)
    8181{
    8282  printf("World::start() - starting new StoryEntity Nr:%i\n", storyID);
     
    8686  this->running = true;
    8787  StoryEntity* se = this->getStoryEntity(storyID);
     88  this->currentEntity = se;
    8889  while(se != NULL && this->running)
    8990    {
    90       se = this->getStoryEntity(storyID);
    91       this->currentEntity = se;
     91      //se = this->getStoryEntity(storyID);
    9292     
    93       se->displayEntityScreen();
     93     
     94      se->displayLoadScreen();
    9495      se->load();
    9596      se->init();
    96       se->releaseEntityScreen();
     97      se->releaseLoadScreen();
    9798      se->start();
    9899
     100      delete se;
     101
    99102      int nextWorldID = se->getNextStoryID();
    100       if(nextWorldID == WORLD_ID_GAMEEND) return errorCode;
     103      //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID);
    101104      se = this->getStoryEntity(nextWorldID);
    102       if(se == NULL)
    103         printf("Campaign::start() - ERROR: world not found, oh oh...\n");
     105      this->currentEntity = se;
     106      if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) )
     107        {
     108          printf("Campaign::start() - quiting campaing story loop\n");
     109          if(se != NULL)
     110            delete se;
     111          return errorCode;
     112        }
     113     
    104114    }
    105115}
     
    111121    {
    112122      this->currentEntity->stop();
    113       delete this->currentEntity;
    114       this->currentEntity = NULL;
     123      //delete this->currentEntity;
     124      //this->currentEntity = NULL;
    115125    }
    116126}
     
    130140
    131141
     142void Campaign::destroy()
     143{
     144  if(this->currentEntity != NULL)
     145    {
     146      this->currentEntity->destroy();
     147      delete this->currentEntity;
     148      this->currentEntity = NULL;
     149    }
     150}
     151
    132152void Campaign::nextLevel()
    133153{
    134   printf("Campaign|nextLevel\n");
    135   int nextID = this->currentEntity->getNextStoryID();
    136   this->stop();
    137   this->start(nextID);
     154  printf("Campaign:nextLevel()\n");
     155  //int nextID = this->currentEntity->getNextStoryID();
     156  //this->stop();
     157  //this->start(nextID);
     158  this->currentEntity->stop();
    138159}
    139160
     
    142163
    143164
    144 StoryEntity* Campaign::getStoryEntity(Uint32 storyID)
     165StoryEntity* Campaign::getStoryEntity(int storyID)
    145166{
     167  //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID);
     168  if( storyID == WORLD_ID_GAMEEND)
     169    return NULL;
    146170  ListTemplate<StoryEntity>* l;
    147   StoryEntity* entity;
     171  StoryEntity* entity = NULL;
    148172  l = this->entities->get_next(); 
    149173  while( l != NULL)
     
    151175      entity = l->get_object();
    152176      l = l->get_next();
    153       if(entity->getStoryID() == storyID)
    154         return entity;
     177      int id = entity->getStoryID();
     178      //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
     179      if(id == storyID)
     180        {
     181          //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
     182          return entity;
     183        }
    155184    }
    156185  return NULL;
Note: See TracChangeset for help on using the changeset viewer.