Changeset 10624 for code/trunk/src/modules/pickup
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/modules/pickup/CollectiblePickup.cc
r9667 r10624 40 40 namespace orxonox 41 41 { 42 RegisterAbstractClass(CollectiblePickup).inheritsFrom (Class(Pickupable));42 RegisterAbstractClass(CollectiblePickup).inheritsFrom<Pickupable>(); 43 43 44 44 /** -
code/trunk/src/modules/pickup/PickupManager.cc
r9667 r10624 38 38 #include "core/GUIManager.h" 39 39 #include "core/class/Identifier.h" 40 #include "core/singleton/ScopedSingletonIncludes.h" 40 41 #include "network/Host.h" 41 #include "network/NetworkFunction.h" 42 #include "util/ScopedSingletonManager.h" 42 #include "network/NetworkFunctionIncludes.h" 43 43 44 44 #include "infos/PlayerInfo.h" … … 51 51 namespace orxonox 52 52 { 53 ManageScopedSingleton(PickupManager, ScopeID::R oot, false);53 ManageScopedSingleton(PickupManager, ScopeID::ROOT, false); 54 54 55 55 // Initialization of the name of the PickupInventory GUI. … … 62 62 registerStaticNetworkFunction(PickupManager::usePickupNetworked); 63 63 64 RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>(); 65 64 66 /** 65 67 @brief … … 94 96 95 97 // Destroying all the WeakPointers that are still there. 96 for(std::map<uint32_t, WeakPtr<Pickupable>*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)97 delete it->second;98 98 this->pickups_.clear(); 99 99 … … 212 212 else 213 213 { 214 callStaticNetworkFunction( PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());214 callStaticNetworkFunction(&PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable()); 215 215 } 216 216 } … … 286 286 // Add the Pickupable to the indexes_ and pickups_ lists. 287 287 this->indexes_[pickup] = index; 288 this->pickups_[index] = new WeakPtr<Pickupable>(pickup);288 this->pickups_[index] = pickup; 289 289 } 290 290 else // If it was dropped, it is removed from the required lists. … … 294 294 index = it->second; 295 295 296 // Remove the Pickupable form the indexes_ and pickups_ list. 297 WeakPtr<Pickupable>* ptr = this->pickups_[index]; 296 // Remove the Pickupable from the indexes_ and pickups_ list. 298 297 this->indexes_.erase(it); 299 298 this->pickups_.erase(index); 300 delete ptr;301 299 } 302 300 … … 316 314 if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end()) 317 315 { 318 callStaticNetworkFunction( PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);316 callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp); 319 317 } 320 318 else 321 319 { 322 callStaticNetworkFunction( PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);320 callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp); 323 321 } 324 322 } … … 400 398 if(this->pickups_.empty()) 401 399 return; 402 Pickupable* pickupable = this->pickups_.find(pickup)->second ->get();400 Pickupable* pickupable = this->pickups_.find(pickup)->second; 403 401 if(pickupable != NULL) 404 402 pickupable->drop(); … … 407 405 else 408 406 { 409 callStaticNetworkFunction( PickupManager::dropPickupNetworked, 0, pickup);407 callStaticNetworkFunction(&PickupManager::dropPickupNetworked, 0, pickup); 410 408 } 411 409 } … … 443 441 if(this->pickups_.empty()) 444 442 return; 445 Pickupable* pickupable = this->pickups_.find(pickup)->second ->get();443 Pickupable* pickupable = this->pickups_.find(pickup)->second; 446 444 if(pickupable != NULL) 447 445 pickupable->setUsed(use); … … 450 448 else 451 449 { 452 callStaticNetworkFunction( PickupManager::usePickupNetworked, 0, pickup, use);450 callStaticNetworkFunction(&PickupManager::usePickupNetworked, 0, pickup, use); 453 451 } 454 452 } -
code/trunk/src/modules/pickup/PickupManager.h
r9667 r10624 161 161 std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_. 162 162 163 std::map<uint32_t, WeakPtr<Pickupable> *> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.163 std::map<uint32_t, WeakPtr<Pickupable> > pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable. 164 164 std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it. 165 165 -
code/trunk/src/modules/pickup/PickupSpawner.cc
r9667 r10624 145 145 if(GameMode::isMaster() && this->isActive()) 146 146 { 147 WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 147 // TODO: why is this a WeakPtr when the comment says StrongPtr? 148 WeakPtr<PickupSpawner> spawner = this; // Create a strong pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 148 149 149 150 // Remove PickupCarriers from the blocked list if they have exceeded their time. -
code/trunk/src/modules/pickup/items/ShrinkPickup.cc
r9667 r10624 182 182 183 183 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 184 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();184 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 185 185 int size = cameraPositions.size(); 186 186 for(int index = 0; index < size; index++) … … 208 208 209 209 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 210 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();210 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 211 211 int size = cameraPositions.size(); 212 212 for(int index = 0; index < size; index++) … … 263 263 264 264 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 265 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();265 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 266 266 int size = cameraPositions.size(); 267 267 for(int index = 0; index < size; index++) … … 304 304 305 305 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation. 306 const std::list< S martPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();306 const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions(); 307 307 int size = cameraPositions.size(); 308 308 for(int index = 0; index < size; index++)
Note: See TracChangeset
for help on using the changeset viewer.