- Timestamp:
- Jan 17, 2016, 1:59:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3/src/orxonox/controllers/FightingController.cc
r11057 r11065 238 238 { 239 239 if (!this || !this->getControllableEntity()) 240 return 0;241 242 Pawn* closestTarget = 0;240 return nullptr; 241 242 Pawn* closestTarget = nullptr; 243 243 float minDistance = std::numeric_limits<float>::infinity(); 244 244 Gametype* gt = this->getGametype(); 245 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)246 { 247 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )245 for (Pawn* pawn : ObjectList<Pawn>()) 246 { 247 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 248 248 continue; 249 249 250 float distance = CommonController::distance ( *itP, this->getControllableEntity());250 float distance = CommonController::distance (pawn, this->getControllableEntity()); 251 251 if (distance < minDistance) 252 252 { 253 closestTarget = *itP;253 closestTarget = pawn; 254 254 minDistance = distance; 255 255 } … … 259 259 return closestTarget; 260 260 } 261 return 0;261 return nullptr; 262 262 } 263 263 //I checked it out, rockets DO NOT cause any problems! this->getControllableEntity() is always a SpaceShip … … 335 335 { 336 336 this->weaponModes_.clear(); // reset previous weapon information 337 WeaponSlot* wSlot = 0;337 WeaponSlot* wSlot = nullptr; 338 338 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 339 339 { 340 WeaponMode* wMode = 0;340 WeaponMode* wMode = nullptr; 341 341 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 342 342 { … … 356 356 } 357 357 358 int FightingController::getFiremode( std::stringname)359 { 360 for ( std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)361 { 362 if ( it->first == name)363 return it->second;358 int FightingController::getFiremode(const std::string& name) 359 { 360 for (const auto& mapEntry : this->weaponModes_) 361 { 362 if (mapEntry.first == name) 363 return mapEntry.second; 364 364 } 365 365 return -1;
Note: See TracChangeset
for help on using the changeset viewer.