CTS converts such that only next checkpoint shows
This commit is contained in:
parent
58d24d67b4
commit
0b6254da89
@ -89,7 +89,7 @@ EntityConverter::EntityConverter(std::string entityMapFile, std::string reflexMa
|
|||||||
*--------------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
matchRelated(std::queue<std::vector<std::string>> entities)
|
EntityConverter::matchRelated(std::queue<std::vector<std::string>> entities)
|
||||||
{
|
{
|
||||||
if( areEntitiesMatched_ ) {
|
if( areEntitiesMatched_ ) {
|
||||||
std::cerr << "Related entities are already matched, doing nothing" << std::endl;
|
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)
|
EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
||||||
{
|
{
|
||||||
std::vector<std::string> convertedLines;
|
std::vector<std::string> convertedLines;
|
||||||
//Requires position coordinate
|
// Requires position coordinate
|
||||||
std::string coords[3];
|
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");
|
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;
|
int team = 0;
|
||||||
std::string trash;
|
std::string trash;
|
||||||
bool havePosition = false;
|
bool havePosition = false;
|
||||||
|
bool isModeRace = true;
|
||||||
|
|
||||||
|
|
||||||
if ( lines.size() < 2 ) {
|
if ( lines.size() < 2 ) {
|
||||||
@ -293,19 +294,23 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
|||||||
else if ( type == "angles" ) {
|
else if ( type == "angles" ) {
|
||||||
std::istringstream iss(lines[i]);
|
std::istringstream iss(lines[i]);
|
||||||
// UInt8 pickupType ID
|
// UInt8 pickupType ID
|
||||||
if ( ! (iss >> trash >> trash >> angle ) {
|
if ( ! (iss >> trash >> trash >> angle )) {
|
||||||
throw std::runtime_error("error: Pickup entity requires Pickup ID");
|
throw std::runtime_error("error: Pickup entity requires Pickup ID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( type == "modeRace" ) {
|
||||||
|
isModeRace = false;
|
||||||
|
}
|
||||||
else if ( type == "teamA" ) {
|
else if ( type == "teamA" ) {
|
||||||
team = 2; // Bool8 teamA 0 indicates teamB only
|
team = 2; // Bool8 teamA 0 indicates teamB only
|
||||||
}
|
}
|
||||||
else ef ( type == "teamB" ) {
|
else if ( type == "teamB" ) {
|
||||||
team = 1; // Bool8 teamB 0 indicates teamA only
|
team = 1; // Bool8 teamB 0 indicates teamA only
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( havePosition ) {
|
if ( havePosition ) {
|
||||||
|
if ( ! isModeRace ) {
|
||||||
switch (team) {
|
switch (team) {
|
||||||
case 0:
|
case 0:
|
||||||
convertedLines.push_back ( "\"classname\" \"info_player_deathmatch\"" );
|
convertedLines.push_back ( "\"classname\" \"info_player_deathmatch\"" );
|
||||||
@ -318,13 +323,22 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
|||||||
break;
|
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;
|
std::stringstream oss;
|
||||||
// coordinates reordered to x, z, y
|
// coordinates reordered to x, z, y
|
||||||
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
oss << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
|
||||||
coords[1] << "\"" << std::endl;
|
coords[1] << "\"" << std::endl;
|
||||||
convertedLines.push_back ( oss.str() );
|
convertedLines.push_back ( oss.str() );
|
||||||
std::stringstream oss2;
|
std::stringstream oss2;
|
||||||
oss2 << "\"angle\" \"" << angle << "\"" << endl;
|
oss2 << "\"angle\" \"" << angle << "\"" << std::endl;
|
||||||
convertedLines.push_back ( oss2.str() );
|
convertedLines.push_back ( oss2.str() );
|
||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
@ -467,6 +481,7 @@ EntityConverter::convertRaceStart(std::vector<std::string> &lines)
|
|||||||
{
|
{
|
||||||
std::vector<std::string> convertedLines;
|
std::vector<std::string> convertedLines;
|
||||||
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"");
|
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"");
|
||||||
|
convertedLines.push_back ("\"targetname\" \"cp1\"");
|
||||||
convertedLines.push_back ("\"cnt\" \"1\"");
|
convertedLines.push_back ("\"cnt\" \"1\"");
|
||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
@ -478,6 +493,7 @@ EntityConverter::convertRaceFinish(std::vector<std::string> &lines)
|
|||||||
{
|
{
|
||||||
std::vector<std::string> convertedLines;
|
std::vector<std::string> convertedLines;
|
||||||
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"");
|
convertedLines.push_back ("\"classname\" \"trigger_race_checkpoint\"");
|
||||||
|
convertedLines.push_back ("\"targetname\" \"finish\"");
|
||||||
convertedLines.push_back ("\"cnt\" \"0\"");
|
convertedLines.push_back ("\"cnt\" \"0\"");
|
||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class EntityConverter
|
class EntityConverter
|
||||||
|
Loading…
Reference in New Issue
Block a user