Changeset 6139 in orxonox.OLD for trunk/src/util/loading
- Timestamp:
- Dec 16, 2005, 6:45:32 PM (19 years ago)
- Location:
- trunk/src/util/loading
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/game_loader.cc
r5982 r6139 46 46 /** 47 47 * simple constructor 48 */48 */ 49 49 GameLoader::GameLoader () 50 50 { … … 57 57 /** 58 58 * simple deconstructor 59 */59 */ 60 60 GameLoader::~GameLoader () 61 61 { … … 69 69 * this class is a singleton class 70 70 * @returns an instance of itself 71 72 73 */71 * 72 * if you are unsure about singleton classes, check the theory out on the internet :) 73 */ 74 74 GameLoader* GameLoader::getInstance() 75 75 { … … 81 81 /** 82 82 * initializes the GameLoader 83 */83 */ 84 84 ErrorMessage GameLoader::init() 85 85 { … … 100 100 * @param fileName to be loaded 101 101 * @returns the loaded campaign 102 103 104 */102 * 103 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 104 */ 105 105 ErrorMessage GameLoader::loadCampaign(const char* fileName) 106 106 { … … 112 112 delete[] campaignName; 113 113 } 114 // World* world0 = new World(DEBUG_WORLD_0); 115 // world0->setNextStoryID(WORLD_ID_GAMEEND); 116 // this->currentCampaign->addEntity(world0, WORLD_ID_2); 117 } 114 } 115 116 117 /** 118 * reads a campaign definition file into a campaign class 119 * @param fileName to be loaded 120 * @returns the loaded campaign 121 * 122 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 123 */ 124 ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName) 125 { 126 ErrorMessage errorCode; 127 char* campaignName = ResourceManager::getFullName(fileName); 128 if (campaignName) 129 { 130 this->currentCampaign = this->fileToNetworkCampaign(campaignName); 131 delete[] campaignName; 132 } 133 } 134 118 135 119 136 /** … … 121 138 * @param campaignID the identifier of the campaign. 122 139 * @returns error message if not able to do so. 123 */140 */ 124 141 ErrorMessage GameLoader::loadDebugCampaign(Uint32 campaignID) 125 142 { … … 156 173 157 174 /** 158 159 160 */175 * starts the current entity 176 * @returns error code if this action has caused a error 177 */ 161 178 ErrorMessage GameLoader::start() 162 179 { … … 167 184 168 185 /** 169 170 171 172 173 174 175 176 177 */186 * stops the current entity 187 * @returns error code if this action has caused a error 188 * 189 * ATTENTION: this function shouldn't call other functions, or if so, they must return 190 * after finishing. If you ignore or forget to do so, the current entity is not able to 191 * terminate and it will run in the background or the ressources can't be freed or even 192 * worse: are freed and the program will end in a segmentation fault! 193 * hehehe, have ya seen it... :) 194 */ 178 195 void GameLoader::stop() 179 196 { … … 184 201 185 202 /** 186 187 188 189 190 */203 * pause the current entity 204 * @returns error code if this action has caused a error 205 * 206 * this pauses the current entity or passes this call forth to the running entity. 207 */ 191 208 ErrorMessage GameLoader::pause() 192 209 { … … 198 215 199 216 /** 200 201 202 203 204 */217 * resumes a pause 218 * @returns error code if this action has caused a error 219 * 220 * this resumess the current entity or passes this call forth to the running entity. 221 */ 205 222 ErrorMessage GameLoader::resume() 206 223 { … … 224 241 * @param fileName to be loaded 225 242 * @returns the loaded campaign 226 227 228 */243 * 244 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 245 */ 229 246 Campaign* GameLoader::fileToCampaign(const char* fileName) 230 247 { … … 273 290 274 291 /** 292 * reads a campaign definition file into a campaign class 293 * @param fileName to be loaded 294 * @returns the loaded campaign 295 * 296 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 297 */ 298 Campaign* GameLoader::fileToNetworkCampaign(const char* fileName) 299 { 300 /* do not entirely load the campaign. just the current world 301 before start of each world, it has to be initialized so it 302 can load everything it needs into memory then. 303 */ 304 305 if( fileName == NULL) 306 { 307 PRINTF(2)("No filename specified for loading"); 308 return NULL; 309 } 310 311 TiXmlDocument* XMLDoc = new TiXmlDocument( fileName); 312 // load the campaign document 313 if( !XMLDoc->LoadFile()) 314 { 315 // report an error 316 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 317 delete XMLDoc; 318 return NULL; 319 } 320 321 // check basic validity 322 TiXmlElement* root = XMLDoc->RootElement(); 323 assert( root != NULL); 324 325 if( strcmp( root->Value(), "Campaign")) 326 { 327 // report an error 328 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 329 delete XMLDoc; 330 return NULL; 331 } 332 333 // construct campaign 334 Campaign* c = new Campaign( root); 335 336 // free the XML data 337 delete XMLDoc; 338 339 return c; 340 } 341 342 343 /** 275 344 * handle keyboard commands 276 345 * @param event the event to handle … … 312 381 313 382 /** 314 \brief this changes to the next level315 */383 * \brief this changes to the next level 384 */ 316 385 void GameLoader::nextLevel() 317 386 { … … 322 391 323 392 /** 324 \briefchange to the previous level - not implemented325 326 this propably useless327 */393 * change to the previous level - not implemented 394 * 395 * this propably useless 396 */ 328 397 void GameLoader::previousLevel() 329 398 { -
trunk/src/util/loading/game_loader.h
r5982 r6139 40 40 { 41 41 42 42 43 public: 43 44 ~GameLoader (); … … 46 47 47 48 ErrorMessage init(); 48 ErrorMessage loadCampaign(const char* name);49 49 ErrorMessage start(); 50 50 void stop(); … … 53 53 ErrorMessage destroy(); 54 54 55 ErrorMessage loadCampaign(const char* name); 56 ErrorMessage loadDebugCampaign(Uint32 campaignID); 57 ErrorMessage loadNetworkCampaign(const char* fileName); 58 55 59 void nextLevel(); 56 60 void previousLevel(); 57 61 58 /** \brief a world command to send to the GameLoader @param cmd the command */ 59 bool worldCommand(Command* cmd); 60 ErrorMessage loadDebugCampaign(Uint32 campaignID); 62 void process(const Event &event); 61 63 62 void process(const Event &event);63 64 64 65 private: … … 66 67 67 68 Campaign* fileToCampaign(const char* name); 69 Campaign* fileToNetworkCampaign(const char* fileName); 70 68 71 69 72 private:
Note: See TracChangeset
for help on using the changeset viewer.