Index: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	(revision 5477)
+++ trunk/src/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(orxonox_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/Makefile.in
===================================================================
--- trunk/src/lib/Makefile.in	(revision 5477)
+++ trunk/src/lib/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXlibs_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/collision_detection/Makefile.in
===================================================================
--- trunk/src/lib/collision_detection/Makefile.in	(revision 5477)
+++ trunk/src/lib/collision_detection/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXcd_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/event/Makefile.in
===================================================================
--- trunk/src/lib/event/Makefile.in	(revision 5477)
+++ trunk/src/lib/event/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXevent_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/graphics/Makefile.in
===================================================================
--- trunk/src/lib/graphics/Makefile.in	(revision 5477)
+++ trunk/src/lib/graphics/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXgraphics_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/graphics/importer/Makefile.in
===================================================================
--- trunk/src/lib/graphics/importer/Makefile.in	(revision 5477)
+++ trunk/src/lib/graphics/importer/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXimporter_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/graphics/spatial_separation/Makefile.in
===================================================================
--- trunk/src/lib/graphics/spatial_separation/Makefile.in	(revision 5477)
+++ trunk/src/lib/graphics/spatial_separation/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXquadtree_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/gui/Makefile.in
===================================================================
--- trunk/src/lib/gui/Makefile.in	(revision 5477)
+++ trunk/src/lib/gui/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
Index: trunk/src/lib/gui/gl_gui/Makefile.in
===================================================================
--- trunk/src/lib/gui/gl_gui/Makefile.in	(revision 5477)
+++ trunk/src/lib/gui/gl_gui/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXglgui_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/gui/gtk_gui/Makefile.in
===================================================================
--- trunk/src/lib/gui/gtk_gui/Makefile.in	(revision 5477)
+++ trunk/src/lib/gui/gtk_gui/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXgui_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/particles/Makefile.in
===================================================================
--- trunk/src/lib/particles/Makefile.in	(revision 5477)
+++ trunk/src/lib/particles/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXparticles_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/physics/Makefile.in
===================================================================
--- trunk/src/lib/physics/Makefile.in	(revision 5477)
+++ trunk/src/lib/physics/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXphysics_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/shell/Makefile.in
===================================================================
--- trunk/src/lib/shell/Makefile.in	(revision 5477)
+++ trunk/src/lib/shell/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXshell_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/sound/Makefile.in
===================================================================
--- trunk/src/lib/sound/Makefile.in	(revision 5477)
+++ trunk/src/lib/sound/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXsound_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/lib/tinyxml/Makefile.in
===================================================================
--- trunk/src/lib/tinyxml/Makefile.in	(revision 5477)
+++ trunk/src/lib/tinyxml/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libtinyxml_a_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/orxonox.cc
===================================================================
--- trunk/src/orxonox.cc	(revision 5477)
+++ trunk/src/orxonox.cc	(revision 5479)
@@ -285,4 +285,7 @@
               CONFIG_SECTION_DATA,
               CONFIG_NAME_DATADIR);
+    Gui* gui = new Gui(argc, argv);
+    gui->startGui();
+    delete gui;
     exit(-1);
   }
Index: trunk/src/subprojects/Makefile.in
===================================================================
--- trunk/src/subprojects/Makefile.in	(revision 5477)
+++ trunk/src/subprojects/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
Index: trunk/src/subprojects/collision_detection/Makefile.in
===================================================================
--- trunk/src/subprojects/collision_detection/Makefile.in	(revision 5477)
+++ trunk/src/subprojects/collision_detection/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -14,6 +14,4 @@
 
 @SET_MAKE@
-
-SOURCES = $(collision_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/subprojects/importer/Makefile.in
===================================================================
--- trunk/src/subprojects/importer/Makefile.in	(revision 5477)
+++ trunk/src/subprojects/importer/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -14,6 +14,4 @@
 
 @SET_MAKE@
-
-SOURCES = $(importer_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/subprojects/particles/Makefile.in
===================================================================
--- trunk/src/subprojects/particles/Makefile.in	(revision 5477)
+++ trunk/src/subprojects/particles/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -14,6 +14,4 @@
 
 @SET_MAKE@
-
-SOURCES = $(particles_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/subprojects/testmain/Makefile.in
===================================================================
--- trunk/src/subprojects/testmain/Makefile.in	(revision 5477)
+++ trunk/src/subprojects/testmain/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(testmain_SOURCES)
 
 srcdir = @srcdir@
Index: trunk/src/util/Makefile.am
===================================================================
--- trunk/src/util/Makefile.am	(revision 5477)
+++ trunk/src/util/Makefile.am	(revision 5479)
@@ -6,5 +6,4 @@
 libORXutils_a_SOURCES = fast_factory.cc \
 			garbage_collector.cc \
-			resource_manager.cc \
 			state.cc \
 			user_control.cc \
@@ -12,4 +11,5 @@
 			animation/animation.cc \
 			animation/animation_player.cc \
+			loading/resource_manager.cc \
 			loading/factory.cc \
 			loading/game_loader.cc \
@@ -21,5 +21,4 @@
 noinst_HEADERS =        fast_factory.h \
 			garbage_collector.h \
-			resource_manager.h \
 			state.h \
 			user_control.h \
@@ -28,4 +27,5 @@
 			animation/animation_player.h \
 			animation/t_animation.h \
+			loading/resource_manager.h \
 			loading/factory.h \
 			loading/game_loader.h \
Index: trunk/src/util/Makefile.in
===================================================================
--- trunk/src/util/Makefile.in	(revision 5477)
+++ trunk/src/util/Makefile.in	(revision 5479)
@@ -1,3 +1,3 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
@@ -15,6 +15,4 @@
 @SET_MAKE@
 
-
-SOURCES = $(libORXutils_a_SOURCES)
 
 srcdir = @srcdir@
@@ -57,8 +55,9 @@
 libORXutils_a_LIBADD =
 am_libORXutils_a_OBJECTS = fast_factory.$(OBJEXT) \
-	garbage_collector.$(OBJEXT) resource_manager.$(OBJEXT) \
-	state.$(OBJEXT) user_control.$(OBJEXT) animation3d.$(OBJEXT) \
+	garbage_collector.$(OBJEXT) state.$(OBJEXT) \
+	user_control.$(OBJEXT) animation3d.$(OBJEXT) \
 	animation.$(OBJEXT) animation_player.$(OBJEXT) \
-	factory.$(OBJEXT) game_loader.$(OBJEXT) load_param.$(OBJEXT) \
+	resource_manager.$(OBJEXT) factory.$(OBJEXT) \
+	game_loader.$(OBJEXT) load_param.$(OBJEXT) \
 	pilot_node.$(OBJEXT) track_manager.$(OBJEXT) \
 	track_node.$(OBJEXT)
@@ -192,5 +191,4 @@
 libORXutils_a_SOURCES = fast_factory.cc \
 			garbage_collector.cc \
-			resource_manager.cc \
 			state.cc \
 			user_control.cc \
@@ -198,4 +196,5 @@
 			animation/animation.cc \
 			animation/animation_player.cc \
+			loading/resource_manager.cc \
 			loading/factory.cc \
 			loading/game_loader.cc \
@@ -207,5 +206,4 @@
 noinst_HEADERS = fast_factory.h \
 			garbage_collector.h \
-			resource_manager.h \
 			state.h \
 			user_control.h \
@@ -214,4 +212,5 @@
 			animation/animation_player.h \
 			animation/t_animation.h \
+			loading/resource_manager.h \
 			loading/factory.h \
 			loading/game_loader.h \
@@ -338,4 +337,18 @@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o animation_player.obj `if test -f 'animation/animation_player.cc'; then $(CYGPATH_W) 'animation/animation_player.cc'; else $(CYGPATH_W) '$(srcdir)/animation/animation_player.cc'; fi`
+
+resource_manager.o: loading/resource_manager.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.o -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.o `test -f 'loading/resource_manager.cc' || echo '$(srcdir)/'`loading/resource_manager.cc; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/resource_manager.Tpo" "$(DEPDIR)/resource_manager.Po"; else rm -f "$(DEPDIR)/resource_manager.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='loading/resource_manager.cc' object='resource_manager.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.o `test -f 'loading/resource_manager.cc' || echo '$(srcdir)/'`loading/resource_manager.cc
+
+resource_manager.obj: loading/resource_manager.cc
+@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.obj -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.obj `if test -f 'loading/resource_manager.cc'; then $(CYGPATH_W) 'loading/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/loading/resource_manager.cc'; fi`; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/resource_manager.Tpo" "$(DEPDIR)/resource_manager.Po"; else rm -f "$(DEPDIR)/resource_manager.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='loading/resource_manager.cc' object='resource_manager.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.obj `if test -f 'loading/resource_manager.cc'; then $(CYGPATH_W) 'loading/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/loading/resource_manager.cc'; fi`
 
 factory.o: loading/factory.cc
Index: trunk/src/util/loading/resource_manager.cc
===================================================================
--- trunk/src/util/loading/resource_manager.cc	(revision 5479)
+++ trunk/src/util/loading/resource_manager.cc	(revision 5479)
@@ -0,0 +1,980 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
+
+#include "resource_manager.h"
+
+#include "debug.h"
+
+// different resource Types
+#ifndef NO_MODEL
+#include "objModel.h"
+#include "primitive_model.h"
+#include "md2Model.h"
+#endif /* NO_MODEL */
+#ifndef NO_TEXTURES
+#include "texture.h"
+#endif /* NO_TEXTURES */
+#ifndef NO_TEXT
+#include "font.h"
+#endif /* NO_TEXT */
+#ifndef NO_AUDIO
+#include "sound_engine.h"
+#include "ogg_player.h"
+#endif /* NO_AUDIO */
+#ifndef NO_SHADERS
+#include "shader.h"
+#endif /* NO_SHADERS */
+
+#include "list.h"
+#include "sdlincl.h"
+
+// File Handling Includes
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+using namespace std;
+
+/**
+ *  standard constructor
+*/
+ResourceManager::ResourceManager ()
+{
+  this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
+  this->setName("ResourceManager");
+
+  this->dataDir = new char[3];
+  strcpy(this->dataDir, "./");
+  this->setDataDir("./data");
+  this->imageDirs = new tList<char>;
+  this->resourceList = new tList<Resource>;
+}
+
+//! Singleton Reference to the ResourceManager
+ResourceManager* ResourceManager::singletonRef = NULL;
+
+/**
+ *  standard destructor
+*/
+ResourceManager::~ResourceManager ()
+{
+  // deleting the Resources-List
+  this->unloadAllByPriority(RP_GAME);
+
+  if (this->resourceList->getSize() > 0)
+    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
+
+  delete this->resourceList;
+  // deleting the Directorie Lists
+  tIterator<char>* tmpIt = imageDirs->getIterator();
+  char* tmpDir = tmpIt->firstElement();
+  while(tmpDir)
+    {
+      delete[] tmpDir;
+      tmpDir = tmpIt->nextElement();
+    }
+  delete tmpIt;
+  delete this->imageDirs;
+
+  delete[] this->dataDir;
+
+  ResourceManager::singletonRef = NULL;
+}
+
+/**
+ *  sets the data main directory
+ * @param dataDir the DataDirectory.
+*/
+bool ResourceManager::setDataDir(const char* dataDir)
+{
+  char* realDir = ResourceManager::homeDirCheck(dataDir);
+  if (isDir(realDir))
+    {
+      delete[] this->dataDir;
+      if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\')
+      {
+        this->dataDir = new char[strlen(realDir)+1];
+        strcpy(this->dataDir, realDir);
+      }
+      else
+      {
+        this->dataDir = new char[strlen(realDir)+2];
+        strcpy(this->dataDir, realDir);
+        this->dataDir[strlen(realDir)] = '/';
+        this->dataDir[strlen(realDir)+1] = '\0';
+      }
+      delete[] realDir;
+      return true;
+    }
+  else
+    {
+      PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir);
+      delete[] realDir;
+      return false;
+    }
+}
+
+/**
+ *  checks for the DataDirectory, by looking if
+ * @param fileInside is inisde??
+*/
+bool ResourceManager::checkDataDir(const char* fileInside)
+{
+  bool retVal;
+  if (!isDir(this->dataDir))
+    {
+      PRINTF(1)("%s is not a directory\n", this->dataDir);
+      return false;
+    }
+
+  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
+  sprintf(testFile, "%s%s", this->dataDir, fileInside);
+  retVal = isFile(testFile);
+  delete[] testFile;
+  return retVal;
+}
+
+#ifndef NO_TEXTURES
+/**
+ *  adds a new Path for Images
+ * @param imageDir The path to insert
+ * @returns true, if the Path was well and injected (or already existent within the list)
+   false otherwise
+*/
+bool ResourceManager::addImageDir(const char* imageDir)
+{
+  if (imageDir == NULL)
+    return false;
+
+  char* newDir;
+  if (imageDir[strlen(imageDir)-1] == '/' || imageDir[strlen(imageDir)-1] == '\\')
+  {
+    newDir = new char[strlen(imageDir)+1];
+    strcpy(newDir, imageDir);
+  }
+  else
+  {
+    newDir = new char[strlen(imageDir)+2];
+    strcpy(newDir, imageDir);
+    newDir[strlen(imageDir)] = '/';
+    newDir[strlen(imageDir)+1] = '\0';
+  }
+  // check if the param is a Directory
+  if (isDir(newDir))
+    {
+      // check if the Directory has been added before
+      tIterator<char>* tmpImageDirs = imageDirs->getIterator();
+      char* tmpDir = tmpImageDirs->firstElement();
+      while(tmpDir)
+        {
+          if (!strcmp(tmpDir, newDir))
+            {
+              PRINTF(3)("Path %s already loaded\n", newDir);
+              delete[] newDir;
+              delete tmpImageDirs;
+              return true;
+            }
+          tmpDir = tmpImageDirs->nextElement();
+        }
+      delete tmpImageDirs;
+
+      // adding the directory to the List
+      this->imageDirs->add(newDir);
+      return true;
+    }
+  else
+    {
+      PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir);
+      delete[] newDir;
+      return false;
+    }
+}
+#endif /* NO_TEXTURES */
+
+/**
+ *  loads resources
+ * @param fileName: The fileName of the resource to load
+ * @param prio: The ResourcePriority of this resource (will only be increased)
+ * @param param1: an additional option to parse (see the constuctors for more help)
+ * @param param2: an additional option to parse (see the constuctors for more help)
+ * @param param3: an additional option to parse (see the constuctors for more help)
+ * @returns a pointer to a desired Resource.
+*/
+BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio, void* param1, void* param2, void* param3)
+{
+  if (fileName == NULL)
+    return NULL;
+  ResourceType tmpType;
+#ifndef NO_MODEL
+#define __IF_OK
+  if (!strncasecmp(fileName+(strlen(fileName)-4), ".obj", 4))
+    tmpType = OBJ;
+  else if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4))
+    tmpType = MD2;
+  else if (!strcasecmp(fileName, "cube") ||
+           !strcasecmp(fileName, "sphere") ||
+           !strcasecmp(fileName, "plane") ||
+           !strcasecmp(fileName, "cylinder") ||
+           !strcasecmp(fileName, "cone"))
+    tmpType = PRIM;
+#endif /* NO_MODEL */
+#ifndef NO_AUDIO
+#ifdef __IF_OK
+  else
+#endif
+#define __IF_OK
+  if (!strncasecmp(fileName+(strlen(fileName)-4), ".wav", 4))
+    tmpType = WAV;
+  else if (!strncasecmp(fileName+(strlen(fileName)-4), ".mp3", 4))
+    tmpType = MP3;
+  else if (!strncasecmp(fileName+(strlen(fileName)-4), ".ogg", 4))
+    tmpType = OGG;
+#endif /* NO_AUDIO */
+#ifndef NO_TEXT
+#ifdef __IF_OK
+  else
+#endif
+#define __IF_OK
+ if (!strncasecmp(fileName+(strlen(fileName)-4), ".ttf", 4))
+    tmpType = TTF;
+#endif /* NO_TEXT */
+#ifndef NO_SHADERS
+#ifdef __IF_OK
+  else
+#endif
+#define __IF_OK
+ if (!strncasecmp(fileName+(strlen(fileName)-5), ".vert", 5))
+    tmpType = SHADER;
+#endif /* NO_SHADERS */
+#ifndef NO_TEXTURES
+#ifdef __IF_OK
+  else
+#else
+  if
+#endif
+   tmpType = IMAGE;
+#endif /* NO_TEXTURES */
+#undef __IF_OK
+  return this->load(fileName, tmpType, prio, param1, param2, param3);
+}
+
+/**
+ * loads resources
+ * @param fileName: The fileName of the resource to load
+ * @param type: The Type of Resource to load.
+ * @param prio: The ResourcePriority of this resource (will only be increased)
+ * @param param1: an additional option to parse (see the constuctors for more help)
+ * @param param2: an additional option to parse (see the constuctors for more help)
+ * @param param3: an additional option to parse (see the constuctors for more help)
+ * @returns a pointer to a desired Resource.
+*/
+BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
+                            void* param1, void* param2, void* param3)
+{
+  if (fileName == NULL)
+    return NULL;
+
+  // searching if the resource was loaded before.
+  Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2, param3);
+  if (tmpResource != NULL) // if the resource was loaded before.
+    {
+      PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
+      tmpResource->count++;
+      if(tmpResource->prio < prio)
+        tmpResource->prio = prio;
+    }
+  else
+    {
+      // Setting up the new Resource
+      tmpResource = new Resource;
+      tmpResource->count = 1;
+      tmpResource->type = type;
+      tmpResource->prio = prio;
+      tmpResource->pointer = NULL;
+      tmpResource->name = new char[strlen(fileName)+1];
+      strcpy(tmpResource->name, fileName);
+
+      // creating the full name. (directoryName + FileName)
+      char* fullName = ResourceManager::getFullName(fileName);
+      // Checking for the type of resource \see ResourceType
+      switch(type)
+        {
+#ifndef NO_MODEL
+        case OBJ:
+          if (param1)
+            tmpResource->modelSize = *(float*)param1;
+          else
+            tmpResource->modelSize = 1.0;
+
+          if(ResourceManager::isFile(fullName))
+            tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
+          else
+            {
+              PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName, dataDir);
+              tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize);
+            }
+          break;
+        case PRIM:
+          if (param1)
+            tmpResource->modelSize = *(float*)param1;
+          else
+            tmpResource->modelSize = 1.0;
+
+          if (!strcmp(tmpResource->name, "cube"))
+            tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize);
+          else if (!strcmp(tmpResource->name, "sphere"))
+            tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize);
+          else if (!strcmp(tmpResource->name, "plane"))
+            tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize);
+          else if (!strcmp(tmpResource->name, "cylinder"))
+            tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize);
+          else if (!strcmp(tmpResource->name, "cone"))
+            tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize);
+          break;
+        case MD2:
+          if(ResourceManager::isFile(fullName))
+            {
+              if (param1 != NULL)
+                {
+                  tmpResource->secFileName = new char[strlen((const char*)param1)+1];
+                  strcpy(tmpResource->secFileName, (const char*) param1);
+                }
+              else
+                tmpResource->secFileName = NULL;
+              tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
+            }
+              break;
+#endif /* NO_MODEL */
+#ifndef NO_TEXT
+        case TTF:
+            if (param1 != NULL)
+              tmpResource->ttfSize = *(unsigned int*)param1;
+            else
+              tmpResource->ttfSize = FONT_DEFAULT_RENDER_SIZE;
+
+          if(isFile(fullName))
+            tmpResource->pointer = new Font(fullName, tmpResource->ttfSize);
+          else
+            PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName, this->dataDir);
+          break;
+#endif /* NO_TEXT */
+#ifndef NO_AUDIO
+        case WAV:
+          if(isFile(fullName))
+            tmpResource->pointer = new SoundBuffer(fullName);
+          break;
+        case OGG:
+          if (isFile(fullName))
+            tmpResource->pointer = new OggPlayer(fullName);
+          break;
+#endif /* NO_AUDIO */
+#ifndef NO_TEXTURES
+        case IMAGE:
+          if(isFile(fullName))
+            {
+              PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
+              tmpResource->pointer = new Texture(fullName);
+            }
+          else
+            {
+              char* tmpDir;
+              tIterator<char>* iterator = imageDirs->getIterator();
+              tmpDir = iterator->firstElement();
+              while(tmpDir)
+                {
+                  char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
+                  sprintf(imgName, "%s%s", tmpDir, fileName);
+                  if(isFile(imgName))
+                    {
+                      PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
+                      tmpResource->pointer = new Texture(imgName);
+                      delete[] imgName;
+                      break;
+                    }
+                  delete[] imgName;
+                  tmpDir = iterator->nextElement();
+                }
+              delete iterator;
+            }
+          if(!tmpResource)
+             PRINTF(2)("!!Image %s not Found!!\n", fileName);
+          break;
+#endif /* NO_TEXTURES */
+#ifndef NO_SHADERS
+          case SHADER:
+            if(ResourceManager::isFile(fullName))
+            {
+              if (param1 != NULL)
+              {
+                char* secFullName = ResourceManager::getFullName((const char*)param1);
+                if (ResourceManager::isFile(secFullName))
+                {
+                  tmpResource->secFileName = new char[strlen((const char*)param1)+1];
+                  strcpy(tmpResource->secFileName, (const char*) param1);
+                  tmpResource->pointer = new Shader(fullName, secFullName);
+                }
+                delete[] secFullName;
+              }
+              else
+              {
+                tmpResource->secFileName = NULL;
+                tmpResource->pointer = new Shader(fullName, NULL);
+              }
+            }
+            break;
+#endif /* NO_SHADERS */
+        default:
+          tmpResource->pointer = NULL;
+          PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name);
+          break;
+        }
+      if (tmpResource->pointer != NULL)
+        this->resourceList->add(tmpResource);
+      delete[] fullName;
+    }
+  if (tmpResource->pointer != NULL)
+    return tmpResource->pointer;
+  else
+    {
+      PRINTF(2)("Resource %s could not be loaded\n", fileName);
+      delete[] tmpResource->name;
+      delete tmpResource;
+      return NULL;
+    }
+}
+
+/**
+ * unloads a Resource
+ * @param pointer: The pointer to free
+ * @param prio: the PriorityLevel to unload this resource
+ * @returns true if successful (pointer found, and deleted), false otherwise
+*/
+bool ResourceManager::unload(void* pointer, ResourcePriority prio)
+{
+  if (pointer == NULL)
+    return false;
+  // if pointer is existent. and only one resource of this type exists.
+  Resource* tmpResource = this->locateResourceByPointer(pointer);
+  if (tmpResource != NULL)
+    return unload(tmpResource, prio);
+  else
+  {
+    PRINTF(2)("Resource not Found %p\n", pointer);
+    return false;
+  }
+}
+
+/**
+ * unloads a Resource
+ * @param resource: The resource to unloade
+ * @param prio the PriorityLevel to unload this resource
+ * @returns true on success, false otherwise.
+*/
+bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
+{
+  if (resource == NULL)
+    return false;
+  if (resource->count > 0)
+    resource->count--;
+
+  if (resource->prio <= prio)
+    {
+      if (resource->count == 0)
+        {
+          // deleting the Resource
+          switch(resource->type)
+            {
+#ifndef NO_MODEL
+            case OBJ:
+            case PRIM:
+              delete (Model*)resource->pointer;
+              break;
+            case MD2:
+              delete (MD2Data*)resource->pointer;
+              break;
+#endif /* NO_MODEL */
+#ifndef NO_AUDIO
+            case WAV:
+              delete (SoundBuffer*)resource->pointer;
+              break;
+            case OGG:
+              delete (OggPlayer*)resource->pointer;
+              break;
+#endif /* NO_AUDIO */
+#ifndef NO_TEXT
+            case TTF:
+              delete (Font*)resource->pointer;
+              break;
+#endif /* NO_TEXT */
+#ifndef NO_TEXTURES
+            case IMAGE:
+              delete (Texture*)resource->pointer;
+              break;
+#endif /* NO_TEXTURES */
+#ifndef NO_SHADERS
+            case SHADER:
+              delete (Shader*)resource->pointer;
+              break;
+#endif /* NO_SHADERS */
+            default:
+              PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
+              return false;
+              break;
+            }
+          // deleting the List Entry:
+          PRINTF(4)("Resource %s safely removed.\n", resource->name);
+          delete[] resource->name;
+          this->resourceList->remove(resource);
+          delete resource;
+        }
+      else
+        PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
+    }
+  else
+    PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name);
+  return true;
+}
+
+
+/**
+ * unloads all alocated Memory of Resources with a pririty lower than prio
+ * @param prio The priority to delete
+*/
+bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
+{
+  tIterator<Resource>* iterator = resourceList->getIterator();
+  Resource* enumRes = iterator->lastElement();
+  while (enumRes)
+    {
+      if (enumRes->prio <= prio)
+        if (enumRes->count == 0)
+          unload(enumRes, prio);
+        else
+          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
+                   enumRes->name, enumRes->count);
+      //enumRes = resourceList->nextElement();
+      enumRes = iterator->prevElement();
+    }
+  delete iterator;
+}
+
+/**
+ * Searches for a Resource by some information
+ * @param fileName: The name to look for
+ * @param type the Type of resource to locate.
+ * @param param1: an additional option to parse (see the constuctors for more help)
+ * @param param2: an additional option to parse (see the constuctors for more help)
+ * @param param3: an additional option to parse (see the constuctors for more help)
+ * @returns a Pointer to the Resource if found, NULL otherwise.
+*/
+Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
+                                                void* param1, void* param2, void* param3)
+{
+  //  Resource* enumRes = resourceList->enumerate();
+  tIterator<Resource>* iterator = resourceList->getIterator();
+  Resource* enumRes = iterator->firstElement();
+  while (enumRes)
+    {
+      if (enumRes->type == type && !strcmp(fileName, enumRes->name))
+        {
+          bool match = false;
+
+          switch (type)
+            {
+#ifndef NO_MODEL
+            case PRIM:
+            case OBJ:
+              if (!param1)
+                {
+                  if (enumRes->modelSize == 1.0)
+                    match = true;
+                }
+              else if (enumRes->modelSize == *(float*)param1)
+                match = true;
+              break;
+            case MD2:
+              if (!param1)
+                {
+                  if (enumRes->secFileName == NULL)
+                    match = true;
+                }
+              else if (!strcmp(enumRes->secFileName, (const char*)param1))
+                match = true;
+              break;
+#endif /* NO_MODEL */
+#ifndef NO_TEXT
+            case TTF:
+              if (param1 == NULL)
+                {
+                  if (enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)
+                    match = true;
+                }
+              else if (enumRes->ttfSize == *(unsigned int*)param1)
+                match = true;
+              break;
+#endif /* NO_TEXT */
+#ifndef NO_SHADERS
+              case SHADER:
+                if (!param1)
+                {
+                  if (enumRes->secFileName == NULL)
+                    match = true;
+                }
+                else if (!strcmp(enumRes->secFileName, (const char*)param1))
+                  match = true;
+#endif /* NO_SHADERS */
+            default:
+              match = true;
+              break;
+            }
+          if (match)
+            {
+              delete iterator;
+              return enumRes;
+            }
+        }
+      enumRes = iterator->nextElement();
+    }
+  delete iterator;
+  return NULL;
+}
+
+/**
+ * Searches for a Resource by Pointer
+ * @param pointer the Pointer to search for
+ * @returns a Pointer to the Resource if found, NULL otherwise.
+*/
+Resource* ResourceManager::locateResourceByPointer(const void* pointer)
+{
+  //  Resource* enumRes = resourceList->enumerate();
+  tIterator<Resource>* iterator = resourceList->getIterator();
+  Resource* enumRes = iterator->firstElement();
+  while (enumRes)
+    {
+      if (pointer == enumRes->pointer)
+        {
+          delete iterator;
+          return enumRes;
+        }
+      enumRes = iterator->nextElement();
+    }
+  delete iterator;
+  return NULL;
+}
+
+/**
+ * Checks if it is a Directory
+ * @param directoryName the Directory to check for
+ * @returns true if it is a directory/symlink false otherwise
+*/
+bool ResourceManager::isDir(const char* directoryName)
+{
+  if (directoryName == NULL)
+    return false;
+
+  char* tmpDirName = NULL;
+  struct stat status;
+
+  // checking for the termination of the string given. If there is a "/" at the end cut it away
+  if (directoryName[strlen(directoryName)-1] == '/' ||
+      directoryName[strlen(directoryName)-1] == '\\')
+    {
+      tmpDirName = new char[strlen(directoryName)];
+      strncpy(tmpDirName, directoryName, strlen(directoryName)-1);
+      tmpDirName[strlen(directoryName)-1] = '\0';
+    }
+  else
+    {
+      tmpDirName = new char[strlen(directoryName)+1];
+      strcpy(tmpDirName, directoryName);
+    }
+
+  if(!stat(tmpDirName, &status))
+    {
+      if (status.st_mode & (S_IFDIR
+#ifndef __WIN32__
+                            | S_IFLNK
+#endif
+                            ))
+        {
+          delete[] tmpDirName;
+          return true;
+        }
+      else
+        {
+          delete[] tmpDirName;
+          return false;
+        }
+    }
+  else
+  {
+    delete[] tmpDirName;
+    return false;
+  }
+}
+
+/**
+ * Checks if the file is either a Regular file or a Symlink
+ * @param fileName the File to check for
+ * @returns true if it is a regular file/symlink, false otherwise
+*/
+bool ResourceManager::isFile(const char* fileName)
+{
+  if (fileName == NULL)
+    return false;
+  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
+  // actually checks the File
+  struct stat status;
+  if (!stat(tmpFileName, &status))
+    {
+      if (status.st_mode & (S_IFREG
+#ifndef __WIN32__
+                            | S_IFLNK
+#endif
+                            ))
+        {
+          delete[] tmpFileName;
+          return true;
+        }
+      else
+        {
+          delete[] tmpFileName;
+          return false;
+        }
+    }
+  else
+    {
+      delete[] tmpFileName;
+      return false;
+    }
+}
+
+/**
+ * touches a File on the disk (thereby creating it)
+ * @param fileName The file to touch
+*/
+bool ResourceManager::touchFile(const char* fileName)
+{
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+  if (tmpName == NULL)
+    return false;
+  FILE* stream;
+  if( (stream = fopen (tmpName, "w")) == NULL)
+    {
+      PRINTF(1)("could not open %s fro writing\n", fileName);
+      delete[] tmpName;
+      return false;
+    }
+  fclose(stream);
+
+  delete[] tmpName;
+}
+
+/**
+ * deletes a File from disk
+ * @param fileName the File to delete
+*/
+bool ResourceManager::deleteFile(const char* fileName)
+{
+  if (fileName == NULL)
+    return false;
+  char* tmpName = ResourceManager::homeDirCheck(fileName);
+  unlink(tmpName);
+  delete[] tmpName;
+}
+
+/**
+ * @param name the Name of the file to check
+ * @returns The name of the file, including the HomeDir
+ * IMPORTANT: this has to be deleted from the outside
+ */
+char* ResourceManager::homeDirCheck(const char* name)
+{
+  if (name == NULL)
+    return NULL;
+  char* retName;
+  if (!strncmp(name, "~/", 2))
+    {
+      char tmpFileName[500];
+#ifdef __WIN32__
+      strcpy(tmpFileName, getenv("USERPROFILE"));
+#else
+      strcpy(tmpFileName, getenv("HOME"));
+#endif
+      retName = new char[strlen(tmpFileName)+strlen(name)];
+      sprintf(retName, "%s%s", tmpFileName, name+1);
+    }
+  else
+    {
+      retName = new char[strlen(name)+1];
+      strcpy(retName, name);
+    }
+  return retName;
+}
+
+/**
+ * @param fileName the Name of the File to check
+ * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
+ * !!IMPORTANT: this has to be deleted from the outside!!
+*/
+char* ResourceManager::getFullName(const char* fileName)
+{
+  if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
+    return NULL;
+
+  char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir())
+                           + strlen(fileName) + 1];
+  sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
+  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
+    return retName;
+  else
+    {
+      delete[] retName;
+      return NULL;
+    }
+}
+
+
+/**
+ * checks wether a file is in the DataDir.
+ * @param fileName the File to check if it is in the Data-Dir structure.
+ * @returns true if the file exists, false otherwise
+ */
+bool ResourceManager::isInDataDir(const char* fileName)
+{
+  if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
+    return false;
+
+  bool retVal = false;
+  char* checkFile = new char[strlen(ResourceManager::getInstance()->getDataDir())
+      + strlen(fileName) + 1];
+  sprintf(checkFile, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
+
+  if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))
+    retVal = true;
+  else
+    retVal = false;
+  delete[] checkFile;
+  return retVal;
+}
+
+
+/**
+ * outputs debug information about the ResourceManager
+*/
+void ResourceManager::debug() const
+{
+  PRINT(0)("=RM===================================\n");
+  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
+  PRINT(0)("======================================\n");
+  // if it is not initialized
+  PRINT(0)(" Reference is: %p\n", ResourceManager::singletonRef);
+  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
+  PRINT(0)(" List of Image-Directories: ");
+  tIterator<char>* tmpIt = imageDirs->getIterator();
+  char* tmpDir = tmpIt->firstElement();
+  while(tmpDir)
+    {
+      PRINT(0)("%s ",tmpDir);
+      tmpDir = tmpIt->nextElement();
+    }
+  delete tmpIt;
+  PRINT(0)("\n");
+
+  PRINT(0)("List of all stored Resources:\n");
+  tIterator<Resource>* iterator = resourceList->getIterator();
+  Resource* enumRes = iterator->firstElement();
+  while (enumRes)
+    {
+      PRINT(0)("-----------------------------------------\n");
+      PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));
+
+      PRINT(0)("gets deleted at ");
+      switch(enumRes->prio)
+        {
+        default:
+        case RP_NO:
+          PRINT(0)("first posibility (0)\n");
+          break;
+        case RP_LEVEL:
+          PRINT(0)("the end of the Level (1)\n");
+          break;
+        case RP_CAMPAIGN:
+          PRINT(0)("the end of the campaign (2)\n");
+          break;
+        case RP_GAME:
+          PRINT(0)("when leaving the game (3)\n");
+          break;
+        }
+      enumRes = iterator->nextElement();
+    }
+  delete iterator;
+
+
+
+  PRINT(0)("==================================RM==\n");
+}
+
+
+/**
+ * converts a ResourceType into the corresponding String
+ * @param type the ResourceType to translate
+ * @returns the converted String.
+ */
+const char* ResourceManager::ResourceTypeToChar(ResourceType type)
+{
+  switch (type)
+  {
+#ifndef NO_MODEL
+    case OBJ:
+      return "ObjectModel";
+      break;
+    case PRIM:
+      return "PrimitiveModel";
+      break;
+    case MD2:
+      return "MD2-Data";
+      break;
+#endif
+#ifndef NO_TEXTURES
+    case IMAGE:
+      return "ImageFile (Texture)";
+      break;
+#endif
+#ifndef NO_AUDIO
+    case WAV:
+      return "SoundFile";
+      break;
+    case OGG:
+      return "MusicFile";
+      break;
+#endif
+#ifndef NO_TEXT
+    case TTF:
+      return "Font (TTF)";
+      break;
+#endif
+#ifndef NO_SHADERS
+    case SHADER:
+      return "Shader";
+      break;
+#endif
+    default:
+      return "unknown Format";
+      break;
+  }
+}
Index: trunk/src/util/loading/resource_manager.h
===================================================================
--- trunk/src/util/loading/resource_manager.h	(revision 5479)
+++ trunk/src/util/loading/resource_manager.h	(revision 5479)
@@ -0,0 +1,148 @@
+/*!
+ * @file resource_manager.h
+  *  The Resource Manager checks if a file/resource is loaded.
+
+    If a file/resource was already loaded the resourceManager will
+    return a void pointer to the desired resource.
+    Otherwise it will instruct the coresponding resource-loader to load,
+    and receive a pointer to it.
+
+    it is possible to compile the resource Manager without some modules by
+    just adding the compile flag -D....
+    (NO_MODEL)
+    (NO_AUDIO)
+    (NO_TEXT)
+    (NO_TEXTURES)
+*/
+
+#ifndef _RESOURCE_MANAGER_H
+#define _RESOURCE_MANAGER_H
+
+#include "base_object.h"
+
+#include "stdlibincl.h"
+
+// FORWARD DECLARATION
+template<class T> class tList;
+
+//! An eumerator for different fileTypes the resourceManager supports
+typedef enum ResourceType
+{
+#ifndef NO_MODEL
+  OBJ,                  //!< loading .obj file
+  PRIM,                 //!< loading primitive model
+  MD2,                  //!< loading md2-file
+#endif /* NO_MODEL */
+#ifndef NO_TEXT
+  TTF,                  //!< loading a TrueTypeFont
+#endif /* NO_TEXT */
+#ifndef NO_AUDIO
+  WAV,                  //!< loading wav
+  MP3,                  //!< loading mp3
+  OGG,                  //!< loading ogg
+#endif /* NO_AUDIO */
+#ifndef NO_TEXTURES
+  IMAGE,                //!< loading an image
+#endif /* NO_TEXTURES */
+#ifndef NO_SHADERS
+  SHADER,               //!< openGL-shader program
+#endif /* NO_SHADERS */
+};
+
+//! An enumerator for different UNLOAD-types.
+/**
+   RP_NO:        will be unloaded on request
+   RP_LEVEL:     will be unloaded at the end of a Level
+   RP_CAMPAIGN:  will be unloaded at the end of a Campaign
+   RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
+*/
+typedef enum ResourcePriority
+{
+  RP_NO        =   0,
+  RP_LEVEL     =   1,
+  RP_CAMPAIGN  =   2,
+  RP_GAME      =   4
+};
+
+//! A Struct that keeps track about A resource its name its Type, and so on
+struct Resource
+{
+  BaseObject*       pointer;           //!< Pointer to the Resource.
+  unsigned int      count;             //!< How many times this Resource has been loaded.
+
+  char*             name;              //!< Name of the Resource.
+  ResourceType      type;              //!< ResourceType of this Resource.
+  ResourcePriority  prio;              //!< The Priority of this resource. (This will only be increased)
+
+  // more specific
+  float             modelSize;         //!< the size of the model (OBJ/PRIM)
+#ifndef NO_MODEL
+  char*             secFileName;       //!< a seconf fileName
+#endif /* NO_MODEL */
+#ifndef NO_TEXT
+  unsigned int      ttfSize;           //!< the size of the ttf-font (TTF)
+#endif /* NO_TEXT */
+};
+
+
+//! The ResourceManager is a class, that decides if a file/resource should be loaded
+/**
+ * If a file/resource was already loaded the resourceManager will
+ * return a pointer to the desired resource.
+ * Otherwise it will instruct the corresponding resource-loader to load,
+ * and receive the pointer to it.
+ *
+ * It does it by looking, if a desired file has already been loaded.
+ * There is also the possibility to check for some variables
+ */
+class ResourceManager : public BaseObject
+{
+ public:
+  virtual ~ResourceManager();
+  /** @returns a Pointer to the only object of this Class */
+  inline static ResourceManager* getInstance() { if (!singletonRef) singletonRef = new ResourceManager();  return singletonRef; };
+
+  bool setDataDir(const char* dataDir);
+  /** @returns the Name of the data directory */
+  inline const char* getDataDir() const { return this->dataDir; };
+
+  bool checkDataDir(const char* fileInside);
+ bool addImageDir(const char* imageDir);
+  BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO,
+               void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
+  BaseObject* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
+               void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
+  bool unload(void* pointer, ResourcePriority prio = RP_NO);
+  bool unload(Resource* resource, ResourcePriority = RP_NO);
+  bool unloadAllByPriority(ResourcePriority prio);
+
+  void debug() const;
+
+
+  // utility functions of this class
+  static bool isDir(const char* directory);
+  static bool isFile(const char* fileName);
+  static bool touchFile(const char* fileName);
+  static bool deleteFile(const char* fileName);
+  static char* homeDirCheck(const char* fileName);
+  static char* getFullName(const char* fileName);
+  static bool isInDataDir(const char* fileName);
+
+  static const char* ResourceTypeToChar(ResourceType type);
+
+ private:
+  ResourceManager();
+
+  Resource* locateResourceByInfo(const char* fileName, ResourceType type, void* param1, void* param2, void* param3);
+  Resource* locateResourceByPointer(const void* pointer);
+
+ private:
+  static ResourceManager*  singletonRef;       //!< singleton Reference
+
+  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
+  tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
+  tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
+
+};
+
+#endif /* _RESOURCE_MANAGER_H */
Index: trunk/src/util/resource_manager.cc
===================================================================
--- trunk/src/util/resource_manager.cc	(revision 5477)
+++ 	(revision )
@@ -1,980 +1,0 @@
-/*
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   ### File Specific:
-   main-programmer: Benjamin Grauer
-   co-programmer: Patrick Boenzli
-*/
-
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
-
-#include "resource_manager.h"
-
-#include "debug.h"
-
-// different resource Types
-#ifndef NO_MODEL
-#include "objModel.h"
-#include "primitive_model.h"
-#include "md2Model.h"
-#endif /* NO_MODEL */
-#ifndef NO_TEXTURES
-#include "texture.h"
-#endif /* NO_TEXTURES */
-#ifndef NO_TEXT
-#include "font.h"
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-#include "sound_engine.h"
-#include "ogg_player.h"
-#endif /* NO_AUDIO */
-#ifndef NO_SHADERS
-#include "shader.h"
-#endif /* NO_SHADERS */
-
-#include "list.h"
-#include "sdlincl.h"
-
-// File Handling Includes
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-using namespace std;
-
-/**
- *  standard constructor
-*/
-ResourceManager::ResourceManager ()
-{
-  this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
-  this->setName("ResourceManager");
-
-  this->dataDir = new char[3];
-  strcpy(this->dataDir, "./");
-  this->setDataDir("./data");
-  this->imageDirs = new tList<char>;
-  this->resourceList = new tList<Resource>;
-}
-
-//! Singleton Reference to the ResourceManager
-ResourceManager* ResourceManager::singletonRef = NULL;
-
-/**
- *  standard destructor
-*/
-ResourceManager::~ResourceManager ()
-{
-  // deleting the Resources-List
-  this->unloadAllByPriority(RP_GAME);
-
-  if (this->resourceList->getSize() > 0)
-    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
-
-  delete this->resourceList;
-  // deleting the Directorie Lists
-  tIterator<char>* tmpIt = imageDirs->getIterator();
-  char* tmpDir = tmpIt->firstElement();
-  while(tmpDir)
-    {
-      delete[] tmpDir;
-      tmpDir = tmpIt->nextElement();
-    }
-  delete tmpIt;
-  delete this->imageDirs;
-
-  delete[] this->dataDir;
-
-  ResourceManager::singletonRef = NULL;
-}
-
-/**
- *  sets the data main directory
- * @param dataDir the DataDirectory.
-*/
-bool ResourceManager::setDataDir(const char* dataDir)
-{
-  char* realDir = ResourceManager::homeDirCheck(dataDir);
-  if (isDir(realDir))
-    {
-      delete[] this->dataDir;
-      if (dataDir[strlen(dataDir)-1] == '/' || dataDir[strlen(dataDir)-1] == '\\')
-      {
-        this->dataDir = new char[strlen(realDir)+1];
-        strcpy(this->dataDir, realDir);
-      }
-      else
-      {
-        this->dataDir = new char[strlen(realDir)+2];
-        strcpy(this->dataDir, realDir);
-        this->dataDir[strlen(realDir)] = '/';
-        this->dataDir[strlen(realDir)+1] = '\0';
-      }
-      delete[] realDir;
-      return true;
-    }
-  else
-    {
-      PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir, this->dataDir);
-      delete[] realDir;
-      return false;
-    }
-}
-
-/**
- *  checks for the DataDirectory, by looking if
- * @param fileInside is inisde??
-*/
-bool ResourceManager::checkDataDir(const char* fileInside)
-{
-  bool retVal;
-  if (!isDir(this->dataDir))
-    {
-      PRINTF(1)("%s is not a directory\n", this->dataDir);
-      return false;
-    }
-
-  char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1];
-  sprintf(testFile, "%s%s", this->dataDir, fileInside);
-  retVal = isFile(testFile);
-  delete[] testFile;
-  return retVal;
-}
-
-#ifndef NO_TEXTURES
-/**
- *  adds a new Path for Images
- * @param imageDir The path to insert
- * @returns true, if the Path was well and injected (or already existent within the list)
-   false otherwise
-*/
-bool ResourceManager::addImageDir(const char* imageDir)
-{
-  if (imageDir == NULL)
-    return false;
-
-  char* newDir;
-  if (imageDir[strlen(imageDir)-1] == '/' || imageDir[strlen(imageDir)-1] == '\\')
-  {
-    newDir = new char[strlen(imageDir)+1];
-    strcpy(newDir, imageDir);
-  }
-  else
-  {
-    newDir = new char[strlen(imageDir)+2];
-    strcpy(newDir, imageDir);
-    newDir[strlen(imageDir)] = '/';
-    newDir[strlen(imageDir)+1] = '\0';
-  }
-  // check if the param is a Directory
-  if (isDir(newDir))
-    {
-      // check if the Directory has been added before
-      tIterator<char>* tmpImageDirs = imageDirs->getIterator();
-      char* tmpDir = tmpImageDirs->firstElement();
-      while(tmpDir)
-        {
-          if (!strcmp(tmpDir, newDir))
-            {
-              PRINTF(3)("Path %s already loaded\n", newDir);
-              delete[] newDir;
-              delete tmpImageDirs;
-              return true;
-            }
-          tmpDir = tmpImageDirs->nextElement();
-        }
-      delete tmpImageDirs;
-
-      // adding the directory to the List
-      this->imageDirs->add(newDir);
-      return true;
-    }
-  else
-    {
-      PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir);
-      delete[] newDir;
-      return false;
-    }
-}
-#endif /* NO_TEXTURES */
-
-/**
- *  loads resources
- * @param fileName: The fileName of the resource to load
- * @param prio: The ResourcePriority of this resource (will only be increased)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @param param3: an additional option to parse (see the constuctors for more help)
- * @returns a pointer to a desired Resource.
-*/
-BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio, void* param1, void* param2, void* param3)
-{
-  if (fileName == NULL)
-    return NULL;
-  ResourceType tmpType;
-#ifndef NO_MODEL
-#define __IF_OK
-  if (!strncasecmp(fileName+(strlen(fileName)-4), ".obj", 4))
-    tmpType = OBJ;
-  else if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4))
-    tmpType = MD2;
-  else if (!strcasecmp(fileName, "cube") ||
-           !strcasecmp(fileName, "sphere") ||
-           !strcasecmp(fileName, "plane") ||
-           !strcasecmp(fileName, "cylinder") ||
-           !strcasecmp(fileName, "cone"))
-    tmpType = PRIM;
-#endif /* NO_MODEL */
-#ifndef NO_AUDIO
-#ifdef __IF_OK
-  else
-#endif
-#define __IF_OK
-  if (!strncasecmp(fileName+(strlen(fileName)-4), ".wav", 4))
-    tmpType = WAV;
-  else if (!strncasecmp(fileName+(strlen(fileName)-4), ".mp3", 4))
-    tmpType = MP3;
-  else if (!strncasecmp(fileName+(strlen(fileName)-4), ".ogg", 4))
-    tmpType = OGG;
-#endif /* NO_AUDIO */
-#ifndef NO_TEXT
-#ifdef __IF_OK
-  else
-#endif
-#define __IF_OK
- if (!strncasecmp(fileName+(strlen(fileName)-4), ".ttf", 4))
-    tmpType = TTF;
-#endif /* NO_TEXT */
-#ifndef NO_SHADERS
-#ifdef __IF_OK
-  else
-#endif
-#define __IF_OK
- if (!strncasecmp(fileName+(strlen(fileName)-5), ".vert", 5))
-    tmpType = SHADER;
-#endif /* NO_SHADERS */
-#ifndef NO_TEXTURES
-#ifdef __IF_OK
-  else
-#else
-  if
-#endif
-   tmpType = IMAGE;
-#endif /* NO_TEXTURES */
-#undef __IF_OK
-  return this->load(fileName, tmpType, prio, param1, param2, param3);
-}
-
-/**
- * loads resources
- * @param fileName: The fileName of the resource to load
- * @param type: The Type of Resource to load.
- * @param prio: The ResourcePriority of this resource (will only be increased)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @param param3: an additional option to parse (see the constuctors for more help)
- * @returns a pointer to a desired Resource.
-*/
-BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio,
-                            void* param1, void* param2, void* param3)
-{
-  if (fileName == NULL)
-    return NULL;
-
-  // searching if the resource was loaded before.
-  Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2, param3);
-  if (tmpResource != NULL) // if the resource was loaded before.
-    {
-      PRINTF(4)("not loading cached resource %s\n", tmpResource->name);
-      tmpResource->count++;
-      if(tmpResource->prio < prio)
-        tmpResource->prio = prio;
-    }
-  else
-    {
-      // Setting up the new Resource
-      tmpResource = new Resource;
-      tmpResource->count = 1;
-      tmpResource->type = type;
-      tmpResource->prio = prio;
-      tmpResource->pointer = NULL;
-      tmpResource->name = new char[strlen(fileName)+1];
-      strcpy(tmpResource->name, fileName);
-
-      // creating the full name. (directoryName + FileName)
-      char* fullName = ResourceManager::getFullName(fileName);
-      // Checking for the type of resource \see ResourceType
-      switch(type)
-        {
-#ifndef NO_MODEL
-        case OBJ:
-          if (param1)
-            tmpResource->modelSize = *(float*)param1;
-          else
-            tmpResource->modelSize = 1.0;
-
-          if(ResourceManager::isFile(fullName))
-            tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize);
-          else
-            {
-              PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName, dataDir);
-              tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize);
-            }
-          break;
-        case PRIM:
-          if (param1)
-            tmpResource->modelSize = *(float*)param1;
-          else
-            tmpResource->modelSize = 1.0;
-
-          if (!strcmp(tmpResource->name, "cube"))
-            tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize);
-          else if (!strcmp(tmpResource->name, "sphere"))
-            tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize);
-          else if (!strcmp(tmpResource->name, "plane"))
-            tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize);
-          else if (!strcmp(tmpResource->name, "cylinder"))
-            tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize);
-          else if (!strcmp(tmpResource->name, "cone"))
-            tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize);
-          break;
-        case MD2:
-          if(ResourceManager::isFile(fullName))
-            {
-              if (param1 != NULL)
-                {
-                  tmpResource->secFileName = new char[strlen((const char*)param1)+1];
-                  strcpy(tmpResource->secFileName, (const char*) param1);
-                }
-              else
-                tmpResource->secFileName = NULL;
-              tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
-            }
-              break;
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-        case TTF:
-            if (param1 != NULL)
-              tmpResource->ttfSize = *(unsigned int*)param1;
-            else
-              tmpResource->ttfSize = FONT_DEFAULT_RENDER_SIZE;
-
-          if(isFile(fullName))
-            tmpResource->pointer = new Font(fullName, tmpResource->ttfSize);
-          else
-            PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName, this->dataDir);
-          break;
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-        case WAV:
-          if(isFile(fullName))
-            tmpResource->pointer = new SoundBuffer(fullName);
-          break;
-        case OGG:
-          if (isFile(fullName))
-            tmpResource->pointer = new OggPlayer(fullName);
-          break;
-#endif /* NO_AUDIO */
-#ifndef NO_TEXTURES
-        case IMAGE:
-          if(isFile(fullName))
-            {
-              PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
-              tmpResource->pointer = new Texture(fullName);
-            }
-          else
-            {
-              char* tmpDir;
-              tIterator<char>* iterator = imageDirs->getIterator();
-              tmpDir = iterator->firstElement();
-              while(tmpDir)
-                {
-                  char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
-                  sprintf(imgName, "%s%s", tmpDir, fileName);
-                  if(isFile(imgName))
-                    {
-                      PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
-                      tmpResource->pointer = new Texture(imgName);
-                      delete[] imgName;
-                      break;
-                    }
-                  delete[] imgName;
-                  tmpDir = iterator->nextElement();
-                }
-              delete iterator;
-            }
-          if(!tmpResource)
-             PRINTF(2)("!!Image %s not Found!!\n", fileName);
-          break;
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-          case SHADER:
-            if(ResourceManager::isFile(fullName))
-            {
-              if (param1 != NULL)
-              {
-                char* secFullName = ResourceManager::getFullName((const char*)param1);
-                if (ResourceManager::isFile(secFullName))
-                {
-                  tmpResource->secFileName = new char[strlen((const char*)param1)+1];
-                  strcpy(tmpResource->secFileName, (const char*) param1);
-                  tmpResource->pointer = new Shader(fullName, secFullName);
-                }
-                delete[] secFullName;
-              }
-              else
-              {
-                tmpResource->secFileName = NULL;
-                tmpResource->pointer = new Shader(fullName, NULL);
-              }
-            }
-            break;
-#endif /* NO_SHADERS */
-        default:
-          tmpResource->pointer = NULL;
-          PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name);
-          break;
-        }
-      if (tmpResource->pointer != NULL)
-        this->resourceList->add(tmpResource);
-      delete[] fullName;
-    }
-  if (tmpResource->pointer != NULL)
-    return tmpResource->pointer;
-  else
-    {
-      PRINTF(2)("Resource %s could not be loaded\n", fileName);
-      delete[] tmpResource->name;
-      delete tmpResource;
-      return NULL;
-    }
-}
-
-/**
- * unloads a Resource
- * @param pointer: The pointer to free
- * @param prio: the PriorityLevel to unload this resource
- * @returns true if successful (pointer found, and deleted), false otherwise
-*/
-bool ResourceManager::unload(void* pointer, ResourcePriority prio)
-{
-  if (pointer == NULL)
-    return false;
-  // if pointer is existent. and only one resource of this type exists.
-  Resource* tmpResource = this->locateResourceByPointer(pointer);
-  if (tmpResource != NULL)
-    return unload(tmpResource, prio);
-  else
-  {
-    PRINTF(2)("Resource not Found %p\n", pointer);
-    return false;
-  }
-}
-
-/**
- * unloads a Resource
- * @param resource: The resource to unloade
- * @param prio the PriorityLevel to unload this resource
- * @returns true on success, false otherwise.
-*/
-bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
-{
-  if (resource == NULL)
-    return false;
-  if (resource->count > 0)
-    resource->count--;
-
-  if (resource->prio <= prio)
-    {
-      if (resource->count == 0)
-        {
-          // deleting the Resource
-          switch(resource->type)
-            {
-#ifndef NO_MODEL
-            case OBJ:
-            case PRIM:
-              delete (Model*)resource->pointer;
-              break;
-            case MD2:
-              delete (MD2Data*)resource->pointer;
-              break;
-#endif /* NO_MODEL */
-#ifndef NO_AUDIO
-            case WAV:
-              delete (SoundBuffer*)resource->pointer;
-              break;
-            case OGG:
-              delete (OggPlayer*)resource->pointer;
-              break;
-#endif /* NO_AUDIO */
-#ifndef NO_TEXT
-            case TTF:
-              delete (Font*)resource->pointer;
-              break;
-#endif /* NO_TEXT */
-#ifndef NO_TEXTURES
-            case IMAGE:
-              delete (Texture*)resource->pointer;
-              break;
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-            case SHADER:
-              delete (Shader*)resource->pointer;
-              break;
-#endif /* NO_SHADERS */
-            default:
-              PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
-              return false;
-              break;
-            }
-          // deleting the List Entry:
-          PRINTF(4)("Resource %s safely removed.\n", resource->name);
-          delete[] resource->name;
-          this->resourceList->remove(resource);
-          delete resource;
-        }
-      else
-        PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count);
-    }
-  else
-    PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name);
-  return true;
-}
-
-
-/**
- * unloads all alocated Memory of Resources with a pririty lower than prio
- * @param prio The priority to delete
-*/
-bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
-{
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->lastElement();
-  while (enumRes)
-    {
-      if (enumRes->prio <= prio)
-        if (enumRes->count == 0)
-          unload(enumRes, prio);
-        else
-          PRINTF(2)("unable to unload %s because there are still %d references to it\n",
-                   enumRes->name, enumRes->count);
-      //enumRes = resourceList->nextElement();
-      enumRes = iterator->prevElement();
-    }
-  delete iterator;
-}
-
-/**
- * Searches for a Resource by some information
- * @param fileName: The name to look for
- * @param type the Type of resource to locate.
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @param param3: an additional option to parse (see the constuctors for more help)
- * @returns a Pointer to the Resource if found, NULL otherwise.
-*/
-Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
-                                                void* param1, void* param2, void* param3)
-{
-  //  Resource* enumRes = resourceList->enumerate();
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
-    {
-      if (enumRes->type == type && !strcmp(fileName, enumRes->name))
-        {
-          bool match = false;
-
-          switch (type)
-            {
-#ifndef NO_MODEL
-            case PRIM:
-            case OBJ:
-              if (!param1)
-                {
-                  if (enumRes->modelSize == 1.0)
-                    match = true;
-                }
-              else if (enumRes->modelSize == *(float*)param1)
-                match = true;
-              break;
-            case MD2:
-              if (!param1)
-                {
-                  if (enumRes->secFileName == NULL)
-                    match = true;
-                }
-              else if (!strcmp(enumRes->secFileName, (const char*)param1))
-                match = true;
-              break;
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-            case TTF:
-              if (param1 == NULL)
-                {
-                  if (enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)
-                    match = true;
-                }
-              else if (enumRes->ttfSize == *(unsigned int*)param1)
-                match = true;
-              break;
-#endif /* NO_TEXT */
-#ifndef NO_SHADERS
-              case SHADER:
-                if (!param1)
-                {
-                  if (enumRes->secFileName == NULL)
-                    match = true;
-                }
-                else if (!strcmp(enumRes->secFileName, (const char*)param1))
-                  match = true;
-#endif /* NO_SHADERS */
-            default:
-              match = true;
-              break;
-            }
-          if (match)
-            {
-              delete iterator;
-              return enumRes;
-            }
-        }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
-  return NULL;
-}
-
-/**
- * Searches for a Resource by Pointer
- * @param pointer the Pointer to search for
- * @returns a Pointer to the Resource if found, NULL otherwise.
-*/
-Resource* ResourceManager::locateResourceByPointer(const void* pointer)
-{
-  //  Resource* enumRes = resourceList->enumerate();
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
-    {
-      if (pointer == enumRes->pointer)
-        {
-          delete iterator;
-          return enumRes;
-        }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
-  return NULL;
-}
-
-/**
- * Checks if it is a Directory
- * @param directoryName the Directory to check for
- * @returns true if it is a directory/symlink false otherwise
-*/
-bool ResourceManager::isDir(const char* directoryName)
-{
-  if (directoryName == NULL)
-    return false;
-
-  char* tmpDirName = NULL;
-  struct stat status;
-
-  // checking for the termination of the string given. If there is a "/" at the end cut it away
-  if (directoryName[strlen(directoryName)-1] == '/' ||
-      directoryName[strlen(directoryName)-1] == '\\')
-    {
-      tmpDirName = new char[strlen(directoryName)];
-      strncpy(tmpDirName, directoryName, strlen(directoryName)-1);
-      tmpDirName[strlen(directoryName)-1] = '\0';
-    }
-  else
-    {
-      tmpDirName = new char[strlen(directoryName)+1];
-      strcpy(tmpDirName, directoryName);
-    }
-
-  if(!stat(tmpDirName, &status))
-    {
-      if (status.st_mode & (S_IFDIR
-#ifndef __WIN32__
-                            | S_IFLNK
-#endif
-                            ))
-        {
-          delete[] tmpDirName;
-          return true;
-        }
-      else
-        {
-          delete[] tmpDirName;
-          return false;
-        }
-    }
-  else
-  {
-    delete[] tmpDirName;
-    return false;
-  }
-}
-
-/**
- * Checks if the file is either a Regular file or a Symlink
- * @param fileName the File to check for
- * @returns true if it is a regular file/symlink, false otherwise
-*/
-bool ResourceManager::isFile(const char* fileName)
-{
-  if (fileName == NULL)
-    return false;
-  char* tmpFileName = ResourceManager::homeDirCheck(fileName);
-  // actually checks the File
-  struct stat status;
-  if (!stat(tmpFileName, &status))
-    {
-      if (status.st_mode & (S_IFREG
-#ifndef __WIN32__
-                            | S_IFLNK
-#endif
-                            ))
-        {
-          delete[] tmpFileName;
-          return true;
-        }
-      else
-        {
-          delete[] tmpFileName;
-          return false;
-        }
-    }
-  else
-    {
-      delete[] tmpFileName;
-      return false;
-    }
-}
-
-/**
- * touches a File on the disk (thereby creating it)
- * @param fileName The file to touch
-*/
-bool ResourceManager::touchFile(const char* fileName)
-{
-  char* tmpName = ResourceManager::homeDirCheck(fileName);
-  if (tmpName == NULL)
-    return false;
-  FILE* stream;
-  if( (stream = fopen (tmpName, "w")) == NULL)
-    {
-      PRINTF(1)("could not open %s fro writing\n", fileName);
-      delete[] tmpName;
-      return false;
-    }
-  fclose(stream);
-
-  delete[] tmpName;
-}
-
-/**
- * deletes a File from disk
- * @param fileName the File to delete
-*/
-bool ResourceManager::deleteFile(const char* fileName)
-{
-  if (fileName == NULL)
-    return false;
-  char* tmpName = ResourceManager::homeDirCheck(fileName);
-  unlink(tmpName);
-  delete[] tmpName;
-}
-
-/**
- * @param name the Name of the file to check
- * @returns The name of the file, including the HomeDir
- * IMPORTANT: this has to be deleted from the outside
- */
-char* ResourceManager::homeDirCheck(const char* name)
-{
-  if (name == NULL)
-    return NULL;
-  char* retName;
-  if (!strncmp(name, "~/", 2))
-    {
-      char tmpFileName[500];
-#ifdef __WIN32__
-      strcpy(tmpFileName, getenv("USERPROFILE"));
-#else
-      strcpy(tmpFileName, getenv("HOME"));
-#endif
-      retName = new char[strlen(tmpFileName)+strlen(name)];
-      sprintf(retName, "%s%s", tmpFileName, name+1);
-    }
-  else
-    {
-      retName = new char[strlen(name)+1];
-      strcpy(retName, name);
-    }
-  return retName;
-}
-
-/**
- * @param fileName the Name of the File to check
- * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
- * !!IMPORTANT: this has to be deleted from the outside!!
-*/
-char* ResourceManager::getFullName(const char* fileName)
-{
-  if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
-    return NULL;
-
-  char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir())
-                           + strlen(fileName) + 1];
-  sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
-  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
-    return retName;
-  else
-    {
-      delete[] retName;
-      return NULL;
-    }
-}
-
-
-/**
- * checks wether a file is in the DataDir.
- * @param fileName the File to check if it is in the Data-Dir structure.
- * @returns true if the file exists, false otherwise
- */
-bool ResourceManager::isInDataDir(const char* fileName)
-{
-  if (fileName == NULL || ResourceManager::getInstance()->getDataDir() == NULL)
-    return false;
-
-  bool retVal = false;
-  char* checkFile = new char[strlen(ResourceManager::getInstance()->getDataDir())
-      + strlen(fileName) + 1];
-  sprintf(checkFile, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName);
-
-  if (ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))
-    retVal = true;
-  else
-    retVal = false;
-  delete[] checkFile;
-  return retVal;
-}
-
-
-/**
- * outputs debug information about the ResourceManager
-*/
-void ResourceManager::debug() const
-{
-  PRINT(0)("=RM===================================\n");
-  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
-  PRINT(0)("======================================\n");
-  // if it is not initialized
-  PRINT(0)(" Reference is: %p\n", ResourceManager::singletonRef);
-  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
-  PRINT(0)(" List of Image-Directories: ");
-  tIterator<char>* tmpIt = imageDirs->getIterator();
-  char* tmpDir = tmpIt->firstElement();
-  while(tmpDir)
-    {
-      PRINT(0)("%s ",tmpDir);
-      tmpDir = tmpIt->nextElement();
-    }
-  delete tmpIt;
-  PRINT(0)("\n");
-
-  PRINT(0)("List of all stored Resources:\n");
-  tIterator<Resource>* iterator = resourceList->getIterator();
-  Resource* enumRes = iterator->firstElement();
-  while (enumRes)
-    {
-      PRINT(0)("-----------------------------------------\n");
-      PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));
-
-      PRINT(0)("gets deleted at ");
-      switch(enumRes->prio)
-        {
-        default:
-        case RP_NO:
-          PRINT(0)("first posibility (0)\n");
-          break;
-        case RP_LEVEL:
-          PRINT(0)("the end of the Level (1)\n");
-          break;
-        case RP_CAMPAIGN:
-          PRINT(0)("the end of the campaign (2)\n");
-          break;
-        case RP_GAME:
-          PRINT(0)("when leaving the game (3)\n");
-          break;
-        }
-      enumRes = iterator->nextElement();
-    }
-  delete iterator;
-
-
-
-  PRINT(0)("==================================RM==\n");
-}
-
-
-/**
- * converts a ResourceType into the corresponding String
- * @param type the ResourceType to translate
- * @returns the converted String.
- */
-const char* ResourceManager::ResourceTypeToChar(ResourceType type)
-{
-  switch (type)
-  {
-#ifndef NO_MODEL
-    case OBJ:
-      return "ObjectModel";
-      break;
-    case PRIM:
-      return "PrimitiveModel";
-      break;
-    case MD2:
-      return "MD2-Data";
-      break;
-#endif
-#ifndef NO_TEXTURES
-    case IMAGE:
-      return "ImageFile (Texture)";
-      break;
-#endif
-#ifndef NO_AUDIO
-    case WAV:
-      return "SoundFile";
-      break;
-    case OGG:
-      return "MusicFile";
-      break;
-#endif
-#ifndef NO_TEXT
-    case TTF:
-      return "Font (TTF)";
-      break;
-#endif
-#ifndef NO_SHADERS
-    case SHADER:
-      return "Shader";
-      break;
-#endif
-    default:
-      return "unknown Format";
-      break;
-  }
-}
Index: trunk/src/util/resource_manager.h
===================================================================
--- trunk/src/util/resource_manager.h	(revision 5477)
+++ 	(revision )
@@ -1,148 +1,0 @@
-/*!
- * @file resource_manager.h
-  *  The Resource Manager checks if a file/resource is loaded.
-
-    If a file/resource was already loaded the resourceManager will
-    return a void pointer to the desired resource.
-    Otherwise it will instruct the coresponding resource-loader to load,
-    and receive a pointer to it.
-
-    it is possible to compile the resource Manager without some modules by
-    just adding the compile flag -D....
-    (NO_MODEL)
-    (NO_AUDIO)
-    (NO_TEXT)
-    (NO_TEXTURES)
-*/
-
-#ifndef _RESOURCE_MANAGER_H
-#define _RESOURCE_MANAGER_H
-
-#include "base_object.h"
-
-#include "stdlibincl.h"
-
-// FORWARD DECLARATION
-template<class T> class tList;
-
-//! An eumerator for different fileTypes the resourceManager supports
-typedef enum ResourceType
-{
-#ifndef NO_MODEL
-  OBJ,                  //!< loading .obj file
-  PRIM,                 //!< loading primitive model
-  MD2,                  //!< loading md2-file
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-  TTF,                  //!< loading a TrueTypeFont
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-  WAV,                  //!< loading wav
-  MP3,                  //!< loading mp3
-  OGG,                  //!< loading ogg
-#endif /* NO_AUDIO */
-#ifndef NO_TEXTURES
-  IMAGE,                //!< loading an image
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-  SHADER,               //!< openGL-shader program
-#endif /* NO_SHADERS */
-};
-
-//! An enumerator for different UNLOAD-types.
-/**
-   RP_NO:        will be unloaded on request
-   RP_LEVEL:     will be unloaded at the end of a Level
-   RP_CAMPAIGN:  will be unloaded at the end of a Campaign
-   RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
-*/
-typedef enum ResourcePriority
-{
-  RP_NO        =   0,
-  RP_LEVEL     =   1,
-  RP_CAMPAIGN  =   2,
-  RP_GAME      =   4
-};
-
-//! A Struct that keeps track about A resource its name its Type, and so on
-struct Resource
-{
-  BaseObject*       pointer;           //!< Pointer to the Resource.
-  unsigned int      count;             //!< How many times this Resource has been loaded.
-
-  char*             name;              //!< Name of the Resource.
-  ResourceType      type;              //!< ResourceType of this Resource.
-  ResourcePriority  prio;              //!< The Priority of this resource. (This will only be increased)
-
-  // more specific
-  float             modelSize;         //!< the size of the model (OBJ/PRIM)
-#ifndef NO_MODEL
-  char*             secFileName;       //!< a seconf fileName
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-  unsigned int      ttfSize;           //!< the size of the ttf-font (TTF)
-#endif /* NO_TEXT */
-};
-
-
-//! The ResourceManager is a class, that decides if a file/resource should be loaded
-/**
- * If a file/resource was already loaded the resourceManager will
- * return a pointer to the desired resource.
- * Otherwise it will instruct the corresponding resource-loader to load,
- * and receive the pointer to it.
- *
- * It does it by looking, if a desired file has already been loaded.
- * There is also the possibility to check for some variables
- */
-class ResourceManager : public BaseObject
-{
- public:
-  virtual ~ResourceManager();
-  /** @returns a Pointer to the only object of this Class */
-  inline static ResourceManager* getInstance() { if (!singletonRef) singletonRef = new ResourceManager();  return singletonRef; };
-
-  bool setDataDir(const char* dataDir);
-  /** @returns the Name of the data directory */
-  inline const char* getDataDir() const { return this->dataDir; };
-
-  bool checkDataDir(const char* fileInside);
- bool addImageDir(const char* imageDir);
-  BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO,
-               void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
-  BaseObject* load(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO,
-               void* param1 = NULL, void* param2 = NULL, void* param3 = NULL);
-  bool unload(void* pointer, ResourcePriority prio = RP_NO);
-  bool unload(Resource* resource, ResourcePriority = RP_NO);
-  bool unloadAllByPriority(ResourcePriority prio);
-
-  void debug() const;
-
-
-  // utility functions of this class
-  static bool isDir(const char* directory);
-  static bool isFile(const char* fileName);
-  static bool touchFile(const char* fileName);
-  static bool deleteFile(const char* fileName);
-  static char* homeDirCheck(const char* fileName);
-  static char* getFullName(const char* fileName);
-  static bool isInDataDir(const char* fileName);
-
-  static const char* ResourceTypeToChar(ResourceType type);
-
- private:
-  ResourceManager();
-
-  Resource* locateResourceByInfo(const char* fileName, ResourceType type, void* param1, void* param2, void* param3);
-  Resource* locateResourceByPointer(const void* pointer);
-
- private:
-  static ResourceManager*  singletonRef;       //!< singleton Reference
-
-  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
-  tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
-  tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
-
-};
-
-#endif /* _RESOURCE_MANAGER_H */
Index: trunk/src/world_entities/weapons/rocket.cc
===================================================================
--- trunk/src/world_entities/weapons/rocket.cc	(revision 5477)
+++ trunk/src/world_entities/weapons/rocket.cc	(revision 5479)
@@ -115,4 +115,5 @@
   ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::trailParticles);
 
+  this->update(0);
   this->emitter->setEmissionRate(45.0);
   this->emitter->setEmissionVelocity(0.0);
