diff options
author | Hop311 <hop3114@gmail.com> | 2023-08-17 21:55:15 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-09 21:52:00 +0200 |
commit | 5d127faa9388ecb763846c3bf19190c891d2a583 (patch) | |
tree | 414e7e5703a5ff37fbfa79d4df7e94ca0cddd7de /extension | |
parent | 1013b3c21226f703caba954664628694aedde469 (diff) |
Moved index_t back to Province
Diffstat (limited to 'extension')
m--------- | extension/deps/openvic-simulation | 0 | ||||
-rw-r--r-- | extension/src/GameSingleton.cpp | 4 | ||||
-rw-r--r-- | extension/src/GameSingleton.hpp | 2 | ||||
-rw-r--r-- | extension/src/LoadGameCompatibility.cpp | 6 | ||||
-rw-r--r-- | extension/src/LoadGameOpenVic.cpp | 7 |
5 files changed, 10 insertions, 9 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation -Subproject 383ef70bea656a77e8b7c6843fd4a79705ecde4 +Subproject 419e58e8de977d7a619b7451bb6d4242af4569f diff --git a/extension/src/GameSingleton.cpp b/extension/src/GameSingleton.cpp index 18fd67a..25f7195 100644 --- a/extension/src/GameSingleton.cpp +++ b/extension/src/GameSingleton.cpp @@ -381,14 +381,14 @@ Ref<Texture> GameSingleton::get_province_colour_texture() const { Error GameSingleton::_update_colour_image() { static PackedByteArray colour_data_array; - static constexpr int64_t colour_data_array_size = (MAX_INDEX + 1) * Map::MAPMODE_COLOUR_SIZE; + static constexpr int64_t colour_data_array_size = (static_cast<int64_t>(Province::MAX_INDEX) + 1) * Map::MAPMODE_COLOUR_SIZE; colour_data_array.resize(colour_data_array_size); Error err = OK; if (game_manager.map.generate_mapmode_colours(mapmode_index, colour_data_array.ptrw()) != SUCCESS) err = FAILED; - static constexpr int32_t PROVINCE_INDEX_SQRT = 1 << (sizeof(index_t) * 4); + static constexpr int32_t PROVINCE_INDEX_SQRT = 1 << (sizeof(Province::index_t) * 4); if (province_colour_image.is_null()) { province_colour_image.instantiate(); ERR_FAIL_NULL_V_EDMSG(province_colour_image, FAILED, diff --git a/extension/src/GameSingleton.hpp b/extension/src/GameSingleton.hpp index cd8cdd0..a1d77c1 100644 --- a/extension/src/GameSingleton.hpp +++ b/extension/src/GameSingleton.hpp @@ -15,7 +15,7 @@ namespace OpenVic { TerrainVariant(const std::string_view new_identfier, colour_t new_colour, godot::Ref<godot::Image> const& new_image); public: - static constexpr size_t MAX_INDEX = 1 << (8 * sizeof(Map::terrain_t)); + static constexpr size_t MAX_TERRIN_VARIANT_COUNT = 1 << (8 * sizeof(Map::terrain_t)); TerrainVariant(TerrainVariant&&) = default; diff --git a/extension/src/LoadGameCompatibility.cpp b/extension/src/LoadGameCompatibility.cpp index 71435a4..27d8250 100644 --- a/extension/src/LoadGameCompatibility.cpp +++ b/extension/src/LoadGameCompatibility.cpp @@ -28,14 +28,14 @@ Error GameSingleton::_load_province_identifier_file_compatibility_mode(String co continue; if (line_number < 2) continue; // skip header line - index_t id = NULL_INDEX; + Province::index_t id = Province::NULL_INDEX; colour_t colour = NULL_COLOUR; if (line.size() > 0) { if (line[0].is_empty()) { id = game_manager.map.get_province_count() + 1; } else if (line[0].is_valid_int()) { const int64_t val = line[0].to_int(); - if (val > NULL_INDEX && val <= MAX_INDEX) id = val; + if (val > Province::NULL_INDEX && val <= Province::MAX_INDEX) id = val; } for (int i = 1; i < 4; ++i) { if (line.size() > i) { @@ -60,7 +60,7 @@ Error GameSingleton::_load_province_identifier_file_compatibility_mode(String co break; } } - if (id == NULL_INDEX || colour == NULL_COLOUR) { + if (id == Province::NULL_INDEX || colour == NULL_COLOUR) { UtilityFunctions::push_error("Invalid province ID-colour entry \"", line, "\" on line ", line_number, " in file: ", file_path); err = FAILED; continue; diff --git a/extension/src/LoadGameOpenVic.cpp b/extension/src/LoadGameOpenVic.cpp index 627578f..8e29f60 100644 --- a/extension/src/LoadGameOpenVic.cpp +++ b/extension/src/LoadGameOpenVic.cpp @@ -205,13 +205,14 @@ Error GameSingleton::_generate_terrain_texture_array() { return FAILED; } // TerrainVariant count is limited by the data type representing it in the map image - if (terrain_variants.get_item_count() > TerrainVariant::MAX_INDEX) { - UtilityFunctions::push_error("Too many terrain textures - all after the first ", MAX_INDEX, " will be ignored"); + if (terrain_variants.get_item_count() > TerrainVariant::MAX_TERRIN_VARIANT_COUNT) { + UtilityFunctions::push_error("Too many terrain textures - all after the first ", + static_cast<uint64_t>(TerrainVariant::MAX_TERRIN_VARIANT_COUNT), " will be ignored"); err = FAILED; } Array terrain_images; - for (size_t i = 0; i < terrain_variants.get_item_count() && i < TerrainVariant::MAX_INDEX; ++i) { + for (size_t i = 0; i < terrain_variants.get_item_count() && i < TerrainVariant::MAX_TERRIN_VARIANT_COUNT; ++i) { TerrainVariant const& var = *terrain_variants.get_item_by_index(i); terrain_variant_map[var.get_colour()] = i; terrain_images.append(var.get_image()); |