Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7221 in orxonox.OLD for trunk/src/lib/util/loading/game_loader.cc


Ignore:
Timestamp:
Mar 15, 2006, 3:10:45 PM (18 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/loading/game_loader.cc

    r7193 r7221  
    8686 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    8787 */
    88 ErrorMessage GameLoader::loadCampaign(const char* fileName)
     88ErrorMessage GameLoader::loadCampaign(const std::string& fileName)
    8989{
    9090  ErrorMessage errorCode;
    91   char* campaignName = ResourceManager::getFullName(fileName);
    92   if (campaignName)
     91  std::string campaignName = ResourceManager::getFullName(fileName);
     92  if (!campaignName.empty())
    9393    {
    9494      this->currentCampaign = this->fileToCampaign(campaignName);
    95       delete[] campaignName;
    9695    }
    9796}
     
    105104 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    106105 */
    107 ErrorMessage GameLoader::loadNetworkCampaign(const char* fileName)
     106ErrorMessage GameLoader::loadNetworkCampaign(const std::string& fileName)
    108107{
    109108  ErrorMessage errorCode;
    110   char* campaignName = ResourceManager::getFullName(fileName);
    111   if (campaignName)
     109  std::string campaignName = ResourceManager::getFullName(fileName);
     110  if (!campaignName.empty())
    112111  {
    113112    this->currentCampaign = this->fileToCampaign(campaignName);
    114     delete[] campaignName;
    115113  }
    116114}
     
    220218 * this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    221219 */
    222 Campaign* GameLoader::fileToCampaign(const char* fileName)
     220Campaign* GameLoader::fileToCampaign(const std::string& fileName)
    223221{
    224222  /* do not entirely load the campaign. just the current world
     
    227225  */
    228226
    229   if( fileName == NULL)
     227  if( fileName.empty())
    230228    {
    231229      PRINTF(2)("No filename specified for loading");
     
    233231    }
    234232
    235   TiXmlDocument* XMLDoc = new TiXmlDocument( fileName);
     233  TiXmlDocument XMLDoc(fileName);
    236234  // load the campaign document
    237   if( !XMLDoc->LoadFile())
     235  if( !XMLDoc.LoadFile(fileName))
    238236    {
    239237      // report an error
    240       PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    241       delete XMLDoc;
     238      PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", fileName.c_str(), XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
    242239      return NULL;
    243240    }
    244241
    245242  // check basic validity
    246   TiXmlElement* root = XMLDoc->RootElement();
     243  TiXmlElement* root = XMLDoc.RootElement();
    247244  assert( root != NULL);
    248245
     
    251248      // report an error
    252249      PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
    253       delete XMLDoc;
    254250      return NULL;
    255251    }
    256252
    257253  // construct campaign
    258   Campaign* c = new Campaign( root);
    259 
    260   // free the XML data
    261   delete XMLDoc;
    262 
    263   return c;
     254  return new Campaign( root);
    264255}
    265256
Note: See TracChangeset for help on using the changeset viewer.