From 37cdd775ac738b2a1264e32471385376e5a34f3a Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 3 Jun 2024 23:39:34 +0100 Subject: Province const/mutable separation + State cleanup --- src/openvic-simulation/history/ProvinceHistory.hpp | 44 ++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'src/openvic-simulation/history/ProvinceHistory.hpp') diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index 7611907..27d744d 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -1,39 +1,49 @@ #pragma once +#include #include -#include "openvic-simulation/country/Country.hpp" #include "openvic-simulation/economy/BuildingType.hpp" -#include "openvic-simulation/economy/Good.hpp" #include "openvic-simulation/history/HistoryMap.hpp" -#include "openvic-simulation/map/Province.hpp" -#include "openvic-simulation/map/TerrainType.hpp" +#include "openvic-simulation/map/ProvinceInstance.hpp" +#include "openvic-simulation/pop/Pop.hpp" +#include "openvic-simulation/types/Date.hpp" +#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" +#include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { struct ProvinceHistoryMap; + struct ProvinceDefinition; + struct Country; + struct Good; + struct TerrainType; + struct Ideology; + struct GameManager; struct ProvinceHistoryEntry : HistoryEntry { friend struct ProvinceHistoryMap; private: - Province const& PROPERTY(province); + ProvinceDefinition const& PROPERTY(province); std::optional PROPERTY(owner); std::optional PROPERTY(controller); - std::optional PROPERTY(colonial); + std::optional PROPERTY(colonial); std::optional PROPERTY(slave); std::vector PROPERTY(add_cores); std::vector PROPERTY(remove_cores); std::optional PROPERTY(rgo); - std::optional PROPERTY(life_rating); + std::optional PROPERTY(life_rating); std::optional PROPERTY(terrain_type); ordered_map PROPERTY(province_buildings); ordered_map PROPERTY(state_buildings); fixed_point_map_t PROPERTY(party_loyalties); + + // TODO - use minimal pop representation (size, type, culture, religion, consciousness, militancy, rebel type) std::vector PROPERTY(pops); - ProvinceHistoryEntry(Province const& new_province, Date new_date); + ProvinceHistoryEntry(ProvinceDefinition const& new_province, Date new_date); bool _load_province_pop_history(GameManager const& game_manager, ast::NodeCPtr root, bool *non_integer_size); }; @@ -44,10 +54,10 @@ namespace OpenVic { friend struct ProvinceHistoryManager; private: - Province const& PROPERTY(province); + ProvinceDefinition const& PROPERTY(province); protected: - ProvinceHistoryMap(Province const& new_province); + ProvinceHistoryMap(ProvinceDefinition const& new_province); std::unique_ptr _make_entry(Date date) const override; bool _load_history_entry(GameManager const& game_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root) override; @@ -58,12 +68,14 @@ namespace OpenVic { ); }; + struct Map; + struct ProvinceHistoryManager { private: - ordered_map province_histories; + ordered_map province_histories; bool locked = false; - ProvinceHistoryMap* _get_or_make_province_history(Province const& province); + ProvinceHistoryMap* _get_or_make_province_history(ProvinceDefinition const& province); public: ProvinceHistoryManager() = default; @@ -72,9 +84,11 @@ namespace OpenVic { void lock_province_histories(Map const& map, bool detailed_errors); bool is_locked() const; - ProvinceHistoryMap const* get_province_history(Province const* province) const; + ProvinceHistoryMap const* get_province_history(ProvinceDefinition const* province) const; - bool load_province_history_file(GameManager const& game_manager, Province const& province, ast::NodeCPtr root); + bool load_province_history_file( + GameManager const& game_manager, ProvinceDefinition const& province, ast::NodeCPtr root + ); bool load_pop_history_file(GameManager const& game_manager, Date date, ast::NodeCPtr root, bool *non_integer_size); }; -} // namespace OpenVic +} -- cgit v1.2.3-56-ga3b1