aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Map.cpp
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2023-12-13 21:21:10 +0100
committer GitHub <noreply@github.com>2023-12-13 21:21:10 +0100
commit2e4110b26281605dde3e10f2183572d22bf773fc (patch)
tree9ba33c2c8800a11ef59acbba711a7230dcf2dc05 /src/openvic-simulation/map/Map.cpp
parente79ad08e28c07bac5d28d0653cbe374cd51e6bbe (diff)
parent2c383640d699680e99c79f0aa2601df9e0843f00 (diff)
Merge pull request #96 from OpenVicProject/calculate_distances
Calculate distance between adjacencies
Diffstat (limited to 'src/openvic-simulation/map/Map.cpp')
-rw-r--r--src/openvic-simulation/map/Map.cpp8
1 files changed, 5 insertions, 3 deletions
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;
};