aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
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
parent8a00697a0e6a4168894594eadc373836a1689eea (diff)
Stop passing Dates by reference
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/GameManager.cpp2
-rw-r--r--src/openvic-simulation/GameManager.hpp2
-rw-r--r--src/openvic-simulation/Modifier.cpp2
-rw-r--r--src/openvic-simulation/Modifier.hpp2
-rw-r--r--src/openvic-simulation/country/Country.cpp4
-rw-r--r--src/openvic-simulation/country/Country.hpp4
-rw-r--r--src/openvic-simulation/economy/Building.cpp8
-rw-r--r--src/openvic-simulation/economy/Building.hpp8
-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
-rw-r--r--src/openvic-simulation/map/Map.cpp4
-rw-r--r--src/openvic-simulation/map/Map.hpp4
-rw-r--r--src/openvic-simulation/map/Province.cpp4
-rw-r--r--src/openvic-simulation/map/Province.hpp4
-rw-r--r--src/openvic-simulation/misc/Define.cpp4
-rw-r--r--src/openvic-simulation/misc/Define.hpp4
-rw-r--r--src/openvic-simulation/politics/Ideology.cpp2
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp2
-rw-r--r--src/openvic-simulation/types/Date.cpp2
-rw-r--r--src/openvic-simulation/types/Date.hpp2
24 files changed, 47 insertions, 47 deletions
diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp
index 261dea5..427fbb1 100644
--- a/src/openvic-simulation/GameManager.cpp
+++ b/src/openvic-simulation/GameManager.cpp
@@ -47,7 +47,7 @@ bool GameManager::setup() {
return ret;
}
-Date const& GameManager::get_today() const {
+Date GameManager::get_today() const {
return today;
}
diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp
index 0b2a40c..9ee3442 100644
--- a/src/openvic-simulation/GameManager.hpp
+++ b/src/openvic-simulation/GameManager.hpp
@@ -51,7 +51,7 @@ namespace OpenVic {
bool setup();
- Date const& get_today() const;
+ Date get_today() const;
bool expand_building(Province::index_t province_index, std::string_view building_type_identifier);
/* Hardcoded data for defining things for which parsing from files has
diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp
index 605ffe4..0d79833 100644
--- a/src/openvic-simulation/Modifier.cpp
+++ b/src/openvic-simulation/Modifier.cpp
@@ -96,7 +96,7 @@ Modifier const& ModifierInstance::get_modifier() const {
return modifier;
}
-Date const& ModifierInstance::get_expiry_date() const {
+Date ModifierInstance::get_expiry_date() const {
return expiry_date;
}
diff --git a/src/openvic-simulation/Modifier.hpp b/src/openvic-simulation/Modifier.hpp
index 4af470e..78f8228 100644
--- a/src/openvic-simulation/Modifier.hpp
+++ b/src/openvic-simulation/Modifier.hpp
@@ -93,7 +93,7 @@ namespace OpenVic {
public:
Modifier const& get_modifier() const;
- Date const& get_expiry_date() const;
+ Date get_expiry_date() const;
};
template<typename Fn>
diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp
index 885340d..b2c4a71 100644
--- a/src/openvic-simulation/country/Country.cpp
+++ b/src/openvic-simulation/country/Country.cpp
@@ -27,11 +27,11 @@ CountryParty::CountryParty(
) : HasIdentifier { new_identifier }, start_date { new_start_date }, end_date { new_end_date }, ideology { new_ideology },
policies { std::move(new_policies) } {}
-Date const& CountryParty::get_start_date() const {
+Date CountryParty::get_start_date() const {
return start_date;
}
-Date const& CountryParty::get_end_date() const {
+Date CountryParty::get_end_date() const {
return end_date;
}
diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp
index b1bbf2b..1ab0e7e 100644
--- a/src/openvic-simulation/country/Country.hpp
+++ b/src/openvic-simulation/country/Country.hpp
@@ -47,8 +47,8 @@ namespace OpenVic {
public:
CountryParty(CountryParty&&) = default;
- const Date& get_start_date() const;
- const Date& get_end_date() const;
+ Date get_start_date() const;
+ Date get_end_date() const;
Ideology const& get_ideology() const;
policy_map_t const& get_policies() const;
};
diff --git a/src/openvic-simulation/economy/Building.cpp b/src/openvic-simulation/economy/Building.cpp
index 39b49ee..38a8863 100644
--- a/src/openvic-simulation/economy/Building.cpp
+++ b/src/openvic-simulation/economy/Building.cpp
@@ -129,11 +129,11 @@ ExpansionState BuildingInstance::get_expansion_state() const {
return expansion_state;
}
-Date const& BuildingInstance::get_start_date() const {
+Date BuildingInstance::get_start_date() const {
return start;
}
-Date const& BuildingInstance::get_end_date() const {
+Date BuildingInstance::get_end_date() const {
return end;
}
@@ -153,7 +153,7 @@ bool BuildingInstance::expand() {
/* REQUIREMENTS:
* MAP-71, MAP-74, MAP-77
*/
-void BuildingInstance::update_state(Date const& today) {
+void BuildingInstance::update_state(Date today) {
switch (expansion_state) {
case ExpansionState::Preparing:
start = today;
@@ -166,7 +166,7 @@ void BuildingInstance::update_state(Date const& today) {
}
}
-void BuildingInstance::tick(Date const& today) {
+void BuildingInstance::tick(Date today) {
if (expansion_state == ExpansionState::Preparing) {
expansion_state = ExpansionState::Expanding;
}
diff --git a/src/openvic-simulation/economy/Building.hpp b/src/openvic-simulation/economy/Building.hpp
index 0b94298..e907e49 100644
--- a/src/openvic-simulation/economy/Building.hpp
+++ b/src/openvic-simulation/economy/Building.hpp
@@ -133,13 +133,13 @@ namespace OpenVic {
level_t get_current_level() const;
ExpansionState get_expansion_state() const;
- Date const& get_start_date() const;
- Date const& get_end_date() const;
+ Date get_start_date() const;
+ Date get_end_date() const;
float get_expansion_progress() const;
bool expand();
- void update_state(Date const& today);
- void tick(Date const& today);
+ void update_state(Date today);
+ void tick(Date today);
};
struct Province;
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:
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 4df17bf..4790853 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -292,7 +292,7 @@ bool Map::setup(BuildingManager const& building_manager, PopManager const& pop_m
return ret;
}
-void Map::update_state(Date const& today) {
+void Map::update_state(Date today) {
for (Province& province : provinces.get_items()) {
province.update_state(today);
}
@@ -300,7 +300,7 @@ void Map::update_state(Date const& today) {
update_total_map_population();
}
-void Map::tick(Date const& today) {
+void Map::tick(Date today) {
for (Province& province : provinces.get_items()) {
province.tick(today);
}
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp
index 61b7b48..d11ad8e 100644
--- a/src/openvic-simulation/map/Map.hpp
+++ b/src/openvic-simulation/map/Map.hpp
@@ -108,8 +108,8 @@ namespace OpenVic {
void update_total_map_population();
Pop::pop_size_t get_total_map_population() const;
- void update_state(Date const& today);
- void tick(Date const& today);
+ void update_state(Date today);
+ void tick(Date today);
bool load_province_definitions(std::vector<ovdl::csv::LineObject> const& lines);
bool load_province_positions(BuildingManager const& building_manager, ast::NodeCPtr root);
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 225d4c0..7b88ebf 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -155,14 +155,14 @@ void Province::update_pops() {
}
}
-void Province::update_state(Date const& today) {
+void Province::update_state(Date today) {
for (BuildingInstance& building : buildings.get_items()) {
building.update_state(today);
}
update_pops();
}
-void Province::tick(Date const& today) {
+void Province::tick(Date today) {
for (BuildingInstance& building : buildings.get_items()) {
building.tick(today);
}
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index 2704354..10f3a9a 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -110,8 +110,8 @@ namespace OpenVic {
distribution_t const& get_religion_distribution() const;
void update_pops();
- void update_state(Date const& today);
- void tick(Date const& today);
+ void update_state(Date today);
+ void tick(Date today);
bool is_adjacent_to(Province const* province);
bool add_adjacency(Province const* province, distance_t distance, flags_t flags);
diff --git a/src/openvic-simulation/misc/Define.cpp b/src/openvic-simulation/misc/Define.cpp
index 5e6a3cb..c866b5d 100644
--- a/src/openvic-simulation/misc/Define.cpp
+++ b/src/openvic-simulation/misc/Define.cpp
@@ -36,11 +36,11 @@ bool DefineManager::add_define(std::string_view name, std::string&& value, Defin
return defines.add_item({ name, std::move(value), type }, duplicate_warning_callback);
}
-const Date& DefineManager::get_start_date() const {
+Date DefineManager::get_start_date() const {
return *start_date;
}
-const Date& DefineManager::get_end_date() const {
+Date DefineManager::get_end_date() const {
return *end_date;
}
diff --git a/src/openvic-simulation/misc/Define.hpp b/src/openvic-simulation/misc/Define.hpp
index 0db9716..56ce0b0 100644
--- a/src/openvic-simulation/misc/Define.hpp
+++ b/src/openvic-simulation/misc/Define.hpp
@@ -42,8 +42,8 @@ namespace OpenVic {
bool add_date_define(std::string_view name, Date date);
IDENTIFIER_REGISTRY_ACCESSORS(define);
- const Date& get_start_date() const;
- const Date& get_end_date() const;
+ Date get_start_date() const;
+ Date get_end_date() const;
bool load_defines_file(ast::NodeCPtr root);
};
diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp
index acbd82f..5721a57 100644
--- a/src/openvic-simulation/politics/Ideology.cpp
+++ b/src/openvic-simulation/politics/Ideology.cpp
@@ -23,7 +23,7 @@ bool Ideology::get_can_reduce_militancy() const {
return can_reduce_militancy;
}
-Date const& Ideology::get_spawn_date() const {
+Date Ideology::get_spawn_date() const {
return spawn_date;
}
diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp
index 046dbc9..bdf9f91 100644
--- a/src/openvic-simulation/politics/Ideology.hpp
+++ b/src/openvic-simulation/politics/Ideology.hpp
@@ -36,7 +36,7 @@ namespace OpenVic {
IdeologyGroup const& get_group() const;
bool is_uncivilised() const;
bool get_can_reduce_militancy() const;
- Date const& get_spawn_date() const;
+ Date get_spawn_date() const;
};
struct IdeologyManager {
diff --git a/src/openvic-simulation/types/Date.cpp b/src/openvic-simulation/types/Date.cpp
index 8fbb859..c5eac41 100644
--- a/src/openvic-simulation/types/Date.cpp
+++ b/src/openvic-simulation/types/Date.cpp
@@ -214,7 +214,7 @@ Date::operator std::string() const {
return to_string();
}
-std::ostream& OpenVic::operator<<(std::ostream& out, Date const& date) {
+std::ostream& OpenVic::operator<<(std::ostream& out, Date date) {
return out << static_cast<int>(date.getYear()) << Date::SEPARATOR_CHARACTER << static_cast<int>(date.getMonth())
<< Date::SEPARATOR_CHARACTER << static_cast<int>(date.getDay());
}
diff --git a/src/openvic-simulation/types/Date.hpp b/src/openvic-simulation/types/Date.hpp
index 0cc2587..c3fee15 100644
--- a/src/openvic-simulation/types/Date.hpp
+++ b/src/openvic-simulation/types/Date.hpp
@@ -96,5 +96,5 @@ namespace OpenVic {
static Date from_string(char const* str, size_t length, bool* successful = nullptr, bool quiet = false);
static Date from_string(std::string_view str, bool* successful = nullptr, bool quiet = false);
};
- std::ostream& operator<<(std::ostream& out, Date const& date);
+ std::ostream& operator<<(std::ostream& out, Date date);
}