From 0b6254da89b32a65132d22bdab2dfd57b77f78fe Mon Sep 17 00:00:00 2001 From: suhrke Date: Mon, 3 Jul 2017 18:10:05 -0700 Subject: [PATCH] CTS converts such that only next checkpoint shows --- ReflexToQ3/includes/EntityConverter.cpp | 52 ++++++++++++++++--------- ReflexToQ3/includes/EntityConverter.hpp | 1 + 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/ReflexToQ3/includes/EntityConverter.cpp b/ReflexToQ3/includes/EntityConverter.cpp index 79852b5..55b8bea 100644 --- a/ReflexToQ3/includes/EntityConverter.cpp +++ b/ReflexToQ3/includes/EntityConverter.cpp @@ -89,7 +89,7 @@ EntityConverter::EntityConverter(std::string entityMapFile, std::string reflexMa *-------------------------------------------------------------------------------------- */ void -matchRelated(std::queue> entities) +EntityConverter::matchRelated(std::queue> entities) { if( areEntitiesMatched_ ) { std::cerr << "Related entities are already matched, doing nothing" << std::endl; @@ -265,14 +265,15 @@ std::vector EntityConverter::convertPlayerSpawn(std::vector &lines) { std::vector convertedLines; - //Requires position coordinate + // Requires position coordinate std::string coords[3]; - //Requires an angle so if no reflex one is given, use 0 + // Requires an angle so if no reflex one is given, use 0 std::string angle("0"); - // 3 for race spawn, 1-2 for corresponding team, 0 for deathmatch spawn + // 1-2 for corresponding team, 0 for deathmatch spawn int team = 0; std::string trash; bool havePosition = false; + bool isModeRace = true; if ( lines.size() < 2 ) { @@ -293,38 +294,51 @@ EntityConverter::convertPlayerSpawn(std::vector &lines) else if ( type == "angles" ) { std::istringstream iss(lines[i]); // UInt8 pickupType ID - if ( ! (iss >> trash >> trash >> angle ) { + if ( ! (iss >> trash >> trash >> angle )) { throw std::runtime_error("error: Pickup entity requires Pickup ID"); } } + else if ( type == "modeRace" ) { + isModeRace = false; + } else if ( type == "teamA" ) { team = 2; // Bool8 teamA 0 indicates teamB only } - else ef ( type == "teamB" ) { + else if ( type == "teamB" ) { team = 1; // Bool8 teamB 0 indicates teamA only } } if ( havePosition ) { - switch (team) { - case 0: - convertedLines.push_back ( "\"classname\" \"info_player_deathmatch\"" ); - break; - case 1: - convertedLines.push_back ( "\"classname\" \"info_player_team1\"" ); - break; - case 2: - convertedLines.push_back ( "\"classname\" \"info_player_team2\"" ); - break; + if ( ! isModeRace ) { + switch (team) { + case 0: + convertedLines.push_back ( "\"classname\" \"info_player_deathmatch\"" ); + break; + case 1: + convertedLines.push_back ( "\"classname\" \"info_player_team1\"" ); + break; + case 2: + convertedLines.push_back ( "\"classname\" \"info_player_team2\"" ); + break; + } + + } + else { + convertedLines.push_back ( "\"classname\" \"info_player_race\"" ); + // Reflex maps have only start and finish, point to start on spawn + convertedLines.push_back ( "\"target\" \"cp1\"" ); + // Reflex maps are only cts, set spawn to cts-only type + convertedLines.push_back ( "\"race_place\" \"-1\"" ); } std::stringstream oss; // coordinates reordered to x, z, y oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " << - coords[1] << "\"" << std::endl; + coords[1] << "\"" << std::endl; convertedLines.push_back ( oss.str() ); std::stringstream oss2; - oss2 << "\"angle\" \"" << angle << "\"" << endl; + oss2 << "\"angle\" \"" << angle << "\"" << std::endl; convertedLines.push_back ( oss2.str() ); return convertedLines; } @@ -467,6 +481,7 @@ EntityConverter::convertRaceStart(std::vector &lines) { std::vector convertedLines; convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\""); + convertedLines.push_back ("\"targetname\" \"cp1\""); convertedLines.push_back ("\"cnt\" \"1\""); return convertedLines; } @@ -478,6 +493,7 @@ EntityConverter::convertRaceFinish(std::vector &lines) { std::vector convertedLines; convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\""); + convertedLines.push_back ("\"targetname\" \"finish\""); convertedLines.push_back ("\"cnt\" \"0\""); return convertedLines; } diff --git a/ReflexToQ3/includes/EntityConverter.hpp b/ReflexToQ3/includes/EntityConverter.hpp index 3535702..898d227 100644 --- a/ReflexToQ3/includes/EntityConverter.hpp +++ b/ReflexToQ3/includes/EntityConverter.hpp @@ -28,6 +28,7 @@ #include #include +#include #include class EntityConverter