Changeset 6412 for code/branches/pickup2/src/orxonox/infos/PlayerInfo.cc
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/infos/PlayerInfo.cc
r5929 r6412 50 50 this->controller_ = 0; 51 51 this->controllableEntity_ = 0; 52 this->controllableEntityID_ = CLIENTID_UNKNOWN; 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0; 53 54 54 55 this->gtinfo_ = 0; … … 80 81 registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 81 82 registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 82 registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);83 83 registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID)); 84 84 } … … 139 139 this->controller_->setPlayer(this); 140 140 if (this->controllableEntity_) 141 { 141 142 this->controller_->setControllableEntity(this->controllableEntity_); 143 this->controllableEntity_->setController(this->controller_); 144 } 142 145 this->changedController(); 143 146 } … … 148 151 return; 149 152 153 if (this->oldControllableEntity_) 154 this->stopTemporaryControl(); 150 155 if (this->controllableEntity_) 151 156 this->stopControl(); … … 159 164 160 165 if (this->controller_) 166 { 161 167 this->controller_->setControllableEntity(entity); 168 this->controllableEntity_->setController(this->controller_); 169 } 170 171 this->changedControllableEntity(); 172 } 173 174 void PlayerInfo::startTemporaryControl(ControllableEntity* entity) 175 { 176 if (!entity) 177 return; 178 179 // assert( this->temporaryControllableEntity_==0 ); 180 181 this->oldControllableEntity_ = this->controllableEntity_; 182 this->controllableEntity_ = entity; 183 this->controllableEntityID_ = entity->getObjectID(); 184 185 entity->setPlayer(this); 186 187 if (this->controller_) 188 this->controller_->setControllableEntity(entity); 162 189 163 190 this->changedControllableEntity(); … … 166 193 void PlayerInfo::stopControl() 167 194 { 195 if ( this->oldControllableEntity_ ) 196 this->stopTemporaryControl(); 197 168 198 ControllableEntity* entity = this->controllableEntity_; 169 199 … … 171 201 return; 172 202 203 this->controllableEntity_->setController(0); 173 204 this->controllableEntity_ = 0; 174 205 this->controllableEntityID_ = OBJECTID_UNKNOWN; … … 177 208 this->controller_->setControllableEntity(0); 178 209 179 entity->removePlayer(); 210 if ( GameMode::isMaster() ) 211 entity->removePlayer(); 212 213 this->changedControllableEntity(); 214 } 215 216 void PlayerInfo::stopTemporaryControl() 217 { 218 ControllableEntity* entity = this->controllableEntity_; 219 220 assert( this->controllableEntity_ && this->oldControllableEntity_ ); 221 if( !entity || !this->oldControllableEntity_ ) 222 return; 223 224 this->controllableEntity_ = this->oldControllableEntity_; 225 this->controllableEntityID_ = this->controllableEntity_->getObjectID(); 226 this->oldControllableEntity_ = 0; 227 228 if ( this->controllableEntity_ && this->controller_) 229 this->controller_->setControllableEntity(this->controllableEntity_); 230 231 if ( GameMode::isMaster() ) 232 entity->removePlayer(); 180 233 181 234 this->changedControllableEntity(); … … 196 249 } 197 250 251 198 252 void PlayerInfo::networkcallback_changedgtinfoID() 199 253 {
Note: See TracChangeset
for help on using the changeset viewer.