aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history/ProvinceHistory.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-28 11:39:08 +0200
committer hop311 <hop3114@gmail.com>2023-10-29 20:42:47 +0100
commit164264b047921dbe1567d2af183e1cffb200a8cb (patch)
tree21c3c81f65ac3259db4808ebe9fd32a94ca993af /src/openvic-simulation/history/ProvinceHistory.hpp
parentd8ec90f07342876e9331819bd3cc372050f78248 (diff)
Astyle formatting (with manual cleanup)
Diffstat (limited to 'src/openvic-simulation/history/ProvinceHistory.hpp')
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp153
1 files changed, 78 insertions, 75 deletions
diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp
index 0304b2a..d4e9615 100644
--- a/src/openvic-simulation/history/ProvinceHistory.hpp
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -1,96 +1,99 @@
#pragma once
+#include <bitset>
#include <map>
#include <vector>
-#include <bitset>
-#include "openvic-simulation/map/Province.hpp"
-#include "openvic-simulation/map/TerrainType.hpp"
#include "openvic-simulation/country/Country.hpp"
-#include "openvic-simulation/economy/Good.hpp"
#include "openvic-simulation/economy/Building.hpp"
+#include "openvic-simulation/economy/Good.hpp"
#include "openvic-simulation/history/Bookmark.hpp"
+#include "openvic-simulation/map/Province.hpp"
+#include "openvic-simulation/map/TerrainType.hpp"
namespace OpenVic {
- struct ProvinceHistoryManager;
+ struct ProvinceHistoryManager;
+
+ struct ProvinceHistory {
+ friend struct ProvinceHistoryManager;
- struct ProvinceHistory {
- friend struct ProvinceHistoryManager;
+ private:
+ Country const* owner;
+ Country const* controller;
+ uint8_t colonial;
+ bool slave;
+ std::vector<Country const*> cores; // non-standard, maintains cores between entries
+ Good const* rgo;
+ uint8_t life_rating;
+ TerrainType const* terrain_type;
+ std::map<Building const*, uint8_t> buildings;
+ std::map<Ideology const*, uint8_t> party_loyalties;
- private:
- Country const* owner;
- Country const* controller;
- uint8_t colonial;
- bool slave;
- std::vector<Country const*> cores; // non-standard, maintains cores between entries
- Good const* rgo;
- uint8_t life_rating;
- TerrainType const* terrain_type;
- std::map<Building const*, uint8_t> buildings;
- std::map<Ideology const*, uint8_t> party_loyalties;
+ ProvinceHistory(
+ Country const* new_owner,
+ Country const* new_controller,
+ uint8_t new_colonial,
+ bool new_slave,
+ std::vector<Country const*>&& new_cores,
+ Good const* new_rgo,
+ uint8_t new_life_rating,
+ TerrainType const* new_terrain_type,
+ std::map<Building const*, uint8_t>&& new_buildings,
+ std::map<Ideology const*, uint8_t>&& new_party_loyalties
+ );
- ProvinceHistory(
- Country const* new_owner,
- Country const* new_controller,
- uint8_t new_colonial,
- bool new_slave,
- std::vector<Country const*>&& new_cores,
- Good const* new_rgo,
- uint8_t new_life_rating,
- TerrainType const* new_terrain_type,
- std::map<Building const*, uint8_t>&& new_buildings,
- std::map<Ideology const*, uint8_t>&& new_party_loyalties
- );
+ public:
+ Country const* get_owner() const;
+ Country const* get_controller() const;
+ uint8_t get_colony_status() const; // 0 = state, 1 = protectorate, 2 = colony
+ bool is_slave() const;
+ std::vector<Country const*> const& get_cores() const;
+ bool is_core_of(Country const* country) const;
+ Good const* get_rgo() const;
+ uint8_t get_life_rating() const;
+ TerrainType const* get_terrain_type() const;
+ std::map<Building const*, uint8_t> const& get_buildings() const;
+ std::map<Ideology const*, uint8_t> const& get_party_loyalties() const;
+ };
- public:
- Country const* get_owner() const;
- Country const* get_controller() const;
- uint8_t get_colony_status() const; // 0 = state, 1 = protectorate, 2 = colony
- bool is_slave() const;
- const std::vector<Country const*>& get_cores() const;
- bool is_core_of(Country const* country) const;
- Good const* get_rgo() const;
- uint8_t get_life_rating() const;
- TerrainType const* get_terrain_type() const;
- const std::map<Building const*, uint8_t>& get_buildings() const;
- const std::map<Ideology const*, uint8_t>& get_party_loyalties() const;
- };
+ struct ProvinceHistoryManager {
+ private:
+ std::map<Province const*, std::map<Date, ProvinceHistory>> province_histories;
+ bool locked = false;
- struct ProvinceHistoryManager {
- private:
- std::map<Province const*, std::map<Date, ProvinceHistory>> province_histories;
- bool locked = false;
+ inline bool _load_province_history_entry(
+ GameManager& game_manager, std::string_view province, Date const& date, ast::NodeCPtr root
+ );
- inline bool _load_province_history_entry(GameManager& game_manager, std::string_view province, Date const& date, ast::NodeCPtr root);
-
- public:
- ProvinceHistoryManager() {}
+ public:
+ ProvinceHistoryManager() {}
- bool add_province_history_entry(
- Province const* province,
- Date date,
- Country const* owner,
- Country const* controller,
- uint8_t colonial,
- bool slave,
- std::vector<Country const*>&& cores, // additive to existing entries
- std::vector<Country const*>&& remove_cores, // existing cores that need to be removed
- Good const* rgo,
- uint8_t life_rating,
- TerrainType const* terrain_type,
- std::map<Building const*, uint8_t>&& buildings,
- std::map<Ideology const*, uint8_t>&& party_loyalties,
- std::bitset<5> updates // bitmap of updated non-pointer values, top to bottom
- );
+ bool add_province_history_entry(
+ Province const* province,
+ Date date,
+ Country const* owner,
+ Country const* controller,
+ uint8_t colonial,
+ bool slave,
+ std::vector<Country const*>&& cores, // additive to existing entries
+ std::vector<Country const*>&& remove_cores, // existing cores that need to be removed
+ Good const* rgo,
+ uint8_t life_rating,
+ TerrainType const* terrain_type,
+ std::map<Building const*, uint8_t>&& buildings,
+ std::map<Ideology const*, uint8_t>&& party_loyalties,
+ std::bitset<5> updates // bitmap of updated non-pointer values, top to bottom
+ );
- void lock_province_histories();
- bool is_locked() const;
+ void lock_province_histories();
+ bool is_locked() const;
- /* Returns history of province at date, if date doesn't have an entry returns closest entry before date. Return can be nullptr if an error occurs. */
- ProvinceHistory const* get_province_history(Province const* province, Date entry) const;
- /* Returns history of province at bookmark date. Return can be nullptr if an error occurs. */
- inline ProvinceHistory const* get_province_history(Province const* province, Bookmark const* bookmark) const;
+ /* Returns history of province at date, if date doesn't have an entry returns closest entry before date.
+ * Return can be nullptr if an error occurs. */
+ ProvinceHistory const* get_province_history(Province const* province, Date entry) const;
+ /* Returns history of province at bookmark date. Return can be nullptr if an error occurs. */
+ inline ProvinceHistory const* get_province_history(Province const* province, Bookmark const* bookmark) const;
- bool load_province_history_file(GameManager& game_manager, std::string_view name, ast::NodeCPtr root);
- };
+ bool load_province_history_file(GameManager& game_manager, std::string_view name, ast::NodeCPtr root);
+ };
} // namespace OpenVic