Changeset 3501 in orxonox.OLD for orxonox/branches/levelloader/src/game_loader.cc
- Timestamp:
- Mar 11, 2005, 5:28:38 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/game_loader.cc
r3499 r3501 35 35 36 36 37 GameLoader::GameLoader () {} 37 GameLoader::GameLoader () 38 { 39 first = NULL; 40 } 38 41 39 42 … … 155 158 can load everything it needs into memory then. 156 159 */ 160 161 if( name == NULL) 162 { 163 PRINTF(ERR)("No filename specified for loading"); 164 } 165 166 TiXMLDocument* XMLDoc = new TiXMLDocument( name); 167 // load the campaign document 168 if( !XMLDoc.LoadFile()) 169 { 170 // report an error 171 PRINTF(ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol()); 172 delete XMLDoc; 173 return NULL; 174 } 175 176 // check basic validity 177 TiXMLElement* element = XMLDoc.RootElement(); 178 assert( element != NULL); 179 180 element = element->FirstChildElement( "Campaign"); 181 182 if( element == NULL ) 183 { 184 // report an error 185 PRINTF(ERR)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n"); 186 delete XMLDoc; 187 return NULL; 188 } 189 190 // construct campaign 191 Campaign c = new Campaign( element); 192 193 // free the XML data 194 delete XMLDoc; 157 195 } 158 196 … … 221 259 this->currentCampaign->previousLevel(); 222 260 } 261 262 263 /** 264 \brief add a Factory to the Factory Q 265 \param factory a Factory to be registered 266 */ 267 void GameLoader::registerFactory( Factory* factory) 268 { 269 if( next == NULL) next = factory; 270 else next->registerFactory( factory); 271 } 272 273 /** 274 \brief load a StoryEntity 275 \param element a XMLElement containing all the needed info 276 */ 277 StoryEntity* GameLoader::fabricate( TiXMLElement* element) 278 { 279 if( first == NULL) 280 { 281 PRINTF(ERR)("GameLoader does not know any factories, fabricate() failed\n"); 282 return NULL; 283 } 284 285 return first->fabricate( element); 286 }
Note: See TracChangeset
for help on using the changeset viewer.