Changeset 5929 for code/trunk/src/orxonox/gametypes
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 9 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/Asteroids.cc
r5781 r5929 54 54 if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_) 55 55 { 56 this->gtinfo_ .sendAnnounceMessage("Time's up - you have lost the match!");56 this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!"); 57 57 this->end(); 58 58 } … … 63 63 if (victim && victim->getPlayer()) 64 64 { 65 this->gtinfo_ .sendAnnounceMessage("You're dead - you have lost the match!");65 this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!"); 66 66 this->end(); 67 67 } -
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 } -
code/trunk/src/orxonox/gametypes/Gametype.h
r5781 r5929 37 37 38 38 #include "core/BaseObject.h" 39 #include "core/ Identifier.h"39 #include "core/SubclassIdentifier.h" 40 40 #include "tools/interfaces/Tickable.h" 41 41 #include "infos/GametypeInfo.h" … … 68 68 public: 69 69 Gametype(BaseObject* creator); 70 virtual ~Gametype() {}70 virtual ~Gametype(); 71 71 72 72 void setConfigValues(); … … 75 75 76 76 inline const GametypeInfo* getGametypeInfo() const 77 { return &this->gtinfo_; }77 { return this->gtinfo_; } 78 78 79 79 inline bool hasStarted() const 80 { return this->gtinfo_ .bStarted_; }80 { return this->gtinfo_->bStarted_; } 81 81 inline bool hasEnded() const 82 { return this->gtinfo_ .bEnded_; }82 { return this->gtinfo_->bEnded_; } 83 83 84 84 virtual void start(); … … 114 114 115 115 inline bool isStartCountdownRunning() const 116 { return this->gtinfo_ .bStartCountdownRunning_; }116 { return this->gtinfo_->bStartCountdownRunning_; } 117 117 inline float getStartCountdown() const 118 { return this->gtinfo_ .startCountdown_; }118 { return this->gtinfo_->startCountdown_; } 119 119 120 120 inline void setHUDTemplate(const std::string& name) 121 { this->gtinfo_ .hudtemplate_ = name; }121 { this->gtinfo_->hudtemplate_ = name; } 122 122 inline const std::string& getHUDTemplate() const 123 { return this->gtinfo_ .hudtemplate_; }123 { return this->gtinfo_->hudtemplate_; } 124 124 125 125 void addBots(unsigned int amount); … … 163 163 virtual void spawnDeadPlayersIfRequested(); 164 164 165 GametypeInfogtinfo_;165 SmartPtr<GametypeInfo> gtinfo_; 166 166 167 167 bool bAutoStart_; … … 184 184 // Config Values 185 185 std::string scoreboardTemplate_; 186 187 /* HACK HACK HACK */ 188 ConsoleCommand* hackAddBots_; 189 ConsoleCommand* hackKillBots_; 190 /* HACK HACK HACK */ 186 191 }; 187 192 } -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
r5781 r5929 42 42 RegisterObject(TeamBaseMatch); 43 43 44 this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));45 this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));44 this->scoreTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::winPoints, this))); 45 this->outputTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::showPoints, this))); 46 46 47 47 this->pointsTeam1_ = 0; … … 67 67 { 68 68 base->setState(BaseState::ControlTeam1); 69 this->gtinfo_ .sendAnnounceMessage("The red team captured a base");69 this->gtinfo_->sendAnnounceMessage("The red team captured a base"); 70 70 } 71 71 if (teamnr == 1) 72 72 { 73 73 base->setState(BaseState::ControlTeam2); 74 this->gtinfo_ .sendAnnounceMessage("The blue team captured a base");74 this->gtinfo_->sendAnnounceMessage("The blue team captured a base"); 75 75 } 76 76 } … … 194 194 195 195 if (it->second == winningteam) 196 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());196 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 197 197 else 198 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());198 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 199 199 } 200 200 -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.h
r5781 r5929 65 65 66 66 std::set<TeamBaseMatchBase*> bases_; 67 Timer <TeamBaseMatch>scoreTimer_;68 Timer <TeamBaseMatch>outputTimer_;67 Timer scoreTimer_; 68 Timer outputTimer_; 69 69 70 70 //points for each team -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r5781 r5929 93 93 94 94 if (valid_player) 95 this-> players_.erase(player);95 this->teamnumbers_.erase(player); 96 96 97 97 return valid_player; … … 100 100 bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator) 101 101 { 102 return (!this->pawnsAreInTheSameTeam(victim, originator) );102 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 103 103 } 104 104 105 105 bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator) 106 106 { 107 return (!this->pawnsAreInTheSameTeam(victim, originator) );107 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 108 108 } 109 109 110 110 bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator) 111 111 { 112 return (!this->pawnsAreInTheSameTeam(victim, originator) );112 return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator); 113 113 } 114 114 -
code/trunk/src/orxonox/gametypes/UnderAttack.cc
r5781 r5929 46 46 this->teams_ = 2; 47 47 this->destroyer_ = 0; 48 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 48 49 this->gameEnded_ = false; 49 50 … … 65 66 66 67 67 void UnderAttack:: destroyedPawn(Pawn* pawn)68 void UnderAttack::killedDestroyer() 68 69 { 69 if (pawn == this->destroyer_) 70 this->end(); //end gametype 71 std::string message = "Ship destroyed! Team 0 has won!"; 72 COUT(0) << message << std::endl; 73 Host::Broadcast(message); 74 this->gameEnded_ = true; 75 76 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 70 77 { 71 this->end(); //end gametype 72 std::string message = "Ship destroyed! Team 0 has won!"; 73 COUT(0) << message << std::endl; 74 Host::Broadcast(message); 75 this->gameEnded_ = true; 78 if (it->first->getClientID() == CLIENTID_UNKNOWN) 79 continue; 76 80 77 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 78 { 79 if (it->first->getClientID() == CLIENTID_UNKNOWN) 80 continue; 81 82 if (it->second == 0) 83 this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID()); 84 else 85 this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 86 } 81 if (it->second == 0) 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 83 else 84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 87 85 } 88 86 } … … 164 162 165 163 if (it->second == 1) 166 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());164 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 167 165 else 168 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());166 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 169 167 } 170 168 } … … 178 176 Host::Broadcast(message); 179 177 */ 180 this->gtinfo_ .sendAnnounceMessage(message);178 this->gtinfo_->sendAnnounceMessage(message); 181 179 182 180 if (timesequence_ >= 30 && timesequence_ <= 60) -
code/trunk/src/orxonox/gametypes/UnderAttack.h
r5781 r5929 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "interfaces/PawnListener.h"35 34 #include "TeamDeathmatch.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport UnderAttack : public TeamDeathmatch , public PawnListener38 class _OrxonoxExport UnderAttack : public TeamDeathmatch 40 39 { 41 40 public: … … 54 53 55 54 protected: 56 virtual void destroyedPawn(Pawn* pawn);55 virtual void killedDestroyer(); 57 56 58 Destroyer*destroyer_;57 WeakPtr<Destroyer> destroyer_; 59 58 unsigned int teams_; 60 59 float gameTime_;
Note: See TracChangeset
for help on using the changeset viewer.