Changeset 3503 in orxonox.OLD for orxonox/branches
- Timestamp:
- Mar 11, 2005, 6:44:55 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/game_loader.cc
r3501 r3503 25 25 #include "command_node.h" 26 26 #include "vector.h" 27 #include "factory.h" 27 28 28 29 #include <string.h> … … 162 163 { 163 164 PRINTF(ERR)("No filename specified for loading"); 165 return NULL; 164 166 } 165 167 -
orxonox/branches/levelloader/src/game_loader.h
r3501 r3503 35 35 36 36 void registerFactory( Factory* factory); 37 StoryEntity* fabricate( TiXMLElement* data);37 BaseObject* fabricate( TiXMLElement* data); 38 38 39 39 private: -
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3501 r3503 21 21 #include "camera.h" 22 22 #include "story_entity.h" 23 #include "factory.h" 23 24 24 25 using namespace std; … … 36 37 { 37 38 TiXMLElement* element; 39 char string; 40 int id; 38 41 39 42 assert( root != NULL); … … 44 47 45 48 // grab all the necessary parameters 46 49 string = grabParameter( root, "identifier"); 50 if( string == NULL || if( sscanf(string, "%d", &id) != 1)) 51 { 52 PRINTF(ERR)("Campaign is missing a proper 'identifier'\n"); 53 setStoryId( -1); 54 } 55 else setStoryId( id); 56 47 57 // find WorldList 48 58 element = root->FirstChildElement( "WorldList"); 49 59 50 // load Worlds 60 // load Worlds/Subcampaigns/Whatever 51 61 while( element != NULL) 52 62 { 53 StoryEntity created =loader->fabricate( element);63 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 54 64 if( created != NULL) addEntity( created); 55 65 element = element->nextSiblingElement(); -
orxonox/branches/levelloader/src/story_entities/world.cc
r3501 r3503 29 29 #include "light.h" 30 30 #include "fontset.h" 31 #include "factory.h" 31 32 32 33 using namespace std; … … 35 36 World::World( TiXMLElement* root) 36 37 { 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 38 char *string, *name; 39 int id; 40 41 // identifier 42 string = grabParameter( root, "identifier"); 43 if( string == NULL || if( sscanf(string, "%d", &id) != 1)) 44 { 45 PRINTF(ERR)("World is missing a proper 'identifier'\n"); 46 setStoryId( -1); 47 } 48 else setStoryId( id); 49 50 // path 51 string = grabParameter( root, "path"); 52 if( string == NULL) 53 { 54 PRINTF(ERR)("World is missing a proper 'path'\n"); 55 setPath( NULL); 56 } 57 else 58 { 59 name = new char[strlen(string + 2)]; 60 strcpy( name, string); 61 setPath( name); 62 } 63 64 47 65 } 48 66 … … 115 133 ErrorMessage World::load() 116 134 { 135 if( 0) // temporary until we really load from files 136 { 137 GameLoader* loader = GameLoader::getInstance(); 138 139 if( getPath() == NULL) 140 { 141 PRINTF(ERR)("World has no path specified for loading"); 142 return (ErrorMessage){213,"Path not specified","World::load()"}; 143 } 144 145 TiXMLDocument* XMLDoc = new TiXMLDocument( name); 146 // load the campaign document 147 if( !XMLDoc.LoadFile()) 148 { 149 // report an error 150 PRINTF(ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol()); 151 delete XMLDoc; 152 return (ErrorMessage){213,"XML File parsing error","World::load()"}; 153 } 154 155 // check basic validity 156 TiXMLElement* element = XMLDoc.RootElement(); 157 assert( element != NULL); 158 159 element = element->FirstChildElement( "WorldDataFile"); 160 161 if( element == NULL ) 162 { 163 // report an error 164 PRINTF(ERR)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 165 delete XMLDoc; 166 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; 167 } 168 169 // load the parameters 170 // name 171 char* temp; 172 char* string = grabParameter( root, "name"); 173 if( string == NULL) 174 { 175 PRINTF(ERR)("World is missing a proper 'name'\n"); 176 setStoryId( -1); 177 } 178 else 179 { 180 temp = new char[strlen(string + 2)]; 181 worldName = temp; 182 } 183 184 185 // find WorldEntities 186 element = root->FirstChildElement( "WorldEntities"); 187 188 // load Players/Objects/Whatever 189 while( element != NULL) 190 { 191 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 192 if( created != NULL) spawn( created); 193 element = element->nextSiblingElement(); 194 } 195 196 // find Track 197 // TODO: load the track somehow 198 199 // free the XML data 200 delete XMLDoc; 201 } 202 117 203 // BezierCurve* tmpCurve = new BezierCurve(); 118 204 if(this->debugWorldNr != -1) … … 916 1002 } 917 1003 1004 void World::setPath( char* name) 1005 { 1006 path = name; 1007 } 1008 1009 char* World::getPath() 1010 { 1011 return path; 1012 } -
orxonox/branches/levelloader/src/story_entities/world.h
r3501 r3503 52 52 void spawn (WorldEntity* entity); 53 53 void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); 54 54 55 void setPath( char* name); 56 char* getPath(); 55 57 56 58 … … 65 67 66 68 char* worldName; //!< The name of this World 69 char* path; //!< The path to the data file used by this World 67 70 int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong 68 71
Note: See TracChangeset
for help on using the changeset viewer.