Changeset 6374 in orxonox.OLD for branches/network/src/story_entities
- Timestamp:
- Dec 31, 2005, 3:53:45 PM (19 years ago)
- Location:
- branches/network/src/story_entities
- Files:
-
- 6 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; -
branches/network/src/story_entities/campaign.h
r6372 r6374 14 14 15 15 public: 16 Campaign (); 17 Campaign ( TiXmlElement* root); 16 Campaign( TiXmlElement* root); 18 17 virtual ~Campaign (); 19 18 … … 48 47 }; 49 48 49 50 51 class CampaignData : virtual public BaseObject 52 { 53 54 public: 55 CampaignData(); 56 virtual ~CampaignData(); 57 58 void addStoryEntity(StoryEntity* se, int storyID = -1); 59 60 void getNextLevel(); 61 }; 62 50 63 #endif /* _CAMPAIGN_H */ -
branches/network/src/story_entities/game_world.cc
r6372 r6374 82 82 83 83 GameWorld::GameWorld(const TiXmlElement* root) 84 : StoryEntity() 84 85 { 85 86 this->setClassID(CL_GAME_WORLD, "GameWorld"); … … 97 98 98 99 this->path = NULL; 99 100 this->loadParams(root);101 100 } 102 101 -
branches/network/src/story_entities/single_player_world.cc
r6365 r6374 38 38 : GameWorld(root) 39 39 { 40 this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld"); 41 this->setName("SinglePlayerWorld uninitialized"); 42 40 43 this->loadParams(root); 41 44 } … … 51 54 { 52 55 PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n"); 53 }54 55 56 /**57 * initializes the world.58 * @param name the name of the world59 * @param worldID the ID of this world60 *61 * set all stuff here that is world generic and does not use to much memory62 * because the real init() function StoryEntity::init() will be called63 * shortly before start of the game.64 * since all worlds are initiated/referenced before they will be started.65 * NO LEVEL LOADING HERE - NEVER!66 */67 void SinglePlayerWorld::constuctorInit(const char* name, int worldID)68 {69 this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld");70 this->setName(name);71 72 this->gameTime = 0.0f;73 this->setSpeed(1.0);74 this->music = NULL;75 this->shell = NULL;76 this->localPlayer = NULL;77 this->localCamera = NULL;78 79 this->showPNodes = false;80 this->showBV = false;81 56 } 82 57 -
branches/network/src/story_entities/single_player_world.h
r6365 r6374 28 28 29 29 private: 30 void constuctorInit(const char* name, int worldID); 30 31 31 }; 32 32 -
branches/network/src/story_entities/story_entity.h
r6372 r6374 18 18 StoryEntity (); 19 19 virtual ~StoryEntity (); 20 21 void loadParams(const TiXmlElement* root); 20 22 21 23 /* initialisation and loading */ … … 47 49 inline void setStoryID(int storyID) { this->storyID = storyID; } 48 50 /** sets the story id of the current entity, this enables it to be identified in a global context. @returns the story id */ 49 inline int getStoryID() { this->storyID =storyID; }51 inline int getStoryID() { return this->storyID; } 50 52 /** sets the id of the next story entity: StoryEntities can choose their following entity themselfs. 51 53 * the entity id defined here will be startet after this entity ends. this can be convenient if you
Note: See TracChangeset
for help on using the changeset viewer.