[Orxonox-commit 2790] r7493 - in code/trunk/src: modules/objects modules/pickup modules/pickup/items orxonox/interfaces orxonox/worldentities

dafrick at orxonox.net dafrick at orxonox.net
Mon Sep 27 19:53:30 CEST 2010


Author: dafrick
Date: 2010-09-27 19:53:30 +0200 (Mon, 27 Sep 2010)
New Revision: 7493

Modified:
   code/trunk/src/modules/objects/Script.cc
   code/trunk/src/modules/pickup/CollectiblePickup.h
   code/trunk/src/modules/pickup/DroppedPickup.cc
   code/trunk/src/modules/pickup/DroppedPickup.h
   code/trunk/src/modules/pickup/PickupSpawner.cc
   code/trunk/src/modules/pickup/items/HealthPickup.h
   code/trunk/src/modules/pickup/items/InvisiblePickup.h
   code/trunk/src/modules/pickup/items/MetaPickup.h
   code/trunk/src/modules/pickup/items/ShieldPickup.h
   code/trunk/src/modules/pickup/items/SpeedPickup.h
   code/trunk/src/orxonox/interfaces/Pickupable.cc
   code/trunk/src/orxonox/worldentities/WorldEntity.cc
Log:
Fixing small bug in Script (regarding number of executions).
Fixed bug in WorldEntity, that caused the visibility and activity to be synchronized incorrectly (since bVisibleMem and bActiveMem are not synchronized).
Some small changed in documentation.
Started "synchronizing" pickups. Seems to work (except GUI), but haven't done any extensive testing yet.


Modified: code/trunk/src/modules/objects/Script.cc
===================================================================
--- code/trunk/src/modules/objects/Script.cc	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/objects/Script.cc	2010-09-27 17:53:30 UTC (rev 7493)
@@ -185,7 +185,7 @@
         if(GameMode::isMaster())
         {
             // If the number of executions have been used up.
-            if(this->times_ != Script::INF && this->remainingExecutions_ == 0)
+            if(this->times_ != Script::INF && this->remainingExecutions_ <= 0)
                 return;
         }
 
@@ -208,7 +208,11 @@
                 {
                     callStaticNetworkFunction(Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
                     if(this->times_ != Script::INF) // Decrement the number of remaining executions.
+                    {
                         this->remainingExecutions_--;
+                        if(this->remainingExecutions_ <= 0)
+                            break;
+                    }
                 }
             }
             // Else we execute the code just for the specified client.

Modified: code/trunk/src/modules/pickup/CollectiblePickup.h
===================================================================
--- code/trunk/src/modules/pickup/CollectiblePickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/CollectiblePickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -43,7 +43,10 @@
 
     /**
     @brief
-        Collectible Pickup class. Any pickup inheriting from this class can be added to a PickupCollection and thus be part uf such.
+        The CollectiblePickup class encompasses all @ref orxonox::Pickupable "Pickupables" that can be added to a @ref orxonox::PickupCollection "PickupCollection" and thus be part of such.
+
+        All you need to do to make your @ref orxonox:.Pickupable "Pickupable" a CollectiblePickup is to, in some way, inherit from it. (The @ref orxonox::Pickup Pickup class, for example, is already a CollectiblePickup).
+
     @author
         Damian 'Mozork' Frick
     */

Modified: code/trunk/src/modules/pickup/DroppedPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/DroppedPickup.cc	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/DroppedPickup.cc	2010-09-27 17:53:30 UTC (rev 7493)
@@ -50,7 +50,6 @@
     DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator)
     {
         RegisterObject(DroppedPickup);
-
     }
 
     /**
@@ -82,10 +81,7 @@
     */
     DroppedPickup::~DroppedPickup()
     {
-        if(this->pickup_ != NULL && this->pickup_->isPickedUp())
-        {
-            this->pickup_ = NULL;
-        }
+
     }
 
     /**
@@ -95,7 +91,9 @@
     */
     Pickupable* DroppedPickup::getPickup(void)
     {
-        return this->pickup_;
+        Pickupable* pickup = this->pickup_;
+        this->pickup_ = NULL;
+        return pickup;
     }
 
 }

Modified: code/trunk/src/modules/pickup/DroppedPickup.h
===================================================================
--- code/trunk/src/modules/pickup/DroppedPickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/DroppedPickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -44,9 +44,11 @@
 
     /**
     @brief
-        Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped.
+        Special PickupSpawner that is created when a @ref orxonox::Pickupable "Pickupable" is dropped. It just spawns one pickup, the one that was dropped.
+
     @author
         Daniel 'Huty' Haggenmueller
+    @author
         Damian 'Mozork' Frick
     */
     class _PickupExport DroppedPickup : public PickupSpawner

Modified: code/trunk/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.cc	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc	2010-09-27 17:53:30 UTC (rev 7493)
@@ -34,6 +34,7 @@
 #include "PickupSpawner.h"
 
 #include "core/CoreIncludes.h"
+#include "core/GameMode.h"
 #include "core/Template.h"
 #include "core/XMLPort.h"
 #include "worldentities/pawns/Pawn.h"
@@ -93,6 +94,7 @@
         {
             PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
             this->attach(representation->getSpawnerRepresentation(this));
+            this->setActive(true); //TODO: Needed?
         }
     }
 
@@ -145,9 +147,8 @@
         else
         {
             PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
-            representation->setVisible(this->isActive());
             this->attach(representation->getSpawnerRepresentation(this));
-            this->setActive(true);
+            this->setActive(true); //TODO: Needed?
         }
     }
 
@@ -159,7 +160,8 @@
     {
         SUPER(PickupSpawner, changedActivity);
 
-        this->setVisible(this->isActive());
+        if(GameMode::isMaster())
+            this->setVisible(this->isActive());
     }
 
     /**
@@ -168,22 +170,22 @@
     @param dt
         Time since last tick.
     */
-    //TODO: Replace with collisions.
+    //TODO: Replace with collisions?
     void PickupSpawner::tick(float dt)
     {
         SUPER(PickupSpawner, tick, dt);
 
-        //! If the PickupSpawner is active.
-        if (this->isActive())
+        // If the PickupSpawner is active.
+        if(GameMode::isMaster() && this->isActive())
         {
             SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
 
-            //! Iterate trough all Pawns.
+            // Iterate trough all Pawns.
             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
             {
                 Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
                 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
-                //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
+                // If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
                 if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_))
                 {
                     this->trigger(*it);
@@ -213,9 +215,8 @@
     void PickupSpawner::decrementSpawnsRemaining(void)
     {
         if(this->spawnsRemaining_ != INF)
-        {
             this->spawnsRemaining_--;
-        }
+
         if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
         {
             this->startRespawnTimer();
@@ -282,7 +283,7 @@
     */
     void PickupSpawner::trigger(Pawn* pawn)
     {
-        if (this->isActive()) //!< Checks whether PickupSpawner is active.
+        if(this->isActive()) // Checks whether PickupSpawner is active.
         {
             COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl;
 
@@ -302,29 +303,11 @@
             PickupCarrier* target = carrier->getTarget(this->pickup_);
             Pickupable* pickup = this->getPickup();
 
-            if(target != NULL && pickup != NULL)
-            {
-                if(pickup->pickup(target))
-                    this->decrementSpawnsRemaining();
-                else
-                {
-                    this->selfDestruct_ = true;
-                    pickup->destroy();
-                }
-            }
-            else
-            {
-                if(target == NULL)
-                    COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl;
+            assert(pickup);
+            assert(target);
+            assert(pickup->pickup(target));
 
-                if(pickup == NULL)
-                    COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl;
-                else
-                {
-                    this->selfDestruct_ = true;
-                    pickup->destroy();
-                }
-            }
+            this->decrementSpawnsRemaining();
         }
     }
 

Modified: code/trunk/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/items/HealthPickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -61,10 +61,10 @@
     @brief
         A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
         There are 4 parameters that can be chosen:
-        1) The health. The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
-        2) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
-        3) The duration type: It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
-        4) The health type: The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
+        - The @b health The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
+        - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
+        - The @b duration @b type It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
+        - The @b health @b type The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
     @author
         Damian 'Mozork' Frick
     */

Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -49,8 +49,8 @@
     @brief
         A pickup that makes the Pawn invisible.
         There are 2 parameters that can be chosen:
-        1) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
-        2) The duration type: It can be chosen how long the Pawn will be invisibel.
+        - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
+        - The @b duration @b type It can be chosen how long the Pawn will be invisibel.
     @author
         Benedict Simlinger
     */

Modified: code/trunk/src/modules/pickup/items/MetaPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/MetaPickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/items/MetaPickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -57,10 +57,10 @@
     /**
     @brief
         The MetaPickup is a pickup that can, depending on the parameter 'metaType', do different things. If the 'metaType' is set to
-        1) 'use', all the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
-        2) 'drop', all the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
-        3) 'destroy', all the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
-        4) 'destroyCarrier', the PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
+        - @b use All the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
+        - @b drop All the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
+        - @b destroy All the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
+        - @b destroyCarrier The PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
     @author
         Damian 'Mozork' Frick
     */

Modified: code/trunk/src/modules/pickup/items/ShieldPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/ShieldPickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/items/ShieldPickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -50,10 +50,11 @@
     @brief
         A Pickup which can add a Shield to the Pawn.
 
-        1) The percentage: The percentage the shield takes from the damage dealt to a Pawn
-        2) The hit points: The amount of damage points a shield can teake before collapsing
-        3) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
-        4) The duration: the activation time of the pickup.
+        There are 4 parameters that can be cosen.
+        - The @b percentage The percentage the shield takes from the damage dealt to a Pawn
+        - The @b hit @b points The amount of damage points a shield can teake before collapsing
+        - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
+        - The @b duration the activation time of the pickup.
 
     @author
         Eric Beier

Modified: code/trunk/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.h	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.h	2010-09-27 17:53:30 UTC (rev 7493)
@@ -49,10 +49,11 @@
     @brief
         A Pickup which can manipulate the Speed of a Pawn.
 
-        1) The speed multiplier:
-           The additional (forward) speed:
-        2) The activation type: 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
-        4) The duration: the activation time of the pickup.
+        There are 4 parameters that can be cosen:
+        - The @b speed @b multiplier
+        - The @b additional (forward) @b speed
+        - The @b activation @b type 'immediate' or 'onUse'. defines if the item is used when it's picked up or only after the player chooses to use it.
+        - The @b duration The activation time of the pickup.
 
     @author
         Eric Beier

Modified: code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc	2010-09-27 17:53:30 UTC (rev 7493)
@@ -67,9 +67,11 @@
     */
     Pickupable::~Pickupable()
     {
-        COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl;
         if(this->pickupIdentifier_ != NULL)
+        {
+            COUT(4) << "Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ") destroyed." << std::endl;
             this->pickupIdentifier_->destroy();
+        }
     }
 
     /**

Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc	2010-09-26 20:38:57 UTC (rev 7492)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc	2010-09-27 17:53:30 UTC (rev 7493)
@@ -213,17 +213,20 @@
     {
         SUPER(WorldEntity, changedActivity);
 
-        for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+        if(GameMode::isMaster())
         {
-            if(!this->isActive())
+            for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
             {
-                (*it)->bActiveMem_ = (*it)->isActive();
-                (*it)->setActive(this->isActive());
+                if(!this->isActive())
+                {
+                    (*it)->bActiveMem_ = (*it)->isActive();
+                    (*it)->setActive(this->isActive());
+                }
+                else
+                {
+                    (*it)->setActive((*it)->bActiveMem_);
+                }
             }
-            else
-            {
-                (*it)->setActive((*it)->bActiveMem_);
-            }
         }
     }
 
@@ -235,17 +238,20 @@
     {
         SUPER(WorldEntity, changedVisibility);
 
-        for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+        if(GameMode::isMaster())
         {
-            if(!this->isVisible())
+            for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
             {
-                (*it)->bVisibleMem_ = (*it)->isVisible();
-                (*it)->setVisible(this->isVisible());
+                if(!this->isVisible())
+                {
+                    (*it)->bVisibleMem_ = (*it)->isVisible();
+                    (*it)->setVisible(this->isVisible());
+                }
+                else
+                {
+                    (*it)->setVisible((*it)->bVisibleMem_);
+                }
             }
-            else
-            {
-                (*it)->setVisible((*it)->bVisibleMem_);
-            }
         }
     }
 




More information about the Orxonox-commit mailing list