Changeset 9973 for code/trunk/src
- Timestamp:
- Jan 4, 2014, 2:56:03 PM (11 years ago)
- Location:
- code/trunk/src/modules/gametypes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
r9967 r9973 105 105 this->nextCheckpoints_.clear(); 106 106 107 if (checkpoints.x > - 1)108 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly109 if (checkpoints.y > - 1)110 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));111 if (checkpoints.z > - 1)112 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));107 if (checkpoints.x > -0.5) 108 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly 109 if (checkpoints.y > -0.5) 110 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5)); 111 if (checkpoints.z > -0.5) 112 this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5)); 113 113 } 114 114 … … 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 (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ ) 149 { 149 150 switch (count) 150 151 152 153 154 155 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; 155 } 156 ++count; 156 157 } 157 158 return checkpoints; -
code/trunk/src/modules/gametypes/SpaceRaceController.cc
r9967 r9973 55 55 ArtificialController(context) 56 56 { 57 RegisterObject(SpaceRaceController) 58 ;std::vector<RaceCheckPoint*> checkpoints;57 RegisterObject(SpaceRaceController); 58 std::vector<RaceCheckPoint*> checkpoints; 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; 61 63 for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it != ObjectList<SpaceRaceManager>::end(); ++it) 62 64 { … … 122 124 }//ausgabe 123 125 orxout()<<"es gibt: "<<checkpoints_.size()<<"checkpoints"<<endl;*/ 124 staticRacePoints_ = findStaticCheckpoints( checkpoints);126 staticRacePoints_ = findStaticCheckpoints(nextRaceCheckpoint_, checkpoints); 125 127 // initialisation of currentRaceCheckpoint_ 126 128 currentRaceCheckpoint_ = NULL; … … 149 151 * returns a vector of static Point (checkpoints the spaceship has to reach) 150 152 */ 151 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints( const std::vector<RaceCheckPoint*>& allCheckpoints)153 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(RaceCheckPoint* currentCheckpoint, const std::vector<RaceCheckPoint*>& allCheckpoints) 152 154 { 153 155 std::map<RaceCheckPoint*, int> zaehler; // counts how many times the checkpoint was reached (for simulation) … … 156 158 zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0)); 157 159 } 158 int maxWays = rekSimulationCheckpointsReached( zaehler.begin()->first, zaehler);160 int maxWays = rekSimulationCheckpointsReached(currentCheckpoint, zaehler); 159 161 160 162 std::vector<RaceCheckPoint*> returnVec; 161 returnVec.clear();162 163 for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler.begin(); iter != zaehler.end(); iter++) 163 164 { 164 165 if (iter->second == maxWays) 165 166 { 166 //returnVec.insert(allCheckpoints[1]); 167 returnVec.insert(returnVec.end(), iter->first); 167 returnVec.push_back(iter->first); 168 168 } 169 169 } … … 189 189 for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it) 190 190 { 191 if (currentCheckpoint == findCheckpoint(*it))191 if (currentCheckpoint == findCheckpoint(*it)) 192 192 { 193 193 //orxout() << currentCheckpoint->getCheckpointIndex()<<endl; 194 194 continue; 195 195 } 196 if(findCheckpoint(*it) == NULL) 197 {orxout()<<"Problematic Point: "<<(*it)<<endl;} 198 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 196 if (findCheckpoint(*it) == NULL) 197 orxout(internal_warning) << "Problematic Point: " << (*it) << endl; 198 else 199 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 199 200 } 200 201 zaehler[currentCheckpoint] += numberOfWays; -
code/trunk/src/modules/gametypes/SpaceRaceController.h
r9967 r9973 50 50 RaceCheckPoint* nextPointFind(RaceCheckPoint*); 51 51 RaceCheckPoint* adjustNextPoint(); 52 std::vector<RaceCheckPoint*> findStaticCheckpoints( const std::vector<RaceCheckPoint*>&);52 std::vector<RaceCheckPoint*> findStaticCheckpoints(RaceCheckPoint*, const std::vector<RaceCheckPoint*>&); 53 53 std::vector<RaceCheckPoint*> staticCheckpoints(); 54 54 int rekSimulationCheckpointsReached(RaceCheckPoint*, std::map<RaceCheckPoint*, int>&);
Note: See TracChangeset
for help on using the changeset viewer.