diff options
author | zaaarf <zaaarf@proton.me> | 2023-09-19 18:07:11 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-09-19 18:07:11 +0200 |
commit | 88948eb11127c6d3442fbd476f7b456643b58728 (patch) | |
tree | 46ae571e7dddc83ebc7e87ae83726356d0f71934 /src/openvic-simulation/map/Province.cpp | |
parent | 3017b6338ca67c0c18f404cf8e162918e36e94e7 (diff) |
fix: various tweaks during review
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r-- | src/openvic-simulation/map/Province.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp index 19dd873..db7e784 100644 --- a/src/openvic-simulation/map/Province.cpp +++ b/src/openvic-simulation/map/Province.cpp @@ -1,7 +1,9 @@ #include "Province.hpp" #include <cassert> +#include <cstddef> #include <iomanip> +#include <iterator> #include <sstream> using namespace OpenVic; @@ -143,14 +145,27 @@ Province::adjacency_t::adjacency_t(Province const* province, distance_t distance assert(province != nullptr); } +Province::distance_t Province::adjacency_t::get_distance() const { + return distance; +} + +Province::flags_t Province::adjacency_t::get_flags() { + return flags; +} + bool Province::is_adjacent_to(Province const* province) { for (adjacency_t adj : adjacencies) - if (adj.province->index == province->index) + if (adj.province == province) return true; return false; } bool Province::add_adjacency(Province const* province, distance_t distance, flags_t flags) { + if (province == nullptr) { + Logger::error("Tried to create null adjacency province for province ", get_identifier(), "!"); + return false; + } + if (is_adjacent_to(province)) return false; adjacencies.push_back({ province, distance, flags }); |