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:
12 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc

    r10624 r11071  
    4949
    5050        this->setRadarObjectColour(ColourValue::Blue);
    51         this->setRadarObjectShape(RadarViewable::Triangle);
     51        this->setRadarObjectShape(RadarViewable::Shape::Triangle);
    5252        this->setRadarVisibility(false);
    5353    }
  • code/trunk/src/modules/gametypes/OldRaceCheckPoint.h

    r9667 r11071  
    4848            virtual ~OldRaceCheckPoint();
    4949
    50             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    51             virtual void tick(float dt);
     50            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     51            virtual void tick(float dt) override;
    5252
    5353            protected:
    54             virtual void triggered(bool bIsTriggered);
     54            virtual void triggered(bool bIsTriggered) override;
    5555            inline void setLast(bool isLast)
    5656                { this->bIsLast_ = isLast; }
     
    6464            inline float getTimeLimit()
    6565                { return this->bTimeLimit_;}
    66             inline const WorldEntity* getWorldEntity() const
     66            virtual inline const WorldEntity* getWorldEntity() const override
    6767                { return this; }
    6868
  • code/trunk/src/modules/gametypes/OldSpaceRace.h

    r9667 r11071  
    5555            virtual ~OldSpaceRace() {}
    5656
    57             virtual void start();
    58             virtual void end();
     57            virtual void start() override;
     58            virtual void end() override;
    5959
    6060            virtual void newCheckpointReached();
    61             virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command.
     61            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command.
    6262                                                        //<! This is only a temporary solution. Better: create racingBots.
    6363
  • code/trunk/src/modules/gametypes/RaceCheckPoint.cc

    r9973 r11071  
    5353
    5454        this->setRadarObjectColour(ColourValue::Blue);
    55         this->setRadarObjectShape(RadarViewable::Triangle);
     55        this->setRadarObjectShape(RadarViewable::Shape::Triangle);
    5656        this->setRadarVisibility(false);
    5757        this->settingsChanged();
     
    125125            }
    126126        }
    127         return NULL;
     127        return nullptr;
    128128    }
    129129
     
    146146    {
    147147        Vector3 checkpoints(-1,-1,-1); int count=0;
    148         for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ )
     148        for (int nextCheckpoint : nextCheckpoints_)
    149149        {
    150150            switch (count)
    151151            {
    152                 case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
    153                 case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
    154                 case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
     152                case 0: checkpoints.x = static_cast<Ogre::Real>(nextCheckpoint); break;
     153                case 1: checkpoints.y = static_cast<Ogre::Real>(nextCheckpoint); break;
     154                case 2: checkpoints.z = static_cast<Ogre::Real>(nextCheckpoint); break;
    155155            }
    156156            ++count;
  • code/trunk/src/modules/gametypes/RaceCheckPoint.h

    r9971 r11071  
    4848            virtual ~RaceCheckPoint();
    4949
    50             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     50            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5151
    5252            inline void setCheckpointIndex(int checkpointIndex)
     
    9292        protected:
    9393
    94             virtual void fire(bool bIsTriggered, BaseObject* originator);
     94            virtual void fire(bool bIsTriggered, BaseObject* originator) override;
    9595
    96             inline const WorldEntity* getWorldEntity() const
     96            virtual inline const WorldEntity* getWorldEntity() const override
    9797            {
    9898                return this;
  • code/trunk/src/modules/gametypes/SpaceRace.cc

    r9804 r11071  
    8888            this->cantMove_ = true;
    8989
    90             for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    91                 it->setActive(false);
     90            for (Engine* engine : ObjectList<Engine>())
     91                engine->setActive(false);
    9292        }
    9393
     
    9595        if (!this->isStartCountdownRunning() && this->cantMove_)
    9696        {
    97             for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    98                 it->setActive(true);
     97            for (Engine* engine : ObjectList<Engine>())
     98                engine->setActive(true);
    9999
    100100            this->cantMove_= false;
  • code/trunk/src/modules/gametypes/SpaceRace.h

    r9667 r11071  
    5757            virtual ~SpaceRace() {}
    5858
    59             void tick(float dt);
     59            virtual void tick(float dt) override;
    6060
    61             virtual void end();
     61            virtual void end() override;
    6262
    6363            void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player);
     
    7070                { return this->clock_; }
    7171
    72             bool allowPawnHit(Pawn* victim, Pawn* originator);
    73             bool allowPawnDamage(Pawn* victim, Pawn* originator);
    74             bool allowPawnDeath(Pawn* victim, Pawn* originator);
     72            virtual bool allowPawnHit(Pawn* victim, Pawn* originator) override;
     73            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override;
     74            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator) override;
    7575
    7676        private:
  • code/trunk/src/modules/gametypes/SpaceRaceController.cc

    r10318 r11071  
    5959
    6060        virtualCheckPointIndex = -2;
    61         if (ObjectList<SpaceRaceManager>::size() != 1)
    62             orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager>::size() << endl;
    63         for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it != ObjectList<SpaceRaceManager>::end(); ++it)
    64         {
    65             checkpoints = it->getAllCheckpoints();
    66             nextRaceCheckpoint_ = it->findCheckpoint(0);
     61        if (ObjectList<SpaceRaceManager>().size() != 1)
     62            orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager>().size() << endl;
     63        for (SpaceRaceManager* manager : ObjectList<SpaceRaceManager>())
     64        {
     65            checkpoints = manager->getAllCheckpoints();
     66            nextRaceCheckpoint_ = manager->findCheckpoint(0);
    6767        }
    6868
     
    9898                    RaceCheckPoint* point2 = findCheckpoint((*numb));
    9999
    100                     //if(point2 != NULL)
     100                    //if(point2 != nullptr)
    101101                    //placeVirtualCheckpoints((*it), point2);
    102102                }
     
    126126        staticRacePoints_ = findStaticCheckpoints(nextRaceCheckpoint_, checkpoints);
    127127        // initialisation of currentRaceCheckpoint_
    128         currentRaceCheckpoint_ = NULL;
     128        currentRaceCheckpoint_ = nullptr;
    129129
    130130        int i;
    131         for (i = -2; findCheckpoint(i) != NULL; i--)
     131        for (i = -2; findCheckpoint(i) != nullptr; i--)
    132132        {
    133133            continue;
     
    154154    {
    155155        std::map<RaceCheckPoint*, int> zaehler; // counts how many times the checkpoint was reached (for simulation)
    156         for (unsigned int i = 0; i < allCheckpoints.size(); i++)
    157         {
    158             zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0));
     156        for (RaceCheckPoint* checkpoint : allCheckpoints)
     157        {
     158            zaehler.insert(std::pair<RaceCheckPoint*, int>(checkpoint,0));
    159159        }
    160160        int maxWays = rekSimulationCheckpointsReached(currentCheckpoint, zaehler);
    161161
    162162        std::vector<RaceCheckPoint*> returnVec;
    163         for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler.begin(); iter != zaehler.end(); iter++)
    164         {
    165             if (iter->second == maxWays)
    166             {
    167                 returnVec.push_back(iter->first);
     163        for (const auto& mapEntry : zaehler)
     164        {
     165            if (mapEntry.second == maxWays)
     166            {
     167                returnVec.push_back(mapEntry.first);
    168168            }
    169169        }
     
    187187        {
    188188            int numberOfWays = 0; // counts number of ways from this Point to the last point
    189             for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it)
    190             {
    191                 if (currentCheckpoint == findCheckpoint(*it))
     189            for (int checkpointIndex : currentCheckpoint->getNextCheckpoints())
     190            {
     191                if (currentCheckpoint == findCheckpoint(checkpointIndex))
    192192                {
    193193                    //orxout() << currentCheckpoint->getCheckpointIndex()<<endl;
    194194                    continue;
    195195                }
    196                 if (findCheckpoint(*it) == NULL)
    197                     orxout(internal_warning) << "Problematic Point: " << (*it) << endl;
     196                if (findCheckpoint(checkpointIndex) == nullptr)
     197                    orxout(internal_warning) << "Problematic Point: " << checkpointIndex << endl;
    198198                else
    199                     numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
     199                    numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(checkpointIndex), zaehler);
    200200            }
    201201            zaehler[currentCheckpoint] += numberOfWays;
     
    209209    float SpaceRaceController::distanceSpaceshipToCheckPoint(RaceCheckPoint* CheckPoint)
    210210    {
    211         if (this->getControllableEntity() != NULL)
     211        if (this->getControllableEntity() != nullptr)
    212212        {
    213213            return (CheckPoint->getPosition()- this->getControllableEntity()->getPosition()).length();
     
    223223    {
    224224        float minDistance = 0;
    225         RaceCheckPoint* minNextRaceCheckPoint = NULL;
     225        RaceCheckPoint* minNextRaceCheckPoint = nullptr;
    226226
    227227        // find the next checkpoint with the minimal distance
    228         for (std::set<int>::iterator it = raceCheckpoint->getNextCheckpoints().begin(); it != raceCheckpoint->getNextCheckpoints().end(); ++it)
    229         {
    230             RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(*it);
     228        for (int checkpointIndex : raceCheckpoint->getNextCheckpoints())
     229        {
     230            RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(checkpointIndex);
    231231            float distance = recCalculateDistance(nextRaceCheckPoint, this->getControllableEntity()->getPosition());
    232232
    233             if (distance < minDistance || minNextRaceCheckPoint == NULL)
     233            if (distance < minDistance || minNextRaceCheckPoint == nullptr)
    234234            {
    235235                minDistance = distance;
     
    255255        {
    256256            float minimum = std::numeric_limits<float>::max();
    257             for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it != currentCheckPoint->getNextCheckpoints().end(); ++it)
     257            for (int checkpointIndex : currentCheckPoint->getNextCheckpoints())
    258258            {
    259259                int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length());
    260260
    261                 minimum = std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint(*it), currentCheckPoint->getPosition()));
     261                minimum = std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint(checkpointIndex), currentCheckPoint->getPosition()));
    262262                // minimum of distanz from 'currentPosition' to the next static Checkpoint
    263263            }
     
    271271    RaceCheckPoint* SpaceRaceController::adjustNextPoint()
    272272    {
    273         if (currentRaceCheckpoint_ == NULL) // no Adjust possible
     273        if (currentRaceCheckpoint_ == nullptr) // no Adjust possible
    274274
    275275        {
     
    289289    RaceCheckPoint* SpaceRaceController::findCheckpoint(int index) const
    290290    {
    291         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    292             if (this->checkpoints_[i]->getCheckpointIndex() == index)
    293                 return this->checkpoints_[i];
    294         return NULL;
     291        for (RaceCheckPoint* checkpoint : this->checkpoints_)
     292            if (checkpoint->getCheckpointIndex() == index)
     293                return checkpoint;
     294        return nullptr;
    295295    }
    296296
     
    299299        orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl;
    300300        RaceCheckPoint* newTempRaceCheckPoint;
    301         for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it)
     301        ObjectList<SpaceRaceManager> list;
     302        for (ObjectList<SpaceRaceManager>::iterator it = list.begin(); it!= list.end(); ++it)
    302303        {
    303304            newTempRaceCheckPoint = new RaceCheckPoint((*it));
     
    347348    void SpaceRaceController::tick(float dt)
    348349    {
    349         if (this->getControllableEntity() == NULL || this->getControllableEntity()->getPlayer() == NULL )
     350        if (this->getControllableEntity() == nullptr || this->getControllableEntity()->getPlayer() == nullptr )
    350351        {
    351352            //orxout()<< this->getControllableEntity() << " in tick"<<endl;
     
    414415        btScalar radiusObject;
    415416
    416         for (std::vector<StaticEntity*>::const_iterator it = allObjects.begin(); it != allObjects.end(); ++it)
    417         {
    418             for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)
    419             {
    420                 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
    421                 if(currentShape == NULL)
     417        for (StaticEntity* object : allObjects)
     418        {
     419            for (int everyShape=0; object->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
     420            {
     421                btCollisionShape* currentShape = object->getAttachedCollisionShape(everyShape)->getCollisionShape();
     422                if(currentShape == nullptr)
    422423                continue;
    423424
     
    444445        for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it != allObjects.end(); ++it)
    445446        {
    446             for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)
     447            for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
    447448            {
    448449                btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
    449                 if(currentShape == NULL)
     450                if(currentShape == nullptr)
    450451                continue;
    451452
     
    488489        std::vector<StaticEntity*> problematicObjects;
    489490
    490         for (ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); it!= ObjectList<StaticEntity>::end(); ++it)
    491         {
    492 
    493             if (dynamic_cast<RaceCheckPoint*>(*it) != NULL)
     491        ObjectList<StaticEntity> list;
     492        for (ObjectList<StaticEntity>::iterator it = list.begin(); it!= list.end(); ++it)
     493        {
     494
     495            if (dynamic_cast<RaceCheckPoint*>(*it) != nullptr)
    494496            {
    495497                continue;
     
    537539        //                    btVector3 positionObject;
    538540        //                    btScalar radiusObject;
    539         //                    if((*it)==NULL)
     541        //                    if((*it)==nullptr)
    540542        //                    {   orxout()<<"Problempoint 1.1"<<endl; continue;}
    541543        //                    //TODO: Probably it points on a wrong object
    542         //                    for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++)
     544        //                    for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++)
    543545        //                    {
    544         //                        if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL)
     546        //                        if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr)
    545547        //                        {    continue;}
    546548        //
     
    570572        //                        btVector3 positionObject;
    571573        //                        btScalar radiusObject;
    572         //                        if((*it)==NULL)
     574        //                        if((*it)==nullptr)
    573575        //                        {   orxout()<<"Problempoint 1"<<endl; continue;}
    574         //                        for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=0; everyShape++)
     576        //                        for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++)
    575577        //                        {
    576         //                            if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==NULL)
     578        //                            if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr)
    577579        //                            {   orxout()<<"Problempoint 2.2"<<endl; continue;}
    578580        //                            (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject);
  • code/trunk/src/modules/gametypes/SpaceRaceController.h

    r10262 r11071  
    4242            SpaceRaceController(Context* context);
    4343            virtual ~SpaceRaceController();
    44             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    45             virtual void tick(float dt);
     44            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     45            virtual void tick(float dt) override;
    4646
    4747        private:
  • code/trunk/src/modules/gametypes/SpaceRaceManager.cc

    r10624 r11071  
    5454    SpaceRaceManager::~SpaceRaceManager()
    5555    {
    56         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    57         this->checkpoints_[i]->destroy();
     56        for (RaceCheckPoint* checkpoint : this->checkpoints_)
     57        checkpoint->destroy();
    5858    }
    5959
     
    7171        this->players_ = this->race_->getPlayers();
    7272
    73         if (this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
     73        if (this->checkpoints_[0] != nullptr && !this->firstcheckpointvisible_)
    7474        {
    7575            this->checkpoints_[0]->setRadarVisibility(true);
     
    7777        }
    7878
    79         for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)
     79        for (const auto& mapEntry : players_)
    8080        {
    8181
    82             for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     82            for (RaceCheckPoint* checkpoint : this->checkpoints_)
    8383            {
    84                 if (this->checkpoints_[i]->playerWasHere(it->first)){
    85                 this->checkpointReached(this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);
     84                if (checkpoint->playerWasHere(mapEntry.first)){
     85                this->checkpointReached(checkpoint, mapEntry.first /*this->checkpoints_[i]->getPlayer()*/);
    8686                }
    8787            }
     
    100100        return this->checkpoints_[index];
    101101        else
    102         return 0;
     102        return nullptr;
    103103    }
    104104
     
    113113    RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
    114114    {
    115         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    116         if (this->checkpoints_[i]->getCheckpointIndex() == index)
    117         return this->checkpoints_[i];
    118         return 0;
     115        for (RaceCheckPoint* checkpoint : this->checkpoints_)
     116        if (checkpoint->getCheckpointIndex() == index)
     117        return checkpoint;
     118        return nullptr;
    119119    }
    120120
    121121    bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const
    122122    {
    123         if (oldCheckpoint != NULL)
     123        if (oldCheckpoint != nullptr)
    124124        {
    125125            // the player already visited an old checkpoint; see which checkpoints are possible now
    126126            const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints();
    127             for (std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)
    128             if (this->findCheckpoint(*it) == newCheckpoint)
     127            for (int possibleCheckpoint : possibleCheckpoints)
     128            if (this->findCheckpoint(possibleCheckpoint) == newCheckpoint)
    129129            return true;
    130130            return false;
     
    179179        {
    180180            const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints();
    181             for (std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)
    182             this->findCheckpoint(*it)->setRadarVisibility(false);
     181            for (int checkpointIndex : oldVisible)
     182            this->findCheckpoint(checkpointIndex)->setRadarVisibility(false);
    183183        }
    184184
     
    188188
    189189            const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints();
    190             for (std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)
    191             this->findCheckpoint(*it)->setRadarVisibility(true);
     190            for (int checkpointIndex : newVisible)
     191            this->findCheckpoint(checkpointIndex)->setRadarVisibility(true);
    192192        }
    193193    }
  • code/trunk/src/modules/gametypes/SpaceRaceManager.h

    r9667 r11071  
    5858            virtual ~SpaceRaceManager() ;
    5959
    60             void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     60            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    6161
    6262            void addCheckpoint(RaceCheckPoint* checkpoint);
     
    6969            std::vector<RaceCheckPoint*> getAllCheckpoints();
    7070
    71             void tick(float dt);
     71            virtual void tick(float dt) override;
    7272
    7373        protected:
Note: See TracChangeset for help on using the changeset viewer.