Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/orxonox/controllers/AIController.cc

    r9667 r11054  
    249249            }
    250250            else
    251                 this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode
     251                this->setPreviousMode();//If bot dies -> getControllableEntity == nullptr -> get out of ROCKET mode
    252252        }//END_OF ROCKET MODE
    253253
  • code/branches/cpp11_v3/src/orxonox/controllers/AIController.h

    r9667 r11054  
    4444            virtual ~AIController();
    4545
    46             virtual void tick(float dt); //<! Carrying out the targets set in action().
     46            virtual void tick(float dt) override; //<! Carrying out the targets set in action().
    4747
    4848        protected:
  • code/branches/cpp11_v3/src/orxonox/controllers/ActionpointController.cc

    r11052 r11054  
    506506                if (targetName == "")
    507507                    break;
    508                 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     508                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    509509                {
    510510                    if (!this || !this->getControllableEntity())
     
    541541                if (protectName == "reservedKeyword:human")
    542542                {
    543                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     543                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    544544                    {
    545545                        if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))
     
    551551                else
    552552                {
    553                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     553                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    554554                    {
    555555                        if (CommonController::getName(*itP) == protectName)
     
    578578                std::string targetName = p.name;
    579579
    580                 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     580                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    581581                {
    582582                    if (CommonController::getName(*itP) == targetName)
     
    707707        float minDistance =  std::numeric_limits<float>::infinity();
    708708        Gametype* gt = this->getGametype();
    709         for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     709        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    710710        {
    711711            if (!this || !this->getControllableEntity())
  • code/branches/cpp11_v3/src/orxonox/controllers/ArtificialController.cc

    r11052 r11054  
    5656        this->currentWaypoint_ = 0;
    5757        this->setAccuracy(5);
    58         this->defaultWaypoint_ = NULL;
     58        this->defaultWaypoint_ = nullptr;
    5959        this->mode_ = DEFAULT;//Vector-implementation: mode_.push_back(DEFAULT);
    6060    }
     
    177177            {
    178178                this->weaponModes_.clear(); // reset previous weapon information
    179                 WeaponSlot* wSlot = 0;
     179                WeaponSlot* wSlot = nullptr;
    180180                for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++)
    181181                {
    182                     WeaponMode* wMode = 0;
     182                    WeaponMode* wMode = nullptr;
    183183                    for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++)
    184184                    {
     
    207207    void ArtificialController::setAllBotLevel(float level)
    208208    {
    209         for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
    210             it->setBotLevel(level);
     209        for (ArtificialController* controller : ObjectList<ArtificialController>())
     210            controller->setBotLevel(level);
    211211    }
    212212
     
    222222    {
    223223        SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
    224         if(ship == NULL) return;
     224        if(ship == nullptr) return;
    225225        if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost
    226226            this->getControllableEntity()->boost(true);
     
    231231    int ArtificialController::getFiremode(std::string name)
    232232    {
    233         for (std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)
    234         {
    235             if (it->first == name)
    236                 return it->second;
     233        for (const auto& mapEntry : this->weaponModes_)
     234        {
     235            if (mapEntry.first == name)
     236                return mapEntry.second;
    237237        }
    238238        return -1;
     
    249249            return this->waypoints_[index];
    250250        else
    251             return 0;
     251            return nullptr;
    252252    }
    253253
     
    258258    void ArtificialController::updatePointsOfInterest(std::string name, float searchDistance)
    259259    {
    260         WorldEntity* waypoint = NULL;
    261         for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
    262         {
    263             if((*it)->getIdentifier() == ClassByString(name))
     260        WorldEntity* waypoint = nullptr;
     261        for (WorldEntity* we : ObjectList<WorldEntity>())
     262        {
     263            if(we->getIdentifier() == ClassByString(name))
    264264            {
    265265                ControllableEntity* controllable = this->getControllableEntity();
    266266                if(!controllable) continue;
    267                 float actualDistance = ( (*it)->getPosition() - controllable->getPosition() ).length();
     267                float actualDistance = ( we->getPosition() - controllable->getPosition() ).length();
    268268                if(actualDistance > searchDistance || actualDistance < 5.0f) continue;
    269269                    // TODO: PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance
     
    271271                else
    272272                {
    273                     waypoint = *it;
     273                    waypoint = we;
    274274                    break;
    275275                }
  • code/branches/cpp11_v3/src/orxonox/controllers/ArtificialController.h

    r9667 r11054  
    4242            virtual ~ArtificialController();
    4343
    44             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     44            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4545
    4646            void abandonTarget(Pawn* target);
    4747
    48             virtual void changedControllableEntity();
     48            virtual void changedControllableEntity() override;
    4949
    5050            virtual void doFire();
     
    8989
    9090            //WAYPOINT DATA
    91             std::vector<WeakPtr<WorldEntity> > waypoints_;
     91            std::vector<WeakPtr<WorldEntity>> waypoints_;
    9292            size_t currentWaypoint_;
    9393            float squaredaccuracy_;
  • code/branches/cpp11_v3/src/orxonox/controllers/Controller.cc

    r9797 r11054  
    4040        RegisterObject(Controller);
    4141
    42         this->player_ = 0;
    43         this->controllableEntity_ = 0;
     42        this->player_ = nullptr;
     43        this->controllableEntity_ = nullptr;
    4444        this->bGodMode_ = false;
    4545        this->team_=-1;
  • code/branches/cpp11_v3/src/orxonox/controllers/Controller.h

    r9797 r11054  
    4545            Controller(Context* context);
    4646            virtual ~Controller();
    47             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     47            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4848            inline void setPlayer(PlayerInfo* player)
    4949                { this->player_ = player; }
  • code/branches/cpp11_v3/src/orxonox/controllers/ControllerDirector.cc

    r10622 r11054  
    3232
    3333        // Initialize member variables
    34         this->player_ = NULL;
    35         this->entity_ = NULL;
    36         this->pTrigger_ = NULL;
     34        this->player_ = nullptr;
     35        this->entity_ = nullptr;
     36        this->pTrigger_ = nullptr;
    3737        this->context_ = context;
    3838    }
     
    110110    {
    111111        this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);
    112         this->player_ = NULL;
     112        this->player_ = nullptr;
    113113
    114114        orxout(verbose) << "Preparation to take Control!" << endl;
    115115
    116116        // Check whether it is a player trigger and extract pawn from it
    117         if(this->pTrigger_ != NULL)
     117        if(this->pTrigger_ != nullptr)
    118118        {
    119119            // Get the object which triggered the event.
     
    121121
    122122            // Check if there actually was a player returned.
    123             if( this->player_ == NULL) return false;
     123            if( this->player_ == nullptr) return false;
    124124        }
    125125        else
  • code/branches/cpp11_v3/src/orxonox/controllers/ControllerDirector.h

    r10622 r11054  
    4343            virtual ~ControllerDirector() { }
    4444
    45             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    4646            bool party(bool bTriggered, BaseObject* trigger);
    47             virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
     47            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
    4848
    4949            inline void setScriptName(const std::string& name) { this->scriptname_ = name; }
  • code/branches/cpp11_v3/src/orxonox/controllers/DroneController.cc

    r9667 r11054  
    4949        RegisterObject(DroneController);
    5050
    51         this->owner_ = 0;
    52         this->drone_ = 0;
     51        this->owner_ = nullptr;
     52        this->drone_ = nullptr;
    5353        this->isShooting_ = false;
    5454        this->setAccuracy(10);
  • code/branches/cpp11_v3/src/orxonox/controllers/DroneController.h

    r9667 r11054  
    5353            virtual ~DroneController();
    5454
    55             virtual void tick(float dt); //!< The controlling happens here. This method defines what the controller has to do each tick.
     55            virtual void tick(float dt) override; //!< The controlling happens here. This method defines what the controller has to do each tick.
    5656
    5757            void setOwner(Pawn* owner);
  • code/branches/cpp11_v3/src/orxonox/controllers/FightingController.cc

    r11052 r11054  
    248248        float minDistance =  std::numeric_limits<float>::infinity();
    249249        Gametype* gt = this->getGametype();
    250         for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     250        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    251251        {
    252252            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
  • code/branches/cpp11_v3/src/orxonox/controllers/FormationController.cc

    r11052 r11054  
    5858    RegisterClass(FormationController);
    5959
    60     static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
    61     static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
    62     static const float FORMATION_LENGTH =  110;
    63     static const float FORMATION_WIDTH =  110;
    64     static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
    65     static const float SPEED_MASTER = 0.6f;
    66     static const float ROTATEFACTOR_MASTER = 0.2f;
    67     static const float SPEED_FREE = 0.8f;
    68     static const float ROTATEFACTOR_FREE = 0.8f;
     60    static constexpr unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
     61    static constexpr int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
     62    static constexpr float FORMATION_LENGTH =  110;
     63    static constexpr float FORMATION_WIDTH =  110;
     64    static constexpr int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
     65    static constexpr float SPEED_MASTER = 0.6f;
     66    static constexpr float ROTATEFACTOR_MASTER = 0.2f;
     67    static constexpr float SPEED_FREE = 0.8f;
     68    static constexpr float ROTATEFACTOR_FREE = 0.8f;
    6969
    7070    FormationController::FormationController(Context* context) : Controller(context)
     
    7272        RegisterObject(FormationController);
    7373
    74         this->target_ = 0;
     74        this->target_ = nullptr;
    7575        this->formationFlight_ = false;
    7676        this->passive_ = false;
    7777        this->maxFormationSize_ = STANDARD_MAX_FORMATION_SIZE;
    78         this->myMaster_ = 0;
     78        this->myMaster_ = nullptr;
    7979        this->freedomCount_ = 0;
    8080
     
    9797            this->removeFromFormation();
    9898
    99             for (ObjectList<FormationController>::iterator it = ObjectList<FormationController>::begin(); it; ++it)
    100             {
    101                 if (*it != this)
     99            for (FormationController* controller : ObjectList<FormationController>())
     100            {
     101                if (controller != this)
    102102                {
    103                     if (it->myMaster_ == this)
     103                    if (controller->myMaster_ == this)
    104104                    {
    105                         orxout(internal_error) << this << " is still master in " << (*it) << endl;
    106                         it->myMaster_ = 0;
     105                        orxout(internal_error) << this << " is still master in " << controller << endl;
     106                        controller->myMaster_ = nullptr;
    107107                    }
    108108
    109109                    while (true)
    110110                    {
    111                         std::vector<FormationController*>::iterator it2 = std::find(it->slaves_.begin(), it->slaves_.end(), this);
    112                         if (it2 != it->slaves_.end())
     111                        std::vector<FormationController*>::iterator it2 = std::find(controller->slaves_.begin(), controller->slaves_.end(), this);
     112                        if (it2 != controller->slaves_.end())
    113113                        {
    114                             orxout(internal_error) << this << " is still slave in " << (*it) << endl;
    115                             it->slaves_.erase(it2);
     114                            orxout(internal_error) << this << " is still slave in " << controller << endl;
     115                            controller->slaves_.erase(it2);
    116116                        }
    117117                        else
     
    140140    void FormationController::formationflight(const bool form)
    141141    {
    142         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    143         {
    144             Controller* controller = 0;
    145 
    146             if (it->getController())
    147                 controller = it->getController();
    148             else if (it->getXMLController())
    149                 controller = it->getXMLController();
     142        for (Pawn* pawn : ObjectList<Pawn>())
     143        {
     144            Controller* controller = nullptr;
     145
     146            if (pawn->getController())
     147                controller = pawn->getController();
     148            else if (pawn->getXMLController())
     149                controller = pawn->getXMLController();
    150150
    151151            if (!controller)
     
    171171    void FormationController::masteraction(const int action)
    172172    {
    173         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    174         {
    175             Controller* controller = 0;
    176 
    177             if (it->getController())
    178                 controller = it->getController();
    179             else if (it->getXMLController())
    180                 controller = it->getXMLController();
     173        for (Pawn* pawn : ObjectList<Pawn>())
     174        {
     175            Controller* controller = nullptr;
     176
     177            if (pawn->getController())
     178                controller = pawn->getController();
     179            else if (pawn->getXMLController())
     180                controller = pawn->getXMLController();
    181181
    182182            if (!controller)
     
    201201    void FormationController::passivebehaviour(const bool passive)
    202202    {
    203         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    204         {
    205             Controller* controller = 0;
    206 
    207             if (it->getController())
    208                 controller = it->getController();
    209             else if (it->getXMLController())
    210                 controller = it->getXMLController();
     203        for (Pawn* pawn : ObjectList<Pawn>())
     204        {
     205            Controller* controller = nullptr;
     206
     207            if (pawn->getController())
     208                controller = pawn->getController();
     209            else if (pawn->getXMLController())
     210                controller = pawn->getXMLController();
    211211
    212212            if (!controller)
     
    228228    void FormationController::formationsize(const int size)
    229229    {
    230         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    231         {
    232             Controller* controller = 0;
    233 
    234             if (it->getController())
    235                 controller = it->getController();
    236             else if (it->getXMLController())
    237                 controller = it->getXMLController();
     230        for (Pawn* pawn : ObjectList<Pawn>())
     231        {
     232            Controller* controller = nullptr;
     233
     234            if (pawn->getController())
     235                controller = pawn->getController();
     236            else if (pawn->getXMLController())
     237                controller = pawn->getXMLController();
    238238
    239239            if (!controller)
     
    383383        }
    384384
    385         this->myMaster_ = 0;
     385        this->myMaster_ = nullptr;
    386386        this->state_ = FREE;
    387387    }
     
    398398        int teamSize = 0;
    399399        //go through all pawns
    400         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
     400        for (Pawn* pawn : ObjectList<Pawn>())
    401401        {
    402402
     
    405405            if (!gt)
    406406            {
    407                 gt=it->getGametype();
    408             }
    409             if (!FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it),gt))
     407                gt=pawn->getGametype();
     408            }
     409            if (!FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn),gt))
    410410                continue;
    411411
    412412            //has it an FormationController?
    413             Controller* controller = 0;
    414 
    415             if (it->getController())
    416                 controller = it->getController();
    417             else if (it->getXMLController())
    418                 controller = it->getXMLController();
     413            Controller* controller = nullptr;
     414
     415            if (pawn->getController())
     416                controller = pawn->getController();
     417            else if (pawn->getXMLController())
     418                controller = pawn->getXMLController();
    419419
    420420            if (!controller)
     
    422422
    423423            //is pawn oneself?
    424             if (orxonox_cast<ControllableEntity*>(*it) == this->getControllableEntity())
     424            if (orxonox_cast<ControllableEntity*>(pawn) == this->getControllableEntity())
    425425                continue;
    426426
     
    433433                continue;
    434434
    435             float distance = (it->getPosition() - this->getControllableEntity()->getPosition()).length();
     435            float distance = (pawn->getPosition() - this->getControllableEntity()->getPosition()).length();
    436436
    437437            // is pawn in range?
     
    440440                if(newMaster->slaves_.size() > this->maxFormationSize_) continue;
    441441
    442                 for(std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)
     442                for(FormationController* slave : this->slaves_)
    443443                {
    444                     (*itSlave)->myMaster_ = newMaster;
    445                     newMaster->slaves_.push_back(*itSlave);
     444                    slave->myMaster_ = newMaster;
     445                    newMaster->slaves_.push_back(slave);
    446446                }
    447447                this->slaves_.clear();
     
    458458        {
    459459            this->state_ = MASTER;
    460             this->myMaster_ = 0;
     460            this->myMaster_ = nullptr;
    461461        }
    462462    }
     
    486486            int i = 1;
    487487
    488             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
     488            for(FormationController* slave : slaves_)
    489489            {
    490490                pos = Vector3::ZERO;
     
    497497                    dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK);
    498498                }
    499                 (*it)->setTargetOrientation(orient);
    500                 (*it)->setTargetPosition(pos);
     499                slave->setTargetOrientation(orient);
     500                slave->setTargetPosition(pos);
    501501                left=!left;
    502502            }
     
    518518            newMaster->state_ = MASTER;
    519519            newMaster->slaves_ = this->slaves_;
    520             newMaster->myMaster_ = 0;
    521 
    522             for(std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)
    523             {
    524                 (*it)->myMaster_ = newMaster;
     520            newMaster->myMaster_ = nullptr;
     521
     522            for(FormationController* slave : newMaster->slaves_)
     523            {
     524                slave->myMaster_ = newMaster;
    525525            }
    526526        }
     
    547547                newMaster->state_ = MASTER;
    548548                newMaster->slaves_ = this->slaves_;
    549                 newMaster->myMaster_ = 0;
    550 
    551                 for(std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)
     549                newMaster->myMaster_ = nullptr;
     550
     551                for(FormationController* slave : newMaster->slaves_)
    552552                {
    553                     (*it)->myMaster_ = newMaster;
     553                    slave->myMaster_ = newMaster;
    554554                }
    555555            }
     
    569569        if(this->state_ != MASTER) return;
    570570
    571         for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    572         {
    573             (*it)->state_ = FREE;
    574             (*it)->myMaster_ = 0;
     571        for(FormationController* slave : slaves_)
     572        {
     573            slave->state_ = FREE;
     574            slave->myMaster_ = nullptr;
    575575        }
    576576        this->slaves_.clear();
     
    584584        if(this->state_ != MASTER) return;
    585585
    586         for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    587         {
    588             (*it)->state_ = FREE;
    589             (*it)->forceFreedom();
    590             (*it)->targetPosition_ = this->targetPosition_;
    591             (*it)->bShooting_ = true;
     586        for(FormationController* slave : slaves_)
     587        {
     588            slave->state_ = FREE;
     589            slave->forceFreedom();
     590            slave->targetPosition_ = this->targetPosition_;
     591            slave->bShooting_ = true;
    592592//             (*it)->getControllableEntity()->fire(0);// fire once for fun
    593593        }
     
    629629
    630630        //search new Master, then take lead
    631         if (this->state_==FREE && this->myMaster_==0)
     631        if (this->state_==FREE && this->myMaster_==nullptr)
    632632        {
    633633          searchNewMaster();
     
    650650            this->slaves_.push_back(this->myMaster_);
    651651            //set this as new master
    652             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    653             {
    654                  (*it)->myMaster_=this;
    655             }
    656             this->myMaster_=0;
     652            for(FormationController* slave : slaves_)
     653            {
     654                 slave->myMaster_=this;
     655            }
     656            this->myMaster_=nullptr;
    657657            this->state_=MASTER;
    658658        }
     
    694694        if (this->state_ == MASTER)
    695695        {
    696             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    697             {
    698                  (*it)->formationMode_ = val;
     696            for(FormationController* slave : slaves_)
     697            {
     698                 slave->formationMode_ = val;
    699699                 if (val == ATTACK)
    700                      (*it)->forgetTarget();
     700                     slave->forgetTarget();
    701701            }
    702702        }
     
    773773    {
    774774
    775         Pawn *humanPawn = NULL;
    776         NewHumanController *currentHumanController = NULL;
     775        Pawn *humanPawn = nullptr;
     776        NewHumanController *currentHumanController = nullptr;
    777777        std::vector<FormationController*> allMasters;
    778778
    779         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    780         {
    781             Controller* controller = 0;
    782 
    783             if (it->getController())
    784                 controller = it->getController();
    785             else if (it->getXMLController())
    786                 controller = it->getXMLController();
     779        for (Pawn* pawn : ObjectList<Pawn>())
     780        {
     781            Controller* controller = nullptr;
     782
     783            if (pawn->getController())
     784                controller = pawn->getController();
     785            else if (pawn->getXMLController())
     786                controller = pawn->getXMLController();
    787787
    788788            if (!controller)
     
    791791            currentHumanController = orxonox_cast<NewHumanController*>(controller);
    792792
    793             if(currentHumanController) humanPawn = *it;
     793            if(currentHumanController) humanPawn = pawn;
    794794
    795795            FormationController *aiController = orxonox_cast<FormationController*>(controller);
     
    800800        }
    801801
    802         if((humanPawn != NULL) && (allMasters.size() != 0))
     802        if((humanPawn != nullptr) && (allMasters.size() != 0))
    803803        {
    804804            float posHuman = humanPawn->getPosition().length();
     
    808808            int i = 0;
    809809
    810             for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
    811             {
    812                 if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
    813                 distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
     810            for(FormationController* master : allMasters)
     811            {
     812                if (!FormationController::sameTeam(master->getControllableEntity(), humanPawn, master->getGametype())) continue;
     813                distance = posHuman - master->getControllableEntity()->getPosition().length();
    814814                if(distance < minDistance) index = i;
     815                i++;
    815816            }
    816817            allMasters[index]->followInit(humanPawn);
     
    826827    void FormationController::followInit(Pawn* pawn, const bool always, const int secondsToFollow)
    827828    {
    828         if (pawn == NULL || this->state_ != MASTER)
     829        if (pawn == nullptr || this->state_ != MASTER)
    829830            return;
    830831        this->specificMasterAction_  =  FOLLOW;
     
    844845    {
    845846
    846         Pawn *humanPawn = NULL;
    847         NewHumanController *currentHumanController = NULL;
    848 
    849         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    850         {
    851             if (!it->getController())
     847        Pawn *humanPawn = nullptr;
     848        NewHumanController *currentHumanController = nullptr;
     849
     850        for (Pawn* pawn : ObjectList<Pawn>())
     851        {
     852            if (!pawn->getController())
    852853                continue;
    853854
    854             currentHumanController = orxonox_cast<NewHumanController*>(it->getController());
     855            currentHumanController = orxonox_cast<NewHumanController*>(pawn->getController());
    855856            if(currentHumanController)
    856857            {
    857                 if (!FormationController::sameTeam(this->getControllableEntity(), *it, this->getGametype())) continue;
    858                 humanPawn = *it;
     858                if (!FormationController::sameTeam(this->getControllableEntity(), pawn, this->getGametype())) continue;
     859                humanPawn = pawn;
    859860                break;
    860861            }
    861862        }
    862863
    863         if((humanPawn != NULL))
     864        if((humanPawn != nullptr))
    864865                this->followInit(humanPawn);
    865866    }
     
    918919        this->forgetTarget();
    919920
    920         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
    921         {
    922             if (FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
     921        for (Pawn* pawn : ObjectList<Pawn>())
     922        {
     923            if (FormationController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), this->getGametype()))
    923924                continue;
    924925
    925926            /* So AI won't choose invisible Spaceships as target */
    926             if (!it->getRadarVisibility())
     927            if (!pawn->getRadarVisibility())
    927928                continue;
    928929
    929             if (static_cast<ControllableEntity*>(*it) != this->getControllableEntity())
     930            if (static_cast<ControllableEntity*>(pawn) != this->getControllableEntity())
    930931            {
    931932                float speed = this->getControllableEntity()->getVelocity().length();
    932933                Vector3 distanceCurrent = this->targetPosition_ - this->getControllableEntity()->getPosition();
    933                 Vector3 distanceNew = it->getPosition() - this->getControllableEntity()->getPosition();
    934                 if (!this->target_ || it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / math::twoPi)
     934                Vector3 distanceNew = pawn->getPosition() - this->getControllableEntity()->getPosition();
     935                if (!this->target_ || pawn->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceNew) / speed / distanceNew.length()) / math::twoPi)
    935936                        < this->targetPosition_.squaredDistance(this->getControllableEntity()->getPosition()) * (1.5f + acos((this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / math::twoPi) + rnd(-250, 250))
    936937                {
    937                     this->setTarget(*it);
     938                    this->setTarget(pawn);
    938939                }
    939940            }
     
    943944    void FormationController::forgetTarget()
    944945    {
    945         this->target_ = 0;
     946        this->target_ = nullptr;
    946947        this->bShooting_ = false;
    947948    }
     
    963964        int team2 = entity2->getTeam();
    964965
    965         Controller* controller = 0;
     966        Controller* controller = nullptr;
    966967        if (entity1->getController())
    967968            controller = entity1->getController();
     
    10001001        }
    10011002
    1002         TeamBaseMatchBase* base = 0;
     1003        TeamBaseMatchBase* base = nullptr;
    10031004        base = orxonox_cast<TeamBaseMatchBase*>(entity1);
    10041005        if (base)
     
    10341035        }
    10351036
    1036         DroneController* droneController = 0;
     1037        DroneController* droneController = nullptr;
    10371038        droneController = orxonox_cast<DroneController*>(entity1->getController());
    10381039        if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)
  • code/branches/cpp11_v3/src/orxonox/controllers/FormationController.h

    r10631 r11054  
    5050      virtual ~FormationController();
    5151
    52       virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     52      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5353
    5454
     
    9393           { return this->formationMode_; }
    9494
    95       virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     95      virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) override;
    9696
    9797      FormationController* getMaster( void ) { return myMaster_; }
     
    9999      FormationController* getSlave( void ) { return this->slaves_.back(); }
    100100
    101       virtual void changedControllableEntity();
     101      virtual void changedControllableEntity() override;
    102102
    103103  protected:
  • code/branches/cpp11_v3/src/orxonox/controllers/HumanController.cc

    r11052 r11054  
    6565    RegisterUnloadableClass(HumanController);
    6666
    67     HumanController* HumanController::localController_s = 0;
     67    HumanController* HumanController::localController_s = nullptr;
    6868
    6969    HumanController::HumanController(Context* context) : FormationController(context)
     
    8181            HumanController::localController_s->removeFromFormation();
    8282        }
    83         HumanController::localController_s = 0;
     83        HumanController::localController_s = nullptr;
    8484    }
    8585
     
    321321            return orxonox_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
    322322        else
    323             return NULL;
     323            return nullptr;
    324324    }
    325325
  • code/branches/cpp11_v3/src/orxonox/controllers/HumanController.h

    r10624 r11054  
    4747            virtual ~HumanController();
    4848
    49             virtual void tick(float dt);
     49            virtual void tick(float dt) override;
    5050
    5151            static void moveFrontBack(const Vector2& value);
  • code/branches/cpp11_v3/src/orxonox/controllers/MasterController.cc

    r11052 r11054  
    5858        {
    5959            //fill the vector in the first tick
    60             for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
     60            for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)
    6161            {
    6262                //----0ptr?----
  • code/branches/cpp11_v3/src/orxonox/controllers/NewHumanController.cc

    r10631 r11054  
    5858    RegisterUnloadableClass(NewHumanController);
    5959
    60     NewHumanController* NewHumanController::localController_s = 0;
     60    NewHumanController* NewHumanController::localController_s = nullptr;
    6161
    6262    NewHumanController::NewHumanController(Context* context)
    6363        : HumanController(context)
    64         , crossHairOverlay_(NULL)
    65         , centerOverlay_(NULL)
    66         , damageOverlayTop_(NULL)
    67         , damageOverlayRight_(NULL)
    68         , damageOverlayBottom_(NULL)
    69         , damageOverlayLeft_(NULL)
     64        , crossHairOverlay_(nullptr)
     65        , centerOverlay_(nullptr)
     66        , damageOverlayTop_(nullptr)
     67        , damageOverlayRight_(nullptr)
     68        , damageOverlayBottom_(nullptr)
     69        , damageOverlayLeft_(nullptr)
    7070        , damageOverlayTT_(0)
    7171        , damageOverlayTR_(0)
    7272        , damageOverlayTB_(0)
    7373        , damageOverlayTL_(0)
    74         , arrowsOverlay1_(NULL)
    75         , arrowsOverlay2_(NULL)
    76         , arrowsOverlay3_(NULL)
    77         , arrowsOverlay4_(NULL)
     74        , arrowsOverlay1_(nullptr)
     75        , arrowsOverlay2_(nullptr)
     76        , arrowsOverlay3_(nullptr)
     77        , arrowsOverlay4_(nullptr)
    7878    {
    7979        RegisterObject(NewHumanController);
     
    445445            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 3000 );
    446446
    447         if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != 0 )
    448             this->getControllableEntity()->setTarget( 0 );
     447        if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != nullptr )
     448            this->getControllableEntity()->setTarget( nullptr );
    449449
    450450        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
  • code/branches/cpp11_v3/src/orxonox/controllers/NewHumanController.h

    r9667 r11054  
    4545            virtual ~NewHumanController();
    4646
    47             virtual void tick(float dt);
     47            virtual void tick(float dt) override;
    4848
    49             virtual void frontback(const Vector2& value);
    50             virtual void yaw(const Vector2& value);
    51             virtual void pitch(const Vector2& value);
     49            virtual void frontback(const Vector2& value) override;
     50            virtual void yaw(const Vector2& value) override;
     51            virtual void pitch(const Vector2& value) override;
    5252
    5353            static void accelerate();
    5454            static void decelerate();
    5555
    56             virtual void doFire(unsigned int firemode);
     56            virtual void doFire(unsigned int firemode) override;
    5757
    58             virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     58            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) override;
    5959
    6060            static void unfire();
     
    6565            static void changeMode();
    6666
    67             virtual void changedControllableEntity();
    68             virtual void doPauseControl();
    69             virtual void doResumeControl();
     67            virtual void changedControllableEntity() override;
     68            virtual void doPauseControl() override;
     69            virtual void doResumeControl() override;
    7070
    7171            float getCurrentYaw(){ return this->currentYaw_; }
  • code/branches/cpp11_v3/src/orxonox/controllers/ScriptController.cc

    r10622 r11054  
    6464        /* Set default values for all variables */
    6565        /* - pointers to zero */
    66         this->player_ = NULL;
    67         this->entity_ = NULL;
     66        this->player_ = nullptr;
     67        this->entity_ = nullptr;
    6868
    6969        /* - times */
     
    121121
    122122      /* Debugging: print all the scriptcontroller object pointers */
    123       for(ObjectList<ScriptController>::iterator it =
    124         ObjectList<ScriptController>::begin();
    125         it != ObjectList<ScriptController>::end(); ++it)
    126       { orxout(verbose) << "Have object in list: " << *it << endl; }
     123      for(ScriptController* controller : ObjectList<ScriptController>())
     124      { orxout(verbose) << "Have object in list: " << controller << endl; }
    127125
    128126      /* Find the first one with a nonzero ID */
    129       for(ObjectList<ScriptController>::iterator it =
    130         ObjectList<ScriptController>::begin();
    131         it != ObjectList<ScriptController>::end(); ++it)
     127      for(ScriptController* controller : ObjectList<ScriptController>())
    132128      {
    133129        // TODO: do some selection here. Currently just returns the first one
    134         if( (*it)->getID() > 0 )
    135         { orxout(verbose) << "Controller to return: " << *it << endl;
    136           return *it;
     130        if( controller->getID() > 0 )
     131        { orxout(verbose) << "Controller to return: " << controller << endl;
     132          return controller;
    137133        }
    138134     
    139135      }
    140       return NULL;
     136      return nullptr;
    141137    }
    142138
  • code/branches/cpp11_v3/src/orxonox/controllers/ScriptController.h

    r10622 r11054  
    7171            void setPlayer(PlayerInfo* player) { this->player_ = player; }
    7272           
    73             virtual void tick(float dt);
     73            virtual void tick(float dt) override;
    7474
    7575            // LUA interface
  • code/branches/cpp11_v3/src/orxonox/controllers/SectionController.cc

    r11052 r11054  
    147147                    Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition();
    148148                    Gametype* gt = this->getGametype();
    149                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
     149                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)
    150150                    {
    151151                        //----is enemy?----
     
    231231        float minDistance =  std::numeric_limits<float>::infinity();
    232232        //go through all pawns
    233         for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
     233        for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)
    234234        {
    235235            //0ptr or not DivisionController?
  • code/branches/cpp11_v3/src/orxonox/controllers/WaypointController.cc

    r9667 r11054  
    4444    WaypointController::~WaypointController()
    4545    {
    46         for (size_t i = 0; i < this->waypoints_.size(); ++i)
     46        for (WorldEntity* waypoint : this->waypoints_)
    4747        {
    48             if(this->waypoints_[i])
    49                 this->waypoints_[i]->destroy();
     48            if(waypoint)
     49                waypoint->destroy();
    5050        }
    5151    }
  • code/branches/cpp11_v3/src/orxonox/controllers/WaypointController.h

    r9667 r11054  
    4444            virtual ~WaypointController();
    4545
    46             virtual void tick(float dt);
     46            virtual void tick(float dt) override;
    4747
    4848        protected:
  • code/branches/cpp11_v3/src/orxonox/controllers/WaypointPatrolController.cc

    r9716 r11054  
    8787        float shortestsqdistance = (float)static_cast<unsigned int>(-1);
    8888
    89         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     89        for (Pawn* pawn : ObjectList<Pawn>())
    9090        {
    91             if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
     91            if (ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), this->getGametype()))
    9292                continue;
    9393
    94             float sqdistance = it->getPosition().squaredDistance(myposition);
     94            float sqdistance = pawn->getPosition().squaredDistance(myposition);
    9595            if (sqdistance < shortestsqdistance)
    9696            {
    9797                shortestsqdistance = sqdistance;
    98                 this->target_ = (*it);
     98                this->target_ = pawn;
    9999            }
    100100        }
    101101
    102102        if (shortestsqdistance > (this->alertnessradius_ * this->alertnessradius_))
    103             this->target_ = 0;
     103            this->target_ = nullptr;
    104104    }
    105105}
  • code/branches/cpp11_v3/src/orxonox/controllers/WaypointPatrolController.h

    r9716 r11054  
    4343            virtual ~WaypointPatrolController() {}
    4444
    45             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    46             virtual void tick(float dt);
     45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     46            virtual void tick(float dt) override;
    4747
    4848            inline void setAlertnessRadius(float radius)
  • code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc

    r11052 r11054  
    192192        Gametype* gt = this->getGametype();
    193193
    194         for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
     194        for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)
    195195        {
    196196            //----0ptr or not a leader or dead?----
Note: See TracChangeset for help on using the changeset viewer.