Changeset 3530 in orxonox.OLD for orxonox/branches/levelloader/src/story_entities
- Timestamp:
- Mar 13, 2005, 10:40:25 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/story_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/story_entities/campaign.cc
r3525 r3530 22 22 #include "story_entity.h" 23 23 #include "factory.h" 24 #include "game_loader.h" 24 25 25 26 using namespace std; 26 27 28 CREATE_FACTORY(Campaign); 27 29 28 30 Campaign::Campaign () … … 37 39 { 38 40 TiXmlElement* element; 39 c harstring;41 const char* string; 40 42 int id; 41 43 … … 48 50 // grab all the necessary parameters 49 51 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);52 if( string == NULL || sscanf(string, "%d", &id) != 1) 53 { 54 PRINTF(1)("Campaign is missing a proper 'identifier'\n"); 55 this->setStoryID( -1); 56 } 57 else this->setStoryID( id); 56 58 57 59 // find WorldList … … 63 65 StoryEntity* created = (StoryEntity*) loader->fabricate( element); 64 66 if( created != NULL) addEntity( created); 65 element = element-> nextSiblingElement();67 element = element->NextSiblingElement(); 66 68 } 67 69 } -
orxonox/branches/levelloader/src/story_entities/campaign.h
r3525 r3530 41 41 }; 42 42 43 CREATE_FACTORY(Campaign);44 45 43 #endif /* _CAMPAIGN_H */ -
orxonox/branches/levelloader/src/story_entities/world.cc
r3525 r3530 30 30 #include "fontset.h" 31 31 #include "factory.h" 32 #include "game_loader.h" 32 33 33 34 using namespace std; 34 35 36 CREATE_FACTORY(World); 35 37 36 38 World::World( TiXmlElement* root) 37 39 { 38 char *string, *name; 40 const char *string; 41 char *name; 39 42 int id; 40 43 41 44 // identifier 42 45 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 setStoryI d( id);46 if( string == NULL || sscanf(string, "%d", &id) != 1) 47 { 48 PRINTF(1)("World is missing a proper 'identifier'\n"); 49 this->setStoryID( -1); 50 } 51 else setStoryID( id); 49 52 50 53 // path … … 52 55 if( string == NULL) 53 56 { 54 PRINTF( ERR)("World is missing a proper 'path'\n");55 setPath( NULL);57 PRINTF(1)("World is missing a proper 'path'\n"); 58 this->setPath( NULL); 56 59 } 57 60 else … … 59 62 name = new char[strlen(string + 2)]; 60 63 strcpy( name, string); 61 setPath( name);64 this->setPath( name); 62 65 } 63 66 … … 105 108 this->nullParent->destroy(); 106 109 delete this->skySphere; 110 if( this->worldName) delete this->worldName; 111 if( this->path) delete this->path; 107 112 108 113 //delete this->trackManager; … … 137 142 if( getPath() == NULL) 138 143 { 139 PRINTF( ERR)("World has no path specified for loading");144 PRINTF(1)("World has no path specified for loading"); 140 145 return (ErrorMessage){213,"Path not specified","World::load()"}; 141 146 } 142 147 143 TiXmlDocument* XMLDoc = new TiXmlDocument( name);148 TiXmlDocument* XMLDoc = new TiXmlDocument( path); 144 149 // load the campaign document 145 if( !XMLDoc .LoadFile())150 if( !XMLDoc->LoadFile()) 146 151 { 147 152 // report an error 148 PRINTF( ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());153 PRINTF(1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 149 154 delete XMLDoc; 150 155 return (ErrorMessage){213,"XML File parsing error","World::load()"}; … … 152 157 153 158 // check basic validity 154 TiXmlElement* root = XMLDoc .RootElement();159 TiXmlElement* root = XMLDoc->RootElement(); 155 160 assert( root != NULL); 156 161 157 element = root->FirstChildElement( "WorldDataFile");162 TiXmlElement* element = root->FirstChildElement( "WorldDataFile"); 158 163 159 164 if( root == NULL ) 160 165 { 161 166 // report an error 162 PRINTF( ERR)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");167 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 163 168 delete XMLDoc; 164 169 return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"}; … … 167 172 // load the parameters 168 173 // name 169 TiXmlElement* element;170 174 char* temp; 171 c har* string = grabParameter( root, "name");175 const char* string = grabParameter( root, "name"); 172 176 if( string == NULL) 173 177 { 174 PRINTF( ERR)("World is missing a proper 'name'\n");175 setStoryId( -1);178 PRINTF(1)("World is missing a proper 'name'\n"); 179 this->setStoryID( -1); 176 180 } 177 181 else 178 182 { 179 183 temp = new char[strlen(string + 2)]; 180 worldName = temp;184 this->worldName = temp; 181 185 } 182 186 … … 187 191 if( element == NULL) 188 192 { 189 PRINTF( ERR)("World is missing 'WorldEntities'\n");193 PRINTF(1)("World is missing 'WorldEntities'\n"); 190 194 } 191 195 else … … 197 201 WorldEntity* created = (WorldEntity*) loader->fabricate( element); 198 202 if( created != NULL) spawn( created); 199 element = element-> nextSiblingElement();203 element = element->NextSiblingElement(); 200 204 } 201 205 } … … 205 209 if( element == NULL) 206 210 { 207 PRINTF( ERR)("World is missing a 'Track'\n");211 PRINTF(1)("World is missing a 'Track'\n"); 208 212 } 209 213 else … … 225 229 testFont->buildFont("../data/pictures/font.tga"); 226 230 227 // initializing the TrackManager228 trackManager = TrackManager::getInstance();229 trackManager->addPoint(Vector(0,-5,0));230 trackManager->addPoint(Vector(10,0,5));231 trackManager->addPoint(Vector(20,0,-5));232 trackManager->addPoint(Vector(30,0,5));233 trackManager->addPoint(Vector(40,0,5));234 trackManager->setDuration(2);235 trackManager->setSavePoint();236 trackManager->addPoint(Vector(50,10,10));237 trackManager->addPoint(Vector(60,0, 10));238 trackManager->addPoint(Vector(70,0, 10));239 trackManager->addPoint(Vector(80,0,-10));240 trackManager->addPoint(Vector(90,0,-10));241 trackManager->setDuration(5);242 trackManager->setSavePoint();243 trackManager->addPoint(Vector(110,0,5));244 trackManager->addPoint(Vector(120,0, 10));245 trackManager->addPoint(Vector(130,0, 10));246 trackManager->addPoint(Vector(140,0,-10));247 trackManager->addPoint(Vector(150,0,-10));248 trackManager->setDuration(3);249 int fork11, fork12, fork13, fork14;250 trackManager->fork(4, &fork11, &fork12, &fork13, &fork14);251 trackManager->workOn(fork11);252 trackManager->addPoint(Vector(170, 0, -15));253 trackManager->addPoint(Vector(180, 0, -15));254 trackManager->setDuration(3);255 trackManager->workOn(fork12);256 trackManager->addPoint(Vector(170, 0, 10));257 trackManager->addPoint(Vector(180, 0, 10));258 trackManager->addPoint(Vector(190,2,5));259 trackManager->addPoint(Vector(200,2,5));260 trackManager->setDuration(7);261 int fork21, fork22;262 trackManager->fork(2, &fork21, &fork22);263 trackManager->workOn(fork21);264 trackManager->addPoint(Vector(220, 10,-10));265 trackManager->addPoint(Vector(230, 0,-10));266 trackManager->addPoint(Vector(240, 0, 2));267 trackManager->addPoint(Vector(250, 0, 0));268 trackManager->addPoint(Vector(260, 0, 5));269 trackManager->setDuration(3);270 trackManager->join(2, fork12, fork11);271 trackManager->workOn(fork22);272 trackManager->addPoint(Vector(220, -10,10));273 trackManager->addPoint(Vector(230, 0, 10));274 trackManager->addPoint(Vector(240, 0, 10));275 trackManager->addPoint(Vector(250, 0, 5));276 trackManager->setDuration(6);277 trackManager->workOn(fork13);278 trackManager->addPoint(Vector(200,-10,5));279 trackManager->addPoint(Vector(250,-10,5));280 trackManager->setDuration(3);281 trackManager->workOn(fork14);282 trackManager->addPoint(Vector(200,15,0));283 trackManager->addPoint(Vector(210,0,10));284 trackManager->setDuration(1);285 trackManager->join(4, fork21, fork22, fork13, fork14);286 trackManager->workOn(10);287 trackManager->addPoint(Vector(250,-10,5));288 trackManager->addPoint(Vector(260,-10,5));289 trackManager->finalize();290 291 231 /*monitor progress*/ 292 232 this->glmis->step(); -
orxonox/branches/levelloader/src/story_entities/world.h
r3525 r3530 8 8 9 9 #include "stdincl.h" 10 10 11 #include "story_entity.h" 11 12 12 13 13 class TrackManager; … … 25 25 it is the main driving factor during gameplay. 26 26 */ 27 //#define SUBCLASS(x,y) class x : public y { 28 29 //SUBCLASS(World,StoryEntity) 27 30 class World : public StoryEntity { 28 31 29 32 public: 30 World (TiXmlElement* root) ,33 World (TiXmlElement* root); 31 34 World (char* name); 32 35 World (int worldID); … … 92 95 }; 93 96 94 CREATE_FACTORY(World);95 96 97 #endif /* _WORLD_H */
Note: See TracChangeset
for help on using the changeset viewer.