Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2005, 10:39:01 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: merged trunk into branche using: svn merge ../trunk/ md2_loader -r 4063:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/game_loader.cc

    r4020 r4139  
    2525#include "command_node.h"
    2626#include "vector.h"
     27#include "resource_manager.h"
    2728#include "factory.h"
    2829
     
    7677{
    7778  ErrorMessage errorCode;
    78  
    79   this->currentCampaign = this->fileToCampaign(name);
     79  char* campaignName;
     80  if (ResourceManager::isFile(name))
     81    {
     82      this->currentCampaign = this->fileToCampaign(name);
     83    }
     84  else
     85    {
     86      campaignName = new char[strlen(ResourceManager::getInstance()->getDataDir())+strlen(name)];
     87      sprintf(campaignName, "%s%s", ResourceManager::getInstance()->getDataDir(), name);
     88      this->currentCampaign = this->fileToCampaign(campaignName);
     89      delete campaignName;
     90    }
    8091}
    8192
     
    162173   this will interprete the map/campaign files and recursivly load a tree of worlds/campaigns
    163174*/
    164 Campaign* GameLoader::fileToCampaign(char *name)
     175Campaign* GameLoader::fileToCampaign(const char *name)
    165176{
    166177  /* do not entirely load the campaign. just the current world
     
    171182  if( name == NULL)
    172183    {
    173       PRINTF0("No filename specified for loading");
     184      PRINTF(2)("No filename specified for loading");
    174185      return NULL;
    175186    }
     
    180191    {
    181192      // report an error
    182       PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
     193      PRINTF(1)("Could not load XML File %s: %s @ %d:%d\n", name, XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    183194      delete XMLDoc;
    184195      return NULL;
     
    192203    {
    193204      // report an error
    194       PRINTF(0)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
     205      PRINTF(2)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
    195206      delete XMLDoc;
    196207      return NULL;
     
    214225bool GameLoader::worldCommand (Command* cmd)
    215226{
    216   if( !strcmp( cmd->cmd, "up_world"))
     227  if( !strcmp( cmd->cmd, CONFIG_NAME_NEXT_WORLD))
    217228    {
    218229      if( !cmd->bUp)
     
    222233      return true;
    223234    }
    224   else if( !strcmp( cmd->cmd, "down_world"))
     235  else if( !strcmp( cmd->cmd, CONFIG_NAME_PREV_WORLD))
    225236    {
    226237      if( !cmd->bUp)
     
    230241      return true;
    231242    }
    232   else if( !strcmp( cmd->cmd, "pause"))
     243  else if( !strcmp( cmd->cmd, CONFIG_NAME_PAUSE))
    233244    {
    234245      if( !cmd->bUp)
     
    241252      return true;
    242253    }
    243   else if( !strcmp( cmd->cmd, "quit"))
     254  else if( !strcmp( cmd->cmd, CONFIG_NAME_QUIT))
    244255    {
    245256      if( !cmd->bUp) this->stop();
     
    279290        assert( factory != NULL);
    280291       
    281         PRINTF0("Registered factory for '%s'\n", factory->getFactoryName());
     292        PRINTF(4)("Registered factory for '%s'\n", factory->getFactoryName());
    282293       
    283294        if( first == NULL) first = factory;
     
    291302BaseObject* GameLoader::fabricate( TiXmlElement* element)
    292303{
    293         assert( element != NULL);
    294        
    295         if( first == NULL)
    296         {
    297                 PRINTF0("GameLoader does not know any factories, fabricate() failed\n");
    298                 return NULL;
    299         }
    300        
    301         if( element->Value() != NULL)
    302         {
    303                 PRINTF0("Attempting fabrication of a '%s'\n", element->Value());
    304                 BaseObject* b = first->fabricate( element);
    305                 if( b == NULL) PRINTF0("Failed to fabricate a '%s'\n", element->Value());
    306                 else PRINTF0("Successfully fabricated a '%s'\n", element->Value());
    307                 return b;
    308         }
    309        
    310         PRINTF0("Fabricate failed, TiXmlElement did not contain a value\n");
    311        
    312         return NULL;
    313 }
     304  assert( element != NULL);
     305       
     306  if( first == NULL)
     307    {
     308      PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n");
     309      return NULL;
     310    }
     311       
     312  if( element->Value() != NULL)
     313    {
     314      PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value());
     315      BaseObject* b = first->fabricate( element);
     316      if( b == NULL)
     317        PRINTF(2)("Failed to fabricate a '%s'\n", element->Value());
     318      else
     319        PRINTF(4)("Successfully fabricated a '%s'\n", element->Value());
     320      return b;
     321    }
     322       
     323  PRINTF(2)("Fabricate failed, TiXmlElement did not contain a value\n");
     324       
     325  return NULL;
     326}
Note: See TracChangeset for help on using the changeset viewer.