aboutsummaryrefslogtreecommitdiff
path: root/extension/src/MapSingleton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/MapSingleton.cpp')
-rw-r--r--extension/src/MapSingleton.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/extension/src/MapSingleton.cpp b/extension/src/MapSingleton.cpp
index 9f76508..9d13496 100644
--- a/extension/src/MapSingleton.cpp
+++ b/extension/src/MapSingleton.cpp
@@ -13,7 +13,7 @@ void MapSingleton::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_province_identifier_file", "file_path"), &MapSingleton::load_province_identifier_file);
ClassDB::bind_method(D_METHOD("load_province_shape_file", "file_path"), &MapSingleton::load_province_shape_file);
ClassDB::bind_method(D_METHOD("get_province_shape_image"), &MapSingleton::get_province_shape_image);
- ClassDB::bind_method(D_METHOD("get_province_id"), &MapSingleton::get_province_id);
+ ClassDB::bind_method(D_METHOD("get_province_identifier_from_colour", "colour"), &MapSingleton::get_province_identifier_from_colour);
}
MapSingleton* MapSingleton::get_singleton() {
@@ -64,9 +64,9 @@ Error MapSingleton::load_province_identifier_file(String const& file_path) {
err = FAILED;
continue;
}
- // static const String prov_prefix = "prov_";
- // if (!identifier.begins_with(prov_prefix))
- // UtilityFunctions::push_warning("Province identifier missing prefix: ", identifier);
+ static const String prov_prefix = "prov_";
+ if (!identifier.begins_with(prov_prefix))
+ UtilityFunctions::push_warning("Province identifier missing prefix: ", identifier);
type = colour_var.get_type();
Province::colour_t colour = Province::NULL_COLOUR;
if (type == Variant::ARRAY) {
@@ -115,12 +115,10 @@ Error MapSingleton::load_province_identifier_file(String const& file_path) {
return err;
}
-godot::String MapSingleton::get_province_id(godot::String const& hex_str) {
- UtilityFunctions::print(hex_str);
- int64_t colour_string = hex_str.hex_to_int();
- godot::String province_id = map.get_province(colour_string).identifier.c_str();
- UtilityFunctions::print("Returning: ",map.get_province(colour_string).to_string().c_str());
- return province_id;
+String MapSingleton::get_province_identifier_from_colour(Province::colour_t colour) {
+ const Province* province = map.get_province_by_colour(colour);
+ if (province) return province->get_identifier().c_str();
+ else return String{};
}
Error MapSingleton::load_province_shape_file(String const& file_path) {