Changeset 3501 in orxonox.OLD for orxonox/branches/levelloader
- Timestamp:
- Mar 11, 2005, 5:28:38 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src
- Files:
-
- 7 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 } -
orxonox/branches/levelloader/src/game_loader.h
r3225 r3501 34 34 ErrorMessage loadDebugCampaign(Uint32 campaignID); 35 35 36 void registerFactory( Factory* factory); 37 StoryEntity* fabricate( TiXMLElement* data); 38 36 39 private: 37 40 GameLoader (); … … 45 48 Campaign* fileToCampaign(char* name); 46 49 50 Factory* first; 47 51 }; 48 52 -
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3499 r3501 33 33 Campaign::~Campaign () {} 34 34 35 Campaign::Campaign ( TiXMLElement* root) 36 { 37 TiXMLElement* element; 38 39 assert( root != NULL); 40 GameLoader* loader = GameLoader::getInstance(); 41 42 this->entities = new ListTemplate<StoryEntity>(); 43 this->isInit = false; 44 45 // grab all the necessary parameters 46 47 // find WorldList 48 element = root->FirstChildElement( "WorldList"); 49 50 // load Worlds 51 while( element != NULL) 52 { 53 StoryEntity created = loader->fabricate( element); 54 if( created != NULL) addEntity( created); 55 element = element->nextSiblingElement(); 56 } 57 } 35 58 36 59 ErrorMessage Campaign::init() -
orxonox/branches/levelloader/src/story_entities/campaign.h
r3499 r3501 1 1 2 #ifndef _CAMPAIGN_H 2 #ifndef _CAMPAIGN_HCREATE_FACTORY 3 3 #define _CAMPAIGN_H 4 4 … … 13 13 public: 14 14 Campaign (); 15 Campaign ( TiXMLElement* root); 15 16 ~Campaign (); 16 17 … … 40 41 }; 41 42 43 CREATE_FACTORY(Campaign); 44 42 45 #endif /* _CAMPAIGN_H */ -
orxonox/branches/levelloader/src/story_entities/story_entity.h
r3499 r3501 16 16 public: 17 17 StoryEntity (); 18 StoryEntity ( TiXMLElement* root) {}; 18 19 virtual ~StoryEntity (); 19 20 -
orxonox/branches/levelloader/src/story_entities/world.cc
r3499 r3501 32 32 using namespace std; 33 33 34 35 World::World( TiXMLElement* root) 36 { 37 TiXMLElement* element; 38 // load parameters 39 // identifier 40 element = FirstChildrenElement("identifier"); 41 if( element == NULL) 42 { 43 PRINTF(ERR)("World created with missing identifier\n"); 44 setStoryID( -1); 45 } 46 // file 47 } 34 48 35 49 /** -
orxonox/branches/levelloader/src/story_entities/world.h
r3499 r3501 28 28 29 29 public: 30 World (TiXMLElement* root), 30 31 World (char* name); 31 32 World (int worldID); … … 88 89 }; 89 90 91 CREATE_FACTORY(World); 92 90 93 #endif /* _WORLD_H */
Note: See TracChangeset
for help on using the changeset viewer.