Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7286 in orxonox.OLD for trunk/src/story_entities


Ignore:
Timestamp:
Apr 13, 2006, 10:33:49 PM (19 years ago)
Author:
bensch
Message:

trunk: very stuck at the moment…. segfaults and errors everywhere…. maybe i will sync back soon… :/

Location:
trunk/src/story_entities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/game_world.cc

    r7283 r7286  
    2020#include "game_world_data.h"
    2121
    22 #include "util/loading/resource_manager.h"
    2322#include "state.h"
    2423#include "class_list.h"
     
    2726#include "util/loading/game_loader.h"
    2827
    29 #include "p_node.h"
    30 #include "world_entity.h"
    3128#include "player.h"
    3229#include "camera.h"
    3330#include "environment.h"
    3431#include "terrain.h"
    35 #include "test_entity.h"
    36 #include "terrain.h"
    3732#include "md2Model.h"
    38 #include "world_entities/projectiles/projectile.h"
    39 #include "npcs/npc_test1.h"
    4033#include "playable.h"
    4134
     
    4740#include "shell_command.h"
    4841
     42#include "util/loading/resource_manager.h"
    4943#include "graphics_engine.h"
    5044#include "event_handler.h"
     
    5347#include "network_manager.h"
    5448#include "physics_engine.h"
    55 #include "fields.h"
    5649
    5750#include "glmenu_imagescreen.h"
     
    10396  PRINTF(4)("Deleted GameWorld\n");
    10497
    105   if (this->audioThread != NULL)
    106     SDL_KillThread(this->audioThread);
     98  this->bRunning = false;
     99  this->unloadData();
     100
     101  if( this->dataTank)
     102    delete this->dataTank;
    107103}
    108104
     
    140136  GameWorld* gw = (GameWorld*)gameWorld;
    141137  printf("STARTIG AUDIO THREAD\n");
     138  if(gw->dataTank != NULL && gw->dataTank->music != NULL)
     139    gw->dataTank->music->playback();
     140  SDL_Delay(100);
    142141  while (gw->bRunning)
    143142  {
    144     if(gw->dataTank->music != NULL)
    145       gw->dataTank->music->playback();
     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();
    146147    SDL_Delay(5);
    147148  }
    148   printf("End the AudioThread\n");
     149  printf("END the AudioThread\n");
    149150}
    150151
     
    168169  }
    169170
    170   TiXmlDocument* XMLDoc = new TiXmlDocument( getLoadFile());
     171  TiXmlDocument XMLDoc = TiXmlDocument( getLoadFile());
    171172  // load the xml world file for further loading
    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;
     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());
    176176    return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
    177177  }
    178178  // check basic validity
    179   TiXmlElement* root = XMLDoc->RootElement();
     179  TiXmlElement* root = XMLDoc.RootElement();
    180180  assert( root != NULL);
    181181  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
     
    183183    // report an error
    184184    PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    185     delete XMLDoc;
    186185    return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"};
    187186  }
     
    190189  this->dataXML = (TiXmlElement*)root->Clone();
    191190
    192   delete XMLDoc;
    193191  this->releaseLoadScreen();
    194192}
     
    201199{
    202200  delete this->shell;
    203   PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n");
     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);
    204212
    205213  this->dataTank->unloadData();
     
    207215  State::setCurrentStoryEntity(NULL);
    208216  if (this->dataXML)
     217  {
    209218    delete this->dataXML;
     219    this->dataXML = NULL;
     220  }
    210221}
    211222
     
    233244  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    234245  this->bRunning = false;
    235 
    236 //  SDL_KillThread(this->audioThread);
    237   this->audioThread = NULL;
    238246}
    239247
     
    396404  PNode::getNullParent()->updateNode (this->dtS);
    397405  SoundEngine::getInstance()->update();
    398 
    399   if (this->dataTank->music != NULL)
    400     this->dataTank->music->update();
    401406}
    402407
  • trunk/src/story_entities/game_world_data.cc

    r7221 r7286  
    2828#include "util/loading/game_loader.h"
    2929
    30 #include "p_node.h"
    3130#include "world_entity.h"
    3231#include "player.h"
    3332#include "camera.h"
    3433#include "environment.h"
     34#include "skybox.h"
    3535#include "terrain.h"
    36 #include "test_entity.h"
    37 #include "terrain.h"
    38 #include "skybox.h"
    39 #include "md2Model.h"
    40 #include "world_entities/projectiles/projectile.h"
    41 #include "npcs/npc_test1.h"
    4236#include "playable.h"
    4337
     
    125119 * @param root reference to the xml root element
    126120 */
    127 ErrorMessage GameWorldData::loadData(TiXmlElement* root)
     121ErrorMessage GameWorldData::loadData(const TiXmlElement* root)
    128122{
    129123  // load the parameters
     
    159153 * @param root reference to the xml root element
    160154 */
    161 ErrorMessage GameWorldData::loadGUI(TiXmlElement* root)
    162 {
    163   TiXmlElement* element = root->FirstChildElement("LoadScreen");
     155ErrorMessage GameWorldData::loadGUI(const TiXmlElement* root)
     156{
     157  const TiXmlElement* element = root->FirstChildElement("LoadScreen");
    164158  if( element == NULL)
    165159  {
     
    192186 * @param root reference to the xml root parameter
    193187 */
    194 ErrorMessage GameWorldData::loadWorldEntities(TiXmlElement* root)
    195 {
    196   TiXmlElement* element = root->FirstChildElement("WorldEntities");
     188ErrorMessage GameWorldData::loadWorldEntities(const TiXmlElement* root)
     189{
     190  const TiXmlElement* element = root->FirstChildElement("WorldEntities");
    197191
    198192  if( element == NULL)
     
    210204      if( created != NULL )
    211205        PRINTF(4)("Created a %s: %s\n", created->getClassName(), created->getName());
     206      else
     207      {
     208        PRINTF(2)("Unable to create a %s\n", element->Value());
     209        element = element->NextSiblingElement();
     210        continue;
     211      }
    212212
    213213      //todo do this more elegant
     
    310310 * @param root reference to the xml root element
    311311 */
    312 ErrorMessage GameWorldData::loadScene(TiXmlElement* root)
     312ErrorMessage GameWorldData::loadScene(const TiXmlElement* root)
    313313{
    314314  LoadParamXML(root, "LightManager", LightManager::getInstance(), LightManager, loadParams);
     
    342342  delete PhysicsEngine::getInstance();
    343343
    344   if (this->music != NULL)
    345     this->setSoundTrack("");
    346   this->music = NULL;
     344  this->setSoundTrack("");
     345
    347346  /* stop the sound eninge */
    348347  SoundEngine::getInstance()->flushAllBuffers();
     
    357356{
    358357  if (this->music != NULL)
    359     delete this->music;
    360   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());
    361366
    362367  if (!name.empty())
     
    364369    PRINTF(3)("Setting Sound Track to %s\n", name.c_str());
    365370    std::string oggFile = ResourceManager::getFullName(name);
    366     this->music = new OggPlayer(oggFile);
     371    OggPlayer* newMusic = new OggPlayer(oggFile);
     372    this->music = newMusic;
    367373
    368374    //(OggPlayer*)ResourceManager::getInstance()->load(name, OGG, RP_LEVEL);
  • trunk/src/story_entities/game_world_data.h

    r7221 r7286  
    3838
    3939    virtual ErrorMessage init();
    40     virtual ErrorMessage loadData(TiXmlElement* root);
     40    virtual ErrorMessage loadData(const TiXmlElement* root);
    4141    virtual ErrorMessage unloadData();
    4242
     
    4646
    4747  protected:
    48     virtual ErrorMessage loadGUI(TiXmlElement* root);
    49     virtual ErrorMessage loadWorldEntities(TiXmlElement* root);
    50     virtual ErrorMessage loadScene(TiXmlElement* root);
     48    virtual ErrorMessage loadGUI(const TiXmlElement* root);
     49    virtual ErrorMessage loadWorldEntities(const TiXmlElement* root);
     50    virtual ErrorMessage loadScene(const TiXmlElement* root);
    5151
    5252    virtual ErrorMessage unloadGUI();
  • trunk/src/story_entities/multi_player_world.cc

    r7193 r7286  
    5757{
    5858  PRINTF(3)("MultiPlayerWorld::~MultiPlayerWorld() - deleting current world\n");
    59   if( this->dataTank)
    60     delete this->dataTank;
    6159}
    6260
  • trunk/src/story_entities/simple_game_menu.cc

    r7221 r7286  
    7979{
    8080  PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n");
    81 
    82   if( this->dataTank)
    83     delete this->dataTank;
    8481}
    8582
  • trunk/src/story_entities/single_player_world.cc

    r7193 r7286  
    5959{
    6060  PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n");
    61 
    62   if( this->dataTank)
    63     delete this->dataTank;
    6461}
    6562
Note: See TracChangeset for help on using the changeset viewer.