[Orxonox-commit 4621] r9292 - code/branches/presentation2012merge/src/modules/pickup

dafrick at orxonox.net dafrick at orxonox.net
Mon Jun 11 22:40:02 CEST 2012


Author: dafrick
Date: 2012-06-11 22:40:01 +0200 (Mon, 11 Jun 2012)
New Revision: 9292

Modified:
   code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc
Log:
Looked through recten changes in pickup module, should be fine!


Modified: code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc	2012-06-10 21:02:29 UTC (rev 9291)
+++ code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc	2012-06-11 20:40:01 UTC (rev 9292)
@@ -272,15 +272,12 @@
     */
     const Pickupable* PickupCollection::getPickupable(unsigned int index) const
     {
-        unsigned int count = 0;
-        for (std::list<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it)
-        {
-            if (count == index)
-                return *it;
-            else
-                ++count;
-        }
-        return NULL;
+        if(this->pickups_.size() >= index)
+            return NULL;
+
+        std::list<CollectiblePickup*>::iterator it = this->pickups_.begin();
+        std::advance(it, index);
+        return *it;
     }
 
     /**




More information about the Orxonox-commit mailing list