fixed error with unmatched target and source
This commit is contained in:
parent
9f32ca0568
commit
821d6001bf
@ -262,8 +262,12 @@ EntityConverter::convertPickup(const std::vector<std::string> &lines) const
|
||||
}
|
||||
|
||||
if ( havePosition && havePickupID ) {
|
||||
auto pickupIter = pickupMap_.find(pickupID);
|
||||
if ( pickupIter == pickupMap_.end() ) {
|
||||
throw std::runtime_error("error: Pickup ID must be valid");
|
||||
}
|
||||
std::stringstream pickupStream;
|
||||
pickupStream << "\"classname\" \"" << pickupMapping_.find(pickupID)->second << "\"" << std::endl;
|
||||
pickupStream << "\"classname\" \"" << pickupIter->second << "\"" << std::endl;
|
||||
convertedLines.push_back ( pickupStream.str() );
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream positionStream;
|
||||
@ -493,7 +497,20 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
||||
}
|
||||
|
||||
if ( havePosition && haveName) {
|
||||
if ( targetMap_.find(targetName)->second == "Teleporter") {
|
||||
auto targetIter = targetMap_.find(targetName);
|
||||
if ( targetIter == targetMap_.end() ) {
|
||||
std::cerr << "EntityConverter doesn't know what the source of a Target entity with the "
|
||||
<< "following attributes. It is probably an unsupported entity type or feature. "
|
||||
<< "(game over camera, etc). Returning an empty vector." << std::endl;
|
||||
std::vector<std::string>::const_iterator it;
|
||||
for ( it=lines.begin(); it!=lines.end(); ++it ) {
|
||||
std::cerr << *it << std::endl;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
std::vector<std::string> empty;
|
||||
return empty;
|
||||
}
|
||||
if ( targetIter->second == "Teleporter") {
|
||||
convertedLines.push_back ( "\"classname\" \"misc_teleporter_dest\"\n" );
|
||||
// coordinates reordered to x, z, y
|
||||
// teleporter height is OFFSET
|
||||
@ -502,7 +519,7 @@ EntityConverter::convertTarget(const std::vector<std::string> &lines) const
|
||||
offset(coords[1], OFFSET_PLAYER) << "\"" << std::endl;
|
||||
convertedLines.push_back ( oss.str() );
|
||||
}
|
||||
else if ( targetMap_.find(targetName)->second == "JumpPad") {
|
||||
else if ( targetIter->second == "JumpPad") {
|
||||
convertedLines.push_back ( "\"classname\" \"target_position\"\n" );
|
||||
// coordinates reordered to x, z, y
|
||||
std::stringstream oss;
|
||||
@ -669,7 +686,7 @@ EntityConverter::mapEntities(const std::string &mapFile)
|
||||
if ( ! (iss >> id >> pickup)) {
|
||||
throw std::runtime_error( "format error in .ent file" );
|
||||
}
|
||||
pickupMapping_.insert ( std::pair<int, std::string>(id, pickup) );
|
||||
pickupMap_.insert ( std::pair<int, std::string>(id, pickup) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -756,7 +773,7 @@ EntityConverter::printMapping() const
|
||||
{
|
||||
std::cout << std::endl << "Reflex pickup ID mapped to Xonotic pickup names: " << std::endl;
|
||||
std::map<int, std::string>::const_iterator it;
|
||||
for ( it=pickupMapping_.begin(); it!=pickupMapping_.end(); ++it )
|
||||
for ( it=pickupMap_.begin(); it!=pickupMap_.end(); ++it )
|
||||
std::cout << it->first << " => " << it->second << std::endl;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ class EntityConverter
|
||||
|
||||
|
||||
// Map Reflex pickup IDs to Xonotic pickup identifiers
|
||||
std::map<int, std::string> pickupMapping_;
|
||||
std::map<int, std::string> pickupMap_;
|
||||
// Map targets (by name) to their source type
|
||||
std::map<std::string, std::string> targetMap_;
|
||||
// Related entities must be matched prior to entity conversion
|
||||
@ -165,7 +165,7 @@ class EntityConverter
|
||||
*--------------------------------------------------------------------------------------
|
||||
* Class: EntityConverter
|
||||
* Method: EntityConverter :: mapEntities
|
||||
* Description: Prepare pickupMapping_
|
||||
* Description: Prepare pickupMap
|
||||
* Parameter: string mapFile, filename of pickup mapping
|
||||
* Return: true if no error, false if error
|
||||
*--------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user