- Timestamp:
- Nov 21, 2015, 7:05:53 PM (8 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.