Changeset 11032
- Timestamp:
- Jan 4, 2016, 12:07:42 AM (9 years ago)
- Location:
- code/branches/presentationHS15/src/orxonox/gametypes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS15/src/orxonox/gametypes/Dynamicmatch.cc
r10624 r11032 86 86 } 87 87 88 Dynamicmatch::~Dynamicmatch() 89 { 90 for (std::set<Timer*>::iterator it = this->piggyTimers_.begin(); it != this->piggyTimers_.end(); ++it) 91 delete (*it); 92 } 93 88 94 void Dynamicmatch::setConfigValues() 89 95 { … … 312 318 spaceship->addSpeedFactor(5); 313 319 ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this)); 314 executor->setDefaultValue(0, spaceship); 315 new Timer(10, false, executor, true); 320 Timer* timer = new Timer(10, false, executor); 321 executor->setDefaultValue(0, spaceship); // TODO: use WeakPtr because spaceship can be destroyed in the meantime 322 executor->setDefaultValue(1, timer); 323 this->piggyTimers_.insert(timer); 316 324 } 317 325 } … … 590 598 } 591 599 592 void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship )// helper function600 void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship, Timer* timer)// helper function 593 601 { 594 602 if (spaceship) … … 596 604 spaceship->addSpeedFactor(1.0f/5.0f); 597 605 } 606 607 this->piggyTimers_.erase(timer); 608 delete timer; 598 609 } 599 610 -
code/branches/presentationHS15/src/orxonox/gametypes/Dynamicmatch.h
r10624 r11032 33 33 34 34 #include <map> 35 #include <set> 35 36 #include <vector> 36 37 … … 45 46 public: 46 47 Dynamicmatch(Context* context); 47 virtual ~Dynamicmatch() {}48 virtual ~Dynamicmatch(); 48 49 49 50 bool notEnoughPigs; … … 77 78 virtual void rewardPig(); 78 79 void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost. 79 void resetSpeedFactor(SpaceShip* spaceship );80 void resetSpeedFactor(SpaceShip* spaceship, Timer* timer); 80 81 void tick (float dt);// used to end the game 81 82 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; … … 88 89 std::map< PlayerInfo*, int > playerParty_; //player's parties are recorded here 89 90 std::vector<ColourValue> partyColours_; //aus TeamDeathmatch 91 std::set<Timer*> piggyTimers_; 90 92 unsigned int numberOf[3]; //array to count number of chasers, pigs, killers 91 93 float pointsPerTime;
Note: See TracChangeset
for help on using the changeset viewer.