From 1f6f364a56319eabd02c050746fe7df3f55ffee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 12 May 2020 17:01:17 +0200 Subject: [PATCH] Port member initialization from constructor to declaration (C++11) Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists. --- .clang-tidy | 42 ++++ core/bind/core_bind.cpp | 114 ++--------- core/bind/core_bind.h | 37 ++-- core/callable.cpp | 10 +- core/callable.h | 8 +- core/class_db.cpp | 13 -- core/class_db.h | 18 +- core/color.h | 12 +- core/command_queue_mt.cpp | 13 -- core/command_queue_mt.h | 16 +- core/compressed_translation.cpp | 3 - core/compressed_translation.h | 2 +- core/cowdata.h | 10 +- core/crypto/crypto.cpp | 3 - core/crypto/crypto.h | 7 +- core/crypto/hashing_context.cpp | 4 - core/crypto/hashing_context.h | 4 +- core/debugger/debugger_marshalls.h | 31 +-- core/engine.cpp | 18 +- core/engine.h | 32 ++-- core/error_macros.h | 12 +- core/func_ref.cpp | 3 - core/func_ref.h | 3 +- core/hash_map.h | 24 +-- core/image.cpp | 11 -- core/image.h | 14 +- core/input/input.cpp | 10 - core/input/input.h | 48 ++--- core/input/input_event.cpp | 120 ++---------- core/input/input_event.h | 109 ++++++----- core/io/compression.h | 2 +- core/io/dtls_server.cpp | 4 +- core/io/dtls_server.h | 2 +- core/io/file_access_buffered.cpp | 8 - core/io/file_access_buffered.h | 6 +- core/io/file_access_buffered_fa.h | 10 +- core/io/file_access_compressed.cpp | 19 -- core/io/file_access_compressed.h | 36 ++-- core/io/file_access_encrypted.cpp | 9 - core/io/file_access_encrypted.h | 12 +- core/io/file_access_memory.cpp | 5 - core/io/file_access_memory.h | 4 +- core/io/file_access_network.cpp | 12 -- core/io/file_access_network.h | 30 ++- core/io/file_access_pack.cpp | 7 - core/io/file_access_pack.h | 19 +- core/io/file_access_zip.cpp | 8 +- core/io/file_access_zip.h | 9 +- core/io/http_client.cpp | 19 +- core/io/http_client.h | 32 ++-- core/io/logger.cpp | 7 +- core/io/logger.h | 6 +- core/io/marshalls.cpp | 3 - core/io/marshalls.h | 2 +- core/io/multiplayer_api.cpp | 6 +- core/io/multiplayer_api.h | 6 +- core/io/networked_multiplayer_peer.cpp | 3 - core/io/networked_multiplayer_peer.h | 2 +- core/io/packet_peer.cpp | 5 - core/io/packet_peer.h | 6 +- core/io/packet_peer_dtls.cpp | 3 - core/io/packet_peer_dtls.h | 2 +- core/io/packet_peer_udp.cpp | 6 - core/io/packet_peer_udp.h | 12 +- core/io/pck_packer.cpp | 5 - core/io/pck_packer.h | 4 +- core/io/resource_format_binary.cpp | 13 -- core/io/resource_format_binary.h | 18 +- core/io/resource_loader.cpp | 1 - core/io/stream_peer.cpp | 5 - core/io/stream_peer.h | 8 +- core/io/stream_peer_ssl.cpp | 4 - core/io/stream_peer_ssl.h | 4 +- core/io/stream_peer_tcp.cpp | 5 +- core/io/stream_peer_tcp.h | 6 +- core/io/translation_loader_po.cpp | 3 - core/io/translation_loader_po.h | 2 +- core/io/xml_parser.cpp | 3 - core/io/xml_parser.h | 12 +- core/list.h | 20 +- core/map.h | 30 +-- core/math/a_star.cpp | 11 -- core/math/a_star.h | 28 ++- core/math/audio_frame.cpp | 31 --- core/math/delaunay_2d.h | 11 +- core/math/delaunay_3d.h | 8 +- core/math/disjoint_set.cpp | 31 --- core/math/expression.cpp | 11 -- core/math/expression.h | 28 ++- core/math/geometry.cpp | 18 +- core/math/octree.h | 59 ++---- core/math/plane.h | 5 +- core/math/quat.h | 13 +- core/math/quick_hull.h | 14 +- core/math/random_number_generator.cpp | 2 - core/math/random_number_generator.h | 2 +- core/math/rect2.h | 3 +- core/math/vector2.h | 16 +- core/math/vector3.h | 5 +- core/math/vector3i.h | 4 +- core/message_queue.cpp | 3 - core/message_queue.h | 6 +- core/method_bind.cpp | 8 - core/method_bind.h | 18 +- core/node_path.cpp | 85 ++++----- core/node_path.h | 4 +- core/oa_hash_map.h | 3 +- core/object.cpp | 80 +++----- core/object.h | 67 +++---- core/ordered_hash_map.h | 21 +- core/os/dir_access.cpp | 8 - core/os/dir_access.h | 18 +- core/os/file_access.cpp | 12 +- core/os/file_access.h | 11 +- core/os/main_loop.cpp | 6 - core/os/main_loop.h | 4 +- core/os/memory.cpp | 2 - core/os/memory.h | 2 +- core/os/mutex.h | 2 +- core/os/os.cpp | 15 -- core/os/os.h | 24 +-- core/os/rw_lock.cpp | 3 - core/os/rw_lock.h | 2 +- core/os/semaphore.cpp | 31 --- core/os/thread.cpp | 6 - core/os/thread.h | 4 +- core/packed_data_container.cpp | 8 - core/packed_data_container.h | 6 +- core/path_remap.cpp | 31 --- core/path_remap.h | 34 ---- core/pool_allocator.h | 10 +- core/print_string.h | 12 +- core/project_settings.cpp | 6 - core/project_settings.h | 35 ++-- core/reference.cpp | 6 - core/reference.h | 22 +-- core/register_core_types.cpp | 1 - core/resource.cpp | 12 +- core/resource.h | 10 +- core/rid.h | 6 +- core/rid_owner.h | 21 +- core/ring_buffer.h | 8 +- core/script_language.cpp | 1 + core/script_language.h | 6 +- core/self_list.h | 21 +- core/set.h | 31 +-- core/spin_lock.h | 1 + core/string_buffer.h | 6 +- core/string_builder.h | 7 +- core/string_name.cpp | 6 - core/string_name.h | 21 +- core/thread_work_pool.cpp | 1 + core/thread_work_pool.h | 2 + core/translation.cpp | 9 +- core/translation.h | 8 +- core/typed_array.cpp | 31 --- core/undo_redo.cpp | 17 -- core/undo_redo.h | 26 +-- core/ustring.cpp | 8 +- core/variant.cpp | 7 - core/variant.h | 7 +- core/variant_parser.h | 13 +- core/vector.h | 5 +- core/vmap.h | 4 +- drivers/alsa/audio_driver_alsa.cpp | 12 +- drivers/alsa/audio_driver_alsa.h | 12 +- drivers/coreaudio/audio_driver_coreaudio.cpp | 15 +- drivers/coreaudio/audio_driver_coreaudio.h | 20 +- drivers/coremidi/midi_driver_coremidi.cpp | 4 +- drivers/coremidi/midi_driver_coremidi.h | 2 +- .../pulseaudio/audio_driver_pulseaudio.cpp | 25 +-- drivers/pulseaudio/audio_driver_pulseaudio.h | 36 ++-- drivers/unix/file_access_unix.cpp | 7 - drivers/unix/file_access_unix.h | 8 +- drivers/unix/net_socket_posix.cpp | 4 +- drivers/unix/net_socket_posix.h | 4 +- drivers/wasapi/audio_driver_wasapi.cpp | 20 +- drivers/wasapi/audio_driver_wasapi.h | 45 ++--- drivers/windows/file_access_windows.cpp | 9 +- drivers/windows/file_access_windows.h | 15 +- drivers/windows/thread_windows.cpp | 7 - drivers/windows/thread_windows.h | 6 +- drivers/xaudio2/audio_driver_xaudio2.cpp | 8 +- drivers/xaudio2/audio_driver_xaudio2.h | 8 +- editor/debugger/editor_debugger_inspector.h | 2 +- editor/debugger/editor_debugger_node.h | 2 +- editor/editor_audio_buses.cpp | 6 +- editor/editor_audio_buses.h | 8 +- editor/editor_export.cpp | 7 - editor/editor_export.h | 8 +- editor/editor_help_search.cpp | 1 - editor/editor_help_search.h | 2 +- editor/editor_node.cpp | 1 - editor/editor_plugin.cpp | 10 - editor/editor_plugin.h | 10 +- editor/editor_sectioned_inspector.cpp | 5 +- editor/editor_sectioned_inspector.h | 2 +- editor/editor_settings.h | 26 +-- editor/filesystem_dock.h | 6 +- editor/import/collada.h | 156 ++++++--------- editor/import/editor_scene_importer_gltf.h | 119 ++++-------- editor/plugins/abstract_polygon_2d_editor.cpp | 32 ---- editor/plugins/abstract_polygon_2d_editor.h | 23 ++- editor/plugins/canvas_item_editor_plugin.h | 17 +- .../physical_bone_3d_editor_plugin.cpp | 6 +- .../plugins/physical_bone_3d_editor_plugin.h | 6 +- editor/plugins/skeleton_3d_editor_plugin.h | 5 +- editor/plugins/tile_map_editor_plugin.h | 29 +-- editor/rename_dialog.h | 4 +- main/main_timer_sync.cpp | 7 +- main/main_timer_sync.h | 10 +- modules/bullet/area_bullet.cpp | 13 +- modules/bullet/area_bullet.h | 30 ++- modules/bullet/bullet_physics_server.cpp | 4 +- modules/bullet/bullet_physics_server.h | 5 +- modules/bullet/collision_object_bullet.cpp | 18 +- modules/bullet/collision_object_bullet.h | 38 ++-- modules/bullet/constraint_bullet.cpp | 5 +- modules/bullet/constraint_bullet.h | 6 +- modules/bullet/godot_ray_world_algorithm.cpp | 1 - modules/bullet/godot_ray_world_algorithm.h | 2 +- modules/bullet/godot_result_callbacks.h | 34 ++-- modules/bullet/rigid_body_bullet.cpp | 20 +- modules/bullet/rigid_body_bullet.h | 41 ++-- modules/bullet/shape_bullet.cpp | 10 +- modules/bullet/shape_bullet.h | 8 +- modules/bullet/soft_body_bullet.cpp | 13 +- modules/bullet/soft_body_bullet.h | 22 +-- modules/bullet/space_bullet.cpp | 17 +- modules/bullet/space_bullet.h | 51 +++-- modules/gdnative/nativescript/nativescript.h | 24 +-- .../pluginscript/pluginscript_script.cpp | 5 - .../pluginscript/pluginscript_script.h | 10 +- .../videodecoder/video_stream_gdnative.cpp | 17 +- .../videodecoder/video_stream_gdnative.h | 42 ++-- modules/gdnavigation/gd_navigation_server.cpp | 3 +- modules/gdnavigation/gd_navigation_server.h | 2 +- modules/gdnavigation/nav_map.cpp | 11 +- modules/gdnavigation/nav_map.h | 18 +- modules/gdnavigation/nav_region.cpp | 5 - modules/gdnavigation/nav_region.h | 6 +- modules/gdnavigation/nav_utils.h | 43 ++--- modules/gdnavigation/rvo_agent.cpp | 3 +- modules/gdnavigation/rvo_agent.h | 2 +- modules/gdscript/gdscript.h | 10 +- modules/gdscript/gdscript_editor.cpp | 25 +-- modules/gdscript/gdscript_function.h | 16 +- modules/gdscript/gdscript_parser.h | 135 +++++++------ modules/gdscript/gdscript_tokenizer.h | 2 +- modules/mono/csharp_script.h | 12 +- modules/mono/editor/bindings_generator.h | 93 +++------ modules/mono/mono_gc_handle.h | 9 +- modules/mono/mono_gd/gd_mono.h | 21 +- modules/mono/mono_gd/gd_mono_assembly.cpp | 11 -- modules/mono/mono_gd/gd_mono_assembly.h | 10 +- modules/mono/mono_gd/gd_mono_method_thunk.h | 24 +-- modules/mono/mono_gd/gd_mono_utils.cpp | 3 +- modules/mono/mono_gd/gd_mono_utils.h | 2 +- modules/mono/mono_gd/managed_type.h | 9 +- modules/webm/video_stream_webm.cpp | 25 +-- modules/webm/video_stream_webm.h | 28 +-- platform/android/net_socket_android.cpp | 5 - platform/android/net_socket_android.h | 6 +- platform/haiku/key_mapping_haiku.h | 2 +- platform/iphone/export/export.cpp | 8 +- platform/iphone/game_center.mm | 2 +- platform/iphone/icloud.mm | 2 +- platform/iphone/in_app_store.mm | 2 +- platform/iphone/ios.mm | 2 +- platform/iphone/os_iphone.cpp | 6 +- platform/javascript/http_client.h.inc | 16 +- .../javascript/http_client_javascript.cpp | 10 +- platform/linuxbsd/key_mapping_x11.h | 2 +- platform/uwp/app.cpp | 10 - platform/uwp/app.h | 16 +- platform/uwp/export/export.cpp | 20 +- platform/windows/key_mapping_windows.h | 2 +- scene/2d/navigation_agent_2d.cpp | 10 +- scene/2d/navigation_agent_2d.h | 14 +- scene/2d/navigation_obstacle_2d.cpp | 4 +- scene/2d/navigation_obstacle_2d.h | 2 +- scene/2d/navigation_region_2d.cpp | 11 -- scene/2d/navigation_region_2d.h | 10 +- scene/3d/navigation_agent_3d.cpp | 11 +- scene/3d/navigation_agent_3d.h | 16 +- scene/3d/navigation_obstacle_3d.cpp | 4 +- scene/3d/navigation_obstacle_3d.h | 2 +- scene/3d/navigation_region_3d.cpp | 6 - scene/3d/navigation_region_3d.h | 8 +- scene/3d/physics_body_3d.cpp | 19 +- scene/3d/physics_body_3d.h | 163 ++++++---------- scene/3d/physics_joint_3d.cpp | 3 +- scene/3d/physics_joint_3d.h | 2 +- scene/3d/skeleton_ik_3d.cpp | 10 +- scene/3d/skeleton_ik_3d.h | 52 ++--- scene/3d/soft_body_3d.cpp | 12 +- scene/3d/soft_body_3d.h | 16 +- scene/3d/spring_arm_3d.cpp | 8 +- scene/3d/spring_arm_3d.h | 12 +- scene/3d/vehicle_body_3d.cpp | 2 +- scene/animation/animation_player.h | 63 +++--- scene/debugger/scene_debugger.h | 2 +- scene/gui/label.cpp | 17 +- scene/gui/label.h | 43 ++--- scene/main/canvas_item.h | 8 +- scene/main/viewport.cpp | 4 +- scene/resources/environment.cpp | 6 +- scene/resources/environment.h | 8 +- scene/resources/physics_material.cpp | 6 - scene/resources/physics_material.h | 16 +- scene/resources/shape_3d.cpp | 12 +- scene/resources/shape_3d.h | 2 +- scene/resources/tile_set.h | 40 ++-- servers/audio/effects/audio_effect_record.h | 5 +- servers/audio/effects/reverb.cpp | 5 +- servers/audio/effects/reverb.h | 40 ++-- servers/physics_3d/body_3d_sw.cpp | 2 +- servers/physics_3d/body_3d_sw.h | 2 +- servers/physics_3d/gjk_epa.cpp | 14 +- .../physics_3d/joints/jacobian_entry_3d_sw.h | 2 +- servers/physics_server_2d.h | 6 +- servers/physics_server_3d.h | 6 +- .../rasterizer_rd/rasterizer_canvas_rd.h | 2 +- servers/rendering/shader_language.h | 180 +++++++----------- servers/xr/xr_interface.cpp | 2 +- 325 files changed, 1689 insertions(+), 3480 deletions(-) create mode 100644 .clang-tidy delete mode 100644 core/math/audio_frame.cpp delete mode 100644 core/math/disjoint_set.cpp delete mode 100644 core/os/semaphore.cpp delete mode 100644 core/path_remap.cpp delete mode 100644 core/path_remap.h delete mode 100644 core/typed_array.cpp diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000000..6e7b1ba39c0 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,42 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-use-default-member-init' +WarningsAsErrors: '' +HeaderFilterRegex: '.*' +AnalyzeTemporaryDtors: false +FormatStyle: none +CheckOptions: +CheckOptions: + - key: cert-dcl16-c.NewSuffixes + value: 'L;LL;LU;LLU' + - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField + value: '0' + - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors + value: '1' + - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: '1' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-default-member-init.IgnoreMacros + value: '1' + - key: modernize-use-default-member-init.UseAssignment + value: '1' + - key: modernize-use-nullptr.NullMacros + value: 'NULL' +... + diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index e2774deb3c1..ed0e7b10185 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -62,6 +62,8 @@ static const unsigned int MONTH_DAYS_TABLE[2][12] = { { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; +////// _ResourceLoader ////// + _ResourceLoader *_ResourceLoader::singleton = nullptr; Error _ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) { @@ -150,10 +152,7 @@ void _ResourceLoader::_bind_methods() { BIND_ENUM_CONSTANT(THREAD_LOAD_LOADED); } -_ResourceLoader::_ResourceLoader() { - - singleton = this; -} +////// _ResourceSaver ////// Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) { ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'."); @@ -189,10 +188,7 @@ void _ResourceSaver::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS); } -_ResourceSaver::_ResourceSaver() { - - singleton = this; -} +////// _OS ////// PackedStringArray _OS::get_connected_midi_inputs() { return OS::get_singleton()->get_connected_midi_inputs(); @@ -319,50 +315,6 @@ bool _OS::has_feature(const String &p_feature) const { return OS::get_singleton()->has_feature(p_feature); } -/* -enum Weekday { - DAY_SUNDAY, - DAY_MONDAY, - DAY_TUESDAY, - DAY_WEDNESDAY, - DAY_THURSDAY, - DAY_FRIDAY, - DAY_SATURDAY -}; - -enum Month { - MONTH_JANUARY, - MONTH_FEBRUARY, - MONTH_MARCH, - MONTH_APRIL, - MONTH_MAY, - MONTH_JUNE, - MONTH_JULY, - MONTH_AUGUST, - MONTH_SEPTEMBER, - MONTH_OCTOBER, - MONTH_NOVEMBER, - MONTH_DECEMBER -}; -*/ -/* -struct Date { - - int year; - Month month; - int day; - Weekday weekday; - bool dst; -}; - -struct Time { - - int hour; - int min; - int sec; -}; -*/ - uint64_t _OS::get_static_memory_usage() const { return OS::get_singleton()->get_static_memory_usage(); @@ -783,6 +735,7 @@ Vector _OS::get_granted_permissions() const { String _OS::get_unique_id() const { return OS::get_singleton()->get_unique_id(); } + _OS *_OS::singleton = nullptr; void _OS::_bind_methods() { @@ -839,8 +792,6 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("is_debug_build"), &_OS::is_debug_build); - //ClassDB::bind_method(D_METHOD("get_mouse_button_state"),&_OS::get_mouse_button_state); - ClassDB::bind_method(D_METHOD("dump_memory_to_file", "file"), &_OS::dump_memory_to_file); ClassDB::bind_method(D_METHOD("dump_resources_to_file", "file"), &_OS::dump_resources_to_file); ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false)); @@ -914,12 +865,7 @@ void _OS::_bind_methods() { BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES); } -_OS::_OS() { - - singleton = this; -} - -///////////////////// GEOMETRY +////// _Geometry ////// _Geometry *_Geometry::singleton = nullptr; @@ -1296,11 +1242,7 @@ void _Geometry::_bind_methods() { BIND_ENUM_CONSTANT(END_ROUND); } -_Geometry::_Geometry() { - singleton = this; -} - -///////////////////////// FILE +////// _File ////// Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector &p_key) { @@ -1736,19 +1678,12 @@ void _File::_bind_methods() { BIND_ENUM_CONSTANT(COMPRESSION_GZIP); } -_File::_File() { - - f = nullptr; - eswap = false; -} - _File::~_File() { - if (f) memdelete(f); } -/////////////////////////////////////////////////////// +////// _Directory ////// Error _Directory::open(const String &p_path) { Error err; @@ -1929,16 +1864,16 @@ void _Directory::_bind_methods() { } _Directory::_Directory() { - d = DirAccess::create(DirAccess::ACCESS_RESOURCES); } _Directory::~_Directory() { - if (d) memdelete(d); } +////// _Marshalls ////// + _Marshalls *_Marshalls::singleton = nullptr; _Marshalls *_Marshalls::get_singleton() { @@ -2046,7 +1981,7 @@ void _Marshalls::_bind_methods() { ClassDB::bind_method(D_METHOD("base64_to_utf8", "base64_str"), &_Marshalls::base64_to_utf8); }; -//////////////// +////// _Semaphore ////// void _Semaphore::wait() { @@ -2070,7 +2005,7 @@ void _Semaphore::_bind_methods() { ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post); } -/////////////// +////// _Mutex ////// void _Mutex::lock() { @@ -2094,7 +2029,7 @@ void _Mutex::_bind_methods() { ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock); } -/////////////// +////// _Thread ////// void _Thread::_start_func(void *ud) { @@ -2204,19 +2139,12 @@ void _Thread::_bind_methods() { BIND_ENUM_CONSTANT(PRIORITY_NORMAL); BIND_ENUM_CONSTANT(PRIORITY_HIGH); } -_Thread::_Thread() { - - active = false; - thread = nullptr; - target_instance = nullptr; -} _Thread::~_Thread() { - ERR_FAIL_COND_MSG(active, "Reference to a Thread object was lost while the thread is still running..."); } -///////////////////////////////////// +////// _ClassDB ////// PackedStringArray _ClassDB::get_class_list() const { @@ -2425,11 +2353,7 @@ void _ClassDB::_bind_methods() { ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &_ClassDB::is_class_enabled); } -_ClassDB::_ClassDB() { -} -_ClassDB::~_ClassDB() { -} -/////////////////////////////// +////// _Engine ////// void _Engine::set_iterations_per_second(int p_ips) { @@ -2588,9 +2512,7 @@ void _Engine::_bind_methods() { _Engine *_Engine::singleton = nullptr; -_Engine::_Engine() { - singleton = this; -} +////// _JSON ////// void JSONParseResult::_bind_methods() { ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error); @@ -2663,7 +2585,3 @@ Ref _JSON::parse(const String &p_json) { } _JSON *_JSON::singleton = nullptr; - -_JSON::_JSON() { - singleton = this; -} diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index d5f44cdc442..44e573ccbe8 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -69,7 +69,7 @@ public: bool has_cached(const String &p_path); bool exists(const String &p_path, const String &p_type_hint = ""); - _ResourceLoader(); + _ResourceLoader() { singleton = this; } }; VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus); @@ -98,7 +98,7 @@ public: Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags); Vector get_recognized_extensions(const RES &p_resource); - _ResourceSaver(); + _ResourceSaver() { singleton = this; } }; VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags); @@ -245,7 +245,7 @@ public: static _OS *get_singleton() { return singleton; } - _OS(); + _OS() { singleton = this; } }; VARIANT_ENUM_CAST(_OS::VideoDriver); @@ -327,7 +327,7 @@ public: Dictionary make_atlas(const Vector &p_rects); - _Geometry(); + _Geometry() { singleton = this; } }; VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation); @@ -335,10 +335,10 @@ VARIANT_ENUM_CAST(_Geometry::PolyJoinType); VARIANT_ENUM_CAST(_Geometry::PolyEndType); class _File : public Reference { - GDCLASS(_File, Reference); - FileAccess *f; - bool eswap; + + FileAccess *f = nullptr; + bool eswap = false; protected: static void _bind_methods(); @@ -429,7 +429,7 @@ public: uint64_t get_modified_time(const String &p_file) const; - _File(); + _File() {} virtual ~_File(); }; @@ -538,10 +538,10 @@ class _Thread : public Reference { protected: Variant ret; Variant userdata; - volatile bool active; - Object *target_instance; + volatile bool active = false; + Object *target_instance = nullptr; StringName target_method; - Thread *thread; + Thread *thread = nullptr; static void _bind_methods(); static void _start_func(void *ud); @@ -559,7 +559,7 @@ public: bool is_active() const; Variant wait_to_finish(); - _Thread(); + _Thread() {} ~_Thread(); }; @@ -600,8 +600,8 @@ public: bool is_class_enabled(StringName p_class) const; - _ClassDB(); - ~_ClassDB(); + _ClassDB() {} + ~_ClassDB() {} }; class _Engine : public Object { @@ -649,7 +649,7 @@ public: void set_editor_hint(bool p_enabled); bool is_editor_hint() const; - _Engine(); + _Engine() { singleton = this; } }; class _JSON; @@ -661,7 +661,7 @@ class JSONParseResult : public Reference { Error error; String error_string; - int error_line; + int error_line = -1; Variant result; @@ -681,8 +681,7 @@ public: void set_result(const Variant &p_result); Variant get_result() const; - JSONParseResult() : - error_line(-1) {} + JSONParseResult() {} }; class _JSON : public Object { @@ -698,7 +697,7 @@ public: String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false); Ref parse(const String &p_json); - _JSON(); + _JSON() { singleton = this; } }; #endif // CORE_BIND_H diff --git a/core/callable.cpp b/core/callable.cpp index 6a5dc151e5a..447cf78bea1 100644 --- a/core/callable.cpp +++ b/core/callable.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "callable.h" + #include "core/script_language.h" #include "message_queue.h" #include "object.h" @@ -255,12 +256,7 @@ Callable::~Callable() { } } -Callable::Callable() { - object = 0; -} - CallableCustom::CallableCustom() { - referenced = false; ref_count.init(); } @@ -349,6 +345,7 @@ Array Signal::get_connections() const { } return arr; } + Signal::Signal(const Object *p_object, const StringName &p_name) { ERR_FAIL_COND_MSG(p_object == nullptr, "Object argument to Signal constructor must be non-null"); @@ -356,10 +353,9 @@ Signal::Signal(const Object *p_object, const StringName &p_name) { object = p_object->get_instance_id(); name = p_name; } + Signal::Signal(ObjectID p_object, const StringName &p_name) { object = p_object; name = p_name; } -Signal::Signal() { -} diff --git a/core/callable.h b/core/callable.h index 7fa024dccd0..5fa1ebf1d1e 100644 --- a/core/callable.h +++ b/core/callable.h @@ -49,7 +49,7 @@ class Callable { //needs to be max 16 bytes in 64 bits StringName method; union { - uint64_t object; + uint64_t object = 0; CallableCustom *custom; }; @@ -100,14 +100,14 @@ public: Callable(ObjectID p_object, const StringName &p_method); Callable(CallableCustom *p_custom); Callable(const Callable &p_callable); - Callable(); + Callable() {} ~Callable(); }; class CallableCustom { friend class Callable; SafeRefCount ref_count; - bool referenced; + bool referenced = false; public: typedef bool (*CompareEqualFunc)(const CallableCustom *p_a, const CallableCustom *p_b); @@ -156,7 +156,7 @@ public: Array get_connections() const; Signal(const Object *p_object, const StringName &p_name); Signal(ObjectID p_object, const StringName &p_name); - Signal(); + Signal() {} }; #endif // CALLABLE_H diff --git a/core/class_db.cpp b/core/class_db.cpp index ee93ac73aec..dd9fba16d38 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -258,19 +258,6 @@ HashMap ClassDB::classes; HashMap ClassDB::resource_base_extensions; HashMap ClassDB::compat_classes; -ClassDB::ClassInfo::ClassInfo() { - - api = API_NONE; - class_ptr = nullptr; - creation_func = nullptr; - inherits_ptr = nullptr; - disabled = false; - exposed = false; -} - -ClassDB::ClassInfo::~ClassInfo() { -} - bool ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) { OBJTYPE_RLOCK; diff --git a/core/class_db.h b/core/class_db.h index f760aa17388..32d21480484 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -114,9 +114,10 @@ public: struct ClassInfo { - APIType api; - ClassInfo *inherits_ptr; - void *class_ptr; + APIType api = API_NONE; + ClassInfo *inherits_ptr = nullptr; + void *class_ptr = nullptr; + HashMap method_map; HashMap constant_map; HashMap> enum_map; @@ -133,11 +134,12 @@ public: StringName inherits; StringName name; - bool disabled; - bool exposed; - Object *(*creation_func)(); - ClassInfo(); - ~ClassInfo(); + bool disabled = false; + bool exposed = false; + Object *(*creation_func)() = nullptr; + + ClassInfo() {} + ~ClassInfo() {} }; template diff --git a/core/color.h b/core/color.h index 8b689fdde1e..066a3f6696e 100644 --- a/core/color.h +++ b/core/color.h @@ -44,7 +44,7 @@ struct Color { float b; float a; }; - float components[4]; + float components[4] = { 0, 0, 0, 1.0 }; }; bool operator==(const Color &p_color) const { return (r == p_color.r && g == p_color.g && b == p_color.b && a == p_color.a); } @@ -204,15 +204,7 @@ struct Color { _FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys operator String() const; - /** - * No construct parameters, r=0, g=0, b=0. a=1 - */ - _FORCE_INLINE_ Color() { - r = 0; - g = 0; - b = 0; - a = 1.0; - } + _FORCE_INLINE_ Color() {} /** * RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0 diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 3ce769c72c3..60ab5d133b9 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -100,24 +100,11 @@ tryagain: } CommandQueueMT::CommandQueueMT(bool p_sync) { - - read_ptr = 0; - write_ptr = 0; - dealloc_ptr = 0; - command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE); - - for (int i = 0; i < SYNC_SEMAPHORES; i++) { - - sync_sems[i].in_use = false; - } if (p_sync) sync = memnew(Semaphore); - else - sync = nullptr; } CommandQueueMT::~CommandQueueMT() { - if (sync) memdelete(sync); memfree(command_mem); diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 2f2b3b783c5..af8bbb24c63 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -301,14 +301,14 @@ class CommandQueueMT { struct SyncSemaphore { Semaphore sem; - bool in_use; + bool in_use = false; }; struct CommandBase { virtual void call() = 0; - virtual void post(){}; - virtual ~CommandBase(){}; + virtual void post() {} + virtual ~CommandBase() {} }; struct SyncCommand : public CommandBase { @@ -339,13 +339,13 @@ class CommandQueueMT { SYNC_SEMAPHORES = 8 }; - uint8_t *command_mem; - uint32_t read_ptr; - uint32_t write_ptr; - uint32_t dealloc_ptr; + uint8_t *command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE); + uint32_t read_ptr = 0; + uint32_t write_ptr = 0; + uint32_t dealloc_ptr = 0; SyncSemaphore sync_sems[SYNC_SEMAPHORES]; Mutex mutex; - Semaphore *sync; + Semaphore *sync = nullptr; template T *allocate() { diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 0225524bc8d..9e6ba6cde2e 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -288,6 +288,3 @@ void PHashTranslation::_bind_methods() { ClassDB::bind_method(D_METHOD("generate", "from"), &PHashTranslation::generate); } - -PHashTranslation::PHashTranslation() { -} diff --git a/core/compressed_translation.h b/core/compressed_translation.h index d599240dfe0..fff4350caa7 100644 --- a/core/compressed_translation.h +++ b/core/compressed_translation.h @@ -86,7 +86,7 @@ public: virtual StringName get_message(const StringName &p_src_text) const; //overridable for other implementations void generate(const Ref &p_from); - PHashTranslation(); + PHashTranslation() {} }; #endif // COMPRESSED_TRANSLATION_H diff --git a/core/cowdata.h b/core/cowdata.h index 975a5729068..e9cfa2925a9 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -54,7 +54,7 @@ class CowData { friend class VMap; private: - mutable T *_ptr; + mutable T *_ptr = nullptr; // internal helpers @@ -183,7 +183,7 @@ public: int find(const T &p_val, int p_from = 0) const; - _FORCE_INLINE_ CowData(); + _FORCE_INLINE_ CowData() {} _FORCE_INLINE_ ~CowData(); _FORCE_INLINE_ CowData(CowData &p_from) { _ref(p_from); }; }; @@ -366,12 +366,6 @@ void CowData::_ref(const CowData &p_from) { } } -template -CowData::CowData() { - - _ptr = nullptr; -} - template CowData::~CowData() { diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index 233f62bd15d..585731ac9f8 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -94,9 +94,6 @@ Ref Crypto::generate_self_signed_certificate(Ref p_k ERR_FAIL_V_MSG(nullptr, "generate_self_signed_certificate is not available when mbedtls module is disabled."); } -Crypto::Crypto() { -} - /// Resource loader/saver RES ResourceFormatLoaderCrypto::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h index d9becab9585..cf21648a4a2 100644 --- a/core/crypto/crypto.h +++ b/core/crypto/crypto.h @@ -31,11 +31,10 @@ #ifndef CRYPTO_H #define CRYPTO_H -#include "core/reference.h" -#include "core/resource.h" - #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/reference.h" +#include "core/resource.h" class CryptoKey : public Resource { GDCLASS(CryptoKey, Resource); @@ -80,7 +79,7 @@ public: virtual Ref generate_rsa(int p_bytes); virtual Ref generate_self_signed_certificate(Ref p_key, String p_issuer_name, String p_not_before, String p_not_after); - Crypto(); + Crypto() {} }; class ResourceFormatLoaderCrypto : public ResourceFormatLoader { diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp index af43bc9bad1..0b21dead74f 100644 --- a/core/crypto/hashing_context.cpp +++ b/core/crypto/hashing_context.cpp @@ -128,10 +128,6 @@ void HashingContext::_bind_methods() { BIND_ENUM_CONSTANT(HASH_SHA256); } -HashingContext::HashingContext() { - ctx = nullptr; -} - HashingContext::~HashingContext() { if (ctx != nullptr) _delete_ctx(); diff --git a/core/crypto/hashing_context.h b/core/crypto/hashing_context.h index 230ba7ee854..f9454fa8911 100644 --- a/core/crypto/hashing_context.h +++ b/core/crypto/hashing_context.h @@ -44,7 +44,7 @@ public: }; private: - void *ctx; + void *ctx = nullptr; HashType type; protected: @@ -57,7 +57,7 @@ public: Error update(PackedByteArray p_chunk); PackedByteArray finish(); - HashingContext(); + HashingContext() {} ~HashingContext(); }; diff --git a/core/debugger/debugger_marshalls.h b/core/debugger/debugger_marshalls.h index 04229c0afca..9ba316d9971 100644 --- a/core/debugger/debugger_marshalls.h +++ b/core/debugger/debugger_marshalls.h @@ -42,11 +42,8 @@ struct DebuggerMarshalls { String format; String type; RID id; - int vram; + int vram = 0; bool operator<(const ResourceInfo &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; } - ResourceInfo() { - vram = 0; - } }; struct ResourceUsage { @@ -119,10 +116,7 @@ struct DebuggerMarshalls { struct ScriptStackVariable { String name; Variant value; - int type; - ScriptStackVariable() { - type = -1; - } + int type = -1; Array serialize(int max_size = 1 << 20); // 1 MiB default. bool deserialize(const Array &p_arr); @@ -137,27 +131,18 @@ struct DebuggerMarshalls { }; struct OutputError { - int hr; - int min; - int sec; - int msec; + int hr = -1; + int min = -1; + int sec = -1; + int msec = -1; String source_file; String source_func; - int source_line; + int source_line = -1; String error; String error_descr; - bool warning; + bool warning = false; Vector callstack; - OutputError() { - hr = -1; - min = -1; - sec = -1; - msec = -1; - source_line = -1; - warning = false; - } - Array serialize(); bool deserialize(const Array &p_arr); }; diff --git a/core/engine.cpp b/core/engine.cpp index 5361e09a8a1..86ce0395b9c 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -217,23 +217,7 @@ Engine *Engine::get_singleton() { bool Engine::is_abort_on_gpu_errors_enabled() const { return abort_on_gpu_errors; } -Engine::Engine() { +Engine::Engine() { singleton = this; - frames_drawn = 0; - ips = 60; - physics_jitter_fix = 0.5; - _physics_interpolation_fraction = 0.0f; - _frame_delay = 0; - _fps = 1; - _target_fps = 0; - _time_scale = 1.0; - _pixel_snap = false; - _physics_frames = 0; - _idle_frames = 0; - _in_physics = false; - _frame_ticks = 0; - _frame_step = 0; - editor_hint = false; - abort_on_gpu_errors = false; } diff --git a/core/engine.h b/core/engine.h index 8512779d4c8..aa28b358140 100644 --- a/core/engine.h +++ b/core/engine.h @@ -51,28 +51,28 @@ public: private: friend class Main; - uint64_t frames_drawn; - uint32_t _frame_delay; - uint64_t _frame_ticks; - float _frame_step; + uint64_t frames_drawn = 0; + uint32_t _frame_delay = 0; + uint64_t _frame_ticks = 0; + float _frame_step = 0; - int ips; - float physics_jitter_fix; - float _fps; - int _target_fps; - float _time_scale; - bool _pixel_snap; - uint64_t _physics_frames; - float _physics_interpolation_fraction; - bool abort_on_gpu_errors; + int ips = 60; + float physics_jitter_fix = 0.5; + float _fps = 1; + int _target_fps = 0; + float _time_scale = 1.0; + bool _pixel_snap = false; + uint64_t _physics_frames = 0; + float _physics_interpolation_fraction = 0.0f; + bool abort_on_gpu_errors = false; - uint64_t _idle_frames; - bool _in_physics; + uint64_t _idle_frames = 0; + bool _in_physics = false; List singletons; Map singleton_ptrs; - bool editor_hint; + bool editor_hint = false; static Engine *singleton; diff --git a/core/error_macros.h b/core/error_macros.h index 83f92129a51..eb2cc5215d4 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -48,16 +48,12 @@ typedef void (*ErrorHandlerFunc)(void *, const char *, const char *, int p_line, struct ErrorHandlerList { - ErrorHandlerFunc errfunc; - void *userdata; + ErrorHandlerFunc errfunc = nullptr; + void *userdata = nullptr; - ErrorHandlerList *next; + ErrorHandlerList *next = nullptr; - ErrorHandlerList() { - errfunc = 0; - next = 0; - userdata = 0; - } + ErrorHandlerList() {} }; void add_error_handler(ErrorHandlerList *p_handler); diff --git a/core/func_ref.cpp b/core/func_ref.cpp index 338c17946b8..ad29f4488d2 100644 --- a/core/func_ref.cpp +++ b/core/func_ref.cpp @@ -94,6 +94,3 @@ void FuncRef::_bind_methods() { ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function); ClassDB::bind_method(D_METHOD("is_valid"), &FuncRef::is_valid); } - -FuncRef::FuncRef() { -} diff --git a/core/func_ref.h b/core/func_ref.h index 8cb3be6e61d..07b361db2d0 100644 --- a/core/func_ref.h +++ b/core/func_ref.h @@ -48,7 +48,8 @@ public: void set_instance(Object *p_obj); void set_function(const StringName &p_func); bool is_valid() const; - FuncRef(); + + FuncRef() {} }; #endif // FUNC_REF_H diff --git a/core/hash_map.h b/core/hash_map.h index f27a86cc023..4a3bee04c5d 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -75,8 +75,8 @@ public: friend class HashMap; uint32_t hash; - Element *next; - Element() { next = 0; } + Element *next = nullptr; + Element() {} Pair pair; public: @@ -94,9 +94,9 @@ public: }; private: - Element **hash_table; - uint8_t hash_table_power; - uint32_t elements; + Element **hash_table = nullptr; + uint8_t hash_table_power = 0; + uint32_t elements = 0; void make_hash_table() { @@ -551,12 +551,6 @@ public: copy_from(p_table); } - HashMap() { - hash_table = nullptr; - elements = 0; - hash_table_power = 0; - } - void get_key_value_ptr_array(const Pair **p_pairs) const { if (unlikely(!hash_table)) return; @@ -584,17 +578,13 @@ public: } } + HashMap() {} + HashMap(const HashMap &p_table) { - - hash_table = nullptr; - elements = 0; - hash_table_power = 0; - copy_from(p_table); } ~HashMap() { - clear(); } }; diff --git a/core/image.cpp b/core/image.cpp index ff8acc54aff..277f6e9bf0f 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -3671,14 +3671,3 @@ Ref Image::duplicate(bool p_subresources) const { void Image::set_as_black() { zeromem(data.ptrw(), data.size()); } - -Image::Image() { - - width = 0; - height = 0; - mipmaps = false; - format = FORMAT_L8; -} - -Image::~Image() { -} diff --git a/core/image.h b/core/image.h index 07b4f497513..dbdfaa917be 100644 --- a/core/image.h +++ b/core/image.h @@ -33,7 +33,6 @@ #include "core/color.h" #include "core/math/rect2.h" - #include "core/resource.h" /** @@ -172,10 +171,11 @@ private: create(p_width, p_height, p_use_mipmaps, p_format, p_data); } - Format format; + Format format = FORMAT_L8; Vector data; - int width, height; - bool mipmaps; + int width = 0; + int height = 0; + bool mipmaps = false; void _copy_internals_from(const Image &p_image) { format = p_image.format; @@ -286,7 +286,7 @@ public: /** * create an empty image */ - Image(); + Image() {} /** * create an empty image of a specific size and format */ @@ -296,6 +296,8 @@ public: */ Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector &p_data); + ~Image() {} + enum AlphaMode { ALPHA_NONE, ALPHA_BIT, @@ -386,8 +388,6 @@ public: mipmaps = p_image->mipmaps; data = p_image->data; } - - ~Image(); }; VARIANT_ENUM_CAST(Image::Format) diff --git a/core/input/input.cpp b/core/input/input.cpp index 91ff676211f..38a71994d89 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1433,16 +1433,6 @@ int Input::get_joy_axis_index_from_string(String p_axis) { Input::Input() { singleton = this; - use_accumulated_input = true; - mouse_button_mask = 0; - mouse_window = 0; - emulate_touch_from_mouse = false; - emulate_mouse_from_touch = false; - mouse_from_touch_index = -1; - event_dispatch_function = nullptr; - default_shape = CURSOR_ARROW; - - fallback_mapping = -1; // Parse default mappings. { diff --git a/core/input/input.h b/core/input/input.h index 9accf14a4f2..f3150a81275 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -36,7 +36,6 @@ #include "core/os/thread_safe.h" class Input : public Object { - GDCLASS(Input, Object); _THREAD_SAFE_CLASS_ @@ -100,7 +99,7 @@ public: typedef void (*EventDispatchFunc)(const Ref &p_event); private: - int mouse_button_mask; + int mouse_button_mask = 0; Set keys_pressed; Set joy_buttons_pressed; @@ -111,7 +110,7 @@ private: Vector3 magnetometer; Vector3 gyroscope; Vector2 mouse_pos; - int64_t mouse_window; + int64_t mouse_window = 0; struct Action { uint64_t physics_frame; @@ -122,10 +121,11 @@ private: Map action_state; - bool emulate_touch_from_mouse; - bool emulate_mouse_from_touch; + bool emulate_touch_from_mouse = false; + bool emulate_mouse_from_touch = false; + bool use_accumulated_input = false; - int mouse_from_touch_index; + int mouse_from_touch_index = -1; struct SpeedTrack { @@ -144,35 +144,21 @@ private: struct Joypad { StringName name; StringName uid; - bool connected; - bool last_buttons[JOY_BUTTON_MAX]; - float last_axis[JOY_AXIS_MAX]; - float filter; - int last_hat; - int mapping; - int hat_current; - - Joypad() { - for (int i = 0; i < JOY_AXIS_MAX; i++) { - last_axis[i] = 0.0f; - } - for (int i = 0; i < JOY_BUTTON_MAX; i++) { - last_buttons[i] = false; - } - connected = false; - last_hat = HAT_MASK_CENTER; - filter = 0.01f; - mapping = -1; - hat_current = 0; - } + bool connected = false; + bool last_buttons[JOY_BUTTON_MAX] = { false }; + float last_axis[JOY_AXIS_MAX] = { 0.0f }; + float filter = 0.01f; + int last_hat = HAT_MASK_CENTER; + int mapping = -1; + int hat_current = 0; }; SpeedTrack mouse_speed_track; Map touch_speed_track; Map joy_names; - int fallback_mapping; + int fallback_mapping = -1; - CursorShape default_shape; + CursorShape default_shape = CURSOR_ARROW; enum JoyType { TYPE_BUTTON, @@ -243,7 +229,7 @@ private: void _parse_input_event_impl(const Ref &p_event, bool p_is_emulated); List> accumulated_events; - bool use_accumulated_input; + friend class DisplayServer; static void (*set_mouse_mode_func)(MouseMode); @@ -253,7 +239,7 @@ private: static CursorShape (*get_current_cursor_shape_func)(); static void (*set_custom_mouse_cursor_func)(const RES &, CursorShape, const Vector2 &); - EventDispatchFunc event_dispatch_function; + EventDispatchFunc event_dispatch_function = nullptr; protected: struct VibrationInfo { diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 4b8c104f39e..9d3f8f94248 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -132,11 +132,7 @@ void InputEvent::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device"); } -InputEvent::InputEvent() { - - device = 0; -} -//////////////// +/////////////////////////////////// void InputEventFromWindow::_bind_methods() { @@ -152,11 +148,7 @@ int64_t InputEventFromWindow::get_window_id() const { return window_id; } -InputEventFromWindow::InputEventFromWindow() { - window_id = 0; -} - -////////////////// +/////////////////////////////////// void InputEventWithModifiers::set_shift(bool p_enabled) { @@ -236,15 +228,7 @@ void InputEventWithModifiers::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command"), "set_command", "get_command"); } -InputEventWithModifiers::InputEventWithModifiers() { - - alt = false; - shift = false; - control = false; - meta = false; -} - -////////////////////////////////// +/////////////////////////////////// void InputEventKey::set_pressed(bool p_pressed) { @@ -411,16 +395,7 @@ void InputEventKey::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo"); } -InputEventKey::InputEventKey() { - - pressed = false; - keycode = 0; - physical_keycode = 0; - unicode = 0; ///unicode - echo = false; -} - -//////////////////////////////////////// +/////////////////////////////////// void InputEventMouse::set_button_mask(int p_mask) { @@ -465,12 +440,7 @@ void InputEventMouse::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position"), "set_global_position", "get_global_position"); } -InputEventMouse::InputEventMouse() { - - button_mask = 0; -} - -/////////////////////////////////////// +/////////////////////////////////// void InputEventMouseButton::set_factor(float p_factor) { @@ -608,15 +578,7 @@ void InputEventMouseButton::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick"); } -InputEventMouseButton::InputEventMouseButton() { - - factor = 1; - button_index = 0; - pressed = false; - doubleclick = false; -} - -//////////////////////////////////////////// +/////////////////////////////////// void InputEventMouseMotion::set_tilt(const Vector2 &p_tilt) { @@ -773,12 +735,7 @@ void InputEventMouseMotion::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); } -InputEventMouseMotion::InputEventMouseMotion() { - - pressure = 0; -} - -//////////////////////////////////////// +/////////////////////////////////// void InputEventJoypadMotion::set_axis(int p_axis) { @@ -849,12 +806,7 @@ void InputEventJoypadMotion::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "axis_value"), "set_axis_value", "get_axis_value"); } -InputEventJoypadMotion::InputEventJoypadMotion() { - - axis = 0; - axis_value = 0; -} -///////////////////////////////// +/////////////////////////////////// void InputEventJoypadButton::set_button_index(int p_index) { @@ -931,14 +883,7 @@ void InputEventJoypadButton::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); } -InputEventJoypadButton::InputEventJoypadButton() { - - button_index = 0; - pressure = 0; - pressed = false; -} - -////////////////////////////////////////////// +/////////////////////////////////// void InputEventScreenTouch::set_index(int p_index) { @@ -1001,13 +946,7 @@ void InputEventScreenTouch::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); } -InputEventScreenTouch::InputEventScreenTouch() { - - index = 0; - pressed = false; -} - -///////////////////////////// +/////////////////////////////////// void InputEventScreenDrag::set_index(int p_index) { @@ -1088,11 +1027,7 @@ void InputEventScreenDrag::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); } -InputEventScreenDrag::InputEventScreenDrag() { - - index = 0; -} -///////////////////////////// +/////////////////////////////////// void InputEventAction::set_action(const StringName &p_action) { @@ -1171,11 +1106,7 @@ void InputEventAction::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength"); } -InputEventAction::InputEventAction() { - pressed = false; - strength = 1.0f; -} -///////////////////////////// +/////////////////////////////////// void InputEventGesture::set_position(const Vector2 &p_pos) { @@ -1194,7 +1125,8 @@ Vector2 InputEventGesture::get_position() const { return pos; } -///////////////////////////// + +/////////////////////////////////// void InputEventMagnifyGesture::set_factor(real_t p_factor) { @@ -1235,11 +1167,7 @@ void InputEventMagnifyGesture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "factor"), "set_factor", "get_factor"); } -InputEventMagnifyGesture::InputEventMagnifyGesture() { - - factor = 1.0; -} -///////////////////////////// +/////////////////////////////////// void InputEventPanGesture::set_delta(const Vector2 &p_delta) { @@ -1279,11 +1207,7 @@ void InputEventPanGesture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta"); } -InputEventPanGesture::InputEventPanGesture() { - - delta = Vector2(0, 0); -} -///////////////////////////// +/////////////////////////////////// void InputEventMIDI::set_channel(const int p_channel) { @@ -1390,15 +1314,3 @@ void InputEventMIDI::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_number"), "set_controller_number", "get_controller_number"); ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_value"), "set_controller_value", "get_controller_value"); } - -InputEventMIDI::InputEventMIDI() { - - channel = 0; - message = 0; - pitch = 0; - velocity = 0; - instrument = 0; - pressure = 0; - controller_number = 0; - controller_value = 0; -} diff --git a/core/input/input_event.h b/core/input/input_event.h index 99ea2efee9e..18792076f5d 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -157,7 +157,7 @@ enum MidiMessageList { class InputEvent : public Resource { GDCLASS(InputEvent, Resource); - int device; + int device = 0; protected: static void _bind_methods(); @@ -177,7 +177,6 @@ public: // To be removed someday, since they do not make sense for all events virtual bool is_pressed() const; virtual bool is_echo() const; - // ...-. virtual String as_text() const; @@ -188,14 +187,15 @@ public: virtual bool is_action_type() const; virtual bool accumulate(const Ref &p_event) { return false; } - InputEvent(); + + InputEvent() {} }; class InputEventFromWindow : public InputEvent { GDCLASS(InputEventFromWindow, InputEvent); - int64_t window_id; + int64_t window_id = 0; protected: static void _bind_methods(); @@ -204,28 +204,27 @@ public: void set_window_id(int64_t p_id); int64_t get_window_id() const; - InputEventFromWindow(); + InputEventFromWindow() {} }; class InputEventWithModifiers : public InputEventFromWindow { GDCLASS(InputEventWithModifiers, InputEventFromWindow); - bool shift; - bool alt; + bool shift = false; + bool alt = false; #ifdef APPLE_STYLE_KEYS union { bool command; - bool meta; //< windows/mac key + bool meta = false; //< windows/mac key }; - bool control; + bool control = false; #else union { bool command; //< windows/mac key - bool control; + bool control = false; }; - bool meta; //< windows/mac key - + bool meta = false; //< windows/mac key #endif protected: @@ -249,20 +248,20 @@ public: void set_modifiers_from_event(const InputEventWithModifiers *event); - InputEventWithModifiers(); + InputEventWithModifiers() {} }; class InputEventKey : public InputEventWithModifiers { GDCLASS(InputEventKey, InputEventWithModifiers); - bool pressed; /// otherwise release + bool pressed = false; /// otherwise release - uint32_t keycode; ///< check keyboard.h , KeyCode enum, without modifier masks - uint32_t physical_keycode; - uint32_t unicode; ///unicode + uint32_t keycode = 0; ///< check keyboard.h , KeyCode enum, without modifier masks + uint32_t physical_keycode = 0; + uint32_t unicode = 0; ///unicode - bool echo; /// true if this is an echo key + bool echo = false; /// true if this is an echo key protected: static void _bind_methods(); @@ -293,14 +292,14 @@ public: virtual String as_text() const; - InputEventKey(); + InputEventKey() {} }; class InputEventMouse : public InputEventWithModifiers { GDCLASS(InputEventMouse, InputEventWithModifiers); - int button_mask; + int button_mask = 0; Vector2 pos; Vector2 global_pos; @@ -318,17 +317,17 @@ public: void set_global_position(const Vector2 &p_global_pos); Vector2 get_global_position() const; - InputEventMouse(); + InputEventMouse() {} }; class InputEventMouseButton : public InputEventMouse { GDCLASS(InputEventMouseButton, InputEventMouse); - float factor; - int button_index; - bool pressed; //otherwise released - bool doubleclick; //last even less than doubleclick time + float factor = 1; + int button_index = 0; + bool pressed = false; //otherwise released + bool doubleclick = false; //last even less than doubleclick time protected: static void _bind_methods(); @@ -352,7 +351,7 @@ public: virtual bool is_action_type() const { return true; } virtual String as_text() const; - InputEventMouseButton(); + InputEventMouseButton() {} }; class InputEventMouseMotion : public InputEventMouse { @@ -360,7 +359,7 @@ class InputEventMouseMotion : public InputEventMouse { GDCLASS(InputEventMouseMotion, InputEventMouse); Vector2 tilt; - float pressure; + float pressure = 0; Vector2 relative; Vector2 speed; @@ -385,14 +384,14 @@ public: virtual bool accumulate(const Ref &p_event); - InputEventMouseMotion(); + InputEventMouseMotion() {} }; class InputEventJoypadMotion : public InputEvent { GDCLASS(InputEventJoypadMotion, InputEvent); - int axis; ///< Joypad axis - float axis_value; ///< -1 to 1 + int axis = 0; ///< Joypad axis + float axis_value = 0; ///< -1 to 1 protected: static void _bind_methods(); @@ -411,15 +410,15 @@ public: virtual bool is_action_type() const { return true; } virtual String as_text() const; - InputEventJoypadMotion(); + InputEventJoypadMotion() {} }; class InputEventJoypadButton : public InputEvent { GDCLASS(InputEventJoypadButton, InputEvent); - int button_index; - bool pressed; - float pressure; //0 to 1 + int button_index = 0; + bool pressed = false; + float pressure = 0; //0 to 1 protected: static void _bind_methods(); @@ -439,14 +438,14 @@ public: virtual bool is_action_type() const { return true; } virtual String as_text() const; - InputEventJoypadButton(); + InputEventJoypadButton() {} }; class InputEventScreenTouch : public InputEventFromWindow { GDCLASS(InputEventScreenTouch, InputEventFromWindow); - int index; + int index = 0; Vector2 pos; - bool pressed; + bool pressed = false; protected: static void _bind_methods(); @@ -464,13 +463,13 @@ public: virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; virtual String as_text() const; - InputEventScreenTouch(); + InputEventScreenTouch() {} }; class InputEventScreenDrag : public InputEventFromWindow { GDCLASS(InputEventScreenDrag, InputEventFromWindow); - int index; + int index = 0; Vector2 pos; Vector2 relative; Vector2 speed; @@ -494,7 +493,7 @@ public: virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; virtual String as_text() const; - InputEventScreenDrag(); + InputEventScreenDrag() {} }; class InputEventAction : public InputEvent { @@ -502,8 +501,8 @@ class InputEventAction : public InputEvent { GDCLASS(InputEventAction, InputEvent); StringName action; - bool pressed; - float strength; + bool pressed = false; + float strength = 1.0f; protected: static void _bind_methods(); @@ -526,7 +525,7 @@ public: virtual bool is_action_type() const { return true; } virtual String as_text() const; - InputEventAction(); + InputEventAction() {} }; class InputEventGesture : public InputEventWithModifiers { @@ -546,7 +545,7 @@ public: class InputEventMagnifyGesture : public InputEventGesture { GDCLASS(InputEventMagnifyGesture, InputEventGesture); - real_t factor; + real_t factor = 1.0; protected: static void _bind_methods(); @@ -558,7 +557,7 @@ public: virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; virtual String as_text() const; - InputEventMagnifyGesture(); + InputEventMagnifyGesture() {} }; class InputEventPanGesture : public InputEventGesture { @@ -576,20 +575,20 @@ public: virtual Ref xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; virtual String as_text() const; - InputEventPanGesture(); + InputEventPanGesture() {} }; class InputEventMIDI : public InputEvent { GDCLASS(InputEventMIDI, InputEvent); - int channel; - int message; - int pitch; - int velocity; - int instrument; - int pressure; - int controller_number; - int controller_value; + int channel = 0; + int message = 0; + int pitch = 0; + int velocity = 0; + int instrument = 0; + int pressure = 0; + int controller_number = 0; + int controller_value = 0; protected: static void _bind_methods(); @@ -621,7 +620,7 @@ public: virtual String as_text() const; - InputEventMIDI(); + InputEventMIDI() {} }; #endif // INPUT_EVENT_H diff --git a/core/io/compression.h b/core/io/compression.h index 8354b581fa0..3e7c125d8e7 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -53,7 +53,7 @@ public: static int get_max_compressed_buffer_size(int p_src_size, Mode p_mode = MODE_ZSTD); static int decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p_src, int p_src_size, Mode p_mode = MODE_ZSTD); - Compression(); + Compression() {} }; #endif // COMPRESSION_H diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp index 5bda06e5b98..7cbf5c618ed 100644 --- a/core/io/dtls_server.cpp +++ b/core/io/dtls_server.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "dtls_server.h" + #include "core/os/file_access.h" #include "core/project_settings.h" @@ -49,6 +50,3 @@ void DTLSServer::_bind_methods() { ClassDB::bind_method(D_METHOD("setup", "key", "certificate", "chain"), &DTLSServer::setup, DEFVAL(Ref())); ClassDB::bind_method(D_METHOD("take_connection", "udp_peer"), &DTLSServer::take_connection); } - -DTLSServer::DTLSServer() { -} diff --git a/core/io/dtls_server.h b/core/io/dtls_server.h index 7b08138f7f9..ae1d3bcd983 100644 --- a/core/io/dtls_server.h +++ b/core/io/dtls_server.h @@ -51,7 +51,7 @@ public: virtual void stop() = 0; virtual Ref take_connection(Ref p_peer) = 0; - DTLSServer(); + DTLSServer() {} }; #endif // DTLS_SERVER_H diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index ab0fb3943ca..2df91a4dd85 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -166,11 +166,3 @@ Error FileAccessBuffered::get_error() const { return last_error; } - -FileAccessBuffered::FileAccessBuffered() { - - cache_size = DEFAULT_CACHE_SIZE; -} - -FileAccessBuffered::~FileAccessBuffered() { -} diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h index a6177c20be3..2832367a8b2 100644 --- a/core/io/file_access_buffered.h +++ b/core/io/file_access_buffered.h @@ -43,7 +43,7 @@ public: }; private: - int cache_size; + int cache_size = DEFAULT_CACHE_SIZE; int cache_data_left() const; mutable Error last_error; @@ -87,8 +87,8 @@ public: virtual Error get_error() const; - FileAccessBuffered(); - virtual ~FileAccessBuffered(); + FileAccessBuffered() {} + virtual ~FileAccessBuffered() {} }; #endif diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index 6ec77d503bd..edb4ff9a9f8 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -132,12 +132,6 @@ public: set_error(OK); }; - /* - static void make_default() { - FileAccess::create_func = FileAccessBufferedFA::create; - }; - */ - virtual uint64_t _get_modified_time(const String &p_file) { return f._get_modified_time(p_file); @@ -151,9 +145,7 @@ public: return f._set_unix_permissions(p_file, p_permissions); } - FileAccessBufferedFA(){ - - }; + FileAccessBufferedFA() {} }; #endif // FILE_ACCESS_BUFFERED_FA_H diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index c76142d22d4..f2827b519e0 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -389,25 +389,6 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t return FAILED; } -FileAccessCompressed::FileAccessCompressed() : - cmode(Compression::MODE_ZSTD), - writing(false), - write_ptr(nullptr), - write_buffer_size(0), - write_max(0), - block_size(0), - read_eof(false), - at_end(false), - read_ptr(nullptr), - read_block(0), - read_block_count(0), - read_block_size(0), - read_pos(0), - read_total(0), - magic("GCMP"), - f(nullptr) { -} - FileAccessCompressed::~FileAccessCompressed() { if (f) diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index 0bb311faa81..f192be08830 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -36,15 +36,15 @@ class FileAccessCompressed : public FileAccess { - Compression::Mode cmode; - bool writing; - uint32_t write_pos; - uint8_t *write_ptr; - uint32_t write_buffer_size; - uint32_t write_max; - uint32_t block_size; - mutable bool read_eof; - mutable bool at_end; + Compression::Mode cmode = Compression::MODE_ZSTD; + bool writing = false; + uint32_t write_pos = 0; + uint8_t *write_ptr = nullptr; + uint32_t write_buffer_size = 0; + uint32_t write_max = 0; + uint32_t block_size = 0; + mutable bool read_eof = false; + mutable bool at_end = false; struct ReadBlock { int csize; @@ -52,17 +52,17 @@ class FileAccessCompressed : public FileAccess { }; mutable Vector comp_buffer; - uint8_t *read_ptr; - mutable int read_block; - int read_block_count; - mutable int read_block_size; - mutable int read_pos; + uint8_t *read_ptr = nullptr; + mutable int read_block = 0; + int read_block_count = 0; + mutable int read_block_size = 0; + mutable int read_pos = 0; Vector read_blocks; - uint32_t read_total; + uint32_t read_total = 0; - String magic; + String magic = "GCMP"; mutable Vector buffer; - FileAccess *f; + FileAccess *f = nullptr; public: void configure(const String &p_magic, Compression::Mode p_mode = Compression::MODE_ZSTD, int p_block_size = 4096); @@ -94,7 +94,7 @@ public: virtual uint32_t _get_unix_permissions(const String &p_file); virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); - FileAccessCompressed(); + FileAccessCompressed() {} virtual ~FileAccessCompressed(); }; diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index a5b38077899..271c34ec4a2 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -317,15 +317,6 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t return ERR_UNAVAILABLE; } -FileAccessEncrypted::FileAccessEncrypted() { - - file = nullptr; - pos = 0; - eofed = false; - mode = MODE_MAX; - writing = false; -} - FileAccessEncrypted::~FileAccessEncrypted() { if (file) diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 7a9f4ecdd81..e269c1e30c7 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -42,15 +42,15 @@ public: }; private: - Mode mode; + Mode mode = MODE_MAX; Vector key; - bool writing; - FileAccess *file; + bool writing = false; + FileAccess *file = nullptr; size_t base; size_t length; Vector data; - mutable int pos; - mutable bool eofed; + mutable int pos = 0; + mutable bool eofed = false; public: Error open_and_parse(FileAccess *p_base, const Vector &p_key, Mode p_mode); @@ -85,7 +85,7 @@ public: virtual uint32_t _get_unix_permissions(const String &p_file); virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions); - FileAccessEncrypted(); + FileAccessEncrypted() {} ~FileAccessEncrypted(); }; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index a2379ce88ff..a3e04a4538b 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -193,8 +193,3 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, int p_length) { copymem(&data[pos], p_src, write); pos += p_length; } - -FileAccessMemory::FileAccessMemory() { - - data = nullptr; -} diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index 2db14db2656..d8be989b200 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -35,7 +35,7 @@ class FileAccessMemory : public FileAccess { - uint8_t *data; + uint8_t *data = nullptr; int length; mutable int pos; @@ -73,7 +73,7 @@ public: virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; } - FileAccessMemory(); + FileAccessMemory() {} }; #endif // FILE_ACCESS_MEMORY_H diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index a3f307393f4..00f504c3918 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -222,17 +222,11 @@ Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const S FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr; FileAccessNetworkClient::FileAccessNetworkClient() { - - thread = nullptr; - quit = false; singleton = this; - last_id = 0; client.instance(); - lockcount = 0; } FileAccessNetworkClient::~FileAccessNetworkClient() { - if (thread) { quit = true; sem.post(); @@ -513,9 +507,6 @@ void FileAccessNetwork::configure() { FileAccessNetwork::FileAccessNetwork() { - eof_flag = false; - opened = false; - pos = 0; FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton; nc->lock_mutex(); id = nc->last_id++; @@ -523,9 +514,6 @@ FileAccessNetwork::FileAccessNetwork() { nc->unlock_mutex(); page_size = GLOBAL_GET("network/remote_fs/page_size"); read_ahead = GLOBAL_GET("network/remote_fs/page_read_ahead"); - last_activity_val = 0; - waiting_on_page = -1; - last_page = -1; } FileAccessNetwork::~FileAccessNetwork() { diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 7f664b46f7c..6cdd6af0b48 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -50,13 +50,14 @@ class FileAccessNetworkClient { List block_requests; Semaphore sem; - Thread *thread; - bool quit; + Thread *thread = nullptr; + bool quit = false; Mutex mutex; Mutex blockrequest_mutex; Map accesses; Ref client; - int last_id; + int last_id = 0; + int lockcount = 0; Vector block; @@ -67,7 +68,6 @@ class FileAccessNetworkClient { void put_64(int64_t p_64); int get_32(); int64_t get_64(); - int lockcount; void lock_mutex(); void unlock_mutex(); @@ -88,27 +88,23 @@ class FileAccessNetwork : public FileAccess { Semaphore sem; Semaphore page_sem; Mutex buffer_mutex; - bool opened; + bool opened = false; size_t total_size; - mutable size_t pos; + mutable size_t pos = 0; int id; - mutable bool eof_flag; - mutable int last_page; - mutable uint8_t *last_page_buff; + mutable bool eof_flag = false; + mutable int last_page = -1; + mutable uint8_t *last_page_buff = nullptr; int page_size; int read_ahead; - mutable int waiting_on_page; - mutable int last_activity_val; + mutable int waiting_on_page = -1; + struct Page { - int activity; - bool queued; + int activity = 0; + bool queued = false; Vector buffer; - Page() { - activity = 0; - queued = false; - } }; mutable Vector pages; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index fd9b83eaf9d..d70f2ba4453 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -109,8 +109,6 @@ PackedData::PackedData() { singleton = this; root = memnew(PackedDir); - root->parent = nullptr; - disabled = false; add_pack_source(memnew(PackedSourcePCK)); } @@ -506,10 +504,5 @@ String DirAccessPack::get_filesystem_type() const { } DirAccessPack::DirAccessPack() { - current = PackedData::get_singleton()->root; - cdir = false; -} - -DirAccessPack::~DirAccessPack() { } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 8df6826ac9a..aa3a14272b8 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -61,15 +61,15 @@ public: private: struct PackedDir { - PackedDir *parent; + PackedDir *parent = nullptr; String name; Map subdirs; Set files; }; struct PathMD5 { - uint64_t a; - uint64_t b; + uint64_t a = 0; + uint64_t b = 0; bool operator<(const PathMD5 &p_md5) const { if (p_md5.a == a) { @@ -83,14 +83,12 @@ private: return a == p_md5.a && b == p_md5.b; }; - PathMD5() { - a = b = 0; - }; + PathMD5() {} PathMD5(const Vector p_buf) { a = *((uint64_t *)&p_buf[0]); b = *((uint64_t *)&p_buf[8]); - }; + } }; Map files; @@ -98,10 +96,9 @@ private: Vector sources; PackedDir *root; - //Map dirs; static PackedData *singleton; - bool disabled; + bool disabled = false; void _free_packed_dirs(PackedDir *p_dir); @@ -203,7 +200,7 @@ class DirAccessPack : public DirAccess { List list_dirs; List list_files; - bool cdir; + bool cdir = false; public: virtual Error list_dir_begin(); @@ -231,7 +228,7 @@ public: virtual String get_filesystem_type() const; DirAccessPack(); - ~DirAccessPack(); + ~DirAccessPack() {} }; #endif // FILE_ACCESS_PACK_H diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 57de66afaf4..9d068fe809d 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -241,9 +241,7 @@ ZipArchive *ZipArchive::get_singleton() { } ZipArchive::ZipArchive() { - instance = this; - //fa_create_func = FileAccess::get_create_func(); } ZipArchive::~ZipArchive() { @@ -369,14 +367,12 @@ bool FileAccessZip::file_exists(const String &p_name) { return false; } -FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) : - zfile(nullptr) { +FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) { _open(p_path, FileAccess::READ); } FileAccessZip::~FileAccessZip() { - close(); } -#endif +#endif // MINIZIP_ENABLED diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index d5ce7d7a8da..17a3d085b62 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -45,18 +45,15 @@ class ZipArchive : public PackSource { public: struct File { - int package; + int package = -1; unz_file_pos file_pos; - File() { - - package = -1; - }; + File() {} }; private: struct Package { String filename; - unzFile zfile; + unzFile zfile = nullptr; }; Vector packages; diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 56f8f1ff91e..672569c5db1 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -729,27 +729,10 @@ int HTTPClient::get_read_chunk_size() const { } HTTPClient::HTTPClient() { - tcp_connection.instance(); - resolving = IP::RESOLVER_INVALID_ID; - status = STATUS_DISCONNECTED; - head_request = false; - conn_port = -1; - body_size = -1; - chunked = false; - body_left = 0; - read_until_eof = false; - chunk_left = 0; - chunk_trailer_part = false; - response_num = 0; - ssl = false; - blocking = false; - handshaking = false; - read_chunk_size = 4096; } -HTTPClient::~HTTPClient() { -} +HTTPClient::~HTTPClient() {} #endif // #ifndef JAVASCRIPT_ENABLED diff --git a/core/io/http_client.h b/core/io/http_client.h index 03ba20f8ddd..05690534ae0 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -158,32 +158,32 @@ private: }; #ifndef JAVASCRIPT_ENABLED - Status status; - IP::ResolverID resolving; - int conn_port; + Status status = STATUS_DISCONNECTED; + IP::ResolverID resolving = IP::RESOLVER_INVALID_ID; + int conn_port = -1; String conn_host; - bool ssl; - bool ssl_verify_host; - bool blocking; - bool handshaking; - bool head_request; + bool ssl = false; + bool ssl_verify_host = false; + bool blocking = false; + bool handshaking = false; + bool head_request = false; Vector response_str; - bool chunked; + bool chunked = false; Vector chunk; - int chunk_left; - bool chunk_trailer_part; - int body_size; - int body_left; - bool read_until_eof; + int chunk_left = 0; + bool chunk_trailer_part = false; + int body_size = -1; + int body_left = 0; + bool read_until_eof = false; Ref tcp_connection; Ref connection; - int response_num; + int response_num = 0; Vector response_headers; - int read_chunk_size; + int read_chunk_size = 4096; Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 02cc78538e1..23165b575e0 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -102,8 +102,6 @@ void Logger::logf_error(const char *p_format, ...) { va_end(argp); } -Logger::~Logger() {} - void RotatedFileLogger::close_file() { if (file) { memdelete(file); @@ -180,8 +178,7 @@ void RotatedFileLogger::rotate_file() { RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) : base_path(p_base_path.simplify_path()), - max_files(p_max_files > 0 ? p_max_files : 1), - file(nullptr) { + max_files(p_max_files > 0 ? p_max_files : 1) { rotate_file(); } @@ -236,8 +233,6 @@ void StdLogger::logv(const char *p_format, va_list p_list, bool p_err) { } } -StdLogger::~StdLogger() {} - CompositeLogger::CompositeLogger(Vector p_loggers) : loggers(p_loggers) { } diff --git a/core/io/logger.h b/core/io/logger.h index 70285511854..54f1a42da92 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -55,7 +55,7 @@ public: void logf(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3; void logf_error(const char *p_format, ...) _PRINTF_FORMAT_ATTRIBUTE_2_3; - virtual ~Logger(); + virtual ~Logger() {} }; /** @@ -65,7 +65,7 @@ class StdLogger : public Logger { public: virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; - virtual ~StdLogger(); + virtual ~StdLogger() {} }; /** @@ -78,7 +78,7 @@ class RotatedFileLogger : public Logger { String base_path; int max_files; - FileAccess *file; + FileAccess *file = nullptr; void rotate_file_without_closing(); void close_file(); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 81bc45b2f7c..abf27954b8f 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -53,9 +53,6 @@ ObjectID EncodedObjectAsID::get_object_id() const { return id; } -EncodedObjectAsID::EncodedObjectAsID() { -} - #define _S(a) ((int32_t)a) #define ERR_FAIL_ADD_OF(a, b, err) ERR_FAIL_COND_V(_S(b) < 0 || _S(a) < 0 || _S(a) > INT_MAX - _S(b), err) #define ERR_FAIL_MUL_OF(a, b, err) ERR_FAIL_COND_V(_S(a) < 0 || _S(b) <= 0 || _S(a) > INT_MAX / _S(b), err) diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 650c95364a7..1ba786d5d98 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -197,7 +197,7 @@ public: void set_object_id(ObjectID p_id); ObjectID get_object_id() const; - EncodedObjectAsID(); + EncodedObjectAsID() {} }; Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false); diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 94e2fdb72cb..998bcfd3f37 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -33,6 +33,7 @@ #include "core/debugger/engine_debugger.h" #include "core/io/marshalls.h" #include "scene/main/node.h" + #include #define NODE_ID_COMPRESSION_SHIFT 3 @@ -1261,10 +1262,7 @@ void MultiplayerAPI::_bind_methods() { BIND_ENUM_CONSTANT(RPC_MODE_PUPPETSYNC); } -MultiplayerAPI::MultiplayerAPI() : - allow_object_decoding(false) { - rpc_sender_id = 0; - root_node = nullptr; +MultiplayerAPI::MultiplayerAPI() { clear(); } diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index 4eb4a53e997..2603fb1e27a 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -56,14 +56,14 @@ private: }; Ref network_peer; - int rpc_sender_id; + int rpc_sender_id = 0; Set connected_peers; HashMap path_send_cache; Map path_get_cache; int last_send_cache_id; Vector packet_cache; - Node *root_node; - bool allow_object_decoding; + Node *root_node = nullptr; + bool allow_object_decoding = false; protected: static void _bind_methods(); diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index b2f810d2121..332beb4c8cb 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -66,6 +66,3 @@ void NetworkedMultiplayerPeer::_bind_methods() { ADD_SIGNAL(MethodInfo("connection_succeeded")); ADD_SIGNAL(MethodInfo("connection_failed")); } - -NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() { -} diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index c1f1924051c..8792886ff36 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -74,7 +74,7 @@ public: virtual ConnectionStatus get_connection_status() const = 0; - NetworkedMultiplayerPeer(); + NetworkedMultiplayerPeer() {} }; VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode) diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 38abb5c0d64..6d3e1341a7c 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -35,11 +35,6 @@ /* helpers / binders */ -PacketPeer::PacketPeer() : - last_get_error(OK), - encode_buffer_max_size(8 * 1024 * 1024) { -} - void PacketPeer::set_encode_buffer_max_size(int p_max_size) { ERR_FAIL_COND_MSG(p_max_size < 1024, "Max encode buffer must be at least 1024 bytes"); diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 62144259ccd..b69efa531f3 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -47,9 +47,9 @@ class PacketPeer : public Reference { Vector _get_packet(); Error _get_packet_error() const; - mutable Error last_get_error; + mutable Error last_get_error = OK; - int encode_buffer_max_size; + int encode_buffer_max_size = 8 * 1024 * 1024; Vector encode_buffer; public: @@ -70,7 +70,7 @@ public: void set_encode_buffer_max_size(int p_max_size); int get_encode_buffer_max_size() const; - PacketPeer(); + PacketPeer() {} ~PacketPeer() {} }; diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp index 6da115eed20..ada3cb10a27 100644 --- a/core/io/packet_peer_dtls.cpp +++ b/core/io/packet_peer_dtls.cpp @@ -57,6 +57,3 @@ void PacketPeerDTLS::_bind_methods() { BIND_ENUM_CONSTANT(STATUS_ERROR); BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); } - -PacketPeerDTLS::PacketPeerDTLS() { -} diff --git a/core/io/packet_peer_dtls.h b/core/io/packet_peer_dtls.h index 4f9f4535bcf..c2ff4e1a7f5 100644 --- a/core/io/packet_peer_dtls.h +++ b/core/io/packet_peer_dtls.h @@ -60,7 +60,7 @@ public: static PacketPeerDTLS *create(); static bool is_available(); - PacketPeerDTLS(); + PacketPeerDTLS() {} }; VARIANT_ENUM_CAST(PacketPeerDTLS::Status); diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index f800ffc3db7..8b6bd7ef90e 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -343,12 +343,6 @@ void PacketPeerUDP::_bind_methods() { } PacketPeerUDP::PacketPeerUDP() : - packet_port(0), - queue_count(0), - peer_port(0), - connected(false), - blocking(true), - broadcast(false), _sock(Ref(NetSocket::create())) { rb.resize(16); } diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index b5a9fc9ec3c..23fc5460a6b 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -47,14 +47,14 @@ protected: uint8_t recv_buffer[PACKET_BUFFER_SIZE]; uint8_t packet_buffer[PACKET_BUFFER_SIZE]; IP_Address packet_ip; - int packet_port; - int queue_count; + int packet_port = 0; + int queue_count = 0; IP_Address peer_addr; - int peer_port; - bool connected; - bool blocking; - bool broadcast; + int peer_port = 0; + bool connected = false; + bool blocking = true; + bool broadcast = false; Ref _sock; static void _bind_methods(); diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 5c4b3379ee6..124ac30b88f 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -180,11 +180,6 @@ Error PCKPacker::flush(bool p_verbose) { return OK; }; -PCKPacker::PCKPacker() { - - file = nullptr; -}; - PCKPacker::~PCKPacker() { if (file != nullptr) { memdelete(file); diff --git a/core/io/pck_packer.h b/core/io/pck_packer.h index 6058de8345c..2848ac3a657 100644 --- a/core/io/pck_packer.h +++ b/core/io/pck_packer.h @@ -39,7 +39,7 @@ class PCKPacker : public Reference { GDCLASS(PCKPacker, Reference); - FileAccess *file; + FileAccess *file = nullptr; int alignment; static void _bind_methods(); @@ -58,7 +58,7 @@ public: Error add_file(const String &p_file, const String &p_src); Error flush(bool p_verbose = false); - PCKPacker(); + PCKPacker() {} ~PCKPacker(); }; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index e0fea143bb9..8ce17bcfbee 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1024,18 +1024,6 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) { return type; } -ResourceLoaderBinary::ResourceLoaderBinary() : - translation_remapped(false), - ver_format(0), - f(nullptr), - importmd_ofs(0), - error(OK) { - - use_nocache = false; - progress = nullptr; - use_sub_threads = false; -} - ResourceLoaderBinary::~ResourceLoaderBinary() { if (f) @@ -2118,6 +2106,5 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES &p_resource, ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr; ResourceFormatSaverBinary::ResourceFormatSaverBinary() { - singleton = this; } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 3c8d916c0a7..57aa0860222 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -37,16 +37,16 @@ class ResourceLoaderBinary { - bool translation_remapped; + bool translation_remapped = false; String local_path; String res_path; String type; Ref resource; - uint32_t ver_format; + uint32_t ver_format = 0; - FileAccess *f; + FileAccess *f = nullptr; - uint64_t importmd_ofs; + uint64_t importmd_ofs = 0; Vector str_buf; List resource_cache; @@ -61,8 +61,8 @@ class ResourceLoaderBinary { RES cache; }; - bool use_sub_threads; - float *progress; + bool use_sub_threads = false; + float *progress = nullptr; Vector external_resources; struct IntResource { @@ -77,9 +77,9 @@ class ResourceLoaderBinary { void _advance_padding(uint32_t p_len); Map remaps; - Error error; + Error error = OK; - bool use_nocache; + bool use_nocache = false; friend class ResourceFormatLoaderBinary; @@ -98,7 +98,7 @@ public: String recognize(FileAccess *p_f); void get_dependencies(FileAccess *p_f, List *p_dependencies, bool p_add_types); - ResourceLoaderBinary(); + ResourceLoaderBinary() {} ~ResourceLoaderBinary(); }; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d90802d7e2d..dc44be4e0be 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -33,7 +33,6 @@ #include "core/io/resource_importer.h" #include "core/os/file_access.h" #include "core/os/os.h" -#include "core/path_remap.h" #include "core/print_string.h" #include "core/project_settings.h" #include "core/translation.h" diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index b28b17aa953..9bbe92096db 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -536,8 +536,3 @@ Ref StreamPeerBuffer::duplicate() const { spb->data = data; return spb; } - -StreamPeerBuffer::StreamPeerBuffer() { - - pointer = 0; -} diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index 9358a2c07cb..a390fdc3253 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -47,7 +47,7 @@ protected: Array _get_data(int p_bytes); Array _get_partial_data(int p_bytes); - bool big_endian; + bool big_endian = false; public: virtual Error put_data(const uint8_t *p_data, int p_bytes) = 0; ///< put a whole chunk of data, blocking until it sent @@ -89,7 +89,7 @@ public: String get_utf8_string(int p_bytes = -1); Variant get_var(bool p_allow_objects = false); - StreamPeer() { big_endian = false; } + StreamPeer() {} }; class StreamPeerBuffer : public StreamPeer { @@ -97,7 +97,7 @@ class StreamPeerBuffer : public StreamPeer { GDCLASS(StreamPeerBuffer, StreamPeer); Vector data; - int pointer; + int pointer = 0; protected: static void _bind_methods(); @@ -123,7 +123,7 @@ public: Ref duplicate() const; - StreamPeerBuffer(); + StreamPeerBuffer() {} }; #endif // STREAM_PEER_H diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp index d98935f77c4..1d86c355786 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_ssl.cpp @@ -73,7 +73,3 @@ void StreamPeerSSL::_bind_methods() { BIND_ENUM_CONSTANT(STATUS_ERROR); BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); } - -StreamPeerSSL::StreamPeerSSL() { - blocking_handshake = true; -} diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h index de3cb09c60b..81b95b856d4 100644 --- a/core/io/stream_peer_ssl.h +++ b/core/io/stream_peer_ssl.h @@ -43,7 +43,7 @@ protected: static bool available; - bool blocking_handshake; + bool blocking_handshake = true; public: enum Status { @@ -68,7 +68,7 @@ public: static bool is_available(); - StreamPeerSSL(); + StreamPeerSSL() {} }; VARIANT_ENUM_CAST(StreamPeerSSL::Status); diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index f0c5816d734..6218b987586 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -362,10 +362,7 @@ void StreamPeerTCP::_bind_methods() { } StreamPeerTCP::StreamPeerTCP() : - _sock(Ref(NetSocket::create())), - timeout(0), - status(STATUS_NONE), - peer_port(0) { + _sock(Ref(NetSocket::create())) { } StreamPeerTCP::~StreamPeerTCP() { diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 86df9ab8cf9..571f6b7c543 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -52,10 +52,10 @@ public: protected: Ref _sock; - uint64_t timeout; - Status status; + uint64_t timeout = 0; + Status status = STATUS_NONE; IP_Address peer_host; - uint16_t peer_port; + uint16_t peer_port = 0; Error _connect(const String &p_address, int p_port); Error _poll_connection(); diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index bce5361c761..6f79e2554ba 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -212,6 +212,3 @@ String TranslationLoaderPO::get_resource_type(const String &p_path) const { return "Translation"; return ""; } - -TranslationLoaderPO::TranslationLoaderPO() { -} diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index 137dfd17682..a196a37dc06 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -43,7 +43,7 @@ public: virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; - TranslationLoaderPO(); + TranslationLoaderPO() {} }; #endif // TRANSLATION_LOADER_PO_H diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 9613ad3f106..a4b64bf17c6 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -543,9 +543,6 @@ int XMLParser::get_current_line() const { } XMLParser::XMLParser() { - - data = nullptr; - close(); special_characters.push_back("&"); special_characters.push_back("gt;"); diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 26c3e6802fe..42b7d6e0d4f 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -66,15 +66,15 @@ public: }; private: - char *data; - char *P; - uint64_t length; + char *data = nullptr; + char *P = nullptr; + uint64_t length = 0; void unescape(String &p_str); Vector special_characters; String node_name; - bool node_empty; - NodeType node_type; - uint64_t node_offset; + bool node_empty = false; + NodeType node_type = NODE_NONE; + uint64_t node_offset = 0; struct Attribute { String name; diff --git a/core/list.h b/core/list.h index 65d45ffdfca..eb74fa7917b 100644 --- a/core/list.h +++ b/core/list.h @@ -54,9 +54,9 @@ public: friend class List; T value; - Element *next_ptr; - Element *prev_ptr; - _Data *data; + Element *next_ptr = nullptr; + Element *prev_ptr = nullptr; + _Data *data = nullptr; public: /** @@ -139,11 +139,7 @@ public: data->erase(this); } - _FORCE_INLINE_ Element() { - next_ptr = 0; - prev_ptr = 0; - data = nullptr; - }; + _FORCE_INLINE_ Element() {} }; private: @@ -178,7 +174,7 @@ private: } }; - _Data *_data; + _Data *_data = nullptr; public: /** @@ -687,7 +683,6 @@ public: */ List(const List &p_list) { - _data = nullptr; const Element *it = p_list.front(); while (it) { @@ -696,9 +691,8 @@ public: } } - List() { - _data = nullptr; - }; + List() {} + ~List() { clear(); if (_data) { diff --git a/core/map.h b/core/map.h index 6b9dff51def..621b6c2842e 100644 --- a/core/map.h +++ b/core/map.h @@ -51,12 +51,12 @@ public: private: friend class Map; - int color; - Element *right; - Element *left; - Element *parent; - Element *_next; - Element *_prev; + int color = RED; + Element *right = nullptr; + Element *left = nullptr; + Element *parent = nullptr; + Element *_next = nullptr; + Element *_prev = nullptr; K _key; V _value; //_Data *data; @@ -93,22 +93,15 @@ public: const V &get() const { return _value; }; - Element() { - color = RED; - right = nullptr; - left = nullptr; - parent = nullptr; - _next = nullptr; - _prev = nullptr; - }; + Element() {} }; private: struct _Data { - Element *_root; + Element *_root = nullptr; Element *_nil; - int size_cache; + int size_cache = 0; _FORCE_INLINE_ _Data() { #ifdef GLOBALNIL_DISABLED @@ -118,8 +111,6 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif - _root = nullptr; - size_cache = 0; } void _create_root() { @@ -673,8 +664,7 @@ public: _copy_from(p_map); } - _FORCE_INLINE_ Map() { - } + _FORCE_INLINE_ Map() {} ~Map() { diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 3aba753f51d..d6d6101402c 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -585,11 +585,6 @@ void AStar::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); } -AStar::AStar() { - last_free_id = 0; - pass = 1; -} - AStar::~AStar() { clear(); } @@ -910,9 +905,3 @@ void AStar2D::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_estimate_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); BIND_VMETHOD(MethodInfo(Variant::FLOAT, "_compute_cost", PropertyInfo(Variant::INT, "from_id"), PropertyInfo(Variant::INT, "to_id"))); } - -AStar2D::AStar2D() { -} - -AStar2D::~AStar2D() { -} diff --git a/core/math/a_star.h b/core/math/a_star.h index 8c10ace33c7..ffb437ee049 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -47,17 +47,15 @@ class AStar : public Reference { struct Point { - Point() : - neighbours(4u), - unlinked_neighbours(4u) {} + Point() {} int id; Vector3 pos; real_t weight_scale; bool enabled; - OAHashMap neighbours; - OAHashMap unlinked_neighbours; + OAHashMap neighbours = 4u; + OAHashMap unlinked_neighbours = 4u; // Used for pathfinding. Point *prev_point; @@ -85,7 +83,7 @@ class AStar : public Reference { int32_t u; int32_t v; }; - uint64_t key; + uint64_t key = 0; }; enum { @@ -94,13 +92,11 @@ class AStar : public Reference { BACKWARD = 2, BIDIRECTIONAL = FORWARD | BACKWARD }; - unsigned char direction; + unsigned char direction = NONE; bool operator<(const Segment &p_s) const { return key < p_s.key; } - Segment() { - key = 0; - direction = NONE; - } + + Segment() {} Segment(int p_from, int p_to) { if (p_from < p_to) { u = p_from; @@ -114,8 +110,8 @@ class AStar : public Reference { } }; - int last_free_id; - uint64_t pass; + int last_free_id = 0; + uint64_t pass = 1; OAHashMap points; Set segments; @@ -159,7 +155,7 @@ public: Vector get_point_path(int p_from_id, int p_to_id); Vector get_id_path(int p_from_id, int p_to_id); - AStar(); + AStar() {} ~AStar(); }; @@ -206,8 +202,8 @@ public: Vector get_point_path(int p_from_id, int p_to_id); Vector get_id_path(int p_from_id, int p_to_id); - AStar2D(); - ~AStar2D(); + AStar2D() {} + ~AStar2D() {} }; #endif // A_STAR_H diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp deleted file mode 100644 index c565ea9b136..00000000000 --- a/core/math/audio_frame.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* audio_frame.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "audio_frame.h" diff --git a/core/math/delaunay_2d.h b/core/math/delaunay_2d.h index b8252e9d167..66b2f8f5732 100644 --- a/core/math/delaunay_2d.h +++ b/core/math/delaunay_2d.h @@ -36,24 +36,21 @@ class Delaunay2D { public: struct Triangle { - int points[3]; - bool bad; - Triangle() { bad = false; } + bool bad = false; + Triangle() {} Triangle(int p_a, int p_b, int p_c) { points[0] = p_a; points[1] = p_b; points[2] = p_c; - bad = false; } }; struct Edge { int edge[2]; - bool bad; - Edge() { bad = false; } + bool bad = false; + Edge() {} Edge(int p_a, int p_b) { - bad = false; edge[0] = p_a; edge[1] = p_b; } diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h index 57f3a78d35f..ab0993abc9c 100644 --- a/core/math/delaunay_3d.h +++ b/core/math/delaunay_3d.h @@ -45,12 +45,12 @@ class Delaunay3D { struct Triangle { uint32_t triangle[3]; - bool bad; + bool bad = false; _FORCE_INLINE_ bool operator==(const Triangle &p_triangle) const { return triangle[0] == p_triangle.triangle[0] && triangle[1] == p_triangle.triangle[1] && triangle[2] == p_triangle.triangle[2]; } - _FORCE_INLINE_ Triangle() { bad = false; } + _FORCE_INLINE_ Triangle() {} _FORCE_INLINE_ Triangle(uint32_t p_a, uint32_t p_b, uint32_t p_c) { if (p_a > p_b) SWAP(p_a, p_b); @@ -59,7 +59,6 @@ class Delaunay3D { if (p_a > p_b) SWAP(p_a, p_b); - bad = false; triangle[0] = p_a; triangle[1] = p_b; triangle[2] = p_c; @@ -74,9 +73,6 @@ class Delaunay3D { } }; - struct FPVal { - }; - _FORCE_INLINE_ static void circum_sphere_compute(const Vector3 *p_points, Simplex *p_simplex) { // the only part in the algorithm where there may be precision errors is this one, so ensure that diff --git a/core/math/disjoint_set.cpp b/core/math/disjoint_set.cpp deleted file mode 100644 index a508151ad3a..00000000000 --- a/core/math/disjoint_set.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* disjoint_set.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "disjoint_set.h" diff --git a/core/math/expression.cpp b/core/math/expression.cpp index f7a124eae32..c43831ddee0 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -2298,17 +2298,6 @@ void Expression::_bind_methods() { ClassDB::bind_method(D_METHOD("get_error_text"), &Expression::get_error_text); } -Expression::Expression() : - output_type(Variant::NIL), - sequenced(false), - error_set(true), - root(nullptr), - nodes(nullptr), - execution_error(false) { - str_ofs = 0; - expression_dirty = false; -} - Expression::~Expression() { if (nodes) { diff --git a/core/math/expression.h b/core/math/expression.h index 78de225ebfe..bf710ecdd52 100644 --- a/core/math/expression.h +++ b/core/math/expression.h @@ -119,22 +119,20 @@ private: struct Input { - Variant::Type type; + Variant::Type type = Variant::NIL; String name; - Input() : - type(Variant::NIL) { - } + Input() {} }; Vector inputs; - Variant::Type output_type; + Variant::Type output_type = Variant::NIL; String expression; - bool sequenced; - int str_ofs; - bool expression_dirty; + bool sequenced = false; + int str_ofs = 0; + bool expression_dirty = false; bool _compile_expression(); @@ -197,7 +195,7 @@ private: Error _get_token(Token &r_token); String error_str; - bool error_set; + bool error_set = true; struct ENode { @@ -215,11 +213,11 @@ private: TYPE_CALL }; - ENode *next; + ENode *next = nullptr; Type type; - ENode() { next = nullptr; } + ENode() {} virtual ~ENode() { if (next) { memdelete(next); @@ -339,12 +337,12 @@ private: return node; } - ENode *root; - ENode *nodes; + ENode *root = nullptr; + ENode *nodes = nullptr; Vector input_names; - bool execution_error; + bool execution_error = false; bool _execute(const Array &p_inputs, Object *p_instance, Expression::ENode *p_node, Variant &r_ret, String &r_error_str); protected: @@ -356,7 +354,7 @@ public: bool has_execute_failed() const; String get_error_text() const; - Expression(); + Expression() {} ~Expression(); }; diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index b0a46036f96..f923b62542e 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -104,25 +104,19 @@ struct _FaceClassify { struct _Link { - int face; - int edge; + int face = -1; + int edge = -1; void clear() { face = -1; edge = -1; } - _Link() { - face = -1; - edge = -1; - } + _Link() {} }; - bool valid; - int group; + bool valid = false; + int group = -1; _Link links[3]; Face3 face; - _FaceClassify() { - group = -1; - valid = false; - }; + _FaceClassify() {} }; static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) { diff --git a/core/math/octree.h b/core/math/octree.h index ffb405bd0ff..7d89c50f697 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -52,7 +52,6 @@ public: private: enum { - NEG = 0, POS = 1, }; @@ -106,49 +105,35 @@ private: // cached for FAST plane check AABB aabb; - uint64_t last_pass; - Octant *parent; - Octant *children[8]; + uint64_t last_pass = 0; + Octant *parent = nullptr; + Octant *children[8] = { nullptr }; - int children_count; // cache for amount of childrens (fast check for removal) - int parent_index; // cache for parent index (fast check for removal) + int children_count = 0; // cache for amount of childrens (fast check for removal) + int parent_index = -1; // cache for parent index (fast check for removal) List pairable_elements; List elements; - Octant() { - children_count = 0; - parent_index = -1; - last_pass = 0; - parent = nullptr; - for (int i = 0; i < 8; i++) - children[i] = nullptr; - } - - ~Octant() { - - /* - for (int i=0;i<8;i++) - memdelete_notnull(children[i]); - */ - } + Octant() {} + ~Octant() {} }; struct PairData; struct Element { - Octree *octree; + Octree *octree = nullptr; - T *userdata; - int subindex; - bool pairable; - uint32_t pairable_mask; - uint32_t pairable_type; + T *userdata = nullptr; + int subindex = 0; + bool pairable = false; + uint32_t pairable_mask = 0; + uint32_t pairable_type = 0; - uint64_t last_pass; - OctreeElementID _id; - Octant *common_parent; + uint64_t last_pass = 0; + OctreeElementID _id = 0; + Octant *common_parent = nullptr; AABB aabb; AABB container_aabb; @@ -163,17 +148,7 @@ private: List octant_owners; - Element() { - last_pass = 0; - _id = 0; - pairable = false; - subindex = 0; - userdata = 0; - octree = 0; - pairable_mask = 0; - pairable_type = 0; - common_parent = nullptr; - } + Element() {} }; struct PairData { diff --git a/core/math/plane.h b/core/math/plane.h index d4f23ff2b65..f91f8165566 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -36,7 +36,7 @@ class Plane { public: Vector3 normal; - real_t d; + real_t d = 0; void set_normal(const Vector3 &p_normal); _FORCE_INLINE_ Vector3 get_normal() const { return normal; }; ///Point is coplanar, CMP_EPSILON for precision @@ -75,8 +75,7 @@ public: _FORCE_INLINE_ bool operator!=(const Plane &p_plane) const; operator String() const; - _FORCE_INLINE_ Plane() : - d(0) {} + _FORCE_INLINE_ Plane() {} _FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) : normal(p_a, p_b, p_c), d(p_d) {} diff --git a/core/math/quat.h b/core/math/quat.h index b3135ad1ca0..1ca6fe7ce36 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -40,7 +40,7 @@ class Quat { public: - real_t x, y, z, w; + real_t x = 0, y = 0, z = 0, w = 1; _FORCE_INLINE_ real_t length_squared() const; bool is_equal_approx(const Quat &p_quat) const; @@ -112,7 +112,9 @@ public: z = p_z; w = p_w; } - inline Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) : + + _FORCE_INLINE_ Quat() {} + _FORCE_INLINE_ Quat(real_t p_x, real_t p_y, real_t p_z, real_t p_w) : x(p_x), y(p_y), z(p_z), @@ -157,13 +159,6 @@ public: w = s * 0.5; } } - - inline Quat() : - x(0), - y(0), - z(0), - w(1) { - } }; real_t Quat::dot(const Quat &q) const { diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 173f919a73c..89061ab4159 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -75,18 +75,12 @@ public: private: struct FaceConnect { - List::Element *left, *right; - FaceConnect() { - left = nullptr; - right = nullptr; - } + List::Element *left, *right = nullptr; + FaceConnect() {} }; struct RetFaceConnect { - List::Element *left, *right; - RetFaceConnect() { - left = nullptr; - right = nullptr; - } + List::Element *left, *right = nullptr; + RetFaceConnect() {} }; public: diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp index 1a1bffb5624..67f4c0b14a2 100644 --- a/core/math/random_number_generator.cpp +++ b/core/math/random_number_generator.cpp @@ -30,8 +30,6 @@ #include "random_number_generator.h" -RandomNumberGenerator::RandomNumberGenerator() {} - void RandomNumberGenerator::_bind_methods() { ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed); ClassDB::bind_method(D_METHOD("get_seed"), &RandomNumberGenerator::get_seed); diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h index e7f188bb427..2b125433b3c 100644 --- a/core/math/random_number_generator.h +++ b/core/math/random_number_generator.h @@ -65,7 +65,7 @@ public: return ret % (to - from + 1) + from; } - RandomNumberGenerator(); + RandomNumberGenerator() {} }; #endif // RANDOM_NUMBER_GENERATOR_H diff --git a/core/math/rect2.h b/core/math/rect2.h index 30dbfdbbe51..a3f3634bfbf 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -393,11 +393,12 @@ struct Rect2i { operator String() const { return String(position) + ", " + String(size); } operator Rect2() const { return Rect2(position, size); } + + Rect2i() {} Rect2i(const Rect2 &p_r2) : position(p_r2.position), size(p_r2.size) { } - Rect2i() {} Rect2i(int p_x, int p_y, int p_width, int p_height) : position(Point2(p_x, p_y)), size(Size2(p_width, p_height)) { diff --git a/core/math/vector2.h b/core/math/vector2.h index c0057f2543b..5a3e6a0660b 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -44,11 +44,11 @@ struct Vector2 { }; union { - real_t x; + real_t x = 0; real_t width; }; union { - real_t y; + real_t y = 0; real_t height; }; @@ -142,11 +142,11 @@ struct Vector2 { operator String() const { return String::num(x) + ", " + String::num(y); } + _FORCE_INLINE_ Vector2() {} _FORCE_INLINE_ Vector2(real_t p_x, real_t p_y) { x = p_x; y = p_y; } - _FORCE_INLINE_ Vector2() { x = y = 0; } }; _FORCE_INLINE_ Vector2 Vector2::plane_project(real_t p_d, const Vector2 &p_vec) const { @@ -260,11 +260,11 @@ struct Vector2i { }; union { - int x; + int x = 0; int width; }; union { - int y; + int y = 0; int height; }; @@ -307,6 +307,8 @@ struct Vector2i { operator String() const { return String::num(x) + ", " + String::num(y); } operator Vector2() const { return Vector2(x, y); } + + inline Vector2i() {} inline Vector2i(const Vector2 &p_vec2) { x = (int)p_vec2.x; y = (int)p_vec2.y; @@ -315,10 +317,6 @@ struct Vector2i { x = p_x; y = p_y; } - inline Vector2i() { - x = 0; - y = 0; - } }; typedef Vector2i Size2i; diff --git a/core/math/vector3.h b/core/math/vector3.h index a5e9d092086..7131063e04a 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -52,7 +52,7 @@ struct Vector3 { real_t z; }; - real_t coord[3]; + real_t coord[3] = { 0 }; }; _FORCE_INLINE_ const real_t &operator[](int p_axis) const { @@ -152,18 +152,17 @@ struct Vector3 { return Vector3i(x, y, z); } + _FORCE_INLINE_ Vector3() {} _FORCE_INLINE_ Vector3(const Vector3i &p_ivec) { x = p_ivec.x; y = p_ivec.y; z = p_ivec.z; } - _FORCE_INLINE_ Vector3(real_t p_x, real_t p_y, real_t p_z) { x = p_x; y = p_y; z = p_z; } - _FORCE_INLINE_ Vector3() { x = y = z = 0; } }; Vector3 Vector3::cross(const Vector3 &p_b) const { diff --git a/core/math/vector3i.h b/core/math/vector3i.h index 6f9754d3b9d..60e5b94c12d 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -49,7 +49,7 @@ struct Vector3i { int32_t z; }; - int32_t coord[3]; + int32_t coord[3] = { 0 }; }; _FORCE_INLINE_ const int32_t &operator[](int p_axis) const { @@ -100,12 +100,12 @@ struct Vector3i { operator String() const; + _FORCE_INLINE_ Vector3i() {} _FORCE_INLINE_ Vector3i(int32_t p_x, int32_t p_y, int32_t p_z) { x = p_x; y = p_y; z = p_z; } - _FORCE_INLINE_ Vector3i() { x = y = z = 0; } }; Vector3i Vector3i::abs() const { diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 652c4244924..ad4211f3dab 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -345,10 +345,7 @@ MessageQueue::MessageQueue() { ERR_FAIL_COND_MSG(singleton != nullptr, "A MessageQueue singleton already exists."); singleton = this; - flushing = false; - buffer_end = 0; - buffer_max_used = 0; buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB); ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/message_queue/max_size_kb", PropertyInfo(Variant::INT, "memory/limits/message_queue/max_size_kb", PROPERTY_HINT_RANGE, "1024,4096,1,or_greater")); buffer_size *= 1024; diff --git a/core/message_queue.h b/core/message_queue.h index 9ba748bb42b..180e0ce3627 100644 --- a/core/message_queue.h +++ b/core/message_queue.h @@ -63,15 +63,15 @@ class MessageQueue { }; uint8_t *buffer; - uint32_t buffer_end; - uint32_t buffer_max_used; + uint32_t buffer_end = 0; + uint32_t buffer_max_used = 0; uint32_t buffer_size; void _call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error); static MessageQueue *singleton; - bool flushing; + bool flushing = false; public: static MessageQueue *get_singleton(); diff --git a/core/method_bind.cpp b/core/method_bind.cpp index c513de9ca09..854e19cf8a9 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -104,14 +104,6 @@ void MethodBind::_generate_argument_types(int p_count) { MethodBind::MethodBind() { static int last_id = 0; method_id = last_id++; - hint_flags = METHOD_FLAGS_DEFAULT; - argument_count = 0; - default_argument_count = 0; -#ifdef DEBUG_METHODS_ENABLED - argument_types = nullptr; -#endif - _const = false; - _returns = false; } MethodBind::~MethodBind() { diff --git a/core/method_bind.h b/core/method_bind.h index b3d4f1bf9bb..0092527a259 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -208,18 +208,18 @@ struct PtrToArg { class MethodBind { int method_id; - uint32_t hint_flags; + uint32_t hint_flags = METHOD_FLAGS_DEFAULT; StringName name; Vector default_arguments; - int default_argument_count; - int argument_count; + int default_argument_count = 0; + int argument_count = 0; - bool _const; - bool _returns; + bool _const = false; + bool _returns = false; protected: #ifdef DEBUG_METHODS_ENABLED - Variant::Type *argument_types; + Variant::Type *argument_types = nullptr; Vector arg_names; #endif void _set_const(bool p_const); @@ -304,12 +304,11 @@ public: typedef Variant (T::*NativeCall)(const Variant **, int, Callable::CallError &); protected: - NativeCall call_method; + NativeCall call_method = nullptr; #ifdef DEBUG_METHODS_ENABLED - MethodInfo arguments; - #endif + public: #ifdef DEBUG_METHODS_ENABLED @@ -384,7 +383,6 @@ public: virtual bool is_vararg() const { return true; } MethodBindVarArg() { - call_method = nullptr; _set_returns(true); } }; diff --git a/core/node_path.cpp b/core/node_path.cpp index 25f1b383466..f8001a354a5 100644 --- a/core/node_path.cpp +++ b/core/node_path.cpp @@ -187,16 +187,6 @@ NodePath::operator String() const { return ret; } -NodePath::NodePath(const NodePath &p_path) { - - data = nullptr; - - if (p_path.data && p_path.data->refcount.ref()) { - - data = p_path.data; - } -} - Vector NodePath::get_names() const { if (data) @@ -285,35 +275,8 @@ NodePath NodePath::get_as_property_path() const { } } -NodePath::NodePath(const Vector &p_path, bool p_absolute) { - - data = nullptr; - - if (p_path.size() == 0) - return; - - data = memnew(Data); - data->refcount.init(); - data->absolute = p_absolute; - data->path = p_path; - data->has_slashes = true; - data->hash_cache_valid = false; -} - -NodePath::NodePath(const Vector &p_path, const Vector &p_subpath, bool p_absolute) { - - data = nullptr; - - if (p_path.size() == 0 && p_subpath.size() == 0) - return; - - data = memnew(Data); - data->refcount.init(); - data->absolute = p_absolute; - data->path = p_path; - data->subpath = p_subpath; - data->has_slashes = true; - data->hash_cache_valid = false; +bool NodePath::is_empty() const { + return !data; } void NodePath::simplify() { @@ -347,10 +310,38 @@ NodePath NodePath::simplified() const { return np; } +NodePath::NodePath(const Vector &p_path, bool p_absolute) { + if (p_path.size() == 0) + return; + + data = memnew(Data); + data->refcount.init(); + data->absolute = p_absolute; + data->path = p_path; + data->has_slashes = true; + data->hash_cache_valid = false; +} + +NodePath::NodePath(const Vector &p_path, const Vector &p_subpath, bool p_absolute) { + if (p_path.size() == 0 && p_subpath.size() == 0) + return; + + data = memnew(Data); + data->refcount.init(); + data->absolute = p_absolute; + data->path = p_path; + data->subpath = p_subpath; + data->has_slashes = true; + data->hash_cache_valid = false; +} + +NodePath::NodePath(const NodePath &p_path) { + if (p_path.data && p_path.data->refcount.ref()) { + data = p_path.data; + } +} + NodePath::NodePath(const String &p_path) { - - data = nullptr; - if (p_path.length() == 0) return; @@ -437,16 +428,6 @@ NodePath::NodePath(const String &p_path) { } } -bool NodePath::is_empty() const { - - return !data; -} -NodePath::NodePath() { - - data = nullptr; -} - NodePath::~NodePath() { - unref(); } diff --git a/core/node_path.h b/core/node_path.h index 76de36cd9f1..fb15d017bfb 100644 --- a/core/node_path.h +++ b/core/node_path.h @@ -48,7 +48,7 @@ class NodePath { mutable uint32_t hash_cache; }; - mutable Data *data; + mutable Data *data = nullptr; void unref(); void _update_hash_cache() const; @@ -93,7 +93,7 @@ public: NodePath(const Vector &p_path, const Vector &p_subpath, bool p_absolute); NodePath(const NodePath &p_path); NodePath(const String &p_path); - NodePath(); + NodePath() {} ~NodePath(); }; diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h index 71e3ba90684..f7c31f8aae3 100644 --- a/core/oa_hash_map.h +++ b/core/oa_hash_map.h @@ -58,7 +58,7 @@ private: uint32_t capacity; - uint32_t num_elements; + uint32_t num_elements = 0; static const uint32_t EMPTY_HASH = 0; @@ -350,7 +350,6 @@ public: OAHashMap(uint32_t p_initial_capacity = 64) { capacity = p_initial_capacity; - num_elements = 0; keys = memnew_arr(TKey, p_initial_capacity); values = memnew_arr(TValue, p_initial_capacity); diff --git a/core/object.cpp b/core/object.cpp index 94d957f3aff..9ae2d2dcde5 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -127,11 +127,6 @@ MethodInfo::operator Dictionary() const { return d; } -MethodInfo::MethodInfo() : - flags(METHOD_FLAG_NORMAL), - id(0) { -} - MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) { MethodInfo mi; @@ -165,29 +160,28 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) { return mi; } +MethodInfo::MethodInfo() : + flags(METHOD_FLAG_NORMAL) {} + MethodInfo::MethodInfo(const String &p_name) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { } MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); } MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); } MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -195,8 +189,7 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -205,8 +198,7 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -215,28 +207,24 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const } MethodInfo::MethodInfo(Variant::Type ret) : - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; } MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; } MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; arguments.push_back(p_param1); } MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -244,8 +232,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -254,8 +241,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -265,8 +251,7 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -278,23 +263,20 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { } MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); } MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); } @@ -302,8 +284,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -312,8 +293,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -323,8 +303,7 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : name(p_name), return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { + flags(METHOD_FLAG_NORMAL) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -1923,32 +1902,19 @@ void Object::set_script_instance_binding(int p_script_language_index, void *p_da void Object::_construct_object(bool p_reference) { type_is_reference = p_reference; - _class_ptr = nullptr; - _block_signals = false; - _predelete_ok = 0; _instance_id = ObjectDB::add_instance(this); - _can_translate = true; - _is_queued_for_deletion = false; - _emitting = false; - instance_binding_count = 0; memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS); - script_instance = nullptr; -#ifdef TOOLS_ENABLED - - _edited = false; - _edited_version = 0; -#endif #ifdef DEBUG_ENABLED _lock_index.init(1); #endif } + Object::Object(bool p_reference) { _construct_object(p_reference); } Object::Object() { - _construct_object(false); } diff --git a/core/object.h b/core/object.h index 3dec8a04808..20defae0954 100644 --- a/core/object.h +++ b/core/object.h @@ -139,12 +139,12 @@ enum PropertyUsageFlags { struct PropertyInfo { - Variant::Type type; + Variant::Type type = Variant::NIL; String name; StringName class_name; //for classes - PropertyHint hint; + PropertyHint hint = PROPERTY_HINT_NONE; String hint_string; - uint32_t usage; + uint32_t usage = PROPERTY_USAGE_DEFAULT; _FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const { PropertyInfo pi = *this; @@ -156,11 +156,7 @@ struct PropertyInfo { static PropertyInfo from_dict(const Dictionary &p_dict); - PropertyInfo() : - type(Variant::NIL), - hint(PROPERTY_HINT_NONE), - usage(PROPERTY_USAGE_DEFAULT) { - } + PropertyInfo() {} PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) : type(p_type), @@ -178,10 +174,7 @@ struct PropertyInfo { PropertyInfo(const StringName &p_class_name) : type(Variant::OBJECT), - class_name(p_class_name), - hint(PROPERTY_HINT_NONE), - usage(PROPERTY_USAGE_DEFAULT) { - } + class_name(p_class_name) {} bool operator==(const PropertyInfo &p_info) const { return ((type == p_info.type) && @@ -203,8 +196,8 @@ struct MethodInfo { String name; PropertyInfo return_val; - uint32_t flags; - int id; + uint32_t flags; // NOLINT - prevent clang-tidy to assign method_bind.h constant here, it should stay in .cpp. + int id = 0; List arguments; Vector default_arguments; @@ -214,6 +207,7 @@ struct MethodInfo { operator Dictionary() const; static MethodInfo from_dict(const Dictionary &p_dict); + MethodInfo(); MethodInfo(const String &p_name); MethodInfo(const String &p_name, const PropertyInfo &p_param1); @@ -416,14 +410,13 @@ public: ::Signal signal; Callable callable; - uint32_t flags; + uint32_t flags = 0; Vector binds; bool operator<(const Connection &p_conn) const; operator Variant() const; - Connection() { - flags = 0; - } + + Connection() {} Connection(const Variant &p_variant); }; @@ -441,16 +434,13 @@ private: struct SignalData { struct Slot { - - int reference_count; + int reference_count = 0; Connection conn; - List::Element *cE; - Slot() { reference_count = 0; } + List::Element *cE = nullptr; }; MethodInfo user; VMap slot_map; - SignalData() {} }; HashMap signal_map; @@ -458,24 +448,24 @@ private: #ifdef DEBUG_ENABLED SafeRefCount _lock_index; #endif - bool _block_signals; - int _predelete_ok; + bool _block_signals = false; + int _predelete_ok = 0; Set change_receptors; ObjectID _instance_id; bool _predelete(); void _postinitialize(); - bool _can_translate; - bool _emitting; + bool _can_translate = true; + bool _emitting = false; #ifdef TOOLS_ENABLED - bool _edited; - uint32_t _edited_version; + bool _edited = false; + uint32_t _edited_version = 0; Set editor_section_folding; #endif - ScriptInstance *script_instance; + ScriptInstance *script_instance = nullptr; Variant script; //reference does not yet exist, store it in a Dictionary metadata; mutable StringName _class_name; - mutable const StringName *_class_ptr; + mutable const StringName *_class_ptr = nullptr; void _add_user_signal(const String &p_name, const Array &p_args = Array()); bool _has_user_signal(const StringName &p_name) const; @@ -494,8 +484,9 @@ private: friend class Reference; bool type_is_reference = false; - uint32_t instance_binding_count; + uint32_t instance_binding_count = 0; void *_script_instance_bindings[MAX_SCRIPT_INSTANCE_BINDINGS]; + Object(bool p_reference); protected: @@ -503,14 +494,14 @@ protected: virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; }; virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; }; virtual void _get_property_listv(List *p_list, bool p_reversed) const {}; - virtual void _notificationv(int p_notification, bool p_reversed){}; + virtual void _notificationv(int p_notification, bool p_reversed) {} static String _get_category() { return ""; } static void _bind_methods(); bool _set(const StringName &p_name, const Variant &p_property) { return false; }; bool _get(const StringName &p_name, Variant &r_property) const { return false; }; void _get_property_list(List *p_list) const {}; - void _notification(int p_notification){}; + void _notification(int p_notification) {} _FORCE_INLINE_ static void (*_get_bind_methods())() { return &Object::_bind_methods; @@ -559,7 +550,7 @@ protected: public: //should be protected, but bug in clang++ static void initialize_class(); - _FORCE_INLINE_ static void register_custom_data_to_otdb(){}; + _FORCE_INLINE_ static void register_custom_data_to_otdb() {} public: #ifdef TOOLS_ENABLED @@ -579,8 +570,8 @@ public: bool _is_gpl_reversed() const { return false; } _FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_id; } - // this is used for editors + // this is used for editors void add_change_receptor(Object *p_receptor); void remove_change_receptor(Object *p_receptor); @@ -613,7 +604,6 @@ public: } enum { - NOTIFICATION_POSTINITIALIZE = 0, NOTIFICATION_PREDELETE = 1 }; @@ -723,7 +713,7 @@ public: StringName tr(const StringName &p_message) const; // translate message (internationalization) - bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete() + bool _is_queued_for_deletion = false; // set to true by SceneTree::queue_delete() bool is_queued_for_deletion() const; _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; } @@ -745,6 +735,7 @@ public: void clear_internal_resource_paths(); _ALWAYS_INLINE_ bool is_reference() const { return type_is_reference; } + Object(); virtual ~Object(); }; diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h index 05debd529fc..1f1be717410 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -55,9 +55,9 @@ public: class Element { friend class OrderedHashMap; - typename InternalList::Element *list_element; - typename InternalList::Element *prev_element; - typename InternalList::Element *next_element; + typename InternalList::Element *list_element = nullptr; + typename InternalList::Element *prev_element = nullptr; + typename InternalList::Element *next_element = nullptr; Element(typename InternalList::Element *p_element) { list_element = p_element; @@ -69,11 +69,7 @@ public: } public: - _FORCE_INLINE_ Element() : - list_element(nullptr), - prev_element(nullptr), - next_element(nullptr) { - } + _FORCE_INLINE_ Element() {} Element next() const { return Element(next_element); @@ -136,16 +132,14 @@ public: class ConstElement { friend class OrderedHashMap; - const typename InternalList::Element *list_element; + const typename InternalList::Element *list_element = nullptr; ConstElement(const typename InternalList::Element *p_element) : list_element(p_element) { } public: - _FORCE_INLINE_ ConstElement() : - list_element(nullptr) { - } + _FORCE_INLINE_ ConstElement() {} ConstElement(const ConstElement &other) : list_element(other.list_element) { @@ -299,8 +293,7 @@ public: _copy_from(p_map); } - _FORCE_INLINE_ OrderedHashMap() { - } + _FORCE_INLINE_ OrderedHashMap() {} }; #endif // ORDERED_HASH_MAP_H diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index b26cd46fd8b..53b959a580b 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -446,11 +446,3 @@ bool DirAccess::exists(String p_dir) { memdelete(da); return valid; } - -DirAccess::DirAccess() { - - _access_type = ACCESS_FILESYSTEM; -} - -DirAccess::~DirAccess() { -} diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 6c876cde5aa..cac0d0ec7c7 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -47,7 +47,7 @@ public: typedef DirAccess *(*CreateFunc)(); private: - AccessType _access_type; + AccessType _access_type = ACCESS_FILESYSTEM; static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags); @@ -110,16 +110,6 @@ public: static String get_full_path(const String &p_path, AccessType p_access); static DirAccess *create_for_path(const String &p_path); - /* - enum DirType { - - FILE_TYPE_INVALID, - FILE_TYPE_FILE, - FILE_TYPE_DIR, - }; - - //virtual DirType get_file_type() const=0; -*/ static DirAccess *create(AccessType p_access); template @@ -130,8 +120,8 @@ public: static DirAccess *open(const String &p_path, Error *r_error = nullptr); - DirAccess(); - virtual ~DirAccess(); + DirAccess() {} + virtual ~DirAccess() {} }; struct DirAccessRef { @@ -142,7 +132,9 @@ struct DirAccessRef { } operator bool() const { return f != nullptr; } + DirAccess *f; + DirAccessRef(DirAccess *fa) { f = fa; } ~DirAccessRef() { if (f) diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 7055780f340..cb8705f706d 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -278,7 +278,7 @@ class CharBuffer { char *buffer; int capacity; - int written; + int written = 0; bool grow() { @@ -305,8 +305,7 @@ class CharBuffer { public: _FORCE_INLINE_ CharBuffer() : buffer(stack_buffer), - capacity(sizeof(stack_buffer) / sizeof(char)), - written(0) { + capacity(sizeof(stack_buffer) / sizeof(char)) { } _FORCE_INLINE_ void push_back(char c) { @@ -716,10 +715,3 @@ String FileAccess::get_sha256(const String &p_file) { memdelete(f); return String::hex_encode_buffer(hash, 32); } - -FileAccess::FileAccess() { - - endian_swap = false; - real_is_double = false; - _access_type = ACCESS_FILESYSTEM; -}; diff --git a/core/os/file_access.h b/core/os/file_access.h index 0f85c447b66..0ee29abbc92 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -53,8 +53,8 @@ public: typedef void (*FileCloseFailNotify)(const String &); typedef FileAccess *(*CreateFunc)(); - bool endian_swap; - bool real_is_double; + bool endian_swap = false; + bool real_is_double = false; virtual uint32_t _get_unix_permissions(const String &p_file) = 0; virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) = 0; @@ -69,7 +69,7 @@ protected: private: static bool backup_save; - AccessType _access_type; + AccessType _access_type = ACCESS_FILESYSTEM; static CreateFunc create_func[ACCESS_MAX]; /** default file access creation function for a platform */ template static FileAccess *_create_builtin() { @@ -176,7 +176,7 @@ public: create_func[p_access] = _create_builtin; } - FileAccess(); + FileAccess() {} virtual ~FileAccess() {} }; @@ -188,8 +188,11 @@ struct FileAccessRef { } operator bool() const { return f != nullptr; } + FileAccess *f; + operator FileAccess *() { return f; } + FileAccessRef(FileAccess *fa) { f = fa; } ~FileAccessRef() { if (f) diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 0d1a080682c..b29e3f61428 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -60,12 +60,6 @@ void MainLoop::set_init_script(const Ref