- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/controllers/FightingController.cc
r11052 r11071 27 27 */ 28 28 #include "controllers/FightingController.h" 29 #include "core/XMLPort.h"30 29 #include "util/Math.h" 31 30 … … 56 55 { 57 56 58 }59 void FightingController::XMLPort( Element& xmlelement, XMLPort::Mode mode )60 {61 SUPER( FightingController, XMLPort, xmlelement, mode );62 57 } 63 58 void FightingController::lookAtTarget(float dt) … … 243 238 { 244 239 if (!this || !this->getControllableEntity()) 245 return 0;246 247 Pawn* closestTarget = 0;240 return nullptr; 241 242 Pawn* closestTarget = nullptr; 248 243 float minDistance = std::numeric_limits<float>::infinity(); 249 244 Gametype* gt = this->getGametype(); 250 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)251 { 252 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) ) 253 248 continue; 254 249 255 float distance = CommonController::distance ( *itP, this->getControllableEntity());250 float distance = CommonController::distance (pawn, this->getControllableEntity()); 256 251 if (distance < minDistance) 257 252 { 258 closestTarget = *itP;253 closestTarget = pawn; 259 254 minDistance = distance; 260 255 } … … 264 259 return closestTarget; 265 260 } 266 return 0;261 return nullptr; 267 262 } 268 263 //I checked it out, rockets DO NOT cause any problems! this->getControllableEntity() is always a SpaceShip … … 340 335 { 341 336 this->weaponModes_.clear(); // reset previous weapon information 342 WeaponSlot* wSlot = 0;337 WeaponSlot* wSlot = nullptr; 343 338 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 344 339 { 345 WeaponMode* wMode = 0;340 WeaponMode* wMode = nullptr; 346 341 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 347 342 { … … 361 356 } 362 357 363 int FightingController::getFiremode( std::stringname)364 { 365 for ( std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)366 { 367 if ( it->first == name)368 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; 369 364 } 370 365 return -1;
Note: See TracChangeset
for help on using the changeset viewer.