Error messages made more clear

This commit is contained in:
suhrke 2017-07-17 13:16:59 -07:00
parent 36f3aa0a1b
commit 168818b9b0
2 changed files with 22 additions and 53 deletions

View File

@ -249,7 +249,7 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
if ( lines.size() < 2 ) { if ( lines.size() < 2 ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup entity requires at least type and ID", lines )); makeErrorMessage( "error: Pickup entity requires minimum of two lines (type and ID)", lines ));
} }
for (int i = 1; i < lines.size(); i++) { for (int i = 1; i < lines.size(); i++) {
@ -260,7 +260,7 @@ EntityConverter::convertPickup(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: Pickup entity requires coordinates", lines )); makeErrorMessage( "error: Invalid Pickup position", lines ));
} }
} }
else if ( type == "pickupType" ) { else if ( type == "pickupType" ) {
@ -268,7 +268,7 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
// UInt8 pickupType ID // UInt8 pickupType ID
if ( ! (iss >> trash >> trash >> pickupID) ) { if ( ! (iss >> trash >> trash >> pickupID) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup entity requires Pickup ID", lines )); makeErrorMessage( "error: Format of Pickup ID line is invalid", lines ));
} }
havePickupID = true; havePickupID = true;
} }
@ -278,12 +278,12 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
auto pickupIter = pickupMap_.find(pickupID); auto pickupIter = pickupMap_.find(pickupID);
if ( pickupIter == pickupMap_.end() ) { if ( pickupIter == pickupMap_.end() ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup ID must be valid", lines )); makeErrorMessage( "error: Pickup ID is invalid", lines ));
} }
std::stringstream pickupStream; std::stringstream pickupStream;
pickupStream << "\"classname\" \"" << pickupIter->second << "\"" << std::endl; pickupStream << "\"classname\" \"" << pickupIter->second << "\"" << std::endl;
convertedLines.push_back ( pickupStream.str() ); convertedLines.push_back ( pickupStream.str() );
// coordinates reordered to x, z, y // coordinates reordered to x, z, yentity
std::stringstream positionStream; std::stringstream positionStream;
positionStream << "\"origin\" \"" << coords[0] << " " << coords[2] << " " << positionStream << "\"origin\" \"" << coords[0] << " " << coords[2] << " " <<
offset(coords[1], OFFSET_PICKUP) << "\"" << std::endl; offset(coords[1], OFFSET_PICKUP) << "\"" << std::endl;
@ -292,7 +292,7 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
} }
else { else {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup requires position and pickup ID, missing 1 or both", lines )); makeErrorMessage( "error: Pickup ID was not in the entity", lines ));
} }
} }
@ -335,7 +335,7 @@ 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 must have valid position coordinates if specified", lines )); makeErrorMessage( "error: Invalid PlayerSpawn position", lines ));
} }
} }
else if ( type == "angles" ) { else if ( type == "angles" ) {
@ -343,7 +343,7 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
// UInt8 pickupType ID // UInt8 pickupType ID
if ( ! (iss >> trash >> trash >> angle )) { if ( ! (iss >> trash >> trash >> angle )) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Pickup entity requires Pickup ID", lines )); makeErrorMessage( "error: Invalid PlayerSpawn angle", lines ));
} }
} }
// Bool8 modeX 0 indicates this spawn is not for game mode X // Bool8 modeX 0 indicates this spawn is not for game mode X
@ -414,13 +414,13 @@ EntityConverter::convertJumpPad(const std::vector<std::string> &lines) const
if ( lines.size() < 2 ) { if ( lines.size() < 2 ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: JumpPad entity requires at least type and target name", lines )); makeErrorMessage( "error: JumpPad entity requires minimum of two lines (type and target)", lines ));
} }
std::istringstream iss(lines[1]); std::istringstream iss(lines[1]);
// String32 target targetName // String32 target targetName
if ( ! (iss >> trash >> trash >> targetName) ) { if ( ! (iss >> trash >> trash >> targetName) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: JumpPad entity requires target name", lines )); makeErrorMessage( "error: Invalid JumpPad target", lines ));
} }
convertedLines.push_back ( "\"classname\" \"trigger_push\"\n" ); convertedLines.push_back ( "\"classname\" \"trigger_push\"\n" );
@ -441,13 +441,13 @@ EntityConverter::convertTeleporter(const std::vector<std::string> &lines) const
if ( lines.size() < 2 ) { if ( lines.size() < 2 ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Teleport entity requires at least type and target name", lines )); makeErrorMessage( "error: Teleport entity requires minimum of two lines (type and target)", lines ));
} }
std::istringstream iss(lines[1]); std::istringstream iss(lines[1]);
// String32 target targetName // String32 target targetName
if ( ! (iss >> trash >> trash >> targetName) ) { if ( ! (iss >> trash >> trash >> targetName) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Teleport entity requires target name", lines )); makeErrorMessage( "error: Invalid Teleport target", lines ));
} }
convertedLines.push_back ( "\"classname\" \"trigger_teleport\"\n" ); convertedLines.push_back ( "\"classname\" \"trigger_teleport\"\n" );
@ -473,7 +473,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
if ( lines.size() < 3 ) { if ( lines.size() < 3 ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Target entity requires at least type and name", lines )); makeErrorMessage( "error: Target entity requires minimum of two lines (type and name)", lines ));
} }
for (int i = 1; i < lines.size(); i++) { for (int i = 1; i < lines.size(); i++) {
@ -484,7 +484,7 @@ EntityConverter::convertTarget(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: Target entity requires coordinates", lines )); makeErrorMessage( "error: Invalid Target position", lines ));
} }
} }
else if ( type == "name" ) { else if ( type == "name" ) {
@ -492,7 +492,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
// UInt8 name uniqueName // UInt8 name uniqueName
if ( ! (iss >> trash >> trash >> targetName) ) { if ( ! (iss >> trash >> trash >> targetName) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Target entity requires target name", lines )); makeErrorMessage( "error: Invalid Target \"target\"", lines ));
} }
haveName = true; haveName = true;
} }
@ -501,7 +501,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
// Vector3 angles angle notapplicable notapplicable // Vector3 angles angle notapplicable notapplicable
if ( ! (iss >> trash >> trash >> angle) ) { if ( ! (iss >> trash >> trash >> angle) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Target entity requires target angle if specified", lines )); makeErrorMessage( "error: Invalid Target angle", lines ));
} }
} }
@ -510,7 +510,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
if ( haveName) { if ( haveName) {
auto targetIter = targetMap_.find(targetName); auto targetIter = targetMap_.find(targetName);
if ( targetIter == targetMap_.end() ) { if ( targetIter == targetMap_.end() ) {
std::cerr << makeErrorMessage("EntityConverter doesn't know what the source of a Target entity with the following attributes. This entity will not be converted. It is probably an unsupported entity type or feature. (e.g. game over camera)", lines); std::cerr << makeErrorMessage("End-game camera Target is not a supported feature in id Tech games. This entity will not be converted", lines);
std::vector<std::string> empty; std::vector<std::string> empty;
return empty; return empty;
@ -544,7 +544,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
} }
else { else {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: Target entity requires position coordinates and targetname", lines )); makeErrorMessage( "error: \"target\" was not found in this Target entity", lines ));
} }
} }
@ -592,7 +592,7 @@ EntityConverter::convertPointLight(const std::vector<std::string> &lines) const
if ( lines.size() < 2 ) { if ( lines.size() < 2 ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: PointLight entity requires at least type", lines )); makeErrorMessage( "error: PointLight entity requires at least one line (type)", lines ));
} }
for (int i = 1; i < lines.size(); i++) { for (int i = 1; i < lines.size(); i++) {
@ -603,7 +603,7 @@ EntityConverter::convertPointLight(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: PointLight entity requires valid position coordinates", lines )); makeErrorMessage( "error: Invalid PointLight position", lines ));
} }
} }
else if ( type == "intensity" ) { else if ( type == "intensity" ) {
@ -611,7 +611,7 @@ EntityConverter::convertPointLight(const std::vector<std::string> &lines) const
// Float intensity validFloat // Float intensity validFloat
if ( ! (iss >> trash >> trash >> intensity) ) { if ( ! (iss >> trash >> trash >> intensity) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: PointLight intensity keyword must be followed by a value", lines )); makeErrorMessage( "error: Invalid PointLight intensity", lines ));
} }
} }
else if ( type == "color" ) { else if ( type == "color" ) {
@ -619,7 +619,7 @@ EntityConverter::convertPointLight(const std::vector<std::string> &lines) const
// ColourXRGB32 color eightDigitHexValue // ColourXRGB32 color eightDigitHexValue
if ( ! (iss >> trash >> trash >> color) ) { if ( ! (iss >> trash >> trash >> color) ) {
throw std::runtime_error( throw std::runtime_error(
makeErrorMessage( "error: PointLight color keyword must be followed by a value", lines )); makeErrorMessage( "error: Invalid PointLight color", lines ));
} }
haveColor = true; haveColor = true;
} }

View File

@ -1,31 +0,0 @@
=======================
=The Reflex Map Format=
=======================
Worldspawn contains all brushes and entities. The maps I've seen contain only a single Worldspawn.
"Pickup" denoted by ID number. We stored the Reflex to Xonotic conversion in r2x.pck
<Table of ID to their pickup name>
"PlayerSpawn" consists of coordinate (Vector3),
angle (first element of Vector3),
team indicator (on individual lines),
game type indicator (on individual lines)
-"JumpPad" stored as a brush and a Target
-"Teleporter" stored as a brush and a Target
-"Target" stored as a position (Vector3) and
a "name" (String32)
***Target can be destination of teleports OR jump pads
-"RaceStart" stored as a brush
-"RaceFinish" stored as a brush
That's all we have converted so far but we intend to convert Effect,
PointLight, Prefab, CameraPath, and possibly liquids.