[Orxonox-commit 1989] r6706 - code/branches/ppspickups1/src/modules/pickup/items

dafrick at orxonox.net dafrick at orxonox.net
Tue Apr 13 00:41:52 CEST 2010


Author: dafrick
Date: 2010-04-13 00:41:52 +0200 (Tue, 13 Apr 2010)
New Revision: 6706

Modified:
   code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc
   code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
Log:
Small adaptations in SpeedPickup.


Modified: code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc	2010-04-12 22:09:10 UTC (rev 6705)
+++ code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.cc	2010-04-12 22:41:52 UTC (rev 6706)
@@ -74,9 +74,9 @@
     */
     void SpeedPickup::initialize(void)
     {
-        this->duration_ = 0.0;
-        this->speedAdd_ = 0.0;
-        this->speedMultiply_ = 1.0;
+        this->duration_ = 0.0f;
+        this->speedAdd_ = 0.0f;
+        this->speedMultiply_ = 1.0f;
 
         this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     }
@@ -133,21 +133,29 @@
         if(!this->isPickedUp())
             return;
 
+        Engine* engine = this->carrierToEngineHelper();
+        if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
+            this->destroy();
+        
         //! If the pickup has transited to used.
         if(this->isUsed())
         {
-            Engine* engine = this->carrierToEngineHelper();
-            if(engine == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
-                this->destroy();
-
             this->startPickupTimer(this->getDuration());
             engine->setSpeedAdd(this->getSpeedAdd());
             engine->setSpeedMultiply(this->getSpeedMultiply());
         }
+        else
+        {
+            engine->setSpeedAdd(0.0f);
+            engine->setSpeedMultiply(1.0f);
+            
+            if(this->isOnce())
+            {
+                this->destroy();
+            }
+        }
     }
 
-
-
     /**
     @brief
         Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
@@ -249,12 +257,8 @@
         }
     }
 
-    void SpeedPickup::PickupTimerCallBack(void) {
-            Engine* engine = this->carrierToEngineHelper();
-            if(engine == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
-                this->destroy();
-
-            engine->setSpeedAdd(0.0f);
-            engine->setSpeedMultiply(1.0f);
+    void SpeedPickup::pickupTimerCallback(void)
+    {       
+        this->setUsed(false);
     }
 }

Modified: code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h	2010-04-12 22:09:10 UTC (rev 6705)
+++ code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h	2010-04-12 22:41:52 UTC (rev 6706)
@@ -37,7 +37,7 @@
 #include "pickup/PickupPrereqs.h"
 
 #include <string>
-#include <worldentities/pawns/Pawn.h>
+#include "worldentities/pawns/Pawn.h"
 #include "worldentities/StaticEntity.h"
 
 #include "pickup/Pickup.h"
@@ -77,6 +77,8 @@
 
         protected:
             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+            
+            virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
 
             void setDuration(float duration);
             void setSpeedAdd(float speedAdd);
@@ -84,7 +86,6 @@
 
         private:
             void initialize(void); //!< Initializes the member variables.
-            void PickupTimerCallBack(void); //!< Function that gets called when timer ends.
             Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
 
             float duration_; //!< The health that is transferred to the Pawn.




More information about the Orxonox-commit mailing list