Changeset 6374 in orxonox.OLD for branches/network/src/story_entities/campaign.cc
- Timestamp:
- Dec 31, 2005, 3:53:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/story_entities/campaign.cc
r6372 r6374 25 25 26 26 27 Campaign::Campaign () 27 /** 28 * the constructor 29 * @param root the XML root element 30 * 31 * this constructor is always called in a XML context (loading procedure) 32 */ 33 Campaign::Campaign ( TiXmlElement* root) 28 34 { 29 35 this->setClassID(CL_CAMPAIGN, "Campaign"); 30 36 this->isInit = false; 31 }32 33 Campaign::Campaign ( TiXmlElement* root)34 {35 this->setClassID(CL_CAMPAIGN, "Campaign");36 37 37 38 PRINTF(4)("Loading Campaign...\n"); 38 39 39 assert( root != NULL); 40 40 41 this->isInit = false;42 43 41 this->loadParams(root); 44 45 46 //if( lastCreated != NULL) 47 //lastCreated->setStoryID( WORLD_ID_GAMEEND); 48 } 49 42 } 43 44 45 /** 46 * the campaign destructor 47 */ 50 48 Campaign::~Campaign () 51 49 {} … … 70 68 71 69 LoadParam(root, "identifier", this, Campaign, setStoryID) 72 73 74 75 70 .describe("A Unique Identifier for this Campaign"); 71 72 LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams) 73 .describe("A List of Worlds to be loaded in this Campaign"); 76 74 } 77 75 … … 83 81 void Campaign::loadWorldListParams(const TiXmlElement* root) 84 82 { 85 if (root == NULL)83 if( root == NULL) 86 84 return; 87 85 88 86 LOAD_PARAM_START_CYCLE(root, element); 89 87 { 90 PRINTF(5)("Campaign: Constructor: adding a world\n");91 88 StoryEntity* created = (StoryEntity*) Factory::fabricate(element); 92 89 if( created != NULL) 93 {94 90 this->addEntity( created); 95 } 91 PRINTF(3)("Campaign: Constructor: adding a world with name \"%s\" and id %i\n", 92 created->getName(), created->getStoryID()); 96 93 } 97 94 LOAD_PARAM_END_CYCLE(element); 98 } 95 96 } 97 99 98 100 99 /** … … 120 119 this->currentEntity = se; 121 120 while( se != NULL && this->running) 121 { 122 PRINTF(0)("Campaign is starting StoryEntity nr:%i\n", se->getStoryID()); 123 124 se->init(); 125 se->loadData(); 126 127 se->preStart(); 128 se->start(); 129 130 131 int nextWorldID = se->getNextStoryID(); 132 133 this->entities.remove(se); 134 delete se; 135 136 se = this->getStoryEntity(nextWorldID); 137 this->currentEntity = se; 138 if( ( nextWorldID == WORLD_ID_GAMEEND) || ( se == NULL) ) 122 139 { 123 PRINTF(0)("Starting new StoryEntity Nr:%i\n", se->getStoryID()); 124 125 se->init(); 126 127 //se->preLoad(); 128 se->loadData(); 129 //se->postLoad(); 130 131 132 se->preStart(); 133 se->start(); 134 135 int nextWorldID = se->getNextStoryID(); 136 137 this->entities.remove(se); 138 delete se; 139 140 //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID); 141 se = this->getStoryEntity(nextWorldID); 142 this->currentEntity = se; 143 if( ( nextWorldID == WORLD_ID_GAMEEND) || ( se == NULL) ) 144 { 145 PRINTF(4)("Quitting campaing story loop\n"); 146 if(se != NULL) 147 delete se; 148 return errorCode; 149 } 140 PRINTF(4)("Quitting campaing story loop\n"); 141 if(se != NULL) 142 delete se; 143 return errorCode; 150 144 } 151 152 /* clean up all world that have not been loaded and therefore are still in the world list - 153 this probably does not belong into the start function. remove this later 154 */ 155 list<StoryEntity*>::iterator it; 156 for(it = this->entities.begin(); it != entities.end(); it++) 157 { 158 delete (*it); 159 } 160 PRINTF(1)("There is no StoryEnity left to play, quitting\n"); 145 } 146 147 /* clean up all world that have not been loaded and therefore are still in the world list - 148 this probably does not belong into the start function. remove this later 149 */ 150 list<StoryEntity*>::iterator it; 151 for(it = this->entities.begin(); it != entities.end(); it++) 152 { 153 delete (*it); 154 } 155 156 PRINTF(2)("There is no StoryEnity left to play, quitting\n"); 161 157 } 162 158 … … 183 179 this->running = false; 184 180 if(this->currentEntity != NULL) 185 186 187 181 { 182 this->currentEntity->stop(); 183 } 188 184 } 189 185 … … 259 255 StoryEntity* Campaign::getStoryEntity(int storyID) 260 256 { 261 //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID);262 257 if( storyID == WORLD_ID_GAMEEND) 263 258 return NULL; 264 259 265 /* 266 tList<StoryEntity>* l; 267 StoryEntity* entity = NULL; 268 l = this->entities->getNext(); 269 while( l != NULL) 270 { 271 entity = l->getObject(); 272 l = l->getNext(); 273 274 int id = entity->getStoryID(); 275 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 276 if(id == storyID) 277 { 278 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 279 return entity; 280 } 281 282 } 283 */ 284 285 260 int id; 286 261 list<StoryEntity*>::iterator it; 287 for (it = this->entities.begin(); it != this->entities.end(); it++) 288 { 289 int id = (*it)->getStoryID(); 290 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 291 if(id == storyID) 292 { 293 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 294 return (*it); 295 } 296 } 297 298 262 for( it = this->entities.begin(); it != this->entities.end(); it++) 263 { 264 id = (*it)->getStoryID(); 265 if( id == storyID) 266 return (*it); 267 } 299 268 300 269 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.