Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty lines in HoI4 province definitions #1707

Merged
merged 1 commit into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading