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

Hack to make Novgorod a last-choice region to work around a hoi4 bug #1681

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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
13 changes: 10 additions & 3 deletions src/HOI4World/Map/StrategicRegions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace
{

[[no_discard]] std::map<int, int> DetermineUsedRegions(const HoI4::State& state,
[[nodiscard]] std::map<int, int> DetermineUsedRegions(const HoI4::State& state,
const std::map<int, int>& province_to_strategic_region_map)
{
std::map<int, int> used_regions; // region ID -> number of provinces in that region
Expand All @@ -30,11 +30,18 @@ namespace
}
}

// hack to make Novgorod a last-choice region to work around this hoi4 bug:
// https://forum.paradoxplaza.com/forum/threads/crash-due-to-some-strategic-regions.1619874/
if (used_regions.contains(132))
{
used_regions[132] = 1;
}

return used_regions;
}


[[no_discard]] std::optional<int> DetermineMostUsedRegion(const std::map<int, int>& used_regions)
[[nodiscard]] std::optional<int> DetermineMostUsedRegion(const std::map<int, int>& used_regions)
{
if (!used_regions.empty())
{
Expand All @@ -60,7 +67,7 @@ void AddProvinceToRegion(int region_number, int province_id, std::map<int, HoI4:
}


[[no_discard]] std::set<int> DetermineAssignedProvinces(const std::map<int, HoI4::StrategicRegion>& strategic_regions)
[[nodiscard]] std::set<int> DetermineAssignedProvinces(const std::map<int, HoI4::StrategicRegion>& strategic_regions)
{
std::set<int> assigned_provinces;
for (const HoI4::StrategicRegion& strategic_region: strategic_regions | std::ranges::views::values)
Expand Down