Index: /trunk/src/lib/util/substring.h
===================================================================
--- /trunk/src/lib/util/substring.h	(revision 6647)
+++ /trunk/src/lib/util/substring.h	(revision 6648)
@@ -16,4 +16,6 @@
   ~SubString();
 
+  const char* operator[](unsigned int i) { return this->getString(i); };
+
   inline unsigned int getCount() { return this->splittersCount; };
   const char* getString(unsigned int i);
Index: /trunk/src/util/loading/resource_manager.cc
===================================================================
--- /trunk/src/util/loading/resource_manager.cc	(revision 6647)
+++ /trunk/src/util/loading/resource_manager.cc	(revision 6648)
@@ -18,4 +18,5 @@
 #include "resource_manager.h"
 
+#include "substring.h"
 #include "debug.h"
 
@@ -235,5 +236,5 @@
 */
 BaseObject* ResourceManager::load(const char* fileName, ResourcePriority prio,
-                                   const MultiType& param0, const MultiType& param1, const MultiType& param2)
+                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
 {
   if (fileName == NULL)
@@ -342,5 +343,7 @@
   // otherwise load it
   if (tmpResource == NULL)
+  {
     tmpResource = this->loadResource(fileName, type, prio, param0, param1, param2);
+  }
   // return cached pointer.
   if (tmpResource != NULL) // if the resource was loaded before.
@@ -349,4 +352,5 @@
     if(tmpResource->prio < prio)
       tmpResource->prio = prio;
+
     return tmpResource->pointer;
   }
@@ -384,130 +388,130 @@
   {
 #ifndef NO_MODEL
-  case OBJ:
-    if (param0.getType() != MT_NULL)
-      tmpResource->param[0] = param0;
-    else
-      tmpResource->param[0] = 1.0f;
-
-    if(ResourceManager::isFile(fullName))
-      tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat());
-    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->param[0].getFloat());
-    }
-    break;
-  case PRIM:
-    if (param0 != MT_NULL)
-      tmpResource->param[0] = param0;
-    else
-      tmpResource->param[0] = 1.0f;
-
-    if (!strcmp(tmpResource->name, "cube"))
-      tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->param[0].getFloat());
-    else if (!strcmp(tmpResource->name, "sphere"))
-      tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->param[0].getFloat());
-    else if (!strcmp(tmpResource->name, "plane"))
-      tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->param[0].getFloat());
-    else if (!strcmp(tmpResource->name, "cylinder"))
-      tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->param[0].getFloat());
-    else if (!strcmp(tmpResource->name, "cone"))
-      tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->param[0].getFloat());
-    break;
-  case MD2:
-    if(ResourceManager::isFile(fullName))
-    {
-      tmpResource->param[0] = param0;
-      tmpResource->pointer = new MD2Data(fullName, tmpResource->param[0].getString());
-      //               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
-
-    }
-    break;
+    case OBJ:
+      if (param0.getType() != MT_NULL)
+        tmpResource->param[0] = param0;
+      else
+        tmpResource->param[0] = 1.0f;
+
+      if(ResourceManager::isFile(fullName))
+        tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat());
+      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->param[0].getFloat());
+      }
+      break;
+    case PRIM:
+      if (param0 != MT_NULL)
+        tmpResource->param[0] = param0;
+      else
+        tmpResource->param[0] = 1.0f;
+
+      if (!strcmp(tmpResource->name, "cube"))
+        tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->param[0].getFloat());
+      else if (!strcmp(tmpResource->name, "sphere"))
+        tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->param[0].getFloat());
+      else if (!strcmp(tmpResource->name, "plane"))
+        tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->param[0].getFloat());
+      else if (!strcmp(tmpResource->name, "cylinder"))
+        tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->param[0].getFloat());
+      else if (!strcmp(tmpResource->name, "cone"))
+        tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->param[0].getFloat());
+      break;
+    case MD2:
+      if(ResourceManager::isFile(fullName))
+      {
+        tmpResource->param[0] = param0;
+        tmpResource->pointer = new MD2Data(fullName, tmpResource->param[0].getString());
+        //               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
+
+      }
+      break;
 #endif /* NO_MODEL */
 #ifndef NO_TEXT
-  case TTF:
-    if (param0 != MT_NULL)
-    {
-      assert(param0.getInt() >= 0);
-      tmpResource->param[0] = param0;
-    }
-    else
-      tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE;
-
-    if(isFile(fullName))
-      tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
-    else
-      PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName, this->dataDir);
-    break;
+    case TTF:
+      if (param0 != MT_NULL)
+      {
+        assert(param0.getInt() >= 0);
+        tmpResource->param[0] = param0;
+      }
+      else
+        tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE;
+
+      if(isFile(fullName))
+        tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
+      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;
+    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 (param0 != MT_NULL)
-      tmpResource->param[0] = param0;
-    else
-      tmpResource->param[0] = GL_TEXTURE_2D;
-    if(isFile(fullName))
-    {
-      PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
-      tmpResource->pointer = new Texture(fullName);
-    }
-    else
-    {
-      std::vector<char*>::iterator imageDir;
-      for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
+    case IMAGE:
+      if (param0 != MT_NULL)
+        tmpResource->param[0] = param0;
+      else
+        tmpResource->param[0] = GL_TEXTURE_2D;
+      if(isFile(fullName))
       {
-        char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
-        sprintf(imgName, "%s%s", *imageDir, fileName);
-        if(isFile(imgName))
-        {
-          PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
-          tmpResource->pointer = new Texture(imgName, tmpResource->param[0].getInt());
-          delete[] imgName;
-          break;
-        }
-        delete[] imgName;
-      }
-    }
-    if(!tmpResource)
-      PRINTF(2)("!!Image %s not Found!!\n", fileName);
-    break;
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-  case SHADER:
-    if(ResourceManager::isFile(fullName))
-    {
-      if (param0 != MT_NULL)
-      {
-        MultiType param = param0; /// HACK
-        char* secFullName = ResourceManager::getFullName(param.getString());
-        if (ResourceManager::isFile(secFullName))
-        {
-          tmpResource->param[0] = secFullName;
-          tmpResource->pointer = new Shader(fullName, secFullName);
-        }
-        delete[] secFullName;
+        PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
+        tmpResource->pointer = new Texture(fullName);
       }
       else
       {
-        tmpResource->param[0] = param0;
-        tmpResource->pointer = new Shader(fullName, NULL);
+        std::vector<char*>::iterator imageDir;
+        for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
+        {
+          char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
+          sprintf(imgName, "%s%s", *imageDir, fileName);
+          if(isFile(imgName))
+          {
+            PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
+            tmpResource->pointer = new Texture(imgName, tmpResource->param[0].getInt());
+            delete[] imgName;
+            break;
+          }
+          delete[] imgName;
+        }
       }
-    }
-    break;
+      if(!tmpResource)
+        PRINTF(2)("!!Image %s not Found!!\n", fileName);
+      break;
+#endif /* NO_TEXTURES */
+#ifndef NO_SHADERS
+    case SHADER:
+      if(ResourceManager::isFile(fullName))
+      {
+        if (param0 != MT_NULL)
+        {
+          MultiType param = param0; /// HACK
+          char* secFullName = ResourceManager::getFullName(param.getString());
+          if (ResourceManager::isFile(secFullName))
+          {
+            tmpResource->param[0] = secFullName;
+            tmpResource->pointer = new Shader(fullName, secFullName);
+          }
+          delete[] secFullName;
+        }
+        else
+        {
+          tmpResource->param[0] = param0;
+          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;
+    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)
@@ -569,39 +573,39 @@
       {
 #ifndef NO_MODEL
-      case OBJ:
-      case PRIM:
-        delete (Model*)resource->pointer;
-        break;
-      case MD2:
-        delete (MD2Data*)resource->pointer;
-        break;
+        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;
+        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;
+        case TTF:
+          delete (Font*)resource->pointer;
+          break;
 #endif /* NO_TEXT */
 #ifndef NO_TEXTURES
-      case IMAGE:
-        delete (Texture*)resource->pointer;
-        break;
+        case IMAGE:
+          delete (Texture*)resource->pointer;
+          break;
 #endif /* NO_TEXTURES */
 #ifndef NO_SHADERS
-      case SHADER:
-        delete (Shader*)resource->pointer;
-        break;
+        case SHADER:
+          delete (Shader*)resource->pointer;
+          break;
 #endif /* NO_SHADERS */
-      default:
-        PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
-        return false;
-        break;
+        default:
+          PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n");
+          return false;
+          break;
       }
       // deleting the List Entry:
@@ -662,5 +666,5 @@
 */
 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type,
-        const MultiType& param0, const MultiType& param1, const MultiType& param2) const
+    const MultiType& param0, const MultiType& param1, const MultiType& param2) const
 {
   std::vector<Resource*>::const_iterator resource;
@@ -673,58 +677,58 @@
       {
 #ifndef NO_MODEL
-      case PRIM:
-      case OBJ:
-        if (param0 == MT_NULL)
-        {
-          if ((*resource)->param[0] == 1.0f)
+        case PRIM:
+        case OBJ:
+          if (param0 == MT_NULL)
+          {
+            if ((*resource)->param[0] == 1.0f)
+              match = true;
+          }
+          else if ((*resource)->param[0] == param0.getFloat())
             match = true;
-        }
-        else if ((*resource)->param[0] == param0.getFloat())
-          match = true;
-        break;
-      case MD2:
-        if (param0 == MT_NULL)
-        {
-          if ((*resource)->param[0] == "")
+          break;
+        case MD2:
+          if (param0 == MT_NULL)
+          {
+            if ((*resource)->param[0] == "")
+              match = true;
+          }
+          else if ((*resource)->param[0] == ((MultiType)param0).getString())
             match = true;
-        }
-        else if ((*resource)->param[0] == ((MultiType)param0).getString())
-          match = true;
-        break;
+          break;
 #endif /* NO_MODEL */
 #ifndef NO_TEXT
-      case TTF:
-        if (param0 == MT_NULL)
-        {
-          if ((*resource)->param[0] == FONT_DEFAULT_RENDER_SIZE)
+        case TTF:
+          if (param0 == MT_NULL)
+          {
+            if ((*resource)->param[0] == FONT_DEFAULT_RENDER_SIZE)
+              match = true;
+          }
+          else if ((*resource)->param[0] == param0.getInt())
             match = true;
-        }
-        else if ((*resource)->param[0] == param0.getInt())
-          match = true;
-        break;
+          break;
 #endif /* NO_TEXT */
 #ifndef NO_SHADERS
-      case SHADER:
-        if (param0 == MT_NULL)
-        {
-          if ((*resource)->param[0] == "")
+        case SHADER:
+          if (param0 == MT_NULL)
+          {
+            if ((*resource)->param[0] == "")
+              match = true;
+          }
+          else if ((*resource)->param[0] == ((MultiType)param0).getString())
             match = true;
-        }
-        else if ((*resource)->param[0] == ((MultiType)param0).getString())
-          match = true;
 #endif /* NO_SHADERS */
 #ifndef NO_TEXTURES
-      case IMAGE:
-        if (param0 == MT_NULL)
-        {
-          if ((*resource)->param[0] == GL_TEXTURE_2D)
+        case IMAGE:
+          if (param0 == MT_NULL)
+          {
+            if ((*resource)->param[0] == GL_TEXTURE_2D)
+              match = true;
+          }
+          else if ((*resource)->param[0] ==  param0.getInt())
             match = true;
-        }
-        else if ((*resource)->param[0] ==  param0.getInt())
+#endif /* NO_TEXTURES */
+        default:
           match = true;
-#endif /* NO_TEXTURES */
-      default:
-        match = true;
-        break;
+          break;
       }
       if (match)
@@ -751,4 +755,58 @@
   return NULL;
 }
+
+char* ResourceManager::toResourcableString(unsigned int i)
+{
+  int len = strlen(ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
+  len += strlen(this->resourceList[i]->name);
+  if (this->resourceList[i]->param[0].getString()) len += strlen(this->resourceList[i]->param[0].getString()) +1;
+  if (this->resourceList[i]->param[1].getString()) len += strlen(this->resourceList[i]->param[1].getString()) +1;
+  if (this->resourceList[i]->param[2].getString()) len += strlen(this->resourceList[i]->param[2].getString()) +1;
+  len += 10;
+  char* tmp = new char[len];
+  tmp[0] = '\0';
+  strcat( tmp, ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
+  strcat(tmp,",");
+  strcat (tmp, this->resourceList[i]->name);
+  if (this->resourceList[i]->param[0].getString() && this->resourceList[i]->param[0].getString() != '\0')
+  {
+    strcat(tmp,",");
+    strcat( tmp, this->resourceList[i]->param[0].getString());
+  }
+  if (this->resourceList[i]->param[1].getString() && this->resourceList[i]->param[1].getString() != '\0')
+  {
+    strcat(tmp,",");
+    strcat( tmp, this->resourceList[i]->param[1].getString());
+  }
+  if (this->resourceList[i]->param[2].getString() && this->resourceList[i]->param[2].getString() != '\0')
+  {
+    strcat(tmp,",");
+    strcat( tmp, this->resourceList[i]->param[2].getString());
+  }
+  return tmp;
+}
+
+/**
+ * @brief caches a Resource from a ResourceableString created with the toResourcableString-function
+ * @param resourceableString the String to cache the resource from.
+ */
+bool ResourceManager::fromResourceableString(const char* resourceableString)
+{
+  SubString splits(resourceableString, ',');
+  splits.debug();
+  if (splits.getCount() == 2)
+    this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
+                RP_LEVEL);
+  else if (splits.getCount() == 3)
+    this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
+                RP_LEVEL, splits[2]);
+  else if (splits.getCount() == 4)
+    this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
+                RP_LEVEL, splits[2], splits[3]);
+  else if (splits.getCount() == 5)
+    this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
+                RP_LEVEL, splits[2], splits[3], splits[4]);
+}
+
 
 /**
@@ -977,17 +1035,17 @@
     switch((*resource)->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;
+      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;
     }
   }
@@ -1027,22 +1085,24 @@
  */
 const char* ResourceManager::resourceNames[] =
-{
+  {
 #ifndef NO_MODEL
-  "ObjectModel",
-  "PrimitiveModel",
-  "MD2-Data",
+    "ObjectModel",
+    "PrimitiveModel",
+    "MD2-Data",
+#endif
+#ifndef NO_TEXT
+    "Font",
+#endif
+#ifndef NO_AUDIO
+    "Wav",
+    "mp3",
+    "ogg",
 #endif
 #ifndef NO_TEXTURES
-  "Texture",
-#endif
-#ifndef NO_AUDIO
-  "Sound",
-  "Music",
-#endif
-#ifndef NO_TEXT
-  "Font",
+    "Texture",
 #endif
 #ifndef NO_SHADERS
-  "Shader",
+    "Shader",
 #endif
-};
+
+  };
Index: /trunk/src/util/loading/resource_manager.h
===================================================================
--- /trunk/src/util/loading/resource_manager.h	(revision 6647)
+++ /trunk/src/util/loading/resource_manager.h	(revision 6648)
@@ -120,4 +120,7 @@
   Resource* locateResourceByPointer(const void* pointer) const;
 
+  char* toResourcableString(unsigned int i);
+  bool fromResourceableString(const char* resourceableString);
+
   void debug() const;
 
