[Orxonox-commit 257] r2912 - in branches/weapons/src/orxonox: . objects/controllers objects/weaponSystem objects/weaponSystem/munitions objects/weaponSystem/weapons objects/worldentities objects/worldentities/pawns

landauf at orxonox.net landauf at orxonox.net
Thu Apr 9 03:18:11 CEST 2009


Author: landauf
Date: 2009-04-09 03:18:11 +0200 (Thu, 09 Apr 2009)
New Revision: 2912

Modified:
   branches/weapons/src/orxonox/OrxonoxPrereqs.h
   branches/weapons/src/orxonox/objects/controllers/AIController.cc
   branches/weapons/src/orxonox/objects/controllers/HumanController.cc
   branches/weapons/src/orxonox/objects/controllers/HumanController.h
   branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc
   branches/weapons/src/orxonox/objects/weaponSystem/Munition.h
   branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
   branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.h
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
   branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h
   branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc
   branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h
   branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
   branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/HsW01.cc
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc
   branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h
   branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h
   branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc
   branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h
   branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.cc
   branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.h
Log:
Several small adjustments in the weaponsystem (like additional const keyword, includes moved from .h to .cc where possible, ...)

Firemode is now an unsigned int instead of an Enum. Instead of "fire" and "altFire" use "fire 0" and "fire 1"


Modified: branches/weapons/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/weapons/src/orxonox/OrxonoxPrereqs.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/OrxonoxPrereqs.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -73,26 +73,6 @@
         };
     }
 
-    //put here all existing munitionTypes
-    namespace MunitionType
-    {
-        enum Enum
-        { laserGunMunition };
-    }
-
-    //put here all weapon fire modes.
-    //they have to be added to Pawn and HumanController, too.
-    namespace WeaponMode
-    {
-        enum Enum
-        {
-            fire     = 0x1,
-            altFire  = 0x2,
-            altFire2 = 0x4
-        };
-    }
-
-
     class GraphicsManager;
     class OgreWindowEventListener;
     class Settings;

Modified: branches/weapons/src/orxonox/objects/controllers/AIController.cc
===================================================================
--- branches/weapons/src/orxonox/objects/controllers/AIController.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/controllers/AIController.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -110,7 +110,7 @@
             this->moveToTargetPosition(dt);
 
         if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0))
-            this->getControllableEntity()->fire(WeaponMode::fire);
+            this->getControllableEntity()->fire(0);
 
         SUPER(AIController, tick, dt);
     }

Modified: branches/weapons/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- branches/weapons/src/orxonox/objects/controllers/HumanController.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/controllers/HumanController.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -45,7 +45,6 @@
     SetConsoleCommand(HumanController, rotatePitch,   true).setAsInputCommand();
     SetConsoleCommand(HumanController, rotateRoll,    true).setAsInputCommand();
     SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
-    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
     SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
     SetConsoleCommand(HumanController, greet,         true);
     SetConsoleCommand(HumanController, use,           true);
@@ -108,18 +107,12 @@
             HumanController::localController_s->controllableEntity_->rotateRoll(value);
     }
 
-    void HumanController::fire()
+    void HumanController::fire(unsigned int firemode)
     {
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
-            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
+            HumanController::localController_s->controllableEntity_->fire(firemode);
     }
 
-    void HumanController::altFire()
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
-            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
-    }
-
     void HumanController::boost()
     {
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)

Modified: branches/weapons/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- branches/weapons/src/orxonox/objects/controllers/HumanController.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/controllers/HumanController.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -50,8 +50,7 @@
             static void rotatePitch(const Vector2& value);
             static void rotateRoll(const Vector2& value);
 
-            static void fire();
-            static void altFire();
+            static void fire(unsigned int firemode);
 
             static void boost();
             static void greet();

Modified: branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,13 +27,10 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "Munition.h"
 
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "Munition.h"
-
 namespace orxonox
 {
     CreateFactory(Munition);
@@ -41,10 +38,13 @@
     Munition::Munition(BaseObject* creator) : BaseObject(creator)
     {
         RegisterObject(Munition);
+
+COUT(0) << "+Munition" << std::endl;
     }
 
     Munition::~Munition()
     {
+COUT(0) << "~Munition" << std::endl;
     }
 
     unsigned int Munition::bullets()
@@ -111,10 +111,4 @@
     {
         this->magazines_ = this->maxMagazines_;
     }
-
-    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(Munition, XMLPort, xmlelement, mode);
-    }
-
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/Munition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Munition.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Munition.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,12 +30,8 @@
 #define _Munition_H__
 
 #include "OrxonoxPrereqs.h"
-
 #include "core/BaseObject.h"
 
-#include "Weapon.h"
-
-
 namespace orxonox
 {
     class _OrxonoxExport Munition : public BaseObject
@@ -44,8 +40,6 @@
             Munition(BaseObject* creator);
             virtual ~Munition();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
             void setMaxBullets(unsigned int amount);
             void setMaxMagazines(unsigned int amount);
 

Modified: branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,12 +27,13 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "Weapon.h"
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "Weapon.h"
+#include "Munition.h"
+#include "WeaponSystem.h"
 
 namespace orxonox
 {
@@ -44,7 +45,7 @@
 
         this->bulletReadyToShoot_ = true;
         this->magazineReadyToShoot_ = true;
-        this->parentWeaponSystem_ = 0;
+        this->weaponSystem_ = 0;
         this->attachedToWeaponSlot_ = 0;
         this->bulletLoadingTime_ = 0;
         this->magazineLoadingTime_ = 0;
@@ -54,13 +55,15 @@
         this->munition_ = 0;
         this->unlimitedMunition_ = false;
         this->setObjectMode(0x0);
+
+COUT(0) << "+Weapon" << std::endl;
     }
 
     Weapon::~Weapon()
     {
+COUT(0) << "~Weapon" << std::endl;
     }
 
-
     void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(Weapon, XMLPort, xmlelement, mode);
@@ -151,14 +154,14 @@
 
 
 
-    void Weapon::attachNeededMunition(std::string munitionName)
+    void Weapon::attachNeededMunition(const std::string& munitionName)
     {
         /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
         */
-        if (this->parentWeaponSystem_)
+        if (this->weaponSystem_)
         {
             //getMunitionType returns 0 if there is no such munitionType
-            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
+            Munition* munition = this->weaponSystem_->getMunitionType(munitionName);
             if ( munition )
             {
                 this->munition_ = munition;
@@ -169,16 +172,16 @@
                 //create new munition with identifier because there is no such munitionType
                 this->munitionIdentifier_ = ClassByString(munitionName);
                 this->munition_ = this->munitionIdentifier_.fabricate(this);
-                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
+                this->weaponSystem_->setNewMunition(munitionName, this->munition_);
                 this->setMunition();
             }
         }
     }
 
 
-    Munition * Weapon::getAttachedMunition(std::string munitionType)
+    Munition * Weapon::getAttachedMunition(const std::string& munitionType)
     {
-        this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
+        this->munition_ = this->weaponSystem_->getMunitionType(munitionType);
         return this->munition_;
     }
 
@@ -192,40 +195,40 @@
 
 
     //get and set functions for XMLPort
-    void Weapon::setMunitionType(std::string munitionType)
+    void Weapon::setMunitionType(const std::string& munitionType)
     {   this->munitionType_ = munitionType; }
 
-    const std::string Weapon::getMunitionType()
+    const std::string& Weapon::getMunitionType() const
     {   return this->munitionType_;  }
 
     void Weapon::setBulletLoadingTime(float loadingTime)
     {   this->bulletLoadingTime_ = loadingTime; }
 
-    const float Weapon::getBulletLoadingTime()
+    const float Weapon::getBulletLoadingTime() const
     {   return this->bulletLoadingTime_;  }
 
     void Weapon::setMagazineLoadingTime(float loadingTime)
     {   this->magazineLoadingTime_ = loadingTime; }
 
-    const float Weapon::getMagazineLoadingTime()
+    const float Weapon::getMagazineLoadingTime() const
     {   return this->magazineLoadingTime_;  }
 
     void Weapon::setBulletAmount(unsigned int amount)
     {   this->bulletAmount_ = amount; }
 
-    const unsigned int Weapon::getBulletAmount()
+    const unsigned int Weapon::getBulletAmount() const
     {   return this->bulletAmount_;  }
 
     void Weapon::setMagazineAmount(unsigned int amount)
     {   this->magazineAmount_ = amount; }
 
-    const unsigned int Weapon::getMagazineAmount()
+    const unsigned int Weapon::getMagazineAmount() const
     {   return this->magazineAmount_;   }
 
     void Weapon::setUnlimitedMunition(bool unlimitedMunition)
     {   this->unlimitedMunition_ = unlimitedMunition;   }
 
-    const bool Weapon::getUnlimitedMunition()
+    const bool Weapon::getUnlimitedMunition() const
     {   return this->unlimitedMunition_;    }
 
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,17 +30,11 @@
 #define _Weapon_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/worldentities/StaticEntity.h"
 
-#include "core/BaseObject.h"
-#include "tools/BillboardSet.h"
 #include "tools/Timer.h"
 #include "core/Identifier.h"
 
-#include "WeaponSystem.h"
-#include "Munition.h"
-
-#include "objects/worldentities/StaticEntity.h"
-
 namespace orxonox
 {
     class _OrxonoxExport Weapon : public StaticEntity
@@ -52,8 +46,8 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
             virtual void fire();
-            void attachNeededMunition(std::string munitionType);
-            Munition * getAttachedMunition(std::string munitiontype);
+            void attachNeededMunition(const std::string& munitionType);
+            Munition * getAttachedMunition(const std::string& munitiontype);
 
             //reloading
             void bulletTimer(float bulletLoadingTime);
@@ -62,18 +56,18 @@
             void magazineReloaded();
 
             //XMLPort functions
-            virtual void setMunitionType(std::string munitionType);
-            virtual const std::string getMunitionType();
+            virtual void setMunitionType(const std::string& munitionType);
+            virtual const std::string& getMunitionType() const;
             virtual void setBulletLoadingTime(float loadingTime);
-            virtual const float getBulletLoadingTime();
+            virtual const float getBulletLoadingTime() const;
             virtual void setMagazineLoadingTime(float loadingTime);
-            virtual const float getMagazineLoadingTime();
+            virtual const float getMagazineLoadingTime() const;
             virtual void setBulletAmount(unsigned int amount);
-            virtual const unsigned int getBulletAmount();
+            virtual const unsigned int getBulletAmount() const;
             virtual void setMagazineAmount(unsigned int amount);
-            virtual const unsigned int getMagazineAmount();
+            virtual const unsigned int getMagazineAmount() const;
             virtual void setUnlimitedMunition(bool unlimitedMunition);
-            virtual const bool getUnlimitedMunition();
+            virtual const bool getUnlimitedMunition() const;
 
             //weapon actions
             virtual void takeBullets();
@@ -85,20 +79,17 @@
             //manually set or reset
             virtual void setWeapon();
             virtual void setMunition();
-            
-            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
-                { this->parentWeaponSystem_=parentWeaponSystem; };
-            inline WeaponSystem * getParentWeaponSystem()
-                { return this->parentWeaponSystem_; };
 
+            inline void setWeaponSystem(WeaponSystem *weaponSystem)
+                { this->weaponSystem_ = weaponSystem; };
+            inline WeaponSystem * getWeaponSystem() const
+                { return this->weaponSystem_; };
+
             inline void setAttachedToWeaponSlot(WeaponSlot * wSlot)
                 { this->attachedToWeaponSlot_ = wSlot; }
-            inline WeaponSlot * getAttachedToWeaponSlot()
+            inline WeaponSlot * getAttachedToWeaponSlot() const
                 { return this->attachedToWeaponSlot_; }
 
-
-        private:
-
         protected:
             bool bReloading_;
             bool bulletReadyToShoot_;
@@ -112,7 +103,7 @@
 
             WeaponSlot * attachedToWeaponSlot_;
             Munition * munition_;
-            WeaponSystem * parentWeaponSystem_;
+            WeaponSystem * weaponSystem_;
 
             SubclassIdentifier<Munition> munitionIdentifier_;
 

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -26,16 +26,15 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "WeaponPack.h"
 
-#include <vector>
-
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Debug.h"
-
-#include "WeaponPack.h"
 #include "objects/worldentities/pawns/Pawn.h"
 
+#include "Weapon.h"
+#include "WeaponSlot.h"
+
 namespace orxonox
 {
     CreateFactory(WeaponPack);
@@ -44,17 +43,27 @@
     {
         RegisterObject(WeaponPack);
 
-        this->parentWeaponSystem_ = 0;
+        this->weaponSystem_ = 0;
         this->firemode_ = 0;
 
+COUT(0) << "+WeaponPack" << std::endl;
     }
 
     WeaponPack::~WeaponPack()
     {
+COUT(0) << "~WeaponPack" << std::endl;
     }
 
-    int WeaponPack::getSize()
+    void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
+        SUPER(WeaponPack, XMLPort, xmlelement, mode);
+
+        XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
+        XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode);
+    }
+
+    int WeaponPack::getSize() const
+    {
         return this->weapons_.size();
     }
 
@@ -66,25 +75,17 @@
         }
     }
 
-    Weapon * WeaponPack::getWeaponPointer(unsigned int n)
+    Weapon * WeaponPack::getWeaponPointer(unsigned int n) const
     {
         return this->weapons_[n];
     }
 
-    void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(WeaponPack, XMLPort, xmlelement, mode);
-
-        XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
-        XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode);
-    }
-
     void WeaponPack::setFireMode(unsigned int firemode)
     {
         this->firemode_ = firemode;
     }
 
-    unsigned int WeaponPack::getFireMode()
+    unsigned int WeaponPack::getFireMode() const
     {
         return this->firemode_;
     }
@@ -94,28 +95,23 @@
         this->weapons_.push_back(weapon);
     }
 
-    const Weapon * WeaponPack::getWeapon(unsigned int index)
+    const Weapon * WeaponPack::getWeapon(unsigned int index) const
     {
         return weapons_[index];
     }
 
-    void WeaponPack::setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
+    void WeaponPack::setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
     {
-        for (int i=0; i < (int) this->weapons_.size(); i++)
-        {
-            this->weapons_[i]->setParentWeaponSystem(weaponSystem);
-        }
-
+        for (size_t i = 0; i < this->weapons_.size(); i++)
+            this->weapons_[i]->setWeaponSystem(weaponSystem);
     }
 
     void WeaponPack::attachNeededMunitionToAllWeapons()
     {
-        for (int i=0; i < (int) this->weapons_.size(); i++)
+        for (size_t i = 0; i < this->weapons_.size(); i++)
         {
             this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
             this->weapons_[i]->setWeapon();
         }
-
     }
-
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -32,11 +32,10 @@
 
 #include "OrxonoxPrereqs.h"
 
+#include <vector>
+
 #include "core/BaseObject.h"
 
-#include "Weapon.h"
-
-
 namespace orxonox
 {
     class _OrxonoxExport WeaponPack : public BaseObject
@@ -49,28 +48,29 @@
 
             void fire();
 
-            Weapon * getWeaponPointer(unsigned int n);
-            int getSize();
+            Weapon * getWeaponPointer(unsigned int n) const;
+            int getSize() const;
 
             void setFireMode(unsigned int firemode);
-            unsigned int getFireMode();
+            unsigned int getFireMode() const;
 
             void addWeapon(Weapon * weapon);
-            const Weapon * getWeapon(unsigned int index);
+            const Weapon * getWeapon(unsigned int index) const;
 
+            void attachNeededMunitionToAllWeapons();
+
             //functions with effect to all weapons of the weaponPack
             //functions needed for creating Pointer to the right objects (-->Pawn.cc)
-            void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
-            void attachNeededMunitionToAllWeapons();
+            inline void setWeaponSystem(WeaponSystem *weaponSystem)
+                { this->weaponSystem_ = weaponSystem; this->setWeaponSystemToAllWeapons(weaponSystem); }
+            inline WeaponSystem * getWeaponSystem() const
+                { return this->weaponSystem_; }
 
-            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
-                { parentWeaponSystem_=parentWeaponSystem; }
-            inline WeaponSystem * getParentWeaponSystem()
-                { return parentWeaponSystem_; }
+        private:
+            void setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
 
-        private:
             std::vector<Weapon *> weapons_;
-            WeaponSystem *parentWeaponSystem_;
+            WeaponSystem *weaponSystem_;
             unsigned int firemode_;
     };
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -26,16 +26,16 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "WeaponSet.h"
 
-#include <vector>
-
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Debug.h"
 #include "objects/worldentities/pawns/Pawn.h"
 
-#include "WeaponSet.h"
+#include "Weapon.h"
+#include "WeaponSlot.h"
 #include "WeaponPack.h"
+#include "WeaponSystem.h"
 
 namespace orxonox
 {
@@ -45,43 +45,53 @@
     {
         RegisterObject(WeaponSet);
 
-        this->parentWeaponSystem_ = 0;
+        this->weaponSystem_ = 0;
         this->attachedWeaponPack_ = 0;
+
+COUT(0) << "+WeaponSet" << std::endl;
     }
 
     WeaponSet::~WeaponSet()
     {
+COUT(0) << "~WeaponSet" << std::endl;
     }
 
+    void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(WeaponSet, XMLPort, xmlelement, mode);
+
+        XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode);
+    }
+
     void WeaponSet::attachWeaponPack(WeaponPack *wPack)
     {
-        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
+        if ( this->weaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->weaponSystem_->getWeaponSlotSize() ) )
         {
             this->attachedWeaponPack_ = wPack;
             int wPackWeapon = 0;    //WeaponCounter for Attaching
-           
+
             //should be possible to choose which slot to use
             //attach every weapon of the weaponPack to a weaponSlot
             for (  int i=0; i < wPack->getSize() ; i++  )
             {
                 //at the moment this function only works for one weaponPack in the entire WeaponSystem...
                 //it also takes the first free weaponSlot...
-                if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
+                if ( this->weaponSystem_->getWeaponSlot(i)->getAttachedWeapon() == 0 && this->weaponSystem_->getWeaponSlot(i) != 0) //if slot not full
                 {
-                    this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) );
-                    this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
-                    this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
+                    this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(i) );
+                    this->weaponSystem_->getWeaponSlot(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
+                    this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
                     wPackWeapon++;
                 }
                 else
                 {
-                    for (int k=0; k < this->parentWeaponSystem_->getWeaponSlotSize(); k++)
+                    for (int k=0; k < this->weaponSystem_->getWeaponSlotSize(); k++)
                     {
-                        if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
+                        if ( this->weaponSystem_->getWeaponSlot(k)->getAttachedWeapon() == 0 )
                         {
-                            this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) );
-                            this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
-                            this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
+                            this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(k) );
+                            this->weaponSystem_->getWeaponSlot(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
+                            this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
                             wPackWeapon++;
                         }
                     }
@@ -97,17 +107,4 @@
         if (this->attachedWeaponPack_)
             this->attachedWeaponPack_->fire();
     }
-
-    void WeaponSet::setFireMode(const unsigned int firemode)
-    {   this->firemode_ = firemode; }
-
-    const unsigned int WeaponSet::getFireMode() const
-    {   return this->firemode_; }
-
-    void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(WeaponSet, XMLPort, xmlelement, mode);
-        XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode);
-    }
-
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -32,11 +32,10 @@
 
 #include "OrxonoxPrereqs.h"
 
+#include <vector>
+
 #include "core/BaseObject.h"
 
-#include "WeaponSlot.h"
-
-
 namespace orxonox
 {
     class _OrxonoxExport WeaponSet : public BaseObject
@@ -50,16 +49,18 @@
             void attachWeaponPack(WeaponPack *wPack);
             void fire();
 
-            void setFireMode(const unsigned int firemode);
-            const unsigned int getFireMode() const;
+            inline void setFireMode(const unsigned int firemode)
+                { this->firemode_ = firemode; }
+            inline unsigned int getFireMode() const
+                { return this->firemode_; }
 
-            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
-                { parentWeaponSystem_=parentWeaponSystem; }
-            inline WeaponSystem * getParentWeaponSystem()
-                { return parentWeaponSystem_; }
+            inline void setWeaponSystem(WeaponSystem *weaponSystem)
+                { this->weaponSystem_ = weaponSystem; }
+            inline WeaponSystem * getWeaponSystem() const
+                { return this->weaponSystem_; }
 
         private:
-            WeaponSystem *parentWeaponSystem_;
+            WeaponSystem *weaponSystem_;
             std::vector<WeaponSlot *> setWeaponSlots_;
             unsigned int firemode_;
             WeaponPack * attachedWeaponPack_;

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,14 +27,13 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "WeaponSlot.h"
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "WeaponSlot.h"
+#include "Weapon.h"
 
-
 namespace orxonox
 {
     CreateFactory(WeaponSlot);
@@ -46,12 +45,19 @@
         this->unlimitedAmmo_ = false;
         this->attachedWeapon_ = 0;
         this->setObjectMode(0x0);
+
+COUT(0) << "+WeaponSlot" << std::endl;
     }
 
     WeaponSlot::~WeaponSlot()
     {
+COUT(0) << "~WeaponSlot" << std::endl;
     }
 
+    void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(WeaponSlot, XMLPort, xmlelement, mode);
+    }
 
     /*sets the munition type
      *unlimited: true
@@ -70,12 +76,6 @@
         this->attachedWeapon_->fire();
     }
 
-
-    void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(WeaponSlot, XMLPort, xmlelement, mode);
-    }
-
     void WeaponSlot::attachWeapon(Weapon *weapon)
     {
         this->attachedWeapon_ = weapon;

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,8 +30,6 @@
 #define _WeaponSlot_H__
 
 #include "OrxonoxPrereqs.h"
-
-#include "Weapon.h"
 #include "objects/worldentities/StaticEntity.h"
 
 namespace orxonox
@@ -49,17 +47,17 @@
             void setAmmoType(bool isUnlimited);
             void fire();
 
-            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
-                { parentWeaponSystem_=parentWeaponSystem; }
-            inline WeaponSystem * getParentWeaponSystem()
-                { return parentWeaponSystem_; }
+            inline void setWeaponSystem(WeaponSystem *weaponSystem)
+                { this->weaponSystem_ = weaponSystem; }
+            inline WeaponSystem * getWeaponSystem() const
+                { return this->weaponSystem_; }
 
 
         private:
             Weapon *attachedWeapon_;
             bool unlimitedAmmo_;
 
-            WeaponSystem *parentWeaponSystem_;
+            WeaponSystem *weaponSystem_;
     };
 }
 

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,16 +27,15 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "WeaponSystem.h"
 
-#include <vector>
-
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
+#include "objects/worldentities/pawns/Pawn.h"
 
-#include "WeaponSystem.h"
+#include "WeaponSlot.h"
+#include "WeaponPack.h"
+#include "WeaponSet.h"
 
-
 /* WeaponSystem
  *
  *  www.orxonox.net/wiki/WeaponSystem
@@ -50,40 +49,96 @@
     {
         RegisterObject(WeaponSystem);
 
-        this->parentPawn_ = 0;
+        this->pawn_ = 0;
+COUT(0) << "+WeaponSystem" << std::endl;
     }
 
     WeaponSystem::~WeaponSystem()
     {
+COUT(0) << "~WeaponSystem" << std::endl;
+        if (this->isInitialized())
+        {
+            if (this->pawn_)
+                this->pawn_->setWeaponSystem(0);
+        }
     }
 
-    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode)
+    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
     {
-        if (firemode < this->weaponSets_.size())
-            this->weaponSets_[firemode]->attachWeaponPack(wPack);
-        this->weaponPacks_.push_back(wPack);
+        if (!wSet)
+            return;
+
+        this->weaponSets_[wSet->getFireMode()] = wSet;
+        wSet->setWeaponSystem(this);
     }
 
+    WeaponSet * WeaponSystem::getWeaponSet(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::map<unsigned int, WeaponSet*>::const_iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
+        {
+            ++i;
+            if (i > index)
+                return it->second;
+        }
+        return 0;
+    }
+
     void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot)
     {
-        wSlot->setParentWeaponSystem(this);
-        this->weaponSlots_.push_back(wSlot);
+        if (!wSlot)
+            return;
+
+        this->weaponSlots_.insert(wSlot);
+        wSlot->setWeaponSystem(this);
     }
 
-    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
+    WeaponSlot * WeaponSystem::getWeaponSlot(unsigned int index) const
     {
-        wSet->setParentWeaponSystem(this);
-        this->weaponSets_.push_back(wSet);
+        unsigned int i = 0;
+        for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
+        {
+            ++i;
+            if (i > index)
+                return (*it);
+        }
+        return 0;
     }
 
-    void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd)
+    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int wSetNumber)
     {
+        if (!wPack)
+            return;
+
+        std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.find(wSetNumber);
+        if (it != this->weaponSets_.end() && it->second)
+            it->second->attachWeaponPack(wPack);
+
+        this->weaponPacks_.insert(wPack);
+        wPack->setWeaponSystem(this);
+        wPack->attachNeededMunitionToAllWeapons(); // TODO - what is this?
+    }
+
+    WeaponPack * WeaponSystem::getWeaponPack(unsigned int index) const
+    {
+        unsigned int i = 0;
+        for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
+        {
+            ++i;
+            if (i > index)
+                return (*it);
+        }
+        return 0;
+   }
+
+    void WeaponSystem::setNewMunition(const std::string& munitionType, Munition * munitionToAdd)
+    {
         this->munitionSet_[munitionType] = munitionToAdd;
     }
 
 
     //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
-    Munition * WeaponSystem::getMunitionType(std::string munitionType)
+    Munition * WeaponSystem::getMunitionType(const std::string& munitionType) const
     {
         std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
         if (it != this->munitionSet_.end())
@@ -96,53 +151,10 @@
     //n is the n'th weaponSet, starting with zero
     //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode)
     //in future this could be well defined and not only for 3 different WeaponModes
-    void WeaponSystem::fire(WeaponMode::Enum n)
+    void WeaponSystem::fire(unsigned int firemode)
     {
-        int set = 0;
-        switch (n)
-        {
-            case WeaponMode::fire:
-                set = 0;
-                break;
-            case WeaponMode::altFire:
-                set = 1;
-                break;
-            case WeaponMode::altFire2:
-                set = 2;
-                break;
-        }
-        if (set < (int)this->weaponSets_.size())
-            this->weaponSets_[set]->fire();
+        std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.find(firemode);
+        if (it != this->weaponSets_.end() && it->second)
+            it->second->fire();
     }
-
-
-    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
-    {
-        if (n < this->weaponSets_.size())
-            return this->weaponSets_[n];
-        else
-            return 0;
-    }
-
-    WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n)
-    {
-        if (n < this->weaponSlots_.size())
-            return this->weaponSlots_[n];
-        else
-            return 0;
-    }
-
-    WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n)
-    {
-        if (n < this->weaponPacks_.size())
-            return this->weaponPacks_[n];
-        else
-            return 0;
-    }
-
-    void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(WeaponSystem, XMLPort, xmlelement, mode);
-    }
-
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -32,13 +32,14 @@
 
 #include "OrxonoxPrereqs.h"
 
+#include <set>
+#include <map>
+
 #include "core/BaseObject.h"
 
-#include "WeaponSet.h"
-#include "WeaponPack.h"
-
 namespace orxonox
 {
+    const unsigned int MAX_FIRE_MODES = 8;
 
     class _OrxonoxExport WeaponSystem : public BaseObject
     {
@@ -46,34 +47,40 @@
             WeaponSystem(BaseObject* creator);
             virtual ~WeaponSystem();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            void attachWeaponSlot(WeaponSlot * wSlot);
+            WeaponSlot * getWeaponSlot(unsigned int index) const;
 
-            void attachWeaponSlot(WeaponSlot *wSlot);
-            void attachWeaponSet(WeaponSet *wSet);
-            //void fire();
-            void fire(WeaponMode::Enum fireMode);
-            void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
-            WeaponSet * getWeaponSetPointer(unsigned int n);
-            WeaponSlot * getWeaponSlotPointer(unsigned int n);
-            WeaponPack * getWeaponPackPointer(unsigned int n);
-            void setNewMunition(std::string munitionType, Munition * munitionToAdd);
-            void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);
-            Munition * getMunitionType(std::string munitionType);
+            void attachWeaponSet(WeaponSet * wSet);
+            WeaponSet * getWeaponSet(unsigned int index) const;
 
-            inline void setParentPawn(Pawn *parentPawn)
-                { parentPawn_=parentPawn; }
-            inline Pawn * getParentPawn()
-                { return parentPawn_; }
+            void attachWeaponPack(WeaponPack * wPack, unsigned int wSetNumber);
+            WeaponPack * getWeaponPack(unsigned int index) const;
 
-            inline int getWeaponSlotSize()
+            void fire(unsigned int firemode);
+
+            void setNewMunition(const std::string& munitionType, Munition * munitionToAdd);
+            void setNewSharedMunition(const std::string& munitionType, Munition * munitionToAdd);
+            Munition * getMunitionType(const std::string& munitionType) const;
+
+            inline void setPawn(Pawn * pawn)
+                { this->pawn_ = pawn; }
+            inline Pawn * getPawn() const
+                { return this->pawn_; }
+
+            inline int getWeaponSlotSize() const
                 { return this->weaponSlots_.size(); }
 
+            static inline unsigned int getMaxFireModes()
+                { return MAX_FIRE_MODES; }
+            static inline unsigned int getFireModeMask(unsigned int firemode)
+                { return (0x1 << firemode); }
+
         private:
-            std::vector<WeaponSet *> weaponSets_;
-            std::vector<WeaponSlot *> weaponSlots_;
-            std::vector<WeaponPack *> weaponPacks_;
+            std::map<unsigned int, WeaponSet *> weaponSets_;
+            std::set<WeaponSlot *> weaponSlots_;
+            std::set<WeaponPack *> weaponPacks_;
             std::map<std::string, Munition *> munitionSet_;
-            Pawn *parentPawn_;
+            Pawn * pawn_;
     };
 }
 

Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,13 +27,10 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "FusionMunition.h"
 
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "FusionMunition.h"
-
 namespace orxonox
 {
     CreateFactory(FusionMunition);

Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/FusionMunition.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,10 +30,8 @@
 #define _FusionMunition_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/Munition.h"
 
-#include "core/BaseObject.h"
-#include "../Munition.h"
-
 namespace orxonox
 {
     class _OrxonoxExport FusionMunition : public Munition

Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,13 +27,10 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "LaserGunMunition.h"
 
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "LaserGunMunition.h"
-
 namespace orxonox
 {
     CreateFactory(LaserGunMunition);

Modified: branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,10 +30,8 @@
 #define _LaserGunMunition_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/Munition.h"
 
-#include "core/BaseObject.h"
-#include "../Munition.h"
-
 namespace orxonox
 {
     class _OrxonoxExport LaserGunMunition : public Munition

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,15 +27,14 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "Fusion.h"
 
-
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "Fusion.h"
+#include "objects/weaponSystem/Munition.h"
+#include "objects/weaponSystem/projectiles/ParticleProjectile.h"
+#include "objects/weaponSystem/WeaponSystem.h"
 
-
 namespace orxonox
 {
     CreateFactory(Fusion);
@@ -72,6 +71,6 @@
         projectile->setOrientation(this->getWorldOrientation());
         projectile->setPosition(this->getWorldPosition());
         projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
-        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
+        projectile->setOwner(this->getWeaponSystem()->getPawn());
     }
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Fusion.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,15 +30,8 @@
 #define _Fusion_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/Weapon.h"
 
-#include "core/BaseObject.h"
-
-#include "../munitions/LaserGunMunition.h"
-#include "util/Math.h"
-#include "../Weapon.h"
-#include "../projectiles/BillboardProjectile.h"
-#include "../projectiles/ParticleProjectile.h"
-
 namespace orxonox
 {
     class _OrxonoxExport Fusion : public Weapon

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/HsW01.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/HsW01.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/HsW01.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -1,83 +1,79 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Martin Polak
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
-
-#include "HsW01.h"
-
-
-namespace orxonox
-{
-    CreateFactory(HsW01);
-
-    HsW01::HsW01(BaseObject* creator) : Weapon(creator)
-    {
-        RegisterObject(HsW01);
-
-        this->speed_ = 1250;
-
-    }
-
-    HsW01::~HsW01()
-    {
-    }
-
-    void HsW01::reloadBullet()
-    {
-        this->bulletTimer(this->bulletLoadingTime_);
-    }
-
-    void HsW01::reloadMagazine()
-    {
-        this->magazineTimer(this->magazineLoadingTime_);
-    }
-
-    void HsW01::takeBullets()
-    {
-        this->munition_->removeBullets(1);
-    }
-
-    void HsW01::takeMagazines()
-    {
-        this->munition_->removeMagazines(1);
-    }
-
-    void HsW01::createProjectile()
-    {
-        BillboardProjectile* projectile = new ParticleProjectile(this);
-        projectile->setOrientation(this->getWorldOrientation());
-        projectile->setPosition(this->getWorldPosition());
-        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
-        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
-    }
-}
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Martin Polak
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HsW01.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(HsW01);
+
+    HsW01::HsW01(BaseObject* creator) : Weapon(creator)
+    {
+        RegisterObject(HsW01);
+
+        this->speed_ = 1250;
+
+    }
+
+    HsW01::~HsW01()
+    {
+    }
+
+    void HsW01::reloadBullet()
+    {
+        this->bulletTimer(this->bulletLoadingTime_);
+    }
+
+    void HsW01::reloadMagazine()
+    {
+        this->magazineTimer(this->magazineLoadingTime_);
+    }
+
+    void HsW01::takeBullets()
+    {
+        this->munition_->removeBullets(1);
+    }
+
+    void HsW01::takeMagazines()
+    {
+        this->munition_->removeMagazines(1);
+    }
+
+    void HsW01::createProjectile()
+    {
+        BillboardProjectile* projectile = new ParticleProjectile(this);
+        projectile->setOrientation(this->getWorldOrientation());
+        projectile->setPosition(this->getWorldPosition());
+        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
+        projectile->setOwner(this->getWeaponSystem()->getPawn());
+    }
+}

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,15 +27,14 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "LaserGun.h"
 
-
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/Debug.h"
 
-#include "LaserGun.h"
+#include "objects/weaponSystem/Munition.h"
+#include "objects/weaponSystem/projectiles/ParticleProjectile.h"
+#include "objects/weaponSystem/WeaponSystem.h"
 
-
 namespace orxonox
 {
     CreateFactory(LaserGun);
@@ -78,6 +77,6 @@
         projectile->setOrientation(this->getWorldOrientation());
         projectile->setPosition(this->getWorldPosition());
         projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
-        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
+        projectile->setOwner(this->getWeaponSystem()->getPawn());
     }
 }

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/LaserGun.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,15 +30,8 @@
 #define _LaserGun_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/weaponSystem/Weapon.h"
 
-#include "core/BaseObject.h"
-
-#include "../munitions/LaserGunMunition.h"
-#include "util/Math.h"
-#include "../Weapon.h"
-#include "../projectiles/BillboardProjectile.h"
-#include "../projectiles/ParticleProjectile.h"
-
 namespace orxonox
 {
     class _OrxonoxExport LaserGun : public Weapon

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -27,14 +27,11 @@
  */
 
 #include "OrxonoxStableHeaders.h"
+#include "Missile.h"
 
-#include <list>
-
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "util/Debug.h"
 
-
 namespace orxonox
 {
     Missile::Missile(BaseObject* creator) : Weapon(creator)

Modified: branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/weaponSystem/weapons/Missile.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,10 +30,8 @@
 #define _Missile_H__
 
 #include "OrxonoxPrereqs.h"
-
 #include "objects/weaponSystem/Weapon.h"
 
-
 namespace orxonox
 {
     class _OrxonoxExport Missile : public Weapon

Modified: branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -30,9 +30,7 @@
 #define _ControllableEntity_H__
 
 #include "OrxonoxPrereqs.h"
-
 #include "MobileEntity.h"
-#include "objects/weaponSystem/WeaponSystem.h"
 
 namespace orxonox
 {
@@ -82,8 +80,7 @@
             inline void rotateRoll(float value)
                 { this->rotateRoll(Vector2(value, 0)); }
 
-            virtual void fire(WeaponMode::Enum fireMode) {}
-            virtual void altFire(WeaponMode::Enum fireMode) {}
+            virtual void fire(unsigned int firemode) {}
 
             virtual void boost() {}
             virtual void greet() {}

Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -38,6 +38,10 @@
 #include "objects/gametypes/Gametype.h"
 #include "objects/worldentities/ParticleSpawner.h"
 #include "objects/worldentities/ExplosionChunk.h"
+#include "objects/weaponSystem/WeaponSystem.h"
+#include "objects/weaponSystem/WeaponSlot.h"
+#include "objects/weaponSystem/WeaponPack.h"
+#include "objects/weaponSystem/WeaponSet.h"
 
 namespace orxonox
 {
@@ -65,7 +69,7 @@
         if (GameMode::isMaster())
         {
             this->weaponSystem_ = new WeaponSystem(this);
-            this->weaponSystem_->setParentPawn(this);
+            this->weaponSystem_->setPawn(this);
         }
         else
             this->weaponSystem_ = 0;
@@ -99,9 +103,9 @@
         XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
         XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
 
-        XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);
-        XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode);
-        XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);
+        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
+        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
+        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
     }
 
     void Pawn::registerVariables()
@@ -118,12 +122,9 @@
 
         if (this->weaponSystem_)
         {
-            if (this->fire_ & WeaponMode::fire)
-                this->weaponSystem_->fire(WeaponMode::fire);
-            if (this->fire_ & WeaponMode::altFire)
-                this->weaponSystem_->fire(WeaponMode::altFire);
-            if (this->fire_ & WeaponMode::altFire2)
-                this->weaponSystem_->fire(WeaponMode::altFire2);
+            for (unsigned int firemode = 0; firemode < WeaponSystem::getMaxFireModes(); firemode++)
+                if (this->fire_ & WeaponSystem::getFireModeMask(firemode))
+                    this->weaponSystem_->fire(firemode);
         }
         this->fire_ = this->firehack_;
         this->firehack_ = 0x0;
@@ -251,9 +252,9 @@
         }
     }
 
-    void Pawn::fire(WeaponMode::Enum fireMode)
+    void Pawn::fire(unsigned int firemode)
     {
-        this->firehack_ |= fireMode;
+        this->firehack_ |= WeaponSystem::getFireModeMask(firemode);
     }
 
     void Pawn::postSpawn()
@@ -274,7 +275,7 @@
     *   with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it.
     *       --> e.g. Pickup-Items
     */
-    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
+    void Pawn::addWeaponSlot(WeaponSlot * wSlot)
     {
         this->attach(wSlot);
         if (this->weaponSystem_)
@@ -284,31 +285,26 @@
     WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
     {
         if (this->weaponSystem_)
-            return this->weaponSystem_->getWeaponSlotPointer(index);
+            return this->weaponSystem_->getWeaponSlot(index);
         else
             return 0;
     }
 
-    void Pawn::setWeaponPack(WeaponPack * wPack)
+    void Pawn::addWeaponPack(WeaponPack * wPack)
     {
         if (this->weaponSystem_)
-        {
-            wPack->setParentWeaponSystem(this->weaponSystem_);
-            wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_);
-            this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
-            wPack->attachNeededMunitionToAllWeapons();
-        }
+            this->weaponSystem_->attachWeaponPack(wPack, wPack->getFireMode());
     }
 
     WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const
     {
         if (this->weaponSystem_)
-            return this->weaponSystem_->getWeaponPackPointer(firemode);
+            return this->weaponSystem_->getWeaponPack(firemode);
         else
             return 0;
     }
 
-    void Pawn::setWeaponSet(WeaponSet * wSet)
+    void Pawn::addWeaponSet(WeaponSet * wSet)
     {
         if (this->weaponSystem_)
             this->weaponSystem_->attachWeaponSet(wSet);
@@ -317,7 +313,7 @@
     WeaponSet * Pawn::getWeaponSet(unsigned int index) const
     {
         if (this->weaponSystem_)
-            return this->weaponSystem_->getWeaponSetPointer(index);
+            return this->weaponSystem_->getWeaponSet(index);
         else
             return 0;
     }

Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -33,12 +33,13 @@
 #include "objects/pickup/ShipEquipment.h"
 #include "objects/worldentities/ControllableEntity.h"
 #include "objects/RadarViewable.h"
-#include "objects/weaponSystem/WeaponSystem.h"
 
 namespace orxonox
 {
     class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
     {
+        friend class WeaponSystem;
+
         public:
             Pawn(BaseObject* creator);
             virtual ~Pawn();
@@ -78,14 +79,14 @@
             virtual void hit(Pawn* originator, const Vector3& force, float damage);
             virtual void kill();
 
-            virtual void fire(WeaponMode::Enum fireMode);
+            virtual void fire(unsigned int firemode);
             virtual void postSpawn();
 
-            void setWeaponSlot(WeaponSlot * wSlot);
+            void addWeaponSlot(WeaponSlot * wSlot);
             WeaponSlot * getWeaponSlot(unsigned int index) const;
-            void setWeaponPack(WeaponPack * wPack);
+            void addWeaponPack(WeaponPack * wPack);
             WeaponPack * getWeaponPack(unsigned int firemode) const;
-            void setWeaponSet(WeaponSet * wSet);
+            void addWeaponSet(WeaponSet * wSet);
             WeaponSet * getWeaponSet(unsigned int index) const;
 
             inline const WorldEntity* getWorldEntity() const
@@ -133,6 +134,10 @@
             std::string spawnparticlesource_;
             float spawnparticleduration_;
             unsigned int numexplosionchunks_;
+
+        private:
+            inline void setWeaponSystem(WeaponSystem* weaponsystem)
+                { this->weaponSystem_ = weaponsystem; }
     };
 
     class _OrxonoxExport PawnListener : virtual public OrxonoxClass

Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.cc
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.cc	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.cc	2009-04-09 01:18:11 UTC (rev 2912)
@@ -195,7 +195,7 @@
         ControllableEntity::rotateRoll(value);
     }
 
-    void Spectator::fire(WeaponMode::Enum fireMode)
+    void Spectator::fire(unsigned int firemode)
     {
         if (this->getPlayer())
             this->getPlayer()->setReadyToSpawn(true);

Modified: branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.h
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.h	2009-04-08 00:58:40 UTC (rev 2911)
+++ branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.h	2009-04-09 01:18:11 UTC (rev 2912)
@@ -56,7 +56,7 @@
             virtual void rotatePitch(const Vector2& value);
             virtual void rotateRoll(const Vector2& value);
 
-            virtual void fire(WeaponMode::Enum fireMode);
+            virtual void fire(unsigned int firemode);
             virtual void greet();
 
         private:




More information about the Orxonox-commit mailing list