Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (8 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc

    r10768 r10821  
    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 (auto & allCheckpoint : allCheckpoints)
     157        {
     158            zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoint,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 (auto & elem : zaehler)
     164        {
     165            if (elem.second == maxWays)
     166            {
     167                returnVec.push_back(elem.first);
    168168            }
    169169        }
     
    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 (auto elem : raceCheckpoint->getNextCheckpoints())
     229        {
     230            RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(elem);
    231231            float distance = recCalculateDistance(nextRaceCheckPoint, this->getControllableEntity()->getPosition());
    232232
     
    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];
     291        for (auto & elem : this->checkpoints_)
     292            if (elem->getCheckpointIndex() == index)
     293                return elem;
    294294        return nullptr;
    295295    }
     
    414414        btScalar radiusObject;
    415415
    416         for (std::vector<StaticEntity*>::const_iterator it = allObjects.begin(); it != allObjects.end(); ++it)
    417         {
    418             for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
    419             {
    420                 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();
     416        for (const auto & allObject : allObjects)
     417        {
     418            for (int everyShape=0; (allObject)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++)
     419            {
     420                btCollisionShape* currentShape = (allObject)->getAttachedCollisionShape(everyShape)->getCollisionShape();
    421421                if(currentShape == nullptr)
    422422                continue;
Note: See TracChangeset for help on using the changeset viewer.