PlayerSpawn defaults to 0,0,0 if position unspecified

This commit is contained in:
suhrke 2017-07-11 22:26:21 -07:00
parent e52d284142
commit 11f8989558

View File

@ -315,13 +315,12 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
{
std::vector<std::string> convertedLines;
// Requires position coordinate
std::string coords[3];
std::string coords[3] = {"0.0", "0.0", "0.0"};
// Requires an angle, default to 0 degrees (floating point)
std::string angle("0.0");
// 1-2 for corresponding team, 0 for deathmatch spawn
int team = 0;
std::string trash;
bool havePosition = false;
bool isModeRace = ws_.cts;
bool isModeCtf = ws_.ctf;
bool isModeTdm = ws_.tdm;
@ -329,10 +328,6 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
bool isModeDuel = ws_.duel;
if ( lines.size() < 2 ) {
throw std::runtime_error(
makeErrorMessage( "error: PlayerSpawn entity requires at least 2 lines", lines ));
}
for (int i = 1; i < lines.size(); i++) {
std::string type = getAttributeType(lines[i]);
@ -342,9 +337,8 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
if ( ! (iss >> trash >> trash >>
coords[0] >> coords[1] >> coords[2])) {
throw std::runtime_error(
makeErrorMessage( "error: PlayerSpawn entity requires position coordinates", lines ));
makeErrorMessage( "error: PlayerSpawn entity must have valid position coordinates if specified", lines ));
}
havePosition = true;
}
else if ( type == "angles" ) {
std::istringstream iss(lines[i]);
@ -378,7 +372,6 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
}
}
if ( havePosition ) {
if ( isModeCtf || isModeTdm || isModeFfa || isModeDuel ) {
switch (team) {
case 0:
@ -409,11 +402,7 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
angleStream << "\"angle\" \"" << adjustAngleForHandedness(angle) << "\"" << std::endl;
convertedLines.push_back (angleStream.str() );
return convertedLines;
}
else {
throw std::runtime_error(
makeErrorMessage( "error: PlayerSpawn entity requires position coordinates", lines ));
}
}