Index: orxonox/branches/nico/src/campaign.cc
===================================================================
--- orxonox/branches/nico/src/campaign.cc	(revision 3021)
+++ orxonox/branches/nico/src/campaign.cc	(revision 3238)
@@ -34,5 +34,5 @@
 
 
-Error Campaign::init()
+ErrorMessage Campaign::init()
 {
   this->isInit = true;
@@ -48,5 +48,5 @@
     want to queue up in the campaign.
 */
-void Campaign::addEntity(StoryEntity* se, Uint32 storyID)
+void Campaign::addEntity(StoryEntity* se, int storyID)
 {
   se->setStoryID(storyID);
@@ -60,5 +60,5 @@
 
 
-void Campaign::removeEntity(Uint32 storyID)
+void Campaign::removeEntity(int storyID)
 {
   this->removeEntity(this->getStoryEntity(storyID));
@@ -73,37 +73,45 @@
 
 
-Error Campaign::start()
+ErrorMessage Campaign::start()
 {
   this->start(0);
 }
 
-Error Campaign::start(Uint32 storyID = 0)
+ErrorMessage Campaign::start(int storyID = 0)
 {
   printf("World::start() - starting new StoryEntity Nr:%i\n", storyID);
-  Error errorCode;
-  if(!this->isInit) return errorCode; 
-  if(storyID == WORLD_ID_GAMEEND) return errorCode;
+  ErrorMessage errorCode;
+  if( !this->isInit) return errorCode; 
+  if( storyID == WORLD_ID_GAMEEND) return errorCode;
   this->running = true;
   StoryEntity* se = this->getStoryEntity(storyID);
-  while(se != NULL && this->running)
+  this->currentEntity = se;
+  while( se != NULL && this->running)
     {
-      se = this->getStoryEntity(storyID);
-      this->currentEntity = se;
-      
-      se->displayEntityScreen();
+      se->displayLoadScreen();
       se->load();
       se->init();
-      se->releaseEntityScreen();
+      se->releaseLoadScreen();
       se->start();
+      se->destroy();
+     
+      delete se;
 
       int nextWorldID = se->getNextStoryID();
-      if(nextWorldID == WORLD_ID_GAMEEND) return errorCode;
+      //printf("Campaing::start() - got nextWorldID = %i\n", nextWorldID);
       se = this->getStoryEntity(nextWorldID);
-      if(se == NULL)
-	printf("Campaign::start() - ERROR: world it not found, oh oh...");
+      this->currentEntity = se;
+      if( ( nextWorldID == WORLD_ID_GAMEEND) ||( se == NULL) ) 
+	{
+	  printf("Campaign::start() - quitting campaing story loop\n");
+	  if(se != NULL)
+	    delete se;
+	  return errorCode;
+	}
+      
     }
 }
 
-Error Campaign::stop()
+ErrorMessage Campaign::stop()
 {
   this->running = false;
@@ -111,10 +119,10 @@
     {
       this->currentEntity->stop();
-      delete this->currentEntity;
-      this->currentEntity = NULL;
+      //delete this->currentEntity;
+      //this->currentEntity = NULL;
     }
 }
 
-Error Campaign::pause()
+ErrorMessage Campaign::pause()
 {
   if(this->currentEntity != NULL)
@@ -123,5 +131,5 @@
 
 
-Error Campaign::resume()
+ErrorMessage Campaign::resume()
 {
   if(this->currentEntity != NULL)
@@ -130,27 +138,59 @@
 
 
+void Campaign::destroy()
+{
+  if(this->currentEntity != NULL)
+    {
+      this->currentEntity->destroy();
+      delete this->currentEntity;
+      this->currentEntity = NULL;
+    }
+}
+
+/*
+  \brief this changes to the next level
+*/
 void Campaign::nextLevel()
 {
-  printf("Campaign|nextLevel\n");
-  int nextID = this->currentEntity->getNextStoryID();
-  this->stop();
-  this->start(nextID);
+  printf("Campaign:nextLevel()\n");
+  //int nextID = this->currentEntity->getNextStoryID();
+  //this->stop();
+  //this->start(nextID);
+  this->currentEntity->stop();
 }
 
+/*
+  \brief change to the previous level - not implemented
+
+  this propably useless
+*/
 void Campaign::previousLevel()
 {}
 
 
-StoryEntity* Campaign::getStoryEntity(Uint32 storyID)
+/*
+  \brief lookup a entity with a given id
+  \param story id to be lookuped
+  \returns the entity found or NULL if search ended without match
+*/
+StoryEntity* Campaign::getStoryEntity(int storyID)
 {
+  //printf("Campaing::getStoryEntity(%i) - getting next Entity\n", storyID);
+  if( storyID == WORLD_ID_GAMEEND)
+    return NULL;
   ListTemplate<StoryEntity>* l;
-  StoryEntity* entity;
-  l = this->entities->get_next();  
+  StoryEntity* entity = NULL;
+  l = this->entities->getNext();  
   while( l != NULL) 
     { 
-      entity = l->get_object();
-      l = l->get_next();
-      if(entity->getStoryID() == storyID)
-	return entity;
+      entity = l->getObject();
+      l = l->getNext();
+      int id = entity->getStoryID();
+      //printf("Campaing::getStoryEntity() - now looping, found entity nr=%i\n", id);
+      if(id == storyID)
+	{
+	  //printf("Campaing::getStoryEntity() - yea, this is what we where looking for: %id\n");
+	  return entity;
+	}
     }
   return NULL;
