aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-24 12:32:37 +0200
committer GitHub <noreply@github.com>2023-05-24 12:32:37 +0200
commit0a1a50cde54fee469bc0069978cd27a2bd1a2fb0 (patch)
tree2ba58efbe0ff3cfdc6f73b7a9e0bfab399d5e0d3
parentac36a373139e3e815f70720b37d4ffc8d9062df9 (diff)
parentd6db91738ceee5cce9e7b7efc32bec89a83fa790 (diff)
Merge pull request #124 from OpenVicProject/bug-fixes
Date fix + string fix + Logger queue
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/GameSingleton.cpp7
-rw-r--r--extension/src/GameSingleton.hpp4
-rw-r--r--extension/src/LoadGameCompatibility.cpp2
-rw-r--r--extension/src/Utilities.hpp6
-rw-r--r--game/src/Autoload/Events.gd2
-rw-r--r--game/src/GameSession/GameSession.gd2
7 files changed, 13 insertions, 10 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject 35b038fe91d4f3c4b3ffdc4f48385ac3b208266
+Subproject 8710cb9b7967de2201b5c440593aab2df310f33
diff --git a/extension/src/GameSingleton.cpp b/extension/src/GameSingleton.cpp
index cb7d0a7..e485cdc 100644
--- a/extension/src/GameSingleton.cpp
+++ b/extension/src/GameSingleton.cpp
@@ -12,9 +12,10 @@ using namespace OpenVic;
GameSingleton* GameSingleton::singleton = nullptr;
void GameSingleton::_bind_methods() {
+ ClassDB::bind_static_method("GameSingleton", D_METHOD("setup_logger"), &GameSingleton::setup_logger);
ClassDB::bind_method(D_METHOD("load_defines", "file_dict"), &GameSingleton::load_defines);
ClassDB::bind_method(D_METHOD("load_defines_compatibility_mode", "file_path"), &GameSingleton::load_defines_compatibility_mode);
- ClassDB::bind_method(D_METHOD("setup"), &GameSingleton::setup);
+ ClassDB::bind_method(D_METHOD("setup_game"), &GameSingleton::setup_game);
ClassDB::bind_method(D_METHOD("get_province_index_from_uv_coords", "coords"), &GameSingleton::get_province_index_from_uv_coords);
ClassDB::bind_method(D_METHOD("get_province_info_from_index", "index"), &GameSingleton::get_province_info_from_index);
@@ -88,7 +89,9 @@ GameSingleton::GameSingleton() : game_manager { [this]() { _on_state_updated();
terrain_variants { "terrain variants" } {
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
+}
+void GameSingleton::setup_logger() {
Logger::set_info_func([](std::string&& str) { UtilityFunctions::print(std_to_godot_string(str)); });
Logger::set_error_func([](std::string&& str) { UtilityFunctions::push_error(std_to_godot_string(str)); });
}
@@ -162,7 +165,7 @@ GameSingleton::~GameSingleton() {
singleton = nullptr;
}
-Error GameSingleton::setup() {
+Error GameSingleton::setup_game() {
return ERR(game_manager.setup());
}
diff --git a/extension/src/GameSingleton.hpp b/extension/src/GameSingleton.hpp
index 6bfb741..6c91de5 100644
--- a/extension/src/GameSingleton.hpp
+++ b/extension/src/GameSingleton.hpp
@@ -74,6 +74,8 @@ namespace OpenVic {
GameSingleton();
~GameSingleton();
+ static void setup_logger();
+
static godot::StringName const& get_province_identifier_file_key();
static godot::StringName const& get_water_province_file_key();
static godot::StringName const& get_region_file_key();
@@ -97,7 +99,7 @@ namespace OpenVic {
/* Post-load/restart game setup - reset the game to post-load state
* and (re)generate starting data, e.g. buildings.
*/
- godot::Error setup();
+ godot::Error setup_game();
int32_t get_province_index_from_uv_coords(godot::Vector2 const& coords) const;
diff --git a/extension/src/LoadGameCompatibility.cpp b/extension/src/LoadGameCompatibility.cpp
index 29b773e..96c165b 100644
--- a/extension/src/LoadGameCompatibility.cpp
+++ b/extension/src/LoadGameCompatibility.cpp
@@ -76,7 +76,7 @@ Error GameSingleton::_load_province_identifier_file_compatibility_mode(String co
Error GameSingleton::_load_terrain_variants_compatibility_mode(String const& terrain_image_path, String const& terrain_texturesheet_path) {
// Read BMP's palette to determine terrain variant colours which texture they're associated with
BMP bmp;
- if (bmp.open(godot_to_c_string(terrain_image_path)) != SUCCESS || bmp.read_header() != SUCCESS || bmp.read_palette() != SUCCESS) {
+ if (bmp.open(godot_to_std_string(terrain_image_path).c_str()) != SUCCESS || bmp.read_header() != SUCCESS || bmp.read_palette() != SUCCESS) {
UtilityFunctions::push_error("Failed to read BMP palette from compatibility mode terrain image: ", terrain_image_path);
return FAILED;
}
diff --git a/extension/src/Utilities.hpp b/extension/src/Utilities.hpp
index 16193e8..75e873f 100644
--- a/extension/src/Utilities.hpp
+++ b/extension/src/Utilities.hpp
@@ -8,12 +8,8 @@
namespace OpenVic {
- inline char const* godot_to_c_string(godot::String const& str) {
- return str.ascii().get_data();
- }
-
inline std::string godot_to_std_string(godot::String const& str) {
- return godot_to_c_string(str);
+ return str.ascii().get_data();
}
inline godot::String std_to_godot_string(std::string const& str) {
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index 0193a08..8800041 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -25,6 +25,8 @@ const _compatibility_mode_path : String = ""
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
func _ready():
+ GameSingleton.setup_logger()
+
var start := Time.get_ticks_usec()
if _compatibility_mode_path:
diff --git a/game/src/GameSession/GameSession.gd b/game/src/GameSession/GameSession.gd
index 556b98e..5bb1c2f 100644
--- a/game/src/GameSession/GameSession.gd
+++ b/game/src/GameSession/GameSession.gd
@@ -4,7 +4,7 @@ extends Control
func _ready():
Events.Options.load_settings_from_file()
- if GameSingleton.setup() != OK:
+ if GameSingleton.setup_game() != OK:
push_error("Failed to setup game")
func _process(delta : float):