Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 2, 2015, 11:22:03 PM (9 years ago)
Author:
landauf
Message:

use actual types instead of 'auto'. only exception is for complicated template types, e.g. when iterating over a map

Location:
code/branches/cpp11_v2/src/orxonox/weaponsystem
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc

    r10821 r10916  
    5555    Munition::~Munition()
    5656    {
    57         for (auto & elem : this->currentMagazines_)
    58             delete elem.second;
     57        for (auto& mapEntry : this->currentMagazines_)
     58            delete mapEntry.second;
    5959    }
    6060
     
    268268        {
    269269            // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
    270             for (const auto & elem : this->currentMagazines_)
    271                 if (elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
     270            for (const auto& mapEntry : this->currentMagazines_)
     271                if (mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_)
    272272                    return true;
    273273        }
     
    316316            {
    317317                bool change = false;
    318                 for (auto & elem : this->currentMagazines_)
     318                for (auto& mapEntry : this->currentMagazines_)
    319319                {
    320320                    // Add munition if the magazine isn't full (but only to loaded magazines)
    321                     if (amount > 0 && elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
     321                    if (amount > 0 && mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_)
    322322                    {
    323                         elem.second->munition_++;
     323                        mapEntry.second->munition_++;
    324324                        amount--;
    325325                        change = true;
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc

    r10821 r10916  
    6161                this->weaponPack_->removeWeapon(this);
    6262
    63             for (auto & elem : this->weaponmodes_)
    64                 elem.second->destroy();
     63            for (auto& mapEntry : this->weaponmodes_)
     64                mapEntry.second->destroy();
    6565        }
    6666    }
     
    8585    {
    8686        unsigned int i = 0;
    87         for (const auto & elem : this->weaponmodes_)
     87        for (const auto& mapEntry : this->weaponmodes_)
    8888        {
    8989            if (i == index)
    90                 return elem.second;
     90                return mapEntry.second;
    9191
    9292            ++i;
     
    136136    void Weapon::reload()
    137137    {
    138         for (auto & elem : this->weaponmodes_)
    139             elem.second->reload();
     138        for (auto& mapEntry : this->weaponmodes_)
     139            mapEntry.second->reload();
    140140    }
    141141
     
    148148    void Weapon::notifyWeaponModes()
    149149    {
    150         for (auto & elem : this->weaponmodes_)
    151             elem.second->setWeapon(this);
     150        for (auto& mapEntry : this->weaponmodes_)
     151            mapEntry.second->setWeapon(this);
    152152    }
    153153}
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc

    r10821 r10916  
    7676    void WeaponPack::fire(unsigned int weaponmode)
    7777    {
    78         for (auto & elem : this->weapons_)
    79             (elem)->fire(weaponmode);
     78        for (Weapon* weapon : this->weapons_)
     79            weapon->fire(weaponmode);
    8080    }
    8181
     
    8686    void WeaponPack::reload()
    8787    {
    88         for (auto & elem : this->weapons_)
    89             (elem)->reload();
     88        for (Weapon* weapon : this->weapons_)
     89            weapon->reload();
    9090    }
    9191
     
    114114        unsigned int i = 0;
    115115
    116         for (const auto & elem : this->weapons_)
     116        for (Weapon* weapon : this->weapons_)
    117117        {
    118118            if (i == index)
    119                 return (elem);
     119                return weapon;
    120120            ++i;
    121121        }
     
    132132    {
    133133        unsigned int i = 0;
    134         for (const auto & elem : this->links_)
     134        for (DefaultWeaponmodeLink* link : this->links_)
    135135        {
    136136            if (i == index)
    137                 return (elem);
     137                return link;
    138138
    139139            ++i;
     
    144144    unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const
    145145    {
    146         for (const auto & elem : this->links_)
    147             if ((elem)->getFiremode() == firemode)
    148                 return (elem)->getWeaponmode();
     146        for (DefaultWeaponmodeLink* link : this->links_)
     147            if (link->getFiremode() == firemode)
     148                return link->getWeaponmode();
    149149
    150150        return WeaponSystem::WEAPON_MODE_UNASSIGNED;
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc

    r10821 r10916  
    6363    {
    6464        // Fire all WeaponPacks with their defined weaponmode
    65         for (auto & elem : this->weaponpacks_)
    66             if (elem.second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
    67                 elem.first->fire(elem.second);
     65        for (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 (auto & elem : this->weaponpacks_)
    74             elem.first->reload();
     73        for (auto& mapEntry : this->weaponpacks_)
     74            mapEntry.first->reload();
    7575    }
    7676
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc

    r10821 r10916  
    106106    {
    107107        unsigned int i = 0;
    108         for (const auto & elem : this->weaponSlots_)
     108        for (WeaponSlot* weaponSlot : this->weaponSlots_)
    109109        {
    110110            ++i;
    111111            if (i > index)
    112                 return (elem);
     112                return weaponSlot;
    113113        }
    114114        return nullptr;
     
    153153    {
    154154        unsigned int i = 0;
    155         for (const auto & elem : this->weaponSets_)
     155        for (const auto& mapEntry : this->weaponSets_)
    156156        {
    157157            ++i;
    158158            if (i > index)
    159                 return elem.second;
     159                return mapEntry.second;
    160160        }
    161161        return nullptr;
     
    168168
    169169        unsigned int freeSlots = 0;
    170         for (auto & elem : this->weaponSlots_)
    171         {
    172             if (!(elem)->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 (auto & elem : this->weaponSlots_)
    187         {
    188             if (!(elem)->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                 (elem)->attachWeapon(weapon);
     191                weaponSlot->attachWeapon(weapon);
    192192                this->getPawn()->attach(weapon);
    193193                ++i;
     
    196196
    197197        // Assign the desired weaponmode to the firemodes
    198         for (auto & elem : this->weaponSets_)
    199         {
    200             unsigned int weaponmode = wPack->getDesiredWeaponmode(elem.first);
     198        for (auto& mapEntry : this->weaponSets_)
     199        {
     200            unsigned int weaponmode = wPack->getDesiredWeaponmode(mapEntry.first);
    201201            if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED)
    202                 elem.second->setWeaponmodeLink(wPack, weaponmode);
     202                mapEntry.second->setWeaponmodeLink(wPack, weaponmode);
    203203        }
    204204
     
    219219
    220220        // Remove all added links from the WeaponSets
    221         for (auto & elem : this->weaponSets_)
    222             elem.second->removeWeaponmodeLink(wPack);
     221        for (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 (const auto & elem : this->weaponPacks_)
     233        for (WeaponPack* weaponPack : this->weaponPacks_)
    234234        {
    235235            ++i;
    236236            if (i > index)
    237                 return (elem);
     237                return weaponPack;
    238238        }
    239239        return nullptr;
     
    268268        // Check if the WeaponSet belongs to this WeaponSystem
    269269        bool foundWeaponSet = false;
    270         for (auto & elem : this->weaponSets_)
    271         {
    272             if (elem.second == wSet)
     270        for (auto& mapEntry : this->weaponSets_)
     271        {
     272            if (mapEntry.second == wSet)
    273273            {
    274274                foundWeaponSet = true;
     
    296296    void WeaponSystem::reload()
    297297    {
    298         for (auto & elem : this->weaponSets_)
    299             elem.second->reload();
     298        for (auto& mapEntry : this->weaponSets_)
     299            mapEntry.second->reload();
    300300    }
    301301
Note: See TracChangeset for help on using the changeset viewer.