Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3220 in orxonox.OLD


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

Location:
orxonox/trunk/src
Files:
8 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;
  • orxonox/trunk/src/campaign.h

    r2816 r3220  
    1919  virtual Error init();
    2020  virtual Error start();
    21   virtual Error start(Uint32 storyID);
     21  virtual Error start(int storyID);
    2222  virtual Error stop();
    2323  virtual Error pause();
    2424  virtual Error resume();
    2525
    26   void addEntity(StoryEntity* se, Uint32 storyID);
     26  virtual void destroy();
     27
     28  void addEntity(StoryEntity* se, int storyID);
    2729  void addEntity(StoryEntity* se);
    28   void removeEntity(Uint32 storyID);
     30  void removeEntity(int storyID);
    2931  void removeEntity(StoryEntity* se);
    3032 
     
    3638  bool running;
    3739
    38   StoryEntity* getStoryEntity(Uint32 storyID);
     40  StoryEntity* getStoryEntity(int storyID);
    3941};
    4042
  • orxonox/trunk/src/game_loader.cc

    r3215 r3220  
    7272      {
    7373        Campaign* debugCampaign = new Campaign();
     74
    7475        World* world0 = new World(DEBUG_WORLD_0);
    75         world0->setNextStoryID(DEBUG_WORLD_1);
     76        world0->setNextStoryID(WORLD_ID_1);
    7677        debugCampaign->addEntity(world0, WORLD_ID_0);
     78
    7779        World* world1 = new World(DEBUG_WORLD_1);
    7880        world1->setNextStoryID(WORLD_ID_GAMEEND);
     
    162164      return true;
    163165    }
     166  else if( !strcmp( cmd->cmd, "quit"))
     167    {
     168      if( !cmd->bUp) this->stop();
     169      return true;
     170    }
    164171  return false;
    165172}
  • orxonox/trunk/src/orxonox.cc

    r3216 r3220  
    269269bool Orxonox::system_command (Command* cmd)
    270270{
    271  
     271  /*
    272272  if( !strcmp( cmd->cmd, "quit"))
    273273    {
     
    276276    }
    277277  return false;
    278  
     278  */
     279  return false;
    279280}
    280281
  • orxonox/trunk/src/story_def.h

    r2636 r3220  
    44
    55
    6 #define DEBUG_CAMPAIGN_0 0
    7 #define DEBUG_CAMPAIGN_1 1
    8 #define DEBUG_CAMPAIGN_2 2
     6#define DEBUG_CAMPAIGN_0 1000
     7#define DEBUG_CAMPAIGN_1 1001
     8#define DEBUG_CAMPAIGN_2 1002
    99
    10 #define DEBUG_WORLD_0 0
    11 #define DEBUG_WORLD_1 1
    12 #define DEBUG_WORLD_2 2
     10#define DEBUG_WORLD_0 100
     11#define DEBUG_WORLD_1 101
     12#define DEBUG_WORLD_2 102
    1313
    1414#define WORLD_ID_0 0
     
    2020#define WORLD_ID_GAMEEND 999
    2121
    22 #define MAX_STORY_ENTITIES 99; //!> maximal StoryEntities in a Campaign
     22#define MAX_STORY_ENTITIES 99 //!> maximal StoryEntities in a Campaign
    2323
    2424#endif
  • orxonox/trunk/src/story_entity.cc

    r2636 r3220  
    3939
    4040
    41 void StoryEntity::setStoryID(Uint32 storyID)
     41void StoryEntity::setStoryID(int storyID)
    4242{
    4343  this->storyID = storyID;
     
    5050
    5151
    52 void StoryEntity::setNextStoryID(Uint32 nextStoryID)
     52void StoryEntity::setNextStoryID(int nextStoryID)
    5353{
    5454  this->nextStoryID = nextStoryID;
    5555}
    5656
    57 Uint32 StoryEntity::getNextStoryID()
     57int StoryEntity::getNextStoryID()
    5858{
    5959  return this->nextStoryID;
     
    6161
    6262
    63 Error StoryEntity::start(Uint32 storyID)
     63Error StoryEntity::start(int storyID)
    6464{}
    6565
     
    8080{}
    8181
    82 
    83 void StoryEntity::displayEntityScreen()
     82void StoryEntity::destroy()
    8483{}
    8584
    86 void StoryEntity::releaseEntityScreen()
     85
     86void StoryEntity::displayLoadScreen()
    8787{}
     88
     89void StoryEntity::releaseLoadScreen()
     90{}
  • orxonox/trunk/src/story_entity.h

    r2636 r3220  
    1616
    1717  virtual Error init();
    18   virtual Error start(Uint32 storyID);
     18  virtual Error start(int storyID);
    1919  virtual Error start();
    2020  virtual Error stop();
     
    2323
    2424  virtual void load();
     25  virtual void destroy();
    2526
    26   virtual void displayEntityScreen();
    27   virtual void releaseEntityScreen();
     27  virtual void displayLoadScreen();
     28  virtual void releaseLoadScreen();
    2829
    29   void setStoryID(Uint32 storyID);
     30  void setStoryID(int storyID);
    3031  int getStoryID();
    3132
    32   void setNextStoryID(Uint32 nextStoryID);
    33   Uint32 getNextStoryID();
     33  void setNextStoryID(int nextStoryID);
     34  int getNextStoryID();
    3435
    3536
    3637 private:
    37   Uint32 storyID;
    38   Uint32 nextStoryID;
     38  int storyID;
     39  int nextStoryID;
    3940};
    4041
  • orxonox/trunk/src/world.cc

    r3216 r3220  
    5151World::~World ()
    5252{
    53   Orxonox *orx = Orxonox::getInstance();
    54   orx->get_localinput()->unbind (this->localPlayer);
    55   delete this->entities;
    56   delete this->localCamera;
    57 }
    58 
    59 
    60 /**
    61     \brief initialize the world before use.
    62 */
    63 Error World::init()
    64 {
    65   this->bPause = false;
     53  printf("World::~World() - deleting current world\n");
    6654  CommandNode* cn = Orxonox::getInstance()->get_localinput();
    67   cn->addToWorld(this);
    68   cn->enable(true);
    69 }
    70 
    71 Error World::start()
    72 {
    73   this->mainLoop();
    74 }
    75 
    76 Error World::stop()
    77 {
    78   this->bQuitCurrentGame = true;
    79   //this->localCamera->setWorld(NULL);
    80   this->localPlayer->destroy();
     55  cn->unbind(this->localPlayer);
     56  cn->reset();
    8157  this->localCamera->destroy();
    8258
     
    8864    }
    8965  this->entities->destroy();
    90   Orxonox::getInstance()->get_localinput()->reset();
     66
     67  delete this->entities;
     68  delete this->localCamera;
     69  /* this->localPlayer hasn't to be deleted explicitly, it is
     70     contained in entities*/
     71}
     72
     73
     74/**
     75    \brief initialize the world before use.
     76*/
     77Error World::init()
     78{
     79  this->bPause = false;
     80  CommandNode* cn = Orxonox::getInstance()->get_localinput();
     81  cn->addToWorld(this);
     82  cn->enable(true);
     83}
     84
     85Error World::start()
     86{
     87  printf("World::start() - starting current World: nr %i\n", this->debugWorldNr);
     88  this->bQuitOrxonox = false;
     89  this->bQuitCurrentGame = false;
     90  this->mainLoop();
     91}
     92
     93Error World::stop()
     94{
     95  printf("World::stop() - got stop signal\n");
     96  this->bQuitCurrentGame = true;
    9197}
    9298
     
    568574{
    569575  this->lastFrame = SDL_GetTicks();
    570   this->bQuitOrxonox = false;
    571   this->bQuitCurrentGame = false;
    572   printf("World|Entering main loop\n");
     576  printf("World::mainLoop() - Entering main loop\n");
    573577  while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */
    574578    {
     
    740744bool World::command(Command* cmd)
    741745{
    742   if( !strcmp( cmd->cmd, "quit"))
    743     {
    744       if( !cmd->bUp) this->stop();
    745       return true;
    746     }
    747746  return false;
    748747}
Note: See TracChangeset for help on using the changeset viewer.