From c1b7cab254ac14a173477661047ad2492930ff8b Mon Sep 17 00:00:00 2001 From: hop311 Date: Tue, 31 Oct 2023 01:11:47 +0000 Subject: History loading changes + PROPERTY macro --- src/openvic-simulation/military/Deployment.hpp | 84 +++++++++++++++++--------- 1 file changed, 55 insertions(+), 29 deletions(-) (limited to 'src/openvic-simulation/military/Deployment.hpp') diff --git a/src/openvic-simulation/military/Deployment.hpp b/src/openvic-simulation/military/Deployment.hpp index 34cf82a..ead324e 100644 --- a/src/openvic-simulation/military/Deployment.hpp +++ b/src/openvic-simulation/military/Deployment.hpp @@ -15,46 +15,69 @@ namespace OpenVic { struct Leader { - std::string name; - const Unit::type_t type; - const Date date; - LeaderTrait const* personality; - LeaderTrait const* background; - fixed_point_t prestige; + private: + std::string PROPERTY(name); + Unit::type_t PROPERTY(type); + Date PROPERTY(date); + LeaderTrait const* PROPERTY(personality); + LeaderTrait const* PROPERTY(background); + fixed_point_t PROPERTY(prestige); + + public: + Leader( + std::string_view new_name, Unit::type_t new_type, Date new_date, LeaderTrait const* new_personality, + LeaderTrait const* new_background, fixed_point_t new_prestige + ); }; struct Regiment { - std::string name; - Unit const* type; - Province const* home; + private: + std::string PROPERTY(name); + Unit const* PROPERTY(type); + Province const* PROPERTY(home); + + public: + Regiment(std::string_view new_name, Unit const* new_type, Province const* new_home); }; struct Ship { - std::string name; - Unit const* type; + private: + std::string PROPERTY(name); + Unit const* PROPERTY(type); + + public: + Ship(std::string_view new_name, Unit const* new_type); }; struct Army { - std::string name; - Province const* location; - std::vector regiments; + private: + std::string PROPERTY(name); + Province const* PROPERTY(location); + std::vector PROPERTY(regiments); + + public: + Army(std::string_view new_name, Province const* new_location, std::vector&& new_regiments); }; struct Navy { - std::string name; - Province const* location; - std::vector ships; - }; + private: + std::string PROPERTY(name); + Province const* PROPERTY(location); + std::vector PROPERTY(ships); - struct DeploymentManager; + public: + Navy(std::string_view new_name, Province const* new_location, std::vector&& new_ships); + }; struct Deployment : HasIdentifier { - friend struct DeploymentManager; + friend std::unique_ptr std::make_unique( + std::string_view&&, std::vector&&, std::vector&&, std::vector&& + ); private: - const std::vector armies; - const std::vector navies; - const std::vector leaders; + std::vector PROPERTY(armies); + std::vector PROPERTY(navies); + std::vector PROPERTY(leaders); Deployment( std::string_view new_path, std::vector&& new_armies, std::vector&& new_navies, @@ -62,14 +85,13 @@ namespace OpenVic { ); public: - const std::vector& get_armies() const; - const std::vector& get_navies() const; - const std::vector& get_leaders() const; + Deployment(Deployment&&) = default; }; struct DeploymentManager { private: - IdentifierRegistry deployments; + IdentifierInstanceRegistry deployments; + string_set_t missing_oob_files; public: DeploymentManager(); @@ -77,8 +99,12 @@ namespace OpenVic { bool add_deployment( std::string_view path, std::vector&& armies, std::vector&& navies, std::vector&& leaders ); - IDENTIFIER_REGISTRY_ACCESSORS(deployment); + IDENTIFIER_REGISTRY_ACCESSORS(deployment) - bool load_oob_file(GameManager& game_manager, std::string_view path, ast::NodeCPtr root); + bool load_oob_file( + GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path, + Deployment const*& deployment, bool fail_on_missing + ); + size_t get_missing_oob_file_count() const; }; } // namespace OpenVic -- cgit v1.2.3-56-ga3b1