diff options
author | hop311 <hop3114@gmail.com> | 2024-01-22 21:02:58 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-01-23 23:14:53 +0100 |
commit | 268a6948c0400905dfc335427395519689f067f5 (patch) | |
tree | b30e9b5774130552fe97e27deaf0370d83920c43 /src/openvic-simulation/history/DiplomaticHistory.cpp | |
parent | d4e597da089a81f719a9c33b46111d1c2c590124 (diff) |
Added reserve_more, expect_dictionary_key[s|_map]_reserve_length[_and_default]reserve_more
Diffstat (limited to 'src/openvic-simulation/history/DiplomaticHistory.cpp')
-rw-r--r-- | src/openvic-simulation/history/DiplomaticHistory.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp index 883a212..55d6d6b 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.cpp +++ b/src/openvic-simulation/history/DiplomaticHistory.cpp @@ -47,6 +47,14 @@ SubjectHistory::SubjectHistory( const Period new_period ) : overlord { new_overlord }, subject { new_subject }, type { new_type }, period {new_period} {} +void DiplomaticHistoryManager::reserve_more_wars(size_t size) { + if (locked) { + Logger::error("Failed to reserve space for ", size, " wars in DiplomaticHistoryManager - already locked!"); + } else { + reserve_more(wars, size); + } +} + void DiplomaticHistoryManager::lock_diplomatic_history() { Logger::info("Locked diplomacy history registry after registering ", alliances.size() + subjects.size() + wars.size(), " items"); locked = true; @@ -184,7 +192,7 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& } bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_manager, ast::NodeCPtr root) { - std::string name = ""; + std::string_view name {}; std::vector<WarHistory::war_participant_t> attackers {}; std::vector<WarHistory::war_participant_t> defenders {}; std::vector<WarHistory::added_wargoal_t> wargoals {}; @@ -270,7 +278,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man )(node); return ret; }, - "name", ZERO_OR_ONE, expect_string(assign_variable_callback_string(name)) + "name", ZERO_OR_ONE, expect_string(assign_variable_callback(name)) )(root); wars.push_back({ name, std::move(attackers), std::move(defenders), std::move(wargoals) }); |