diff options
author | hop311 <hop3114@gmail.com> | 2023-11-04 19:44:38 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-11-07 19:34:51 +0100 |
commit | b5bbeb47febc823517a5baba4eca66f32fb3609c (patch) | |
tree | 1a78d296f22d1cd17a84ce824974f9438a197074 /src/openvic-simulation/military | |
parent | c1b7cab254ac14a173477661047ad2492930ff8b (diff) |
Cross-platform file lookup (case and separator)
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r-- | src/openvic-simulation/military/Deployment.cpp | 16 | ||||
-rw-r--r-- | src/openvic-simulation/military/LeaderTrait.hpp | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/openvic-simulation/military/Deployment.cpp b/src/openvic-simulation/military/Deployment.cpp index b5d335a..0530986 100644 --- a/src/openvic-simulation/military/Deployment.cpp +++ b/src/openvic-simulation/military/Deployment.cpp @@ -37,9 +37,6 @@ bool DeploymentManager::add_deployment( Logger::error("Attemped to load order of battle with no path! Something is very wrong!"); return false; } - if (armies.empty() && navies.empty() && leaders.empty()) { - Logger::warning("Loading redundant empty order of battle at ", path); - } return deployments.add_item( std::make_unique<Deployment>(std::move(path), std::move(armies), std::move(navies), std::move(leaders)) @@ -47,8 +44,8 @@ bool DeploymentManager::add_deployment( } bool DeploymentManager::load_oob_file( - GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path, Deployment const*& deployment, - bool fail_on_missing + GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path, + Deployment const*& deployment, bool fail_on_missing ) { deployment = get_deployment_by_identifier(history_path); if (deployment != nullptr) { @@ -57,14 +54,13 @@ bool DeploymentManager::load_oob_file( if (missing_oob_files.contains(history_path)) { return !fail_on_missing; } - static const fs::path oob_directory = "history/units/"; - fs::path full_path = oob_directory; - full_path += history_path; - const fs::path lookedup_path = dataloader.lookup_file(full_path, false); + static constexpr std::string_view oob_directory = "history/units/"; + const fs::path lookedup_path = + dataloader.lookup_file(StringUtils::append_string_views(oob_directory, history_path), false); if (lookedup_path.empty()) { missing_oob_files.emplace(history_path); if (fail_on_missing) { - Logger::warning("Could not find OOB file ", full_path, "!"); + Logger::warning("Could not find OOB file ", history_path, "!"); return false; } else { return true; diff --git a/src/openvic-simulation/military/LeaderTrait.hpp b/src/openvic-simulation/military/LeaderTrait.hpp index e61a1fc..16b4201 100644 --- a/src/openvic-simulation/military/LeaderTrait.hpp +++ b/src/openvic-simulation/military/LeaderTrait.hpp @@ -46,7 +46,7 @@ namespace OpenVic { struct LeaderTraitManager { private: IdentifierRegistry<LeaderTrait> leader_traits; - inline static const string_set_t allowed_modifiers = { + static inline const string_set_t allowed_modifiers = { "attack", "defence", "morale", "organisation", "reconnaissance", "speed", "attrition", "experience", "reliability" }; |