Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2005, 1:21:26 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/ll2trunktemp: some more headers, now the level really gets loaded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/ll2trunktemp/src/game_loader.cc

    r3940 r3989  
    164164     can load everything it needs into memory then.
    165165  */
     166 
     167  if( name == NULL)
     168  {
     169                PRINTF0("No filename specified for loading");
     170                return NULL;
     171  }
     172 
     173        TiXmlDocument* XMLDoc = new TiXmlDocument( name);
     174        // load the campaign document
     175        if( !XMLDoc->LoadFile())
     176        {
     177                // report an error
     178                PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     179                delete XMLDoc;
     180                return NULL;
     181        }
     182       
     183        // check basic validity
     184        TiXmlElement* root = XMLDoc->RootElement();
     185        assert( root != NULL);
     186       
     187        if( strcmp( root->Value(), "Campaign"))
     188        {
     189                // report an error
     190                PRINTF0("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
     191                delete XMLDoc;
     192                return NULL;
     193        }
     194       
     195        // construct campaign
     196        Campaign* c = new Campaign( root);
     197       
     198        // free the XML data
     199        delete XMLDoc;
     200       
     201        return c;
    166202}
    167203
Note: See TracChangeset for help on using the changeset viewer.