Index: orxonox/branches/levelloader/src/story_entities/world.cc
===================================================================
--- orxonox/branches/levelloader/src/story_entities/world.cc	(revision 3753)
+++ orxonox/branches/levelloader/src/story_entities/world.cc	(revision 3834)
@@ -220,5 +220,7 @@
   this->setClassName ("World");
 
-  this->worldName = name;
+  //this->worldName = name;
+  //this->worldName = new char[strlen(name)+1];
+  //strcpy(this->worldName, name);
   this->debugWorldNr = worldID;
   this->entities = new tList<WorldEntity>();
@@ -247,168 +249,168 @@
 ErrorMessage World::load()
 {	
-	PRINTF0("> Loading world: '%s'\n", getPath());
-	
-	GameLoader* loader = GameLoader::getInstance();
-	
+  PRINTF0("> Loading world: '%s'\n", getPath());
+  
+  GameLoader* loader = GameLoader::getInstance();
+  
   if( getPath() == NULL)
+    {
+      PRINTF0("World has no path specified for loading");
+      return (ErrorMessage){213,"Path not specified","World::load()"};
+    }
+  
+  TiXmlDocument* XMLDoc = new TiXmlDocument( path);
+  // load the campaign document
+  if( !XMLDoc->LoadFile())
+    //this->glmis->step();
+  
   {
-		PRINTF0("World has no path specified for loading");
-		return (ErrorMessage){213,"Path not specified","World::load()"};
+    // report an error
+    PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
+    delete XMLDoc;
+    return (ErrorMessage){213,"XML File parsing error","World::load()"};
   }
   
-	TiXmlDocument* XMLDoc = new TiXmlDocument( path);
-	// load the campaign document
-	if( !XMLDoc->LoadFile())
-      this->glmis->step();
-
+  // check basic validity
+  TiXmlElement* root = XMLDoc->RootElement();
+  assert( root != NULL);
+  
+  if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
+    {
+      // report an error
+      PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
+      delete XMLDoc;
+      return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
+    }
+  
+  // load the parameters
+  // name
+  char* temp;
+  const char* string = grabParameter( root, "name");
+  if( string == NULL)
+    {
+      PRINTF0("World is missing a proper 'name'\n");
+      string = "Unknown";
+      temp = new char[strlen(string + 2)];
+      strcpy( temp, string);
+      this->worldName = temp;
+    }
+  else
+    {
+      temp = new char[strlen(string + 2)];
+      strcpy( temp, string);
+      this->worldName = temp;
+    }
+  
+  
+  // find WorldEntities
+  TiXmlElement* element = root->FirstChildElement( "WorldEntities");
+  
+  if( element == NULL)
+    {
+      PRINTF0("World is missing 'WorldEntities'\n");
+    }
+  else
+    {
+      element = element->FirstChildElement();
+      // load Players/Objects/Whatever
+      PRINTF0("Loading WorldEntities\n");
+      while( element != NULL)
 	{
-		// report an error
-		PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
-		delete XMLDoc;
-		return (ErrorMessage){213,"XML File parsing error","World::load()"};
+	  WorldEntity* created = (WorldEntity*) loader->fabricate( element);
+	  if( created != NULL) this->spawn( created);
+	  // if we load a 'Player' we use it as localPlayer
+	  //todo do this more elegant 
+	  if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
+	  element = element->NextSiblingElement();
 	}
-	
-	// check basic validity
-	TiXmlElement* root = XMLDoc->RootElement();
-	assert( root != NULL);
-	
-	if( root == NULL || root->Value() == NULL || strcmp( root->Value(), "WorldDataFile"))
-	{
-		// report an error
-		PRINTF0("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
-		delete XMLDoc;
-		return (ErrorMessage){213,"Path not a WorldDataFile","World::load()"};
-	}
-	
-	// load the parameters
-		// name
-	char* temp;
-	const char* string = grabParameter( root, "name");
-	if( string == NULL)
-	{
-		PRINTF0("World is missing a proper 'name'\n");
-		string = "Unknown";
-		temp = new char[strlen(string + 2)];
-		strcpy( temp, string);
-		this->worldName = temp;
-	}
-	else
-	{
-		temp = new char[strlen(string + 2)];
-		strcpy( temp, string);
-		this->worldName = temp;
-	}
-	
-	
-	// find WorldEntities
-  TiXmlElement* element = root->FirstChildElement( "WorldEntities");
-  
-  if( element == NULL)
-  {
-		PRINTF0("World is missing 'WorldEntities'\n");
-  }
-  else
-  {
-  	element = element->FirstChildElement();
-	  // load Players/Objects/Whatever
-		PRINTF0("Loading WorldEntities\n");
-		while( element != NULL)
-		{
-			WorldEntity* created = (WorldEntity*) loader->fabricate( element);
-			if( created != NULL) this->spawn( created);
-				// if we load a 'Player' we use it as localPlayer
-				//todo do this more elegant 
-			 if( element->Value() != NULL && !strcmp( element->Value(), "Player")) localPlayer = (Player*) created;
-			element = element->NextSiblingElement();
-		}
-		PRINTF0("Done loading WorldEntities\n");
-	}
-	
-	// find Track
+      PRINTF0("Done loading WorldEntities\n");
+    }
+  
+  // find Track
   element = root->FirstChildElement( "Track");
   if( element == NULL)
-  {
-		PRINTF0("World is missing a 'Track'\n");
-  }
+    {
+      PRINTF0("============>>>>>>>>>>>>>>>>>World is missing a 'Track'\n");
+    }
   else
-  {	
-  	//load track
- 		PRINTF0("Loading Track\n");
- 		trackManager = TrackManager::getInstance();
-  	trackManager->loadTrack( element);
-  	trackManager->finalize();
-		PRINTF0("Done loading Track\n");
-	}
-	
-	// free the XML data
-	delete XMLDoc;
-	
-	// finalize world
-	  // initialize Font
-	  testFont = new FontSet();
-	  testFont->buildFont("../data/pictures/font.tga");
-	
-		// create null parent
-    this->nullParent = NullParent::getInstance ();
-    this->nullParent->setName ("NullParent");
-    
-    // finalize myPlayer
-		if( localPlayer == NULL)
-		{
-			PRINTF0("No Player specified in World '%s'\n", this->worldName);
-			return (ErrorMessage){213,"No Player defined","World::load()"};
-		}
-		
-    	// bind input
-    Orxonox *orx = Orxonox::getInstance ();
-    orx->getLocalInput()->bind (localPlayer);
-    
-    	// bind camera
-    this->localCamera = new Camera();
-    this->localCamera->setName ("camera");
-    //this->localCamera->bind (localPlayer);
-    this->localPlayer->addChild (this->localCamera);
-
-	
-	// stuff beyond this point remains to be loaded properly
-	
-      /*monitor progress*/
+    {	
+      //load track
+      PRINTF0("============>>>>>>>>>>>>>>>>Loading Track\n");
+      trackManager = TrackManager::getInstance();
+      trackManager->loadTrack( element);
+      trackManager->finalize();
+      PRINTF0("============>>>>>>>>>>>>>>>>Done loading Track\n");
+    }
+  
+  // free the XML data
+  delete XMLDoc;
+  
+  // finalize world
+  // initialize Font
+  testFont = new FontSet();
+  testFont->buildFont("../data/pictures/font.tga");
+  
+  // create null parent
+  this->nullParent = NullParent::getInstance ();
+  this->nullParent->setName ("NullParent");
+  
+  // finalize myPlayer
+  if( localPlayer == NULL)
+    {
+      PRINTF0("No Player specified in World '%s'\n", this->worldName);
+      return (ErrorMessage){213,"No Player defined","World::load()"};
+    }
+  
+  // bind input
+  Orxonox *orx = Orxonox::getInstance ();
+  orx->getLocalInput()->bind (localPlayer);
+  
+  // bind camera
+  this->localCamera = new Camera();
+  this->localCamera->setName ("camera");
+  //this->localCamera->bind (localPlayer);
+  this->localPlayer->addChild (this->localCamera);
+  
+  
+  // stuff beyond this point remains to be loaded properly
+  
+  /*monitor progress*/
   //  this->glmis->step();
-
-      // LIGHT initialisation
-      lightMan = LightManager::getInstance();
-      lightMan->setAmbientColor(.1,.1,.1);
-      lightMan->addLight();
-      //      lightMan->setAttenuation(1.0, .01, 0.0);
-      //      lightMan->setDiffuseColor(1,1,1);
-      //  lightMan->addLight(1);
-      //  lightMan->setPosition(20, 10, -20);
-      //  lightMan->setDiffuseColor(0,0,0);
-      lightMan->debug();
-	    lightMan->setPosition(-5.0, 10.0, -40.0);
-
-
-	    // Create SkySphere
-	    this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
-	    this->skySphere->setName("SkySphere");
-	    this->localCamera->addChild(this->skySphere);
-	    this->skySphere->setMode(PNODE_MOVEMENT);
-
-
-	    //	    trackManager->setBindSlave(env);
-	    PNode* tn = trackManager->getTrackNode();
-	    tn->addChild(this->localPlayer);
-
-	    //localCamera->setParent(TrackNode::getInstance());
-	    tn->addChild(this->localCamera);
-	    //	    localCamera->lookAt(tn);
-	    this->localPlayer->setMode(PNODE_ALL);
-	    //Vector* cameraOffset = new Vector (0, 5, -10);
-	    //trackManager->condition(2, LEFTRIGHT, this->localPlayer);
-
+  
+  // LIGHT initialisation
+  lightMan = LightManager::getInstance();
+  lightMan->setAmbientColor(.1,.1,.1);
+  lightMan->addLight();
+  //      lightMan->setAttenuation(1.0, .01, 0.0);
+  //      lightMan->setDiffuseColor(1,1,1);
+  //  lightMan->addLight(1);
+  //  lightMan->setPosition(20, 10, -20);
+  //  lightMan->setDiffuseColor(0,0,0);
+  lightMan->debug();
+  lightMan->setPosition(-5.0, 10.0, -40.0);
+  
+  
+  // Create SkySphere
+  this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
+  this->skySphere->setName("SkySphere");
+  this->localCamera->addChild(this->skySphere);
+  this->skySphere->setMode(PNODE_MOVEMENT);
+  
+  
+  //	    trackManager->setBindSlave(env);
+  PNode* tn = trackManager->getTrackNode();
+  tn->addChild(this->localPlayer);
+  
+  //localCamera->setParent(TrackNode::getInstance());
+  tn->addChild(this->localCamera);
+  //	    localCamera->lookAt(tn);
+  this->localPlayer->setMode(PNODE_ALL);
+  //Vector* cameraOffset = new Vector (0, 5, -10);
+  //trackManager->condition(2, LEFTRIGHT, this->localPlayer);
+  
   // initialize debug coord system
   objectList = glGenLists(1);
   glNewList (objectList, GL_COMPILE);
- 
+  
   trackManager->drawGraph(.01);
   trackManager->debug(2);
@@ -697,5 +699,5 @@
       this->tick ();
       // Update the state
-      this->update ();      
+      this->update ();     
       // Process collision
      this->collide ();
