Index: /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.cc
===================================================================
--- /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.cc	(revision 10675)
+++ /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.cc	(revision 10676)
@@ -72,14 +72,14 @@
   this->parentEntity = 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_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] = new WeaponSlot();
-    this->currentSlotConfig[i]->setCapability(WTYPE_ALL);
-    this->currentSlotConfig[i]->setCurrentWeapon(NULL);
-    this->currentSlotConfig[i]->setNextWeapon(NULL);
+    this->slotConfigs[i] = new WeaponSlot();
+    this->slotConfigs[i]->setCapability(WTYPE_ALL);
+//     this->slotConfigs[i]->setCurrentWeapon(NULL);
+//     this->slotConfigs[i]->setNextWeapon(NULL);
 
     // NAMING
@@ -95,6 +95,6 @@
       sprintf(tmpName, "WeaponMan_slot%d", i);
     }
-    this->currentSlotConfig[i]->setName(tmpName);
-    this->currentSlotConfig[i]->deactivateNode();
+    this->slotConfigs[i]->setName(tmpName);
+    this->slotConfigs[i]->deactivateNode();
     delete[] tmpName;
   }
@@ -204,5 +204,5 @@
   {
     for (int i = 0; i < WM_MAX_SLOTS; i++)
-      this->parentNode->addChild(this->currentSlotConfig[i]);
+      this->parentNode->addChild(this->slotConfigs[i]);
   }
 
@@ -232,8 +232,8 @@
   if (slot < this->slotCount)
   {
-    this->currentSlotConfig[slot]->setRelCoor(position);
+    this->slotConfigs[slot]->setRelCoor(position);
 
     if (parent != NULL)
-      this->currentSlotConfig[slot]->setParent(parent);
+      this->slotConfigs[slot]->setParent(parent);
   }
 }
@@ -248,5 +248,5 @@
 {
   if (slot < this->slotCount)
-    this->currentSlotConfig[slot]->setRelDir(rotation);
+    this->slotConfigs[slot]->setRelDir(rotation);
 }
 
@@ -276,5 +276,5 @@
       slotID = -1;
   }
-  // if no ConfigID is supplied set to Current Config.
+//   if no ConfigID is supplied set to Current Config.
   if (configID <= -1)
     configID = this->currentConfigID;
@@ -287,36 +287,38 @@
   }
 
-  if (configID > 0 && slotID > 0 && this->configs[configID][slotID] != NULL)
-  {
-    PRINTF(3)("Weapon-slot %d/%d of %s already poulated, remove weapon (%s::%s) first\n", configID, slotID, this->getCName(), weapon->getClassCName(), weapon->getCName());
+//   if (configID > 0 && slotID > 0 && this->configs[configID][slotID] != NULL)
+//   {
+//     PRINTF(3)("Weapon-slot %d/%d of %s already poulated, remove weapon (%s::%s) first\n", configID, slotID, this->getCName(), weapon->getClassCName(), weapon->getCName());
+//     return false;
+//   }
+
+//   if (slotID <= -1) // WM_FREE_SLOT
+//   {
+//     slotID = this->getNextFreeSlot(configID, weapon->getCapability());
+//     if( slotID < 0 || slotID >= this->slotCount)
+//     {
+//       PRINTF(1)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
+//       return false;
+//     }
+//   }
+
+//   if (!(this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLKINDS) &&
+//       this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLDIRS)
+//   {
+//     PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
+//               slotID, weapon->getCapability(), this->slotConfigs[slotID]->getCapability());
+//     return false;
+//   }
+
+  //! @todo check if the weapon is already assigned to another config in another slot
+//   if (this->configs[configID][slotID] != NULL)
+//     return false;
+  if( this->slotConfigs[slotID]->getWeapon(configID) != NULL )
     return false;
-  }
-
-  if (slotID <= -1) // WM_FREE_SLOT
-  {
-    slotID = this->getNextFreeSlot(configID, weapon->getCapability());
-    if( slotID < 0 || slotID >= this->slotCount)
-    {
-      PRINTF(1)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
-      return false;
-    }
-  }
-
-  if (!(this->currentSlotConfig[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLKINDS) &&
-      this->currentSlotConfig[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLDIRS)
-  {
-    PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
-              slotID, weapon->getCapability(), this->currentSlotConfig[slotID]->getCapability());
-    return false;
-  }
-
-  //! @todo check if the weapon is already assigned to another config in another slot
-  if (this->configs[configID][slotID] != NULL)
-    return false;
-
-  this->configs[configID][slotID] = weapon;
+
+  this->slotConfigs[slotID]->setWeapon(weapon, configID);
   weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType()));
-  if(configID == this->currentConfigID)
-    this->currentSlotConfig[slotID]->setNextWeapon(weapon);
+//   if(configID == this->currentConfigID)
+//     this->slotConfigs[slotID]->setNextWeapon(weapon);
   //if (this->parent != NULL)
   {
@@ -363,5 +365,5 @@
   if (slot > slotCount)
     return;
-  this->currentSlotConfig[slot]->setCapability(slotCapability);
+  this->slotConfigs[slot]->setCapability(slotCapability);
 }
 
@@ -383,12 +385,15 @@
       for (int i = 0; i < WM_MAX_CONFIGS; i++)
       {
-        if (this->configs[i][j] == weapon)
-          this->configs[i][j] = NULL;
+        if (this->slotConfigs[j]->getWeapon(i) == weapon)
+          this->slotConfigs[j]->setWeapon(NULL, i);
       }
-      if (this->currentSlotConfig[j]->getCurrentWeapon() == weapon)
-      {
-        this->currentSlotConfig[j]->setNextWeapon(NULL);
-      }
+//       if (this->slotConfigs[j]->getCurrentWeapon() == weapon)
+//       {
+//         this->slotConfigs[j]->setNextWeapon(NULL);
+//       }
     }
+  }
+  else {
+
   }
 }
@@ -427,5 +432,5 @@
 
   for (int i = 0; i < WM_MAX_SLOTS; i++)
-    this->currentSlotConfig[i]->setNextWeapon(this->configs[currentConfigID][i]);
+    this->slotConfigs[i]->setNextWeapon(currentConfigID);
 }
 
@@ -440,5 +445,5 @@
   {
 //     printf("%i ", i);
-    firingWeapon = this->currentSlotConfig[i]->getCurrentWeapon();
+    firingWeapon = this->slotConfigs[i]->getCurrentWeapon();
     if( firingWeapon != NULL)
     {
@@ -449,6 +454,6 @@
 //   printf("\n");
   /*
-	this->crosshair->setRotationSpeed(500);
-	this->crossHairSizeAnim->replay();
+  this->crosshair->setRotationSpeed(500);
+  this->crossHairSizeAnim->replay();
   */
 }
@@ -462,5 +467,5 @@
   for(int i = 0; i < this->slotCount; i++)
   {
-    firingWeapon = this->currentSlotConfig[i]->getCurrentWeapon();
+    firingWeapon = this->slotConfigs[i]->getCurrentWeapon();
     if( firingWeapon != NULL)
       firingWeapon->requestAction(WA_NONE);
@@ -481,16 +486,14 @@
   Weapon* tickWeapon;
 
-
   for(int i = 0; i < this->slotCount; i++)
   {
-
     //NICE LITTLE DEBUG FUNCTION
-    /*   if (this->currentSlotConfig[i]->currentWeapon != NULL || this->currentSlotConfig[i]->nextWeapon != NULL)
-      printf("%p %p\n", this->currentSlotConfig[i]->currentWeapon, this->currentSlotConfig[i]->nextWeapon);*/
+    /*   if (this->slotConfigs[i]->currentWeapon != NULL || this->slotConfigs[i]->nextWeapon != NULL)
+      printf("%p %p\n", this->slotConfigs[i]->currentWeapon, this->slotConfigs[i]->nextWeapon);*/
 
     // current Weapon in Slot i
-    tickWeapon = this->currentSlotConfig[i]->getCurrentWeapon();
+    tickWeapon = this->slotConfigs[i]->getCurrentWeapon();
     // On A change (current != next)
-    if (tickWeapon != this->currentSlotConfig[i]->getNextWeapon())
+    if (tickWeapon != this->slotConfigs[i]->getNextWeapon())
     {
       // if a Weapon is Active in slot i, deactivate it.
@@ -505,10 +508,11 @@
         {
           tickWeapon->toList(OM_NULL);
-          this->currentSlotConfig[i]->setCurrentWeapon(NULL);
+          this->slotConfigs[i]->setCurrentWeapon(NULL);
         }
       }
       // switching to next Weapon
-      this->currentSlotConfig[i]->setCurrentWeapon(this->currentSlotConfig[i]->getNextWeapon());
-      tickWeapon = this->currentSlotConfig[i]->getCurrentWeapon();
+//       this->slotConfigs[i]->setCurrentWeapon(this->slotConfigs[i]->getNextWeapon());
+      this->slotConfigs[i]->setNextToCurrent();
+      tickWeapon = this->slotConfigs[i]->getCurrentWeapon();
 
       if (tickWeapon != NULL)
@@ -517,14 +521,14 @@
         tickWeapon->toList(this->parentEntity->getOMListNumber());
         tickWeapon->requestAction(WA_ACTIVATE);
-        this->currentSlotConfig[i]->activateNode();
-        tickWeapon->setParent(this->currentSlotConfig[i]);
+        this->slotConfigs[i]->activateNode();
+        tickWeapon->setParent(this->slotConfigs[i]);
       }
       else
-        this->currentSlotConfig[i]->deactivateNode();
+        this->slotConfigs[i]->deactivateNode();
       if (this->parentEntity != NULL && this->parentEntity->isA(Playable::staticClassID()))
         dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
     }
     else if (unlikely(tickWeapon != NULL && tickWeapon->getCurrentState() == WS_DEACTIVATING))
-      this->currentSlotConfig[i]->setCurrentWeapon(NULL);
+      this->slotConfigs[i]->setCurrentWeapon(NULL);
   }
 }
@@ -540,5 +544,5 @@
   for (int i = 0; i < this->slotCount; i++)
   {
-    drawWeapon = this->currentSlotConfig[i]->getCurrentWeapon();
+    drawWeapon = this->slotConfigs[i]->getCurrentWeapon();
     if( drawWeapon != NULL && drawWeapon->isVisible())
       drawWeapon->draw();
@@ -558,7 +562,7 @@
       for( int i = 0; i < this->slotCount; ++i)
       {
-        if( this->configs[configID][i] == NULL &&
-            (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLKINDS) &&
-            (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLDIRS))
+        if( this->slotConfigs[i]->getWeapon(configID) == NULL &&
+            (this->slotConfigs[i]->getCapability() & capability & WTYPE_ALLKINDS) &&
+            (this->slotConfigs[i]->getCapability() & capability & WTYPE_ALLDIRS))
           return i;
       }
@@ -568,7 +572,7 @@
     for( int i = 0; i < this->slotCount; ++i)
     {
-      if( this->configs[configID][i] == NULL &&
-          (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLKINDS) &&
-          (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLDIRS))
+      if( this->slotConfigs[i]->getWeapon(configID) == NULL &&
+          (this->slotConfigs[i]->getCapability() & capability & WTYPE_ALLKINDS) &&
+          (this->slotConfigs[i]->getCapability() & capability & WTYPE_ALLDIRS))
         return i;
     }
@@ -608,6 +612,6 @@
     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]->getClassCName());
+      if (this->slotConfigs[j]->getWeapon(i) != NULL)
+        PRINT(3)("Slot %d loaded a %s\n", j, this->slotConfigs[j]->getWeapon(i)->getClassCName());
     }
   }
@@ -617,16 +621,16 @@
 long WeaponManager::getSlotCapability(int slot) const
 {
-  return this->currentSlotConfig[slot]->getCapability();
+  return this->slotConfigs[slot]->getCapability();
 }
 
 const Vector& WeaponManager::getSlotPosition(int slot) const
 {
-  return this->currentSlotConfig[slot]->getRelCoor();
+  return this->slotConfigs[slot]->getRelCoor();
 }
 
 Weapon* WeaponManager::getWeapon(int slotID) const
 {
-  return (slotID >= 0 && slotID < this->slotCount)? this->currentSlotConfig[slotID]->getNextWeapon(): NULL;
-}
-
-
+  return (slotID >= 0 && slotID < this->slotCount)? this->slotConfigs[slotID]->getNextWeapon(): NULL;
+}
+
+
Index: /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.h
===================================================================
--- /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.h	(revision 10675)
+++ /branches/vs-enhencements/src/world_entities/weapons/weapon_manager.h	(revision 10676)
@@ -122,8 +122,8 @@
     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.
-    WeaponSlot*             currentSlotConfig[WM_MAX_SLOTS];          //!< The currentConfigureation.
-
-    Weapon*                 availiableWeapons[WM_MAX_LOADED_WEAPONS]; //!< The availiable Weapons of this WeaponManager
+//     Weapon*                 configs[WM_MAX_CONFIGS][WM_MAX_SLOTS];    //!< An array of predefined configurations and assigned weapon.
+//     WeaponSlot*             currentSlotConfig[WM_MAX_SLOTS];          //!< The currentConfigureation.
+    WeaponSlot*             slotConfigs[WM_MAX_SLOTS];
+    Weapon*                 availiableWeapons[WM_MAX_LOADED_WEAPONS]; //!< The availiable Weapons of this WeaponSlot
 
     bool                    weaponChange;
Index: /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.cc
===================================================================
--- /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.cc	(revision 10675)
+++ /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.cc	(revision 10676)
@@ -12,5 +12,5 @@
 ### File Specific
    main-programmer: Patrick Boenzli
-
+   co-programmer: Nicolas Schlumberger
 */
 
@@ -30,4 +30,7 @@
 {
   this->registerObject(this, WeaponSlot::_objectList);
+
+  for (int i = 0; i < WM_MAX_CONFIGS; i++)
+    this->configs[i] = NULL;
 }
 
@@ -58,9 +61,12 @@
   .describe("sets the weapon slot");
 
-  LoadParam(root, "currentWeapon", this, WeaponSlot, setCurrentWeapon)
-  .describe("creates and set next weapon");
+//   LoadParam(root, "currentWeapon", this, WeaponSlot, setCurrentWeapon)
+//   .describe("creates and set next weapon");
+// 
+//   LoadParam(root, "nextWeapon", this, WeaponSlot, setNextWeapon)
+//   .describe("creates and set next weapon");
 
-  LoadParam(root, "nextWeapon", this, WeaponSlot, setNextWeapon)
-  .describe("creates and set next weapon");
+  LoadParam(root, "addWeapon", this, WeaponSlot, addWeapon)
+  .describe("create a new Weapon, and add it to config");
 }
 
Index: /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.h
===================================================================
--- /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.h	(revision 10675)
+++ /branches/vs-enhencements/src/world_entities/weapons/weapon_slot.h	(revision 10676)
@@ -9,4 +9,5 @@
 #include "p_node.h"
 #include "weapon.h"
+#include "weapon_manager.h"
 
 class Weapon;
@@ -31,12 +32,16 @@
 
   inline Weapon* getCurrentWeapon() { return this->currentWeapon; }
-  inline void setCurrentWeapon(Weapon* weapon) { this->currentWeapon = weapon; }
+  inline void setCurrentWeapon(int config) { this->currentWeapon = this->configs[config]; }
 
   inline Weapon* getNextWeapon() { return this->nextWeapon; }
-  inline void setNextWeapon(Weapon* weapon) { this->nextWeapon = weapon; }
+  inline void setNextWeapon(int config) { if (config == -1) this->nextWeapon = NULL; else this->nextWeapon = configs[config]; }
 
-  inline void setNextWeapon(const std::string& weaponName){this->nextWeapon = Weapon::createWeapon(weaponName); };
-  inline void setCurrentWeapon(const std::string& weaponName){ this->currentWeapon = Weapon::createWeapon(weaponName); };
+  inline void setNextToCurrent() {this->currentWeapon = this->nextWeapon; };
+//   inline void setNextWeapon(const std::string& weaponName){this->nextWeapon = Weapon::createWeapon(weaponName); };
+//   inline void setCurrentWeapon(const std::string& weaponName){ this->currentWeapon = Weapon::createWeapon(weaponName); };
 
+  inline void addWeapon(const std::string& weaponName, int config) {this->configs[config] = Weapon::createWeapon(weaponName); }
+  inline void setWeapon(Weapon* weapon, int config) {this->configs[config] = weapon; };
+  inline Weapon* getWeapon(int config) { if (config > WM_MAX_CONFIGS) return NULL; return this->configs[config]; };
 
   inline void setWeaponConfig(int slot, int side) { this->weaponSlot = slot; this->weaponSide = side; }
@@ -44,4 +49,5 @@
   inline int getWeaponSide() { return this->weaponSide; }
 
+  void removeWeapon(Weapon* weapon);
 
 private:
@@ -52,6 +58,11 @@
   long          capability;             //!< the capabilities of the Slot @see WeaponSlotCapability.
 
+  Weapon*       configs[WM_MAX_CONFIGS];
+
   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)
+
+//   int           currentConfig;
+//   int           nextConfig;
 };
 
