[Orxonox-commit 5301] r9964 - code/trunk/src/modules/gametypes
landauf at orxonox.net
landauf at orxonox.net
Fri Jan 3 21:44:23 CET 2014
Author: landauf
Date: 2014-01-03 21:44:23 +0100 (Fri, 03 Jan 2014)
New Revision: 9964
Modified:
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
code/trunk/src/modules/gametypes/RaceCheckPoint.h
code/trunk/src/modules/gametypes/SpaceRaceController.cc
Log:
removed unused code (some of the code was after a 'return' statement and thus never executed)
Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2014-01-03 20:29:13 UTC (rev 9963)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2014-01-03 20:44:23 UTC (rev 9964)
@@ -103,40 +103,6 @@
}
}
- //Must not be called before setNextCheckpointsAsVector3 at least once has been called
- void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
- /*std::set<int> lastcheckpoints=this->nextCheckpoints_;
- nextCheckpoints_.clear();
- std::set<int>::iterator it = lastcheckpoints.begin();
- if(checkpoints.x<-1){
- virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it)));
- it++;
- }
- if(checkpoints.x!=-1)
- 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
-
- if(checkpoints.y<-1){
- virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it)));
- it++;
- }
- if(checkpoints.y!=-1)
- this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
-
- if(checkpoints.z<-1){
- virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it)));
- it++;
- }
- if(checkpoints.z!=-1)
- this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));*/
- nextCheckpointsVirtual_.clear();
- if(checkpoints.x!=-1)
- nextCheckpointsVirtual_.insert(checkpoints.x);
- if(checkpoints.y!=-1)
- nextCheckpointsVirtual_.insert(checkpoints.y);
- if(checkpoints.z!=-1)
- nextCheckpointsVirtual_.insert(checkpoints.z);
- }
-
void RaceCheckPoint::setNextCheckpointsAsVector3(const Vector3& checkpoints)
{
this->nextCheckpoints_.clear();
@@ -147,8 +113,6 @@
this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
if (checkpoints.z > -1)
this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
-
- this->nextCheckpointsVirtual_=nextCheckpoints_;
}
PlayerInfo* RaceCheckPoint::getPlayer(unsigned int clientID) const
@@ -194,43 +158,6 @@
++count;
}
return checkpoints;
- //= getVirtualNextCheckpointsAsVector3();
- int j[3];
- j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
- j[1]=changeVirtualToRealCheckPoint(checkpoints.y);
- j[2]=changeVirtualToRealCheckPoint(checkpoints.z);
-
-
- return Vector3(j[0],j[1],j[2]);
-
-
}
- int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) {
- int temp=checkpointID;
- while(temp<-1){
- temp = this->virtualToRealCheckPoints_[temp];
- }
- return temp;
- }
-
-
- Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const
- {
- Vector3 checkpoints = Vector3(-1, -1, -1);
-
- size_t count = 0;
- for (std::set<int>::iterator it = this->nextCheckpointsVirtual_.begin(); it != this->nextCheckpointsVirtual_.end(); ++it)
- {
- switch (count)
- {
- case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
- case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
- case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
- }
- ++count;
- }
-
- return checkpoints;
- }
}
Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.h 2014-01-03 20:29:13 UTC (rev 9963)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.h 2014-01-03 20:44:23 UTC (rev 9964)
@@ -60,24 +60,10 @@
void setNextCheckpointsAsVector3(const Vector3& checkpoints);
Vector3 getNextCheckpointsAsVector3();
- Vector3 getVirtualNextCheckpointsAsVector3() const;
- void setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints);
- int changeVirtualToRealCheckPoint(int);
- const std::set<int>& getVirtualNextCheckpoints() const
- {
- return this->nextCheckpointsVirtual_;
- }
-
std::set<int> getNextCheckpoints()
{
return nextCheckpoints_;
- std::set<int> temp;
- std::set<int> temp2=getVirtualNextCheckpoints();
- for (std::set<int>::iterator it = temp2.begin(); it!=temp2.end(); ++it){
- temp.insert(changeVirtualToRealCheckPoint((*it)));
- }
- return temp;
}
inline void setLast(bool isLast)
{
@@ -119,8 +105,6 @@
bool bIsLast_; ///< True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
float timeLimit_; ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
- std::set<int> nextCheckpointsVirtual_;
- std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
};
}
Modified: code/trunk/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceController.cc 2014-01-03 20:29:13 UTC (rev 9963)
+++ code/trunk/src/modules/gametypes/SpaceRaceController.cc 2014-01-03 20:44:23 UTC (rev 9964)
@@ -187,7 +187,7 @@
else
{
int numberOfWays = 0; // counts number of ways from this Point to the last point
- for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it)
+ for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it)
{
if(currentCheckpoint == findCheckpoint(*it))
{
@@ -223,7 +223,7 @@
{
float distances[] = {-1, -1, -1};
int temp_i = 0;
- for (std::set<int>::iterator it =raceCheckpoint->getVirtualNextCheckpoints().begin(); it!= raceCheckpoint->getVirtualNextCheckpoints().end(); ++it)
+ for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it)
{
distances[temp_i] = recCalculateDistance(findCheckpoint(*it), this->getControllableEntity()->getPosition());
temp_i++;
@@ -232,11 +232,11 @@
{
if (distances[2] < distances[1] && distances[2] >= 0)
{
- return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
+ return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
}
else
{
- std::set<int>::iterator temp = raceCheckpoint->getVirtualNextCheckpoints().begin();
+ std::set<int>::iterator temp = raceCheckpoint->getNextCheckpoints().begin();
return findCheckpoint(*(++temp)); // return [1]
}
}
@@ -244,11 +244,11 @@
{
if (distances[2] < distances[0] && distances[2] >= 0)
{
- return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return [2]
+ return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return [2]
}
else
{
- return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().begin()); // return [0]
+ return findCheckpoint(*raceCheckpoint->getNextCheckpoints().begin()); // return [0]
}
}
}
@@ -267,7 +267,7 @@
else
{
float minimum = std::numeric_limits<float>::max();
- for (std::set<int>::iterator it = currentCheckPoint->getVirtualNextCheckpoints().begin(); it != currentCheckPoint->getVirtualNextCheckpoints().end(); ++it)
+ for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it != currentCheckPoint->getNextCheckpoints().end(); ++it)
{
int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length());
@@ -288,7 +288,7 @@
{
return nextRaceCheckpoint_;
}
- if ((currentRaceCheckpoint_->getVirtualNextCheckpoints()).size() == 1) // no Adjust possible
+ if ((currentRaceCheckpoint_->getNextCheckpoints()).size() == 1) // no Adjust possible
{
return nextRaceCheckpoint_;
More information about the Orxonox-commit
mailing list