Changeset 4139 in orxonox.OLD for orxonox/branches/md2_loader/src/game_loader.cc
- Timestamp:
- May 10, 2005, 10:39:01 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/game_loader.cc
r4020 r4139 25 25 #include "command_node.h" 26 26 #include "vector.h" 27 #include "resource_manager.h" 27 28 #include "factory.h" 28 29 … … 76 77 { 77 78 ErrorMessage errorCode; 78 79 this->currentCampaign = this->fileToCampaign(name); 79 char* campaignName; 80 if (ResourceManager::isFile(name)) 81 { 82 this->currentCampaign = this->fileToCampaign(name); 83 } 84 else 85 { 86 campaignName = new char[strlen(ResourceManager::getInstance()->getDataDir())+strlen(name)]; 87 sprintf(campaignName, "%s%s", ResourceManager::getInstance()->getDataDir(), name); 88 this->currentCampaign = this->fileToCampaign(campaignName); 89 delete campaignName; 90 } 80 91 } 81 92 … … 162 173 this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns 163 174 */ 164 Campaign* GameLoader::fileToCampaign(c har *name)175 Campaign* GameLoader::fileToCampaign(const char *name) 165 176 { 166 177 /* do not entirely load the campaign. just the current world … … 171 182 if( name == NULL) 172 183 { 173 PRINTF 0("No filename specified for loading");184 PRINTF(2)("No filename specified for loading"); 174 185 return NULL; 175 186 } … … 180 191 { 181 192 // report an error 182 PRINTF 0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());193 PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", name, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 183 194 delete XMLDoc; 184 195 return NULL; … … 192 203 { 193 204 // report an error 194 PRINTF( 0)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");205 PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 195 206 delete XMLDoc; 196 207 return NULL; … … 214 225 bool GameLoader::worldCommand (Command* cmd) 215 226 { 216 if( !strcmp( cmd->cmd, "up_world"))227 if( !strcmp( cmd->cmd, CONFIG_NAME_NEXT_WORLD)) 217 228 { 218 229 if( !cmd->bUp) … … 222 233 return true; 223 234 } 224 else if( !strcmp( cmd->cmd, "down_world"))235 else if( !strcmp( cmd->cmd, CONFIG_NAME_PREV_WORLD)) 225 236 { 226 237 if( !cmd->bUp) … … 230 241 return true; 231 242 } 232 else if( !strcmp( cmd->cmd, "pause"))243 else if( !strcmp( cmd->cmd, CONFIG_NAME_PAUSE)) 233 244 { 234 245 if( !cmd->bUp) … … 241 252 return true; 242 253 } 243 else if( !strcmp( cmd->cmd, "quit"))254 else if( !strcmp( cmd->cmd, CONFIG_NAME_QUIT)) 244 255 { 245 256 if( !cmd->bUp) this->stop(); … … 279 290 assert( factory != NULL); 280 291 281 PRINTF 0("Registered factory for '%s'\n", factory->getFactoryName());292 PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName()); 282 293 283 294 if( first == NULL) first = factory; … … 291 302 BaseObject* GameLoader::fabricate( TiXmlElement* element) 292 303 { 293 assert( element != NULL); 294 295 if( first == NULL) 296 { 297 PRINTF0("GameLoader does not know any factories, fabricate() failed\n"); 298 return NULL; 299 } 300 301 if( element->Value() != NULL) 302 { 303 PRINTF0("Attempting fabrication of a '%s'\n", element->Value()); 304 BaseObject* b = first->fabricate( element); 305 if( b == NULL) PRINTF0("Failed to fabricate a '%s'\n", element->Value()); 306 else PRINTF0("Successfully fabricated a '%s'\n", element->Value()); 307 return b; 308 } 309 310 PRINTF0("Fabricate failed, TiXmlElement did not contain a value\n"); 311 312 return NULL; 313 } 304 assert( element != NULL); 305 306 if( first == NULL) 307 { 308 PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n"); 309 return NULL; 310 } 311 312 if( element->Value() != NULL) 313 { 314 PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value()); 315 BaseObject* b = first->fabricate( element); 316 if( b == NULL) 317 PRINTF(2)("Failed to fabricate a '%s'\n", element->Value()); 318 else 319 PRINTF(4)("Successfully fabricated a '%s'\n", element->Value()); 320 return b; 321 } 322 323 PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n"); 324 325 return NULL; 326 }
Note: See TracChangeset
for help on using the changeset viewer.