From c3c6f8e3441aee2cbd3f7c13ac32d6705c368143 Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Sat, 26 Aug 2023 00:12:34 +0200 Subject: [PATCH] some IntrelliSense warnings --- src/game_api/file_api.cpp | 5 ++--- src/game_api/level_api.cpp | 2 +- src/game_api/render_api.cpp | 2 +- src/game_api/script/lua_vm.cpp | 2 +- src/game_api/script/usertypes/entity_lua.cpp | 2 +- src/game_api/script/usertypes/gui_lua.cpp | 4 ++-- src/game_api/script/usertypes/vanilla_render_lua.cpp | 4 ++-- src/game_api/string_hashes.cpp | 2 +- src/game_api/strings_get_hashes.py | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/game_api/file_api.cpp b/src/game_api/file_api.cpp index 44e8e8bf9..e7c8bccfc 100644 --- a/src/game_api/file_api.cpp +++ b/src/game_api/file_api.cpp @@ -62,7 +62,7 @@ std::string hash_path(std::string_view path) int i = 0; do { - uint64_t merge = std::toupper(abs_path_str[i]) * 65536 + std::toupper(abs_path_str[i + 1]); + uint64_t merge = (uint64_t)std::toupper(abs_path_str[i]) * 65536 + (uint64_t)std::toupper(abs_path_str[i + 1]); res = res * 8191 + merge; i++; } while (i < abs_path_str.length()); @@ -260,13 +260,12 @@ FileInfo* load_file_as_dds_if_image(const char* file_path, AllocFun alloc_fun) { fwrite(file_info->Data, sizeof(char), file_info->DataSize, cache_file); DEBUG("Cached '{}' to '{}'", path, cache_path.string()); + fclose(cache_file); } else { DEBUG("Couldn't cache '{}' to '{}'", path, cache_path.string()); } - fclose(cache_file); - return file_info; } } diff --git a/src/game_api/level_api.cpp b/src/game_api/level_api.cpp index 5ee5699d3..5ca86e4f3 100644 --- a/src/game_api/level_api.cpp +++ b/src/game_api/level_api.cpp @@ -1497,7 +1497,7 @@ std::uint32_t LevelGenData::define_tile_code(std::string tile_code) std::optional LevelGenData::get_short_tile_code(ShortTileCodeDef short_tile_code_def) { - for (auto [i, def] : short_tile_codes) + for (auto& [i, def] : short_tile_codes) { if (def == short_tile_code_def) { diff --git a/src/game_api/render_api.cpp b/src/game_api/render_api.cpp index 69ec9b4fd..ab1d26118 100644 --- a/src/game_api/render_api.cpp +++ b/src/game_api/render_api.cpp @@ -374,7 +374,7 @@ void on_open_journal_chapter(JournalUI* journal_ui, uint8_t chapter, bool instan } side ^= 0x1; } - for (auto p : pages_copy) // free unused screens + for (auto& p : pages_copy) // free unused screens { if (p.second) { diff --git a/src/game_api/script/lua_vm.cpp b/src/game_api/script/lua_vm.cpp index d4759b545..acbad8b46 100644 --- a/src/game_api/script/lua_vm.cpp +++ b/src/game_api/script/lua_vm.cpp @@ -2473,7 +2473,7 @@ end //, "", ...check__[game_settings.txt]\[game_data/game_settings.txt\]... //, "CROSSPROGRESS_AUTOSYNC", 47 ); - for (auto [setting_name_view, setting_index] : get_settings_names_and_indices()) + for (auto& [setting_name_view, setting_index] : get_settings_names_and_indices()) { std::string setting_name{setting_name_view}; std::transform(setting_name.begin(), setting_name.end(), setting_name.begin(), [](unsigned char c) diff --git a/src/game_api/script/usertypes/entity_lua.cpp b/src/game_api/script/usertypes/entity_lua.cpp index db99f6f9a..fe421c0d4 100644 --- a/src/game_api/script/usertypes/entity_lua.cpp +++ b/src/game_api/script/usertypes/entity_lua.cpp @@ -327,7 +327,7 @@ void register_usertypes(sol::state& lua) auto name = item.name.substr(9, item.name.size()); lua["ENT_TYPE"][name] = item.id; } - for (auto elm : get_custom_types_map()) + for (auto& elm : get_custom_types_map()) { lua["ENT_TYPE"][elm.second] = elm.first; } diff --git a/src/game_api/script/usertypes/gui_lua.cpp b/src/game_api/script/usertypes/gui_lua.cpp index f9ed34d48..bac36a4a3 100644 --- a/src/game_api/script/usertypes/gui_lua.cpp +++ b/src/game_api/script/usertypes/gui_lua.cpp @@ -149,7 +149,7 @@ void GuiDrawContext::draw_poly(std::vector points, float thickness, uColor auto draw = [&](ImDrawList* dl) { dl->PathClear(); - for (auto point : points) + for (auto& point : points) { ImVec2 a = screenify_fix({point.x, point.y}); dl->PathLineToMergeDuplicate(a); @@ -170,7 +170,7 @@ void GuiDrawContext::draw_poly_filled(std::vector points, uColor color) auto draw = [&](ImDrawList* dl) { dl->PathClear(); - for (auto point : points) + for (auto& point : points) { ImVec2 a = screenify_fix({point.x, point.y}); dl->PathLineToMergeDuplicate(a); diff --git a/src/game_api/script/usertypes/vanilla_render_lua.cpp b/src/game_api/script/usertypes/vanilla_render_lua.cpp index 10eaad6a2..6acac6df3 100644 --- a/src/game_api/script/usertypes/vanilla_render_lua.cpp +++ b/src/game_api/script/usertypes/vanilla_render_lua.cpp @@ -337,7 +337,7 @@ void VanillaRenderContext::draw_screen_poly(std::vector points, float thic if (!corner.is_null()) draw_screen_poly_filled(convert_ratio(corner, true), std::move(color)); } - for (auto line : draw_list) + for (auto& line : draw_list) { draw_screen_poly_filled(convert_ratio(line, true), std::move(color)); } @@ -533,7 +533,7 @@ void VanillaRenderContext::draw_world_poly(std::vector points, float thick if (!corner.is_null()) draw_world_poly_filled(corner, std::move(color)); } - for (auto line : draw_list) + for (auto& line : draw_list) { draw_world_poly_filled(line, std::move(color)); } diff --git a/src/game_api/string_hashes.cpp b/src/game_api/string_hashes.cpp index 45f8dc37e..7c643280c 100644 --- a/src/game_api/string_hashes.cpp +++ b/src/game_api/string_hashes.cpp @@ -1,6 +1,6 @@ // THIS FILE IS AUTO-GENERATED -// If you need to make changes it please change strings_get_hashes.py +// If you need to make changes to it, please change "strings_get_hashes.py" #include // for uint32_t #include // for less diff --git a/src/game_api/strings_get_hashes.py b/src/game_api/strings_get_hashes.py index 11f3d4875..6dcb5001a 100644 --- a/src/game_api/strings_get_hashes.py +++ b/src/game_api/strings_get_hashes.py @@ -9,7 +9,7 @@ print( """ // THIS FILE IS AUTO-GENERATED -// If you need to make changes it please change strings_get_hashes.py +// If you need to make changes to it, please change "strings_get_hashes.py" #include // for uint32_t #include // for less