Changeset 8289 for code/branches
- Timestamp:
- Apr 21, 2011, 10:45:42 PM (14 years ago)
- Location:
- code/branches/dockingsystem2/src/orxonox/infos
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc
r8196 r8289 51 51 this->controllableEntity_ = 0; 52 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0;54 53 55 54 this->gtinfo_ = 0; … … 151 150 return; 152 151 153 if (this->oldControllableEntity_)152 while (this->previousControllableEntity_.size() > 0) 154 153 this->stopTemporaryControl(); 154 155 155 if (this->controllableEntity_) 156 156 this->stopControl(); … … 176 176 if (!entity) 177 177 return; 178 179 assert( this->oldControllableEntity_==0 ); 180 181 this->oldControllableEntity_ = this->controllableEntity_; 178 179 this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_)); 182 180 this->controllableEntity_ = entity; 183 181 this->controllableEntityID_ = entity->getObjectID(); … … 194 192 void PlayerInfo::stopControl() 195 193 { 196 if ( this->oldControllableEntity_)194 while ( this->previousControllableEntity_.size() > 0) 197 195 this->stopTemporaryControl(); 198 196 … … 219 217 ControllableEntity* entity = this->controllableEntity_; 220 218 221 assert( this->controllableEntity_ && this->oldControllableEntity_);222 if( !entity || !this->oldControllableEntity_)219 assert(this->controllableEntity_ != NULL); 220 if( !entity || this->previousControllableEntity_.size() == 0 ) 223 221 return; 224 222 225 223 this->controllableEntity_->setController(0); 226 227 this->controllableEntity_ = this->oldControllableEntity_; 224 225 this->controllableEntity_ = this->previousControllableEntity_.back(); 226 do { 227 this->controllableEntity_ = this->previousControllableEntity_.back(); 228 } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0); 228 229 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 229 this-> oldControllableEntity_ = 0;230 231 if ( this->controllableEntity_ && this->controller_)230 this->previousControllableEntity_.pop_back(); 231 232 if ( this->controllableEntity_ != NULL && this->controller_ != NULL) 232 233 this->controller_->setControllableEntity(this->controllableEntity_); 233 234 -
code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.h
r7163 r8289 98 98 Controller* controller_; 99 99 ControllableEntity* controllableEntity_; 100 ControllableEntity* oldControllableEntity_;100 std::vector< WeakPtr<ControllableEntity> > previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent. 101 101 unsigned int controllableEntityID_; 102 102
Note: See TracChangeset
for help on using the changeset viewer.