Changeset 8706 for code/trunk/src/orxonox/infos/PlayerInfo.cc
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/infos/PlayerInfo.cc
r8327 r8706 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(); … … 177 177 return; 178 178 179 assert( this->oldControllableEntity_==0 ); 180 181 this->oldControllableEntity_ = this->controllableEntity_; 179 this->controllableEntity_->destroyHud(); // HACK-ish 180 this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_)); 182 181 this->controllableEntity_ = entity; 183 182 this->controllableEntityID_ = entity->getObjectID(); … … 194 193 void PlayerInfo::stopControl() 195 194 { 196 if ( this->oldControllableEntity_)195 while ( this->previousControllableEntity_.size() > 0) 197 196 this->stopTemporaryControl(); 198 197 … … 215 214 } 216 215 216 void PlayerInfo::pauseControl() 217 { 218 ControllableEntity* entity = this->controllableEntity_; 219 220 if (!entity) 221 return; 222 223 this->controllableEntity_->getController()->setActive(false); 224 //this->controllableEntity_->getController()->setControllableEntity(NULL); 225 this->controllableEntity_->setController(0); 226 } 227 217 228 void PlayerInfo::stopTemporaryControl() 218 229 { 219 230 ControllableEntity* entity = this->controllableEntity_; 220 231 221 assert( this->controllableEntity_ && this->oldControllableEntity_);222 if( !entity || !this->oldControllableEntity_)232 assert(this->controllableEntity_ != NULL); 233 if( !entity || this->previousControllableEntity_.size() == 0 ) 223 234 return; 224 235 225 236 this->controllableEntity_->setController(0); 237 this->controllableEntity_->destroyHud(); // HACK-ish 226 238 227 this->controllableEntity_ = this->oldControllableEntity_; 239 // this->controllableEntity_ = this->previousControllableEntity_.back(); 240 do { 241 this->controllableEntity_ = this->previousControllableEntity_.back(); 242 } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0); 228 243 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 229 this-> oldControllableEntity_ = 0;230 231 if ( this->controllableEntity_ && this->controller_)244 this->previousControllableEntity_.pop_back(); 245 246 if ( this->controllableEntity_ != NULL && this->controller_ != NULL) 232 247 this->controller_->setControllableEntity(this->controllableEntity_); 248 249 // HACK-ish 250 if(this->controllableEntity_ != NULL) 251 this->controllableEntity_->createHud(); 233 252 234 253 if ( GameMode::isMaster() )
Note: See TracChangeset
for help on using the changeset viewer.