CTS can now coexist with other modes as a circuit (which is most official flex ctf maps)

This commit is contained in:
surkeh 2017-10-10 18:19:58 -07:00
parent f88a4710f0
commit 579b23fccb
3 changed files with 12 additions and 16 deletions

View File

@ -28,5 +28,5 @@ EntityConverter.o: src/EntityConverter.cpp
$(CC) -c $^ $(CFLAGS) $(CC) -c $^ $(CFLAGS)
clean: clean:
rm *.o *.log $(EX) rm *.o $(EX)

View File

@ -392,11 +392,7 @@ EntityConverter::convertPlayerSpawn (const std::vector<std::string> &lines) cons
} }
} }
else { else {
convertedLines.push_back ("\"classname\" \"info_player_race\"\n"); convertedLines.push_back ("\"classname\" \"info_player_start\"\n");
// Reflex maps have only start and finish, point to start on spawn
convertedLines.push_back ("\"target\" \"cp1\"\n");
// Reflex maps are only cts, set spawn to cts-only type
convertedLines.push_back ("\"race_place\" \"-1\"\n");
} }
std::stringstream positionStream; std::stringstream positionStream;
@ -518,7 +514,7 @@ EntityConverter::convertTarget (const std::vector<std::string> &lines) const
if (haveName) { if (haveName) {
auto targetIter = targetMap_.find (targetName); auto targetIter = targetMap_.find (targetName);
if (targetIter == targetMap_.end()) { if (targetIter == targetMap_.end()) {
std::cerr << makeErrorMessage ("End-game camera Target is not a supported feature in id Tech games. Skipping", lines); //std::cerr << makeErrorMessage ("End-game camera Target is not a supported feature in id Tech games. Skipping", lines);
std::vector<std::string> empty; std::vector<std::string> empty;
return empty; return empty;
@ -565,7 +561,8 @@ EntityConverter::convertRaceStart (const std::vector<std::string> &lines) const
std::vector<std::string> convertedLines; std::vector<std::string> convertedLines;
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\n"); convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\n");
convertedLines.push_back ("\"targetname\" \"cp1\"\n"); convertedLines.push_back ("\"targetname\" \"cp1\"\n");
convertedLines.push_back ("\"cnt\" \"1\"\n"); // While 0 is finish in Race, in CTS, checkpoints numbered from 0 to n
convertedLines.push_back ("\"cnt\" \"0\"\n");
return convertedLines; return convertedLines;
} }
@ -577,7 +574,8 @@ EntityConverter::convertRaceFinish (const std::vector<std::string> &lines) const
std::vector<std::string> convertedLines; std::vector<std::string> convertedLines;
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\n"); convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\n");
convertedLines.push_back ("\"targetname\" \"finish\"\n"); convertedLines.push_back ("\"targetname\" \"finish\"\n");
convertedLines.push_back ("\"cnt\" \"0\"\n"); // While 0 is finish in Race, in CTS, checkpoints numbered from 0 to n
convertedLines.push_back ("\"cnt\" \"1\"\n");
return convertedLines; return convertedLines;
} }

View File

@ -129,12 +129,10 @@ TEST_CASE ("r2x: a single PlayerSpawn (race) entity can be converted", "[EntityC
std::vector<std::string> unused = ec.convert(worldspawn); std::vector<std::string> unused = ec.convert(worldspawn);
std::vector<std::string> converted = ec.convert(entity); std::vector<std::string> converted = ec.convert(entity);
REQUIRE (converted[0] == "\"classname\" \"info_player_race\"\n"); REQUIRE (converted[0] == "\"classname\" \"info_player_start\"\n");
REQUIRE (converted[1] == "\"target\" \"cp1\"\n");
REQUIRE (converted[2] == "\"race_place\" \"-1\"\n");
// The z (vertical) is offset by +32 // The z (vertical) is offset by +32
std::istringstream iss (converted[3]); std::istringstream iss (converted[1]);
std::string attribute; std::string attribute;
std::string coords[2]; std::string coords[2];
float offsetCoord; float offsetCoord;
@ -146,7 +144,7 @@ TEST_CASE ("r2x: a single PlayerSpawn (race) entity can be converted", "[EntityC
REQUIRE (fabs(-100.00000 - offsetCoord) <= DELTA); REQUIRE (fabs(-100.00000 - offsetCoord) <= DELTA);
SECTION( "Converted angles are valid (Different coordinate system handedness)") { SECTION( "Converted angles are valid (Different coordinate system handedness)") {
std::istringstream angleLineStream(converted[4]); std::istringstream angleLineStream(converted[2]);
std::string angleAttribute; std::string angleAttribute;
std::string a; std::string a;
float angle; float angle;
@ -279,7 +277,7 @@ TEST_CASE ("r2x: a single RaceStart entity can be converted", "[EntityConverter]
REQUIRE (converted[0] == "\"classname\" \"trigger_race_checkpoint\"\n"); REQUIRE (converted[0] == "\"classname\" \"trigger_race_checkpoint\"\n");
REQUIRE (converted[1] == "\"targetname\" \"cp1\"\n"); REQUIRE (converted[1] == "\"targetname\" \"cp1\"\n");
REQUIRE (converted[2] == "\"cnt\" \"1\"\n"); REQUIRE (converted[2] == "\"cnt\" \"0\"\n");
} }
@ -305,7 +303,7 @@ TEST_CASE ("r2x: a single RaceFinish entity can be converted", "[EntityConverter
REQUIRE (converted[0] == "\"classname\" \"trigger_race_checkpoint\"\n"); REQUIRE (converted[0] == "\"classname\" \"trigger_race_checkpoint\"\n");
REQUIRE (converted[1] == "\"targetname\" \"finish\"\n"); REQUIRE (converted[1] == "\"targetname\" \"finish\"\n");
REQUIRE (converted[2] == "\"cnt\" \"0\"\n"); REQUIRE (converted[2] == "\"cnt\" \"1\"\n");
} }