Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/controllers/FightingController.cc

    r11052 r11071  
    2727 */
    2828#include "controllers/FightingController.h"
    29 #include "core/XMLPort.h"
    3029#include "util/Math.h"
    3130
     
    5655    {
    5756       
    58     }
    59     void FightingController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
    60     {
    61         SUPER( FightingController, XMLPort, xmlelement, mode );
    6257    }
    6358    void FightingController::lookAtTarget(float dt)
     
    243238    {
    244239        if (!this || !this->getControllableEntity())
    245             return 0;
    246 
    247         Pawn* closestTarget = 0;
     240            return nullptr;
     241
     242        Pawn* closestTarget = nullptr;
    248243        float minDistance =  std::numeric_limits<float>::infinity();
    249244        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) )
    253248                continue;
    254249
    255             float distance = CommonController::distance (*itP, this->getControllableEntity());
     250            float distance = CommonController::distance (pawn, this->getControllableEntity());
    256251            if (distance < minDistance)
    257252            {
    258                 closestTarget = *itP;
     253                closestTarget = pawn;
    259254                minDistance = distance;
    260255            }
     
    264259           return closestTarget;
    265260        }
    266         return 0; 
     261        return nullptr;
    267262    }
    268263    //I checked it out, rockets DO NOT cause any problems! this->getControllableEntity() is always a SpaceShip
     
    340335            {
    341336                this->weaponModes_.clear(); // reset previous weapon information
    342                 WeaponSlot* wSlot = 0;
     337                WeaponSlot* wSlot = nullptr;
    343338                for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++)
    344339                {
    345                     WeaponMode* wMode = 0;
     340                    WeaponMode* wMode = nullptr;
    346341                    for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++)
    347342                    {
     
    361356    }
    362357
    363     int FightingController::getFiremode(std::string name)
    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;
    369364        }
    370365        return -1;
Note: See TracChangeset for help on using the changeset viewer.