Changeset 6386 in orxonox.OLD for branches/network/src/util
- Timestamp:
- Jan 2, 2006, 1:30:23 AM (19 years ago)
- Location:
- branches/network/src/util/loading
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/util/loading/game_loader.cc
r6152 r6386 61 61 } 62 62 63 64 /**65 * this class is a singleton class66 * @returns an instance of itself67 *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 }76 63 77 64 /** … … 124 111 if (campaignName) 125 112 { 126 this->currentCampaign = this->fileTo NetworkCampaign(campaignName);113 this->currentCampaign = this->fileToCampaign(campaignName); 127 114 delete[] campaignName; 128 115 } … … 225 212 226 213 /** 227 * release the mem ATTENTION: not implemented228 */229 ErrorMessage GameLoader::destroy()230 {231 232 }233 234 235 /**236 214 * reads a campaign definition file into a campaign class 237 215 * @param fileName to be loaded … … 285 263 286 264 287 /**288 * reads a campaign definition file into a campaign class289 * @param fileName to be loaded290 * @returns the loaded campaign291 *292 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns293 */294 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName)295 {296 /* do not entirely load the campaign. just the current world297 before start of each world, it has to be initialized so it298 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 document309 if( !XMLDoc->LoadFile())310 {311 // report an error312 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 validity318 TiXmlElement* root = XMLDoc->RootElement();319 assert( root != NULL);320 321 if( strcmp( root->Value(), "Campaign"))322 {323 // report an error324 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 campaign330 Campaign* c = new Campaign( root);331 332 // free the XML data333 delete XMLDoc;334 335 return c;336 }337 338 265 339 266 /** … … 347 274 if( likely(event.bPressed)) 348 275 { 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(); 357 277 } 358 278 } … … 377 297 378 298 /** 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 */ 301 void GameLoader::switchToNextLevel() 302 { 303 if(this->currentCampaign != NULL) 304 this->currentCampaign->switchToNextLevel(); 305 } 306 307 -
branches/network/src/util/loading/game_loader.h
r6152 r6386 41 41 public: 42 42 ~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; } 43 45 44 static GameLoader* getInstance(); 46 ErrorMessage loadCampaign(const char* name); 47 ErrorMessage loadDebugCampaign(Uint32 campaignID); 48 ErrorMessage loadNetworkCampaign(const char* fileName); 45 49 46 50 ErrorMessage init(); … … 49 53 ErrorMessage pause(); 50 54 ErrorMessage resume(); 51 ErrorMessage destroy();52 55 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(); 59 57 60 58 void process(const Event &event); … … 65 63 66 64 Campaign* fileToCampaign(const char* name); 67 Campaign* fileToNetworkCampaign(const char* fileName);68 65 69 66
Note: See TracChangeset
for help on using the changeset viewer.