Index: orxonox/trunk/src/util/resource_manager.cc
===================================================================
--- orxonox/trunk/src/util/resource_manager.cc	(revision 4457)
+++ orxonox/trunk/src/util/resource_manager.cc	(revision 4462)
@@ -21,4 +21,5 @@
 #include "objModel.h"
 #include "primitive_model.h"
+#include "md2Model.h"
 #include "texture.h"
 #include "text_engine.h"
@@ -173,6 +174,9 @@
 {
   ResourceType tmpType;
+
   if (!strncmp(fileName+(strlen(fileName)-4), ".obj", 4))
     tmpType = OBJ;
+  if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4))
+    tmpType = MD2;
   else if (!strncmp(fileName+(strlen(fileName)-4), ".wav", 4))
     tmpType = WAV;
@@ -226,6 +230,5 @@
 
       // creating the full name. (directoryName + FileName)
-      char* fullName = new char[strlen(this->getDataDir())+strlen(fileName)+1];
-      sprintf(fullName, "%s%s", this->getDataDir(), fileName);
+      char* fullName = ResourceManager::getFullName(fileName);
       // Checking for the type of resource \see ResourceType
       switch(type)
@@ -262,4 +265,19 @@
 	    tmpResource->pointer = new PrimitiveModel(CONE, tmpResource->modelSize);
 	  break;
+	case MD2:
+	  if(ResourceManager::isFile(fullName))
+	    {
+	      if (param1)
+		{
+		  tmpResource->skinFileName = new char[strlen((const char*)param1)+1];
+		  strcpy(tmpResource->skinFileName, (const char*) fileName);
+		}
+	      else
+		tmpResource->skinFileName = NULL;
+	      char* skinFileName = ResourceManager::getFullName(tmpResource->skinFileName);
+	      tmpResource->pointer = new MD2Data(fullName, skinFileName);
+	      delete []skinFileName;
+	    }
+	      break;
 	case TTF:
 	    if (param1)
@@ -373,4 +391,7 @@
 	      delete (Model*)resource->pointer;
 	      break;
+	    case MD2:
+	      delete (MD2Data*)resource->pointer;
+	      break;
 	    case IMAGE:
 	      delete (Texture*)resource->pointer;
@@ -425,5 +446,6 @@
    \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* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
+						void* param1, void* param2, void* param3)
 {
   //  Resource* enumRes = resourceList->enumerate();
@@ -436,4 +458,5 @@
 	  bool match = false;
 	  bool subMatch = false;
+
 	  switch (type)
 	    {
@@ -446,4 +469,13 @@
 		}
 	      else if (enumRes->modelSize == *(float*)param1)
+		match = true;
+	      break;
+	    case MD2:
+	      if (!param1)
+		{
+		  if (enumRes->skinFileName == NULL)
+		    match = true;
+		}
+	      else if (!strcmp(enumRes->skinFileName, (const char*) param1))
 		match = true;
 	      break;
@@ -519,4 +551,7 @@
 bool ResourceManager::isDir(const char* directoryName)
 {
+  if (directoryName == NULL)
+    return false;
+
   char* tmpDirName = NULL;
   struct stat status;
@@ -563,4 +598,6 @@
 bool ResourceManager::isFile(const char* fileName)
 {
+  if (fileName == NULL)
+    return false;
   char* tmpFileName = ResourceManager::homeDirCheck(fileName);
   // actually checks the File
@@ -597,5 +634,6 @@
 {
   char* tmpName = ResourceManager::homeDirCheck(fileName);
-
+  if (tmpName == NULL)
+    return false;
   FILE* stream;
   if( (stream = fopen (tmpName, "w")) == NULL)
@@ -615,4 +653,6 @@
 bool ResourceManager::deleteFile(const char* fileName)
 {
+  if (fileName == NULL)
+    return false;
   char* tmpName = ResourceManager::homeDirCheck(fileName);
   unlink(tmpName);
@@ -627,4 +667,6 @@
 char* ResourceManager::homeDirCheck(const char* name)
 {
+  if (name == NULL)
+    return NULL;
   char* retName;
   if (!strncmp(name, "~/", 2))
@@ -654,8 +696,11 @@
 char* ResourceManager::getFullName(const char* fileName)
 {
+  if (fileName == 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))
+  if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName))
     return retName;
   else
Index: orxonox/trunk/src/util/resource_manager.h
===================================================================
--- orxonox/trunk/src/util/resource_manager.h	(revision 4457)
+++ orxonox/trunk/src/util/resource_manager.h	(revision 4462)
@@ -19,23 +19,25 @@
 template<class T> class tList;
 
-//! An eumerator for different fileTypes the resourceManager supports \todo WAV, MP3, OGG support
-enum ResourceType {OBJ,
-		   PRIM,
-		   WAV,
-		   MP3,
-		   OGG,
-		   TTF,
-		   IMAGE};
+//! An eumerator for different fileTypes the resourceManager supports
+typedef enum ResourceType { OBJ,
+			    PRIM,
+			    MD2,
+			    WAV,
+			    MP3,
+			    OGG,
+			    TTF,
+			    IMAGE };
+
 //! 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)
+   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)
 */
-enum ResourcePriority {RP_NO = 0,
-		       RP_LEVEL = 1,
-		       RP_CAMPAIGN = 2,
-		       RP_GAME = 3};
+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
@@ -55,4 +57,5 @@
   unsigned char ttfColorG;
   unsigned char ttfColorB;
+  char* skinFileName;
 };
 
@@ -66,6 +69,4 @@
 
    It does it by looking, if a desired file has already been loaded.
-
-   \todo loading also dependant by parameters.
 */
 class ResourceManager : public BaseObject 
