Changeset 10916 for code/branches/cpp11_v2/src/orxonox/weaponsystem
- Timestamp:
- Dec 2, 2015, 11:22:03 PM (9 years ago)
- 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 55 55 Munition::~Munition() 56 56 { 57 for (auto & elem: this->currentMagazines_)58 delete elem.second;57 for (auto& mapEntry : this->currentMagazines_) 58 delete mapEntry.second; 59 59 } 60 60 … … 268 268 { 269 269 // 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_) 272 272 return true; 273 273 } … … 316 316 { 317 317 bool change = false; 318 for (auto & elem: this->currentMagazines_)318 for (auto& mapEntry : this->currentMagazines_) 319 319 { 320 320 // 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_) 322 322 { 323 elem.second->munition_++;323 mapEntry.second->munition_++; 324 324 amount--; 325 325 change = true; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc
r10821 r10916 61 61 this->weaponPack_->removeWeapon(this); 62 62 63 for (auto & elem: this->weaponmodes_)64 elem.second->destroy();63 for (auto& mapEntry : this->weaponmodes_) 64 mapEntry.second->destroy(); 65 65 } 66 66 } … … 85 85 { 86 86 unsigned int i = 0; 87 for (const auto & elem: this->weaponmodes_)87 for (const auto& mapEntry : this->weaponmodes_) 88 88 { 89 89 if (i == index) 90 return elem.second;90 return mapEntry.second; 91 91 92 92 ++i; … … 136 136 void Weapon::reload() 137 137 { 138 for (auto & elem: this->weaponmodes_)139 elem.second->reload();138 for (auto& mapEntry : this->weaponmodes_) 139 mapEntry.second->reload(); 140 140 } 141 141 … … 148 148 void Weapon::notifyWeaponModes() 149 149 { 150 for (auto & elem: this->weaponmodes_)151 elem.second->setWeapon(this);150 for (auto& mapEntry : this->weaponmodes_) 151 mapEntry.second->setWeapon(this); 152 152 } 153 153 } -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc
r10821 r10916 76 76 void WeaponPack::fire(unsigned int weaponmode) 77 77 { 78 for ( auto & elem: this->weapons_)79 (elem)->fire(weaponmode);78 for (Weapon* weapon : this->weapons_) 79 weapon->fire(weaponmode); 80 80 } 81 81 … … 86 86 void WeaponPack::reload() 87 87 { 88 for ( auto & elem: this->weapons_)89 (elem)->reload();88 for (Weapon* weapon : this->weapons_) 89 weapon->reload(); 90 90 } 91 91 … … 114 114 unsigned int i = 0; 115 115 116 for ( const auto & elem: this->weapons_)116 for (Weapon* weapon : this->weapons_) 117 117 { 118 118 if (i == index) 119 return (elem);119 return weapon; 120 120 ++i; 121 121 } … … 132 132 { 133 133 unsigned int i = 0; 134 for ( const auto & elem: this->links_)134 for (DefaultWeaponmodeLink* link : this->links_) 135 135 { 136 136 if (i == index) 137 return (elem);137 return link; 138 138 139 139 ++i; … … 144 144 unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const 145 145 { 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(); 149 149 150 150 return WeaponSystem::WEAPON_MODE_UNASSIGNED; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc
r10821 r10916 63 63 { 64 64 // 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); 68 68 } 69 69 … … 71 71 { 72 72 // 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(); 75 75 } 76 76 -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc
r10821 r10916 106 106 { 107 107 unsigned int i = 0; 108 for ( const auto & elem: this->weaponSlots_)108 for (WeaponSlot* weaponSlot : this->weaponSlots_) 109 109 { 110 110 ++i; 111 111 if (i > index) 112 return (elem);112 return weaponSlot; 113 113 } 114 114 return nullptr; … … 153 153 { 154 154 unsigned int i = 0; 155 for (const auto & elem: this->weaponSets_)155 for (const auto& mapEntry : this->weaponSets_) 156 156 { 157 157 ++i; 158 158 if (i > index) 159 return elem.second;159 return mapEntry.second; 160 160 } 161 161 return nullptr; … … 168 168 169 169 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()) 173 173 ++freeSlots; 174 174 } … … 184 184 // Attach all weapons to the first free slots (and to the Pawn) 185 185 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()) 189 189 { 190 190 Weapon* weapon = wPack->getWeapon(i); 191 (elem)->attachWeapon(weapon);191 weaponSlot->attachWeapon(weapon); 192 192 this->getPawn()->attach(weapon); 193 193 ++i; … … 196 196 197 197 // 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); 201 201 if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED) 202 elem.second->setWeaponmodeLink(wPack, weaponmode);202 mapEntry.second->setWeaponmodeLink(wPack, weaponmode); 203 203 } 204 204 … … 219 219 220 220 // 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); 223 223 224 224 // Remove the WeaponPack from the WeaponSystem … … 231 231 { 232 232 unsigned int i = 0; 233 for ( const auto & elem: this->weaponPacks_)233 for (WeaponPack* weaponPack : this->weaponPacks_) 234 234 { 235 235 ++i; 236 236 if (i > index) 237 return (elem);237 return weaponPack; 238 238 } 239 239 return nullptr; … … 268 268 // Check if the WeaponSet belongs to this WeaponSystem 269 269 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) 273 273 { 274 274 foundWeaponSet = true; … … 296 296 void WeaponSystem::reload() 297 297 { 298 for (auto & elem: this->weaponSets_)299 elem.second->reload();298 for (auto& mapEntry : this->weaponSets_) 299 mapEntry.second->reload(); 300 300 } 301 301
Note: See TracChangeset
for help on using the changeset viewer.