Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2015, 10:47:51 PM (9 years ago)
Author:
landauf
Message:

use range-based for-loop where it makes sense (e.g. ObjectList)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/weapons/projectiles/GravityBombField.cc

    r10765 r10919  
    125125
    126126            //Check if any pawn is inside the shockwave and hit it with dammage proportional to the distance between explosion centre and pawn. Make sure, the same pawn is damaged only once.
    127             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     127            for (Pawn* pawn : ObjectList<Pawn>())
    128128            {
    129                 Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
     129                Vector3 distanceVector = pawn->getWorldPosition()-this->getWorldPosition();
    130130                 //orxout(debug_output) << "Found Pawn:" << it->getWorldPosition() << endl;
    131131                if(distanceVector.length()< forceSphereRadius_)
    132132                {
    133133                    //orxout(debug_output) << "Force sphere radius is: " << forceSphereRadius_ << " Distance to Pawn is: " << distanceVector.length();
    134                     if (std::find(victimsAlreadyDamaged_.begin(),victimsAlreadyDamaged_.end(),*it) == victimsAlreadyDamaged_.end())
     134                    if (std::find(victimsAlreadyDamaged_.begin(),victimsAlreadyDamaged_.end(),pawn) == victimsAlreadyDamaged_.end())
    135135                    {
    136136                        //orxout(debug_output) << "Found Pawn to damage: " << it->getWorldPosition() << endl;
    137137                        float damage = FORCE_FIELD_EXPLOSION_DAMMAGE*(1-distanceVector.length()/EXPLOSION_RADIUS);
    138138                        //orxout(debug_output) << "Damage: " << damage << endl;
    139                         it->hit(shooter_, it->getWorldPosition(), nullptr, damage, 0,0);
    140                         victimsAlreadyDamaged_.push_back(*it);
     139                        pawn->hit(shooter_, pawn->getWorldPosition(), nullptr, damage, 0,0);
     140                        victimsAlreadyDamaged_.push_back(pawn);
    141141                    }
    142142                }
Note: See TracChangeset for help on using the changeset viewer.