[Orxonox-commit 2836] r7539 - code/trunk/src/modules/pickup

dafrick at orxonox.net dafrick at orxonox.net
Wed Oct 13 22:57:13 CEST 2010


Author: dafrick
Date: 2010-10-13 22:57:13 +0200 (Wed, 13 Oct 2010)
New Revision: 7539

Modified:
   code/trunk/src/modules/pickup/PickupManager.cc
   code/trunk/src/modules/pickup/PickupRepresentation.h
Log:
Some cleanup in PickupManager.


Modified: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc	2010-10-13 18:36:51 UTC (rev 7538)
+++ code/trunk/src/modules/pickup/PickupManager.cc	2010-10-13 20:57:13 UTC (rev 7539)
@@ -33,17 +33,16 @@
 
 #include "PickupManager.h"
 
-#include "util/Convert.h"
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
 #include "core/GUIManager.h"
 #include "core/Identifier.h"
 #include "network/Host.h"
 #include "network/NetworkFunction.h"
+#include "util/ScopedSingletonManager.h"
 
-#include "interfaces/PickupCarrier.h"
 #include "infos/PlayerInfo.h"
+#include "interfaces/PickupCarrier.h"
 #include "worldentities/pawns/Pawn.h"
 
 #include "CollectiblePickup.h"
@@ -95,8 +94,6 @@
         this->representations_.clear();
         this->representationsNetworked_.clear();
 
-        //TODO: Destroying properly?
-        //TODO: Shouldnt these list be empty, to avoid problems when switching levels?
         // Destroying all the PickupInventoryContainers that are still there.
         for(std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.begin(); it != this->pickupInventoryContainers_.end(); it++)
             delete it->second;
@@ -483,8 +480,10 @@
     void PickupManager::dropPickup(uint32_t pickup)
     {
         // If we're either server or standalone and the list of pickups is not empty, we find and drop the input pickup.
-        if(GameMode::isMaster() && !this->pickups_.empty())
+        if(GameMode::isMaster())
         {
+            if(this->pickups_.empty())
+                return;
             Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
             if(pickupable != NULL)
                 pickupable->drop();
@@ -508,12 +507,7 @@
         if(GameMode::isServer()) // Obviously we only want to do this on the server.
         {
             PickupManager& manager = PickupManager::getInstance();
-            //TODO: Just call dropPickup() on manager?
-            if(manager.pickups_.empty())
-                return;
-            Pickupable* pickupable = manager.pickups_.find(pickup)->second->get();
-            if(pickupable != NULL)
-                pickupable->drop();
+            manager.dropPickup(pickup);
         }
     }
 
@@ -529,8 +523,10 @@
     void PickupManager::usePickup(uint32_t pickup, bool use)
     {
         // If we're either server or standalone and the list of pickups is not empty, we find and change the used status of the input pickup.
-        if(GameMode::isMaster() && !this->pickups_.empty())
+        if(GameMode::isMaster())
         {
+            if(this->pickups_.empty())
+                return;
             Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
             if(pickupable != NULL)
                 pickupable->setUsed(use);
@@ -556,12 +552,7 @@
         if(GameMode::isServer())
         {
             PickupManager& manager = PickupManager::getInstance();
-            //TODO: Just call usePickup() on manager?
-            if(manager.pickups_.empty())
-                return;
-            Pickupable* pickupable = manager.pickups_.find(pickup)->second->get();
-            if(pickupable != NULL)
-                pickupable->setUsed(use);
+            manager.usePickup(pickup, use);
         }
     }
 

Modified: code/trunk/src/modules/pickup/PickupRepresentation.h
===================================================================
--- code/trunk/src/modules/pickup/PickupRepresentation.h	2010-10-13 18:36:51 UTC (rev 7538)
+++ code/trunk/src/modules/pickup/PickupRepresentation.h	2010-10-13 20:57:13 UTC (rev 7539)
@@ -53,6 +53,11 @@
     @brief
         The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
         They are created through XML and are registered with the PickupManager.
+
+    @author
+        Damian 'Mozork' Frick
+
+    @ingroup Pickup
     */
     class _PickupExport PickupRepresentation // tolua_export
         : public BaseObject, public Synchronisable




More information about the Orxonox-commit mailing list