Changeset 4217 in orxonox.OLD for orxonox/branches/movie_player/src/game_loader.cc
- Timestamp:
- May 18, 2005, 11:27:40 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/movie_player/src/game_loader.cc
r4010 r4217 25 25 #include "command_node.h" 26 26 #include "vector.h" 27 #include "resource_manager.h" 27 28 #include "factory.h" 28 29 … … 36 37 37 38 38 GameLoader::GameLoader () {} 39 GameLoader::GameLoader () 40 { 41 first = NULL; 42 } 39 43 40 44 … … 70 74 this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 71 75 */ 72 ErrorMessage GameLoader::loadCampaign(c har* name)76 ErrorMessage GameLoader::loadCampaign(const char* name) 73 77 { 74 78 ErrorMessage errorCode; 75 76 this->currentCampaign = this->fileToCampaign(name); 79 char* campaignName = ResourceManager::getFullName(name); 80 if (campaignName) 81 { 82 this->currentCampaign = this->fileToCampaign(campaignName); 83 delete campaignName; 84 } 77 85 } 78 86 … … 159 167 this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 160 168 */ 161 Campaign* GameLoader::fileToCampaign(c har *name)169 Campaign* GameLoader::fileToCampaign(const char *name) 162 170 { 163 171 /* do not entirely load the campaign. just the current world … … 168 176 if( name == NULL) 169 177 { 170 PRINTF 0("No filename specified for loading");178 PRINTF(2)("No filename specified for loading"); 171 179 return NULL; 172 180 } … … 177 185 { 178 186 // report an error 179 PRINTF 0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());187 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", name, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 180 188 delete XMLDoc; 181 189 return NULL; … … 189 197 { 190 198 // report an error 191 PRINTF( 0)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");199 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 192 200 delete XMLDoc; 193 201 return NULL; … … 211 219 bool GameLoader::worldCommand (Command* cmd) 212 220 { 213 if( !strcmp( cmd->cmd, "up_world"))221 if( !strcmp( cmd->cmd, CONFIG_NAME_NEXT_WORLD)) 214 222 { 215 223 if( !cmd->bUp) … … 219 227 return true; 220 228 } 221 else if( !strcmp( cmd->cmd, "down_world"))229 else if( !strcmp( cmd->cmd, CONFIG_NAME_PREV_WORLD)) 222 230 { 223 231 if( !cmd->bUp) … … 227 235 return true; 228 236 } 229 else if( !strcmp( cmd->cmd, "pause"))237 else if( !strcmp( cmd->cmd, CONFIG_NAME_PAUSE)) 230 238 { 231 239 if( !cmd->bUp) … … 238 246 return true; 239 247 } 240 else if( !strcmp( cmd->cmd, "quit"))248 else if( !strcmp( cmd->cmd, CONFIG_NAME_QUIT)) 241 249 { 242 250 if( !cmd->bUp) this->stop(); … … 276 284 assert( factory != NULL); 277 285 278 PRINTF 0("Registered factory for '%s'\n", factory->getClassname());286 PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName()); 279 287 280 288 if( first == NULL) first = factory; … … 288 296 BaseObject* GameLoader::fabricate( TiXmlElement* element) 289 297 { 290 assert( element != NULL); 291 292 if( first == NULL) 293 { 294 PRINTF0("GameLoader does not know any factories, fabricate() failed\n"); 295 return NULL; 296 } 297 298 if( element->Value() != NULL) 299 { 300 PRINTF0("Attempting fabrication of a '%s'\n", element->Value()); 301 BaseObject* b = first->fabricate( element); 302 if( b == NULL) PRINTF0("Failed to fabricate a '%s'\n", element->Value()); 303 else PRINTF0("Successfully fabricated a '%s'\n", element->Value()); 304 return b; 305 } 306 307 PRINTF0("Fabricate failed, TiXmlElement did not contain a value\n"); 308 309 return NULL; 310 } 298 assert( element != NULL); 299 300 if( first == NULL) 301 { 302 PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n"); 303 return NULL; 304 } 305 306 if( element->Value() != NULL) 307 { 308 PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value()); 309 BaseObject* b = first->fabricate( element); 310 if( b == NULL) 311 PRINTF(2)("Failed to fabricate a '%s'\n", element->Value()); 312 else 313 PRINTF(4)("Successfully fabricated a '%s'\n", element->Value()); 314 return b; 315 } 316 317 PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n"); 318 319 return NULL; 320 }
Note: See TracChangeset
for help on using the changeset viewer.