Changeset 10821 for code/branches/cpp11_v2/src/orxonox/worldentities/pawns
- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox/worldentities/pawns
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10768 r10821 99 99 } 100 100 // iterate through all attached parts 101 for( unsigned int j = 0; j < this->partList_.size(); j++)101 for(auto & elem : this->partList_) 102 102 { 103 103 // if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done). 104 if(( this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))104 if((elem->getName() == this->getAttachedObject(i)->getName()) && !elem->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 105 105 { 106 106 // The Entity is added to the part's entityList_ 107 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));107 elem->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 108 108 // An entry in the partMap_ is created, assigning the part to the entity. 109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), elem); 110 110 } 111 111 } … … 146 146 ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const 147 147 { 148 for ( std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)149 { 150 if ( it->first == entity)151 return it->second;148 for (const auto & elem : this->partMap_) 149 { 150 if (elem.first == entity) 151 return elem.second; 152 152 } 153 153 return nullptr; … … 242 242 ShipPart* ModularSpaceShip::getShipPartByName(std::string name) 243 243 { 244 for( std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it)245 { 246 if(orxonox_cast<ShipPart*>( *it)->getName() == name)247 { 248 return orxonox_cast<ShipPart*>( *it);244 for(auto & elem : this->partList_) 245 { 246 if(orxonox_cast<ShipPart*>(elem)->getName() == name) 247 { 248 return orxonox_cast<ShipPart*>(elem); 249 249 } 250 250 } … … 261 261 bool ModularSpaceShip::hasShipPart(ShipPart* part) const 262 262 { 263 for( unsigned int i = 0; i < this->partList_.size(); i++)264 { 265 if( this->partList_[i]== part)263 for(auto & elem : this->partList_) 264 { 265 if(elem == part) 266 266 return true; 267 267 } -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
r10768 r10821 158 158 159 159 // Run the engines 160 for( std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); it++)161 ( *it)->run(dt);160 for(auto & elem : this->engineList_) 161 (elem)->run(dt); 162 162 163 163 if (this->hasLocalController()) … … 318 318 bool SpaceShip::hasEngine(Engine* engine) const 319 319 { 320 for( unsigned int i = 0; i < this->engineList_.size(); i++)321 { 322 if( this->engineList_[i]== engine)320 for(auto & elem : this->engineList_) 321 { 322 if(elem == engine) 323 323 return true; 324 324 } … … 350 350 Engine* SpaceShip::getEngineByName(const std::string& name) 351 351 { 352 for( size_t i = 0; i < this->engineList_.size(); ++i)353 if( this->engineList_[i]->getName() == name)354 return this->engineList_[i];352 for(auto & elem : this->engineList_) 353 if(elem->getName() == name) 354 return elem; 355 355 356 356 orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl; … … 396 396 void SpaceShip::addSpeedFactor(float factor) 397 397 { 398 for( unsigned int i=0; i<this->engineList_.size(); i++)399 this->engineList_[i]->addSpeedMultiply(factor);398 for(auto & elem : this->engineList_) 399 elem->addSpeedMultiply(factor); 400 400 } 401 401 … … 408 408 void SpaceShip::addSpeed(float speed) 409 409 { 410 for( unsigned int i=0; i<this->engineList_.size(); i++)411 this->engineList_[i]->addSpeedAdd(speed);410 for(auto & elem : this->engineList_) 411 elem->addSpeedAdd(speed); 412 412 } 413 413 … … 436 436 { 437 437 float speed=0; 438 for( unsigned int i=0; i<this->engineList_.size(); i++)439 { 440 if( this->engineList_[i]->getMaxSpeedFront() > speed)441 speed = this->engineList_[i]->getMaxSpeedFront();438 for(auto & elem : this->engineList_) 439 { 440 if(elem->getMaxSpeedFront() > speed) 441 speed = elem->getMaxSpeedFront(); 442 442 } 443 443 return speed; -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r10624 r10821 80 80 81 81 std::set<WorldEntity*> attachments = this->getAttachedObjects(); 82 for ( std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)82 for (const auto & attachment : attachments) 83 83 { 84 if (( *it)->isA(Class(TeamColourable)))84 if ((attachment)->isA(Class(TeamColourable))) 85 85 { 86 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);86 TeamColourable* tc = orxonox_cast<TeamColourable*>(attachment); 87 87 tc->setTeamColour(colour); 88 88 }
Note: See TracChangeset
for help on using the changeset viewer.