Index: /orxonox/trunk/src/util/fast_factory.cc
===================================================================
--- /orxonox/trunk/src/util/fast_factory.cc	(revision 4950)
+++ /orxonox/trunk/src/util/fast_factory.cc	(revision 4951)
@@ -194,5 +194,5 @@
   {
     PRINTF(2)("The deadList of Class %s is empty, this may be either because it has not been filled yet, or the cache is to small.\n" \
-        "Fabricating a new %s", this->getName(), this->getName());
+        "Fabricating a new %s\n", this->getName(), this->getName());
     this->fabricate();
     return this->resurrect();
Index: /orxonox/trunk/src/world_entities/player.cc
===================================================================
--- /orxonox/trunk/src/world_entities/player.cc	(revision 4950)
+++ /orxonox/trunk/src/world_entities/player.cc	(revision 4951)
@@ -49,5 +49,5 @@
   Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
 
-  this->weaponMan->addWeapon(wpRight, WM_CONFIG0, WM_SLOT0);
+  this->weaponMan->addWeapon(wpRight);
 //  this->weaponMan->addWeapon(wpLeft, WM_CONFIG1, WM_SLOT1);
 //  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
@@ -83,8 +83,10 @@
   Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1);
 
-  this->weaponMan->addWeapon(wpRight, WM_CONFIG0, WM_SLOT0);
-  this->weaponMan->addWeapon(wpLeft, WM_CONFIG1, WM_SLOT1);
-  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
-  this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);
+  this->weaponMan->addWeapon(wpRight, 0,0);
+  this->weaponMan->addWeapon(wpLeft, 0, 1);
+  this->weaponMan->addWeapon(wpLeft, 1, 1);
+  this->weaponMan->addWeapon(wpRight, 2, 0);
+/*  this->weaponMan->addWeapon(wpRight, WM_CONFIG2);
+  this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);*/
 }
 
@@ -96,5 +98,5 @@
   this->setClassID(CL_PLAYER, "Player");
 
-  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
+//  this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);
   travelSpeed = 15.0;
   velocity = new Vector();
Index: /orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
===================================================================
--- /orxonox/trunk/src/world_entities/weapons/weapon_manager.cc	(revision 4950)
+++ /orxonox/trunk/src/world_entities/weapons/weapon_manager.cc	(revision 4951)
@@ -13,4 +13,6 @@
    main-programmer: Patrick Boenzli
    co-programmer: Benjamin Grauer
+
+   2005-07-24: Benjamin Grauer: restructurate, so it can handle the new Weapons.
 */
 
@@ -34,8 +36,8 @@
  * @param number of weapon slots of the model/ship <= 8 (limitied)
  */
-WeaponManager::WeaponManager(int slotCount)
+WeaponManager::WeaponManager(unsigned int slotCount)
 {
   this->init();
-  this->slotCount = slotCount;
+  this->setSlotCount(slotCount);
 }
 
@@ -51,16 +53,4 @@
 WeaponManager::~WeaponManager()
 {
-  /*
-  i dont have to delete the weapons itself, because they are
-  worldentities and therefore in the entities list of the world.
-  world will clean them up for me
-  */
-  for(int i = 0; i < WM_MAX_CONFIGS; ++i)
-  {
-    this->configs[i].bUsed = false;
-    for(int j = 0; j < WM_MAX_SLOTS; ++j)
-      this->configs[i].slots[j] = NULL;
-  }
-
   // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.)
   //delete this->crosshair;
@@ -74,15 +64,26 @@
   this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
 
-  for(int i = 0; i < WM_MAX_CONFIGS; ++i)
-  {
-    this->configs[i].bUsed = false;
-    for(int j = 0; j < WM_MAX_SLOTS; ++j)
-      this->configs[i].slots[j] = NULL;
-  }
-  this->currConfID = WM_CONFIG0;
-
-
-
-
+  this->parent = NULL;
+
+  for (int i = 0; i < WM_MAX_CONFIGS; i++)
+    for (int j = 0; j < WM_MAX_SLOTS; j++)
+      this->configs[i][j] = NULL;
+
+  for (int i = 0; i < WM_MAX_SLOTS; i++)
+  {
+    this->currentSlotConfig[i].capability = WM_SLOTC_ALL;
+    this->currentSlotConfig[i].currentWeapon = NULL;
+    this->currentSlotConfig[i].nextWeapon = NULL;
+  }
+
+  for (int i = 0; i < WM_MAX_LOADED_WEAPONS; i++)
+    this->availiableWeapons[i] = NULL;
+
+
+  this->currentConfigID = 0;
+  this->slotCount = 2;
+  this->weaponChange;
+
+  // CROSSHAIR INITIALISATION
   this->crosshair = new Crosshair();
 
@@ -101,5 +102,5 @@
 {
   static_cast<BaseObject*>(this)->loadParams(root);
-
+/*
   LoadParam<WeaponManager>(root, "slot-count", this, &WeaponManager::setSlotCount)
       .describe("how many slots(cannons) the WeaponManager can handle");
@@ -111,5 +112,5 @@
       // LoadParam<WeaponManager>(root, "Weapon", this, &WeaponManager::addWeapon);
 
-  LOAD_PARAM_END_CYCLE;
+  LOAD_PARAM_END_CYCLE;*/
 }
 
@@ -134,7 +135,10 @@
  * @param slotCount the number of slots
  */
-void WeaponManager::setSlotCount(int slotCount)
-{
-  this->slotCount = slotCount;
+void WeaponManager::setSlotCount(unsigned int slotCount)
+{
+  if (slotCount <= WM_MAX_SLOTS)
+    this->slotCount = slotCount;
+  else
+    this->slotCount = WM_MAX_SLOTS;
 }
 
@@ -152,19 +156,23 @@
 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
 {
-  if( slotID == WM_FREE_SLOT)
-  {
-    int freeSlot = this->getNextFreeSlot( configID);
-    if( freeSlot < 0 || freeSlot >= this->slotCount)
+  if (unlikely(configID >= WM_MAX_CONFIGS || slotID >= (int)this->slotCount))
+  {
+    PRINTF(2)("Slot %d of config %d is not availiabe\n", slotID, configID);
+    return;
+  }
+
+  if (this->configs[configID][slotID] != NULL && configID > 0 && slotID > 0)
+    PRINTF(3)("Weapon-slot %d/%d of %s already poulated, overwriting\n", configID, slotID, this->getName());
+
+  if (slotID == -1) // WM_FREE_SLOT
+  {
+    slotID = this->getNextFreeSlot(configID);
+    if( slotID < 0 || slotID >= this->slotCount)
     {
       PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
       return;
     }
-    PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot);
-    this->configs[configID].bUsed = true;
-    this->configs[configID].slots[freeSlot] = weapon;
-    return;
-  }
-  this->configs[configID].bUsed = true;
-  this->configs[configID].slots[slotID] = weapon;
+  }
+  this->configs[configID][slotID] = weapon;
   PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID);
 }
@@ -187,68 +195,66 @@
 void WeaponManager::nextWeaponConf()
 {
-  PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID);
-
-  int i, lastConfID;
-  lastConfID = this->currConfID;
-  for(i = this->currConfID + 1; i < WM_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
-  if( i == WM_MAX_CONFIGS) this->currConfID = WM_CONFIG0;
-  else this->currConfID = i;
-
-
-  Weapon *w1, *w2;
-  for(int j = 0; j < WM_MAX_SLOTS; ++j)
-  {
-    w1 = this->configs[lastConfID].slots[j];
-    w2 = this->configs[this->currConfID].slots[j];
-
-    if( w1 == w2)
+  PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currentConfigID);
+
+  ++this->currentConfigID;
+  if (this->currentConfigID >= WM_MAX_CONFIGS)
+    this->currentConfigID = 0;
+
+  for (int i = 0; i < WM_MAX_SLOTS; i++)
+  {
+    this->currentSlotConfig[i].nextWeapon = this->configs[currentConfigID][i];
+    if (this->currentSlotConfig[i].currentWeapon != this->currentSlotConfig[i].nextWeapon && this->currentSlotConfig[i].currentWeapon != NULL)
+      (this->currentSlotConfig[i].currentWeapon->requestAction(WA_DEACTIVATE));
+  }
+
+  this->debug();
+}
+
+
+/**
+ * triggers fire of all weapons in the current weaponconfig
+ */
+void WeaponManager::fire()
+{
+  Weapon* firingWeapon;
+  for(int i = 0; i < this->slotCount; i++)
+  {
+    firingWeapon = this->currentSlotConfig[i].currentWeapon;
+    if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
+  }
+  this->crosshair->setRotationSpeed(500);
+  this->crossHairSizeAnim->replay();
+}
+
+
+/**
+ * triggers tick of all weapons in the current weaponconfig
+ * @param second passed since last tick
+ */
+void WeaponManager::tick(float dt)
+{
+  Weapon* tickWeapon;
+
+  // all weapons
+  for(int i = 0; i < this->slotCount; i++)
+  {
+
+    tickWeapon = this->currentSlotConfig[i].currentWeapon;
+    if (tickWeapon != this->currentSlotConfig[i].nextWeapon) // if no change occures
     {
-      printf("no need for change\n");
-    }
-    else
-    {
-      if( w1 != NULL )
+      if (tickWeapon != NULL && tickWeapon->isActive())
       {
-        w1->requestAction(WA_DEACTIVATE);
-        printf("deactivating %i,%i\n", j,lastConfID);
+        tickWeapon->requestAction(WA_DEACTIVATE);
       }
-      if( w2 != NULL)
+      else
       {
-        w2->requestAction(WA_ACTIVATE);
-        printf("activating %i,%i\n", j, this->currConfID);
+        tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon;
+        if (tickWeapon != NULL)
+          tickWeapon->requestAction(WA_ACTIVATE);
       }
     }
-  }
-}
-
-
-/**
- * triggers fire of all weapons in the current weaponconfig
- */
-void WeaponManager::fire()
-{
-  Weapon* firingWeapon;
-  for(int i = 0; i < WM_MAX_SLOTS; ++i)
-  {
-    firingWeapon = this->configs[this->currConfID].slots[i];
-    if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
-  }
-  this->crosshair->setRotationSpeed(500);
-  this->crossHairSizeAnim->replay();
-}
-
-
-/**
- * triggers tick of all weapons in the current weaponconfig
- * @param second passed since last tick
- */
-void WeaponManager::tick(float dt)
-{
-  Weapon* w;
-  for(int i = 0; i < WM_MAX_SLOTS; ++i)
-  {
-    w = this->configs[this->currConfID].slots[i];
-    if( w != NULL && w->isActive())
-      w->tickW(dt);
+
+    if( tickWeapon != NULL && tickWeapon->isActive())
+      tickWeapon->tickW(dt);
   }
 
@@ -260,13 +266,12 @@
  * triggers draw of all weapons in the current weaponconfig
  */
-void WeaponManager::draw()
-{
-  Weapon* w;
-  for (int j = 0; j < 4; ++j )
-  for(int i = 0; i < WM_MAX_SLOTS; ++i)
-  {
-    w = this->configs[j].slots[i];
-    if( w != NULL && w->isVisible())
-      w->draw();
+void WeaponManager::draw() const
+{
+  Weapon* drawWeapon;
+  for (int i = 0; i < this->slotCount; i++)
+  {
+    drawWeapon = this->currentSlotConfig[i].currentWeapon;
+    if( drawWeapon != NULL && drawWeapon->isVisible())
+      drawWeapon->draw();
   }
 }
@@ -279,7 +284,7 @@
 int WeaponManager::getNextFreeSlot(int configID)
 {
-  for( int i = 0; i < WM_MAX_SLOTS; ++i)
-  {
-    if( this->configs[configID].slots[i] == NULL)
+  for( int i = 0; i < this->slotCount; ++i)
+  {
+    if( this->configs[configID][i] == NULL)
       return i;
   }
@@ -287,2 +292,19 @@
 }
 
+
+
+void WeaponManager::debug() const
+{
+  PRINT(3)("WeaponManager Debug Information\n");
+  PRINT(3)("-------------------------------\n");
+  PRINT(3)("current Config is %d\n", this->currentConfigID);
+  for (int i = 0; i < WM_MAX_CONFIGS; i++)
+  {
+    PRINT(3)("Listing Weapons in Configuration %d\n", i);
+    for (int j = 0; j < WM_MAX_SLOTS; j++)
+    {
+      if (this->configs[i][j] != NULL)
+        PRINT(3)("Slot %d loaded a %s\n", j, this->configs[i][j]->getClassName());
+    }
+  }
+}
Index: /orxonox/trunk/src/world_entities/weapons/weapon_manager.h
===================================================================
--- /orxonox/trunk/src/world_entities/weapons/weapon_manager.h	(revision 4950)
+++ /orxonox/trunk/src/world_entities/weapons/weapon_manager.h	(revision 4951)
@@ -29,77 +29,46 @@
 #include "base_object.h"
 
+#include "vector.h"
 
 // FORWARD DECLARATION
+class PNode;
 class Weapon;
 class Crosshair;
 template <class T> class tAnimation;
 
-#define    WM_MAX_SLOTS            8                   //!< How many slots the WeaponManager has at its max
-#define    WM_MAX_CONFIGS          4                   //!< The maximum number of predefined Configurations
-#define    WM_MAX_LOADED_WEAPONS   20                  //!< The
 
-//! this is an identifier for the weapon config
+#define    WM_MAX_SLOTS            8              //!< How many slots the WeaponManager has at its max
+#define    WM_MAX_CONFIGS          4              //!< The maximum number of predefined Configurations
+#define    WM_MAX_LOADED_WEAPONS   20             //!< The
+
+//! an enumerator defining capabilities of a WeaponSlot
 typedef enum
 {
-  WM_CONFIG0           = 0,
-  WM_CONFIG1           = 1,
-  WM_CONFIG2           = 2,
-  WM_CONFIG3           = 3,
+  WM_SLOTC_DIRECTIONAL   = 0x00000001,           //!< if the Slot is able to carry directional weapons
+  WM_SLOTC_TURRET        = 0x00000002,           //!< if the Slot is able to carry turrets
+  WM_SLOTC_ALLKINDS      = 0x0000000f,           //!< if the Slot is able to carry all kinds of weapons
 
-  WM_CONFIGCOUNT       = 4
-} WM_CONFIG;
+  WM_SLOTC_FORWARD       = 0x00000010,           //!< if the Slot is able to carry weapons firing forward
+  WM_SLOTC_BACKWARD      = 0x00000020,           //!< if the Slot is able to carry weapons firing backwards
+  WM_SLOTC_LEFT          = 0x00000040,           //!< if the Slot is able to carry weapons firing to the left
+  WM_SLOTC_RIGHT         = 0x00000080,           //!< if the Slot is able to carry weapons firing to the right
+  WM_SLOTC_ALLDIRS       = 0x000000f0,           //!< this slot can fire into all directions
 
-//! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time
-typedef enum
-{
-  WM_SLOT0              = 0,
-  WM_SLOT1              = 1,
-  WM_SLOT2              = 2,
-  WM_SLOT3              = 3,
-  WM_SLOT4              = 4,
-  WM_SLOT5              = 5,
-  WM_SLOT6              = 6,
-  WM_SLOT7              = 7,
-
-  WM_SLOT_COUNT         = 8,
-
-  WM_FREE_SLOT          = -1
-} WM_SLOT;
-
-typedef enum
-{
-  WM_SLOTC_DIRECTIONAL   = 1,
-  WM_SLOTC_TURRET        = 2,
-  WM_SLOTC_ALLKINDS      = 3,
-
-  WM_SLOTC_FORWARD       = 4,
-  WM_SLOTC_BACKWARD      = 8,
-  WM_SLOTC_LEFT          = 16,
-  WM_SLOTC_RIGHT         = 32,
-  WM_SLOTC_ALLDIRS       = 60,
-
-  WM_SLOTC_ALL           = 63,
+  WM_SLOTC_ALL           = 0x000000ff,           //!< everything allowed in this slot
 } WM_SlotCapability;
 
-typedef struct WM_Slot
-{
-  int           number;
-  long          capability;
-
-  Weapon*       currentWeapon;
-  Weapon*       nextWeapon;
-};
-
-//! this is a weapon Configuration: it has up to 8 slots
+//! an enumerator defining a Slot, where a Weapon can be stored inside.
 typedef struct
 {
-  bool           bUsed;                       //!< is set to true, if this configuration is
-  Weapon*        slots[WM_MAX_SLOTS];
-} weaponConfig;
+  Vector        position;               //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager)
+  long          capability;             //!< the capabilities of the Slot @see WM_SlotCapability.
 
+  Weapon*       currentWeapon;          //!< The current weapon this slot is carrying.
+  Weapon*       nextWeapon;             //!< either NULL or the next weapon that will be set (require currentWeapon to deactivate)
+} WM_Slot;
 
 class WeaponManager : public BaseObject {
   public:
-    WeaponManager(int slotCount);
+    WeaponManager(unsigned int slotCount);
     WeaponManager(const TiXmlElement* root);
     ~WeaponManager();
@@ -109,25 +78,38 @@
     void loadWeapons(const TiXmlElement* root);
 
-    void setSlotCount(int slotCount);
+    // setting up the WeaponManager with the following functions
+    void setSlotPosition(int slot, const Vector& position);
+    void setSlotCapability(long slotCapability);
 
-    void addWeapon(Weapon* weapon, int configID = WM_CONFIG0, int slotID = WM_FREE_SLOT);
-    void removeWeapon(Weapon* weapon, int configID = WM_CONFIG0);
+    void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
+    void removeWeapon(Weapon* weapon, int configID = -1);
+
     void nextWeaponConf();
 
     void fire();
+
     void tick(float dt);
-    void draw();
+    void draw() const;
+
+    void debug() const;
 
   private:
+    void setSlotCount(unsigned int slotCount);
+
     int getNextFreeSlot(int configID);
 
   private:
-    Crosshair*              crosshair;               //!< an aim.
-    tAnimation<Crosshair>*  crossHairSizeAnim;       //!< An animation for the crosshair (scaling)
+    PNode*                  parent;                                  //!< The parent, this WeaponManager is connected to.
 
-    int                     slotCount;               //!< number of weapon slots a ship has
-    int                     currConfID;              //!< the currently selected config
-    weaponConfig            configs[4];              //!< a list of four configurations
+    int                     slotCount;                               //!< number of weapon slots the ship has.
+    int                     currentConfigID;                         //!< the currently selected config.
+    Weapon*                 configs[WM_MAX_CONFIGS][WM_MAX_SLOTS];   //!< An array of predefined configurations and assigned weapon.
+    WM_Slot                 currentSlotConfig[WM_MAX_SLOTS];         //!< The currentConfigureation.
 
     Weapon*                 availiableWeapons[WM_MAX_LOADED_WEAPONS];
+
+    bool                    weaponChange;
+
+    Crosshair*              crosshair;                               //!< an aim.
+    tAnimation<Crosshair>*  crossHairSizeAnim;                       //!< An animation for the crosshair (scaling)
 };
