From 2c383640d699680e99c79f0aa2601df9e0843f00 Mon Sep 17 00:00:00 2001 From: wvpm <24685035+wvpm@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:56:26 +0100 Subject: Calculate distance between adjacencies --- src/openvic-simulation/map/Map.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/openvic-simulation/map/Map.cpp') diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp index b272f1f..1e68cc6 100644 --- a/src/openvic-simulation/map/Map.cpp +++ b/src/openvic-simulation/map/Map.cpp @@ -612,10 +612,12 @@ bool Map::load_map_images(fs::path const& province_path, fs::path const& terrain bool Map::_generate_province_adjacencies() { bool changed = false; - auto generate_adjacency = [&](Province* cur, size_t x, size_t y) -> bool { + auto generate_adjacency = [&](Province* current, size_t x, size_t y) -> bool { Province* neighbour = get_province_by_index(province_shape_image[x + y * width].index); - if (neighbour != nullptr && cur != neighbour) { - return cur->add_adjacency(neighbour, 0, 0) | neighbour->add_adjacency(cur, 0, 0); + if (neighbour != nullptr && current != neighbour) { + const Province::distance_t distance = current->calculate_distance_to(neighbour); + const Province::flags_t flags = 0; + return current->add_adjacency(neighbour, distance, flags) | neighbour->add_adjacency(current, distance, flags); } return false; }; -- cgit v1.2.3-56-ga3b1