aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-06 22:12:10 +0200
committer hop311 <hop3114@gmail.com>2024-09-06 22:12:10 +0200
commit34c8b1039a5a7982a84c718ca8625efcd940bbf5 (patch)
tree479bddfb6a01b2627118ee2b71adea4105fe8718 /src/openvic-simulation
parent429765a8cdc93cc8975d2676d04cb628c21064a4 (diff)
Trigger gamestate update in headless mode + add `update_clock` functionsupdate-clock
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/GameManager.cpp9
-rw-r--r--src/openvic-simulation/GameManager.hpp2
-rw-r--r--src/openvic-simulation/InstanceManager.cpp10
-rw-r--r--src/openvic-simulation/InstanceManager.hpp1
4 files changed, 22 insertions, 0 deletions
diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp
index 2577b54..2980dbd 100644
--- a/src/openvic-simulation/GameManager.cpp
+++ b/src/openvic-simulation/GameManager.cpp
@@ -74,3 +74,12 @@ bool GameManager::start_game_session() {
return instance_manager->start_game_session();
}
+
+bool GameManager::update_clock() {
+ if (!instance_manager) {
+ Logger::error("Cannot update clock - instance manager uninitialised!");
+ return false;
+ }
+
+ return instance_manager->update_clock();
+}
diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp
index fdbcb6a..91de279 100644
--- a/src/openvic-simulation/GameManager.hpp
+++ b/src/openvic-simulation/GameManager.hpp
@@ -38,5 +38,7 @@ namespace OpenVic {
bool setup_instance(Bookmark const* bookmark);
bool start_game_session();
+
+ bool update_clock();
};
}
diff --git a/src/openvic-simulation/InstanceManager.cpp b/src/openvic-simulation/InstanceManager.cpp
index 1df6e90..ea30246 100644
--- a/src/openvic-simulation/InstanceManager.cpp
+++ b/src/openvic-simulation/InstanceManager.cpp
@@ -148,6 +148,16 @@ bool InstanceManager::start_game_session() {
return true;
}
+bool InstanceManager::update_clock() {
+ if (!is_game_session_started()) {
+ Logger::error("Cannot update clock - game session not started!");
+ return false;
+ }
+
+ simulation_clock.conditionally_advance_game();
+ return true;
+}
+
bool InstanceManager::expand_selected_province_building(size_t building_index) {
set_gamestate_needs_update();
ProvinceInstance* province = map_instance.get_selected_province();
diff --git a/src/openvic-simulation/InstanceManager.hpp b/src/openvic-simulation/InstanceManager.hpp
index 9cf346a..cfb5447 100644
--- a/src/openvic-simulation/InstanceManager.hpp
+++ b/src/openvic-simulation/InstanceManager.hpp
@@ -58,6 +58,7 @@ namespace OpenVic {
bool setup();
bool load_bookmark(Bookmark const* new_bookmark);
bool start_game_session();
+ bool update_clock();
bool expand_selected_province_building(size_t building_index);
};