Changeset 11071 for code/trunk/src/modules/gametypes
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc
r10624 r11071 49 49 50 50 this->setRadarObjectColour(ColourValue::Blue); 51 this->setRadarObjectShape(RadarViewable:: Triangle);51 this->setRadarObjectShape(RadarViewable::Shape::Triangle); 52 52 this->setRadarVisibility(false); 53 53 } -
code/trunk/src/modules/gametypes/OldRaceCheckPoint.h
r9667 r11071 48 48 virtual ~OldRaceCheckPoint(); 49 49 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;51 virtual void tick(float dt) ;50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 51 virtual void tick(float dt) override; 52 52 53 53 protected: 54 virtual void triggered(bool bIsTriggered) ;54 virtual void triggered(bool bIsTriggered) override; 55 55 inline void setLast(bool isLast) 56 56 { this->bIsLast_ = isLast; } … … 64 64 inline float getTimeLimit() 65 65 { return this->bTimeLimit_;} 66 inline const WorldEntity* getWorldEntity() const66 virtual inline const WorldEntity* getWorldEntity() const override 67 67 { return this; } 68 68 -
code/trunk/src/modules/gametypes/OldSpaceRace.h
r9667 r11071 55 55 virtual ~OldSpaceRace() {} 56 56 57 virtual void start() ;58 virtual void end() ;57 virtual void start() override; 58 virtual void end() override; 59 59 60 60 virtual void newCheckpointReached(); 61 virtual void addBots(unsigned int amount) {} //<! overwrite function in order to bypass the addbots command.61 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command. 62 62 //<! This is only a temporary solution. Better: create racingBots. 63 63 -
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
r9973 r11071 53 53 54 54 this->setRadarObjectColour(ColourValue::Blue); 55 this->setRadarObjectShape(RadarViewable:: Triangle);55 this->setRadarObjectShape(RadarViewable::Shape::Triangle); 56 56 this->setRadarVisibility(false); 57 57 this->settingsChanged(); … … 125 125 } 126 126 } 127 return NULL;127 return nullptr; 128 128 } 129 129 … … 146 146 { 147 147 Vector3 checkpoints(-1,-1,-1); int count=0; 148 for ( std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++)148 for (int nextCheckpoint : nextCheckpoints_) 149 149 { 150 150 switch (count) 151 151 { 152 case 0: checkpoints.x = static_cast<Ogre::Real>( *it); break;153 case 1: checkpoints.y = static_cast<Ogre::Real>( *it); break;154 case 2: checkpoints.z = static_cast<Ogre::Real>( *it); break;152 case 0: checkpoints.x = static_cast<Ogre::Real>(nextCheckpoint); break; 153 case 1: checkpoints.y = static_cast<Ogre::Real>(nextCheckpoint); break; 154 case 2: checkpoints.z = static_cast<Ogre::Real>(nextCheckpoint); break; 155 155 } 156 156 ++count; -
code/trunk/src/modules/gametypes/RaceCheckPoint.h
r9971 r11071 48 48 virtual ~RaceCheckPoint(); 49 49 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 51 51 52 52 inline void setCheckpointIndex(int checkpointIndex) … … 92 92 protected: 93 93 94 virtual void fire(bool bIsTriggered, BaseObject* originator) ;94 virtual void fire(bool bIsTriggered, BaseObject* originator) override; 95 95 96 inline const WorldEntity* getWorldEntity() const96 virtual inline const WorldEntity* getWorldEntity() const override 97 97 { 98 98 return this; -
code/trunk/src/modules/gametypes/SpaceRace.cc
r9804 r11071 88 88 this->cantMove_ = true; 89 89 90 for ( ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)91 it->setActive(false);90 for (Engine* engine : ObjectList<Engine>()) 91 engine->setActive(false); 92 92 } 93 93 … … 95 95 if (!this->isStartCountdownRunning() && this->cantMove_) 96 96 { 97 for ( ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)98 it->setActive(true);97 for (Engine* engine : ObjectList<Engine>()) 98 engine->setActive(true); 99 99 100 100 this->cantMove_= false; -
code/trunk/src/modules/gametypes/SpaceRace.h
r9667 r11071 57 57 virtual ~SpaceRace() {} 58 58 59 v oid tick(float dt);59 virtual void tick(float dt) override; 60 60 61 virtual void end() ;61 virtual void end() override; 62 62 63 63 void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player); … … 70 70 { return this->clock_; } 71 71 72 bool allowPawnHit(Pawn* victim, Pawn* originator);73 bool allowPawnDamage(Pawn* victim, Pawn* originator);74 bool allowPawnDeath(Pawn* victim, Pawn* originator);72 virtual bool allowPawnHit(Pawn* victim, Pawn* originator) override; 73 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override; 74 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator) override; 75 75 76 76 private: -
code/trunk/src/modules/gametypes/SpaceRaceController.cc
r10318 r11071 59 59 60 60 virtualCheckPointIndex = -2; 61 if (ObjectList<SpaceRaceManager> ::size() != 1)62 orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager> ::size() << endl;63 for ( ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it != ObjectList<SpaceRaceManager>::end(); ++it)64 { 65 checkpoints = it->getAllCheckpoints();66 nextRaceCheckpoint_ = it->findCheckpoint(0);61 if (ObjectList<SpaceRaceManager>().size() != 1) 62 orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager>().size() << endl; 63 for (SpaceRaceManager* manager : ObjectList<SpaceRaceManager>()) 64 { 65 checkpoints = manager->getAllCheckpoints(); 66 nextRaceCheckpoint_ = manager->findCheckpoint(0); 67 67 } 68 68 … … 98 98 RaceCheckPoint* point2 = findCheckpoint((*numb)); 99 99 100 //if(point2 != NULL)100 //if(point2 != nullptr) 101 101 //placeVirtualCheckpoints((*it), point2); 102 102 } … … 126 126 staticRacePoints_ = findStaticCheckpoints(nextRaceCheckpoint_, checkpoints); 127 127 // initialisation of currentRaceCheckpoint_ 128 currentRaceCheckpoint_ = NULL;128 currentRaceCheckpoint_ = nullptr; 129 129 130 130 int i; 131 for (i = -2; findCheckpoint(i) != NULL; i--)131 for (i = -2; findCheckpoint(i) != nullptr; i--) 132 132 { 133 133 continue; … … 154 154 { 155 155 std::map<RaceCheckPoint*, int> zaehler; // counts how many times the checkpoint was reached (for simulation) 156 for ( unsigned int i = 0; i < allCheckpoints.size(); i++)157 { 158 zaehler.insert(std::pair<RaceCheckPoint*, int>( allCheckpoints[i],0));156 for (RaceCheckPoint* checkpoint : allCheckpoints) 157 { 158 zaehler.insert(std::pair<RaceCheckPoint*, int>(checkpoint,0)); 159 159 } 160 160 int maxWays = rekSimulationCheckpointsReached(currentCheckpoint, zaehler); 161 161 162 162 std::vector<RaceCheckPoint*> returnVec; 163 for ( std::map<RaceCheckPoint*, int>::iterator iter = zaehler.begin(); iter != zaehler.end(); iter++)164 { 165 if ( iter->second == maxWays)166 { 167 returnVec.push_back( iter->first);163 for (const auto& mapEntry : zaehler) 164 { 165 if (mapEntry.second == maxWays) 166 { 167 returnVec.push_back(mapEntry.first); 168 168 } 169 169 } … … 187 187 { 188 188 int numberOfWays = 0; // counts number of ways from this Point to the last point 189 for ( std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it)190 { 191 if (currentCheckpoint == findCheckpoint( *it))189 for (int checkpointIndex : currentCheckpoint->getNextCheckpoints()) 190 { 191 if (currentCheckpoint == findCheckpoint(checkpointIndex)) 192 192 { 193 193 //orxout() << currentCheckpoint->getCheckpointIndex()<<endl; 194 194 continue; 195 195 } 196 if (findCheckpoint( *it) == NULL)197 orxout(internal_warning) << "Problematic Point: " << (*it)<< endl;196 if (findCheckpoint(checkpointIndex) == nullptr) 197 orxout(internal_warning) << "Problematic Point: " << checkpointIndex << endl; 198 198 else 199 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint( *it), zaehler);199 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(checkpointIndex), zaehler); 200 200 } 201 201 zaehler[currentCheckpoint] += numberOfWays; … … 209 209 float SpaceRaceController::distanceSpaceshipToCheckPoint(RaceCheckPoint* CheckPoint) 210 210 { 211 if (this->getControllableEntity() != NULL)211 if (this->getControllableEntity() != nullptr) 212 212 { 213 213 return (CheckPoint->getPosition()- this->getControllableEntity()->getPosition()).length(); … … 223 223 { 224 224 float minDistance = 0; 225 RaceCheckPoint* minNextRaceCheckPoint = NULL;225 RaceCheckPoint* minNextRaceCheckPoint = nullptr; 226 226 227 227 // find the next checkpoint with the minimal distance 228 for ( std::set<int>::iterator it = raceCheckpoint->getNextCheckpoints().begin(); it != raceCheckpoint->getNextCheckpoints().end(); ++it)229 { 230 RaceCheckPoint* nextRaceCheckPoint = findCheckpoint( *it);228 for (int checkpointIndex : raceCheckpoint->getNextCheckpoints()) 229 { 230 RaceCheckPoint* nextRaceCheckPoint = findCheckpoint(checkpointIndex); 231 231 float distance = recCalculateDistance(nextRaceCheckPoint, this->getControllableEntity()->getPosition()); 232 232 233 if (distance < minDistance || minNextRaceCheckPoint == NULL)233 if (distance < minDistance || minNextRaceCheckPoint == nullptr) 234 234 { 235 235 minDistance = distance; … … 255 255 { 256 256 float minimum = std::numeric_limits<float>::max(); 257 for ( std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it != currentCheckPoint->getNextCheckpoints().end(); ++it)257 for (int checkpointIndex : currentCheckPoint->getNextCheckpoints()) 258 258 { 259 259 int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length()); 260 260 261 minimum = std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint( *it), currentCheckPoint->getPosition()));261 minimum = std::min(minimum, dist_currentCheckPoint_currentPosition + recCalculateDistance(findCheckpoint(checkpointIndex), currentCheckPoint->getPosition())); 262 262 // minimum of distanz from 'currentPosition' to the next static Checkpoint 263 263 } … … 271 271 RaceCheckPoint* SpaceRaceController::adjustNextPoint() 272 272 { 273 if (currentRaceCheckpoint_ == NULL) // no Adjust possible273 if (currentRaceCheckpoint_ == nullptr) // no Adjust possible 274 274 275 275 { … … 289 289 RaceCheckPoint* SpaceRaceController::findCheckpoint(int index) const 290 290 { 291 for ( size_t i = 0; i < this->checkpoints_.size(); ++i)292 if ( this->checkpoints_[i]->getCheckpointIndex() == index)293 return this->checkpoints_[i];294 return NULL;291 for (RaceCheckPoint* checkpoint : this->checkpoints_) 292 if (checkpoint->getCheckpointIndex() == index) 293 return checkpoint; 294 return nullptr; 295 295 } 296 296 … … 299 299 orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl; 300 300 RaceCheckPoint* newTempRaceCheckPoint; 301 for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it) 301 ObjectList<SpaceRaceManager> list; 302 for (ObjectList<SpaceRaceManager>::iterator it = list.begin(); it!= list.end(); ++it) 302 303 { 303 304 newTempRaceCheckPoint = new RaceCheckPoint((*it)); … … 347 348 void SpaceRaceController::tick(float dt) 348 349 { 349 if (this->getControllableEntity() == NULL || this->getControllableEntity()->getPlayer() == NULL)350 if (this->getControllableEntity() == nullptr || this->getControllableEntity()->getPlayer() == nullptr ) 350 351 { 351 352 //orxout()<< this->getControllableEntity() << " in tick"<<endl; … … 414 415 btScalar radiusObject; 415 416 416 for ( std::vector<StaticEntity*>::const_iterator it = allObjects.begin(); it != allObjects.end(); ++it)417 { 418 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)419 { 420 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape();421 if(currentShape == NULL)417 for (StaticEntity* object : allObjects) 418 { 419 for (int everyShape=0; object->getAttachedCollisionShape(everyShape) != nullptr; everyShape++) 420 { 421 btCollisionShape* currentShape = object->getAttachedCollisionShape(everyShape)->getCollisionShape(); 422 if(currentShape == nullptr) 422 423 continue; 423 424 … … 444 445 for (std::vector<StaticEntity*>::iterator it = allObjects.begin(); it != allObjects.end(); ++it) 445 446 { 446 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++)447 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != nullptr; everyShape++) 447 448 { 448 449 btCollisionShape* currentShape = (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape(); 449 if(currentShape == NULL)450 if(currentShape == nullptr) 450 451 continue; 451 452 … … 488 489 std::vector<StaticEntity*> problematicObjects; 489 490 490 for (ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); it!= ObjectList<StaticEntity>::end(); ++it) 491 { 492 493 if (dynamic_cast<RaceCheckPoint*>(*it) != NULL) 491 ObjectList<StaticEntity> list; 492 for (ObjectList<StaticEntity>::iterator it = list.begin(); it!= list.end(); ++it) 493 { 494 495 if (dynamic_cast<RaceCheckPoint*>(*it) != nullptr) 494 496 { 495 497 continue; … … 537 539 // btVector3 positionObject; 538 540 // btScalar radiusObject; 539 // if((*it)== NULL)541 // if((*it)==nullptr) 540 542 // { orxout()<<"Problempoint 1.1"<<endl; continue;} 541 543 // //TODO: Probably it points on a wrong object 542 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!= 0; everyShape++)544 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++) 543 545 // { 544 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()== NULL)546 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr) 545 547 // { continue;} 546 548 // … … 570 572 // btVector3 positionObject; 571 573 // btScalar radiusObject; 572 // if((*it)== NULL)574 // if((*it)==nullptr) 573 575 // { orxout()<<"Problempoint 1"<<endl; continue;} 574 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!= 0; everyShape++)576 // for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape)!=nullptr; everyShape++) 575 577 // { 576 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()== NULL)578 // if((*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()==nullptr) 577 579 // { orxout()<<"Problempoint 2.2"<<endl; continue;} 578 580 // (*it)->getAttachedCollisionShape(everyShape)->getCollisionShape()->getBoundingSphere(positionObject,radiusObject); -
code/trunk/src/modules/gametypes/SpaceRaceController.h
r10262 r11071 42 42 SpaceRaceController(Context* context); 43 43 virtual ~SpaceRaceController(); 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;45 virtual void tick(float dt) ;44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 45 virtual void tick(float dt) override; 46 46 47 47 private: -
code/trunk/src/modules/gametypes/SpaceRaceManager.cc
r10624 r11071 54 54 SpaceRaceManager::~SpaceRaceManager() 55 55 { 56 for ( size_t i = 0; i < this->checkpoints_.size(); ++i)57 this->checkpoints_[i]->destroy();56 for (RaceCheckPoint* checkpoint : this->checkpoints_) 57 checkpoint->destroy(); 58 58 } 59 59 … … 71 71 this->players_ = this->race_->getPlayers(); 72 72 73 if (this->checkpoints_[0] != NULL&& !this->firstcheckpointvisible_)73 if (this->checkpoints_[0] != nullptr && !this->firstcheckpointvisible_) 74 74 { 75 75 this->checkpoints_[0]->setRadarVisibility(true); … … 77 77 } 78 78 79 for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)79 for (const auto& mapEntry : players_) 80 80 { 81 81 82 for ( size_t i = 0; i < this->checkpoints_.size(); ++i)82 for (RaceCheckPoint* checkpoint : this->checkpoints_) 83 83 { 84 if ( this->checkpoints_[i]->playerWasHere(it->first)){85 this->checkpointReached( this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);84 if (checkpoint->playerWasHere(mapEntry.first)){ 85 this->checkpointReached(checkpoint, mapEntry.first /*this->checkpoints_[i]->getPlayer()*/); 86 86 } 87 87 } … … 100 100 return this->checkpoints_[index]; 101 101 else 102 return 0;102 return nullptr; 103 103 } 104 104 … … 113 113 RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const 114 114 { 115 for ( size_t i = 0; i < this->checkpoints_.size(); ++i)116 if ( this->checkpoints_[i]->getCheckpointIndex() == index)117 return this->checkpoints_[i];118 return 0;115 for (RaceCheckPoint* checkpoint : this->checkpoints_) 116 if (checkpoint->getCheckpointIndex() == index) 117 return checkpoint; 118 return nullptr; 119 119 } 120 120 121 121 bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const 122 122 { 123 if (oldCheckpoint != NULL)123 if (oldCheckpoint != nullptr) 124 124 { 125 125 // the player already visited an old checkpoint; see which checkpoints are possible now 126 126 const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints(); 127 for ( std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)128 if (this->findCheckpoint( *it) == newCheckpoint)127 for (int possibleCheckpoint : possibleCheckpoints) 128 if (this->findCheckpoint(possibleCheckpoint) == newCheckpoint) 129 129 return true; 130 130 return false; … … 179 179 { 180 180 const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints(); 181 for ( std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)182 this->findCheckpoint( *it)->setRadarVisibility(false);181 for (int checkpointIndex : oldVisible) 182 this->findCheckpoint(checkpointIndex)->setRadarVisibility(false); 183 183 } 184 184 … … 188 188 189 189 const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints(); 190 for ( std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)191 this->findCheckpoint( *it)->setRadarVisibility(true);190 for (int checkpointIndex : newVisible) 191 this->findCheckpoint(checkpointIndex)->setRadarVisibility(true); 192 192 } 193 193 } -
code/trunk/src/modules/gametypes/SpaceRaceManager.h
r9667 r11071 58 58 virtual ~SpaceRaceManager() ; 59 59 60 v oid XMLPort(Element& xmlelement, XMLPort::Mode mode);60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 61 61 62 62 void addCheckpoint(RaceCheckPoint* checkpoint); … … 69 69 std::vector<RaceCheckPoint*> getAllCheckpoints(); 70 70 71 v oid tick(float dt);71 virtual void tick(float dt) override; 72 72 73 73 protected:
Note: See TracChangeset
for help on using the changeset viewer.