Skip to content

Commit

Permalink
Handle empty lines in HoI4 province definitions (#1707)
Browse files Browse the repository at this point in the history
  • Loading branch information
cetvrtak authored Jun 30, 2024
1 parent f7057cf commit be71cbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/HOI4World/Map/HoI4ProvinceDefinitionImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
auto pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
auto provNum = stoi(line.substr(0, pos));
if (provNum == 0)
Expand All @@ -47,7 +47,7 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
const int red(stoi(line.substr(0, pos)));
line = line.substr(pos + 1, line.length());
Expand All @@ -56,7 +56,7 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
const int green(stoi(line.substr(0, pos)));
line = line.substr(pos + 1, line.length());
Expand All @@ -65,7 +65,7 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
const int blue(stoi(line.substr(0, pos)));
line = line.substr(pos + 1, line.length());
Expand All @@ -77,7 +77,7 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
const std::string landOrSea = line.substr(0, pos);
line = line.substr(pos + 1, line.length());
Expand All @@ -94,15 +94,15 @@ Maps::ProvinceDefinitions HoI4::importProvinceDefinitions(const std::string& pat
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
line = line.substr(pos + 1, line.length());

// terrain
pos = line.find_first_of(';');
if (pos == std::string::npos)
{
break;
continue;
}
const std::string terrain = line.substr(0, pos);
line = line.substr(pos + 1, line.length());
Expand Down
4 changes: 4 additions & 0 deletions src/HOI4World/Map/HoI4Provinces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ std::map<int, HoI4::Province> HoI4::importProvinces(const Configuration& theConf
}

auto IDSeparator = line.find_first_of(';');
if (IDSeparator == std::string::npos)
{
continue;
}
auto ID = stoi(line.substr(0, IDSeparator));
if (ID == 0)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Mappers/Provinces/ProvinceMapperFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ void checkAllHoI4ProvincesMapped(const Mappers::VersionedMappings& versionedMapp

while (true)
{
if (definitions.eof())
{
break;
}
auto provNum = getNextProvinceNumFromFile(definitions);
if (!provNum)
{
break;
continue;
}
if (*provNum == 0)
{
Expand Down

0 comments on commit be71cbb

Please sign in to comment.