Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 13, 2005, 10:40:25 PM (19 years ago)
Author:
chris
Message:

orxonox/branches/levelloader: Got the system to compile, the basic backbone now runs. What remains to be done is implementing all necessary functions to load all vital classes into a world

Location:
orxonox/branches/levelloader/src/story_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelloader/src/story_entities/campaign.cc

    r3525 r3530  
    2222#include "story_entity.h"
    2323#include "factory.h"
     24#include "game_loader.h"
    2425
    2526using namespace std;
    2627
     28CREATE_FACTORY(Campaign);
    2729
    2830Campaign::Campaign ()
     
    3739{
    3840        TiXmlElement* element;
    39         char string;
     41        const char* string;
    4042        int id;
    4143       
     
    4850  // grab all the necessary parameters
    4951        string = grabParameter( root, "identifier");
    50         if( string == NULL || if( sscanf(string, "%d", &id) != 1))
    51         {
    52                 PRINTF(ERR)("Campaign is missing a proper 'identifier'\n");
    53                 setStoryId( -1);
    54         }
    55         else setStoryId( id);
     52        if( string == NULL || sscanf(string, "%d", &id) != 1)
     53        {
     54                PRINTF(1)("Campaign is missing a proper 'identifier'\n");
     55                this->setStoryID( -1);
     56        }
     57        else this->setStoryID( id);
    5658       
    5759  // find WorldList
     
    6365                StoryEntity* created = (StoryEntity*) loader->fabricate( element);
    6466                if( created != NULL) addEntity( created);
    65                 element = element->nextSiblingElement();
     67                element = element->NextSiblingElement();
    6668        }
    6769}
  • orxonox/branches/levelloader/src/story_entities/campaign.h

    r3525 r3530  
    4141};
    4242
    43 CREATE_FACTORY(Campaign);
    44 
    4543#endif /* _CAMPAIGN_H */
  • orxonox/branches/levelloader/src/story_entities/world.cc

    r3525 r3530  
    3030#include "fontset.h"
    3131#include "factory.h"
     32#include "game_loader.h"
    3233
    3334using namespace std;
    3435
     36CREATE_FACTORY(World);
    3537
    3638World::World( TiXmlElement* root)
    3739{
    38         char *string, *name;
     40        const char *string;
     41        char *name;
    3942        int id;
    4043
    4144        // identifier
    4245        string = grabParameter( root, "identifier");
    43         if( string == NULL || if( sscanf(string, "%d", &id) != 1))
    44         {
    45                 PRINTF(ERR)("World is missing a proper 'identifier'\n");
    46                 setStoryId( -1);
    47         }
    48         else setStoryId( id);
     46        if( string == NULL || sscanf(string, "%d", &id) != 1)
     47        {
     48                PRINTF(1)("World is missing a proper 'identifier'\n");
     49                this->setStoryID( -1);
     50        }
     51        else setStoryID( id);
    4952       
    5053        // path
     
    5255        if( string == NULL)
    5356        {
    54                 PRINTF(ERR)("World is missing a proper 'path'\n");
    55                 setPath( NULL);
     57                PRINTF(1)("World is missing a proper 'path'\n");
     58                this->setPath( NULL);
    5659        }
    5760        else
     
    5962                name = new char[strlen(string + 2)];
    6063                strcpy( name, string);
    61                 setPath( name);
     64                this->setPath( name);
    6265        }
    6366       
     
    105108  this->nullParent->destroy(); 
    106109  delete this->skySphere;
     110  if( this->worldName) delete this->worldName;
     111  if( this->path) delete this->path;
    107112
    108113  //delete this->trackManager;
     
    137142  if( getPath() == NULL)
    138143  {
    139                 PRINTF(ERR)("World has no path specified for loading");
     144                PRINTF(1)("World has no path specified for loading");
    140145                return (ErrorMessage){213,"Path not specified","World::load()"};
    141146  }
    142147 
    143         TiXmlDocument* XMLDoc = new TiXmlDocument( name);
     148        TiXmlDocument* XMLDoc = new TiXmlDocument( path);
    144149        // load the campaign document
    145         if( !XMLDoc.LoadFile())
     150        if( !XMLDoc->LoadFile())
    146151        {
    147152                // report an error
    148                 PRINTF(ERR)("Error loading XML File: %s @ %d:%d\n", XMLDoc.ErrorDesc(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
     153                PRINTF(1)("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    149154                delete XMLDoc;
    150155                return (ErrorMessage){213,"XML File parsing error","World::load()"};
     
    152157       
    153158        // check basic validity
    154         TiXmlElement* root = XMLDoc.RootElement();
     159        TiXmlElement* root = XMLDoc->RootElement();
    155160        assert( root != NULL);
    156161       
    157         element = root->FirstChildElement( "WorldDataFile");
     162        TiXmlElement* element = root->FirstChildElement( "WorldDataFile");
    158163       
    159164        if( root == NULL )
    160165        {
    161166                // report an error
    162                 PRINTF(ERR)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
     167                PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    163168                delete XMLDoc;
    164169                return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
     
    167172        // load the parameters
    168173                // name
    169         TiXmlElement* element;
    170174        char* temp;
    171         char* string = grabParameter( root, "name");
     175        const char* string = grabParameter( root, "name");
    172176        if( string == NULL)
    173177        {
    174                 PRINTF(ERR)("World is missing a proper 'name'\n");
    175                 setStoryId( -1);
     178                PRINTF(1)("World is missing a proper 'name'\n");
     179                this->setStoryID( -1);
    176180        }
    177181        else
    178182        {
    179183                temp = new char[strlen(string + 2)];
    180                 worldName = temp;
     184                this->worldName = temp;
    181185        }
    182186       
     
    187191  if( element == NULL)
    188192  {
    189                 PRINTF(ERR)("World is missing 'WorldEntities'\n");
     193                PRINTF(1)("World is missing 'WorldEntities'\n");
    190194  }
    191195  else
     
    197201                        WorldEntity* created = (WorldEntity*) loader->fabricate( element);
    198202                        if( created != NULL) spawn( created);
    199                         element = element->nextSiblingElement();
     203                        element = element->NextSiblingElement();
    200204                }
    201205        }
     
    205209  if( element == NULL)
    206210  {
    207                 PRINTF(ERR)("World is missing a 'Track'\n");
     211                PRINTF(1)("World is missing a 'Track'\n");
    208212  }
    209213  else
     
    225229      testFont->buildFont("../data/pictures/font.tga");
    226230
    227       // initializing the TrackManager
    228       trackManager = TrackManager::getInstance();
    229       trackManager->addPoint(Vector(0,-5,0));
    230       trackManager->addPoint(Vector(10,0,5));
    231       trackManager->addPoint(Vector(20,0,-5));
    232       trackManager->addPoint(Vector(30,0,5));
    233       trackManager->addPoint(Vector(40,0,5));
    234       trackManager->setDuration(2);
    235       trackManager->setSavePoint();
    236       trackManager->addPoint(Vector(50,10,10));
    237       trackManager->addPoint(Vector(60,0, 10));
    238       trackManager->addPoint(Vector(70,0, 10));
    239       trackManager->addPoint(Vector(80,0,-10));
    240       trackManager->addPoint(Vector(90,0,-10));
    241       trackManager->setDuration(5);
    242       trackManager->setSavePoint();
    243       trackManager->addPoint(Vector(110,0,5));
    244       trackManager->addPoint(Vector(120,0, 10));
    245       trackManager->addPoint(Vector(130,0, 10));
    246       trackManager->addPoint(Vector(140,0,-10));
    247       trackManager->addPoint(Vector(150,0,-10));
    248       trackManager->setDuration(3);
    249       int fork11, fork12, fork13, fork14;
    250       trackManager->fork(4, &fork11, &fork12, &fork13, &fork14);
    251       trackManager->workOn(fork11);
    252       trackManager->addPoint(Vector(170, 0, -15));
    253       trackManager->addPoint(Vector(180, 0, -15));
    254       trackManager->setDuration(3);
    255       trackManager->workOn(fork12);
    256       trackManager->addPoint(Vector(170, 0, 10));
    257       trackManager->addPoint(Vector(180, 0, 10));
    258       trackManager->addPoint(Vector(190,2,5));
    259       trackManager->addPoint(Vector(200,2,5));
    260       trackManager->setDuration(7);
    261       int fork21, fork22;
    262       trackManager->fork(2, &fork21, &fork22);
    263       trackManager->workOn(fork21);
    264       trackManager->addPoint(Vector(220, 10,-10));
    265       trackManager->addPoint(Vector(230, 0,-10));
    266       trackManager->addPoint(Vector(240, 0, 2));
    267       trackManager->addPoint(Vector(250, 0, 0));
    268       trackManager->addPoint(Vector(260, 0, 5));
    269       trackManager->setDuration(3);
    270       trackManager->join(2, fork12, fork11);
    271       trackManager->workOn(fork22);
    272       trackManager->addPoint(Vector(220, -10,10));
    273       trackManager->addPoint(Vector(230, 0, 10));
    274       trackManager->addPoint(Vector(240, 0, 10));
    275       trackManager->addPoint(Vector(250, 0, 5));
    276       trackManager->setDuration(6);
    277       trackManager->workOn(fork13);
    278       trackManager->addPoint(Vector(200,-10,5));
    279       trackManager->addPoint(Vector(250,-10,5));
    280       trackManager->setDuration(3);
    281       trackManager->workOn(fork14);
    282       trackManager->addPoint(Vector(200,15,0));
    283       trackManager->addPoint(Vector(210,0,10));
    284       trackManager->setDuration(1);
    285       trackManager->join(4, fork21, fork22, fork13, fork14);
    286       trackManager->workOn(10);
    287       trackManager->addPoint(Vector(250,-10,5));
    288       trackManager->addPoint(Vector(260,-10,5));
    289       trackManager->finalize();
    290      
    291231      /*monitor progress*/
    292232      this->glmis->step();
  • orxonox/branches/levelloader/src/story_entities/world.h

    r3525 r3530  
    88
    99#include "stdincl.h"
     10
    1011#include "story_entity.h"
    11 
    1212
    1313class TrackManager;
     
    2525   it is the main driving factor during gameplay.
    2626*/
     27//#define SUBCLASS(x,y) class x : public y {
     28
     29//SUBCLASS(World,StoryEntity)
    2730class World : public StoryEntity {
    2831
    2932 public:
    30         World (TiXmlElement* root),
     33        World (TiXmlElement* root);
    3134  World (char* name);
    3235  World (int worldID);
     
    9295};
    9396
    94 CREATE_FACTORY(World);
    95 
    9697#endif /* _WORLD_H */
Note: See TracChangeset for help on using the changeset viewer.