Changeset 5806
- Timestamp:
- Sep 27, 2009, 4:13:13 AM (15 years ago)
- Location:
- code/branches/core5/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/BaseObject.h
r5805 r5806 138 138 inline const SmartPtr<Scene>& getScene() const { return this->scene_; } 139 139 140 inline void setGametype( Gametype*gametype)140 inline void setGametype(const SmartPtr<Gametype>& gametype) 141 141 { 142 142 if (gametype != this->gametype_) … … 147 147 } 148 148 } 149 inline Gametype*getGametype() const { return this->gametype_; }149 inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; } 150 150 inline Gametype* getOldGametype() const { return this->oldGametype_; } 151 151 virtual void changedGametype() {} … … 196 196 BaseObject* creator_; 197 197 SmartPtr<Scene> scene_; 198 Gametype*gametype_;198 SmartPtr<Gametype> gametype_; 199 199 Gametype* oldGametype_; 200 200 std::set<Template*> templates_; -
code/branches/core5/src/modules/gamestates/GSLevel.cc
r5805 r5806 52 52 #include "LevelManager.h" 53 53 #include "PlayerManager.h" 54 #include "infos/HumanPlayer.h" 54 55 55 56 namespace orxonox … … 242 243 void GSLevel::unloadLevel() 243 244 { 245 for (ObjectList<HumanPlayer>::iterator it = ObjectList<HumanPlayer>::begin(); it; ++it) 246 it->setGametype(0); 247 244 248 Loader::unload(startFile_s); 245 249 -
code/branches/core5/src/modules/objects/triggers/CheckPoint.cc
r5738 r5806 85 85 DistanceTrigger::triggered(bIsTriggered); 86 86 87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype() );87 Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get()); 88 88 if (gametype) 89 89 { -
code/branches/core5/src/modules/overlays/hud/TeamBaseMatchScore.cc
r5738 r5806 118 118 119 119 if (this->getOwner() && this->getOwner()->getGametype()) 120 this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype() );120 this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get()); 121 121 else 122 122 this->owner_ = 0; -
code/branches/core5/src/modules/overlays/hud/UnderAttackHealthBar.cc
r5800 r5806 78 78 this->owner_ = player; 79 79 80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype() );80 UnderAttack* ua = orxonox_cast<UnderAttack*>(player->getGametype().get()); 81 81 if (ua) 82 82 { -
code/branches/core5/src/modules/pong/Pong.cc
r5800 r5806 158 158 159 159 if (player) 160 this->gtinfo_ .sendAnnounceMessage(player->getName() + " scored");160 this->gtinfo_->sendAnnounceMessage(player->getName() + " scored"); 161 161 } 162 162 -
code/branches/core5/src/modules/pong/PongCenterpoint.cc
r5738 r5806 73 73 if (this->getGametype() && this->getGametype()->isA(Class(Pong))) 74 74 { 75 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype() );75 Pong* pong_gametype = orxonox_cast<Pong*>(this->getGametype().get()); 76 76 pong_gametype->setCenterpoint(this); 77 77 } -
code/branches/core5/src/modules/pong/PongScore.cc
r5738 r5806 133 133 134 134 if (this->getOwner() && this->getOwner()->getGametype()) 135 this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype() );135 this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get()); 136 136 else 137 137 this->owner_ = 0; -
code/branches/core5/src/orxonox/gametypes/Asteroids.cc
r5738 r5806 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/branches/core5/src/orxonox/gametypes/Gametype.cc
r5801 r5806 47 47 CreateUnloadableFactory(Gametype); 48 48 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) , gtinfo_(creator)49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 50 50 { 51 51 RegisterObject(Gametype); 52 53 this->setGametype(this); 52 53 this->gtinfo_ = new GametypeInfo(creator); 54 55 this->setGametype(SmartPtr<Gametype>(this, false)); 54 56 55 57 this->defaultControllableEntity_ = Class(Spectator); … … 76 78 else 77 79 this->scoreboard_ = 0; 80 } 81 82 Gametype::~Gametype() 83 { 84 if (this->isInitialized()) 85 this->gtinfo_->destroy(); 78 86 } 79 87 … … 100 108 } 101 109 102 if (this->gtinfo_ .bStartCountdownRunning_ && !this->gtinfo_.bStarted_)103 this->gtinfo_ .startCountdown_ -= dt;104 105 if (!this->gtinfo_ .bStarted_)110 if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_) 111 this->gtinfo_->startCountdown_ -= dt; 112 113 if (!this->gtinfo_->bStarted_) 106 114 this->checkStart(); 107 else if (!this->gtinfo_ .bEnded_)115 else if (!this->gtinfo_->bEnded_) 108 116 this->spawnDeadPlayersIfRequested(); 109 117 … … 115 123 this->addBots(this->numberOfBots_); 116 124 117 this->gtinfo_ .bStarted_ = true;125 this->gtinfo_->bStarted_ = true; 118 126 119 127 this->spawnPlayersIfRequested(); … … 122 130 void Gametype::end() 123 131 { 124 this->gtinfo_ .bEnded_ = true;132 this->gtinfo_->bEnded_ = true; 125 133 126 134 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 243 251 244 252 if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 245 this->gtinfo_ .sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());253 this->gtinfo_->sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID()); 246 254 if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN) 247 this->gtinfo_ .sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());255 this->gtinfo_->sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID()); 248 256 } 249 257 } … … 308 316 it->second.state_ = PlayerState::Dead; 309 317 310 if (!it->first->isReadyToSpawn() || !this->gtinfo_ .bStarted_)318 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_) 311 319 { 312 320 this->spawnPlayerAsDefaultPawn(it->first); … … 319 327 void Gametype::checkStart() 320 328 { 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;329 if (!this->gtinfo_->bStarted_) 330 { 331 if (this->gtinfo_->bStartCountdownRunning_) 332 { 333 if (this->gtinfo_->startCountdown_ <= 0) 334 { 335 this->gtinfo_->bStartCountdownRunning_ = false; 336 this->gtinfo_->startCountdown_ = 0; 329 337 this->start(); 330 338 } … … 349 357 if (allplayersready && hashumanplayers) 350 358 { 351 this->gtinfo_ .startCountdown_ = this->initialStartCountdown_;352 this->gtinfo_ .bStartCountdownRunning_ = true;359 this->gtinfo_->startCountdown_ = this->initialStartCountdown_; 360 this->gtinfo_->bStartCountdownRunning_ = true; 353 361 } 354 362 } -
code/branches/core5/src/orxonox/gametypes/Gametype.h
r5776 r5806 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_; -
code/branches/core5/src/orxonox/gametypes/TeamBaseMatch.cc
r5738 r5806 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/branches/core5/src/orxonox/gametypes/UnderAttack.cc
r5738 r5806 81 81 82 82 if (it->second == 0) 83 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());83 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 84 84 else 85 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());85 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 86 86 } 87 87 } … … 164 164 165 165 if (it->second == 1) 166 this->gtinfo_ .sendAnnounceMessage("You have won the match!", it->first->getClientID());166 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID()); 167 167 else 168 this->gtinfo_ .sendAnnounceMessage("You have lost the match!", it->first->getClientID());168 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID()); 169 169 } 170 170 } … … 178 178 Host::Broadcast(message); 179 179 */ 180 this->gtinfo_ .sendAnnounceMessage(message);180 this->gtinfo_->sendAnnounceMessage(message); 181 181 182 182 if (timesequence_ >= 30 && timesequence_ <= 60) -
code/branches/core5/src/orxonox/infos/HumanPlayer.cc
r5801 r5806 162 162 163 163 if (this->isInitialized() && this->isLocalPlayer()) 164 if (this->getGametype()->getHUDTemplate() != "") 164 { 165 if (this->getGametype() && this->getGametype()->getHUDTemplate() != "") 165 166 this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate()); 167 else 168 this->setGametypeHUDTemplate(""); 169 } 166 170 } 167 171 -
code/branches/core5/src/orxonox/worldentities/pawns/Destroyer.cc
r5738 r5806 40 40 RegisterObject(Destroyer); 41 41 42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype() );42 UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get()); 43 43 if (gametype) 44 44 { -
code/branches/core5/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r5738 r5806 45 45 this->state_ = BaseState::Uncontrolled; 46 46 47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype() );47 TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get()); 48 48 if (gametype) 49 49 { … … 58 58 this->fireEvent(); 59 59 60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype() );60 TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get()); 61 61 if (!gametype) 62 62 return;
Note: See TracChangeset
for help on using the changeset viewer.