Changeset 5929 for code/trunk/src/orxonox/gametypes/Gametype.cc
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gametypes/Gametype.cc
r5781 r5929 33 33 #include "core/ConfigValueIncludes.h" 34 34 #include "core/GameMode.h" 35 #include "core/ConsoleCommand.h" 35 36 36 37 #include "infos/PlayerInfo.h" … … 47 48 CreateUnloadableFactory(Gametype); 48 49 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) , gtinfo_(creator)50 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 50 51 { 51 52 RegisterObject(Gametype); 52 53 this->setGametype(this); 53 54 this->gtinfo_ = new GametypeInfo(creator); 55 56 this->setGametype(SmartPtr<Gametype>(this, false)); 54 57 55 58 this->defaultControllableEntity_ = Class(Spectator); … … 76 79 else 77 80 this->scoreboard_ = 0; 81 82 /* HACK HACK HACK */ 83 this->hackAddBots_ = createConsoleCommand( createFunctor(&Gametype::addBots, this), "hackAddBots"); 84 this->hackKillBots_ = createConsoleCommand( createFunctor(&Gametype::killBots, this), "hackKillBots"); 85 CommandExecutor::addConsoleCommandShortcut( this->hackAddBots_ ); 86 CommandExecutor::addConsoleCommandShortcut( this->hackKillBots_ ); 87 /* HACK HACK HACK */ 88 } 89 90 Gametype::~Gametype() 91 { 92 if (this->isInitialized()) 93 { 94 this->gtinfo_->destroy(); 95 if( this->hackAddBots_ ) 96 delete this->hackAddBots_; 97 if( this->hackKillBots_ ) 98 delete this->hackKillBots_; 99 } 78 100 } 79 101 … … 100 122 } 101 123 102 if (this->gtinfo_ .bStartCountdownRunning_ && !this->gtinfo_.bStarted_)103 this->gtinfo_ .startCountdown_ -= dt;104 105 if (!this->gtinfo_ .bStarted_)124 if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_) 125 this->gtinfo_->startCountdown_ -= dt; 126 127 if (!this->gtinfo_->bStarted_) 106 128 this->checkStart(); 107 else if (!this->gtinfo_ .bEnded_)129 else if (!this->gtinfo_->bEnded_) 108 130 this->spawnDeadPlayersIfRequested(); 109 131 … … 115 137 this->addBots(this->numberOfBots_); 116 138 117 this->gtinfo_ .bStarted_ = true;139 this->gtinfo_->bStarted_ = true; 118 140 119 141 this->spawnPlayersIfRequested(); … … 122 144 void Gametype::end() 123 145 { 124 this->gtinfo_ .bEnded_ = true;146 this->gtinfo_->bEnded_ = true; 125 147 126 148 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 130 152 ControllableEntity* oldentity = it->first->getControllableEntity(); 131 153 132 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity ->getCreator());154 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity); 133 155 if (oldentity->getCamera()) 134 156 { … … 243 265 244 266 if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 245 this->gtinfo_ .sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());267 this->gtinfo_->sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID()); 246 268 if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 247 this->gtinfo_ .sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());269 this->gtinfo_->sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID()); 248 270 } 249 271 } … … 308 330 it->second.state_ = PlayerState::Dead; 309 331 310 if (!it->first->isReadyToSpawn() || !this->gtinfo_ .bStarted_)332 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_) 311 333 { 312 334 this->spawnPlayerAsDefaultPawn(it->first); … … 319 341 void Gametype::checkStart() 320 342 { 321 if (!this->gtinfo_ .bStarted_)322 { 323 if (this->gtinfo_ .bStartCountdownRunning_)324 { 325 if (this->gtinfo_ .startCountdown_ <= 0)326 { 327 this->gtinfo_ .bStartCountdownRunning_ = false;328 this->gtinfo_ .startCountdown_ = 0;343 if (!this->gtinfo_->bStarted_) 344 { 345 if (this->gtinfo_->bStartCountdownRunning_) 346 { 347 if (this->gtinfo_->startCountdown_ <= 0) 348 { 349 this->gtinfo_->bStartCountdownRunning_ = false; 350 this->gtinfo_->startCountdown_ = 0; 329 351 this->start(); 330 352 } … … 349 371 if (allplayersready && hashumanplayers) 350 372 { 351 this->gtinfo_ .startCountdown_ = this->initialStartCountdown_;352 this->gtinfo_ .bStartCountdownRunning_ = true;373 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 374 this->gtinfo_->bStartCountdownRunning_ = true; 353 375 } 354 376 } … … 419 441 if (it->getGametype() == this) 420 442 { 421 delete (*(it++));443 (it++)->destroy(); 422 444 ++i; 423 445 } 446 else 447 ++it; 424 448 } 425 449 }
Note: See TracChangeset
for help on using the changeset viewer.