Merge branch 'master' of https://git.teknik.io/scuti/reflex2q3
This commit is contained in:
commit
c2fc685cb4
@ -466,10 +466,9 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
|||||||
//position and name required, angles optional
|
//position and name required, angles optional
|
||||||
std::string coords[3] = {"0.0", "0.0", "0.0"};
|
std::string coords[3] = {"0.0", "0.0", "0.0"};
|
||||||
std::string targetName;
|
std::string targetName;
|
||||||
std::string angle;
|
std::string angle = "0.0";
|
||||||
std::string trash;
|
std::string trash;
|
||||||
bool haveName = false;
|
bool haveName = false;
|
||||||
bool haveAngle = false;
|
|
||||||
|
|
||||||
|
|
||||||
if ( lines.size() < 3 ) {
|
if ( lines.size() < 3 ) {
|
||||||
@ -504,7 +503,6 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
|||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
makeErrorMessage( "error: Target entity requires target angle if specified", lines ));
|
makeErrorMessage( "error: Target entity requires target angle if specified", lines ));
|
||||||
}
|
}
|
||||||
haveAngle = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -538,12 +536,10 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
|||||||
targetStream << "\"targetname\" \"" << targetName << "\"" << std::endl;
|
targetStream << "\"targetname\" \"" << targetName << "\"" << std::endl;
|
||||||
convertedLines.push_back ( targetStream.str() );
|
convertedLines.push_back ( targetStream.str() );
|
||||||
|
|
||||||
// Write angle only if position and name exist
|
// write angle every time
|
||||||
if ( haveAngle ) {
|
|
||||||
std::stringstream angleStream;
|
std::stringstream angleStream;
|
||||||
angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl;
|
angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl;
|
||||||
convertedLines.push_back( angleStream.str() );
|
convertedLines.push_back( angleStream.str() );
|
||||||
}
|
|
||||||
return convertedLines;
|
return convertedLines;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -362,6 +362,17 @@ TEST_CASE( "r2x: a single Teleporter and related Target can be converted", "[Ent
|
|||||||
REQUIRE( coords[0] == "\"-216.00000" );
|
REQUIRE( coords[0] == "\"-216.00000" );
|
||||||
REQUIRE( coords[1] == "-1488.000488" );
|
REQUIRE( coords[1] == "-1488.000488" );
|
||||||
REQUIRE( fabs(-100.00000 - offsetCoord) <= DELTA );
|
REQUIRE( fabs(-100.00000 - offsetCoord) <= DELTA );
|
||||||
|
|
||||||
|
SECTION( "When angle unspecified, defaults to 0.0 (converted to 90.0)" ) {
|
||||||
|
std::istringstream angleStream(converted2[3]);
|
||||||
|
std::string a;
|
||||||
|
float angle;
|
||||||
|
angleStream >> attribute >> a;
|
||||||
|
a.erase(a.begin()); //removing preceding quote is necessary
|
||||||
|
std::stringstream out(a);
|
||||||
|
out >> angle;
|
||||||
|
REQUIRE( fabs(90.0 - angle) <= DELTA );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user