Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc

    r11052 r11054  
    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;
     237                return weaponPack;
     238        }
     239        return nullptr;
    240240    }
    241241
     
    273273        // Check if the WeaponSet belongs to this WeaponSystem
    274274        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)
     275        for (const auto& mapEntry : this->weaponSets_)
     276        {
     277            if (mapEntry.second == wSet)
    278278            {
    279279                foundWeaponSet = true;
     
    301301    void WeaponSystem::reload()
    302302    {
    303         for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)
    304             it->second->reload();
     303        for (const auto& mapEntry : this->weaponSets_)
     304            mapEntry.second->reload();
    305305    }
    306306
     
    308308    {
    309309        if (!identifier || !identifier->getIdentifier())
    310             return 0;
     310            return nullptr;
    311311
    312312        std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier());
     
    337337        else
    338338        {
    339             orxout(internal_warning) << "Adding munition failed. identifier == NULL " << endl;
     339            orxout(internal_warning) << "Adding munition failed. identifier == nullptr " << endl;
    340340        }
    341341    }
Note: See TracChangeset for help on using the changeset viewer.