Changeset 8706 for code/trunk/src/orxonox/gametypes/Gametype.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/gametypes/Gametype.cc
r8327 r8706 121 121 } 122 122 123 if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_) 124 this->gtinfo_->startCountdown_ -= dt; 125 126 if (!this->gtinfo_->bStarted_) 123 if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted()) 124 this->gtinfo_->countdownStartCountdown(dt); 125 126 if (!this->gtinfo_->hasStarted()) 127 { 128 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 129 { 130 // Inform the GametypeInfo that the player is ready to spawn. 131 if(it->first->isHumanPlayer() && it->first->isReadyToSpawn()) 132 this->gtinfo_->playerReadyToSpawn(it->first); 133 } 134 127 135 this->checkStart(); 128 else if (!this->gtinfo_->bEnded_) 136 } 137 else if (!this->gtinfo_->hasEnded()) 129 138 this->spawnDeadPlayersIfRequested(); 130 139 … … 136 145 this->addBots(this->numberOfBots_); 137 146 138 this->gtinfo_-> bStarted_ = true;147 this->gtinfo_->start(); 139 148 140 149 this->spawnPlayersIfRequested(); … … 143 152 void Gametype::end() 144 153 { 145 this->gtinfo_-> bEnded_ = true;154 this->gtinfo_->end(); 146 155 147 156 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 173 182 { 174 183 this->players_[player].state_ = PlayerState::Joined; 184 this->gtinfo_->playerEntered(player); 175 185 } 176 186 … … 270 280 } 271 281 282 if(victim->getPlayer()->isHumanPlayer()) 283 this->gtinfo_->pawnKilled(victim->getPlayer()); 284 272 285 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); 273 286 if (victim->getCamera()) … … 306 319 SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const 307 320 { 321 // If there is at least one SpawnPoint. 308 322 if (this->spawnpoints_.size() > 0) 309 323 { 324 // Fallback spawn point if there is no active one, choose a random one. 310 325 SpawnPoint* fallbackSpawnPoint = NULL; 311 326 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 312 327 unsigned int index = 0; 313 std:: set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;328 std::vector<SpawnPoint*> activeSpawnPoints; 314 329 for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it) 315 330 { … … 317 332 fallbackSpawnPoint = (*it); 318 333 319 if ( !(*it)->isActive())320 activeSpawnPoints. erase(*it);334 if (*it != NULL && (*it)->isActive()) 335 activeSpawnPoints.push_back(*it); 321 336 322 337 ++index; 323 338 } 324 339 325 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 326 index = 0; 327 for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it) 328 { 329 if (index == randomspawn) 330 return (*it); 331 332 ++index; 333 } 334 340 if(activeSpawnPoints.size() > 0) 341 { 342 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size()))); 343 return activeSpawnPoints[randomspawn]; 344 } 345 346 COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl; 335 347 return fallbackSpawnPoint; 336 348 } … … 346 358 it->second.state_ = PlayerState::Dead; 347 359 348 if (!it->first->isReadyToSpawn() || !this->gtinfo_-> bStarted_)360 if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted()) 349 361 { 350 362 this->spawnPlayerAsDefaultPawn(it->first); … … 357 369 void Gametype::checkStart() 358 370 { 359 if (!this->gtinfo_-> bStarted_)360 { 361 if (this->gtinfo_-> bStartCountdownRunning_)362 { 363 if (this->gtinfo_-> startCountdown_ <= 0)364 { 365 this->gtinfo_-> bStartCountdownRunning_ = false;366 this->gtinfo_->s tartCountdown_ = 0;371 if (!this->gtinfo_->hasStarted()) 372 { 373 if (this->gtinfo_->isStartCountdownRunning()) 374 { 375 if (this->gtinfo_->getStartCountdown() <= 0.0f) 376 { 377 this->gtinfo_->stopStartCountdown(); 378 this->gtinfo_->setStartCountdown(0.0f);; 367 379 this->start(); 368 380 } … … 389 401 // If in developer's mode, there is no start countdown. 390 402 if(Core::getInstance().inDevMode()) 391 this-> gtinfo_->startCountdown_ = 0;403 this->start(); 392 404 else 393 this->gtinfo_->s tartCountdown_ = this->initialStartCountdown_;394 this->gtinfo_-> bStartCountdownRunning_ = true;405 this->gtinfo_->setStartCountdown(this->initialStartCountdown_); 406 this->gtinfo_->startStartCountdown(); 395 407 } 396 408 } … … 402 414 { 403 415 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 416 { 404 417 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 405 418 this->spawnPlayer(it->first); 419 } 406 420 } 407 421 … … 422 436 player->startControl(spawnpoint->spawn()); 423 437 this->players_[player].state_ = PlayerState::Alive; 438 439 if(player->isHumanPlayer()) 440 this->gtinfo_->playerSpawned(player); 441 424 442 this->playerPostSpawn(player); 425 443 }
Note: See TracChangeset
for help on using the changeset viewer.