Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2011, 4:44:39 PM (13 years ago)
Author:
dafrick
Message:

Merging dockingsystem2 branch to presentation branch.

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/infos/PlayerInfo.cc

    r8327 r8561  
    5151        this->controllableEntity_ = 0;
    5252        this->controllableEntityID_ = OBJECTID_UNKNOWN;
    53         this->oldControllableEntity_ = 0;
    5453
    5554        this->gtinfo_ = 0;
     
    151150            return;
    152151
    153         if (this->oldControllableEntity_)
     152        while (this->previousControllableEntity_.size() > 0)
    154153            this->stopTemporaryControl();
     154       
    155155        if (this->controllableEntity_)
    156156            this->stopControl();
     
    176176        if (!entity)
    177177            return;
    178 
    179         assert( this->oldControllableEntity_==0 );
    180 
    181         this->oldControllableEntity_ = this->controllableEntity_;
     178       
     179        this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
    182180        this->controllableEntity_ = entity;
    183181        this->controllableEntityID_ = entity->getObjectID();
     
    194192    void PlayerInfo::stopControl()
    195193    {
    196         if ( this->oldControllableEntity_ )
     194        while ( this->previousControllableEntity_.size() > 0)
    197195            this->stopTemporaryControl();
    198196
     
    215213    }
    216214
     215    void PlayerInfo::pauseControl()
     216    {
     217        ControllableEntity* entity = this->controllableEntity_;
     218
     219        if (!entity)
     220            return;
     221
     222        this->controllableEntity_->getController()->setActive(false);
     223        //this->controllableEntity_->getController()->setControllableEntity(NULL);
     224        this->controllableEntity_->setController(0);
     225    }
     226
    217227    void PlayerInfo::stopTemporaryControl()
    218228    {
    219229        ControllableEntity* entity = this->controllableEntity_;
    220230
    221         assert( this->controllableEntity_ && this->oldControllableEntity_ );
    222         if( !entity || !this->oldControllableEntity_ )
     231        assert(this->controllableEntity_ != NULL);
     232        if( !entity || this->previousControllableEntity_.size() == 0 )
    223233            return;
    224234
    225235        this->controllableEntity_->setController(0);
    226236       
    227         this->controllableEntity_ = this->oldControllableEntity_;
     237//        this->controllableEntity_ = this->previousControllableEntity_.back();
     238        do {
     239            this->controllableEntity_ = this->previousControllableEntity_.back();
     240        } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0);
    228241        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
    229         this->oldControllableEntity_ = 0;
    230 
    231         if ( this->controllableEntity_ && this->controller_)
     242        this->previousControllableEntity_.pop_back();
     243
     244        if ( this->controllableEntity_ != NULL && this->controller_ != NULL)
    232245            this->controller_->setControllableEntity(this->controllableEntity_);
    233246
Note: See TracChangeset for help on using the changeset viewer.