Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 27, 2010, 7:53:30 PM (14 years ago)
Author:
dafrick
Message:

Fixing small bug in Script (regarding number of executions).
Fixed bug in WorldEntity, that caused the visibility and activity to be synchronized incorrectly (since bVisibleMem and bActiveMem are not synchronized).
Some small changed in documentation.
Started "synchronizing" pickups. Seems to work (except GUI), but haven't done any extensive testing yet.

File:
1 edited

Legend:

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

    r7401 r7493  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/GameMode.h"
    3738#include "core/Template.h"
    3839#include "core/XMLPort.h"
     
    9495            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    9596            this->attach(representation->getSpawnerRepresentation(this));
     97            this->setActive(true); //TODO: Needed?
    9698        }
    9799    }
     
    146148        {
    147149            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    148             representation->setVisible(this->isActive());
    149150            this->attach(representation->getSpawnerRepresentation(this));
    150             this->setActive(true);
     151            this->setActive(true); //TODO: Needed?
    151152        }
    152153    }
     
    160161        SUPER(PickupSpawner, changedActivity);
    161162
    162         this->setVisible(this->isActive());
     163        if(GameMode::isMaster())
     164            this->setVisible(this->isActive());
    163165    }
    164166
     
    169171        Time since last tick.
    170172    */
    171     //TODO: Replace with collisions.
     173    //TODO: Replace with collisions?
    172174    void PickupSpawner::tick(float dt)
    173175    {
    174176        SUPER(PickupSpawner, tick, dt);
    175177
    176         //! If the PickupSpawner is active.
    177         if (this->isActive())
     178        // If the PickupSpawner is active.
     179        if(GameMode::isMaster() && this->isActive())
    178180        {
    179181            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)
    180182
    181             //! Iterate trough all Pawns.
     183            // Iterate trough all Pawns.
    182184            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    183185            {
    184186                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    185187                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    186                 //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
     188                // If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
    187189                if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_))
    188190                {
     
    214216    {
    215217        if(this->spawnsRemaining_ != INF)
    216         {
    217218            this->spawnsRemaining_--;
    218         }
     219
    219220        if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
    220221        {
     
    283284    void PickupSpawner::trigger(Pawn* pawn)
    284285    {
    285         if (this->isActive()) //!< Checks whether PickupSpawner is active.
     286        if(this->isActive()) // Checks whether PickupSpawner is active.
    286287        {
    287288            COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl;
     
    303304            Pickupable* pickup = this->getPickup();
    304305
    305             if(target != NULL && pickup != NULL)
    306             {
    307                 if(pickup->pickup(target))
    308                     this->decrementSpawnsRemaining();
    309                 else
    310                 {
    311                     this->selfDestruct_ = true;
    312                     pickup->destroy();
    313                 }
    314             }
    315             else
    316             {
    317                 if(target == NULL)
    318                     COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl;
    319 
    320                 if(pickup == NULL)
    321                     COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl;
    322                 else
    323                 {
    324                     this->selfDestruct_ = true;
    325                     pickup->destroy();
    326                 }
    327             }
     306            assert(pickup);
     307            assert(target);
     308            assert(pickup->pickup(target));
     309
     310            this->decrementSpawnsRemaining();
    328311        }
    329312    }
Note: See TracChangeset for help on using the changeset viewer.