diff options
author | hop311 <hop3114@gmail.com> | 2023-11-14 22:42:00 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-11-15 21:06:20 +0100 |
commit | 8271b1519e095ee3e7245cde2f0b54561c3ec619 (patch) | |
tree | 0168ea3d3125f68b700d53e3fa0ebdd80b337653 /src/openvic-simulation/history | |
parent | e031758cf68535e97045c07f36e2524676447778 (diff) |
Bookmark loading + province and building cleanup
Diffstat (limited to 'src/openvic-simulation/history')
4 files changed, 13 insertions, 15 deletions
diff --git a/src/openvic-simulation/history/HistoryManager.hpp b/src/openvic-simulation/history/HistoryManager.hpp index ec6d1c5..a7fc668 100644 --- a/src/openvic-simulation/history/HistoryManager.hpp +++ b/src/openvic-simulation/history/HistoryManager.hpp @@ -19,9 +19,5 @@ namespace OpenVic { REF_GETTERS(country_manager) REF_GETTERS(province_manager) REF_GETTERS(diplomacy_manager) - - inline bool load_bookmark_file(ast::NodeCPtr root) { - return bookmark_manager.load_bookmark_file(root); - } }; } diff --git a/src/openvic-simulation/history/HistoryMap.hpp b/src/openvic-simulation/history/HistoryMap.hpp index 64d886d..07f54f0 100644 --- a/src/openvic-simulation/history/HistoryMap.hpp +++ b/src/openvic-simulation/history/HistoryMap.hpp @@ -30,6 +30,11 @@ namespace OpenVic { std::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) { + const Date end_date = _get_end_date(game_manager); + if (date > end_date) { + Logger::error("History entry ", date, " defined after end date ", end_date); + return false; + } typename decltype(entries)::iterator it = entries.find(date); if (it == entries.end()) { const std::pair<typename decltype(entries)::iterator, bool> result = entries.emplace(date, _make_entry(date)); @@ -64,14 +69,12 @@ namespace OpenVic { bool is_date = false; const Date sub_date { Date::from_string(key, &is_date, true) }; if (is_date) { - if (sub_date <= date) { + if (sub_date < date) { Logger::error("History entry ", sub_date, " defined before parent entry date ", date); return false; } - const Date end_date = _get_end_date(game_manager); - if (sub_date > end_date) { - Logger::error("History entry ", sub_date, " defined after end date ", end_date); - return false; + if (sub_date == date) { + Logger::warning("History entry ", sub_date, " defined with same date as parent entry"); } if (_try_load_history_entry(game_manager, args..., sub_date, value)) { return true; @@ -94,7 +97,7 @@ namespace OpenVic { return nullptr; } /* Returns history entries up to date as an ordered list of entries. */ - std::vector<entry_type const*> get_entries(Date end) const { + std::vector<entry_type const*> get_entries_up_to(Date end) const { std::vector<entry_type const*> ret; for (typename decltype(entries)::value_type const& entry : entries) { if (entry.first <= end) { diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp index 141d256..379c7d1 100644 --- a/src/openvic-simulation/history/ProvinceHistory.cpp +++ b/src/openvic-simulation/history/ProvinceHistory.cpp @@ -36,7 +36,7 @@ bool ProvinceHistoryMap::_load_history_entry( Building const* building = building_manager.get_building_by_identifier(key); if (building != nullptr) { return expect_uint<Building::level_t>([&entry, building](Building::level_t level) -> bool { - entry.buildings[building] = level; + entry.province_buildings[building] = level; return true; })(value); } @@ -93,7 +93,7 @@ bool ProvinceHistoryMap::_load_history_entry( ), "upgrade", ZERO_OR_ONE, success_callback // doesn't appear to have an effect )(node); - entry.buildings[building] = level; + entry.state_buildings[building] = level; return ret; } )(root); diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index 313f3a4..d0136bb 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -18,8 +18,6 @@ namespace OpenVic { struct ProvinceHistoryEntry : HistoryEntry { friend struct ProvinceHistoryMap; - using building_level_map_t = std::map<Building const*, Building::level_t>; - private: Province const& PROPERTY(province); @@ -32,7 +30,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); - building_level_map_t PROPERTY(buildings); + std::map<Building const*, Building::level_t> PROPERTY(province_buildings); + std::map<Building const*, Building::level_t> PROPERTY(state_buildings); fixed_point_map_t<Ideology const*> PROPERTY(party_loyalties); ProvinceHistoryEntry(Province const& new_province, Date new_date); |