aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Province.cpp
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-09-19 14:09:19 +0200
committer zaaarf <zaaarf@proton.me>2023-09-19 17:33:15 +0200
commit3017b6338ca67c0c18f404cf8e162918e36e94e7 (patch)
tree688d961ebddd6efdf910e90601c0ed5ce2740e48 /src/openvic-simulation/map/Province.cpp
parent5ece48b0bf738a14a4464d09f29468b9dffdbe05 (diff)
fix: adjacency algorithm optimisiations and fixes
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r--src/openvic-simulation/map/Province.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 8dcaa42..19dd873 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -138,24 +138,22 @@ void Province::tick(Date const& today) {
building.tick(today);
}
-Province::adjacency_t::adjacency_t(index_t new_provice_id, distance_t new_distance, flags_t new_flags) {
- assert(new_provice_id != Province::NULL_INDEX);
- province_id = new_provice_id;
- distance = new_distance;
- flags = new_flags;
+Province::adjacency_t::adjacency_t(Province const* province, distance_t distance, flags_t flags)
+ : province { province }, distance { distance }, flags { flags } {
+ assert(province != nullptr);
}
-bool Province::is_adjacent_to(index_t province_index) {
+bool Province::is_adjacent_to(Province const* province) {
for (adjacency_t adj : adjacencies)
- if (adj.province_id == province_index)
+ if (adj.province->index == province->index)
return true;
return false;
}
-bool Province::add_adjacency(index_t province_index, distance_t distance, flags_t flags) {
- if (is_adjacent_to(province_index))
+bool Province::add_adjacency(Province const* province, distance_t distance, flags_t flags) {
+ if (is_adjacent_to(province))
return false;
- adjacencies.push_back({ province_index, distance, flags });
+ adjacencies.push_back({ province, distance, flags });
return true;
}