Index: /orxonox/branches/levelLoader.tmp/src/game_loader.cc
===================================================================
--- /orxonox/branches/levelLoader.tmp/src/game_loader.cc	(revision 3902)
+++ /orxonox/branches/levelLoader.tmp/src/game_loader.cc	(revision 3903)
@@ -15,5 +15,4 @@
    co-programmer: ...
 */
-
 
 #include "game_loader.h"
@@ -25,4 +24,6 @@
 #include "command_node.h"
 #include "vector.h"
+#include "factory.h"
+#include "debug.h"
 
 #include <string.h>
@@ -35,5 +36,8 @@
 
 
-GameLoader::GameLoader () {}
+GameLoader::GameLoader ()
+{
+	first = NULL;
+}
 
 
@@ -164,4 +168,40 @@
      can load everything it needs into memory then.
   */
+  
+  if( name == NULL)
+  {
+		PRINTF0("No filename specified for loading");
+		return NULL;
+  }
+  
+	TiXmlDocument* XMLDoc = new TiXmlDocument( name);
+	// load the campaign document
+	if( !XMLDoc->LoadFile())
+	{
+		// report an error
+		PRINTF0("Error loading XML File: %s @ %d:%d\n", XMLDoc->ErrorDesc(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
+		delete XMLDoc;
+		return NULL;
+	}
+	
+	// check basic validity
+	TiXmlElement* root = XMLDoc->RootElement();
+	assert( root != NULL);
+	
+	if( strcmp( root->Value(), "Campaign"))
+	{
+		// report an error
+		PRINTF0("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
+		delete XMLDoc;
+		return NULL;
+	}
+	
+	// construct campaign
+	Campaign* c = new Campaign( root);
+	
+	// free the XML data
+	delete XMLDoc;
+	
+	return c;
 }
 
@@ -230,2 +270,45 @@
     this->currentCampaign->previousLevel();
 }
+
+
+/**
+   \brief add a Factory to the Factory Q
+   \param factory a Factory to be registered
+*/
+void GameLoader::registerFactory( Factory* factory)
+{
+	assert( factory != NULL);
+	
+	PRINTF0("Registered factory for '%s'\n", factory->getClassname());
+	
+	if( first == NULL) first = factory;
+	else first->registerFactory( factory);
+}
+
+/**
+   \brief load a StoryEntity
+   \param element a XMLElement containing all the needed info
+*/
+BaseObject* GameLoader::fabricate( TiXmlElement* element)
+{
+	assert( element != NULL);
+	
+	if( first == NULL)
+	{
+		PRINTF0("GameLoader does not know any factories, fabricate() failed\n");
+		return NULL;
+	}
+	
+	if( element->Value() != NULL)
+	{
+		PRINTF0("Attempting fabrication of a '%s'\n", element->Value());
+		BaseObject* b = first->fabricate( element);
+		if( b == NULL) PRINTF0("Failed to fabricate a '%s'\n", element->Value());
+		else PRINTF0("Successfully fabricated a '%s'\n", element->Value());
+		return b;
+	}
+	
+	PRINTF0("Fabricate failed, TiXmlElement did not contain a value\n");
+	
+	return NULL;
+}
Index: /orxonox/branches/levelLoader.tmp/src/game_loader.h
===================================================================
--- /orxonox/branches/levelLoader.tmp/src/game_loader.h	(revision 3902)
+++ /orxonox/branches/levelLoader.tmp/src/game_loader.h	(revision 3903)
@@ -9,5 +9,7 @@
 //#include "stdincl.h"
 #include "story_def.h"
+#include "factory.h"
 #include "comincl.h"
+#include "error.h"
 
 //-----------------------------------------------------------------------------
@@ -51,4 +53,7 @@
   ErrorMessage loadDebugCampaign(Uint32 campaignID);
   
+  void registerFactory( Factory* factory);
+  BaseObject* fabricate( TiXmlElement* data);
+  
  private:
   GameLoader ();
@@ -62,4 +67,5 @@
   Campaign* fileToCampaign(char* name);
 
+  Factory* first;
 };
 
Index: /orxonox/branches/levelLoader.tmp/src/util/levelloader/factory.h
===================================================================
--- /orxonox/branches/levelLoader.tmp/src/util/levelloader/factory.h	(revision 3902)
+++ /orxonox/branches/levelLoader.tmp/src/util/levelloader/factory.h	(revision 3903)
@@ -25,4 +25,5 @@
 
 #include "stdincl.h"
+#include "tinyxml.h"
 
 class BaseObject;
@@ -40,5 +41,5 @@
 	virtual BaseObject* fabricate( TiXmlElement* root);
 	void initialize();
-  void registerFactory( Factory* factory);
+	void registerFactory( Factory* factory);
 	void setClassname(char* name) {classname = name;}
 	char* getClassname() {return classname;};
