Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6374 in orxonox.OLD for branches


Ignore:
Timestamp:
Dec 31, 2005, 3:53:45 PM (19 years ago)
Author:
patrick
Message:

network: single player loads again, many changes in the function bodies of the loading code

Location:
branches/network/src/story_entities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/story_entities/campaign.cc

    r6372 r6374  
    2525
    2626
    27 Campaign::Campaign ()
     27/**
     28 *  the constructor
     29 * @param root the XML root element
     30 *
     31 * this constructor is always called in a XML context (loading procedure)
     32 */
     33Campaign::Campaign ( TiXmlElement* root)
    2834{
    2935  this->setClassID(CL_CAMPAIGN, "Campaign");
    3036  this->isInit = false;
    31 }
    32 
    33 Campaign::Campaign ( TiXmlElement* root)
    34 {
    35   this->setClassID(CL_CAMPAIGN, "Campaign");
    3637
    3738  PRINTF(4)("Loading Campaign...\n");
    38 
    3939  assert( root != NULL);
    4040
    41   this->isInit = false;
    42 
    4341  this->loadParams(root);
    44 
    45 
    46   //if( lastCreated != NULL)
    47   //lastCreated->setStoryID( WORLD_ID_GAMEEND);
    48 }
    49 
     42}
     43
     44
     45/**
     46 * the campaign destructor
     47 */
    5048Campaign::~Campaign ()
    5149{}
     
    7068
    7169  LoadParam(root, "identifier", this, Campaign, setStoryID)
    72      .describe("A Unique Identifier for this Campaign");
    73 
    74    LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams)
    75       .describe("A List of Worlds to be loaded in this Campaign");
     70  .describe("A Unique Identifier for this Campaign");
     71
     72  LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams)
     73  .describe("A List of Worlds to be loaded in this Campaign");
    7674}
    7775
     
    8381void Campaign::loadWorldListParams(const TiXmlElement* root)
    8482{
    85   if (root == NULL)
     83  if( root == NULL)
    8684    return;
    8785
    8886  LOAD_PARAM_START_CYCLE(root, element);
    8987  {
    90     PRINTF(5)("Campaign: Constructor: adding a world\n");
    9188    StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
    9289    if( created != NULL)
    93     {
    9490      this->addEntity( created);
    95     }
     91    PRINTF(3)("Campaign: Constructor: adding a world with name \"%s\" and id %i\n",
     92              created->getName(), created->getStoryID());
    9693  }
    9794  LOAD_PARAM_END_CYCLE(element);
    98 }
     95
     96}
     97
    9998
    10099/**
     
    120119  this->currentEntity = se;
    121120  while( se != NULL && this->running)
     121  {
     122    PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", se->getStoryID());
     123
     124    se->init();
     125    se->loadData();
     126
     127    se->preStart();
     128    se->start();
     129
     130
     131    int nextWorldID = se->getNextStoryID();
     132
     133    this->entities.remove(se);
     134    delete se;
     135
     136    se = this->getStoryEntity(nextWorldID);
     137    this->currentEntity = se;
     138    if( ( nextWorldID == WORLD_ID_GAMEEND) || ( se == NULL) )
    122139    {
    123       PRINTF(0)("Starting new StoryEntity Nr:%i\n", se->getStoryID());
    124 
    125       se->init();
    126 
    127       //se->preLoad();
    128       se->loadData();
    129       //se->postLoad();
    130 
    131 
    132       se->preStart();
    133       se->start();
    134 
    135       int nextWorldID = se->getNextStoryID();
    136 
    137       this->entities.remove(se);
    138       delete se;
    139 
    140       //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID);
    141       se = this->getStoryEntity(nextWorldID);
    142       this->currentEntity = se;
    143       if( ( nextWorldID == WORLD_ID_GAMEEND) || ( se == NULL) )
    144         {
    145           PRINTF(4)("Quitting campaing story loop\n");
    146           if(se != NULL)
    147             delete se;
    148           return errorCode;
    149         }
     140      PRINTF(4)("Quitting campaing story loop\n");
     141      if(se != NULL)
     142        delete se;
     143      return errorCode;
    150144    }
    151 
    152     /* clean up all world that have not been loaded and therefore are still in the world list  -
    153        this probably does not belong into the start function. remove this later
    154     */
    155     list<StoryEntity*>::iterator it;
    156     for(it = this->entities.begin(); it != entities.end(); it++)
    157     {
    158       delete (*it);
    159     }
    160     PRINTF(1)("There is no StoryEnity left to play, quitting\n");
     145  }
     146
     147  /* clean up all world that have not been loaded and therefore are still in the world list  -
     148     this probably does not belong into the start function. remove this later
     149  */
     150  list<StoryEntity*>::iterator it;
     151  for(it = this->entities.begin(); it != entities.end(); it++)
     152  {
     153    delete (*it);
     154  }
     155
     156  PRINTF(2)("There is no StoryEnity left to play, quitting\n");
    161157}
    162158
     
    183179  this->running = false;
    184180  if(this->currentEntity != NULL)
    185     {
    186       this->currentEntity->stop();
    187     }
     181  {
     182    this->currentEntity->stop();
     183  }
    188184}
    189185
     
    259255StoryEntity* Campaign::getStoryEntity(int storyID)
    260256{
    261   //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID);
    262257  if( storyID == WORLD_ID_GAMEEND)
    263258    return NULL;
    264259
    265   /*
    266   tList<StoryEntity>* l;
    267   StoryEntity* entity = NULL;
    268   l = this->entities->getNext();
    269   while( l != NULL)
    270     {
    271       entity = l->getObject();
    272       l = l->getNext();
    273 
    274       int id = entity->getStoryID();
    275       //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    276       if(id == storyID)
    277         {
    278           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    279           return entity;
    280         }
    281 
    282     }
    283   */
    284 
    285 
     260  int id;
    286261  list<StoryEntity*>::iterator it;
    287   for (it = this->entities.begin(); it != this->entities.end(); it++)
    288   {
    289       int id = (*it)->getStoryID();
    290       //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
    291       if(id == storyID)
    292         {
    293           //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
    294           return (*it);
    295         }
    296     }
    297 
    298 
     262  for( it = this->entities.begin(); it != this->entities.end(); it++)
     263  {
     264    id = (*it)->getStoryID();
     265    if( id == storyID)
     266      return (*it);
     267  }
    299268
    300269  return NULL;
  • branches/network/src/story_entities/campaign.h

    r6372 r6374  
    1414
    1515  public:
    16     Campaign ();
    17     Campaign ( TiXmlElement* root);
     16    Campaign( TiXmlElement* root);
    1817    virtual ~Campaign ();
    1918
     
    4847};
    4948
     49
     50
     51class CampaignData : virtual public BaseObject
     52{
     53
     54  public:
     55    CampaignData();
     56    virtual ~CampaignData();
     57
     58    void addStoryEntity(StoryEntity* se, int storyID = -1);
     59
     60    void getNextLevel();
     61};
     62
    5063#endif /* _CAMPAIGN_H */
  • branches/network/src/story_entities/game_world.cc

    r6372 r6374  
    8282
    8383GameWorld::GameWorld(const TiXmlElement* root)
     84  : StoryEntity()
    8485{
    8586  this->setClassID(CL_GAME_WORLD, "GameWorld");
     
    9798
    9899  this->path = NULL;
    99 
    100   this->loadParams(root);
    101100}
    102101
  • branches/network/src/story_entities/single_player_world.cc

    r6365 r6374  
    3838  : GameWorld(root)
    3939{
     40  this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld");
     41  this->setName("SinglePlayerWorld uninitialized");
     42
    4043  this->loadParams(root);
    4144}
     
    5154{
    5255  PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n");
    53 }
    54 
    55 
    56 /**
    57  * initializes the world.
    58  * @param name the name of the world
    59  * @param worldID the ID of this world
    60  *
    61  * set all stuff here that is world generic and does not use to much memory
    62  * because the real init() function StoryEntity::init() will be called
    63  * shortly before start of the game.
    64  * since all worlds are initiated/referenced before they will be started.
    65  * NO LEVEL LOADING HERE - NEVER!
    66 */
    67 void SinglePlayerWorld::constuctorInit(const char* name, int worldID)
    68 {
    69   this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld");
    70   this->setName(name);
    71 
    72   this->gameTime = 0.0f;
    73   this->setSpeed(1.0);
    74   this->music = NULL;
    75   this->shell = NULL;
    76   this->localPlayer = NULL;
    77   this->localCamera = NULL;
    78 
    79   this->showPNodes = false;
    80   this->showBV = false;
    8156}
    8257
  • branches/network/src/story_entities/single_player_world.h

    r6365 r6374  
    2828
    2929  private:
    30     void constuctorInit(const char* name, int worldID);
     30
    3131};
    3232
  • branches/network/src/story_entities/story_entity.h

    r6372 r6374  
    1818  StoryEntity ();
    1919  virtual ~StoryEntity ();
     20
     21  void loadParams(const TiXmlElement* root);
    2022
    2123  /* initialisation and loading */
     
    4749  inline void setStoryID(int storyID) { this->storyID = storyID; }
    4850  /** sets the story id of the current entity, this enables it to be identified in a  global context. @returns  the story id  */
    49   inline int getStoryID() { this->storyID = storyID; }
     51  inline int getStoryID() { return this->storyID; }
    5052  /**  sets the id of the next story entity: StoryEntities can choose their following entity themselfs.
    5153   * the entity id defined here  will be startet after this entity ends. this can be convenient if you
Note: See TracChangeset for help on using the changeset viewer.