Changeset 3220 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 19, 2004, 9:09:36 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/campaign.cc
r3209 r3220 48 48 want to queue up in the campaign. 49 49 */ 50 void Campaign::addEntity(StoryEntity* se, Uint32storyID)50 void Campaign::addEntity(StoryEntity* se, int storyID) 51 51 { 52 52 se->setStoryID(storyID); … … 60 60 61 61 62 void Campaign::removeEntity( Uint32storyID)62 void Campaign::removeEntity(int storyID) 63 63 { 64 64 this->removeEntity(this->getStoryEntity(storyID)); … … 78 78 } 79 79 80 Error Campaign::start( Uint32storyID = 0)80 Error Campaign::start(int storyID = 0) 81 81 { 82 82 printf("World::start() - starting new StoryEntity Nr:%i\n", storyID); … … 86 86 this->running = true; 87 87 StoryEntity* se = this->getStoryEntity(storyID); 88 this->currentEntity = se; 88 89 while(se != NULL && this->running) 89 90 { 90 se = this->getStoryEntity(storyID); 91 this->currentEntity = se; 91 //se = this->getStoryEntity(storyID); 92 92 93 se->displayEntityScreen(); 93 94 se->displayLoadScreen(); 94 95 se->load(); 95 96 se->init(); 96 se->release EntityScreen();97 se->releaseLoadScreen(); 97 98 se->start(); 98 99 100 delete se; 101 99 102 int nextWorldID = se->getNextStoryID(); 100 if(nextWorldID == WORLD_ID_GAMEEND) return errorCode;103 //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID); 101 104 se = this->getStoryEntity(nextWorldID); 102 if(se == NULL) 103 printf("Campaign::start() - ERROR: world not found, oh oh...\n"); 105 this->currentEntity = se; 106 if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 107 { 108 printf("Campaign::start() - quiting campaing story loop\n"); 109 if(se != NULL) 110 delete se; 111 return errorCode; 112 } 113 104 114 } 105 115 } … … 111 121 { 112 122 this->currentEntity->stop(); 113 delete this->currentEntity;114 this->currentEntity = NULL;123 //delete this->currentEntity; 124 //this->currentEntity = NULL; 115 125 } 116 126 } … … 130 140 131 141 142 void Campaign::destroy() 143 { 144 if(this->currentEntity != NULL) 145 { 146 this->currentEntity->destroy(); 147 delete this->currentEntity; 148 this->currentEntity = NULL; 149 } 150 } 151 132 152 void Campaign::nextLevel() 133 153 { 134 printf("Campaign|nextLevel\n"); 135 int nextID = this->currentEntity->getNextStoryID(); 136 this->stop(); 137 this->start(nextID); 154 printf("Campaign:nextLevel()\n"); 155 //int nextID = this->currentEntity->getNextStoryID(); 156 //this->stop(); 157 //this->start(nextID); 158 this->currentEntity->stop(); 138 159 } 139 160 … … 142 163 143 164 144 StoryEntity* Campaign::getStoryEntity( Uint32storyID)165 StoryEntity* Campaign::getStoryEntity(int storyID) 145 166 { 167 //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID); 168 if( storyID == WORLD_ID_GAMEEND) 169 return NULL; 146 170 ListTemplate<StoryEntity>* l; 147 StoryEntity* entity ;171 StoryEntity* entity = NULL; 148 172 l = this->entities->get_next(); 149 173 while( l != NULL) … … 151 175 entity = l->get_object(); 152 176 l = l->get_next(); 153 if(entity->getStoryID() == storyID) 154 return entity; 177 int id = entity->getStoryID(); 178 //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id); 179 if(id == storyID) 180 { 181 //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n"); 182 return entity; 183 } 155 184 } 156 185 return NULL; -
orxonox/trunk/src/campaign.h
r2816 r3220 19 19 virtual Error init(); 20 20 virtual Error start(); 21 virtual Error start( Uint32storyID);21 virtual Error start(int storyID); 22 22 virtual Error stop(); 23 23 virtual Error pause(); 24 24 virtual Error resume(); 25 25 26 void addEntity(StoryEntity* se, Uint32 storyID); 26 virtual void destroy(); 27 28 void addEntity(StoryEntity* se, int storyID); 27 29 void addEntity(StoryEntity* se); 28 void removeEntity( Uint32storyID);30 void removeEntity(int storyID); 29 31 void removeEntity(StoryEntity* se); 30 32 … … 36 38 bool running; 37 39 38 StoryEntity* getStoryEntity( Uint32storyID);40 StoryEntity* getStoryEntity(int storyID); 39 41 }; 40 42 -
orxonox/trunk/src/game_loader.cc
r3215 r3220 72 72 { 73 73 Campaign* debugCampaign = new Campaign(); 74 74 75 World* world0 = new World(DEBUG_WORLD_0); 75 world0->setNextStoryID( DEBUG_WORLD_1);76 world0->setNextStoryID(WORLD_ID_1); 76 77 debugCampaign->addEntity(world0, WORLD_ID_0); 78 77 79 World* world1 = new World(DEBUG_WORLD_1); 78 80 world1->setNextStoryID(WORLD_ID_GAMEEND); … … 162 164 return true; 163 165 } 166 else if( !strcmp( cmd->cmd, "quit")) 167 { 168 if( !cmd->bUp) this->stop(); 169 return true; 170 } 164 171 return false; 165 172 } -
orxonox/trunk/src/orxonox.cc
r3216 r3220 269 269 bool Orxonox::system_command (Command* cmd) 270 270 { 271 271 /* 272 272 if( !strcmp( cmd->cmd, "quit")) 273 273 { … … 276 276 } 277 277 return false; 278 278 */ 279 return false; 279 280 } 280 281 -
orxonox/trunk/src/story_def.h
r2636 r3220 4 4 5 5 6 #define DEBUG_CAMPAIGN_0 07 #define DEBUG_CAMPAIGN_1 1 8 #define DEBUG_CAMPAIGN_2 26 #define DEBUG_CAMPAIGN_0 1000 7 #define DEBUG_CAMPAIGN_1 1001 8 #define DEBUG_CAMPAIGN_2 1002 9 9 10 #define DEBUG_WORLD_0 011 #define DEBUG_WORLD_1 1 12 #define DEBUG_WORLD_2 210 #define DEBUG_WORLD_0 100 11 #define DEBUG_WORLD_1 101 12 #define DEBUG_WORLD_2 102 13 13 14 14 #define WORLD_ID_0 0 … … 20 20 #define WORLD_ID_GAMEEND 999 21 21 22 #define MAX_STORY_ENTITIES 99 ;//!> maximal StoryEntities in a Campaign22 #define MAX_STORY_ENTITIES 99 //!> maximal StoryEntities in a Campaign 23 23 24 24 #endif -
orxonox/trunk/src/story_entity.cc
r2636 r3220 39 39 40 40 41 void StoryEntity::setStoryID( Uint32storyID)41 void StoryEntity::setStoryID(int storyID) 42 42 { 43 43 this->storyID = storyID; … … 50 50 51 51 52 void StoryEntity::setNextStoryID( Uint32nextStoryID)52 void StoryEntity::setNextStoryID(int nextStoryID) 53 53 { 54 54 this->nextStoryID = nextStoryID; 55 55 } 56 56 57 Uint32StoryEntity::getNextStoryID()57 int StoryEntity::getNextStoryID() 58 58 { 59 59 return this->nextStoryID; … … 61 61 62 62 63 Error StoryEntity::start( Uint32storyID)63 Error StoryEntity::start(int storyID) 64 64 {} 65 65 … … 80 80 {} 81 81 82 83 void StoryEntity::displayEntityScreen() 82 void StoryEntity::destroy() 84 83 {} 85 84 86 void StoryEntity::releaseEntityScreen() 85 86 void StoryEntity::displayLoadScreen() 87 87 {} 88 89 void StoryEntity::releaseLoadScreen() 90 {} -
orxonox/trunk/src/story_entity.h
r2636 r3220 16 16 17 17 virtual Error init(); 18 virtual Error start( Uint32storyID);18 virtual Error start(int storyID); 19 19 virtual Error start(); 20 20 virtual Error stop(); … … 23 23 24 24 virtual void load(); 25 virtual void destroy(); 25 26 26 virtual void display EntityScreen();27 virtual void release EntityScreen();27 virtual void displayLoadScreen(); 28 virtual void releaseLoadScreen(); 28 29 29 void setStoryID( Uint32storyID);30 void setStoryID(int storyID); 30 31 int getStoryID(); 31 32 32 void setNextStoryID( Uint32nextStoryID);33 Uint32getNextStoryID();33 void setNextStoryID(int nextStoryID); 34 int getNextStoryID(); 34 35 35 36 36 37 private: 37 Uint32storyID;38 Uint32nextStoryID;38 int storyID; 39 int nextStoryID; 39 40 }; 40 41 -
orxonox/trunk/src/world.cc
r3216 r3220 51 51 World::~World () 52 52 { 53 Orxonox *orx = Orxonox::getInstance(); 54 orx->get_localinput()->unbind (this->localPlayer); 55 delete this->entities; 56 delete this->localCamera; 57 } 58 59 60 /** 61 \brief initialize the world before use. 62 */ 63 Error World::init() 64 { 65 this->bPause = false; 53 printf("World::~World() - deleting current world\n"); 66 54 CommandNode* cn = Orxonox::getInstance()->get_localinput(); 67 cn->addToWorld(this); 68 cn->enable(true); 69 } 70 71 Error World::start() 72 { 73 this->mainLoop(); 74 } 75 76 Error World::stop() 77 { 78 this->bQuitCurrentGame = true; 79 //this->localCamera->setWorld(NULL); 80 this->localPlayer->destroy(); 55 cn->unbind(this->localPlayer); 56 cn->reset(); 81 57 this->localCamera->destroy(); 82 58 … … 88 64 } 89 65 this->entities->destroy(); 90 Orxonox::getInstance()->get_localinput()->reset(); 66 67 delete this->entities; 68 delete this->localCamera; 69 /* this->localPlayer hasn't to be deleted explicitly, it is 70 contained in entities*/ 71 } 72 73 74 /** 75 \brief initialize the world before use. 76 */ 77 Error World::init() 78 { 79 this->bPause = false; 80 CommandNode* cn = Orxonox::getInstance()->get_localinput(); 81 cn->addToWorld(this); 82 cn->enable(true); 83 } 84 85 Error World::start() 86 { 87 printf("World::start() - starting current World: nr %i\n", this->debugWorldNr); 88 this->bQuitOrxonox = false; 89 this->bQuitCurrentGame = false; 90 this->mainLoop(); 91 } 92 93 Error World::stop() 94 { 95 printf("World::stop() - got stop signal\n"); 96 this->bQuitCurrentGame = true; 91 97 } 92 98 … … 568 574 { 569 575 this->lastFrame = SDL_GetTicks(); 570 this->bQuitOrxonox = false; 571 this->bQuitCurrentGame = false; 572 printf("World|Entering main loop\n"); 576 printf("World::mainLoop() - Entering main loop\n"); 573 577 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */ 574 578 { … … 740 744 bool World::command(Command* cmd) 741 745 { 742 if( !strcmp( cmd->cmd, "quit"))743 {744 if( !cmd->bUp) this->stop();745 return true;746 }747 746 return false; 748 747 }
Note: See TracChangeset
for help on using the changeset viewer.