Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8819


Ignore:
Timestamp:
Aug 3, 2011, 9:54:19 PM (13 years ago)
Author:
dafrick
Message:

Minor change in PickupSpawner, fixing possible cause for segfaults.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/src/modules/pickup/PickupSpawner.cc

    r7801 r8819  
    181181        if(GameMode::isMaster() && this->isActive())
    182182        {
    183             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)
     183            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)
    184184
    185185            // Remove PickupCarriers from the blocked list if they have exceeded their time.
     
    195195            for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    196196            {
     197                if(spawner == NULL) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute).
     198                    break;
     199
    197200                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    198201                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    199                 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawnder, is in trigger-distance and the carrier is not blocked.
     202                // 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.
    200203                if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end())
    201204                {
Note: See TracChangeset for help on using the changeset viewer.