Changeset 5979 in orxonox.OLD for branches/network/src
- Timestamp:
- Dec 7, 2005, 5:58:01 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/orxonox.cc
r5972 r5979 351 351 352 352 this->gameLoader = GameLoader::getInstance(); 353 354 if( this->port == -1 || this->serverName != NULL)355 this->gameLoader->loadNetworkCampaign("worlds/Default NetworkCampaign.oxc");353 354 if( this->port != -1 || this->serverName != NULL) 355 this->gameLoader->loadNetworkCampaign("worlds/DefaultCampaign.oxc"); 356 356 else 357 357 this->gameLoader->loadCampaign("worlds/DefaultCampaign.oxc"); 358 358 359 359 // this->gameLoader->loadDebugCampaign(DEBUG_CAMPAIGN_0); 360 360 this->gameLoader->init(); -
branches/network/src/util/loading/game_loader.cc
r5974 r5979 143 143 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 144 144 */ 145 ErrorMessage GameLoader::loadNetworkCampaign(const char* name) 146 {} 145 ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName) 146 { 147 ErrorMessage errorCode; 148 char* campaignName = ResourceManager::getFullName(fileName); 149 if( campaignName) 150 { 151 this->currentCampaign = this->fileToNetworkCampaign(campaignName); 152 delete[] campaignName; 153 } 154 } 147 155 148 156 … … 303 311 304 312 /** 313 * reads a campaign definition file into a campaign class 314 * @param fileName to be loaded 315 * @returns the loaded campaign 316 * 317 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 318 */ 319 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName) 320 { 321 /* do not entirely load the campaign. just the current world 322 before start of each world, it has to be initialized so it 323 can load everything it needs into memory then. 324 */ 325 326 if( fileName == NULL) 327 { 328 PRINTF(2)("No filename specified for loading"); 329 return NULL; 330 } 331 332 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName); 333 // load the campaign document 334 if( !XMLDoc->LoadFile()) 335 { 336 // report an error 337 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 338 delete XMLDoc; 339 return NULL; 340 } 341 342 // check basic validity 343 TiXmlElement* root = XMLDoc->RootElement(); 344 assert( root != NULL); 345 346 if( strcmp( root->Value(), "Campaign")) 347 { 348 // report an error 349 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 350 delete XMLDoc; 351 return NULL; 352 } 353 354 // construct campaign 355 Campaign* c = new Campaign( root); 356 357 // free the XML data 358 delete XMLDoc; 359 360 return c; 361 } 362 363 364 /** 305 365 * handle keyboard commands 306 366 * @param event the event to handle -
branches/network/src/util/loading/game_loader.h
r5974 r5979 58 58 59 59 ErrorMessage loadDebugCampaign(Uint32 campaignID); 60 ErrorMessage loadCampaign(const char* name);61 ErrorMessage loadNetworkCampaign(const char* name);60 ErrorMessage loadCampaign(const char* fileName); 61 ErrorMessage loadNetworkCampaign(const char* fileName); 62 62 63 63 void process(const Event &event); … … 70 70 GameLoader (); 71 71 72 Campaign* fileToCampaign(const char* name); 72 Campaign* fileToCampaign(const char* fileName); 73 Campaign* fileToNetworkCampaign(const char* fileName); 73 74 74 75
Note: See TracChangeset
for help on using the changeset viewer.