PlayerSpawn defaults to 0,0,0 if position unspecified
This commit is contained in:
parent
e52d284142
commit
11f8989558
@ -315,13 +315,12 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
|
|||||||
{
|
{
|
||||||
std::vector<std::string> convertedLines;
|
std::vector<std::string> convertedLines;
|
||||||
// Requires position coordinate
|
// 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)
|
// Requires an angle, default to 0 degrees (floating point)
|
||||||
std::string angle("0.0");
|
std::string angle("0.0");
|
||||||
// 1-2 for corresponding team, 0 for deathmatch spawn
|
// 1-2 for corresponding team, 0 for deathmatch spawn
|
||||||
int team = 0;
|
int team = 0;
|
||||||
std::string trash;
|
std::string trash;
|
||||||
bool havePosition = false;
|
|
||||||
bool isModeRace = ws_.cts;
|
bool isModeRace = ws_.cts;
|
||||||
bool isModeCtf = ws_.ctf;
|
bool isModeCtf = ws_.ctf;
|
||||||
bool isModeTdm = ws_.tdm;
|
bool isModeTdm = ws_.tdm;
|
||||||
@ -329,10 +328,6 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
|
|||||||
bool isModeDuel = ws_.duel;
|
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++) {
|
for (int i = 1; i < lines.size(); i++) {
|
||||||
std::string type = getAttributeType(lines[i]);
|
std::string type = getAttributeType(lines[i]);
|
||||||
@ -342,9 +337,8 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
|
|||||||
if ( ! (iss >> trash >> trash >>
|
if ( ! (iss >> trash >> trash >>
|
||||||
coords[0] >> coords[1] >> coords[2])) {
|
coords[0] >> coords[1] >> coords[2])) {
|
||||||
throw std::runtime_error(
|
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" ) {
|
else if ( type == "angles" ) {
|
||||||
std::istringstream iss(lines[i]);
|
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 ) {
|
if ( isModeCtf || isModeTdm || isModeFfa || isModeDuel ) {
|
||||||
switch (team) {
|
switch (team) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -409,11 +402,7 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
|
|||||||
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 {
|
|
||||||
throw std::runtime_error(
|
|
||||||
makeErrorMessage( "error: PlayerSpawn entity requires position coordinates", lines ));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user