aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/headless/main.cpp3
-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
5 files changed, 25 insertions, 0 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp
index ecce333..fcb5e8d 100644
--- a/src/headless/main.cpp
+++ b/src/headless/main.cpp
@@ -49,6 +49,9 @@ static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests)
Logger::info("===== Starting game session... =====");
ret &= game_manager.start_game_session();
+ // This triggers a gamestate update
+ ret &= game_manager.update_clock();
+
return ret;
}
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);
};