Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r10624 r11071  
    5555        Pointer to the object which created this item.
    5656    */
    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)
    5858    {
    5959        RegisterObject(PickupSpawner);
     
    7474        this->selfDestruct_ = false;
    7575
    76         this->setPickupable(NULL);
     76        this->setPickupable(nullptr);
    7777    }
    7878
     
    8383    PickupSpawner::~PickupSpawner()
    8484    {
    85         if(this->isInitialized() && this->selfDestruct_ && this->pickup_ != NULL)
     85        if(this->isInitialized() && this->selfDestruct_ && this->pickup_ != nullptr)
    8686            this->pickup_->destroy();
    8787    }
     
    158158
    159159            // Iterate trough all Pawns.
    160             for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     160            for(Pawn* pawn : ObjectList<Pawn>())
    161161            {
    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).
    163163                    break;
    164164
    165                 Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    166                 PickupCarrier* carrier = static_cast<PickupCarrier*>(*it);
     165                Vector3 distance = pawn->getWorldPosition() - this->getWorldPosition();
     166                PickupCarrier* carrier = static_cast<PickupCarrier*>(pawn);
    167167                // 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())
    169169                {
    170170                    if(carrier->isTarget(this->pickup_))
    171                         this->trigger(*it);
     171                        this->trigger(pawn);
    172172                }
    173173            }
     
    195195        pickedUp = false; // To avoid compiler warning.
    196196
    197         this->setPickupable(NULL);
     197        this->setPickupable(nullptr);
    198198        this->decrementSpawnsRemaining();
    199199    }
     
    282282        {
    283283            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)
    288288        {
    289289            Identifier* identifier = this->pickupTemplate_->getBaseclassIdentifier();
    290             if (identifier != NULL)
     290            if (identifier != nullptr)
    291291            {
    292292                Pickupable* pickup = orxonox_cast<Pickupable*>(identifier->fabricate(this->getContext()));
     
    298298        }
    299299
    300         return NULL;
     300        return nullptr;
    301301    }
    302302
     
    309309    void PickupSpawner::setPickupable(Pickupable* pickup)
    310310    {
    311         if (this->representation_ != NULL)
     311        if (this->representation_ != nullptr)
    312312        {
    313313            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)
    320320                this->pickup_->destroy();
    321321
Note: See TracChangeset for help on using the changeset viewer.