Changeset 10624 for code/trunk/src/orxonox/gametypes
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r9945 r10624 310 310 if (spaceship) 311 311 { 312 WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);313 if(ptr == NULL)314 return;315 312 spaceship->addSpeedFactor(5); 316 313 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 317 executor->setDefaultValue(0, ptr);314 executor->setDefaultValue(0, spaceship); 318 315 new Timer(10, false, executor, true); 319 316 } … … 593 590 } 594 591 595 void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function 596 { 597 if (*ptr) 598 { 599 (*ptr)->addSpeedFactor(1.0f/5.0f); 600 } 601 delete ptr; 592 void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship)// helper function 593 { 594 if (spaceship) 595 { 596 spaceship->addSpeedFactor(1.0f/5.0f); 597 } 602 598 } 603 599 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r9676 r10624 77 77 virtual void rewardPig(); 78 78 void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost. 79 void resetSpeedFactor( WeakPtr<SpaceShip>* ptr);79 void resetSpeedFactor(SpaceShip* spaceship); 80 80 void tick (float dt);// used to end the game 81 81 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/trunk/src/orxonox/gametypes/Gametype.cc
r10281 r10624 34 34 #include "core/config/ConfigValueIncludes.h" 35 35 #include "core/GameMode.h" 36 #include "core/command/ConsoleCommand .h"36 #include "core/command/ConsoleCommandIncludes.h" 37 37 #include "gamestates/GSLevel.h" 38 38 … … 49 49 namespace orxonox 50 50 { 51 static const std::string __CC_addBots_name = "addBots"; 52 static const std::string __CC_killBots_name = "killBots"; 53 54 SetConsoleCommand("Gametype", __CC_addBots_name, &Gametype::addBots ).addShortcut().defaultValues(1); 55 SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0); 56 51 57 RegisterUnloadableClass(Gametype); 52 58 … … 55 61 RegisterObject(Gametype); 56 62 63 this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency) 64 57 65 this->gtinfo_ = new GametypeInfo(context); 58 66 59 this->setGametype(SmartPtr<Gametype>(this, false));60 61 67 this->defaultControllableEntity_ = Class(Spectator); 68 this->scoreboard_ = 0; 62 69 63 70 this->bAutoStart_ = false; … … 74 81 this->setConfigValues(); 75 82 83 ModifyConsoleCommand(__CC_addBots_name).setObject(this); 84 ModifyConsoleCommand(__CC_killBots_name).setObject(this); 85 } 86 87 Gametype::~Gametype() 88 { 89 if (this->isInitialized()) 90 { 91 if (this->gtinfo_) 92 this->gtinfo_->destroy(); 93 94 ModifyConsoleCommand(__CC_addBots_name).setObject(NULL); 95 ModifyConsoleCommand(__CC_killBots_name).setObject(NULL); 96 } 97 } 98 99 /** 100 * @brief Initializes sub-objects of the Gametype. This must be called after the constructor. 101 * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor. 102 */ 103 void Gametype::init() 104 { 76 105 // load the corresponding score board 77 106 if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty()) 78 107 { 79 this->scoreboard_ = new OverlayGroup( context);108 this->scoreboard_ = new OverlayGroup(this->getContext()); 80 109 this->scoreboard_->addTemplate(this->scoreboardTemplate_); 81 this->scoreboard_->setGametype(this);82 }83 else84 this->scoreboard_ = 0;85 86 /* HACK HACK HACK */87 this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );88 this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );89 /* HACK HACK HACK */90 }91 92 Gametype::~Gametype()93 {94 if (this->isInitialized())95 {96 this->gtinfo_->destroy();97 if( this->dedicatedAddBots_ )98 delete this->dedicatedAddBots_;99 if( this->dedicatedKillBots_ )100 delete this->dedicatedKillBots_;101 110 } 102 111 } … … 406 415 { 407 416 // If in developer's mode, there is no start countdown. 408 if(Core::getInstance(). inDevMode())417 if(Core::getInstance().getConfig()->inDevMode()) 409 418 this->start(); 410 419 else -
code/trunk/src/orxonox/gametypes/Gametype.h
r10281 r10624 72 72 virtual ~Gametype(); 73 73 74 virtual void init(); 75 74 76 void setConfigValues(); 75 77 … … 176 178 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states); 177 179 178 SmartPtr<GametypeInfo> gtinfo_;180 WeakPtr<GametypeInfo> gtinfo_; 179 181 180 182 bool bAutoStart_; … … 199 201 std::string scoreboardTemplate_; 200 202 201 /* HACK HACK HACK */202 ConsoleCommand* dedicatedAddBots_;203 ConsoleCommand* dedicatedKillBots_;204 /* HACK HACK HACK */205 203 Timer showMenuTimer_; 206 204 }; -
code/trunk/src/orxonox/gametypes/Mission.cc
r10258 r10624 33 33 34 34 #include "core/CoreIncludes.h" 35 #include "core/command/ConsoleCommand .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 36 #include "infos/PlayerInfo.h" 37 37 #include "network/Host.h"
Note: See TracChangeset
for help on using the changeset viewer.