Changeset 7287 in orxonox.OLD for trunk/src/story_entities
- Timestamp:
- Apr 13, 2006, 10:41:48 PM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world.cc
r7286 r7287 20 20 #include "game_world_data.h" 21 21 22 #include "util/loading/resource_manager.h" 22 23 #include "state.h" 23 24 #include "class_list.h" … … 26 27 #include "util/loading/game_loader.h" 27 28 29 #include "p_node.h" 30 #include "world_entity.h" 28 31 #include "player.h" 29 32 #include "camera.h" 30 33 #include "environment.h" 31 34 #include "terrain.h" 35 #include "test_entity.h" 36 #include "terrain.h" 32 37 #include "md2Model.h" 38 #include "world_entities/projectiles/projectile.h" 39 #include "npcs/npc_test1.h" 33 40 #include "playable.h" 34 41 … … 40 47 #include "shell_command.h" 41 48 42 #include "util/loading/resource_manager.h"43 49 #include "graphics_engine.h" 44 50 #include "event_handler.h" … … 47 53 #include "network_manager.h" 48 54 #include "physics_engine.h" 55 #include "fields.h" 49 56 50 57 #include "glmenu_imagescreen.h" … … 96 103 PRINTF(4)("Deleted GameWorld\n"); 97 104 98 this->bRunning = false; 99 this->unloadData(); 100 101 if( this->dataTank) 102 delete this->dataTank; 105 if (this->audioThread != NULL) 106 SDL_KillThread(this->audioThread); 103 107 } 104 108 … … 136 140 GameWorld* gw = (GameWorld*)gameWorld; 137 141 printf("STARTIG AUDIO THREAD\n"); 138 if(gw->dataTank != NULL && gw->dataTank->music != NULL)139 gw->dataTank->music->playback();140 SDL_Delay(100);141 142 while (gw->bRunning) 142 143 { 143 printf("PLAYBACK\n"); 144 ClassList::debug(3, CL_SOUND_OGG_PLAYER); 145 if(gw->dataTank != NULL && gw->dataTank->music != NULL) 146 gw->dataTank->music->update(); 144 if(gw->dataTank->music != NULL) 145 gw->dataTank->music->playback(); 147 146 SDL_Delay(5); 148 147 } 149 printf("E NDthe AudioThread\n");148 printf("End the AudioThread\n"); 150 149 } 151 150 … … 169 168 } 170 169 171 TiXmlDocument XMLDoc =TiXmlDocument( getLoadFile());170 TiXmlDocument* XMLDoc = new TiXmlDocument( getLoadFile()); 172 171 // load the xml world file for further loading 173 if( !XMLDoc.LoadFile()) 174 { 175 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile().c_str(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol()); 172 if( !XMLDoc->LoadFile()) 173 { 174 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 175 delete XMLDoc; 176 176 return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"}; 177 177 } 178 178 // check basic validity 179 TiXmlElement* root = XMLDoc .RootElement();179 TiXmlElement* root = XMLDoc->RootElement(); 180 180 assert( root != NULL); 181 181 if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile")) … … 183 183 // report an error 184 184 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 185 delete XMLDoc; 185 186 return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"}; 186 187 } … … 189 190 this->dataXML = (TiXmlElement*)root->Clone(); 190 191 192 delete XMLDoc; 191 193 this->releaseLoadScreen(); 192 194 } … … 199 201 { 200 202 delete this->shell; 201 this->shell = NULL; 202 PRINTF(0)("GameWorld::~unloadData() - unloading the current GameWorld %s::%s\n", this->getClassName(), this->getName()); 203 204 if (this->audioThread != NULL) 205 { 206 this->bRunning = false; 207 SDL_WaitThread(this->audioThread, NULL); 208 this->audioThread = NULL; 209 } 210 211 ClassList::debug( 3, CL_GAME_WORLD_DATA); 203 PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n"); 212 204 213 205 this->dataTank->unloadData(); … … 215 207 State::setCurrentStoryEntity(NULL); 216 208 if (this->dataXML) 217 {218 209 delete this->dataXML; 219 this->dataXML = NULL;220 }221 210 } 222 211 … … 244 233 PRINTF(3)("GameWorld::stop() - got stop signal\n"); 245 234 this->bRunning = false; 235 236 // SDL_KillThread(this->audioThread); 237 this->audioThread = NULL; 246 238 } 247 239 … … 404 396 PNode::getNullParent()->updateNode (this->dtS); 405 397 SoundEngine::getInstance()->update(); 398 399 if (this->dataTank->music != NULL) 400 this->dataTank->music->update(); 406 401 } 407 402 -
trunk/src/story_entities/game_world_data.cc
r7286 r7287 28 28 #include "util/loading/game_loader.h" 29 29 30 #include "p_node.h" 30 31 #include "world_entity.h" 31 32 #include "player.h" 32 33 #include "camera.h" 33 34 #include "environment.h" 35 #include "terrain.h" 36 #include "test_entity.h" 37 #include "terrain.h" 34 38 #include "skybox.h" 35 #include "terrain.h" 39 #include "md2Model.h" 40 #include "world_entities/projectiles/projectile.h" 41 #include "npcs/npc_test1.h" 36 42 #include "playable.h" 37 43 … … 119 125 * @param root reference to the xml root element 120 126 */ 121 ErrorMessage GameWorldData::loadData( constTiXmlElement* root)127 ErrorMessage GameWorldData::loadData(TiXmlElement* root) 122 128 { 123 129 // load the parameters … … 153 159 * @param root reference to the xml root element 154 160 */ 155 ErrorMessage GameWorldData::loadGUI( constTiXmlElement* root)156 { 157 constTiXmlElement* element = root->FirstChildElement("LoadScreen");161 ErrorMessage GameWorldData::loadGUI(TiXmlElement* root) 162 { 163 TiXmlElement* element = root->FirstChildElement("LoadScreen"); 158 164 if( element == NULL) 159 165 { … … 186 192 * @param root reference to the xml root parameter 187 193 */ 188 ErrorMessage GameWorldData::loadWorldEntities( constTiXmlElement* root)189 { 190 constTiXmlElement* element = root->FirstChildElement("WorldEntities");194 ErrorMessage GameWorldData::loadWorldEntities(TiXmlElement* root) 195 { 196 TiXmlElement* element = root->FirstChildElement("WorldEntities"); 191 197 192 198 if( element == NULL) … … 204 210 if( created != NULL ) 205 211 PRINTF(4)("Created a %s: %s\n", created->getClassName(), created->getName()); 206 else207 {208 PRINTF(2)("Unable to create a %s\n", element->Value());209 element = element->NextSiblingElement();210 continue;211 }212 212 213 213 //todo do this more elegant … … 310 310 * @param root reference to the xml root element 311 311 */ 312 ErrorMessage GameWorldData::loadScene( constTiXmlElement* root)312 ErrorMessage GameWorldData::loadScene(TiXmlElement* root) 313 313 { 314 314 LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams); … … 342 342 delete PhysicsEngine::getInstance(); 343 343 344 this->setSoundTrack(""); 345 344 if (this->music != NULL) 345 this->setSoundTrack(""); 346 this->music = NULL; 346 347 /* stop the sound eninge */ 347 348 SoundEngine::getInstance()->flushAllBuffers(); … … 356 357 { 357 358 if (this->music != NULL) 358 { 359 OggPlayer* oldMusic = this->music; 360 this->music = NULL; 361 delete oldMusic; 362 } 363 364 365 PRINTF(0)("Setting Sound Track to %s\n", name.c_str()); 359 delete this->music; 360 this->music = NULL; 366 361 367 362 if (!name.empty()) … … 369 364 PRINTF(3)("Setting Sound Track to %s\n", name.c_str()); 370 365 std::string oggFile = ResourceManager::getFullName(name); 371 OggPlayer* newMusic = new OggPlayer(oggFile); 372 this->music = newMusic; 366 this->music = new OggPlayer(oggFile); 373 367 374 368 //(OggPlayer*)ResourceManager::getInstance()->load(name, OGG, RP_LEVEL); -
trunk/src/story_entities/game_world_data.h
r7286 r7287 38 38 39 39 virtual ErrorMessage init(); 40 virtual ErrorMessage loadData( constTiXmlElement* root);40 virtual ErrorMessage loadData(TiXmlElement* root); 41 41 virtual ErrorMessage unloadData(); 42 42 … … 46 46 47 47 protected: 48 virtual ErrorMessage loadGUI( constTiXmlElement* root);49 virtual ErrorMessage loadWorldEntities( constTiXmlElement* root);50 virtual ErrorMessage loadScene( constTiXmlElement* root);48 virtual ErrorMessage loadGUI(TiXmlElement* root); 49 virtual ErrorMessage loadWorldEntities(TiXmlElement* root); 50 virtual ErrorMessage loadScene(TiXmlElement* root); 51 51 52 52 virtual ErrorMessage unloadGUI(); -
trunk/src/story_entities/multi_player_world.cc
r7286 r7287 57 57 { 58 58 PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n"); 59 if( this->dataTank) 60 delete this->dataTank; 59 61 } 60 62 -
trunk/src/story_entities/simple_game_menu.cc
r7286 r7287 79 79 { 80 80 PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n"); 81 82 if( this->dataTank) 83 delete this->dataTank; 81 84 } 82 85 -
trunk/src/story_entities/single_player_world.cc
r7286 r7287 59 59 { 60 60 PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n"); 61 62 if( this->dataTank) 63 delete this->dataTank; 61 64 } 62 65
Note: See TracChangeset
for help on using the changeset viewer.