Changeset 6000 in orxonox.OLD for branches/network/src/util
- Timestamp:
- Dec 9, 2005, 1:04:31 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/util/loading/game_loader.cc
r5982 r6000 117 117 } 118 118 119 120 /** 121 * reads a campaign definition file into a campaign class 122 * @param fileName to be loaded 123 * @returns the loaded campaign 124 125 this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 126 */ 127 ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName) 128 { 129 ErrorMessage errorCode; 130 char* campaignName = ResourceManager::getFullName(fileName); 131 if (campaignName) 132 { 133 this->currentCampaign = this->fileToNetworkCampaign(campaignName); 134 delete[] campaignName; 135 } 136 // World* world0 = new World(DEBUG_WORLD_0); 137 // world0->setNextStoryID(WORLD_ID_GAMEEND); 138 // this->currentCampaign->addEntity(world0, WORLD_ID_2); 139 } 140 141 142 119 143 /** 120 144 * loads a debug campaign for test purposes only. … … 272 296 273 297 298 299 /** 300 * reads a campaign definition file into a campaign class 301 * @param fileName to be loaded 302 * @returns the loaded campaign 303 304 this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 305 */ 306 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName) 307 { 308 /* do not entirely load the campaign. just the current world 309 before start of each world, it has to be initialized so it 310 can load everything it needs into memory then. 311 */ 312 313 if( fileName == NULL) 314 { 315 PRINTF(2)("No filename specified for loading"); 316 return NULL; 317 } 318 319 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName); 320 // load the campaign document 321 if( !XMLDoc->LoadFile()) 322 { 323 // report an error 324 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 325 delete XMLDoc; 326 return NULL; 327 } 328 329 // check basic validity 330 TiXmlElement* root = XMLDoc->RootElement(); 331 assert( root != NULL); 332 333 if( strcmp( root->Value(), "Campaign")) 334 { 335 // report an error 336 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 337 delete XMLDoc; 338 return NULL; 339 } 340 341 // construct campaign 342 Campaign* c = new Campaign( root); 343 344 // free the XML data 345 delete XMLDoc; 346 347 return c; 348 } 349 350 274 351 /** 275 352 * handle keyboard commands
Note: See TracChangeset
for help on using the changeset viewer.