From 579b23fccb2f51e2a37ce069b62872283ff6f5df Mon Sep 17 00:00:00 2001 From: surkeh Date: Tue, 10 Oct 2017 18:19:58 -0700 Subject: [PATCH] CTS can now coexist with other modes as a circuit (which is most official flex ctf maps) --- Makefile | 2 +- src/EntityConverter.cpp | 14 ++++++-------- test/catch-entityconverter.cpp | 12 +++++------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 26207df..3d2957e 100644 --- a/Makefile +++ b/Makefile @@ -28,5 +28,5 @@ EntityConverter.o: src/EntityConverter.cpp $(CC) -c $^ $(CFLAGS) clean: - rm *.o *.log $(EX) + rm *.o $(EX) diff --git a/src/EntityConverter.cpp b/src/EntityConverter.cpp index 47c41c9..d1cefe9 100644 --- a/src/EntityConverter.cpp +++ b/src/EntityConverter.cpp @@ -392,11 +392,7 @@ EntityConverter::convertPlayerSpawn (const std::vector &lines) cons } } else { - convertedLines.push_back ("\"classname\" \"info_player_race\"\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"); + convertedLines.push_back ("\"classname\" \"info_player_start\"\n"); } std::stringstream positionStream; @@ -518,7 +514,7 @@ EntityConverter::convertTarget (const std::vector &lines) const if (haveName) { auto targetIter = targetMap_.find (targetName); 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 empty; return empty; @@ -565,7 +561,8 @@ EntityConverter::convertRaceStart (const std::vector &lines) const std::vector convertedLines; convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\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; } @@ -577,7 +574,8 @@ EntityConverter::convertRaceFinish (const std::vector &lines) const std::vector convertedLines; convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"\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; } diff --git a/test/catch-entityconverter.cpp b/test/catch-entityconverter.cpp index 9319ea7..fd62051 100644 --- a/test/catch-entityconverter.cpp +++ b/test/catch-entityconverter.cpp @@ -129,12 +129,10 @@ TEST_CASE ("r2x: a single PlayerSpawn (race) entity can be converted", "[EntityC std::vector unused = ec.convert(worldspawn); std::vector converted = ec.convert(entity); - REQUIRE (converted[0] == "\"classname\" \"info_player_race\"\n"); - REQUIRE (converted[1] == "\"target\" \"cp1\"\n"); - REQUIRE (converted[2] == "\"race_place\" \"-1\"\n"); + REQUIRE (converted[0] == "\"classname\" \"info_player_start\"\n"); // The z (vertical) is offset by +32 - std::istringstream iss (converted[3]); + std::istringstream iss (converted[1]); std::string attribute; std::string coords[2]; float offsetCoord; @@ -146,7 +144,7 @@ TEST_CASE ("r2x: a single PlayerSpawn (race) entity can be converted", "[EntityC REQUIRE (fabs(-100.00000 - offsetCoord) <= DELTA); SECTION( "Converted angles are valid (Different coordinate system handedness)") { - std::istringstream angleLineStream(converted[4]); + std::istringstream angleLineStream(converted[2]); std::string angleAttribute; std::string a; 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[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[1] == "\"targetname\" \"finish\"\n"); - REQUIRE (converted[2] == "\"cnt\" \"0\"\n"); + REQUIRE (converted[2] == "\"cnt\" \"1\"\n"); }