aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-30 00:06:10 +0100
committer hop311 <hop3114@gmail.com>2023-11-07 19:33:33 +0100
commite91ce707b2c0e80591b9fd1b6a5215e6e6989df8 (patch)
tree3740e9feb3bfa91b8b02362ed11d1e9f7e67e7c9 /src/openvic-simulation/history
parent8a00697a0e6a4168894594eadc373836a1689eea (diff)
Stop passing Dates by reference
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r--src/openvic-simulation/history/Bookmark.cpp2
-rw-r--r--src/openvic-simulation/history/Bookmark.hpp2
-rw-r--r--src/openvic-simulation/history/CountryHistory.cpp12
-rw-r--r--src/openvic-simulation/history/CountryHistory.hpp4
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.cpp8
-rw-r--r--src/openvic-simulation/history/ProvinceHistory.hpp2
6 files changed, 15 insertions, 15 deletions
diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp
index edfa064..92d8de5 100644
--- a/src/openvic-simulation/history/Bookmark.cpp
+++ b/src/openvic-simulation/history/Bookmark.cpp
@@ -25,7 +25,7 @@ std::string_view Bookmark::get_description() const {
return description;
}
-Date const& Bookmark::get_date() const {
+Date Bookmark::get_date() const {
return date;
}
diff --git a/src/openvic-simulation/history/Bookmark.hpp b/src/openvic-simulation/history/Bookmark.hpp
index 8f0075f..e93718f 100644
--- a/src/openvic-simulation/history/Bookmark.hpp
+++ b/src/openvic-simulation/history/Bookmark.hpp
@@ -29,7 +29,7 @@ namespace OpenVic {
std::string_view get_name() const;
std::string_view get_description() const;
- Date const& get_date() const;
+ Date get_date() const;
uint32_t get_initial_camera_x() const;
uint32_t get_initial_camera_y() const;
};
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp
index d0764be..ed72f52 100644
--- a/src/openvic-simulation/history/CountryHistory.cpp
+++ b/src/openvic-simulation/history/CountryHistory.cpp
@@ -33,7 +33,7 @@ CountryParty const* CountryHistory::get_ruling_party() const {
return ruling_party;
}
-const Date CountryHistory::get_last_election() const {
+Date CountryHistory::get_last_election() const {
return last_election;
}
@@ -103,7 +103,7 @@ bool CountryHistoryManager::add_country_history_entry(
if (ruling_party != nullptr) {
existing_entry->second.ruling_party = ruling_party;
}
- if (last_election != Date(0)) {
+ if (last_election != Date{}) {
existing_entry->second.last_election = last_election;
}
if (updated_upper_house) {
@@ -195,7 +195,7 @@ inline CountryHistory const* CountryHistoryManager::get_country_history(Country
}
inline bool CountryHistoryManager::_load_country_history_entry(
- GameManager& game_manager, std::string_view name, Date const& date, ast::NodeCPtr root
+ GameManager& game_manager, std::string_view name, Date date, ast::NodeCPtr root
) {
Province const* capital = nullptr;
Culture const* primary_culture = nullptr;
@@ -208,7 +208,7 @@ inline bool CountryHistoryManager::_load_country_history_entry(
std::map<Ideology const*, fixed_point_t> upper_house;
fixed_point_t plurality = -1, prestige = -1;
bool civilised = false;
- Date last_election = Date(0);
+ Date last_election {};
Deployment const* initial_oob = nullptr;
bool updated_accepted_cultures = false, updated_upper_house = false, updated_reforms = false;
@@ -354,12 +354,12 @@ bool CountryHistoryManager::load_country_history_file(GameManager& game_manager,
ret &= expect_dictionary([this, &game_manager, &name](std::string_view key, ast::NodeCPtr value) -> bool {
bool is_date = false;
- Date entry = Date().from_string(key, &is_date, true);
+ Date entry = Date::from_string(key, &is_date, true);
if (!is_date) {
return true;
}
- Date const& end_date = game_manager.get_define_manager().get_end_date();
+ Date end_date = game_manager.get_define_manager().get_end_date();
if (entry > end_date) {
Logger::error(
"History entry ", entry.to_string(), " of country ", name, " defined after defined end date ",
diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp
index 52d99df..0401ec4 100644
--- a/src/openvic-simulation/history/CountryHistory.hpp
+++ b/src/openvic-simulation/history/CountryHistory.hpp
@@ -54,7 +54,7 @@ namespace OpenVic {
const std::vector<Culture const*>& get_accepted_cultures() const;
Religion const* get_religion() const;
CountryParty const* get_ruling_party() const;
- const Date get_last_election() const;
+ Date get_last_election() const;
const std::map<Ideology const*, fixed_point_t>& get_upper_house() const;
Province const* get_capital() const;
GovernmentType const* get_government_type() const;
@@ -72,7 +72,7 @@ namespace OpenVic {
bool locked = false;
inline bool _load_country_history_entry(
- GameManager& game_manager, std::string_view name, Date const& date, ast::NodeCPtr root
+ GameManager& game_manager, std::string_view name, Date date, ast::NodeCPtr root
);
public:
diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp
index c2d5451..6dbf6a4 100644
--- a/src/openvic-simulation/history/ProvinceHistory.cpp
+++ b/src/openvic-simulation/history/ProvinceHistory.cpp
@@ -176,7 +176,7 @@ inline ProvinceHistory const* ProvinceHistoryManager::get_province_history(
}
inline bool ProvinceHistoryManager::_load_province_history_entry(
- GameManager& game_manager, std::string_view province, Date const& date, ast::NodeCPtr root
+ GameManager& game_manager, std::string_view province, Date date, ast::NodeCPtr root
) {
Country const* owner = nullptr;
Country const* controller = nullptr;
@@ -207,7 +207,7 @@ inline bool ProvinceHistoryManager::_load_province_history_entry(
}
bool is_date;
- Date().from_string(key, &is_date, true);
+ Date::from_string(key, &is_date, true);
if (is_date) {
return true;
}
@@ -307,12 +307,12 @@ bool ProvinceHistoryManager::load_province_history_file(GameManager& game_manage
ret &= expect_dictionary(
[this, &game_manager, &name](std::string_view key, ast::NodeCPtr value) -> bool {
bool is_date = false;
- Date entry = Date().from_string(key, &is_date, true);
+ Date entry = Date::from_string(key, &is_date, true);
if (!is_date) {
return true;
}
- Date const& end_date = game_manager.get_define_manager().get_end_date();
+ Date end_date = game_manager.get_define_manager().get_end_date();
if (entry > end_date) {
Logger::error(
"History entry ", entry.to_string(), " of province ", name, " defined after defined end date ",
diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp
index 42dacbf..90c87e2 100644
--- a/src/openvic-simulation/history/ProvinceHistory.hpp
+++ b/src/openvic-simulation/history/ProvinceHistory.hpp
@@ -56,7 +56,7 @@ namespace OpenVic {
bool locked = false;
inline bool _load_province_history_entry(
- GameManager& game_manager, std::string_view province, Date const& date, ast::NodeCPtr root
+ GameManager& game_manager, std::string_view province, Date date, ast::NodeCPtr root
);
public: