Changeset 9290 for code/branches/presentation2012merge/src/modules/pickup/PickupCollectionIdentifier.cc
- Timestamp:
- Jun 10, 2012, 11:01:40 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/modules/pickup/PickupCollectionIdentifier.cc
r7533 r9290 35 35 36 36 #include "PickupCollectionIdentifier.h" 37 #include "PickupCollection.h" 37 38 38 39 namespace orxonox … … 43 44 Constructor. Registers the object. 44 45 */ 45 PickupCollectionIdentifier::PickupCollectionIdentifier(Pickup able* pickup) : PickupIdentifier(pickup)46 PickupCollectionIdentifier::PickupCollectionIdentifier(PickupCollection* collection) : PickupIdentifier(collection) 46 47 { 47 48 RegisterObject(PickupCollectionIdentifier); 49 50 this->collection_ = collection; 48 51 } 49 52 … … 80 83 81 84 // If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller. 82 if(this-> identifiers_.size() != collectionIdentifier->identifiers_.size())83 return this-> identifiers_.size()-collectionIdentifier->identifiers_.size();85 if(this->collection_->getPickups().size() != collectionIdentifier->collection_->getPickups().size()) 86 return this->collection_->getPickups().size()-collectionIdentifier->collection_->getPickups().size(); 84 87 85 88 // Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller. 86 std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it2 = collectionIdentifier->identifiers_.begin(); 87 for(std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); it++) 89 std::list<CollectiblePickup*>::const_iterator it1 = this->collection_->getPickups().begin(); 90 std::list<CollectiblePickup*>::const_iterator it2 = collectionIdentifier->collection_->getPickups().begin(); 91 for( ; it1 != this->collection_->getPickups().end(); ++it1, ++it2) 88 92 { 93 const PickupIdentifier* id1 = (*it1)->getPickupIdentifier(); 94 const PickupIdentifier* id2 = (*it2)->getPickupIdentifier(); 89 95 90 if( (*it)->compare(*it2) < 0)96 if(id1->compare(id2) < 0) 91 97 return -1; 92 if( (*it2)->compare(*it) < 0)98 if(id2->compare(id1) < 0) 93 99 return 1; 94 100 } … … 98 104 } 99 105 100 /**101 @brief102 Add a Pickupable to the PickupCollectionIdentifier.103 @param identifier104 A pointer to the PickupIdentifier of the Pickupable to be added.105 */106 void PickupCollectionIdentifier::addPickup(const PickupIdentifier* identifier)107 {108 this->identifiers_.insert(identifier);109 }110 111 106 } 112 107
Note: See TracChangeset
for help on using the changeset viewer.