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/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);
Note: See TracChangeset for help on using the changeset viewer.