Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6424 in orxonox.OLD for trunk/src/util/loading


Ignore:
Timestamp:
Jan 7, 2006, 11:07:22 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the branche network back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r 6351:HEAD
no conflicts

Location:
trunk/src/util/loading
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/game_loader.cc

    r6152 r6424  
    6161}
    6262
    63 
    64 /**
    65  *  this class is a singleton class
    66  * @returns an instance of itself
    67  *
    68  * if you are unsure about singleton classes, check the theory out on the internet :)
    69  */
    70 GameLoader* GameLoader::getInstance()
    71 {
    72   if(singletonRef == NULL)
    73     singletonRef = new GameLoader();
    74   return singletonRef;
    75 }
    7663
    7764/**
     
    124111  if (campaignName)
    125112  {
    126     this->currentCampaign = this->fileToNetworkCampaign(campaignName);
     113    this->currentCampaign = this->fileToCampaign(campaignName);
    127114    delete[] campaignName;
    128115  }
     
    225212
    226213/**
    227  *  release the mem ATTENTION: not implemented
    228  */
    229 ErrorMessage GameLoader::destroy()
    230 {
    231 
    232 }
    233 
    234 
    235 /**
    236214 *  reads a campaign definition file into a campaign class
    237215 * @param fileName to be loaded
     
    285263
    286264
    287 /**
    288  *  reads a campaign definition file into a campaign class
    289  * @param fileName to be loaded
    290  * @returns the loaded campaign
    291  *
    292  *  this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    293  */
    294 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName)
    295 {
    296   /* do not entirely load the campaign. just the current world
    297   before start of each world, it has to be initialized so it
    298   can load everything it needs into memory then.
    299   */
    300 
    301   if( fileName == NULL)
    302   {
    303     PRINTF(2)("No filename specified for loading");
    304     return NULL;
    305   }
    306 
    307   TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
    308   // load the campaign document
    309   if( !XMLDoc->LoadFile())
    310   {
    311       // report an error
    312     PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    313     delete XMLDoc;
    314     return NULL;
    315   }
    316 
    317   // check basic validity
    318   TiXmlElement* root = XMLDoc->RootElement();
    319   assert( root != NULL);
    320 
    321   if( strcmp( root->Value(), "Campaign"))
    322   {
    323       // report an error
    324     PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
    325     delete XMLDoc;
    326     return NULL;
    327   }
    328 
    329   // construct campaign
    330   Campaign* c = new Campaign( root);
    331 
    332   // free the XML data
    333   delete XMLDoc;
    334 
    335   return c;
    336 }
    337 
    338265
    339266/**
     
    347274    if( likely(event.bPressed))
    348275    {
    349       this->nextLevel();
    350     }
    351   }
    352   else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD)
    353   {
    354     if( likely(event.bPressed))
    355     {
    356       this->previousLevel();
     276      this->switchToNextLevel();
    357277    }
    358278  }
     
    377297
    378298/**
    379  *  \brief this changes to the next level
    380  */
    381 void GameLoader::nextLevel()
    382 {
    383   if(this->currentCampaign != NULL)
    384     this->currentCampaign->nextLevel();
    385 }
    386 
    387 
    388 /**
    389  *  change to the previous level - not implemented
    390  *
    391  * this propably useless
    392  */
    393 void GameLoader::previousLevel()
    394 {
    395   if(this->currentCampaign != NULL)
    396     this->currentCampaign->previousLevel();
    397 }
     299 *  this changes to the next level
     300 */
     301void GameLoader::switchToNextLevel()
     302{
     303  if(this->currentCampaign != NULL)
     304    this->currentCampaign->switchToNextLevel();
     305}
     306
     307
  • trunk/src/util/loading/game_loader.h

    r6152 r6424  
    4141 public:
    4242  ~GameLoader ();
     43  /**  this class is a singleton class @returns an instance of itself  */
     44  static GameLoader* getInstance() { if(singletonRef == NULL) singletonRef = new GameLoader(); return singletonRef; }
    4345
    44   static GameLoader* getInstance();
     46  ErrorMessage loadCampaign(const char* name);
     47  ErrorMessage loadDebugCampaign(Uint32 campaignID);
     48  ErrorMessage loadNetworkCampaign(const char* fileName);
    4549
    4650  ErrorMessage init();
     
    4953  ErrorMessage pause();
    5054  ErrorMessage resume();
    51   ErrorMessage destroy();
    5255
    53   ErrorMessage loadCampaign(const char* name);
    54   ErrorMessage loadDebugCampaign(Uint32 campaignID);
    55   ErrorMessage loadNetworkCampaign(const char* fileName);
    56 
    57   void nextLevel();
    58   void previousLevel();
     56  void switchToNextLevel();
    5957
    6058  void process(const Event &event);
     
    6563
    6664  Campaign* fileToCampaign(const char* name);
    67   Campaign* fileToNetworkCampaign(const char* fileName);
    6865
    6966
Note: See TracChangeset for help on using the changeset viewer.