Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 11, 2005, 5:28:38 PM (19 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: Feeble attempt to load anything… neither finished nor useful

File:
1 edited

Legend:

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

    r3499 r3501  
    3535
    3636
    37 GameLoader::GameLoader () {}
     37GameLoader::GameLoader ()
     38{
     39        first = NULL;
     40}
    3841
    3942
     
    155158     can load everything it needs into memory then.
    156159  */
     160 
     161  if( name == NULL)
     162  {
     163                PRINTF(ERR)("No filename specified for loading");
     164  }
     165 
     166        TiXMLDocument* XMLDoc = new TiXMLDocument( name);
     167        // load the campaign document
     168        if( !XMLDoc.LoadFile())
     169        {
     170                // report an error
     171                PRINTF(ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
     172                delete XMLDoc;
     173                return NULL;
     174        }
     175       
     176        // check basic validity
     177        TiXMLElement* element = XMLDoc.RootElement();
     178        assert( element != NULL);
     179       
     180        element = element->FirstChildElement( "Campaign");
     181       
     182        if( element == NULL )
     183        {
     184                // report an error
     185                PRINTF(ERR)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
     186                delete XMLDoc;
     187                return NULL;
     188        }
     189       
     190        // construct campaign
     191        Campaign c = new Campaign( element);
     192       
     193        // free the XML data
     194        delete XMLDoc;
    157195}
    158196
     
    221259    this->currentCampaign->previousLevel();
    222260}
     261
     262
     263/**
     264   \brief add a Factory to the Factory Q
     265   \param factory a Factory to be registered
     266*/
     267void GameLoader::registerFactory( Factory* factory)
     268{
     269        if( next == NULL) next = factory;
     270        else next->registerFactory( factory);
     271}
     272
     273/**
     274   \brief load a StoryEntity
     275   \param element a XMLElement containing all the needed info
     276*/
     277StoryEntity* GameLoader::fabricate( TiXMLElement* element)
     278{
     279        if( first == NULL)
     280        {
     281                PRINTF(ERR)("GameLoader does not know any factories, fabricate() failed\n");
     282                return NULL;
     283        }
     284       
     285        return first->fabricate( element);
     286}
Note: See TracChangeset for help on using the changeset viewer.