diff options
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 }); |