EC: fixed malformed race spawn conversion, issue #33
This commit is contained in:
parent
ff47d28870
commit
0e61e02259
@ -286,11 +286,11 @@ EntityConverter::convertPlayerSpawn(std::vector<std::string> &lines)
|
||||
|
||||
}
|
||||
else {
|
||||
convertedLines.push_back ( "\"classname\" \"info_player_race\"" );
|
||||
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\"" );
|
||||
convertedLines.push_back ( "\"target\" \"cp1\"\n" );
|
||||
// Reflex maps are only cts, set spawn to cts-only type
|
||||
convertedLines.push_back ( "\"race_place\" \"-1\"" );
|
||||
convertedLines.push_back ( "\"race_place\" \"-1\"\n" );
|
||||
}
|
||||
|
||||
std::stringstream oss;
|
||||
|
@ -93,6 +93,54 @@ TEST_CASE( "r2x: a single Pickup entity can be converted", "[EntityConverter]" )
|
||||
|
||||
|
||||
|
||||
TEST_CASE( "r2x: a single PlayerSpawn (race) entity can be converted", "[EntityConverter]" ) {
|
||||
|
||||
// Instantiate object
|
||||
EntityConverter ec (PICKUP_FILENAME);
|
||||
|
||||
// Mock up entity
|
||||
std::vector<std::string> entity;
|
||||
entity.push_back(" type PlayerSpawn");
|
||||
entity.push_back(" Vector3 position -216.00000 -132.00000 -1488.000488");
|
||||
entity.push_back(" Vector3 angles 180.00000 0.00000 0.00000");
|
||||
entity.push_back(" Bool8 teamA 0");
|
||||
entity.push_back(" Bool8 teamB 0");
|
||||
entity.push_back(" Bool8 modeCTF 0");
|
||||
entity.push_back(" Bool8 modeFFA 0");
|
||||
entity.push_back(" Bool8 modeTDM 0");
|
||||
entity.push_back(" Bool8 mode1v1 0");
|
||||
|
||||
// Mock up entity queue
|
||||
std::queue<std::vector<std::string>> q;
|
||||
q.push( entity );
|
||||
|
||||
// Match related entities (none)
|
||||
ec.matchRelated( q );
|
||||
|
||||
// Convert a single entity
|
||||
std::vector<std::string> 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[4] == "\"angle\" \"180.00000\"\n" );
|
||||
|
||||
// The z (vertical) is offset by +32
|
||||
std::istringstream iss(converted[3]);
|
||||
std::string attribute;
|
||||
std::string coords[2];
|
||||
float offsetCoord;
|
||||
iss >> attribute >> coords[0] >> coords[1] >> offsetCoord;
|
||||
|
||||
REQUIRE( attribute == "\"origin\"" );
|
||||
REQUIRE( coords[0] == "\"-216.00000" );
|
||||
REQUIRE( coords[1] == "-1488.000488" );
|
||||
REQUIRE( fabs(-100.00000 - offsetCoord) <= DELTA );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_CASE( "r2x: a single PlayerSpawn (teamA) entity can be converted", "[EntityConverter]" ) {
|
||||
|
||||
// Instantiate object
|
||||
|
Loading…
Reference in New Issue
Block a user