Changeset 9967 for code/trunk/src/modules
- Timestamp:
- Jan 3, 2014, 10:14: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
r9964 r9967 60 60 this->bIsLast_ = false; 61 61 this->timeLimit_ = 0; 62 //this->players_ = vector<PlayerInfo*>();63 64 //orxout(user_status) << "test" << std::endl;65 62 } 66 63 -
code/trunk/src/modules/gametypes/SpaceRaceController.cc
r9965 r9967 149 149 * returns a vector of static Point (checkpoints the spaceship has to reach) 150 150 */ 151 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints( std::vector<RaceCheckPoint*>allCheckpoints)152 { 153 std::map<RaceCheckPoint*, int> * zaehler = new std::map<RaceCheckPoint*, int>(); // counts how many times the checkpoint was reached (for simulation)151 std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(const std::vector<RaceCheckPoint*>& allCheckpoints) 152 { 153 std::map<RaceCheckPoint*, int> zaehler; // counts how many times the checkpoint was reached (for simulation) 154 154 for (unsigned int i = 0; i < allCheckpoints.size(); i++) 155 155 { 156 zaehler ->insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0));157 } 158 int maxWays = rekSimulationCheckpointsReached(zaehler ->begin()->first, zaehler);156 zaehler.insert(std::pair<RaceCheckPoint*, int>(allCheckpoints[i],0)); 157 } 158 int maxWays = rekSimulationCheckpointsReached(zaehler.begin()->first, zaehler); 159 159 160 160 std::vector<RaceCheckPoint*> returnVec; 161 161 returnVec.clear(); 162 for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler ->begin(); iter != zaehler->end(); iter++)162 for (std::map<RaceCheckPoint*, int>::iterator iter = zaehler.begin(); iter != zaehler.end(); iter++) 163 163 { 164 164 if (iter->second == maxWays) … … 168 168 } 169 169 } 170 delete zaehler;171 170 return returnVec; 172 171 } … … 176 175 * return how many ways go from the given Checkpoint to the last Checkpoint (of the Game) 177 176 */ 178 int SpaceRaceController::rekSimulationCheckpointsReached(RaceCheckPoint* currentCheckpoint, std::map<RaceCheckPoint*, int> *zaehler)177 int SpaceRaceController::rekSimulationCheckpointsReached(RaceCheckPoint* currentCheckpoint, std::map<RaceCheckPoint*, int>& zaehler) 179 178 { 180 179 … … 182 181 {// last point reached 183 182 184 (*zaehler)[currentCheckpoint] += 1;183 zaehler[currentCheckpoint] += 1; 185 184 return 1; // 1 Way form the last point to this one 186 185 } … … 199 198 numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler); 200 199 } 201 (*zaehler)[currentCheckpoint] += numberOfWays;200 zaehler[currentCheckpoint] += numberOfWays; 202 201 return numberOfWays; // returns the number of ways from this point to the last one 203 202 } … … 245 244 * returns the distance between "currentPosition" and the next static checkpoint that can be reached from "currentCheckPoint" 246 245 */ 247 float SpaceRaceController::recCalculateDistance(RaceCheckPoint* currentCheckPoint, Vector3currentPosition)246 float SpaceRaceController::recCalculateDistance(RaceCheckPoint* currentCheckPoint, const Vector3& currentPosition) 248 247 { 249 248 // find: looks if the currentCheckPoint is a staticCheckPoint (staticCheckPoint is the same as: static Point) … … 295 294 } 296 295 297 /*RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , Vector3virtualCheckPointPosition )296 /*RaceCheckPoint* SpaceRaceController::addVirtualCheckPoint( RaceCheckPoint* previousCheckpoint, int indexFollowingCheckPoint , const Vector3& virtualCheckPointPosition ) 298 297 { 299 298 orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl; … … 393 392 394 393 // True if a coordinate of 'pointToPoint' is smaller then the corresponding coordinate of 'groesse' 395 bool SpaceRaceController::vergleicheQuader( Vector3 pointToPoint, Vector3groesse)394 bool SpaceRaceController::vergleicheQuader(const Vector3& pointToPoint, const Vector3& groesse) 396 395 { 397 396 if(abs(pointToPoint.x) < groesse.x) … … 405 404 } 406 405 407 bool SpaceRaceController::directLinePossible(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, std::vector<StaticEntity*>allObjects)406 bool SpaceRaceController::directLinePossible(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, const std::vector<StaticEntity*>& allObjects) 408 407 { 409 408 … … 413 412 btScalar radiusObject; 414 413 415 for (std::vector<StaticEntity*>:: iterator it = allObjects.begin(); it != allObjects.end(); ++it)414 for (std::vector<StaticEntity*>::const_iterator it = allObjects.begin(); it != allObjects.end(); ++it) 416 415 { 417 416 for (int everyShape=0; (*it)->getAttachedCollisionShape(everyShape) != 0; everyShape++) … … 434 433 } 435 434 436 /*void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, std::vector<StaticEntity*>allObjects)435 /*void SpaceRaceController::computeVirtualCheckpoint(RaceCheckPoint* racepoint1, RaceCheckPoint* racepoint2, const std::vector<StaticEntity*>& allObjects) 437 436 { 438 437 Vector3 cP1ToCP2=(racepoint2->getPosition()-racepoint1->getPosition()) / (racepoint2->getPosition()-racepoint1->getPosition()).length(); //unit Vector -
code/trunk/src/modules/gametypes/SpaceRaceController.h
r9966 r9967 41 41 public: 42 42 SpaceRaceController(Context* context); 43 virtual ~SpaceRaceController(); 43 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 44 virtual ~SpaceRaceController();45 45 virtual void tick(float dt); 46 46 47 47 private: 48 float recCalculateDistance(RaceCheckPoint*, Vector3currentPosition);48 float recCalculateDistance(RaceCheckPoint*, const Vector3& currentPosition); 49 49 float distanceSpaceshipToCheckPoint(RaceCheckPoint*); 50 50 RaceCheckPoint* nextPointFind(RaceCheckPoint*); 51 51 RaceCheckPoint* adjustNextPoint(); 52 std::vector<RaceCheckPoint*> findStaticCheckpoints( std::vector<RaceCheckPoint*>);52 std::vector<RaceCheckPoint*> findStaticCheckpoints(const std::vector<RaceCheckPoint*>&); 53 53 std::vector<RaceCheckPoint*> staticCheckpoints(); 54 int rekSimulationCheckpointsReached(RaceCheckPoint*, std::map<RaceCheckPoint*, int> *);54 int rekSimulationCheckpointsReached(RaceCheckPoint*, std::map<RaceCheckPoint*, int>&); 55 55 // same as SpaceRaceManager, but needed to add virtuell Checkpoints ( Checkpoints which don't exist but needed to avoid collisions with big Objects) 56 56 RaceCheckPoint* findCheckpoint(int index) const; 57 //RaceCheckPoint * addVirtualCheckPoint(RaceCheckPoint*, int , Vector3);57 //RaceCheckPoint * addVirtualCheckPoint(RaceCheckPoint*, int , const Vector3&); 58 58 //void placeVirtualCheckpoints(RaceCheckPoint*, RaceCheckPoint*); 59 bool vergleicheQuader( Vector3, Vector3);60 bool directLinePossible(RaceCheckPoint*, RaceCheckPoint*, std::vector<StaticEntity*>);61 //void computeVirtualCheckpoint(RaceCheckPoint*, RaceCheckPoint*, std::vector<StaticEntity*>);59 bool vergleicheQuader(const Vector3&, const Vector3&); 60 bool directLinePossible(RaceCheckPoint*, RaceCheckPoint*, const std::vector<StaticEntity*>&); 61 //void computeVirtualCheckpoint(RaceCheckPoint*, RaceCheckPoint*, const std::vector<StaticEntity*>&); 62 62 63 63 std::vector<RaceCheckPoint*> staticRacePoints_;
Note: See TracChangeset
for help on using the changeset viewer.