Player spawns added to entity file, used by EntityConverter
This commit is contained in:
@@ -79,12 +79,11 @@ EntityConverter::EntityConverter(const std::string &entityMapFile,
|
||||
else {
|
||||
throw std::ios::failure( "Error: EntityConverter failed to open .map file " + reflexMapFile );
|
||||
}
|
||||
fin.close();
|
||||
haveMapInfo_ = true;
|
||||
|
||||
//DEBUG
|
||||
//printMapping();
|
||||
//printTargetSources();
|
||||
fin.close();
|
||||
|
||||
if (haveRequiredMappings())
|
||||
haveMapInfo_ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +110,8 @@ EntityConverter::extractMapInfo(std::queue<std::vector<std::string>> entities)
|
||||
}
|
||||
}
|
||||
|
||||
haveMapInfo_ = true;
|
||||
if (haveRequiredMappings())
|
||||
haveMapInfo_ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -371,15 +371,21 @@ EntityConverter::convertPlayerSpawn(const std::vector<std::string> &lines) const
|
||||
}
|
||||
|
||||
if ( isModeCtf || isModeTdm || isModeFfa || isModeDuel ) {
|
||||
std::stringstream ss;
|
||||
std::map<std::string, std::string>::const_iterator it;
|
||||
switch (team) {
|
||||
case 0:
|
||||
convertedLines.push_back ( "\"classname\" \"info_player_deathmatch\"\n" );
|
||||
convertedLines.push_back ("\"classname\" \"info_player_deathmatch\"\n" );
|
||||
break;
|
||||
case 1:
|
||||
convertedLines.push_back ( "\"classname\" \"info_player_team1\"\n" );
|
||||
case 1:
|
||||
it = entityMap_.find("team1");
|
||||
ss << "\"classname\" \"" << it->second << "\"" << std::endl;
|
||||
convertedLines.push_back (ss.str());
|
||||
break;
|
||||
case 2:
|
||||
convertedLines.push_back ( "\"classname\" \"info_player_team2\"\n" );
|
||||
it = entityMap_.find("team2");
|
||||
ss << "\"classname\" \"" << it->second << "\"" << std::endl;
|
||||
convertedLines.push_back (ss.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -698,6 +704,24 @@ EntityConverter::mapEntities(const std::string &mapFile)
|
||||
|
||||
|
||||
|
||||
bool
|
||||
EntityConverter::haveRequiredMappings()
|
||||
{
|
||||
std::vector<std::string> required = { "team1",
|
||||
"team2" };
|
||||
for (std::string id : required) {
|
||||
auto pickupIter = entityMap_.find(id);
|
||||
if ( pickupIter == entityMap_.end() ) {
|
||||
throw std::runtime_error ("error: Missing required entity mappings");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
EntityConverter::extractFromEntity(const std::string &line, std::istream &is)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user