Changeset 6101 for code/branches/particles2/src/orxonox/infos
- Timestamp:
- Nov 20, 2009, 1:02:09 AM (15 years ago)
- Location:
- code/branches/particles2/src/orxonox/infos
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
r6087 r6101 51 51 this->controllableEntity_ = 0; 52 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->temporaryControllableEntity_ = 0; 54 this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0; 55 54 56 55 this->gtinfo_ = 0; … … 82 81 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 83 82 registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 84 registerVariable(this->temporaryControllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));85 registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);86 83 registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID)); 87 84 } … … 151 148 return; 152 149 150 if (this->oldControllableEntity_) 151 this->stopTemporaryControl(); 153 152 if (this->controllableEntity_) 154 153 this->stopControl(); … … 172 171 return; 173 172 174 assert( this->temporaryControllableEntity_==0 ); 175 176 this->temporaryControllableEntity_ = entity; 177 this->temporaryControllableEntityID_ = entity->getObjectID(); 173 // assert( this->temporaryControllableEntity_==0 ); 174 175 this->oldControllableEntity_ = this->controllableEntity_; 176 this->controllableEntity_ = entity; 177 this->controllableEntityID_ = entity->getObjectID(); 178 178 179 179 entity->setPlayer(this); 180 180 181 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);182 183 181 if (this->controller_) 184 182 this->controller_->setControllableEntity(entity); … … 189 187 void PlayerInfo::stopControl() 190 188 { 189 if ( this->oldControllableEntity_ ) 190 this->stopTemporaryControl(); 191 191 192 ControllableEntity* entity = this->controllableEntity_; 192 193 … … 200 201 this->controller_->setControllableEntity(0); 201 202 202 entity->removePlayer(); 203 if ( GameMode::isMaster() ) 204 entity->removePlayer(); 203 205 204 206 this->changedControllableEntity(); … … 207 209 void PlayerInfo::stopTemporaryControl() 208 210 { 209 ControllableEntity* entity = this->temporaryControllableEntity_; 210 211 if (!entity) 212 return; 213 214 this->temporaryControllableEntity_ = 0; 215 this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN; 211 ControllableEntity* entity = this->controllableEntity_; 212 213 if (!entity || !this->oldControllableEntity_) 214 return; 215 216 this->controllableEntity_ = this->oldControllableEntity_; 217 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 218 this->oldControllableEntity_ = 0; 216 219 217 220 if ( this->controllableEntity_ && this->controller_) 218 221 this->controller_->setControllableEntity(this->controllableEntity_); 219 222 220 entity->removePlayer(); 223 if ( GameMode::isMaster() ) 224 entity->removePlayer(); 221 225 222 226 this->changedControllableEntity(); … … 237 241 } 238 242 239 void PlayerInfo::networkcallback_changedtemporarycontrollableentityID()240 {241 CCOUT(0) << "changedtemporarycontrollableentityid" << endl;242 if (this->temporaryControllableEntityID_ != OBJECTID_UNKNOWN)243 {244 Synchronisable* temp = Synchronisable::getSynchronisable(this->temporaryControllableEntityID_);245 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(temp);246 this->startTemporaryControl(entity);247 }248 else249 {250 this->stopTemporaryControl();251 }252 }253 254 243 255 244 void PlayerInfo::networkcallback_changedgtinfoID() 256 245 { 257 CCOUT(0) << "changedcontrollableentityid" << endl;258 246 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 259 247 { -
code/branches/particles2/src/orxonox/infos/PlayerInfo.h
r6087 r6101 92 92 private: 93 93 void networkcallback_changedcontrollableentityID(); 94 void networkcallback_changedtemporarycontrollableentityID();95 94 void networkcallback_changedgtinfoID(); 96 95 void updateGametypeInfo(); … … 99 98 Controller* controller_; 100 99 ControllableEntity* controllableEntity_; 101 ControllableEntity* temporaryControllableEntity_;100 ControllableEntity* oldControllableEntity_; 102 101 unsigned int controllableEntityID_; 103 unsigned int temporaryControllableEntityID_;104 102 105 103 const GametypeInfo* gtinfo_;
Note: See TracChangeset
for help on using the changeset viewer.