Added default case for target angles, fixes pocket-infinity conversion
This commit is contained in:
parent
34cd34df8f
commit
130cf2d762
@ -466,10 +466,9 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
||||
//position and name required, angles optional
|
||||
std::string coords[3] = {"0.0", "0.0", "0.0"};
|
||||
std::string targetName;
|
||||
std::string angle;
|
||||
std::string angle = "0.0";
|
||||
std::string trash;
|
||||
bool haveName = false;
|
||||
bool haveAngle = false;
|
||||
|
||||
|
||||
if ( lines.size() < 3 ) {
|
||||
@ -504,7 +503,6 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
||||
throw std::runtime_error(
|
||||
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;
|
||||
convertedLines.push_back ( targetStream.str() );
|
||||
|
||||
// Write angle only if position and name exist
|
||||
if ( haveAngle ) {
|
||||
// write angle every time
|
||||
std::stringstream angleStream;
|
||||
angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl;
|
||||
convertedLines.push_back( angleStream.str() );
|
||||
}
|
||||
return convertedLines;
|
||||
}
|
||||
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[1] == "-1488.000488" );
|
||||
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