Changeset 9973 for code/trunk/src/modules/gametypes/SpaceRaceController.cc
- Timestamp:
- Jan 4, 2014, 2:56:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.