diff --git a/ReflexToQ3/includes/EntityConverter.cpp b/ReflexToQ3/includes/EntityConverter.cpp index 2ae0b92..73e3b16 100644 --- a/ReflexToQ3/includes/EntityConverter.cpp +++ b/ReflexToQ3/includes/EntityConverter.cpp @@ -466,10 +466,9 @@ EntityConverter::convertTarget(const std::vector &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 &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 &lines) const targetStream << "\"targetname\" \"" << targetName << "\"" << std::endl; convertedLines.push_back ( targetStream.str() ); - // Write angle only if position and name exist - if ( haveAngle ) { - std::stringstream angleStream; - angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl; - convertedLines.push_back( angleStream.str() ); - } + // write angle every time + std::stringstream angleStream; + angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl; + convertedLines.push_back( angleStream.str() ); return convertedLines; } else { diff --git a/ReflexToQ3/test/catch.cpp b/ReflexToQ3/test/catch.cpp index 931d415..d63ae36 100644 --- a/ReflexToQ3/test/catch.cpp +++ b/ReflexToQ3/test/catch.cpp @@ -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 ); + } }