Changeset 11062 for code/branches/cpp11_v3/src/orxonox/weaponsystem
- Timestamp:
- Jan 13, 2016, 11:13:30 PM (9 years ago)
- Location:
- code/branches/cpp11_v3/src/orxonox/weaponsystem
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.cc
r11054 r11062 52 52 this->reloadTime_ = 0.5f; 53 53 54 this->lastFilledWeaponMode_ = NULL;54 this->lastFilledWeaponMode_ = nullptr; 55 55 } 56 56 … … 200 200 magazine->munition_ = 0; 201 201 202 if (this->reload( NULL))202 if (this->reload(nullptr)) 203 203 // Successfully reloaded, continue recursively 204 204 return this->takeMunition(amount, 0); … … 271 271 if (it->first == lastFilledWeaponMode_) 272 272 { 273 lastFilledWeaponMode_ = NULL;273 lastFilledWeaponMode_ = nullptr; 274 274 } 275 275 delete it->second; … … 315 315 { 316 316 // 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); 318 318 if (magazine) 319 319 { … … 347 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 348 348 // Otherwise set it to the next weapon mode 349 if (lastFilledWeaponMode_ == NULL)349 if (lastFilledWeaponMode_ == nullptr) 350 350 { 351 351 it = this->assignedMagazines_.begin(); … … 441 441 for (unsigned int i = 0; i < addedMagazines; ++i) 442 442 { 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); 448 448 break; 449 449 } … … 523 523 if (it->first == lastFilledWeaponMode_) 524 524 { 525 lastFilledWeaponMode_ = NULL;525 lastFilledWeaponMode_ = nullptr; 526 526 } 527 527 delete it->second; -
code/branches/cpp11_v3/src/orxonox/weaponsystem/Munition.h
r11052 r11062 39 39 namespace orxonox 40 40 { 41 namespaceMunitionDeployment41 enum class MunitionDeployment 42 42 { 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 }; 50 47 51 48 class _OrxonoxExport Munition : public BaseObject … … 69 66 virtual ~Munition(); 70 67 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;68 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 72 69 73 70 unsigned int getNumMunition(WeaponMode* user) const; … … 80 77 inline unsigned int getMaxMunitionPerMagazine() const 81 78 { return this->maxMunitionPerMagazine_; } 82 inline MunitionDeployment ::ValuegetMunitionDeployment() const79 inline MunitionDeployment getMunitionDeployment() const 83 80 { return deployment_; } 84 81 … … 115 112 std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used. 116 113 117 MunitionDeployment ::Valuedeployment_; // 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. 118 115 119 116 bool bAllowMunitionRefilling_; -
code/branches/cpp11_v3/src/orxonox/weaponsystem/Weapon.cc
r11054 r11062 158 158 void Weapon::updateMunition() 159 159 { 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(); 162 162 } 163 163 } -
code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponPack.cc
r11059 r11062 159 159 void WeaponPack::updateMunition() 160 160 { 161 for ( std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)162 (*it)->updateMunition();161 for (Weapon* weapon : this->weapons_) 162 weapon->updateMunition(); 163 163 } 164 164 } -
code/branches/cpp11_v3/src/orxonox/weaponsystem/WeaponSystem.cc
r11059 r11062 312 312 else 313 313 { 314 return NULL;314 return nullptr; 315 315 } 316 316 } … … 318 318 void WeaponSystem::addMunition(Munition* munition) 319 319 { 320 if (munition == NULL)320 if (munition == nullptr) 321 321 { 322 322 return; … … 338 338 void WeaponSystem::updateMunition() 339 339 { 340 for ( std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)341 { 342 (*it)->updateMunition();340 for (WeaponPack* weaponPack : this->weaponPacks_) 341 { 342 weaponPack->updateMunition(); 343 343 } 344 344 }
Note: See TracChangeset
for help on using the changeset viewer.