Changeset 10765 for code/branches/cpp11_v2/src/modules/pickup
- Timestamp:
- Nov 4, 2015, 10:25:42 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/modules/pickup
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/pickup/CollectiblePickup.cc
r10624 r10765 47 47 Registers the object and initializes variables. 48 48 */ 49 CollectiblePickup::CollectiblePickup() : collection_( NULL)49 CollectiblePickup::CollectiblePickup() : collection_(nullptr) 50 50 { 51 51 RegisterObject(CollectiblePickup); … … 103 103 void CollectiblePickup::wasRemovedFromCollection(void) 104 104 { 105 this->collection_ = NULL;105 this->collection_ = nullptr; 106 106 } 107 107 } -
code/branches/cpp11_v2/src/modules/pickup/CollectiblePickup.h
r9348 r10765 69 69 */ 70 70 bool isInCollection(void) const 71 { return this->collection_ != NULL; }71 { return this->collection_ != nullptr; } 72 72 73 73 private: -
code/branches/cpp11_v2/src/modules/pickup/PickupCollection.cc
r9667 r10765 148 148 for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it) 149 149 { 150 if(this->getCarrier() == NULL)151 (*it)->setCarrier( NULL);150 if(this->getCarrier() == nullptr) 151 (*it)->setCarrier(nullptr); 152 152 else 153 153 (*it)->setCarrier(this->getCarrier()->getTarget(*it)); … … 227 227 bool PickupCollection::addPickupable(CollectiblePickup* pickup) 228 228 { 229 if(pickup == NULL)229 if(pickup == nullptr) 230 230 return false; 231 231 … … 247 247 { 248 248 if(this->pickups_.size() >= index) 249 return NULL;249 return nullptr; 250 250 251 251 std::list<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); -
code/branches/cpp11_v2/src/modules/pickup/PickupManager.cc
r10624 r10765 68 68 Constructor. Registers the PickupManager and creates the default PickupRepresentation. 69 69 */ 70 PickupManager::PickupManager() : guiLoaded_(false), pickupHighestIndex_(0), defaultRepresentation_( NULL)70 PickupManager::PickupManager() : guiLoaded_(false), pickupHighestIndex_(0), defaultRepresentation_(nullptr) 71 71 { 72 72 RegisterObject(PickupManager); … … 85 85 { 86 86 // Destroying the default representation. 87 if(this->defaultRepresentation_ != NULL)87 if(this->defaultRepresentation_ != nullptr) 88 88 this->defaultRepresentation_->destroy(); 89 89 … … 184 184 CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(pickup); 185 185 // If the Pickupable is part of a PickupCollection it isn't displayed in the PickupInventory, just the PickupCollection is. 186 if(collectible != NULL&& collectible->isInCollection())186 if(collectible != nullptr && collectible->isInCollection()) 187 187 return; 188 188 189 189 // Getting clientId of the host this change of the pickup's used status concerns. 190 190 PickupCarrier* carrier = pickup->getCarrier(); 191 while(carrier->getCarrierParent() != NULL)191 while(carrier->getCarrierParent() != nullptr) 192 192 carrier = carrier->getCarrierParent(); 193 193 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 194 if(pawn == NULL)194 if(pawn == nullptr) 195 195 return; 196 196 PlayerInfo* info = pawn->getPlayer(); 197 if(info == NULL)197 if(info == nullptr) 198 198 return; 199 199 unsigned int clientId = info->getClientID(); … … 265 265 CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(pickup); 266 266 // If the Pickupable is part of a PickupCollection it isn't displayed in the PickupInventory, just the PickupCollection is. 267 if(collectible != NULL&& collectible->isInCollection())267 if(collectible != nullptr && collectible->isInCollection()) 268 268 return; 269 269 270 270 // Getting clientId of the host this change of the pickup's pickedUp status concerns. 271 271 PickupCarrier* carrier = pickup->getCarrier(); 272 while(carrier->getCarrierParent() != NULL)272 while(carrier->getCarrierParent() != nullptr) 273 273 carrier = carrier->getCarrierParent(); 274 274 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 275 if(pawn == NULL)275 if(pawn == nullptr) 276 276 return; 277 277 PlayerInfo* info = pawn->getFormerPlayer(); 278 if(info == NULL)278 if(info == nullptr) 279 279 return; 280 280 unsigned int clientId = info->getClientID(); … … 399 399 return; 400 400 Pickupable* pickupable = this->pickups_.find(pickup)->second; 401 if(pickupable != NULL)401 if(pickupable != nullptr) 402 402 pickupable->drop(); 403 403 } … … 442 442 return; 443 443 Pickupable* pickupable = this->pickups_.find(pickup)->second; 444 if(pickupable != NULL)444 if(pickupable != nullptr) 445 445 pickupable->setUsed(use); 446 446 } -
code/branches/cpp11_v2/src/modules/pickup/PickupRepresentation.cc
r9667 r10765 52 52 This is primarily for use of the PickupManager in creating a default PickupRepresentation. 53 53 */ 54 PickupRepresentation::PickupRepresentation() : BaseObject( NULL), Synchronisable(NULL), spawnerRepresentation_(NULL)54 PickupRepresentation::PickupRepresentation() : BaseObject(nullptr), Synchronisable(nullptr), spawnerRepresentation_(nullptr) 55 55 { 56 56 RegisterObject(PickupRepresentation); … … 64 64 Default Constructor. Registers the object and initializes its member variables. 65 65 */ 66 PickupRepresentation::PickupRepresentation(Context* context) : BaseObject(context), Synchronisable(context), spawnerRepresentation_( NULL)66 PickupRepresentation::PickupRepresentation(Context* context) : BaseObject(context), Synchronisable(context), spawnerRepresentation_(nullptr) 67 67 { 68 68 RegisterObject(PickupRepresentation); … … 78 78 PickupRepresentation::~PickupRepresentation() 79 79 { 80 if(this->spawnerRepresentation_ != NULL)80 if(this->spawnerRepresentation_ != nullptr) 81 81 this->spawnerRepresentation_->destroy(); 82 82 … … 135 135 StaticEntity* PickupRepresentation::createSpawnerRepresentation(PickupSpawner* spawner) 136 136 { 137 if(this->spawnerRepresentation_ == NULL)137 if(this->spawnerRepresentation_ == nullptr) 138 138 { 139 139 orxout(verbose, context::pickups) << "PickupRepresentation: No spawner representation found." << endl; … … 149 149 this->spawnerRepresentation_->setVisible(true); 150 150 StaticEntity* temp = this->spawnerRepresentation_; 151 this->spawnerRepresentation_ = NULL;151 this->spawnerRepresentation_ = nullptr; 152 152 153 153 return temp; … … 164 164 { 165 165 this->spawnerRepresentation_ = representation; 166 if(this->spawnerRepresentation_ != NULL)166 if(this->spawnerRepresentation_ != nullptr) 167 167 this->spawnerRepresentation_->setVisible(false); 168 168 } -
code/branches/cpp11_v2/src/modules/pickup/PickupRepresentation.h
r9667 r10765 119 119 @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like. 120 120 @param index The index. 121 @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.121 @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns nullptr. 122 122 */ 123 123 inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index) const 124 { if(index == 0) return this->spawnerRepresentation_; return NULL; }124 { if(index == 0) return this->spawnerRepresentation_; return nullptr; } 125 125 /** 126 126 @brief Get the name of the image representing the pickup in the PickupInventory. -
code/branches/cpp11_v2/src/modules/pickup/PickupSpawner.cc
r10624 r10765 55 55 Pointer to the object which created this item. 56 56 */ 57 PickupSpawner::PickupSpawner(Context* context) : StaticEntity(context), pickup_( NULL), representation_(NULL), pickupTemplate_(NULL)57 PickupSpawner::PickupSpawner(Context* context) : StaticEntity(context), pickup_(nullptr), representation_(nullptr), pickupTemplate_(nullptr) 58 58 { 59 59 RegisterObject(PickupSpawner); … … 74 74 this->selfDestruct_ = false; 75 75 76 this->setPickupable( NULL);76 this->setPickupable(nullptr); 77 77 } 78 78 … … 83 83 PickupSpawner::~PickupSpawner() 84 84 { 85 if(this->isInitialized() && this->selfDestruct_ && this->pickup_ != NULL)85 if(this->isInitialized() && this->selfDestruct_ && this->pickup_ != nullptr) 86 86 this->pickup_->destroy(); 87 87 } … … 160 160 for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 161 161 { 162 if(spawner == NULL) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute).162 if(spawner == nullptr) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute). 163 163 break; 164 164 … … 166 166 PickupCarrier* carrier = static_cast<PickupCarrier*>(*it); 167 167 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawner, is in trigger-distance and the carrier is not blocked. 168 if(distance.length() < this->triggerDistance_ && carrier != NULL&& this->blocked_.find(carrier) == this->blocked_.end())168 if(distance.length() < this->triggerDistance_ && carrier != nullptr && this->blocked_.find(carrier) == this->blocked_.end()) 169 169 { 170 170 if(carrier->isTarget(this->pickup_)) … … 195 195 pickedUp = false; // To avoid compiler warning. 196 196 197 this->setPickupable( NULL);197 this->setPickupable(nullptr); 198 198 this->decrementSpawnsRemaining(); 199 199 } … … 282 282 { 283 283 orxout(internal_error, context::pickups) << "Massive Error: PickupSpawner still alive until having spawned last item." << endl; 284 return NULL;285 } 286 287 if (this->pickupTemplate_ != NULL)284 return nullptr; 285 } 286 287 if (this->pickupTemplate_ != nullptr) 288 288 { 289 289 Identifier* identifier = this->pickupTemplate_->getBaseclassIdentifier(); 290 if (identifier != NULL)290 if (identifier != nullptr) 291 291 { 292 292 Pickupable* pickup = orxonox_cast<Pickupable*>(identifier->fabricate(this->getContext())); … … 298 298 } 299 299 300 return NULL;300 return nullptr; 301 301 } 302 302 … … 309 309 void PickupSpawner::setPickupable(Pickupable* pickup) 310 310 { 311 if (this->representation_ != NULL)311 if (this->representation_ != nullptr) 312 312 { 313 313 this->representation_->destroy(); 314 this->representation_ = NULL;315 } 316 317 if (pickup != NULL)318 { 319 if (this->pickup_ != NULL)314 this->representation_ = nullptr; 315 } 316 317 if (pickup != nullptr) 318 { 319 if (this->pickup_ != nullptr) 320 320 this->pickup_->destroy(); 321 321 -
code/branches/cpp11_v2/src/modules/pickup/items/DamageBoostPickup.cc
r9667 r10765 106 106 107 107 SpaceShip* ship = this->carrierToSpaceShipHelper(); 108 if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.108 if(ship == nullptr) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed. 109 109 this->Pickupable::destroy(); 110 110 … … 152 152 Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails. 153 153 @return 154 A pointer to the SpaceShip, or NULLif the conversion failed.154 A pointer to the SpaceShip, or nullptr if the conversion failed. 155 155 */ 156 156 SpaceShip* DamageBoostPickup::carrierToSpaceShipHelper(void) … … 159 159 SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier); 160 160 161 if(ship == NULL)161 if(ship == nullptr) 162 162 { 163 163 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in DamageBoostPickup." << endl; -
code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc
r9667 r10765 122 122 123 123 Pawn* pawn = this->carrierToPawnHelper(); 124 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.124 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 125 125 this->Pickupable::destroy(); 126 126 … … 131 131 Controller* controller = drone->getController(); 132 132 DroneController* droneController = orxonox_cast<DroneController*>(controller); 133 if(droneController != NULL)133 if(droneController != nullptr) 134 134 { 135 135 droneController->setOwner(pawn); … … 156 156 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 157 157 @return 158 A pointer to the Pawn, or NULLif the conversion failed.158 A pointer to the Pawn, or nullptr if the conversion failed. 159 159 */ 160 160 Pawn* DronePickup::carrierToPawnHelper(void) … … 163 163 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 164 164 165 if(pawn == NULL)165 if(pawn == nullptr) 166 166 { 167 167 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in DronePickup." << endl; -
code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc
r9667 r10765 114 114 { 115 115 Pawn* pawn = this->carrierToPawnHelper(); 116 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.116 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 117 117 this->Pickupable::destroy(); 118 118 … … 168 168 { 169 169 Pawn* pawn = this->carrierToPawnHelper(); 170 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.170 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 171 171 this->Pickupable::destroy(); 172 172 … … 206 206 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 207 207 208 if(pawn == NULL)208 if(pawn == nullptr) 209 209 { 210 210 orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is '" << carrier->getIdentifier()->getName() << "' instead of Pawn." << endl; … … 233 233 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 234 234 @return 235 A pointer to the Pawn, or NULLif the conversion failed.235 A pointer to the Pawn, or nullptr if the conversion failed. 236 236 */ 237 237 Pawn* HealthPickup::carrierToPawnHelper(void) … … 240 240 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 241 241 242 if(pawn == NULL)242 if(pawn == nullptr) 243 243 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl; 244 244 -
code/branches/cpp11_v2/src/modules/pickup/items/InvisiblePickup.cc
r9667 r10765 139 139 { 140 140 Pawn* pawn = this->carrierToPawnHelper(); 141 if(pawn == NULL)141 if(pawn == nullptr) 142 142 return false; 143 143 … … 163 163 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 164 164 @return 165 A pointer to the Pawn, or NULLif the conversion failed.165 A pointer to the Pawn, or nullptr if the conversion failed. 166 166 */ 167 167 Pawn* InvisiblePickup::carrierToPawnHelper(void) … … 170 170 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 171 171 172 if(pawn == NULL)172 if(pawn == nullptr) 173 173 { 174 174 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in InvisiblePickup." << endl; -
code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
r9667 r10765 107 107 { 108 108 PickupCarrier* carrier = this->getCarrier(); 109 if(this->getMetaType() != pickupMetaType::none && carrier != NULL)109 if(this->getMetaType() != pickupMetaType::none && carrier != nullptr) 110 110 { 111 111 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed. … … 121 121 { 122 122 Pickupable* pickup = (*it); 123 if(pickup == NULL|| pickup == this)123 if(pickup == nullptr || pickup == this) 124 124 continue; 125 125 -
code/branches/cpp11_v2/src/modules/pickup/items/ShieldPickup.cc
r9667 r10765 99 99 100 100 Pawn* pawn = this->carrierToPawnHelper(); 101 if(pawn == NULL)101 if(pawn == nullptr) 102 102 this->Pickupable::destroy(); 103 103 … … 143 143 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 144 144 @return 145 A pointer to the Pawn, or NULLif the conversion failed.145 A pointer to the Pawn, or nullptr if the conversion failed. 146 146 */ 147 147 Pawn* ShieldPickup::carrierToPawnHelper(void) … … 150 150 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 151 151 152 if(pawn == NULL)152 if(pawn == nullptr) 153 153 { 154 154 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in ShieldPickup." << endl; -
code/branches/cpp11_v2/src/modules/pickup/items/ShrinkPickup.cc
r10624 r10765 146 146 { 147 147 Pawn* pawn = this->carrierToPawnHelper(); 148 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.148 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 149 149 { 150 150 this->Pickupable::destroy(); … … 173 173 //TODO: Deploy particle effect. 174 174 Pawn* pawn = this->carrierToPawnHelper(); 175 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.175 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 176 176 return; 177 177 … … 187 187 { 188 188 CameraPosition* cameraPos = pawn->getCameraPosition(index); 189 if(cameraPos == NULL)189 if(cameraPos == nullptr) 190 190 continue; 191 191 cameraPos->setPosition(cameraPos->getPosition()/factor); … … 201 201 //TODO: Deploy particle effect. 202 202 Pawn* pawn = this->carrierToPawnHelper(); 203 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.203 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 204 204 return; 205 205 … … 213 213 { 214 214 CameraPosition* cameraPos = pawn->getCameraPosition(index); 215 if(cameraPos == NULL)215 if(cameraPos == nullptr) 216 216 continue; 217 217 cameraPos->setPosition(cameraPos->getPosition()/this->shrinkFactor_); … … 237 237 { 238 238 Pawn* pawn = this->carrierToPawnHelper(); 239 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.239 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 240 240 { 241 241 this->Pickupable::destroy(); … … 268 268 { 269 269 CameraPosition* cameraPos = pawn->getCameraPosition(index); 270 if(cameraPos == NULL)270 if(cameraPos == nullptr) 271 271 continue; 272 272 cameraPos->setPosition(cameraPos->getPosition()/factor); … … 277 277 { 278 278 Pawn* pawn = this->carrierToPawnHelper(); 279 if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.279 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed. 280 280 this->Pickupable::destroy(); 281 281 … … 309 309 { 310 310 CameraPosition* cameraPos = pawn->getCameraPosition(index); 311 if(cameraPos == NULL)311 if(cameraPos == nullptr) 312 312 continue; 313 313 cameraPos->setPosition(cameraPos->getPosition()/factor); -
code/branches/cpp11_v2/src/modules/pickup/items/SpeedPickup.cc
r9667 r10765 99 99 100 100 SpaceShip* ship = this->carrierToSpaceShipHelper(); 101 if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed.101 if(ship == nullptr) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed. 102 102 this->Pickupable::destroy(); 103 103 … … 143 143 Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails. 144 144 @return 145 A pointer to the SpaceShip, or NULLif the conversion failed.145 A pointer to the SpaceShip, or nullptr if the conversion failed. 146 146 */ 147 147 SpaceShip* SpeedPickup::carrierToSpaceShipHelper(void) … … 150 150 SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier); 151 151 152 if(ship == NULL)152 if(ship == nullptr) 153 153 { 154 154 orxout(internal_error, context::pickups) << "Invalid PickupCarrier in SpeedPickup." << endl;
Note: See TracChangeset
for help on using the changeset viewer.