Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 15, 2006, 3:10:45 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

Location:
trunk/src/story_entities
Files:
8 edited

Legend:

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

    r7193 r7221  
    145145  GameLoader* loader = GameLoader::getInstance();
    146146
    147   if( getLoadFile() == NULL)
     147  if( getLoadFile().empty())
    148148  {
    149149    PRINTF(1)("GameWorld has no path specified for loading\n");
     
    155155  if( !XMLDoc->LoadFile())
    156156  {
    157     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     157    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    158158    delete XMLDoc;
    159159    return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
  • trunk/src/story_entities/game_world_data.cc

    r7193 r7221  
    129129  // load the parameters
    130130  // name
    131   const char* string = grabParameter( root, "name");
    132   if( string == NULL)
     131  std::string string = grabParameter( root, "name");
     132  if( string.empty() )
    133133  {
    134134    PRINTF(2)("GameWorld is missing a proper 'name'\n");
     
    136136  }
    137137  else
    138     this->setName(string);
     138    this->setName(string.c_str());
    139139
    140140  this->loadGUI(root);
     
    343343
    344344  if (this->music != NULL)
    345     this->setSoundTrack(NULL);
     345    this->setSoundTrack("");
    346346  this->music = NULL;
    347347  /* stop the sound eninge */
     
    354354
    355355
    356 void GameWorldData::setSoundTrack(const char* name)
     356void GameWorldData::setSoundTrack(const std::string& name)
    357357{
    358358  if (this->music != NULL)
     
    360360  this->music = NULL;
    361361
    362   if (name != NULL)
    363   {
    364     PRINTF(3)("Setting Sound Track to %s\n", name);
    365     char* oggFile = ResourceManager::getFullName(name); /// FIXME
     362  if (!name.empty())
     363  {
     364    PRINTF(3)("Setting Sound Track to %s\n", name.c_str());
     365    std::string oggFile = ResourceManager::getFullName(name);
    366366    this->music = new OggPlayer(oggFile);
    367     delete[] oggFile;
    368367
    369368    //(OggPlayer*)ResourceManager::getInstance()->load(name, OGG, RP_LEVEL);
  • trunk/src/story_entities/game_world_data.h

    r7020 r7221  
    4242
    4343    /* interface functions */
    44     void setSoundTrack(const char* name);
     44    void setSoundTrack(const std::string& name);
    4545    void loadGameRule(const TiXmlElement* root);
    4646
  • trunk/src/story_entities/movie_loader.cc

    r7193 r7221  
    3636}
    3737
    38 MovieLoader::~MovieLoader() 
     38MovieLoader::~MovieLoader()
    3939{
    4040  delete this->movie_player;
     
    5656}
    5757
    58 void MovieLoader::loadMovie(const char* filename)
     58void MovieLoader::loadMovie(const std::string& filename)
    5959{
    6060  movie_player->loadMovie(filename);
     
    7878
    7979  this->movie_player->start(0);
    80  
     80
    8181  this->isRunning = true;
    8282  this->run();
     
    139139
    140140  // calculate time difference in milliseconds (Uint32)
    141   this->dt = currentFrame - this->lastFrame; 
     141  this->dt = currentFrame - this->lastFrame;
    142142  // calculate time difference in seconds (float)
    143143  this->dts = (float)this->dt / 1000.0f;
  • trunk/src/story_entities/movie_loader.h

    r7022 r7221  
    4343
    4444  private:
    45     void loadMovie(const char* filename);
     45    void loadMovie(const std::string& filename);
    4646    void setFPS(float fps);
    4747    void tick();
  • trunk/src/story_entities/simple_game_menu.cc

    r7193 r7221  
    6363  this->menuSelectedIndex = 0;
    6464
    65   this->loadParams(root);
     65  if (root != NULL)
     66    this->loadParams(root);
    6667
    6768  State::setMenuID(this->getNextStoryID());
     
    7071
    7172/**
    72  *  remove the SimpleGameMenu from memory
     73 *  @brief remove the SimpleGameMenu from memory
    7374 *
    7475 *  delete everything explicitly, that isn't contained in the parenting tree!
     
    8586
    8687/**
    87  * loads the parameters of a SimpleGameMenu from an XML-element
     88 * @brief loads the parameters of a SimpleGameMenu from an XML-element
    8889 * @param root the XML-element to load from
    8990 */
     
    99100
    100101/**
    101  * this is executed just before load
     102 * @brief this is executed just before load
    102103 *
    103104 * since the load function sometimes needs data, that has been initialized
     
    125126
    126127/**
    127  * load the data
     128 * @brief load the data
    128129 */
    129130ErrorMessage SimpleGameMenu::loadData()
     
    265266
    266267/**
    267  * start the menu
     268 * @brief start the menu
    268269 */
    269270bool SimpleGameMenu::start()
  • trunk/src/story_entities/story_entity.cc

    r7193 r7221  
    4040  this->isRunning = false;
    4141
    42   this->loadFile = NULL;
     42  this->loadFile = "";
    4343  this->storyID = -1;
    44   this->description = NULL;
    45   this->menuItemImage = NULL;
    46   this->menuScreenshoot = NULL;
     44  this->description = "";
     45  this->menuItemImage = "";
     46  this->menuScreenshoot = "";
    4747  this->nextStoryID = WORLD_ID_GAMEEND;
    4848  this->bMenuEntry = false;
     
    100100 * @param name the name of the path
    101101 */
    102 void StoryEntity::setLoadFile(const char* fileName)
     102void StoryEntity::setLoadFile(const std::string& fileName)
    103103{
    104   if (this->loadFile)
    105     delete this->loadFile;
    106104  if (ResourceManager::isFile(fileName))
    107105  {
    108     this->loadFile = new char[strlen(fileName)+1];
    109     strcpy(this->loadFile, fileName);
     106    this->loadFile =  fileName;
    110107  }
    111108  else
     
    120117 * @param name name
    121118 */
    122 void StoryEntity::setDescription(const char* description)
     119void StoryEntity::setDescription(const std::string& description)
    123120{
    124   if (this->description)
    125     delete[] this->description;
    126   if (description!= NULL)
    127   {
    128     this->description= new char[strlen(description)+1];
    129     strcpy(this->description, description);
    130   }
    131   else this->description= NULL;
     121  this->description = description;
    132122}
    133123
     
    149139{
    150140  PRINTF(3)("Grabbing the Worlds Settings\n", this->getLoadFile());
    151   if( getLoadFile() == NULL)
    152     return;
     141  if( getLoadFile().empty())
     142        return;
    153143  TiXmlDocument XMLDoc(this->getLoadFile());
    154144  // load the xml world file for further loading
    155145  if( !XMLDoc.LoadFile())
    156146  {
    157     PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
     147    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile().c_str(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
    158148    return;
    159149  }
     
    181171 * @param name name
    182172 */
    183 void StoryEntity::setMenuItemImage(const char* image)
     173void StoryEntity::setMenuItemImage(const std::string& image)
    184174{
    185   if (this->menuItemImage)
    186     delete[] this->menuItemImage;
    187   if (image != NULL)
    188   {
    189     this->menuItemImage = new char[strlen(image)+1];
    190     strcpy(this->menuItemImage, image);
    191   }
    192   else this->menuItemImage = NULL;
     175  this->menuItemImage = image;
    193176}
    194177
    195178
    196 /** sets the menu screenshoot of this StoryEntity @param name name */
    197 void StoryEntity::setMenuScreenshoot(const char* image)
     179/** sets the menu screenshoot of this StoryEntity
     180 * @param name name
     181 */
     182void StoryEntity::setMenuScreenshoot(const std::string& image)
    198183{
    199   if (this->menuScreenshoot)
    200     delete[] this->menuScreenshoot;
    201   if (image != NULL)
    202   {
    203     this->menuScreenshoot = new char[strlen(image)+1];
    204     strcpy(this->menuScreenshoot, image);
    205   }
    206   else this->menuScreenshoot = NULL;
     184  this->menuScreenshoot = image;
    207185}
    208186
  • trunk/src/story_entities/story_entity.h

    r6993 r7221  
    6161  inline int getStoryID() { return this->storyID; }
    6262
    63   void setLoadFile( const char* fileName);
     63  void setLoadFile(const std::string& fileName);
    6464  /** @returns the Filename this StoryEntity was loaded with */
    65   const char* getLoadFile() const { return this->loadFile; }
     65  const std::string& getLoadFile() const { return this->loadFile; }
    6666
    6767  void setNextStoryID(int nextStoryID);
    6868  /**  gets the story id of the current entity @returns story id */
    6969  inline int getNextStoryID() const { return this->nextStoryID; }
    70   inline void setDescription(const char* description);
     70  inline void setDescription(const std::string& description);
    7171  /** @returns the description of this StoryEntity */
    72   inline const char* getDescription() { return this->description; }
     72  inline const std::string& getDescription() { return this->description; }
    7373
    7474  void grabWorldInfo();
     
    7878  inline bool isContainedInMenu() { return this->bMenuEntry; }
    7979  /** sets the menu item image of this StoryEntity @param name name */
    80   inline void setMenuItemImage(const char* image);
     80  inline void setMenuItemImage(const std::string& image);
    8181  /** @returns the menu item image of this StoryEntity */
    82   inline const char* getMenuItemImage() { return this->menuItemImage; }
    83   inline void setMenuScreenshoot(const char* image);
     82  inline const std::string& getMenuItemImage() { return this->menuItemImage; }
     83  inline void setMenuScreenshoot(const std::string& image);
    8484  /** @returns the menu screenshoot of this StoryEntity */
    85   inline const char* getMenuScreenshoot() { return this->menuScreenshoot; }
     85  inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; }
    8686
    8787  protected:
    88     bool isInit;            //!< if the entity is initialized, this has to be true.
    89     bool isRunning;         //!< is true if the entity is running
    90     bool isPaused;          //!< is true if the entity is paused
     88    bool          isInit;            //!< if the entity is initialized, this has to be true.
     89    bool          isRunning;         //!< is true if the entity is running
     90    bool          isPaused;          //!< is true if the entity is paused
    9191
    9292
    9393 private:
    94     int     storyID;          //!< this is the number of this entity, identifying it in a list/tree...
    95     int     nextStoryID;      //!< if this entity has finished, this entity shall be called
    96     char*   loadFile;         //!< The file from which this world is loaded
     94    int           storyID;          //!< this is the number of this entity, identifying it in a list/tree...
     95    int           nextStoryID;      //!< if this entity has finished, this entity shall be called
     96    std::string   loadFile;         //!< The file from which this world is loaded
    9797
    98     char*   description;      //!< the description of the StoryEntity
    99     char*   menuItemImage;    //!< the item image of the StoryEntity
    100     char*   menuScreenshoot;  //!< the screenshoot of the StoryEntity
    101     bool    bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
     98    std::string   description;      //!< the description of the StoryEntity
     99    std::string   menuItemImage;    //!< the item image of the StoryEntity
     100    std::string   menuScreenshoot;  //!< the screenshoot of the StoryEntity
     101    bool          bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    102102};
    103103
Note: See TracChangeset for help on using the changeset viewer.