Index: code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2914)
+++ code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc	(revision 2915)
@@ -63,12 +63,18 @@
                 this->pawn_->setWeaponSystem(0);
 
-            for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); )
-                delete (it++)->second;
-
-            for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); )
-                delete (*(it++));
-
-            for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); )
-                delete (*(it++));
+//            for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); )
+//                delete (it++)->second;
+            while (!this->weaponSets_.empty())
+                delete (this->weaponSets_.begin()->second);
+
+//            for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); )
+//                delete (*(it++));
+            while (!this->weaponPacks_.empty())
+                delete (*this->weaponPacks_.begin());
+
+//            for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); )
+//                delete (*(it++));
+            while (!this->weaponSlots_.empty())
+                delete (*this->weaponSlots_.begin());
         }
     }
@@ -79,5 +85,5 @@
             return;
 
-        this->weaponSlots_.insert(wSlot);
+        this->weaponSlots_.push_back(wSlot);
         wSlot->setWeaponSystem(this);
     }
@@ -91,5 +97,12 @@
             this->removeWeaponPack(wSlot->getWeapon()->getWeaponPack());
 
-        this->weaponSlots_.erase(wSlot);
+        for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+        {
+            if ((*it) == wSlot)
+            {
+                this->weaponSlots_.erase(it);
+                break;
+            }
+        }
     }
 
@@ -97,5 +110,5 @@
     {
         unsigned int i = 0;
-        for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+        for (std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
         {
             ++i;
@@ -159,5 +172,5 @@
 
         unsigned int freeSlots = 0;
-        for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+        for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
         {
             if (!(*it)->isOccupied())
@@ -175,5 +188,5 @@
         // Attach all weapons to the first free slots (and to the Pawn)
         unsigned int i = 0;
-        for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+        for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
         {
             if (!(*it)->isOccupied() && i < wPack->getNumWeapons())
@@ -196,5 +209,4 @@
         this->weaponPacks_.insert(wPack);
         wPack->setWeaponSystem(this);
-        wPack->attachNeededMunitionToAllWeapons(); // TODO - what is this?
 
         return true;
@@ -231,5 +243,16 @@
     bool WeaponSystem::swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2)
     {
-        // TODO
+        if (!wSlot1 || !wSlot2)
+            return false;
+
+        Weapon* weapon1 = wSlot1->getWeapon();
+        Weapon* weapon2 = wSlot2->getWeapon();
+
+        wSlot1->attachWeapon(weapon2);
+        wSlot2->attachWeapon(weapon1);
+
+        return true;
+        // In the future, certain weapons might not fit to some slots. Swapping would then be
+        // impossible and the returnvalue would be false.
     }
 
