[Orxonox-commit 6405] r11062 - in code/branches/cpp11_v3/src: libraries/core libraries/core/module modules/overlays/hud modules/weapons/munitions orxonox/gametypes orxonox/overlays orxonox/weaponsystem orxonox/worldentities orxonox/worldentities/pawns

landauf at orxonox.net landauf at orxonox.net
Wed Jan 13 23:13:30 CET 2016


Author: landauf
Date: 2016-01-13 23:13:30 +0100 (Wed, 13 Jan 2016)
New Revision: 11062

Modified:
   code/branches/cpp11_v3/src/libraries/core/GUIManager.cc
   code/branches/cpp11_v3/src/libraries/core/module/Plugin.cc
   code/branches/cpp11_v3/src/modules/overlays/hud/HUDHealthBar.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/FusionMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/GravityBombMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/IceMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/LaserMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/LightningMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/MineMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/RocketMunition.h
   code/branches/cpp11_v3/src/modules/weapons/munitions/SplitMunition.h
   code/branches/cpp11_v3/src/orxonox/gametypes/Dynamicmatch.cc
   code/branches/cpp11_v3/src/orxonox/overlays/OverlayGroup.cc
   code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.cc
   code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.h
   code/branches/cpp11_v3/src/orxonox/weaponsystem/Weapon.cc
   code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponPack.cc
   code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc
   code/branches/cpp11_v3/src/orxonox/worldentities/TeamSpawnPoint.h
   code/branches/cpp11_v3/src/orxonox/worldentities/pawns/Pawn.cc
Log:
added c++11 features to code that was modified in presentationHS15

Modified: code/branches/cpp11_v3/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/cpp11_v3/src/libraries/core/GUIManager.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/libraries/core/GUIManager.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -266,8 +266,8 @@
         {
             ArgumentCompletionList names;
             const std::vector<std::string> guis = GUIManager::getInstance().getLoadedGUIs();
-            for (size_t i = 0; i < guis.size(); ++i)
-                names.push_back(ArgumentCompletionListElement(guis[i], getLowercase(guis[i])));
+            for (const std::string gui : guis)
+                names.push_back(ArgumentCompletionListElement(gui, getLowercase(gui)));
             return names;
         }
     }

Modified: code/branches/cpp11_v3/src/libraries/core/module/Plugin.cc
===================================================================
--- code/branches/cpp11_v3/src/libraries/core/module/Plugin.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/libraries/core/module/Plugin.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -78,7 +78,7 @@
     void Plugin::load()
     {
         // only load module if it isn't already loaded. otherwise merely activate it.
-        if (this->moduleInstance_ == NULL)
+        if (this->moduleInstance_ == nullptr)
             this->loadModule();
         else
             this->activateModule();
@@ -111,7 +111,7 @@
         orxout(internal_info) << "Unloading plugin " << this->name_ << "..." << endl;
         Core::getInstance().unloadModule(this->moduleInstance_);
         delete this->moduleInstance_;
-        this->moduleInstance_ = NULL;
+        this->moduleInstance_ = nullptr;
     }
     void Plugin::deactivateModule()
     {

Modified: code/branches/cpp11_v3/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- code/branches/cpp11_v3/src/modules/overlays/hud/HUDHealthBar.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/overlays/hud/HUDHealthBar.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -111,8 +111,8 @@
             inline void setHealthBarOwner(Pawn* owner)
                 { this->owner_ = owner; }
         protected:
-            virtual void positionChanged();
-            virtual void sizeChanged();
+            virtual void positionChanged() override;
+            virtual void sizeChanged() override;
         private:
             void positionText();
             WeakPtr<Pawn> owner_;

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/FusionMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/FusionMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/FusionMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             FusionMunition(Context* context);
-            virtual ~FusionMunition() {}
+            virtual ~FusionMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/GravityBombMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/GravityBombMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/GravityBombMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -26,7 +26,7 @@
     {
         public:
             GravityBombMunition(Context* context);
-            virtual ~GravityBombMunition() {}
+            virtual ~GravityBombMunition() = default;
     };
 
 }

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/IceMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/IceMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/IceMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             IceMunition(Context* context);
-            virtual ~IceMunition() {}
+            virtual ~IceMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/LaserMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/LaserMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/LaserMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             LaserMunition(Context* context);
-            virtual ~LaserMunition() {}
+            virtual ~LaserMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/LightningMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/LightningMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/LightningMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             LightningMunition(Context* context);
-            virtual ~LightningMunition() {}
+            virtual ~LightningMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/MineMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/MineMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/MineMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             MineMunition(Context* context);
-            virtual ~MineMunition() {}
+            virtual ~MineMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/RocketMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/RocketMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/RocketMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             RocketMunition(Context* context);
-            virtual ~RocketMunition() {}
+            virtual ~RocketMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/modules/weapons/munitions/SplitMunition.h
===================================================================
--- code/branches/cpp11_v3/src/modules/weapons/munitions/SplitMunition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/modules/weapons/munitions/SplitMunition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
     {
         public:
             SplitMunition(Context* context);
-            virtual ~SplitMunition() {}
+            virtual ~SplitMunition() = default;
     };
 }
 

Modified: code/branches/cpp11_v3/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/gametypes/Dynamicmatch.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/gametypes/Dynamicmatch.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -87,8 +87,8 @@
 
     Dynamicmatch::~Dynamicmatch()
     {
-        for (std::set<Timer*>::iterator it = this->piggyTimers_.begin(); it != this->piggyTimers_.end(); ++it)
-            delete (*it);
+        for (Timer* timer : this->piggyTimers_)
+            delete timer;
     }
 
     void Dynamicmatch::setConfigValues()

Modified: code/branches/cpp11_v3/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/overlays/OverlayGroup.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/overlays/OverlayGroup.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -50,8 +50,8 @@
         ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(overlaygroupnames)()
         {
             ArgumentCompletionList names;
-            for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>().begin(); it; ++it)
-                names.push_back(ArgumentCompletionListElement(it->getName(), getLowercase(it->getName())));
+            for (OverlayGroup* overlayGroup : ObjectList<OverlayGroup>())
+                names.push_back(ArgumentCompletionListElement(overlayGroup->getName(), getLowercase(overlayGroup->getName())));
             return names;
         }
     }

Modified: code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -51,7 +51,7 @@
 
         this->reloadTime_ = 0.5f;
 
-        this->lastFilledWeaponMode_ = NULL;
+        this->lastFilledWeaponMode_ = nullptr;
     }
 
     Munition::~Munition()
@@ -199,7 +199,7 @@
                     amount -= magazine->munition_;
                     magazine->munition_ = 0;
 
-                    if (this->reload(NULL))
+                    if (this->reload(nullptr))
                         // Successfully reloaded, continue recursively
                         return this->takeMunition(amount, 0);
                     else
@@ -270,7 +270,7 @@
         {
             if (it->first == lastFilledWeaponMode_)
             {
-                lastFilledWeaponMode_ = NULL;
+                lastFilledWeaponMode_ = nullptr;
             }            
             delete it->second;
             this->assignedMagazines_.erase(it);
@@ -314,7 +314,7 @@
         if (deployment_ == MunitionDeployment::Stack)
         {
             // Stacking munition means, if a magazine gets full, the munition adds to a new magazine
-            Magazine* magazine = this->getMagazine(NULL);
+            Magazine* magazine = this->getMagazine(nullptr);
             if (magazine)
             {
                 // Add the whole amount
@@ -346,7 +346,7 @@
 
             // If the pointer to the weapon mode whose magazine got munition added to is NULL, then set the iterator to the beginning of the map
             // Otherwise set it to the next weapon mode
-            if (lastFilledWeaponMode_ == NULL)
+            if (lastFilledWeaponMode_ == nullptr)
             {
                 it = this->assignedMagazines_.begin();
             }
@@ -440,11 +440,11 @@
         // Double loop and break is needed because the reload function changes the assigned magazines. This may confuse the iterator.
         for (unsigned int i = 0; i < addedMagazines; ++i)
         {
-            for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
+            for (const auto& mapEntry : this->assignedMagazines_)
             {
-                if (needReload(it->first))
+                if (needReload(mapEntry.first))
                 {
-                    reload(it->first);
+                    reload(mapEntry.first);
                     break;
                 }
             }
@@ -522,7 +522,7 @@
         {
             if (it->first == lastFilledWeaponMode_)
             {
-                lastFilledWeaponMode_ = NULL;
+                lastFilledWeaponMode_ = nullptr;
             }
             delete it->second;
             this->assignedMagazines_.erase(it);           
@@ -557,4 +557,4 @@
         this->bLoaded_ = true;
         this->munition_ = munition->maxMunitionPerMagazine_;
     }
-}
\ No newline at end of file
+}

Modified: code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.h
===================================================================
--- code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -38,15 +38,12 @@
 
 namespace orxonox
 {
-    namespace MunitionDeployment
+    enum class MunitionDeployment
     {
-        enum Value
-        {
-            Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some.
-            Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
-            Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
-        };
-    }
+        Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some.
+        Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
+        Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
+    };
 
     class _OrxonoxExport Munition : public BaseObject
     {        
@@ -68,7 +65,7 @@
             Munition(Context* context);
             virtual ~Munition();
 
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
 
             unsigned int getNumMunition(WeaponMode* user) const;
             unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
@@ -79,7 +76,7 @@
                 { return this->maxMagazines_; }
             inline unsigned int getMaxMunitionPerMagazine() const
                 { return this->maxMunitionPerMagazine_; }
-            inline MunitionDeployment::Value getMunitionDeployment() const
+            inline MunitionDeployment getMunitionDeployment() const
                 { return deployment_; }
 
 
@@ -114,7 +111,7 @@
             unsigned int unassignedMagazines_; // Number of magazines that are not assigned to a weapon mode. These are alway treated as full.
             std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used.
 
-            MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
+            MunitionDeployment deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
 
             bool bAllowMunitionRefilling_;
             bool bAllowMultiMunitionRemovementUnderflow_;

Modified: code/branches/cpp11_v3/src/orxonox/weaponsystem/Weapon.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/weaponsystem/Weapon.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/weaponsystem/Weapon.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -157,7 +157,7 @@
 
     void Weapon::updateMunition()
     {
-        for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
-            it->second->updateMunition();
+        for (const auto& mapEnty : this->weaponmodes_)
+            mapEnty.second->updateMunition();
     }
 }

Modified: code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponPack.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponPack.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponPack.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -158,7 +158,7 @@
 
     void WeaponPack::updateMunition()
     {
-        for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
-            (*it)->updateMunition();
+        for (Weapon* weapon : this->weapons_)
+            weapon->updateMunition();
     }
 }

Modified: code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -311,13 +311,13 @@
         }
         else
         {
-            return NULL;
+            return nullptr;
         }
     }
 
     void WeaponSystem::addMunition(Munition* munition)
     {
-        if (munition == NULL)
+        if (munition == nullptr)
         {
             return;
         }
@@ -337,9 +337,9 @@
 
     void WeaponSystem::updateMunition()
     {
-        for (std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
+        for (WeaponPack* weaponPack : this->weaponPacks_)
         {
-            (*it)->updateMunition();
+            weaponPack->updateMunition();
         }
     }
 }

Modified: code/branches/cpp11_v3/src/orxonox/worldentities/TeamSpawnPoint.h
===================================================================
--- code/branches/cpp11_v3/src/orxonox/worldentities/TeamSpawnPoint.h	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/worldentities/TeamSpawnPoint.h	2016-01-13 22:13:30 UTC (rev 11062)
@@ -48,7 +48,7 @@
                 { this->teamNumber_ = team; }
             unsigned int getTeamNumber() const
                 { return this->teamNumber_; }
-            virtual Pawn* spawn();
+            virtual Pawn* spawn() override;
 
         private:
             int teamNumber_;

Modified: code/branches/cpp11_v3/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/cpp11_v3/src/orxonox/worldentities/pawns/Pawn.cc	2016-01-13 22:02:33 UTC (rev 11061)
+++ code/branches/cpp11_v3/src/orxonox/worldentities/pawns/Pawn.cc	2016-01-13 22:13:30 UTC (rev 11062)
@@ -85,7 +85,7 @@
 
         this->aimPosition_ = Vector3::ZERO;
 
-        //this->explosionPartList_ = NULL;
+        //this->explosionPartList_ = nullptr;
 
         if (GameMode::isMaster())
         {
@@ -522,7 +522,7 @@
 
     Munition* Pawn::getMunitionXML() const
     {
-        return NULL;
+        return nullptr;
     }
 
     Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier)
@@ -532,7 +532,7 @@
             return weaponSystem_->getMunition(identifier);
         }
 
-        return NULL;
+        return nullptr;
     }
 
     //Tell the Map (RadarViewable), if this is a playership




More information about the Orxonox-commit mailing list