Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3557 in orxonox.OLD


Ignore:
Timestamp:
Mar 15, 2005, 10:53:46 AM (19 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: Rolling toward bug-free-ness

Location:
orxonox/branches/levelloader/src
Files:
8 edited

Legend:

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

    r3542 r3557  
    282282BaseObject* GameLoader::fabricate( TiXmlElement* element)
    283283{
     284        assert( element != NULL);
     285       
    284286        if( first == NULL)
    285287        {
     
    288290        }
    289291       
    290         return first->fabricate( element);
    291 }
     292        if( element->Value() != NULL)
     293        {
     294                PRINTF0("Attempting fabrication of a '%s'\n", element->Value());
     295                BaseObject* b = first->fabricate( element);
     296                if( b == NULL) PRINTF0("Failed to fabricate a '%s'\n", element->Value());
     297                else PRINTF0("Successfully fabricated a '%s'\n", element->Value());
     298                return b;
     299        }
     300       
     301        PRINTF0("Fabricate failed, TiXmlElement did not contain a value\n");
     302       
     303        return NULL;
     304}
  • orxonox/branches/levelloader/src/lib/coord/p_node.cc

    r3499 r3557  
    4040  this->bAbsDirChanged = false;
    4141  this->parent = NULL;
     42  this->objectName = NULL;
    4243}
    4344
     
    5960  this->bAbsDirChanged = false;
    6061  this->parent = parent;
    61 
     62  this->objectName = NULL;
     63 
    6264  parent->addChild (this);
    6365}
     
    7981  */
    8082  this->parent = NULL;
     83  if( this->objectName) delete this->objectName;
    8184  /* there is currently a problem with cleaning up - fix*/
    8285}
     
    442445  \brief set the name of the node
    443446
     447        \todo Error free assignment of name by copying the string instead of keeping just the pointer
     448       
    444449  for debug purposes realy usefull, not used to work properly
    445450*/
    446 void PNode::setName (char* newName)
    447 {
    448   this->objectName = newName;
     451void PNode::setName (const char* newName)
     452{
     453        int l = strlen( newName);
     454       
     455        if( this->objectName != NULL) delete this->objectName;
     456        this->objectName = NULL;
     457       
     458        if( newName != NULL)
     459        {
     460                this->objectName = new char[l+1];
     461               
     462                for( int i = 0; i < l+1; i++)
     463                        this->objectName[i] = newName[i];
     464        }
    449465}
    450466
     
    453469  \brief gets the name of the node
    454470*/
    455 char* PNode::getName ()
     471const char* PNode::getName ()
    456472{
    457473  return this->objectName;
  • orxonox/branches/levelloader/src/lib/coord/p_node.h

    r3499 r3557  
    7373  virtual void tick (float dt);
    7474
    75   void setName (char* newName);
    76   char* getName ();
     75  void setName (const char* newName);
     76  const char* getName ();
    7777
    7878
  • orxonox/branches/levelloader/src/story_entities/campaign.cc

    r3542 r3557  
    4242        int id;
    4343       
     44        PRINTF0("Loading Campaign...\n");
     45       
    4446        assert( root != NULL);
    4547        GameLoader* loader = GameLoader::getInstance();
     
    5254        if( string == NULL || sscanf(string, "%d", &id) != 1)
    5355        {
    54                 PRINTF(1)("Campaign is missing a proper 'identifier'\n");
     56                PRINTF0("Campaign is missing a proper 'identifier'\n");
    5557                this->setStoryID( -1);
    5658        }
     
    5961  // find WorldList
    6062  element = root->FirstChildElement( "WorldList");
     63  if( element == NULL)
     64  {
     65                PRINTF0("Campaign is missing a proper 'WorldList'\n");
     66  }
     67  else
     68        element = element->FirstChildElement();
    6169 
    6270  // load Worlds/Subcampaigns/Whatever
     
    8189}
    8290
    83 
    84 ErrorMessage Campaign::start()
    85 {
    86   this->start(0);
    87 }
    88 
    89 
    90 ErrorMessage Campaign::start(int storyID = 0)
    91 {
    92   printf("World::start() - starting new StoryEntity Nr:%i\n", storyID);
     91ErrorMessage Campaign::start(int storyID)
     92{
     93  printf("Camapaign::start() - starting new StoryEntity Nr:%i\n", storyID);
    9394  ErrorMessage errorCode;
    9495  if( !this->isInit) return errorCode;
     
    9798  StoryEntity* se = this->getStoryEntity(storyID);
    9899  this->currentEntity = se;
     100  if( se == NULL)
     101  {
     102        printf("Camapaign::start() - Start StoryEntity not found\n");
     103        return errorCode;
     104  }
    99105  while( se != NULL && this->running)
    100106    {
  • orxonox/branches/levelloader/src/story_entities/campaign.h

    r3530 r3557  
    1919
    2020  virtual ErrorMessage init();
    21   virtual ErrorMessage start();
    22   virtual ErrorMessage start(int storyID);
     21  virtual ErrorMessage start(int storyID = 0);
    2322  virtual ErrorMessage pause();
    2423  virtual ErrorMessage resume();
  • orxonox/branches/levelloader/src/story_entities/world.cc

    r3542 r3557  
    6868       
    6969        localPlayer = NULL;
     70  this->entities = new tList<WorldEntity>();
    7071               
    7172}
     
    142143{
    143144       
    144         PRINTF0("Loading world: '%s'\n", getPath());
     145        PRINTF0("> Loading world: '%s'\n", getPath());
    145146       
    146147        GameLoader* loader = GameLoader::getInstance();
     
    166167        assert( root != NULL);
    167168       
    168         TiXmlElement* element = root->FirstChildElement( "WorldDataFile");
    169        
    170         if( root == NULL )
     169        if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
    171170        {
    172171                // report an error
     
    197196       
    198197        // find WorldEntities
    199   element = root->FirstChildElement( "WorldEntities");
     198  TiXmlElement* element = root->FirstChildElement( "WorldEntities");
    200199 
    201200  if( element == NULL)
     
    207206        element = element->FirstChildElement();
    208207          // load Players/Objects/Whatever
     208                PRINTF0("Loading WorldEntities\n");
    209209                while( element != NULL)
    210210                {
    211211                        WorldEntity* created = (WorldEntity*) loader->fabricate( element);
    212                         if( created != NULL) spawn( created);
    213                         assert( element->Value() != NULL);
     212                        if( created != NULL) this->spawn( created);
    214213                                // if we load a 'Player' we use it as localPlayer
    215                         if( !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
     214                        // if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
    216215                        element = element->NextSiblingElement();
    217216                }
     217                PRINTF0("Done loading WorldEntities\n");
    218218        }
    219219       
     
    227227  {     
    228228        //load track
    229         trackManager = TrackManager::getInstance();
     229                PRINTF0("Loading Track\n");
     230                trackManager = TrackManager::getInstance();
    230231        trackManager->loadTrack( element);
    231232        trackManager->finalize();
     233                PRINTF0("Done loading Track\n");
    232234        }
    233235
     
    495497  //gluNurbsProperty (theNurb, GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR);
    496498  //gluNurbsProperty (theNurb, GLU_NURBS_VERTEX, vertexCallback );
    497 
     499       
     500        PRINTF0("> Done Loading world: '%s'\n", getPath());
    498501}
    499502
  • orxonox/branches/levelloader/src/track_manager.cc

    r3530 r3557  
    705705                        {
    706706                                assert( container->Value() != NULL);
    707                                 if( sscanf( container->Value(), "%f,%f,%f", &x, &y, &z) == 3)
     707                                if( sscanf( container->Value(), "%lf,%lf,%lf", &x, &y, &z) == 3)
     708                                {
     709                                        PRINTF0("Loaded Point: %lf,%lf,%lf (%s)\n", x, y, z, container->Value());
    708710                                        addPoint( Vector( x, y, z));
     711                                }
    709712                                else
    710713                                {
    711                                         PRINTF(1)("Invalid Point in Track (skipped)\n");
     714                                        PRINTF0("Invalid Point in Track (skipped)\n");
    712715                                }                       
    713716                        }
     
    719722                        {
    720723                                assert( container->Value() != NULL);
    721                                 if( sscanf( container->Value(), "%f", &d) == 1)
     724                                if( sscanf( container->Value(), "%lf", &d) == 1)
     725                                {
     726                                        PRINTF0("Loaded Duration: %lf (%s)\n", d, container->Value());
    722727                                        setDuration( d);
     728                                }
    723729                                else
    724730                                {
    725                                         PRINTF(1)("Invalid Duration in Track (skipped)\n");
     731                                        PRINTF0("Invalid Duration in Track (skipped)\n");
    726732                                }                       
    727733                        }
     
    729735                else if( !strcmp( element->Value(), "SavePoint"))
    730736                {
     737                        PRINTF0("Loaded Savepoint\n");
    731738                        setSavePoint();
    732739                }
     
    737744                        {
    738745                                assert( container->Value() != NULL);
     746                                PRINTF0("Loaded Fork: %s\n", container->Value());
    739747                                forkS( container->Value());
    740748                        }
     
    746754                        {
    747755                                assert( container->Value() != NULL);
     756                                PRINTF0("Loaded Join: %s\n", container->Value());
    748757                                joinS( container->Value());
    749758                        }
     
    755764                        {
    756765                                assert( container->Value() != NULL);
     766                                PRINTF0("Loaded WorkOn: %s\n", container->Value());
    757767                                workOnS( container->Value());
    758768                        }
  • orxonox/branches/levelloader/src/world_entities/environment.cc

    r3542 r3557  
    3535Environment::Environment ( TiXmlElement* root)
    3636{
     37        assert( root != NULL);
     38       
    3739        char* temp;
    3840        const char* string = grabParameter( root, "name");
     41
    3942        if( string == NULL)
    4043        {
    41                 PRINTF(1)("Environment is missing a proper 'name'\n");
     44                PRINTF0("Environment is missing a proper 'name'\n");
    4245                string = "Unknown";
    43                 temp = new char[strlen(string + 2)];
    44                 strcpy( temp, string);
    45                 this->setName( temp);
     46                this->setName( string);
    4647        }
    4748        else
    4849        {
    49                 temp = new char[strlen(string + 2)];
    50                 strcpy( temp, string);
    51                 this->setName( temp);
     50                this->setName( string);
    5251        }
    5352       
     
    5857        else
    5958        {
    60                 PRINTF(1)("Environment is missing a proper 'model'\n");
     59                PRINTF0("Environment is missing a proper 'model'\n");
    6160                this->model = new OBJModel( "../data/models/reaplow.obj");
    6261        }
    6362        if( this->model == NULL)
    6463        {
    65                 PRINTF(1)("Environment model '%s' could not be loaded\n", string);
     64                PRINTF0("Environment model '%s' could not be loaded\n", string);
    6665        }
    6766       
     
    6968       
    7069        string = grabParameter( root, "position");
    71         if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
     70        if( string != NULL && sscanf( string, "%lf,%lf,%lf", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
    7271        {
    7372                Vector* es = new Vector( buff[0], buff[1], buff[2]);
     
    7776        else
    7877        {
    79                 PRINTF(1)("Environment is missing a proper 'position'\n");
     78                PRINTF0("Environment is missing a proper 'position'\n");
    8079                Vector* es = new Vector();
    8180                this->setAbsCoor(es);
    8281                delete es;
    8382        }
    84        
     83               
    8584        string = grabParameter( root, "orientation");
    86         if( string != NULL && sscanf( string, "%f,%f,%f", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
     85        if( string != NULL && sscanf( string, "%lf,%lf,%lf", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
    8786        {
    8887                Quaternion* qs = new Quaternion( buff[0], buff[1], buff[2]);
     
    9291        else
    9392        {
    94                 PRINTF(1)("Environment is missing a proper 'orientation'\n");
     93                PRINTF0("Environment is missing a proper 'orientation'\n");
    9594        Quaternion* qs = new Quaternion ();
    9695                this->setAbsDir(qs);
Note: See TracChangeset for help on using the changeset viewer.