From 0103af1ddda6a2aa31227965141dd7d3a513e081 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:53:28 +0300 Subject: Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. --- .github/workflows/windows_builds.yml | 2 +- SConstruct | 34 +- core/config/project_settings.cpp | 26 +- core/input/input.cpp | 1 - core/input/input_event.cpp | 42 +- core/io/file_access_encrypted.cpp | 8 +- core/io/file_access_network.cpp | 8 +- core/io/http_client_tcp.cpp | 20 +- core/io/image.cpp | 10 +- core/io/image_loader.cpp | 2 +- core/io/resource_format_binary.cpp | 20 +- core/io/resource_importer.cpp | 4 +- core/io/resource_loader.cpp | 8 +- core/io/resource_saver.cpp | 4 +- core/io/stream_peer_tcp.cpp | 4 +- core/io/stream_peer_tcp.h | 2 +- core/math/expression.cpp | 54 +-- core/math/projection.cpp | 14 +- core/math/triangle_mesh.cpp | 18 +- core/object/script_language.cpp | 12 +- core/string/optimized_translation.cpp | 18 +- core/string/translation.cpp | 101 +++-- core/variant/callable.cpp | 24 +- core/variant/variant.cpp | 4 - drivers/gles3/rasterizer_gles3.cpp | 10 +- drivers/vulkan/rendering_device_vulkan.cpp | 16 +- drivers/vulkan/rendering_device_vulkan.h | 2 +- drivers/vulkan/vulkan_context.cpp | 4 +- drivers/vulkan/vulkan_context.h | 2 +- drivers/windows/dir_access_windows.cpp | 6 +- drivers/windows/file_access_windows.cpp | 6 +- editor/animation_bezier_editor.cpp | 14 +- editor/animation_track_editor.cpp | 102 +++-- editor/animation_track_editor_plugins.cpp | 36 +- editor/code_editor.cpp | 18 +- editor/connections_dialog.cpp | 28 +- editor/create_dialog.cpp | 20 +- .../debug_adapter/debug_adapter_protocol.cpp | 12 +- .../debug_adapter/debug_adapter_server.cpp | 8 +- editor/debugger/editor_debugger_inspector.cpp | 10 +- editor/debugger/editor_debugger_node.cpp | 7 +- editor/debugger/editor_performance_profiler.cpp | 8 +- editor/debugger/script_editor_debugger.cpp | 24 +- editor/dependency_editor.cpp | 6 +- editor/dependency_editor.h | 2 +- editor/editor_asset_installer.cpp | 16 +- editor/editor_audio_buses.cpp | 8 +- editor/editor_autoload_settings.cpp | 49 ++- editor/editor_file_dialog.cpp | 26 +- editor/editor_file_system.cpp | 32 +- editor/editor_help.cpp | 17 +- editor/editor_help_search.cpp | 22 +- editor/editor_inspector.cpp | 32 +- editor/editor_locale_dialog.cpp | 10 +- editor/editor_node.cpp | 150 ++++--- editor/editor_path.cpp | 14 +- editor/editor_plugin.cpp | 6 +- editor/editor_plugin_settings.cpp | 6 +- editor/editor_properties.cpp | 24 +- editor/editor_properties_array_dict.cpp | 44 +- editor/editor_resource_picker.cpp | 16 +- editor/editor_resource_preview.cpp | 6 +- editor/editor_sectioned_inspector.cpp | 6 +- editor/editor_settings.cpp | 18 +- editor/editor_toaster.cpp | 22 +- editor/export/export_template_manager.cpp | 30 +- editor/export/project_export.cpp | 26 +- editor/filesystem_dock.cpp | 114 +++-- editor/filesystem_dock.h | 6 +- editor/find_in_files.cpp | 4 +- editor/find_in_files.h | 2 +- editor/import/audio_stream_import_settings.cpp | 14 +- editor/import/dynamic_font_import_settings.cpp | 12 +- editor/import/editor_import_plugin.cpp | 4 +- .../import/resource_importer_layered_texture.cpp | 18 +- editor/import/resource_importer_texture.cpp | 30 +- editor/inspector_dock.cpp | 16 +- editor/plugin_config_dialog.cpp | 8 +- editor/plugins/abstract_polygon_2d_editor.cpp | 4 +- editor/plugins/animation_blend_space_2d_editor.cpp | 26 +- .../plugins/animation_blend_tree_editor_plugin.cpp | 24 +- editor/plugins/animation_player_editor_plugin.cpp | 20 +- editor/plugins/asset_library_editor_plugin.cpp | 22 +- .../audio_stream_randomizer_editor_plugin.cpp | 16 +- editor/plugins/canvas_item_editor_plugin.cpp | 462 ++++++++++----------- editor/plugins/cpu_particles_2d_editor_plugin.cpp | 4 +- .../plugins/editor_resource_conversion_plugin.cpp | 2 +- editor/plugins/gpu_particles_2d_editor_plugin.cpp | 4 +- editor/plugins/gpu_particles_3d_editor_plugin.cpp | 22 +- editor/plugins/gradient_editor.cpp | 4 +- editor/plugins/line_2d_editor_plugin.cpp | 6 +- editor/plugins/node_3d_editor_gizmos.cpp | 10 +- editor/plugins/node_3d_editor_plugin.cpp | 26 +- editor/plugins/path_3d_editor_plugin.cpp | 18 +- editor/plugins/script_editor_plugin.cpp | 218 +++++----- editor/plugins/script_text_editor.cpp | 26 +- editor/plugins/skeleton_3d_editor_plugin.cpp | 24 +- editor/plugins/sprite_frames_editor_plugin.cpp | 4 +- editor/plugins/text_shader_editor.cpp | 100 ++--- editor/plugins/tiles/tile_data_editors.cpp | 36 +- editor/plugins/tiles/tile_map_editor.cpp | 30 +- .../plugins/tiles/tile_set_atlas_source_editor.cpp | 16 +- editor/plugins/tiles/tile_set_editor.cpp | 84 ++-- editor/plugins/tiles/tiles_editor_plugin.cpp | 4 +- editor/plugins/visual_shader_editor_plugin.cpp | 302 +++++++------- editor/project_manager.cpp | 14 +- editor/project_settings_editor.cpp | 6 +- editor/rename_dialog.cpp | 6 +- editor/scene_create_dialog.cpp | 6 +- editor/scene_tree_dock.cpp | 12 +- editor/scene_tree_editor.cpp | 48 +-- editor/script_create_dialog.cpp | 10 +- editor/script_create_dialog.h | 4 +- editor/shader_create_dialog.cpp | 30 +- modules/csg/csg_shape.cpp | 110 ++--- modules/enet/enet_multiplayer_peer.cpp | 6 +- modules/gdscript/editor/gdscript_highlighter.cpp | 12 +- modules/gdscript/gdscript.cpp | 134 +++--- modules/gdscript/gdscript.h | 2 +- modules/gdscript/gdscript_analyzer.cpp | 30 +- modules/gdscript/gdscript_compiler.cpp | 104 ++--- modules/gdscript/gdscript_compiler.h | 8 +- modules/gdscript/gdscript_disassembler.cpp | 4 +- modules/gdscript/gdscript_editor.cpp | 28 +- modules/gdscript/gdscript_function.cpp | 10 +- modules/gdscript/gdscript_parser.cpp | 22 +- modules/gdscript/gdscript_parser.h | 20 +- modules/gdscript/gdscript_tokenizer.cpp | 18 +- modules/gdscript/gdscript_vm.cpp | 2 +- .../language_server/gdscript_extend_parser.cpp | 42 +- .../language_server/gdscript_language_server.cpp | 12 +- .../language_server/gdscript_text_document.cpp | 22 +- .../language_server/gdscript_workspace.cpp | 36 +- .../gltf/editor/editor_scene_importer_blend.cpp | 10 +- modules/gltf/extensions/gltf_light.cpp | 5 +- modules/gltf/gltf_document.cpp | 95 +++-- modules/gridmap/grid_map.cpp | 8 +- modules/lightmapper_rd/lightmapper_rd.cpp | 8 +- modules/multiplayer/scene_replication_config.cpp | 16 +- modules/noise/noise_texture_2d.cpp | 18 +- modules/openxr/action_map/openxr_action.cpp | 6 +- modules/openxr/openxr_interface.cpp | 24 +- modules/openxr/util.h | 84 ++-- modules/text_server_adv/text_server_adv.cpp | 4 +- modules/theora/video_stream_theora.cpp | 35 +- platform/macos/export/macho.cpp | 10 +- scene/2d/audio_listener_2d.cpp | 1 - scene/2d/collision_object_2d.cpp | 20 +- scene/2d/cpu_particles_2d.cpp | 71 ++-- scene/2d/gpu_particles_2d.cpp | 10 +- scene/2d/navigation_obstacle_2d.cpp | 10 +- scene/2d/parallax_background.cpp | 28 +- scene/2d/parallax_layer.cpp | 12 +- scene/2d/physics_body_2d.cpp | 22 +- scene/2d/skeleton_2d.cpp | 6 +- scene/2d/tile_map.cpp | 112 ++--- scene/3d/audio_listener_3d.cpp | 2 - scene/3d/collision_object_3d.cpp | 24 +- scene/3d/collision_shape_3d.cpp | 6 +- scene/3d/cpu_particles_3d.cpp | 36 +- scene/3d/gpu_particles_collision_3d.cpp | 44 +- scene/3d/gpu_particles_collision_3d.h | 2 +- scene/3d/label_3d.cpp | 18 +- scene/3d/lightmap_gi.cpp | 34 +- scene/3d/mesh_instance_3d.cpp | 20 +- scene/3d/navigation_obstacle_3d.cpp | 10 +- scene/3d/path_3d.cpp | 4 +- scene/3d/physics_body_3d.cpp | 22 +- scene/3d/soft_body_3d.cpp | 8 +- scene/3d/sprite_3d.cpp | 54 +-- scene/3d/visible_on_screen_notifier_3d.cpp | 5 +- scene/3d/voxel_gi.cpp | 22 +- scene/animation/animation_blend_space_2d.cpp | 36 +- scene/animation/animation_blend_tree.cpp | 216 +++++----- scene/animation/animation_node_state_machine.cpp | 52 +-- scene/animation/animation_player.cpp | 7 +- scene/animation/animation_tree.cpp | 8 +- scene/animation/tween.cpp | 12 +- scene/debugger/scene_debugger.cpp | 6 +- scene/gui/code_edit.cpp | 16 +- scene/gui/color_picker.cpp | 94 ++--- scene/gui/control.cpp | 2 +- scene/gui/dialogs.cpp | 10 +- scene/gui/file_dialog.cpp | 8 +- scene/gui/graph_edit.cpp | 6 +- scene/gui/graph_node.cpp | 4 +- scene/gui/item_list.cpp | 14 +- scene/gui/label.cpp | 6 +- scene/gui/line_edit.cpp | 4 +- scene/gui/menu_bar.cpp | 20 +- scene/gui/menu_button.cpp | 20 +- scene/gui/popup.cpp | 40 +- scene/gui/popup_menu.cpp | 16 +- scene/gui/rich_text_label.cpp | 176 ++++---- scene/gui/rich_text_label.h | 12 +- scene/gui/text_edit.cpp | 54 +-- scene/gui/tree.cpp | 44 +- scene/main/multiplayer_api.cpp | 8 +- scene/main/node.cpp | 12 +- scene/main/scene_tree.cpp | 92 ++-- scene/main/viewport.cpp | 26 +- scene/main/window.cpp | 24 +- scene/resources/animation.cpp | 22 +- scene/resources/audio_stream_wav.cpp | 4 +- scene/resources/capsule_shape_3d.cpp | 10 +- scene/resources/convex_polygon_shape_3d.cpp | 6 +- scene/resources/cylinder_shape_3d.cpp | 10 +- scene/resources/font.cpp | 36 +- scene/resources/importer_mesh.cpp | 6 +- scene/resources/mesh.cpp | 42 +- scene/resources/mesh_library.cpp | 30 +- scene/resources/navigation_mesh.cpp | 24 +- scene/resources/packed_scene.cpp | 10 +- scene/resources/polygon_path_finder.cpp | 8 +- scene/resources/primitive_meshes.cpp | 8 +- scene/resources/resource_format_text.cpp | 28 +- scene/resources/skin.cpp | 20 +- scene/resources/sprite_frames.cpp | 6 +- scene/resources/texture.cpp | 6 +- scene/resources/theme.cpp | 34 +- scene/resources/tile_set.cpp | 6 +- scene/resources/visual_shader.cpp | 380 ++++++++--------- scene/resources/visual_shader.h | 2 +- scene/resources/visual_shader_particle_nodes.cpp | 20 +- servers/audio/effects/audio_effect_eq.cpp | 6 +- servers/navigation_server_3d.cpp | 20 +- servers/physics_2d/godot_area_2d.cpp | 6 +- servers/physics_2d/godot_body_2d.cpp | 16 +- servers/physics_2d/godot_joints_2d.cpp | 6 +- servers/physics_2d/godot_shape_2d.cpp | 66 +-- servers/physics_3d/godot_area_3d.cpp | 6 +- servers/physics_3d/godot_body_3d.cpp | 30 +- servers/physics_3d/godot_shape_3d.cpp | 76 ++-- servers/rendering/renderer_canvas_cull.cpp | 32 +- servers/rendering/renderer_canvas_cull.h | 4 +- .../renderer_rd/renderer_scene_render_rd.cpp | 10 +- servers/rendering/rendering_device_binds.h | 4 +- servers/rendering/shader_compiler.cpp | 6 +- thirdparty/misc/patches/polypartition-hole.patch | 15 + thirdparty/misc/polypartition.h | 4 +- 240 files changed, 3408 insertions(+), 3449 deletions(-) create mode 100644 thirdparty/misc/patches/polypartition-hole.patch diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 507bb21a46..31661e3f90 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -6,7 +6,7 @@ on: [push, pull_request] env: # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: master - SCONSFLAGS: verbose=yes warnings=all werror=yes module_text_server_fb_enabled=yes + SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes SCONS_CACHE_MSVC_CONFIG: true concurrency: diff --git a/SConstruct b/SConstruct index 646f41839d..1eb6bdcbfd 100644 --- a/SConstruct +++ b/SConstruct @@ -651,16 +651,32 @@ if selected_platform in platform_list: # Configure compiler warnings if env.msvc: # MSVC - # Truncations, narrowing conversions, signed/unsigned comparisons... - disable_nonessential_warnings = ["/wd4267", "/wd4244", "/wd4305", "/wd4018", "/wd4800"] - if env["warnings"] == "extra": - env.Append(CCFLAGS=["/Wall"]) # Implies /W4 - elif env["warnings"] == "all": - env.Append(CCFLAGS=["/W3"] + disable_nonessential_warnings) - elif env["warnings"] == "moderate": - env.Append(CCFLAGS=["/W2"] + disable_nonessential_warnings) - else: # 'no' + if env["warnings"] == "no": env.Append(CCFLAGS=["/w"]) + else: + if env["warnings"] == "extra": + env.Append(CCFLAGS=["/W4"]) + elif env["warnings"] == "all": + env.Append(CCFLAGS=["/W3"]) + elif env["warnings"] == "moderate": + env.Append(CCFLAGS=["/W2"]) + # Disable warnings which we don't plan to fix. + + env.Append( + CCFLAGS=[ + "/wd4100", # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism. + "/wd4127", # C4127 (conditional expression is constant) + "/wd4201", # C4201 (non-standard nameless struct/union): Only relevant for C89. + "/wd4244", # C4244 C4245 C4267 (narrowing conversions): Unavoidable at this scale. + "/wd4245", + "/wd4267", + "/wd4305", # C4305 (truncation): double to float or real_t, too hard to avoid. + "/wd4514", # C4514 (unreferenced inline function has been removed) + "/wd4714", # C4714 (function marked as __forceinline not inlined) + "/wd4820", # C4820 (padding added after construct) + ] + ) + # Set exception handling model to avoid warnings caused by Windows system headers. env.Append(CCFLAGS=["/EHsc"]) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 4d19a93991..001a351e0b 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -785,7 +785,7 @@ Error ProjectSettings::save() { return error; } -Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap> &p_props, const CustomMap &p_custom, const String &p_custom_features) { Error err; Ref file = FileAccess::open(p_file, FileAccess::WRITE, &err); ERR_FAIL_COND_V_MSG(err != OK, err, "Couldn't save project.binary at " + p_file + "."); @@ -795,7 +795,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap> &E : props) { + for (const KeyValue> &E : p_props) { count += E.value.size(); } @@ -821,7 +821,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMapstore_32(count); //store how many properties are saved } - for (const KeyValue> &E : props) { + for (const KeyValue> &E : p_props) { for (const String &key : E.value) { String k = key; if (!E.key.is_empty()) { @@ -853,7 +853,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const RBMap> &props, const CustomMap &p_custom, const String &p_custom_features) { +Error ProjectSettings::_save_settings_text(const String &p_file, const RBMap> &p_props, const CustomMap &p_custom, const String &p_custom_features) { Error err; Ref file = FileAccess::open(p_file, FileAccess::WRITE, &err); @@ -874,8 +874,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const RBMapstore_string("\n"); - for (const KeyValue> &E : props) { - if (E.key != props.begin()->key) { + for (const KeyValue> &E : p_props) { + if (E.key != p_props.begin()->key) { file->store_string("\n"); } @@ -980,7 +980,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust vclist.insert(vc); } - RBMap> props; + RBMap> save_props; for (const _VCSort &E : vclist) { String category = E.name; @@ -994,24 +994,24 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust category = category.substr(0, div); name = name.substr(div + 1, name.size()); } - props[category].push_back(name); + save_props[category].push_back(name); } - String custom_features; + String save_features; for (int i = 0; i < p_custom_features.size(); i++) { if (i > 0) { - custom_features += ","; + save_features += ","; } String f = p_custom_features[i].strip_edges().replace("\"", ""); - custom_features += f; + save_features += f; } if (p_path.ends_with(".godot") || p_path.ends_with("override.cfg")) { - return _save_settings_text(p_path, props, p_custom, custom_features); + return _save_settings_text(p_path, save_props, p_custom, save_features); } else if (p_path.ends_with(".binary")) { - return _save_settings_binary(p_path, props, p_custom, custom_features); + return _save_settings_binary(p_path, save_props, p_custom, save_features); } else { ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown config file format: " + p_path + "."); } diff --git a/core/input/input.cpp b/core/input/input.cpp index 1390a0a7fa..889c2a92fa 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -365,7 +365,6 @@ Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_po // Inverse lerp length to map (p_deadzone, 1) to (0, 1). return vector * (Math::inverse_lerp(p_deadzone, 1.0f, length) / length); } - return vector; } float Input::get_joy_axis(int p_device, JoyAxis p_axis) const { diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 712fc68c93..38037eaf72 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -449,11 +449,11 @@ bool InputEventKey::action_match(const Ref &p_event, bool p_exact_ma match &= action_mask == key_mask; } if (match) { - bool pressed = key->is_pressed(); + bool key_pressed = key->is_pressed(); if (r_pressed != nullptr) { - *r_pressed = pressed; + *r_pressed = key_pressed; } - float strength = pressed ? 1.0f : 0.0f; + float strength = key_pressed ? 1.0f : 0.0f; if (r_strength != nullptr) { *r_strength = strength; } @@ -610,20 +610,20 @@ bool InputEventMouseButton::action_match(const Ref &p_event, bool p_ } bool match = button_index == mb->button_index; - Key action_mask = get_modifiers_mask(); - Key button_mask = mb->get_modifiers_mask(); + Key action_modifiers_mask = get_modifiers_mask(); + Key button_modifiers_mask = mb->get_modifiers_mask(); if (mb->is_pressed()) { - match &= (action_mask & button_mask) == action_mask; + match &= (action_modifiers_mask & button_modifiers_mask) == action_modifiers_mask; } if (p_exact_match) { - match &= action_mask == button_mask; + match &= action_modifiers_mask == button_modifiers_mask; } if (match) { - bool pressed = mb->is_pressed(); + bool mb_pressed = mb->is_pressed(); if (r_pressed != nullptr) { - *r_pressed = pressed; + *r_pressed = mb_pressed; } - float strength = pressed ? 1.0f : 0.0f; + float strength = mb_pressed ? 1.0f : 0.0f; if (r_strength != nullptr) { *r_strength = strength; } @@ -808,9 +808,9 @@ String InputEventMouseMotion::as_text() const { } String InputEventMouseMotion::to_string() { - MouseButton button_mask = get_button_mask(); - String button_mask_string = itos((int64_t)button_mask); - switch (button_mask) { + MouseButton mouse_button_mask = get_button_mask(); + String button_mask_string = itos((int64_t)mouse_button_mask); + switch (mouse_button_mask) { case MouseButton::MASK_LEFT: button_mask_string += vformat(" (%s)", TTRGET(_mouse_button_descriptions[(size_t)MouseButton::LEFT - 1])); break; @@ -1045,11 +1045,11 @@ bool InputEventJoypadButton::action_match(const Ref &p_event, bool p bool match = button_index == jb->button_index; if (match) { - bool pressed = jb->is_pressed(); + bool jb_pressed = jb->is_pressed(); if (r_pressed != nullptr) { - *r_pressed = pressed; + *r_pressed = jb_pressed; } - float strength = pressed ? 1.0f : 0.0f; + float strength = jb_pressed ? 1.0f : 0.0f; if (r_strength != nullptr) { *r_strength = strength; } @@ -1340,16 +1340,16 @@ bool InputEventAction::action_match(const Ref &p_event, bool p_exact bool match = action == act->action; if (match) { - bool pressed = act->pressed; + bool act_pressed = act->pressed; if (r_pressed != nullptr) { - *r_pressed = pressed; + *r_pressed = act_pressed; } - float strength = pressed ? 1.0f : 0.0f; + float act_strength = act_pressed ? 1.0f : 0.0f; if (r_strength != nullptr) { - *r_strength = strength; + *r_strength = act_strength; } if (r_raw_strength != nullptr) { - *r_raw_strength = strength; + *r_raw_strength = act_strength; } } return match; diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index be502dacd9..e7b2a2dfee 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -102,13 +102,13 @@ Error FileAccessEncrypted::open_and_parse(Ref p_base, const Vector p_base, const String &p_key, Mode p_mode) { String cs = p_key.md5_text(); ERR_FAIL_COND_V(cs.length() != 32, ERR_INVALID_PARAMETER); - Vector key; - key.resize(32); + Vector key_md5; + key_md5.resize(32); for (int i = 0; i < 32; i++) { - key.write[i] = cs[i]; + key_md5.write[i] = cs[i]; } - return open_and_parse(p_base, key, p_mode); + return open_and_parse(p_base, key_md5, p_mode); } Error FileAccessEncrypted::open_internal(const String &p_path, int p_mode_flags) { diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 13730518bf..87f3f66597 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -137,12 +137,12 @@ void FileAccessNetworkClient::_thread_func() { int64_t offset = get_64(); int32_t len = get_32(); - Vector block; - block.resize(len); - client->get_data(block.ptrw(), len); + Vector resp_block; + resp_block.resize(len); + client->get_data(resp_block.ptrw(), len); if (fa) { //may have been queued - fa->_set_block(offset, block); + fa->_set_block(offset, resp_block); } } break; diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 5c1d00a330..aff79320ca 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -358,38 +358,38 @@ Error HTTPClientTCP::poll() { } break; } } else if (tls) { - Ref tls; + Ref tls_conn; if (!handshaking) { // Connect the StreamPeerTLS and start handshaking. - tls = Ref(StreamPeerTLS::create()); - tls->set_blocking_handshake_enabled(false); - Error err = tls->connect_to_stream(tcp_connection, tls_verify_host, conn_host); + tls_conn = Ref(StreamPeerTLS::create()); + tls_conn->set_blocking_handshake_enabled(false); + Error err = tls_conn->connect_to_stream(tcp_connection, tls_verify_host, conn_host); if (err != OK) { close(); status = STATUS_TLS_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } - connection = tls; + connection = tls_conn; handshaking = true; } else { // We are already handshaking, which means we can use your already active TLS connection. - tls = static_cast>(connection); - if (tls.is_null()) { + tls_conn = static_cast>(connection); + if (tls_conn.is_null()) { close(); status = STATUS_TLS_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } - tls->poll(); // Try to finish the handshake. + tls_conn->poll(); // Try to finish the handshake. } - if (tls->get_status() == StreamPeerTLS::STATUS_CONNECTED) { + if (tls_conn->get_status() == StreamPeerTLS::STATUS_CONNECTED) { // Handshake has been successful. handshaking = false; ip_candidates.clear(); status = STATUS_CONNECTED; return OK; - } else if (tls->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) { + } else if (tls_conn->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) { // Handshake has failed. close(); status = STATUS_TLS_HANDSHAKE_ERROR; diff --git a/core/io/image.cpp b/core/io/image.cpp index 56c05bf042..4be624a5a8 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -3869,15 +3869,15 @@ Dictionary Image::compute_image_metrics(const Ref p_compared_image, bool double image_metric_max, image_metric_mean, image_metric_mean_squared, image_metric_root_mean_squared, image_metric_peak_snr = 0.0; const bool average_component_error = true; - const uint32_t width = MIN(compared_image->get_width(), source_image->get_width()); - const uint32_t height = MIN(compared_image->get_height(), source_image->get_height()); + const uint32_t w = MIN(compared_image->get_width(), source_image->get_width()); + const uint32_t h = MIN(compared_image->get_height(), source_image->get_height()); // Histogram approach originally due to Charles Bloom. double hist[256]; memset(hist, 0, sizeof(hist)); - for (uint32_t y = 0; y < height; y++) { - for (uint32_t x = 0; x < width; x++) { + for (uint32_t y = 0; y < h; y++) { + for (uint32_t x = 0; x < w; x++) { const Color color_a = compared_image->get_pixel(x, y); const Color color_b = source_image->get_pixel(x, y); @@ -3922,7 +3922,7 @@ Dictionary Image::compute_image_metrics(const Ref p_compared_image, bool } // See http://richg42.blogspot.com/2016/09/how-to-compute-psnr-from-old-berkeley.html - double total_values = width * height; + double total_values = w * h; if (average_component_error) { total_values *= 4; diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index d6854666c0..397984a2ab 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -51,7 +51,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { } Error ImageFormatLoaderExtension::load_image(Ref p_image, Ref p_fileaccess, BitField p_flags, float p_scale) { - Error err; + Error err = ERR_UNAVAILABLE; if (GDVIRTUAL_CALL(_load_image, p_image, p_fileaccess, p_flags, p_scale, err)) { return err; } diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 9ab45f85b8..2a79067e02 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -169,10 +169,10 @@ StringName ResourceLoaderBinary::_get_string() { } Error ResourceLoaderBinary::parse_variant(Variant &r_v) { - uint32_t type = f->get_32(); - print_bl("find property of type: " + itos(type)); + uint32_t prop_type = f->get_32(); + print_bl("find property of type: " + itos(prop_type)); - switch (type) { + switch (prop_type) { case VARIANT_NIL: { r_v = Variant(); } break; @@ -1100,16 +1100,14 @@ String ResourceLoaderBinary::recognize(Ref p_f) { uint32_t ver_major = f->get_32(); f->get_32(); // ver_minor - uint32_t ver_format = f->get_32(); + uint32_t ver_fmt = f->get_32(); - if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) { + if (ver_fmt > FORMAT_VERSION || ver_major > VERSION_MAJOR) { f.unref(); return ""; } - String type = get_unicode_string(); - - return type; + return get_unicode_string(); } Ref ResourceFormatLoaderBinary::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { @@ -2118,9 +2116,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Refget_save_class()); - String path = save_order[i]->get_path(); - path = relative_paths ? local_path.path_to_file(path) : path; - save_unicode_string(f, path); + String res_path = save_order[i]->get_path(); + res_path = relative_paths ? local_path.path_to_file(res_path) : res_path; + save_unicode_string(f, res_path); ResourceUID::ID ruid = ResourceSaver::get_resource_id_for_path(save_order[i]->get_path(), false); f->store_64(ruid); } diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index d923522317..564b37e662 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -110,8 +110,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy #ifdef TOOLS_ENABLED if (r_path_and_type.metadata && !r_path_and_type.path.is_empty()) { - Dictionary metadata = r_path_and_type.metadata; - if (metadata.has("has_editor_variant")) { + Dictionary meta = r_path_and_type.metadata; + if (meta.has("has_editor_variant")) { r_path_and_type.path = r_path_and_type.path.get_basename() + ".editor." + r_path_and_type.path.get_extension(); } } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index eccb397e2e..a018221b7f 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -68,7 +68,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ } bool ResourceFormatLoader::handles_type(const String &p_type) const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_handles_type, p_type, success)) { return success; } @@ -102,7 +102,7 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const { } ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const { - int64_t uid; + int64_t uid = ResourceUID::INVALID_ID; if (GDVIRTUAL_CALL(_get_resource_uid, p_path, uid)) { return uid; } @@ -123,7 +123,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li } bool ResourceFormatLoader::exists(const String &p_path) const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_exists, p_path, success)) { return success; } @@ -175,7 +175,7 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Hash deps_dict[E.key] = E.value; } - int64_t err; + int64_t err = OK; if (GDVIRTUAL_CALL(_rename_dependencies, p_path, deps_dict, err)) { return (Error)err; } diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 386ccb78e9..2f863baaac 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -42,7 +42,7 @@ ResourceSavedCallback ResourceSaver::save_callback = nullptr; ResourceSaverGetResourceIDForPath ResourceSaver::save_get_id_for_path = nullptr; Error ResourceFormatSaver::save(const Ref &p_resource, const String &p_path, uint32_t p_flags) { - int64_t res; + int64_t res = ERR_METHOD_NOT_FOUND; if (GDVIRTUAL_CALL(_save, p_resource, p_path, p_flags, res)) { return (Error)res; } @@ -51,7 +51,7 @@ Error ResourceFormatSaver::save(const Ref &p_resource, const String &p } bool ResourceFormatSaver::recognize(const Ref &p_resource) const { - bool success; + bool success = false; if (GDVIRTUAL_CALL(_recognize, p_resource, success)) { return success; } diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index ba79590c19..e035e1b613 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -256,9 +256,9 @@ void StreamPeerTCP::disconnect_from_host() { peer_port = 0; } -Error StreamPeerTCP::wait(NetSocket::PollType p_type, int timeout) { +Error StreamPeerTCP::wait(NetSocket::PollType p_type, int p_timeout) { ERR_FAIL_COND_V(_sock.is_null() || !_sock->is_open(), ERR_UNAVAILABLE); - return _sock->poll(p_type, timeout); + return _sock->poll(p_type, p_timeout); } Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) { diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 39c2e84346..778fb83374 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -79,7 +79,7 @@ public: Error poll(); // Wait or check for writable, readable. - Error wait(NetSocket::PollType p_type, int timeout = 0); + Error wait(NetSocket::PollType p_type, int p_timeout = 0); // Read/Write from StreamPeer Error put_data(const uint8_t *p_data, int p_bytes) override; diff --git a/core/math/expression.cpp b/core/math/expression.cpp index e230b69dc9..dcec3929fe 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -560,7 +560,7 @@ const char *Expression::token_name[TK_MAX] = { }; Expression::ENode *Expression::_parse_expression() { - Vector expression; + Vector expression_nodes; while (true) { //keep appending stuff to expression @@ -838,14 +838,14 @@ Expression::ENode *Expression::_parse_expression() { ExpressionNode e; e.is_op = true; e.op = Variant::OP_NEGATE; - expression.push_back(e); + expression_nodes.push_back(e); continue; } break; case TK_OP_NOT: { ExpressionNode e; e.is_op = true; e.op = Variant::OP_NOT; - expression.push_back(e); + expression_nodes.push_back(e); continue; } break; @@ -960,7 +960,7 @@ Expression::ENode *Expression::_parse_expression() { ExpressionNode e; e.is_op = false; e.node = expr; - expression.push_back(e); + expression_nodes.push_back(e); } //ok finally look for an operator @@ -1054,19 +1054,19 @@ Expression::ENode *Expression::_parse_expression() { ExpressionNode e; e.is_op = true; e.op = op; - expression.push_back(e); + expression_nodes.push_back(e); } } /* Reduce the set of expressions and place them in an operator tree, respecting precedence */ - while (expression.size() > 1) { + while (expression_nodes.size() > 1) { int next_op = -1; int min_priority = 0xFFFFF; bool is_unary = false; - for (int i = 0; i < expression.size(); i++) { - if (!expression[i].is_op) { + for (int i = 0; i < expression_nodes.size(); i++) { + if (!expression_nodes[i].is_op) { continue; } @@ -1074,7 +1074,7 @@ Expression::ENode *Expression::_parse_expression() { bool unary = false; - switch (expression[i].op) { + switch (expression_nodes[i].op) { case Variant::OP_POWER: priority = 0; break; @@ -1130,7 +1130,7 @@ Expression::ENode *Expression::_parse_expression() { priority = 14; break; default: { - _set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op)); + _set_error("Parser bug, invalid operator in expression: " + itos(expression_nodes[i].op)); return nullptr; } } @@ -1153,9 +1153,9 @@ Expression::ENode *Expression::_parse_expression() { // OK! create operator.. if (is_unary) { int expr_pos = next_op; - while (expression[expr_pos].is_op) { + while (expression_nodes[expr_pos].is_op) { expr_pos++; - if (expr_pos == expression.size()) { + if (expr_pos == expression_nodes.size()) { //can happen.. _set_error("Unexpected end of expression..."); return nullptr; @@ -1165,29 +1165,29 @@ Expression::ENode *Expression::_parse_expression() { //consecutively do unary operators for (int i = expr_pos - 1; i >= next_op; i--) { OperatorNode *op = alloc_node(); - op->op = expression[i].op; - op->nodes[0] = expression[i + 1].node; + op->op = expression_nodes[i].op; + op->nodes[0] = expression_nodes[i + 1].node; op->nodes[1] = nullptr; - expression.write[i].is_op = false; - expression.write[i].node = op; - expression.remove_at(i + 1); + expression_nodes.write[i].is_op = false; + expression_nodes.write[i].node = op; + expression_nodes.remove_at(i + 1); } } else { - if (next_op < 1 || next_op >= (expression.size() - 1)) { + if (next_op < 1 || next_op >= (expression_nodes.size() - 1)) { _set_error("Parser bug..."); ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node(); - op->op = expression[next_op].op; + op->op = expression_nodes[next_op].op; - if (expression[next_op - 1].is_op) { + if (expression_nodes[next_op - 1].is_op) { _set_error("Parser bug..."); ERR_FAIL_V(nullptr); } - if (expression[next_op + 1].is_op) { + if (expression_nodes[next_op + 1].is_op) { // this is not invalid and can really appear // but it becomes invalid anyway because no binary op // can be followed by a unary op in a valid combination, @@ -1197,17 +1197,17 @@ Expression::ENode *Expression::_parse_expression() { return nullptr; } - op->nodes[0] = expression[next_op - 1].node; //expression goes as left - op->nodes[1] = expression[next_op + 1].node; //next expression goes as right + op->nodes[0] = expression_nodes[next_op - 1].node; //expression goes as left + op->nodes[1] = expression_nodes[next_op + 1].node; //next expression goes as right //replace all 3 nodes by this operator and make it an expression - expression.write[next_op - 1].node = op; - expression.remove_at(next_op); - expression.remove_at(next_op); + expression_nodes.write[next_op - 1].node = op; + expression_nodes.remove_at(next_op); + expression_nodes.remove_at(next_op); } } - return expression[0].node; + return expression_nodes[0].node; } bool Expression::_compile_expression() { diff --git a/core/math/projection.cpp b/core/math/projection.cpp index c628bf0bde..30c4f12795 100644 --- a/core/math/projection.cpp +++ b/core/math/projection.cpp @@ -169,7 +169,7 @@ Projection Projection::perspective_znear_adjusted(real_t p_new_znear) const { } Plane Projection::get_projection_plane(Planes p_plane) const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; switch (p_plane) { case PLANE_NEAR: { @@ -402,7 +402,7 @@ void Projection::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, r } real_t Projection::get_z_far() const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; Plane new_plane = Plane(matrix[3] - matrix[2], matrix[7] - matrix[6], matrix[11] - matrix[10], @@ -415,7 +415,7 @@ real_t Projection::get_z_far() const { } real_t Projection::get_z_near() const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; Plane new_plane = Plane(matrix[3] + matrix[2], matrix[7] + matrix[6], matrix[11] + matrix[10], @@ -426,7 +426,7 @@ real_t Projection::get_z_near() const { } Vector2 Projection::get_viewport_half_extents() const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; ///////--- Near Plane ---/////// Plane near_plane = Plane(matrix[3] + matrix[2], matrix[7] + matrix[6], @@ -454,7 +454,7 @@ Vector2 Projection::get_viewport_half_extents() const { } Vector2 Projection::get_far_plane_half_extents() const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; ///////--- Far Plane ---/////// Plane far_plane = Plane(matrix[3] - matrix[2], matrix[7] - matrix[6], @@ -514,7 +514,7 @@ Vector Projection::get_projection_planes(const Transform3D &p_transform) Vector planes; planes.resize(6); - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; Plane new_plane; @@ -807,7 +807,7 @@ bool Projection::is_orthogonal() const { } real_t Projection::get_fov() const { - const real_t *matrix = (const real_t *)this->columns; + const real_t *matrix = (const real_t *)columns; Plane right_plane = Plane(matrix[3] - matrix[0], matrix[7] - matrix[4], diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 4433559e6d..6515c55a85 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -215,10 +215,8 @@ Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const { switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = b.aabb.intersects(p_aabb); - if (!valid) { + if (!b.aabb.intersects(p_aabb)) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - } else { if (b.face_index >= 0) { const Triangle &s = triangleptr[b.face_index]; @@ -302,12 +300,8 @@ bool TriangleMesh::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = b.aabb.intersects_segment(p_begin, p_end); - //bool valid = b.aabb.intersects(ray_aabb); - - if (!valid) { + if (!b.aabb.intersects_segment(p_begin, p_end)) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - } else { if (b.face_index >= 0) { const Triangle &s = triangleptr[b.face_index]; @@ -407,10 +401,8 @@ bool TriangleMesh::intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, V switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = b.aabb.intersects_ray(p_begin, p_dir); - if (!valid) { + if (!b.aabb.intersects_ray(p_begin, p_dir)) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - } else { if (b.face_index >= 0) { const Triangle &s = triangleptr[b.face_index]; @@ -508,10 +500,8 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou switch (stack[level] >> VISITED_BIT_SHIFT) { case TEST_AABB_BIT: { - bool valid = b.aabb.intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count); - if (!valid) { + if (!b.aabb.intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count)) { stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; - } else { if (b.face_index >= 0) { const Triangle &s = triangleptr[b.face_index]; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index e56d2e80b9..5a3413512d 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -106,23 +106,23 @@ Dictionary Script::_get_script_constant_map() { PropertyInfo Script::get_class_category() const { String path = get_path(); - String name; + String scr_name; if (is_built_in()) { if (get_name().is_empty()) { - name = TTR("Built-in script"); + scr_name = TTR("Built-in script"); } else { - name = vformat("%s (%s)", get_name(), TTR("Built-in")); + scr_name = vformat("%s (%s)", get_name(), TTR("Built-in")); } } else { if (get_name().is_empty()) { - name = path.get_file(); + scr_name = path.get_file(); } else { - name = get_name(); + scr_name = get_name(); } } - return PropertyInfo(Variant::NIL, name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY); + return PropertyInfo(Variant::NIL, scr_name, PROPERTY_HINT_NONE, path, PROPERTY_USAGE_CATEGORY); } #endif // TOOLS_ENABLED diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index 07302cc8c3..b130c2fc79 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -179,14 +179,14 @@ void OptimizedTranslation::generate(const Ref &p_from) { } bool OptimizedTranslation::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name.operator String(); - if (name == "hash_table") { + String prop_name = p_name.operator String(); + if (prop_name == "hash_table") { hash_table = p_value; - } else if (name == "bucket_table") { + } else if (prop_name == "bucket_table") { bucket_table = p_value; - } else if (name == "strings") { + } else if (prop_name == "strings") { strings = p_value; - } else if (name == "load_from") { + } else if (prop_name == "load_from") { generate(p_value); } else { return false; @@ -196,12 +196,12 @@ bool OptimizedTranslation::_set(const StringName &p_name, const Variant &p_value } bool OptimizedTranslation::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name.operator String(); - if (name == "hash_table") { + String prop_name = p_name.operator String(); + if (prop_name == "hash_table") { r_ret = hash_table; - } else if (name == "bucket_table") { + } else if (prop_name == "bucket_table") { r_ret = bucket_table; - } else if (name == "strings") { + } else if (prop_name == "strings") { r_ret = strings; } else { return false; diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 4748f1a0cb..9ee7f2b17b 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -297,27 +297,27 @@ String TranslationServer::standardize_locale(const String &p_locale) const { String univ_locale = p_locale.replace("-", "_"); // Extract locale elements. - String lang, script, country, variant; + String lang_name, script_name, country_name, variant_name; Vector locale_elements = univ_locale.get_slice("@", 0).split("_"); - lang = locale_elements[0]; + lang_name = locale_elements[0]; if (locale_elements.size() >= 2) { if (locale_elements[1].length() == 4 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_lower_case(locale_elements[1][1]) && is_ascii_lower_case(locale_elements[1][2]) && is_ascii_lower_case(locale_elements[1][3])) { - script = locale_elements[1]; + script_name = locale_elements[1]; } if (locale_elements[1].length() == 2 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_upper_case(locale_elements[1][1])) { - country = locale_elements[1]; + country_name = locale_elements[1]; } } if (locale_elements.size() >= 3) { if (locale_elements[2].length() == 2 && is_ascii_upper_case(locale_elements[2][0]) && is_ascii_upper_case(locale_elements[2][1])) { - country = locale_elements[2]; - } else if (variant_map.has(locale_elements[2].to_lower()) && variant_map[locale_elements[2].to_lower()] == lang) { - variant = locale_elements[2].to_lower(); + country_name = locale_elements[2]; + } else if (variant_map.has(locale_elements[2].to_lower()) && variant_map[locale_elements[2].to_lower()] == lang_name) { + variant_name = locale_elements[2].to_lower(); } } if (locale_elements.size() >= 4) { - if (variant_map.has(locale_elements[3].to_lower()) && variant_map[locale_elements[3].to_lower()] == lang) { - variant = locale_elements[3].to_lower(); + if (variant_map.has(locale_elements[3].to_lower()) && variant_map[locale_elements[3].to_lower()] == lang_name) { + variant_name = locale_elements[3].to_lower(); } } @@ -325,69 +325,69 @@ String TranslationServer::standardize_locale(const String &p_locale) const { Vector script_extra = univ_locale.get_slice("@", 1).split(";"); for (int i = 0; i < script_extra.size(); i++) { if (script_extra[i].to_lower() == "cyrillic") { - script = "Cyrl"; + script_name = "Cyrl"; break; } else if (script_extra[i].to_lower() == "latin") { - script = "Latn"; + script_name = "Latn"; break; } else if (script_extra[i].to_lower() == "devanagari") { - script = "Deva"; + script_name = "Deva"; break; - } else if (variant_map.has(script_extra[i].to_lower()) && variant_map[script_extra[i].to_lower()] == lang) { - variant = script_extra[i].to_lower(); + } else if (variant_map.has(script_extra[i].to_lower()) && variant_map[script_extra[i].to_lower()] == lang_name) { + variant_name = script_extra[i].to_lower(); } } // Handles known non-ISO language names used e.g. on Windows. - if (locale_rename_map.has(lang)) { - lang = locale_rename_map[lang]; + if (locale_rename_map.has(lang_name)) { + lang_name = locale_rename_map[lang_name]; } // Handle country renames. - if (country_rename_map.has(country)) { - country = country_rename_map[country]; + if (country_rename_map.has(country_name)) { + country_name = country_rename_map[country_name]; } // Remove unsupported script codes. - if (!script_map.has(script)) { - script = ""; + if (!script_map.has(script_name)) { + script_name = ""; } // Add script code base on language and country codes for some ambiguous cases. - if (script.is_empty()) { + if (script_name.is_empty()) { for (int i = 0; i < locale_script_info.size(); i++) { const LocaleScriptInfo &info = locale_script_info[i]; - if (info.name == lang) { - if (country.is_empty() || info.supported_countries.has(country)) { - script = info.script; + if (info.name == lang_name) { + if (country_name.is_empty() || info.supported_countries.has(country_name)) { + script_name = info.script; break; } } } } - if (!script.is_empty() && country.is_empty()) { + if (!script_name.is_empty() && country_name.is_empty()) { // Add conntry code based on script for some ambiguous cases. for (int i = 0; i < locale_script_info.size(); i++) { const LocaleScriptInfo &info = locale_script_info[i]; - if (info.name == lang && info.script == script) { - country = info.default_country; + if (info.name == lang_name && info.script == script_name) { + country_name = info.default_country; break; } } } // Combine results. - String locale = lang; - if (!script.is_empty()) { - locale = locale + "_" + script; + String out = lang_name; + if (!script_name.is_empty()) { + out = out + "_" + script_name; } - if (!country.is_empty()) { - locale = locale + "_" + country; + if (!country_name.is_empty()) { + out = out + "_" + country_name; } - if (!variant.is_empty()) { - locale = locale + "_" + variant; + if (!variant_name.is_empty()) { + out = out + "_" + variant_name; } - return locale; + return out; } int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const { @@ -420,31 +420,29 @@ int TranslationServer::compare_locales(const String &p_locale_a, const String &p } String TranslationServer::get_locale_name(const String &p_locale) const { - String locale = standardize_locale(p_locale); - - String lang, script, country; - Vector locale_elements = locale.split("_"); - lang = locale_elements[0]; + String lang_name, script_name, country_name; + Vector locale_elements = standardize_locale(p_locale).split("_"); + lang_name = locale_elements[0]; if (locale_elements.size() >= 2) { if (locale_elements[1].length() == 4 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_lower_case(locale_elements[1][1]) && is_ascii_lower_case(locale_elements[1][2]) && is_ascii_lower_case(locale_elements[1][3])) { - script = locale_elements[1]; + script_name = locale_elements[1]; } if (locale_elements[1].length() == 2 && is_ascii_upper_case(locale_elements[1][0]) && is_ascii_upper_case(locale_elements[1][1])) { - country = locale_elements[1]; + country_name = locale_elements[1]; } } if (locale_elements.size() >= 3) { if (locale_elements[2].length() == 2 && is_ascii_upper_case(locale_elements[2][0]) && is_ascii_upper_case(locale_elements[2][1])) { - country = locale_elements[2]; + country_name = locale_elements[2]; } } - String name = language_map[lang]; - if (!script.is_empty()) { - name = name + " (" + script_map[script] + ")"; + String name = language_map[lang_name]; + if (!script_name.is_empty()) { + name = name + " (" + script_map[script_name] + ")"; } - if (!country.is_empty()) { - name = name + ", " + country_name_map[country]; + if (!country_name.is_empty()) { + name = name + ", " + country_name_map[country_name]; } return name; } @@ -630,12 +628,12 @@ TranslationServer *TranslationServer::singleton = nullptr; bool TranslationServer::_load_translations(const String &p_from) { if (ProjectSettings::get_singleton()->has_setting(p_from)) { - Vector translations = ProjectSettings::get_singleton()->get(p_from); + const Vector &translation_names = ProjectSettings::get_singleton()->get(p_from); - int tcount = translations.size(); + int tcount = translation_names.size(); if (tcount) { - const String *r = translations.ptr(); + const String *r = translation_names.ptr(); for (int i = 0; i < tcount; i++) { Ref tr = ResourceLoader::load(r[i]); @@ -964,7 +962,6 @@ void TranslationServer::_bind_methods() { } void TranslationServer::load_translations() { - String locale = get_locale(); _load_translations("internationalization/locale/translations"); //all _load_translations("internationalization/locale/translations_" + locale.substr(0, 2)); diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index b35e2f004b..79532d9aca 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -402,33 +402,33 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const { } Error Signal::connect(const Callable &p_callable, uint32_t p_flags) { - Object *object = get_object(); - ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED); + Object *obj = get_object(); + ERR_FAIL_COND_V(!obj, ERR_UNCONFIGURED); - return object->connect(name, p_callable, p_flags); + return obj->connect(name, p_callable, p_flags); } void Signal::disconnect(const Callable &p_callable) { - Object *object = get_object(); - ERR_FAIL_COND(!object); - object->disconnect(name, p_callable); + Object *obj = get_object(); + ERR_FAIL_COND(!obj); + obj->disconnect(name, p_callable); } bool Signal::is_connected(const Callable &p_callable) const { - Object *object = get_object(); - ERR_FAIL_COND_V(!object, false); + Object *obj = get_object(); + ERR_FAIL_COND_V(!obj, false); - return object->is_connected(name, p_callable); + return obj->is_connected(name, p_callable); } Array Signal::get_connections() const { - Object *object = get_object(); - if (!object) { + Object *obj = get_object(); + if (!obj) { return Array(); } List connections; - object->get_signal_connection_list(name, &connections); + obj->get_signal_connection_list(name, &connections); Array arr; for (const Object::Connection &E : connections) { diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index a6e91bf2ac..fbce337359 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1101,8 +1101,6 @@ bool Variant::is_one() const { return !is_zero(); } } - - return false; } bool Variant::is_null() const { @@ -3573,8 +3571,6 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const evaluate(OP_EQUAL, *this, p_variant, r, v); return r; } - - return false; } bool Variant::is_ref_counted() const { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 3ac923d33c..0836a21254 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -100,9 +100,9 @@ void RasterizerGLES3::begin_frame(double frame_step) { canvas->set_time(time_total); scene->set_time(time_total, frame_step); - GLES3::Utilities *utilities = GLES3::Utilities::get_singleton(); - utilities->info.render_final = utilities->info.render; - utilities->info.render.reset(); + GLES3::Utilities *utils = GLES3::Utilities::get_singleton(); + utils->info.render_final = utils->info.render; + utils->info.render.reset(); //scene->iteration(); } @@ -275,9 +275,7 @@ void RasterizerGLES3::prepare_for_blitting_render_targets() { } void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect) { - GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton(); - - GLES3::RenderTarget *rt = texture_storage->get_render_target(p_render_target); + GLES3::RenderTarget *rt = GLES3::TextureStorage::get_singleton()->get_render_target(p_render_target); ERR_FAIL_COND(!rt); glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->fbo); diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index f0f70b62e0..9b193056c2 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -7262,12 +7262,12 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff return OK; } -void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil) { +void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *p_draw_list, Framebuffer *p_framebuffer, Point2i p_viewport_offset, Point2i p_viewport_size, bool p_clear_color, const Vector &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil) { Vector clear_attachments; int color_index = 0; int texture_index = 0; - for (int i = 0; i < framebuffer->texture_ids.size(); i++) { - Texture *texture = texture_owner.get_or_null(framebuffer->texture_ids[i]); + for (int i = 0; i < p_framebuffer->texture_ids.size(); i++) { + Texture *texture = texture_owner.get_or_null(p_framebuffer->texture_ids[i]); if (!texture) { texture_index++; @@ -7300,12 +7300,12 @@ void RenderingDeviceVulkan::_draw_list_insert_clear_region(DrawList *draw_list, VkClearRect cr; cr.baseArrayLayer = 0; cr.layerCount = 1; - cr.rect.offset.x = viewport_offset.x; - cr.rect.offset.y = viewport_offset.y; - cr.rect.extent.width = viewport_size.width; - cr.rect.extent.height = viewport_size.height; + cr.rect.offset.x = p_viewport_offset.x; + cr.rect.offset.y = p_viewport_offset.y; + cr.rect.extent.width = p_viewport_size.width; + cr.rect.extent.height = p_viewport_size.height; - vkCmdClearAttachments(draw_list->command_buffer, clear_attachments.size(), clear_attachments.ptr(), 1, &cr); + vkCmdClearAttachments(p_draw_list->command_buffer, clear_attachments.size(), clear_attachments.ptr(), 1, &cr); } RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector &p_clear_color_values, float p_clear_depth, uint32_t p_clear_stencil, const Rect2 &p_region, const Vector &p_storage_textures) { diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index abec1b0e1b..7c75e9bb2e 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -905,7 +905,7 @@ class RenderingDeviceVulkan : public RenderingDevice { bool draw_list_unbind_color_textures = false; bool draw_list_unbind_depth_textures = false; - void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil); + void _draw_list_insert_clear_region(DrawList *p_draw_list, Framebuffer *p_framebuffer, Point2i p_viewport_offset, Point2i p_viewport_size, bool p_clear_color, const Vector &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil); Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass, uint32_t *r_subpass_count); Error _draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents, const Vector &p_storage_textures); _FORCE_INLINE_ DrawList *_get_draw_list_ptr(DrawListID p_id); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index e64b0c4a84..1ab8914624 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -48,7 +48,7 @@ VulkanHooks *VulkanContext::vulkan_hooks = nullptr; -VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) { +VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice p_device, const VkRenderPassCreateInfo2 *p_create_info, const VkAllocationCallbacks *p_allocator, VkRenderPass *p_render_pass) { if (fpCreateRenderPass2KHR == nullptr) { fpCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)vkGetInstanceProcAddr(inst, "vkCreateRenderPass2KHR"); } @@ -56,7 +56,7 @@ VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice device, const VkRenderPa if (fpCreateRenderPass2KHR == nullptr) { return VK_ERROR_EXTENSION_NOT_PRESENT; } else { - return (fpCreateRenderPass2KHR)(device, pCreateInfo, pAllocator, pRenderPass); + return (fpCreateRenderPass2KHR)(p_device, p_create_info, p_allocator, p_render_pass); } } diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index 9889cf336b..7389e86ad7 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -270,7 +270,7 @@ protected: public: // Extension calls. - VkResult vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass); + VkResult vkCreateRenderPass2KHR(VkDevice p_device, const VkRenderPassCreateInfo2 *p_create_info, const VkAllocationCallbacks *p_allocator, VkRenderPass *p_render_pass); uint32_t get_vulkan_major() const { return vulkan_major; }; uint32_t get_vulkan_minor() const { return vulkan_minor; }; diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 3660e956e3..c085ba372b 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -200,9 +200,9 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) const { return current_dir; } else { if (_get_root_string().is_empty()) { - int p = current_dir.find(":"); - if (p != -1) { - return current_dir.substr(p + 1); + int pos = current_dir.find(":"); + if (pos != -1) { + return current_dir.substr(pos + 1); } } return current_dir; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 095d936c78..4e8b327ffe 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -95,8 +95,8 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) { // platforms). if (p_mode_flags == READ) { WIN32_FIND_DATAW d; - HANDLE f = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d); - if (f != INVALID_HANDLE_VALUE) { + HANDLE fnd = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d); + if (fnd != INVALID_HANDLE_VALUE) { String fname = String::utf16((const char16_t *)(d.cFileName)); if (!fname.is_empty()) { String base_file = path.get_file(); @@ -104,7 +104,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) { WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms."); } } - FindClose(f); + FindClose(fnd); } } #endif diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 3b87b3e65e..604758300d 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -338,14 +338,14 @@ void AnimationBezierTrackEdit::_notification(int p_what) { Ref unlock = get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons")); float lock_hpos = remove_hpos - hsep - lock->get_width(); - Ref visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); - Ref hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); - float visibility_hpos = lock_hpos - hsep - visible->get_width(); + Ref visibility_visible = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); + Ref visibility_hidden = get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")); + float visibility_hpos = lock_hpos - hsep - visibility_visible->get_width(); Ref solo = get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons")); float solo_hpos = visibility_hpos - hsep - solo->get_width(); - float buttons_width = remove->get_width() + lock->get_width() + visible->get_width() + solo->get_width() + hsep * 3; + float buttons_width = remove->get_width() + lock->get_width() + visibility_visible->get_width() + solo->get_width() + hsep * 3; for (int i = 0; i < tracks.size(); ++i) { // RELATED TRACKS TITLES @@ -418,11 +418,11 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_texture(unlock, lock_rect.position); } - Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visible->get_height() / 2.0, visible->get_width(), visible->get_height()); + Rect2 visible_rect = Rect2(visibility_hpos, icon_start_height - visibility_visible->get_height() / 2.0, visibility_visible->get_width(), visibility_visible->get_height()); if (hidden_tracks.has(current_track)) { - draw_texture(hidden, visible_rect.position); + draw_texture(visibility_hidden, visible_rect.position); } else { - draw_texture(visible, visible_rect.position); + draw_texture(visibility_visible, visible_rect.position); } Rect2 solo_rect = Rect2(solo_hpos, icon_start_height - solo->get_height() / 2.0, solo->get_width(), solo->get_height()); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 9529460ab1..1d13972458 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2029,14 +2029,14 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref type_icon = _get_key_type_icon(); - draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); - ofs += type_icon->get_width() + hsep; + Ref key_type_icon = _get_key_type_icon(); + draw_texture(key_type_icon, Point2(ofs, int(get_size().height - key_type_icon->get_height()) / 2)); + ofs += key_type_icon->get_width() + hsep; - NodePath path = animation->track_get_path(track); + NodePath anim_path = animation->track_get_path(track); Node *node = nullptr; - if (root && root->has_node(path)) { - node = root->get_node(path); + if (root && root->has_node(anim_path)) { + node = root->get_node(anim_path); } String text; @@ -2053,7 +2053,7 @@ void AnimationTrackEdit::_notification(int p_what) { } else if (animation->track_get_type(track) == Animation::TYPE_ANIMATION) { text = TTR("Anim Clips:"); } else { - text += path.get_concatenated_subnames(); + text += anim_path.get_concatenated_subnames(); } text_color.a *= 0.7; } else if (node) { @@ -2062,14 +2062,14 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2)); icon_cache = icon; - text = String() + node->get_name() + ":" + path.get_concatenated_subnames(); + text = String() + node->get_name() + ":" + anim_path.get_concatenated_subnames(); ofs += hsep; ofs += icon->get_width(); } else { - icon_cache = type_icon; + icon_cache = key_type_icon; - text = path; + text = anim_path; } path_cache = text; @@ -2853,9 +2853,9 @@ void AnimationTrackEdit::gui_input(const Ref &p_event) { if (ape) { AnimationPlayer *ap = ape->get_player(); if (ap) { - NodePath path = animation->track_get_path(track); - Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(path.get_concatenated_names())); - StringName prop = path.get_concatenated_subnames(); + NodePath npath = animation->track_get_path(track); + Node *nd = ap->get_node(ap->get_root())->get_node(NodePath(npath.get_concatenated_names())); + StringName prop = npath.get_concatenated_subnames(); PropertyInfo prop_info; ClassDB::get_property_info(nd->get_class(), prop, &prop_info); bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1; @@ -4463,24 +4463,24 @@ void AnimationTrackEditor::_update_tracks() { return; } - bool read_only = false; + bool file_read_only = false; if (!animation->get_path().is_resource_file()) { int srpos = animation->get_path().find("::"); if (srpos != -1) { String base = animation->get_path().substr(0, srpos); if (ResourceLoader::get_resource_type(base) == "PackedScene") { if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) { - read_only = true; + file_read_only = true; } } else { if (FileAccess::exists(base + ".import")) { - read_only = true; + file_read_only = true; } } } } else { if (FileAccess::exists(animation->get_path() + ".import")) { - read_only = true; + file_read_only = true; } } @@ -4612,7 +4612,7 @@ void AnimationTrackEditor::_update_tracks() { track_edit->set_undo_redo(undo_redo); track_edit->set_timeline(timeline); track_edit->set_root(root); - track_edit->set_animation_and_track(animation, i, read_only); + track_edit->set_animation_and_track(animation, i, file_read_only); track_edit->set_play_position(timeline->get_play_position()); track_edit->set_editor(this); @@ -5072,10 +5072,8 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { return; } - Vector3 scale = base->get_scale(); - undo_redo->create_action(TTR("Add Scale Key")); - undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, scale); + undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, base->get_scale()); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs); undo_redo->commit_action(); @@ -5671,18 +5669,18 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) { if (animation.is_null()) { return; } - float step = animation->get_step(); - if (step == 0) { - step = 1; + float anim_step = animation->get_step(); + if (anim_step == 0) { + anim_step = 1; } if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) { // Use more precise snapping when holding Shift. // This is used when scrobbling the timeline using Alt + Mouse wheel. - step *= 0.25; + anim_step *= 0.25; } float pos = timeline->get_play_position(); - pos = Math::snapped(pos - step, step); + pos = Math::snapped(pos - anim_step, anim_step); if (pos < 0) { pos = 0; } @@ -5694,21 +5692,21 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event, bool p_timeli if (animation.is_null()) { return; } - float step = animation->get_step(); - if (step == 0) { - step = 1; + float anim_step = animation->get_step(); + if (anim_step == 0) { + anim_step = 1; } if (p_from_mouse_event && Input::get_singleton()->is_key_pressed(Key::SHIFT)) { // Use more precise snapping when holding Shift. // This is used when scrobbling the timeline using Alt + Mouse wheel. // Do not use precise snapping when using the menu action or keyboard shortcut, // as the default keyboard shortcut requires pressing Shift. - step *= 0.25; + anim_step *= 0.25; } float pos = timeline->get_play_position(); - pos = Math::snapped(pos + step, step); + pos = Math::snapped(pos + anim_step, anim_step); if (pos > animation->get_length()) { pos = animation->get_length(); } @@ -5801,9 +5799,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_COPY_TRACKS_CONFIRM: { track_clipboard.clear(); - TreeItem *root = track_copy_select->get_root(); - if (root) { - TreeItem *it = root->get_first_child(); + TreeItem *tree_root = track_copy_select->get_root(); + if (tree_root) { + TreeItem *it = tree_root->get_first_child(); while (it) { Dictionary md = it->get_metadata(0); int idx = md["track_idx"]; @@ -6037,7 +6035,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_LINEAR_ANGLE || animation->track_get_interpolation_type(track) == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector> insert_queue; + Vector> insert_queue_new; for (int i = 0; i < len; i++) { // Check neighboring keys. if (keys[i] + 1 == keys[i + 1]) { @@ -6058,15 +6056,15 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Pair keydata; keydata.first = from_t + delta_t; keydata.second = Tween::interpolate_variant(from_v, delta_v, delta_t, duration, transition_type, ease_type); - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } } // Do insertion. - for (int i = 0; i < insert_queue.size(); i++) { - undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue[i].first, insert_queue[i].second); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue[i].first); + for (int i = 0; i < insert_queue_new.size(); i++) { + undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, insert_queue_new[i].first, insert_queue_new[i].second); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", track, insert_queue_new[i].first); } ++E; @@ -6213,7 +6211,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { bool is_using_angle = it == Animation::INTERPOLATION_LINEAR_ANGLE || it == Animation::INTERPOLATION_CUBIC_ANGLE; // Make insert queue. - Vector> insert_queue; + Vector> insert_queue_new; switch (type) { case Animation::TYPE_POSITION_3D: { @@ -6223,7 +6221,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Vector3 v; animation->position_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_ROTATION_3D: { @@ -6233,7 +6231,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Quaternion v; animation->rotation_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_SCALE_3D: { @@ -6243,7 +6241,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Vector3 v; animation->scale_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_BLEND_SHAPE: { @@ -6253,7 +6251,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { float v; animation->blend_shape_track_interpolate(i, delta_t, &v); keydata.second = v; - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; case Animation::TYPE_VALUE: { @@ -6261,7 +6259,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { Pair keydata; keydata.first = delta_t; keydata.second = animation->value_track_interpolate(i, delta_t); - insert_queue.append(keydata); + insert_queue_new.append(keydata); } } break; default: { @@ -6276,9 +6274,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { // Insert keys. undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", i, is_using_angle ? Animation::INTERPOLATION_LINEAR_ANGLE : Animation::INTERPOLATION_LINEAR); - for (int j = insert_queue.size() - 1; j >= 0; j--) { - undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue[j].first, insert_queue[j].second); - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue[j].first); + for (int j = insert_queue_new.size() - 1; j >= 0; j--) { + undo_redo->add_do_method(animation.ptr(), "track_insert_key", i, insert_queue_new[j].first, insert_queue_new[j].second); + undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", i, insert_queue_new[j].first); } // Undo methods. @@ -6925,19 +6923,19 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_dialog->set_title(TTR("Select Tracks to Copy")); track_copy_dialog->set_ok_button_text(TTR("Copy")); - VBoxContainer *track_vbox = memnew(VBoxContainer); - track_copy_dialog->add_child(track_vbox); + VBoxContainer *track_copy_vbox = memnew(VBoxContainer); + track_copy_dialog->add_child(track_copy_vbox); Button *select_all_button = memnew(Button); select_all_button->set_text(TTR("Select All/None")); select_all_button->connect("pressed", callable_mp(this, &AnimationTrackEditor::_select_all_tracks_for_copy)); - track_vbox->add_child(select_all_button); + track_copy_vbox->add_child(select_all_button); track_copy_select = memnew(Tree); track_copy_select->set_h_size_flags(SIZE_EXPAND_FILL); track_copy_select->set_v_size_flags(SIZE_EXPAND_FILL); track_copy_select->set_hide_root(true); - track_vbox->add_child(track_copy_select); + track_copy_vbox->add_child(track_copy_select); track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed).bind(EDIT_COPY_TRACKS_CONFIRM)); } diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 6499cf8df2..971b671a0c 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -412,9 +412,9 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se sf->get_animation_list(&animations); int frame = get_animation()->track_get_key_value(get_track(), p_index); - String animation; + String animation_name; if (animations.size() == 1) { - animation = animations.front()->get(); + animation_name = animations.front()->get(); } else { // Go through other track to find if animation is set String animation_path = get_animation()->track_get_path(get_track()); @@ -422,10 +422,10 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track())); float track_time = get_animation()->track_get_key_time(get_track(), p_index); int animaiton_index = get_animation()->track_find_key(animation_track, track_time); - animation = get_animation()->track_get_key_value(animation_track, animaiton_index); + animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index); } - Ref texture = sf->get_frame(animation, frame); + Ref texture = sf->get_frame(animation_name, frame); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -504,9 +504,9 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in sf->get_animation_list(&animations); int frame = get_animation()->track_get_key_value(get_track(), p_index); - String animation; + String animation_name; if (animations.size() == 1) { - animation = animations.front()->get(); + animation_name = animations.front()->get(); } else { // Go through other track to find if animation is set String animation_path = get_animation()->track_get_path(get_track()); @@ -514,10 +514,10 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in int animation_track = get_animation()->find_track(animation_path, get_animation()->track_get_type(get_track())); float track_time = get_animation()->track_get_key_time(get_track(), p_index); int animaiton_index = get_animation()->track_find_key(animation_track, track_time); - animation = get_animation()->track_get_key_value(animation_track, animaiton_index); + animation_name = get_animation()->track_get_key_value(animation_track, animaiton_index); } - texture = sf->get_frame(animation, frame); + texture = sf->get_frame(animation_name, frame); if (!texture.is_valid()) { AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right); return; @@ -670,15 +670,15 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ Vector lines; Vector colorv; { - Ref animation = ap->get_animation(anim); + Ref ap_anim = ap->get_animation(anim); - for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); + for (int i = 0; i < ap_anim->get_track_count(); i++) { + float h = (rect.size.height - 2) / ap_anim->get_track_count(); int y = 2 + h * i + h / 2; - for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); + for (int j = 0; j < ap_anim->track_get_key_count(i); j++) { + float ofs = ap_anim->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; if (x < from_x || x >= (to_x - 4)) { @@ -1244,15 +1244,15 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, Vector lines; Vector colorv; { - Ref animation = ap->get_animation(anim); + Ref ap_anim = ap->get_animation(anim); - for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); + for (int i = 0; i < ap_anim->get_track_count(); i++) { + float h = (rect.size.height - 2) / ap_anim->get_track_count(); int y = 2 + h * i + h / 2; - for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); + for (int j = 0; j < ap_anim->track_get_key_count(i); j++) { + float ofs = ap_anim->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; if (x < from_x || x >= (to_x - 4)) { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index fe9831d0ef..b73b49a434 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -184,7 +184,7 @@ void FindReplaceBar::_replace() { selection_end = Point2i(text_editor->get_selection_to_line(0), text_editor->get_selection_to_column(0)); } - String replace_text = get_replace_text(); + String repl_text = get_replace_text(); int search_text_len = get_search_text().length(); text_editor->begin_complex_operation(); @@ -201,13 +201,13 @@ void FindReplaceBar::_replace() { Point2i match_from(result_line, result_col); Point2i match_to(result_line, result_col + search_text_len); if (!(match_from < selection_begin || match_to > selection_end)) { - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); if (match_to.x == selection_end.x) { // Adjust selection bounds if necessary - selection_end.y += replace_text.length() - search_text_len; + selection_end.y += repl_text.length() - search_text_len; } } } else { - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); } } text_editor->end_complex_operation(); @@ -241,7 +241,7 @@ void FindReplaceBar::_replace_all() { text_editor->set_caret_line(0, false, true, 0, 0); text_editor->set_caret_column(0, true, 0); - String replace_text = get_replace_text(); + String repl_text = get_replace_text(); int search_text_len = get_search_text().length(); int rc = 0; @@ -264,7 +264,7 @@ void FindReplaceBar::_replace_all() { break; // Done. } - prev_match = Point2i(result_line, result_col + replace_text.length()); + prev_match = Point2i(result_line, result_col + repl_text.length()); text_editor->unfold_line(result_line); text_editor->select(result_line, result_col, result_line, match_to.y, 0); @@ -275,14 +275,14 @@ void FindReplaceBar::_replace_all() { } // Replace but adjust selection bounds. - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); if (match_to.x == selection_end.x) { - selection_end.y += replace_text.length() - search_text_len; + selection_end.y += repl_text.length() - search_text_len; } } else { // Just replace. - text_editor->insert_text_at_caret(replace_text, 0); + text_editor->insert_text_at_caret(repl_text, 0); } rc++; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index ddeb8643b8..258ce434f6 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -184,8 +184,8 @@ void ConnectDialog::_add_bind() { Variant::Type type = (Variant::Type)type_list->get_item_id(type_list->get_selected()); Variant value; - Callable::CallError error; - Variant::construct(type, value, nullptr, 0, error); + Callable::CallError err; + Variant::construct(type, value, nullptr, 0, err); cdbinds->params.push_back(value); cdbinds->notify_changed(); @@ -583,19 +583,19 @@ void ConnectionsDock::_make_or_edit_connection() { // Conditions to add function: must have a script and must not have the method already // (in the class, the script itself, or inherited). bool add_script_function = false; - Ref