Changeset 11071 for code/trunk/src/orxonox/weaponsystem/Munition.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/weaponsystem/Munition.cc
r11052 r11071 52 52 this->reloadTime_ = 0.5f; 53 53 54 this->lastFilledWeaponMode_ = NULL;54 this->lastFilledWeaponMode_ = nullptr; 55 55 } 56 56 57 57 Munition::~Munition() 58 58 { 59 for ( std::map<WeaponMode*, Magazine*>::iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)60 delete it->second;59 for (const auto& mapEntry : this->assignedMagazines_) 60 delete mapEntry.second; 61 61 } 62 62 … … 76 76 // For separated magazines we definitively need a given user 77 77 if (!user) 78 return 0;78 return nullptr; 79 79 80 80 // Use the map to get the magazine assigned to the given user … … 90 90 } 91 91 92 return 0;92 return nullptr; 93 93 } 94 94 … … 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); … … 262 262 if (deployment_ != MunitionDeployment::Separate) 263 263 { 264 user = NULL;264 user = nullptr; 265 265 } 266 266 … … 271 271 if (it->first == lastFilledWeaponMode_) 272 272 { 273 lastFilledWeaponMode_ = NULL;273 lastFilledWeaponMode_ = nullptr; 274 274 } 275 275 delete it->second; … … 299 299 { 300 300 // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition) 301 for ( std::map<WeaponMode*, Magazine*>::const_iterator it = this->assignedMagazines_.begin(); it != this->assignedMagazines_.end(); ++it)302 if ( it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)301 for (const auto& mapEntry : this->assignedMagazines_) 302 if (mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_) 303 303 return true; 304 304 } … … 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 { … … 345 345 std::map<WeaponMode*, Magazine*>::iterator it; 346 346 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 map347 // If the pointer to the weapon mode whose magazine got munition added to is nullptr, 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 } … … 515 515 // If we don't use separate magazines, set user to 0 516 516 if (deployment_ != MunitionDeployment::Separate) 517 user = NULL;517 user = nullptr; 518 518 519 519 // Remove the current magazine for the given user … … 523 523 if (it->first == lastFilledWeaponMode_) 524 524 { 525 lastFilledWeaponMode_ = NULL;525 lastFilledWeaponMode_ = nullptr; 526 526 } 527 527 delete it->second;
Note: See TracChangeset
for help on using the changeset viewer.