[Orxonox-commit 1779] r6497 - in code/branches/pickup3/src: libraries/core modules/pickup modules/pickup/items orxonox/interfaces

dafrick at orxonox.net dafrick at orxonox.net
Mon Mar 8 21:17:23 CET 2010


Author: dafrick
Date: 2010-03-08 21:17:22 +0100 (Mon, 08 Mar 2010)
New Revision: 6497

Modified:
   code/branches/pickup3/src/libraries/core/OrxonoxClass.h
   code/branches/pickup3/src/modules/pickup/Pickup.cc
   code/branches/pickup3/src/modules/pickup/Pickup.h
   code/branches/pickup3/src/modules/pickup/PickupCollection.cc
   code/branches/pickup3/src/modules/pickup/PickupCollection.h
   code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
   code/branches/pickup3/src/modules/pickup/items/HealthPickup.h
   code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
   code/branches/pickup3/src/orxonox/interfaces/Pickupable.h
Log:
Fixed bug in clone() (Argument needed to be as reference). Pickups seem to be working now (after very sporadic testing), more systematic testing (and probably still some more bug fixes) will follow.


Modified: code/branches/pickup3/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/branches/pickup3/src/libraries/core/OrxonoxClass.h	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/libraries/core/OrxonoxClass.h	2010-03-08 20:17:22 UTC (rev 6497)
@@ -108,7 +108,7 @@
             bool isParentOf(const OrxonoxClass* object);
             bool isDirectParentOf(const OrxonoxClass* object);
             
-            virtual void clone(OrxonoxClass* item) {}
+            virtual void clone(OrxonoxClass*& item) {}
 
             inline unsigned int getReferenceCount() const
                 { return this->referenceCount_; }

Modified: code/branches/pickup3/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/Pickup.cc	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/Pickup.cc	2010-03-08 20:17:22 UTC (rev 6497)
@@ -187,6 +187,7 @@
     {
         SUPER(Pickup, changedCarrier);
         
+        COUT(1) << "Changed Carrier: " << this->isPickedUp() << this->isImmediate() << std::endl;
         //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
         if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
         {
@@ -200,7 +201,7 @@
     @return
         Returns the clone of this pickup as a pointer to a Pickupable.
     */
-    void Pickup::clone(OrxonoxClass* item)
+    void Pickup::clone(OrxonoxClass*& item)
     {
         if(item == NULL)
             item = new Pickup(this);

Modified: code/branches/pickup3/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/Pickup.h	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/Pickup.h	2010-03-08 20:17:22 UTC (rev 6497)
@@ -118,7 +118,7 @@
             
             virtual void changedCarrier(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
                                     
-            virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the Pickup.
+            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
                 
         protected:
             void initializeIdentifier(void);

Modified: code/branches/pickup3/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollection.cc	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/PickupCollection.cc	2010-03-08 20:17:22 UTC (rev 6497)
@@ -160,7 +160,7 @@
     }
     
     //TODO: Steal description from Pickupable.
-    void PickupCollection::clone(OrxonoxClass* item)
+    void PickupCollection::clone(OrxonoxClass*& item)
     {
         if(item == NULL)
             item = new PickupCollection(this);

Modified: code/branches/pickup3/src/modules/pickup/PickupCollection.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollection.h	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/PickupCollection.h	2010-03-08 20:17:22 UTC (rev 6497)
@@ -61,7 +61,7 @@
             
             virtual void changedCarrier(void);
             
-            virtual void clone(OrxonoxClass* item);
+            virtual void clone(OrxonoxClass*& item);
             
             virtual const PickupIdentifier* getPickupIdentifier(void);
             

Modified: code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-08 20:17:22 UTC (rev 6497)
@@ -279,7 +279,7 @@
     @param item
         A pointer to the Orxonox class.
     */
-    void HealthPickup::clone(OrxonoxClass* item)
+    void HealthPickup::clone(OrxonoxClass*& item)
     {
         if(item == NULL)
             item = new HealthPickup(this);

Modified: code/branches/pickup3/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.h	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/modules/pickup/items/HealthPickup.h	2010-03-08 20:17:22 UTC (rev 6497)
@@ -73,7 +73,7 @@
             virtual void tick(float dt); //!< Is called every tick.
             
             virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
-            virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the input OrxonoxClass.
+            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
             
             /**
             @brief Get the health that is transfered to the Pawn upon usage of this pickup.

Modified: code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-08 20:17:22 UTC (rev 6497)
@@ -171,8 +171,8 @@
             return false;
         
         COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
+        this->setPickedUp(true);
         this->setCarrier(carrier);
-        this->setPickedUp(true);
         return true;
     }
     
@@ -230,9 +230,11 @@
     //TODO: Does this work?
     Pickupable* Pickupable::clone(void)
     {
-        Pickupable* pickup = NULL;
-        this->clone(pickup);
+        OrxonoxClass* item = NULL;
+        this->clone(item);
         
+        Pickupable* pickup = dynamic_cast<Pickupable*>(item);
+        
         COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl;
         return pickup;
     }
@@ -245,7 +247,7 @@
         A pointer to the OrxonoxClass that is to be duplicated.
     */
     //TODO: Specify how the implementation must be done in detail.
-    void Pickupable::clone(OrxonoxClass* item)
+    void Pickupable::clone(OrxonoxClass*& item)
     {
         SUPER(Pickupable, clone, item);
     }

Modified: code/branches/pickup3/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/Pickupable.h	2010-03-08 19:07:48 UTC (rev 6496)
+++ code/branches/pickup3/src/orxonox/interfaces/Pickupable.h	2010-03-08 20:17:22 UTC (rev 6497)
@@ -101,7 +101,7 @@
             bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup.
             
             Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
-            virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the input OrxonoxClass.
+            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
             
             /**
             @brief Get the PickupIdentifier of this Pickupable.




More information about the Orxonox-commit mailing list