From b5bbeb47febc823517a5baba4eca66f32fb3609c Mon Sep 17 00:00:00 2001 From: hop311 Date: Sat, 4 Nov 2023 18:44:38 +0000 Subject: Cross-platform file lookup (case and separator) --- src/openvic-simulation/military/Deployment.cpp | 16 ++++++---------- src/openvic-simulation/military/LeaderTrait.hpp | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/openvic-simulation/military') 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(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 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" }; -- cgit v1.2.3-56-ga3b1