aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-11-06 21:39:40 +0100
committer hop311 <hop3114@gmail.com>2023-11-07 19:35:38 +0100
commitd30421fa7d7f6ad87d3f90cc0ab491742f0d2548 (patch)
tree601591215af0c6724766019ebb577141ea5807c5 /src/openvic-simulation/dataloader
parentb5bbeb47febc823517a5baba4eca66f32fb3609c (diff)
History loading generalisation
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp25
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.hpp9
2 files changed, 17 insertions, 17 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 0174eb3..6911de5 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -371,9 +371,7 @@ bool Dataloader::set_roots(path_vector_t const& new_roots) {
fs::path Dataloader::lookup_file(std::string_view path, bool print_error) const {
#if FILESYSTEM_NEEDS_FORWARD_SLASHES
/* Back-slashes need to be converted into forward-slashes */
- const std::string forward_slash_path {
- StringUtils::make_forward_slash_path(StringUtils::remove_leading_slashes(path))
- };
+ const std::string forward_slash_path { StringUtils::make_forward_slash_path(StringUtils::remove_leading_slashes(path)) };
path = forward_slash_path;
#endif
@@ -417,9 +415,7 @@ template<typename _DirIterator, std::predicate<fs::path const&, fs::path const&>
Dataloader::path_vector_t Dataloader::_lookup_files_in_dir(std::string_view path, fs::path const& extension) const {
#if FILESYSTEM_NEEDS_FORWARD_SLASHES
/* Back-slashes need to be converted into forward-slashes */
- const std::string forward_slash_path {
- StringUtils::make_forward_slash_path(StringUtils::remove_leading_slashes(path))
- };
+ const std::string forward_slash_path { StringUtils::make_forward_slash_path(StringUtils::remove_leading_slashes(path)) };
path = forward_slash_path;
#endif
const fs::path filepath { path };
@@ -440,8 +436,8 @@ Dataloader::path_vector_t Dataloader::_lookup_files_in_dir(std::string_view path
ret.push_back(file);
} else if (start_of_current_root_entries <= index) {
Logger::warning(
- "Files in the same directory with conflicting names: ", ret[index], " (accepted) and ",
- file, " (rejected)"
+ "Files in the same directory with conflicting names: ", ret[index], " (accepted) and ", file,
+ " (rejected)"
);
}
}
@@ -641,7 +637,7 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi
);
}
);
- game_manager.get_history_manager().get_province_manager().lock_province_histories();
+ game_manager.get_history_manager().get_province_manager().lock_province_histories(game_manager.get_map(), false);
return ret;
}
@@ -664,8 +660,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const {
static constexpr std::string_view default_region_sea = "region_sea.txt";
static constexpr std::string_view default_province_flag_sprite = "province_flag_sprites";
- const v2script::Parser parser =
- parse_defines(lookup_file(append_string_views(map_directory, defaults_filename)));
+ const v2script::Parser parser = parse_defines(lookup_file(append_string_views(map_directory, defaults_filename)));
std::vector<std::string_view> water_province_identifiers;
@@ -719,9 +714,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const {
Logger::error("Failed to load map default file!");
}
- if (!map.load_province_definitions(
- parse_csv(lookup_file(append_string_views(map_directory, definitions))).get_lines()
- )) {
+ if (!map.load_province_definitions(parse_csv(lookup_file(append_string_views(map_directory, definitions))).get_lines())) {
Logger::error("Failed to load province definitions file!");
ret = false;
}
@@ -734,9 +727,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const {
ret = false;
}
- if (!map.load_region_file(
- parse_defines(lookup_file(append_string_views(map_directory, region))).get_file_node()
- )) {
+ if (!map.load_region_file(parse_defines(lookup_file(append_string_views(map_directory, region))).get_file_node())) {
Logger::error("Failed to load region file!");
ret = false;
}
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp
index 4d56488..a23fb4f 100644
--- a/src/openvic-simulation/dataloader/NodeTools.hpp
+++ b/src/openvic-simulation/dataloader/NodeTools.hpp
@@ -4,6 +4,7 @@
#include <cstdint>
#include <functional>
#include <map>
+#include <optional>
#include <set>
#include <type_traits>
@@ -310,5 +311,13 @@ namespace OpenVic {
return true;
};
}
+
+ template<typename T>
+ Callback<T const&> auto assign_variable_callback_pointer(std::optional<T const*>& var) {
+ return [&var](T const& val) -> bool {
+ var = &val;
+ return true;
+ };
+ }
}
}