Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 9656)
+++ trunk/src/world_entities/world_entity.cc	(revision 9869)
@@ -20,5 +20,6 @@
 #include "shell_command.h"
 
-#include "model.h"
+#include "util/loading/resource_manager.h"
+#include "resource_obj.h"
 #include "md2/md2Model.h"
 #include "md3/md3_model.h"
@@ -26,5 +27,4 @@
 #include "aabb_tree_node.h"
 
-#include "util/loading/resource_manager.h"
 #include "util/loading/load_param.h"
 #include "obb_tree.h"
@@ -39,5 +39,7 @@
 #include "game_rules.h"
 #include "kill.h"
-
+#include "debug.h"
+
+#include "projectiles/projectile.h"
 
 SHELL_COMMAND(model, WorldEntity, loadModel)
@@ -47,4 +49,6 @@
 SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
 
+
+ObjectListDefinition(WorldEntity);
 /**
  *  Loads the WordEntity-specific Part of any derived Class
@@ -56,5 +60,5 @@
     : Synchronizeable()
 {
-  this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
+  this->registerObject(this, WorldEntity::_objectList);
 
   this->obbTree = NULL;
@@ -72,5 +76,4 @@
   this->objectListNumber = OM_INIT;
   this->lastObjectListNumber = OM_INIT;
-  this->objectListIterator = NULL;
 
   // reset all collision handles to NULL == unsubscribed state
@@ -81,5 +84,5 @@
 
   // registering default reactions:
-  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);
+  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* WorldEntity::staticClassID(), */ Projectile::staticClassID());
 
   this->toList(OM_NULL);
@@ -160,7 +163,7 @@
   std::string name = fileName;
 
-  if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 )
-  {
-    name.erase(ResourceManager::getInstance()->getDataDir().size());
+  if (  name.find( Resources::ResourceManager::getInstance()->mainGlobalPath().name() ) == 0 )
+  {
+    name.erase(Resources::ResourceManager::getInstance()->mainGlobalPath().name().size());
   }
 
@@ -178,5 +181,5 @@
       {
         lodFile[offset] = 48+(int)i;
-        if (ResourceManager::isInDataDir(lodFile))
+        if (Resources::ResourceManager::getInstance()->checkFileInMainPath( lodFile))
           this->loadModel(lodFile, scaling, i);
       }
@@ -188,16 +191,20 @@
       this->scaling = 1.0;
     }
+    /// LOADING AN OBJ FILE
     if(fileName.find(".obj") != std::string::npos)
     {
       PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str());
-      BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling);
-      if (loadedModel != NULL)
-        this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber);
+      StaticModel* model = new StaticModel();
+      *model = ResourceOBJ(fileName, this->scaling);
+      if (model->getVertexCount() > 0)
+      {
+        this->setModel(model, modelNumber);
+	if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */)
+	  this->buildObbTree(obbTreeDepth);
+      }
       else
-        PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
-
-      if( modelNumber == 0 && !this->isA(CL_WEAPON))
-        this->buildObbTree(obbTreeDepth);
-    }
+        delete model;
+    }
+    /// LOADING AN MD2-model
     else if(fileName.find(".md2") != std::string::npos)
     {
@@ -210,12 +217,13 @@
         this->buildObbTree(obbTreeDepth);
     }
+    /// LOADING AN MD3-MODEL.
     else if(fileName.find(".md3") != std::string::npos)
     {
       PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str());
-      Model* m = new md3::MD3Model(fileName, this->scaling);
-      this->setModel(m, 0);
-
-//       if( m != NULL)
-//         this->buildObbTree(obbTreeDepth);
+//      Model* m = new md3::MD3Model(fileName, this->scaling);
+//      this->setModel(m, 0);
+
+      //       if( m != NULL)
+      //         this->buildObbTree(obbTreeDepth);
     }
   }
@@ -238,12 +246,5 @@
   if (this->models[modelNumber] != NULL)
   {
-    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber]));
-    if (resource != NULL)
-      ResourceManager::getInstance()->unload(resource, RP_LEVEL);
-    else
-    {
-      PRINTF(4)("Forcing model deletion\n");
-      delete this->models[modelNumber];
-    }
+    delete this->models[modelNumber];
   }
 
@@ -281,5 +282,6 @@
   }
 
-  if( this->models[0] != NULL) {
+  if( this->models[0] != NULL)
+  {
     this->aabbNode = new AABBTreeNode();
     this->aabbNode->spawnBVTree(this->models[0]);
@@ -300,5 +302,5 @@
  *  @param target1 a filter target (classID)
  */
-void WorldEntity::subscribeReaction(CREngine::CRType type, long target1)
+void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1)
 {
   this->subscribeReaction(type);
@@ -314,5 +316,5 @@
  *  @param target1 a filter target (classID)
  */
-void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2)
+void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2)
 {
   this->subscribeReaction(type);
@@ -329,5 +331,5 @@
  *  @param target1 a filter target (classID)
  */
-void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3)
+void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3)
 {
   this->subscribeReaction(type);
@@ -345,5 +347,5 @@
  *  @param target1 a filter target (classID)
  */
-void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, long target4)
+void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4)
 {
   this->subscribeReaction(type);
@@ -365,5 +367,6 @@
 void WorldEntity::subscribeReaction(CREngine::CRType type)
 {
-  if( this->collisionHandles[type] != NULL)  {
+  if( this->collisionHandles[type] != NULL)
+  {
     PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n");
     return;
@@ -496,6 +499,6 @@
 void removeFromReflectionList()
 {
-/// TODO
-///  State::getObject
+  /// TODO
+  ///  State::getObject
 }
 
@@ -556,8 +559,8 @@
   {
 
-  this->setAbsCoor(ray_2 - v);
-
-  }
-    else
+    this->setAbsCoor(ray_2 - v);
+
+  }
+  else
   {
     if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z)
@@ -643,6 +646,6 @@
     }
 
-//     if( this->aabbNode != NULL)
-//       this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);
+    //     if( this->aabbNode != NULL)
+    //       this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);
 
     glPopMatrix();
