Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/weaponsystem/DefaultWeaponmodeLink.h

    r9667 r11071  
    4242            virtual ~DefaultWeaponmodeLink();
    4343
    44             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     44            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4545
    4646            inline void setFiremode(const unsigned int firemode)
  • code/trunk/src/orxonox/weaponsystem/Munition.cc

    r11052 r11071  
    5252        this->reloadTime_ = 0.5f;
    5353
    54         this->lastFilledWeaponMode_ = NULL;
     54        this->lastFilledWeaponMode_ = nullptr;
    5555    }
    5656
    5757    Munition::~Munition()
    5858    {
    59         for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    60             delete it->second;
     59        for (const auto& mapEntry : this->assignedMagazines_)
     60            delete mapEntry.second;
    6161    }
    6262
     
    7676            // For separated magazines we definitively need a given user
    7777            if (!user)
    78                 return 0;
     78                return nullptr;
    7979
    8080            // Use the map to get the magazine assigned to the given user
     
    9090        }
    9191
    92         return 0;
     92        return nullptr;
    9393    }
    9494
     
    200200                    magazine->munition_ = 0;
    201201
    202                     if (this->reload(NULL))
     202                    if (this->reload(nullptr))
    203203                        // Successfully reloaded, continue recursively
    204204                        return this->takeMunition(amount, 0);
     
    262262        if (deployment_ != MunitionDeployment::Separate)
    263263        {
    264             user = NULL;
     264            user = nullptr;
    265265        }
    266266
     
    271271            if (it->first == lastFilledWeaponMode_)
    272272            {
    273                 lastFilledWeaponMode_ = NULL;
     273                lastFilledWeaponMode_ = nullptr;
    274274            }           
    275275            delete it->second;
     
    299299        {
    300300            // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
    301             for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    302                 if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
     301            for (const auto& mapEntry : this->assignedMagazines_)
     302                if (mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_)
    303303                    return true;
    304304        }
     
    315315        {
    316316            // Stacking munition means, if a magazine gets full, the munition adds to a new magazine
    317             Magazine* magazine = this->getMagazine(NULL);
     317            Magazine* magazine = this->getMagazine(nullptr);
    318318            if (magazine)
    319319            {
     
    345345            std::map<WeaponMode*, Magazine*>::iterator it;
    346346
    347             // 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
     347            // If the pointer to the weapon mode whose magazine got munition added to is nullptr, then set the iterator to the beginning of the map
    348348            // Otherwise set it to the next weapon mode
    349             if (lastFilledWeaponMode_ == NULL)
     349            if (lastFilledWeaponMode_ == nullptr)
    350350            {
    351351                it = this->assignedMagazines_.begin();
     
    441441        for (unsigned int i = 0; i < addedMagazines; ++i)
    442442        {
    443             for (std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)
    444             {
    445                 if (needReload(it->first))
    446                 {
    447                     reload(it->first);
     443            for (const auto& mapEntry : this->assignedMagazines_)
     444            {
     445                if (needReload(mapEntry.first))
     446                {
     447                    reload(mapEntry.first);
    448448                    break;
    449449                }
     
    515515        // If we don't use separate magazines, set user to 0
    516516        if (deployment_ != MunitionDeployment::Separate)
    517             user = NULL;
     517            user = nullptr;
    518518
    519519        // Remove the current magazine for the given user
     
    523523            if (it->first == lastFilledWeaponMode_)
    524524            {
    525                 lastFilledWeaponMode_ = NULL;
     525                lastFilledWeaponMode_ = nullptr;
    526526            }
    527527            delete it->second;
  • code/trunk/src/orxonox/weaponsystem/Munition.h

    r11052 r11071  
    3939namespace orxonox
    4040{
    41     namespace MunitionDeployment
     41    enum class MunitionDeployment
    4242    {
    43         enum Value
    44         {
    45             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.
    46             Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
    47             Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
    48         };
    49     }
     43        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.
     44        Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
     45        Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
     46    };
    5047
    5148    class _OrxonoxExport Munition : public BaseObject
     
    6966            virtual ~Munition();
    7067
    71             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     68            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    7269
    7370            unsigned int getNumMunition(WeaponMode* user) const;
     
    8077            inline unsigned int getMaxMunitionPerMagazine() const
    8178                { return this->maxMunitionPerMagazine_; }
    82             inline MunitionDeployment::Value getMunitionDeployment() const
     79            inline MunitionDeployment getMunitionDeployment() const
    8380                { return deployment_; }
    8481
     
    115112            std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used.
    116113
    117             MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
     114            MunitionDeployment deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
    118115
    119116            bool bAllowMunitionRefilling_;
  • code/trunk/src/orxonox/weaponsystem/ReplenishingMunition.h

    r11052 r11071  
    5252        public:
    5353            ReplenishingMunition(Context* context);
    54             virtual ~ReplenishingMunition() {}
     54            virtual ~ReplenishingMunition() = default;
    5555
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     56            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5757           
    58             virtual float getProgress();
     58            float getProgress();
    5959            inline unsigned int getReplenishAmount() const
    6060                { return replenishAmount_; }
  • code/trunk/src/orxonox/weaponsystem/Weapon.cc

    r11052 r11071  
    4545        RegisterObject(Weapon);
    4646
    47         this->weaponPack_ = 0;
    48         this->weaponSlot_ = 0;
     47        this->weaponPack_ = nullptr;
     48        this->weaponSlot_ = nullptr;
    4949        this->bReloading_ = false;
    5050        this->reloadingWeaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
     
    6161                this->weaponPack_->removeWeapon(this);
    6262
    63             for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
    64                 it->second->destroy();
     63            for (const auto& mapEntry : this->weaponmodes_)
     64                mapEntry.second->destroy();
    6565        }
    6666    }
     
    8585    {
    8686        unsigned int i = 0;
    87         for (std::multimap<unsigned int, WeaponMode*>::const_iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
     87        for (const auto& mapEntry : this->weaponmodes_)
    8888        {
    8989            if (i == index)
    90                 return it->second;
     90                return mapEntry.second;
    9191
    9292            ++i;
    9393        }
    94         return 0;
     94        return nullptr;
    9595    }
    9696
     
    140140    void Weapon::reload()
    141141    {
    142         for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
    143             it->second->reload();
     142        for (const auto& mapEntry : this->weaponmodes_)
     143            mapEntry.second->reload();
    144144    }
    145145
     
    152152    void Weapon::notifyWeaponModes()
    153153    {
    154         for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
    155             it->second->setWeapon(this);
     154        for (const auto& mapEntry : this->weaponmodes_)
     155            mapEntry.second->setWeapon(this);
    156156    }
    157157
    158158    void Weapon::updateMunition()
    159159    {
    160         for (std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)
    161             it->second->updateMunition();
     160        for (const auto& mapEnty : this->weaponmodes_)
     161            mapEnty.second->updateMunition();
    162162    }
    163163}
  • code/trunk/src/orxonox/weaponsystem/Weapon.h

    r11052 r11071  
    5050            virtual ~Weapon();
    5151
    52             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     52            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5353
    5454            void fire(unsigned int mode);
     
    5757            void addWeaponmode(WeaponMode* weaponmode);
    5858            WeaponMode* getWeaponmode(unsigned int index) const;
    59             inline std::multimap<unsigned int, WeaponMode*>* getAllWeaponmodes()
    60                 { return &weaponmodes_; }
     59            inline const std::multimap<unsigned int, WeaponMode*>& getAllWeaponmodes() const
     60                { return weaponmodes_; }
    6161            inline int getNumWeaponModes() const
    6262                { return weaponmodes_.size(); }
  • code/trunk/src/orxonox/weaponsystem/WeaponMode.cc

    r11052 r11071  
    5151        RegisterObject(WeaponMode);
    5252
    53         this->weapon_ = 0;
     53        this->weapon_ = nullptr;
    5454        this->mode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
    5555
    56         this->munition_ = 0;
     56        this->munition_ = nullptr;
    5757        this->initialMunition_ = 0;
    5858        this->initialMagazines_ = 0;
     
    244244        else
    245245        {
    246             this->munition_ = NULL;
     246            this->munition_ = nullptr;
    247247        }
    248248    }
  • code/trunk/src/orxonox/weaponsystem/WeaponMode.h

    r11052 r11071  
    5252            virtual ~WeaponMode();
    5353
    54             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     54            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5555
    5656            bool fire(float* reloadTime);
  • code/trunk/src/orxonox/weaponsystem/WeaponPack.cc

    r11052 r11071  
    4444        RegisterObject(WeaponPack);
    4545
    46         this->weaponSystem_ = 0;
     46        this->weaponSystem_ = nullptr;
    4747    }
    4848
     
    7676    void WeaponPack::fire(unsigned int weaponmode)
    7777    {
    78         for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    79             (*it)->fire(weaponmode);
     78        for (Weapon* weapon : this->weapons_)
     79            weapon->fire(weaponmode);
    8080    }
    8181
     
    8686    void WeaponPack::reload()
    8787    {
    88         for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    89             (*it)->reload();
     88        for (Weapon* weapon : this->weapons_)
     89            weapon->reload();
    9090    }
    9191
     
    107107        assert(it != this->weapons_.end());
    108108        this->weapons_.erase(it);
    109         weapon->setWeaponPack(0);
     109        weapon->setWeaponPack(nullptr);
    110110    }
    111111
     
    114114        unsigned int i = 0;
    115115
    116         for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     116        for (Weapon* weapon : this->weapons_)
    117117        {
    118118            if (i == index)
    119                 return (*it);
     119                return weapon;
    120120            ++i;
    121121        }
    122122
    123         return 0;
     123        return nullptr;
    124124    }
    125 
    126     std::vector<Weapon*>* WeaponPack::getAllWeapons()
    127     {
    128         return &weapons_;       
    129     }   
    130125
    131126    void WeaponPack::addDefaultWeaponmodeLink(DefaultWeaponmodeLink* link)
     
    137132    {
    138133        unsigned int i = 0;
    139         for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
     134        for (DefaultWeaponmodeLink* link : this->links_)
    140135        {
    141136            if (i == index)
    142                 return (*it);
     137                return link;
    143138
    144139            ++i;
    145140        }
    146         return 0;
     141        return nullptr;
    147142    }
    148143
    149144    unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const
    150145    {
    151         for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
    152             if ((*it)->getFiremode() == firemode)
    153                 return (*it)->getWeaponmode();
     146        for (DefaultWeaponmodeLink* link : this->links_)
     147            if (link->getFiremode() == firemode)
     148                return link->getWeaponmode();
    154149
    155150        return WeaponSystem::WEAPON_MODE_UNASSIGNED;
     
    158153    void WeaponPack::notifyWeapons()
    159154    {
    160         for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    161             (*it)->setWeaponPack(this);
     155        for (Weapon* weapon : this->weapons_)
     156            weapon->setWeaponPack(this);
    162157    }
    163158
    164159    void WeaponPack::updateMunition()
    165160    {
    166         for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    167             (*it)->updateMunition();
     161        for (Weapon* weapon : this->weapons_)
     162            weapon->updateMunition();
    168163    }
    169164}
  • code/trunk/src/orxonox/weaponsystem/WeaponPack.h

    r11052 r11071  
    4444            virtual ~WeaponPack();
    4545
    46             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4747
    4848            void fire(unsigned int weaponmode);
     
    5252            void removeWeapon(Weapon * weapon);
    5353            Weapon * getWeapon(unsigned int index) const;
    54             std::vector<Weapon*>* getAllWeapons();
     54            inline const std::vector<Weapon*>& getAllWeapons() const
     55                { return weapons_; }
    5556
    5657            inline size_t getNumWeapons() const
  • code/trunk/src/orxonox/weaponsystem/WeaponSet.cc

    r10650 r11071  
    4343        RegisterObject(WeaponSet);
    4444
    45         this->weaponSystem_ = 0;
     45        this->weaponSystem_ = nullptr;
    4646        this->desiredFiremode_ = WeaponSystem::FIRE_MODE_UNASSIGNED;
    4747    }
     
    6363    {
    6464        // Fire all WeaponPacks with their defined weaponmode
    65         for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
    66             if (it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
    67                 it->first->fire(it->second);
     65        for (const auto& mapEntry : this->weaponpacks_)
     66            if (mapEntry.second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
     67                mapEntry.first->fire(mapEntry.second);
    6868    }
    6969
     
    7171    {
    7272        // Reload all WeaponPacks with their defined weaponmode
    73         for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
    74             it->first->reload();
     73        for (const auto& mapEntry : this->weaponpacks_)
     74            mapEntry.first->reload();
    7575    }
    7676
  • code/trunk/src/orxonox/weaponsystem/WeaponSet.h

    r9667 r11071  
    4444            virtual ~WeaponSet();
    4545
    46             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4747
    4848            void fire();
  • code/trunk/src/orxonox/weaponsystem/WeaponSlot.cc

    r10648 r11071  
    4343        RegisterObject(WeaponSlot);
    4444
    45         this->weaponSystem_ = 0;
    46         this->weapon_ = 0;
     45        this->weaponSystem_ = nullptr;
     46        this->weapon_ = nullptr;
    4747
    4848        this->setSyncMode(ObjectDirection::None);
     
    8888        if (this->weapon_)
    8989        {
    90             this->weapon_->setWeaponSlot(0);
    91             this->weapon_ = 0;
     90            this->weapon_->setWeaponSlot(nullptr);
     91            this->weapon_ = nullptr;
    9292        }
    9393    }
  • code/trunk/src/orxonox/weaponsystem/WeaponSlot.h

    r10650 r11071  
    6262            virtual ~WeaponSlot();
    6363
    64             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6565
    6666            void attachWeapon(Weapon * weapon);
     
    7474            */
    7575            inline bool isOccupied() const
    76                 { return (this->weapon_ != 0); }
     76                { return (this->weapon_ != nullptr); }
    7777
    7878            inline void setWeaponSystem(WeaponSystem * weaponSystem)
  • code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc

    r11052 r11071  
    5252        RegisterObject(WeaponSystem);
    5353
    54         this->pawn_ = 0;
     54        this->pawn_ = nullptr;
    5555    }
    5656
     
    6060        {
    6161            if (this->pawn_)
    62                 this->pawn_->setWeaponSystem(0);
     62                this->pawn_->setWeaponSystem(nullptr);
    6363
    6464            while (!this->weaponSets_.empty())
     
    106106    {
    107107        unsigned int i = 0;
    108         for (std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
     108        for (WeaponSlot* weaponSlot : this->weaponSlots_)
    109109        {
    110110            ++i;
    111111            if (i > index)
    112                 return (*it);
    113         }
    114         return 0;
     112                return weaponSlot;
     113        }
     114        return nullptr;
    115115    }
    116116
     
    153153    {
    154154        unsigned int i = 0;
    155         for (std::map<unsigned int, WeaponSet*>::const_iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
     155        for (const auto& mapEntry : this->weaponSets_)
    156156        {
    157157            ++i;
    158158            if (i > index)
    159                 return it->second;
    160         }
    161         return 0;
     159                return mapEntry.second;
     160        }
     161        return nullptr;
    162162    }
    163163
     
    168168
    169169        unsigned int freeSlots = 0;
    170         for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
    171         {
    172             if (!(*it)->isOccupied())
     170        for (WeaponSlot* weaponSlot : this->weaponSlots_)
     171        {
     172            if (!weaponSlot->isOccupied())
    173173                ++freeSlots;
    174174        }
     
    184184        // Attach all weapons to the first free slots (and to the Pawn)
    185185        unsigned int i = 0;
    186         for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)
    187         {
    188             if (!(*it)->isOccupied() && i < wPack->getNumWeapons())
     186        for (WeaponSlot* weaponSlot : this->weaponSlots_)
     187        {
     188            if (!weaponSlot->isOccupied() && i < wPack->getNumWeapons())
    189189            {
    190190                Weapon* weapon = wPack->getWeapon(i);
    191                 (*it)->attachWeapon(weapon);
     191                weaponSlot->attachWeapon(weapon);
    192192                this->getPawn()->attach(weapon);
    193193                ++i;
     
    196196
    197197        // Assign the desired weaponmode to the firemodes
    198         for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
    199         {
    200             unsigned int weaponmode = wPack->getDesiredWeaponmode(it->first);
     198        for (const auto& mapEntry : this->weaponSets_)
     199        {
     200            unsigned int weaponmode = wPack->getDesiredWeaponmode(mapEntry.first);
    201201            if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED)
    202                 it->second->setWeaponmodeLink(wPack, weaponmode);
     202                mapEntry.second->setWeaponmodeLink(wPack, weaponmode);
    203203        }
    204204
     
    213213        // Remove all weapons from their WeaponSlot
    214214        unsigned int i = 0;
    215         Weapon* weapon = 0;
     215        Weapon* weapon = nullptr;
    216216        while ((weapon = wPack->getWeapon(i++)))
    217217            if (weapon->getWeaponSlot())
     
    219219
    220220        // Remove all added links from the WeaponSets
    221         for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
    222             it->second->removeWeaponmodeLink(wPack);
     221        for (const auto& mapEntry : this->weaponSets_)
     222            mapEntry.second->removeWeaponmodeLink(wPack);
    223223
    224224        // Remove the WeaponPack from the WeaponSystem
     
    231231    {
    232232        unsigned int i = 0;
    233         for (std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
     233        for (WeaponPack* weaponPack : this->weaponPacks_)
    234234        {
    235235            ++i;
    236236            if (i > index)
    237                 return (*it);
    238         }
    239         return 0;
    240     }
    241 
    242     std::vector<WeaponPack *> * WeaponSystem::getAllWeaponPacks()
    243     {
    244         return &weaponPacks_;
    245     }   
     237                return weaponPack;
     238        }
     239        return nullptr;
     240    }
    246241
    247242    bool WeaponSystem::swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2)
     
    273268        // Check if the WeaponSet belongs to this WeaponSystem
    274269        bool foundWeaponSet = false;
    275         for (std::map<unsigned int, WeaponSet *>::iterator it2 = this->weaponSets_.begin(); it2 != this->weaponSets_.end(); ++it2)
    276         {
    277             if (it2->second == wSet)
     270        for (const auto& mapEntry : this->weaponSets_)
     271        {
     272            if (mapEntry.second == wSet)
    278273            {
    279274                foundWeaponSet = true;
     
    301296    void WeaponSystem::reload()
    302297    {
    303         for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
    304             it->second->reload();
     298        for (const auto& mapEntry : this->weaponSets_)
     299            mapEntry.second->reload();
    305300    }
    306301
     
    308303    {
    309304        if (!identifier || !identifier->getIdentifier())
    310             return 0;
     305            return nullptr;
    311306
    312307        std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier());
     
    317312        else
    318313        {
    319             return NULL;
     314            return nullptr;
    320315        }
    321316    }
     
    323318    void WeaponSystem::addMunition(Munition* munition)
    324319    {
    325         if (munition == NULL)
     320        if (munition == nullptr)
    326321        {
    327322            return;
     
    337332        else
    338333        {
    339             orxout(internal_warning) << "Adding munition failed. identifier == NULL " << endl;
     334            orxout(internal_warning) << "Adding munition failed. identifier == nullptr " << endl;
    340335        }
    341336    }
     
    343338    void WeaponSystem::updateMunition()
    344339    {
    345         for (std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
    346         {
    347             (*it)->updateMunition();
     340        for (WeaponPack* weaponPack : this->weaponPacks_)
     341        {
     342            weaponPack->updateMunition();
    348343        }
    349344    }
  • code/trunk/src/orxonox/weaponsystem/WeaponSystem.h

    r11052 r11071  
    6767            void removeWeaponPack(WeaponPack * wPack);
    6868            WeaponPack * getWeaponPack(unsigned int index) const;
    69             std::vector<WeaponPack *> * getAllWeaponPacks();
     69            inline const std::vector<WeaponPack *>& getAllWeaponPacks() const
     70                { return weaponPacks_; }
    7071
    7172            // configure slots and firemodes
Note: See TracChangeset for help on using the changeset viewer.