- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc
r11052 r11054 52 52 RegisterObject(WeaponSystem); 53 53 54 this->pawn_ = 0;54 this->pawn_ = nullptr; 55 55 } 56 56 … … 60 60 { 61 61 if (this->pawn_) 62 this->pawn_->setWeaponSystem( 0);62 this->pawn_->setWeaponSystem(nullptr); 63 63 64 64 while (!this->weaponSets_.empty()) … … 106 106 { 107 107 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_) 109 109 { 110 110 ++i; 111 111 if (i > index) 112 return (*it);113 } 114 return 0;112 return weaponSlot; 113 } 114 return nullptr; 115 115 } 116 116 … … 153 153 { 154 154 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_) 156 156 { 157 157 ++i; 158 158 if (i > index) 159 return it->second;160 } 161 return 0;159 return mapEntry.second; 160 } 161 return nullptr; 162 162 } 163 163 … … 168 168 169 169 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()) 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 ( 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()) 189 189 { 190 190 Weapon* weapon = wPack->getWeapon(i); 191 (*it)->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 ( 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); 201 201 if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED) 202 it->second->setWeaponmodeLink(wPack, weaponmode);202 mapEntry.second->setWeaponmodeLink(wPack, weaponmode); 203 203 } 204 204 … … 213 213 // Remove all weapons from their WeaponSlot 214 214 unsigned int i = 0; 215 Weapon* weapon = 0;215 Weapon* weapon = nullptr; 216 216 while ((weapon = wPack->getWeapon(i++))) 217 217 if (weapon->getWeaponSlot()) … … 219 219 220 220 // 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); 223 223 224 224 // Remove the WeaponPack from the WeaponSystem … … 231 231 { 232 232 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_) 234 234 { 235 235 ++i; 236 236 if (i > index) 237 return (*it);238 } 239 return 0;237 return weaponPack; 238 } 239 return nullptr; 240 240 } 241 241 … … 273 273 // Check if the WeaponSet belongs to this WeaponSystem 274 274 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) 278 278 { 279 279 foundWeaponSet = true; … … 301 301 void WeaponSystem::reload() 302 302 { 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(); 305 305 } 306 306 … … 308 308 { 309 309 if (!identifier || !identifier->getIdentifier()) 310 return 0;310 return nullptr; 311 311 312 312 std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier()); … … 337 337 else 338 338 { 339 orxout(internal_warning) << "Adding munition failed. identifier == NULL" << endl;339 orxout(internal_warning) << "Adding munition failed. identifier == nullptr " << endl; 340 340 } 341 341 }
Note: See TracChangeset
for help on using the changeset viewer.