Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2005, 11:58:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/levelLoader: constifization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelLoader/src/story_entities/world.cc

    r4248 r4253  
    121121CREATE_FACTORY(World);
    122122
    123 World::World( TiXmlElement* root)
     123World::World(const TiXmlElement* root)
    124124{
    125125  this->constuctorInit("", -1);
    126126  this->path = NULL;
    127   const char *string;
    128   char *name;
    129   int id;
    130  
    131   PRINTF0("Creating a World\n");
    132  
    133   // identifier
    134   string = grabParameter( root, "identifier");
    135   if( string == NULL || sscanf(string, "%d", &id) != 1)
    136     {
    137       PRINTF0("World is missing a proper 'identifier'\n");
    138       this->setStoryID( -1);
    139     }
    140   else setStoryID( id);
    141 
    142   // next id
    143   string = grabParameter( root, "nextid");
    144   if( string == NULL || sscanf(string, "%d", &id) != 1)
    145     {
    146       PRINTF0("World is missing a proper 'nextid'\n");
    147       this->setStoryID( -1);
    148     }
    149   else setNextStoryID( id);
    150  
    151 
    152   // path
    153   string = grabParameter( root, "path");
    154   if( string == NULL)
    155     {
    156       PRINTF0("World is missing a proper 'path'\n");
    157       this->setPath( NULL);
    158     }
    159   else
    160     {
    161       name = new char[strlen(string + 2)];
    162       strcpy( name, string);
    163       this->setPath( name);
    164     }
     127 
     128  this->loadParams(root);
    165129}
    166130
     
    234198  this->debugWorldNr = worldID;
    235199  this->entities = new tList<WorldEntity>();
     200}
     201
     202void World::loadParams(const TiXmlElement* root)
     203{
     204  const char *string;
     205  char *name;
     206  int id;
     207
     208  PRINTF0("Creating a World\n");
     209 
     210  // identifier
     211  string = grabParameter( root, "identifier");
     212  if( string == NULL || sscanf(string, "%d", &id) != 1)
     213    {
     214      PRINTF0("World is missing a proper 'identifier'\n");
     215      this->setStoryID( -1);
     216    }
     217  else setStoryID( id);
     218
     219  // next id
     220  string = grabParameter( root, "nextid");
     221  if( string == NULL || sscanf(string, "%d", &id) != 1)
     222    {
     223      PRINTF0("World is missing a proper 'nextid'\n");
     224      this->setStoryID( -1);
     225    }
     226  else setNextStoryID( id);
     227 
     228
     229  // path
     230  string = grabParameter( root, "path");
     231  if( string == NULL)
     232    {
     233      PRINTF0("World is missing a proper 'path'\n");
     234      this->setPath( NULL);
     235    }
     236  else
     237    {
     238      name = new char[strlen(string + 2)];
     239      strcpy( name, string);
     240      this->setPath( name);
     241    }
    236242}
    237243
     
    332338  else
    333339    {
    334       this->glmis->load(element);
     340      this->glmis->loadParams(element);
    335341      this->glmis->draw();
    336342    }
Note: See TracChangeset for help on using the changeset viewer.