CTS converts such that only next checkpoint shows

This commit is contained in:
suhrke 2017-07-03 18:10:05 -07:00
parent 58d24d67b4
commit 0b6254da89
2 changed files with 35 additions and 18 deletions

View File

@ -89,7 +89,7 @@ EntityConverter::EntityConverter(std::string entityMapFile, std::string reflexMa
*--------------------------------------------------------------------------------------
*/
void
matchRelated(std::queue<std::vector<std::string>> entities)
EntityConverter::matchRelated(std::queue<std::vector<std::string>> entities)
{
if( areEntitiesMatched_ ) {
std::cerr << "Related entities are already matched, doing nothing" << std::endl;
@ -265,14 +265,15 @@ std::vector<std::string>
EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
{
std::vector<std::string> 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<std::string> &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<std::string> &lines)
{
std::vector<std::string> 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<std::string> &lines)
{
std::vector<std::string> convertedLines;
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"");
convertedLines.push_back ("\"targetname\" \"finish\"");
convertedLines.push_back ("\"cnt\" \"0\"");
return convertedLines;
}

View File

@ -28,6 +28,7 @@
#include <map>
#include <string>
#include <queue>
#include <vector>
class EntityConverter