Index: /orxonox/branches/ll2trunktemp/src/factory.cc
===================================================================
--- /orxonox/branches/ll2trunktemp/src/factory.cc	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/factory.cc	(revision 4004)
@@ -30,7 +30,7 @@
    set everything to zero and define classname
 */
-Factory::Factory ()
+Factory::Factory (const char* name)
 {
-  classname = "NULL";
+  this->setClassname(name);
   next = NULL;
   
@@ -45,10 +45,19 @@
 Factory::~Factory ()
 {
-  printf("%s\n", this->classname);
-  Factory* tmpDel = this->next;
-  this->next = NULL;
-  //  if (tmpDel)
-  //    delete tmpDel;
+  //  printf("%s\n", this->classname);
+  //  Factory* tmpDel = this->next;
+  //  this->next = NULL;
+  if (this->next)
+    delete this->next;
 }
+
+void Factory::setClassname(const char* name)
+{
+  if (classname)
+    delete classname;
+  classname = new char[strlen(name)+1];
+  strcpy(classname, name);
+}
+
 
 /**
Index: /orxonox/branches/ll2trunktemp/src/factory.h
===================================================================
--- /orxonox/branches/ll2trunktemp/src/factory.h	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/factory.h	(revision 4004)
@@ -11,18 +11,11 @@
 #include "xmlparser/tinyxml.h"
 
-#define CREATE_FACTORY(x) \
-		class x ## Factory : public Factory { \
-		 public:	\
-		  x ## Factory (){setClassname( #x );} \
-		  ~x ## Factory () {}; \
-		 private: \
-			BaseObject* fabricate( TiXmlElement* root) \
-			{ \
-				if(!strcmp(root->Value(), getClassname())) return new  x ( root); \
-				else if( getNext() != NULL) return getNext()->fabricate( root); \
-				else return NULL; \
-			} \
-		}; \
-		x ## Factory global_ ## x ## Factory;
+/** 
+    Creates a factory to a Loadable Class.
+    this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
+*/
+#define CREATE_FACTORY(x) tFactory<x>* global_ ## x ## Factory = new tFactory<x>(#x);
+
+
 		
 //! The Factory is
@@ -33,5 +26,5 @@
 
  public:
-  Factory ();
+  Factory (const char* name = NULL);
   ~Factory ();
   
@@ -40,6 +33,6 @@
   void initialize();
   void registerFactory( Factory* factory);
-  void setClassname(char* name) {classname = name;}
-  char* getClassname() {return classname;};
+  void setClassname(const char* name);
+  const char* getClassname() {return classname;};
   void setNext( Factory* factory) {next = factory;}
   Factory* getNext() {return next;}
@@ -51,8 +44,43 @@
 };
 
+template<class T> class tFactory : public Factory
+{
+ public:
+  tFactory(const char* name);
+  virtual ~tFactory();
+  
+  private:
+  BaseObject* fabricate( TiXmlElement* root);
+};
+
+template<class T>
+tFactory<T>::tFactory(const char* name) : Factory(name)
+{
+  printf("fileName: %s\n", name);
+}
+  
+
+template<class T>
+tFactory<T>::~tFactory()
+{}
+
+template<class T>
+BaseObject* tFactory<T>::fabricate( TiXmlElement* root) 
+{ 
+  if(!strcmp(root->Value(), getClassname()))
+    return new T ( root);
+  else if( getNext() != NULL) 
+    return getNext()->fabricate( root);
+  else 
+    return NULL;
+}
+
 // helper function
 
 const char* grabParameter( TiXmlElement* root, const char* name);
 
+
+
+
 #endif /* _FACTORY_H */
 
Index: /orxonox/branches/ll2trunktemp/src/game_loader.cc
===================================================================
--- /orxonox/branches/ll2trunktemp/src/game_loader.cc	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/game_loader.cc	(revision 4004)
@@ -25,4 +25,5 @@
 #include "command_node.h"
 #include "vector.h"
+#include "factory.h"
 
 #include <string.h>
@@ -188,5 +189,5 @@
     {
       // report an error
-      PRINTF0("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
+      PRINTF(0)("Specified XML File is not an orxonox campaign file (Campaign element missing)\n");
       delete XMLDoc;
       return NULL;
Index: /orxonox/branches/ll2trunktemp/src/game_loader.h
===================================================================
--- /orxonox/branches/ll2trunktemp/src/game_loader.h	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/game_loader.h	(revision 4004)
@@ -10,4 +10,5 @@
 #include "story_def.h"
 #include "comincl.h"
+
 
 //-----------------------------------------------------------------------------
Index: /orxonox/branches/ll2trunktemp/src/orxonox.cc
===================================================================
--- /orxonox/branches/ll2trunktemp/src/orxonox.cc	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/orxonox.cc	(revision 4004)
@@ -34,4 +34,5 @@
 #include "resource_manager.h"
 #include "text_engine.h"
+#include "factory.h"
 
 #include <string.h>
Index: /orxonox/branches/ll2trunktemp/src/story_entities/world.cc
===================================================================
--- /orxonox/branches/ll2trunktemp/src/story_entities/world.cc	(revision 4003)
+++ /orxonox/branches/ll2trunktemp/src/story_entities/world.cc	(revision 4004)
@@ -114,5 +114,5 @@
 }
 
-CREATE_FACTORY(World)
+CREATE_FACTORY(World);
 
 World::World( TiXmlElement* root)
