diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-12-25 08:42:11 +0100 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-12-31 20:46:26 +0100 |
commit | e1496a87178d925277aceed0ebcbab06920e15ee (patch) | |
tree | ba081f9f4d74865ab5851a2efd560745900ca81a /src/openvic-simulation/history | |
parent | 0a425fbe05d6138b753c0e4a7c06f06695bde8af (diff) |
Add `https://github.com/Tessil/ordered-map`
Add is_specialization_of to Utility.hpp
Add OpenVic::ordered_map and OpenVic::ordered_set
Change `std::map` to `ordered_map`
Change `std::set to use `ordered_set`
Add `set_callback_pointer(tsl::ordered_set<T const*>& set)`
Add mutable_iterator to enable mutable value iterator for `tsl::ordered_map`
Add std::hash<OpenVic::Date> implementation
Enable deps/SCsub to expose dependency includes neccessary for inclusion
Diffstat (limited to 'src/openvic-simulation/history')
5 files changed, 17 insertions, 14 deletions
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp index 00c88b8..48b30e6 100644 --- a/src/openvic-simulation/history/CountryHistory.cpp +++ b/src/openvic-simulation/history/CountryHistory.cpp @@ -242,7 +242,7 @@ bool CountryHistoryManager::load_country_history_file( return false; } } - CountryHistoryMap& country_history = it->second; + CountryHistoryMap& country_history = it.value(); return country_history._load_history_file( game_manager, dataloader, game_manager.get_military_manager().get_deployment_manager(), root diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp index 106b1c3..6d4392b 100644 --- a/src/openvic-simulation/history/CountryHistory.hpp +++ b/src/openvic-simulation/history/CountryHistory.hpp @@ -3,22 +3,23 @@ #include <map> #include <optional> -#include "openvic-simulation/misc/Decision.hpp" #include "openvic-simulation/country/Country.hpp" #include "openvic-simulation/history/Bookmark.hpp" #include "openvic-simulation/history/HistoryMap.hpp" #include "openvic-simulation/map/Province.hpp" #include "openvic-simulation/military/Deployment.hpp" +#include "openvic-simulation/misc/Decision.hpp" #include "openvic-simulation/politics/Government.hpp" #include "openvic-simulation/politics/Ideology.hpp" #include "openvic-simulation/politics/Issue.hpp" #include "openvic-simulation/politics/NationalValue.hpp" #include "openvic-simulation/pop/Culture.hpp" #include "openvic-simulation/pop/Religion.hpp" -#include "openvic-simulation/types/Colour.hpp" -#include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/research/Invention.hpp" #include "openvic-simulation/research/Technology.hpp" +#include "openvic-simulation/types/Colour.hpp" +#include "openvic-simulation/types/Date.hpp" +#include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { struct CountryHistoryMap; @@ -44,8 +45,8 @@ namespace OpenVic { std::vector<Reform const*> PROPERTY(reforms); std::optional<Deployment const*> PROPERTY(inital_oob); std::optional<TechnologySchool const*> PROPERTY(tech_school); - std::map<Technology const*, bool> PROPERTY(technologies); - std::map<Invention const*, bool> PROPERTY(inventions); + ordered_map<Technology const*, bool> PROPERTY(technologies); + ordered_map<Invention const*, bool> PROPERTY(inventions); fixed_point_map_t<Country const*> PROPERTY(foreign_investment); std::optional<fixed_point_t> PROPERTY(consciousness); std::optional<fixed_point_t> PROPERTY(nonstate_consciousness); @@ -55,8 +56,8 @@ namespace OpenVic { std::optional<fixed_point_t> PROPERTY(colonial_points); string_set_t PROPERTY(country_flags); string_set_t PROPERTY(global_flags); - std::map<GovernmentType const*, GovernmentType const*> PROPERTY(government_flag_overrides); - std::set<Decision const*> decisions; + ordered_map<GovernmentType const*, GovernmentType const*> PROPERTY(government_flag_overrides); + ordered_set<Decision const*> decisions; CountryHistoryEntry(Country const& new_country, Date new_date); }; @@ -81,7 +82,7 @@ namespace OpenVic { struct CountryHistoryManager { private: - std::map<Country const*, CountryHistoryMap> country_histories; + ordered_map<Country const*, CountryHistoryMap> country_histories; bool locked = false; public: diff --git a/src/openvic-simulation/history/HistoryMap.hpp b/src/openvic-simulation/history/HistoryMap.hpp index 576f00e..64975bc 100644 --- a/src/openvic-simulation/history/HistoryMap.hpp +++ b/src/openvic-simulation/history/HistoryMap.hpp @@ -5,6 +5,7 @@ #include "openvic-simulation/dataloader/NodeTools.hpp" #include "openvic-simulation/types/Date.hpp" +#include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { @@ -29,7 +30,7 @@ namespace OpenVic { using entry_type = _Entry; private: - std::map<Date, std::unique_ptr<entry_type>> PROPERTY(entries); + ordered_map<Date, std::unique_ptr<entry_type>> PROPERTY(entries); bool _try_load_history_entry(GameManager const& game_manager, Args... args, Date date, ast::NodeCPtr root) { entry_type *const entry = _get_or_make_entry(game_manager, date); diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp index db998b7..f5e5187 100644 --- a/src/openvic-simulation/history/ProvinceHistory.cpp +++ b/src/openvic-simulation/history/ProvinceHistory.cpp @@ -147,7 +147,7 @@ ProvinceHistoryMap* ProvinceHistoryManager::_get_or_make_province_history(Provin return nullptr; } } - return &it->second; + return &it.value(); } bool ProvinceHistoryManager::load_province_history_file( diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index c3c8e67..0bda35d 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -11,6 +11,7 @@ #include "openvic-simulation/history/HistoryMap.hpp" #include "openvic-simulation/map/Province.hpp" #include "openvic-simulation/map/TerrainType.hpp" +#include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { struct ProvinceHistoryMap; @@ -30,8 +31,8 @@ namespace OpenVic { std::optional<Good const*> PROPERTY(rgo); std::optional<Province::life_rating_t> PROPERTY(life_rating); std::optional<TerrainType const*> PROPERTY(terrain_type); - std::map<BuildingType const*, BuildingType::level_t> PROPERTY(province_buildings); - std::map<BuildingType const*, BuildingType::level_t> PROPERTY(state_buildings); + ordered_map<BuildingType const*, BuildingType::level_t> PROPERTY(province_buildings); + ordered_map<BuildingType const*, BuildingType::level_t> PROPERTY(state_buildings); fixed_point_map_t<Ideology const*> PROPERTY(party_loyalties); std::vector<Pop> PROPERTY(pops); @@ -62,7 +63,7 @@ namespace OpenVic { struct ProvinceHistoryManager { private: - std::map<Province const*, ProvinceHistoryMap> PROPERTY(province_histories); + ordered_map<Province const*, ProvinceHistoryMap> PROPERTY(province_histories); bool locked = false; ProvinceHistoryMap* _get_or_make_province_history(Province const& province); |