From f851c4aa330e1064a66db50be62db2466f4fb768 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 5 Apr 2022 13:40:26 +0300 Subject: Fix some issues found by cppcheck. --- core/debugger/engine_profiler.cpp | 6 +-- core/debugger/local_debugger.cpp | 4 +- core/debugger/remote_debugger.cpp | 11 +++--- core/debugger/remote_debugger_peer.cpp | 4 +- core/debugger/remote_debugger_peer.h | 14 +++---- core/error/error_macros.cpp | 2 +- core/error/error_macros.h | 2 +- core/extension/native_extension.cpp | 16 ++++---- core/input/input.cpp | 6 ++- core/input/input.h | 6 +-- core/input/input_event.cpp | 12 +++--- core/io/file_access_network.cpp | 2 +- core/io/file_access_pack.h | 4 +- core/io/file_access_zip.h | 4 +- core/io/ip.cpp | 2 +- core/io/packed_data_container.cpp | 2 +- core/io/translation_loader_po.cpp | 2 +- core/math/basis.cpp | 2 +- core/math/face3.cpp | 2 +- core/math/face3.h | 2 +- core/math/math_funcs.h | 25 ++++++------ core/object/ref_counted.h | 2 +- core/object/script_language.cpp | 2 +- core/object/script_language.h | 32 +++++++-------- core/os/pool_allocator.cpp | 4 +- core/os/pool_allocator.h | 2 +- core/string/print_string.cpp | 2 +- core/string/print_string.h | 2 +- core/string/translation.cpp | 4 +- core/string/translation.h | 2 +- core/templates/command_queue_mt.h | 8 ++-- core/templates/thread_work_pool.h | 2 +- core/variant/callable_bind.cpp | 16 ++++---- core/variant/callable_bind.h | 32 +++++++-------- core/variant/variant_parser.h | 12 +++--- core/variant/variant_utility.cpp | 72 +++++++++++++++++----------------- 36 files changed, 164 insertions(+), 160 deletions(-) (limited to 'core') diff --git a/core/debugger/engine_profiler.cpp b/core/debugger/engine_profiler.cpp index c858b1febd..6235d19405 100644 --- a/core/debugger/engine_profiler.cpp +++ b/core/debugger/engine_profiler.cpp @@ -55,13 +55,13 @@ Error EngineProfiler::bind(const String &p_name) { EngineDebugger::Profiler prof( this, [](void *p_user, bool p_enable, const Array &p_opts) { - ((EngineProfiler *)p_user)->toggle(p_enable, p_opts); + static_cast(p_user)->toggle(p_enable, p_opts); }, [](void *p_user, const Array &p_data) { - ((EngineProfiler *)p_user)->add(p_data); + static_cast(p_user)->add(p_data); }, [](void *p_user, double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) { - ((EngineProfiler *)p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time); + static_cast(p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time); }); registration = p_name; EngineDebugger::register_profiler(p_name, prof); diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index c9f7d81a90..131cbaed6c 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -369,11 +369,11 @@ LocalDebugger::LocalDebugger() { Profiler scr_prof( scripts_profiler, [](void *p_user, bool p_enable, const Array &p_opts) { - ((ScriptsProfiler *)p_user)->toggle(p_enable, p_opts); + static_cast(p_user)->toggle(p_enable, p_opts); }, nullptr, [](void *p_user, double p_frame_time, double p_idle_time, double p_physics_time, double p_physics_frame_time) { - ((ScriptsProfiler *)p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time); + static_cast(p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time); }); register_profiler("scripts", scr_prof); } diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 2fce23d003..425261aa6c 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -161,8 +161,9 @@ public: if (!monitor_value.is_num()) { ERR_PRINT("Value of custom monitor '" + String(custom_monitor_names[i]) + "' is not a number"); arr[i + max] = Variant(); + } else { + arr[i + max] = monitor_value; } - arr[i + max] = monitor_value; } EngineDebugger::get_singleton()->send_message("performance:profile_frame", arr); @@ -189,7 +190,7 @@ void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char * return; //ignore script errors, those go through debugger } - RemoteDebugger *rd = (RemoteDebugger *)p_this; + RemoteDebugger *rd = static_cast(p_this); if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive errors during flush. return; } @@ -208,7 +209,7 @@ void RemoteDebugger::_err_handler(void *p_this, const char *p_func, const char * } void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p_error) { - RemoteDebugger *rd = (RemoteDebugger *)p_this; + RemoteDebugger *rd = static_cast(p_this); if (rd->flushing && Thread::get_caller_id() == rd->flush_thread) { // Can't handle recursive prints during flush. return; @@ -656,12 +657,12 @@ RemoteDebugger::RemoteDebugger(Ref p_peer) { // Core and profiler captures. Capture core_cap(this, [](void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) { - return ((RemoteDebugger *)p_user)->_core_capture(p_cmd, p_data, r_captured); + return static_cast(p_user)->_core_capture(p_cmd, p_data, r_captured); }); register_message_capture("core", core_cap); Capture profiler_cap(this, [](void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) { - return ((RemoteDebugger *)p_user)->_profiler_capture(p_cmd, p_data, r_captured); + return static_cast(p_user)->_profiler_capture(p_cmd, p_data, r_captured); }); register_message_capture("profiler", profiler_cap); diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 7c7d38ab0a..950500884e 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -162,7 +162,7 @@ Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_po int port = p_port; const int tries = 6; - int waits[tries] = { 1, 10, 100, 1000, 1000, 1000 }; + const int waits[tries] = { 1, 10, 100, 1000, 1000, 1000 }; tcp_client->connect_to_host(ip, port); @@ -192,7 +192,7 @@ Error RemoteDebuggerPeerTCP::connect_to_host(const String &p_host, uint16_t p_po void RemoteDebuggerPeerTCP::_thread_func(void *p_ud) { // Update in time for 144hz monitors const uint64_t min_tick = 6900; - RemoteDebuggerPeerTCP *peer = (RemoteDebuggerPeerTCP *)p_ud; + RemoteDebuggerPeerTCP *peer = static_cast(p_ud); while (peer->running && peer->is_peer_connected()) { uint64_t ticks_usec = OS::get_singleton()->get_ticks_usec(); peer->_poll(); diff --git a/core/debugger/remote_debugger_peer.h b/core/debugger/remote_debugger_peer.h index 010336ffd3..473fd8d712 100644 --- a/core/debugger/remote_debugger_peer.h +++ b/core/debugger/remote_debugger_peer.h @@ -81,13 +81,13 @@ public: Error connect_to_host(const String &p_host, uint16_t p_port); - void poll(); - bool is_peer_connected(); - bool has_message(); - Array get_message(); - Error put_message(const Array &p_arr); - int get_max_message_size() const; - void close(); + void poll() override; + bool is_peer_connected() override; + bool has_message() override; + Array get_message() override; + Error put_message(const Array &p_arr) override; + int get_max_message_size() const override; + void close() override; RemoteDebuggerPeerTCP(Ref p_stream = Ref()); ~RemoteDebuggerPeerTCP(); diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp index ceccd43259..8add4b9a3a 100644 --- a/core/error/error_macros.cpp +++ b/core/error/error_macros.cpp @@ -50,7 +50,7 @@ void add_error_handler(ErrorHandlerList *p_handler) { _global_unlock(); } -void remove_error_handler(ErrorHandlerList *p_handler) { +void remove_error_handler(const ErrorHandlerList *p_handler) { _global_lock(); ErrorHandlerList *prev = nullptr; diff --git a/core/error/error_macros.h b/core/error/error_macros.h index 01e22e84b7..2cfb5421c6 100644 --- a/core/error/error_macros.h +++ b/core/error/error_macros.h @@ -58,7 +58,7 @@ struct ErrorHandlerList { }; void add_error_handler(ErrorHandlerList *p_handler); -void remove_error_handler(ErrorHandlerList *p_handler); +void remove_error_handler(const ErrorHandlerList *p_handler); // Functions used by the error macros. void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, bool p_editor_notify = false, ErrorHandlerType p_type = ERR_HANDLER_ERROR); diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 1a39c937e8..34a11758f8 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -112,7 +112,7 @@ public: static GDNativeInterface gdnative_interface; void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!String(class_name).is_valid_identifier(), "Attempt to register extension class '" + class_name + "', which is not a valid class identifier."); @@ -163,7 +163,7 @@ void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibr ClassDB::register_extension_class(&extension->native_extension); } void NativeExtension::_register_extension_class_method(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; StringName method_name = p_method_info->name; @@ -177,7 +177,7 @@ void NativeExtension::_register_extension_class_method(const GDNativeExtensionCl ClassDB::bind_method_custom(class_name, method); } void NativeExtension::_register_extension_class_integer_constant(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_enum_name, const char *p_constant_name, GDNativeInt p_constant_value) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to register extension constant '" + String(p_constant_name) + "' for unexisting class '" + class_name + "'."); @@ -188,7 +188,7 @@ void NativeExtension::_register_extension_class_integer_constant(const GDNativeE } void NativeExtension::_register_extension_class_property(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const GDNativePropertyInfo *p_info, const char *p_setter, const char *p_getter) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to register extension class property '" + String(p_info->name) + "' for unexisting class '" + class_name + "'."); @@ -206,7 +206,7 @@ void NativeExtension::_register_extension_class_property(const GDNativeExtension } void NativeExtension::_register_extension_class_property_group(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_group_name, const char *p_prefix) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to register extension class property group '" + String(p_group_name) + "' for unexisting class '" + class_name + "'."); @@ -215,7 +215,7 @@ void NativeExtension::_register_extension_class_property_group(const GDNativeExt } void NativeExtension::_register_extension_class_property_subgroup(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_subgroup_name, const char *p_prefix) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to register extension class property subgroup '" + String(p_subgroup_name) + "' for unexisting class '" + class_name + "'."); @@ -224,7 +224,7 @@ void NativeExtension::_register_extension_class_property_subgroup(const GDNative } void NativeExtension::_register_extension_class_signal(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name, const char *p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to register extension class signal '" + String(p_signal_name) + "' for unexisting class '" + class_name + "'."); @@ -245,7 +245,7 @@ void NativeExtension::_register_extension_class_signal(const GDNativeExtensionCl } void NativeExtension::_unregister_extension_class(const GDNativeExtensionClassLibraryPtr p_library, const char *p_class_name) { - NativeExtension *self = (NativeExtension *)p_library; + NativeExtension *self = static_cast(p_library); StringName class_name = p_class_name; ERR_FAIL_COND_MSG(!self->extension_classes.has(class_name), "Attempt to unregister unexisting extension class '" + class_name + "'."); diff --git a/core/input/input.cpp b/core/input/input.cpp index e64b5a3ab7..343076b4e1 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -772,6 +772,8 @@ void Input::action_press(const StringName &p_action, float p_strength) { action.process_frame = Engine::get_singleton()->get_process_frames(); action.pressed = true; action.strength = p_strength; + action.raw_strength = p_strength; + action.exact = true; action_state[p_action] = action; } @@ -783,6 +785,8 @@ void Input::action_release(const StringName &p_action) { action.process_frame = Engine::get_singleton()->get_process_frames(); action.pressed = false; action.strength = 0.f; + action.raw_strength = 0.f; + action.exact = true; action_state[p_action] = action; } @@ -1070,7 +1074,6 @@ void Input::_axis_event(int p_device, JoyAxis p_axis, float p_value) { Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, JoyButton p_button) { JoyEvent event; - event.type = TYPE_MAX; for (int i = 0; i < mapping.bindings.size(); i++) { const JoyBinding binding = mapping.bindings[i]; @@ -1106,7 +1109,6 @@ Input::JoyEvent Input::_get_mapped_button_event(const JoyDeviceMapping &mapping, Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, JoyAxis p_axis, float p_value) { JoyEvent event; - event.type = TYPE_MAX; for (int i = 0; i < mapping.bindings.size(); i++) { const JoyBinding binding = mapping.bindings[i]; diff --git a/core/input/input.h b/core/input/input.h index ac688b53b8..bbdac46805 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -157,9 +157,9 @@ private: }; struct JoyEvent { - int type; - int index; // Can be either JoyAxis or JoyButton. - float value; + int type = TYPE_MAX; + int index = -1; // Can be either JoyAxis or JoyButton. + float value = 0.f; }; struct JoyBinding { diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index b8ab722b12..2d4c203748 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -47,30 +47,30 @@ int InputEvent::get_device() const { } bool InputEvent::is_action(const StringName &p_action, bool p_exact_match) const { - return InputMap::get_singleton()->event_is_action(Ref((InputEvent *)this), p_action, p_exact_match); + return InputMap::get_singleton()->event_is_action(Ref(const_cast(this)), p_action, p_exact_match); } bool InputEvent::is_action_pressed(const StringName &p_action, bool p_allow_echo, bool p_exact_match) const { bool pressed; - bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr); + bool valid = InputMap::get_singleton()->event_get_action_status(Ref(const_cast(this)), p_action, p_exact_match, &pressed, nullptr, nullptr); return valid && pressed && (p_allow_echo || !is_echo()); } bool InputEvent::is_action_released(const StringName &p_action, bool p_exact_match) const { bool pressed; - bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr); + bool valid = InputMap::get_singleton()->event_get_action_status(Ref(const_cast(this)), p_action, p_exact_match, &pressed, nullptr, nullptr); return valid && !pressed; } float InputEvent::get_action_strength(const StringName &p_action, bool p_exact_match) const { float strength; - bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, nullptr, &strength, nullptr); + bool valid = InputMap::get_singleton()->event_get_action_status(Ref(const_cast(this)), p_action, p_exact_match, nullptr, &strength, nullptr); return valid ? strength : 0.0f; } float InputEvent::get_action_raw_strength(const StringName &p_action, bool p_exact_match) const { float raw_strength; - bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, nullptr, nullptr, &raw_strength); + bool valid = InputMap::get_singleton()->event_get_action_status(Ref(const_cast(this)), p_action, p_exact_match, nullptr, nullptr, &raw_strength); return valid ? raw_strength : 0.0f; } @@ -83,7 +83,7 @@ bool InputEvent::is_echo() const { } Ref InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { - return Ref((InputEvent *)this); + return Ref(const_cast(this)); } bool InputEvent::action_match(const Ref &p_event, bool p_exact_match, float p_deadzone, bool *r_pressed, float *r_strength, float *r_raw_strength) const { diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index cb38ac0928..612181f8d5 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -165,7 +165,7 @@ void FileAccessNetworkClient::_thread_func() { } void FileAccessNetworkClient::_thread_func(void *s) { - FileAccessNetworkClient *self = (FileAccessNetworkClient *)s; + FileAccessNetworkClient *self = static_cast(s); self->_thread_func(); } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index fe4b12aef6..d4b32df2c7 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -139,8 +139,8 @@ public: class PackedSourcePCK : public PackSource { public: - virtual bool try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset); - virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file); + virtual bool try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset) override; + virtual FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file) override; }; class FileAccessPack : public FileAccess { diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 7cd5893101..a238c66437 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -67,8 +67,8 @@ public: bool file_exists(String p_name) const; - virtual bool try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset); - FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file); + virtual bool try_open_pack(const String &p_path, bool p_replace_files, uint64_t p_offset) override; + FileAccess *get_file(const String &p_path, PackedData::PackedFile *p_file) override; static ZipArchive *get_singleton(); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 2f88307d94..52674150bb 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -109,7 +109,7 @@ struct _IP_ResolverPrivate { } static void _thread_function(void *self) { - _IP_ResolverPrivate *ipr = (_IP_ResolverPrivate *)self; + _IP_ResolverPrivate *ipr = static_cast<_IP_ResolverPrivate *>(self); while (!ipr->thread_abort) { ipr->sem.wait(); diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index 14183b472b..027fdd51aa 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -105,7 +105,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b if (type == TYPE_ARRAY || type == TYPE_DICT) { Ref pdcr = memnew(PackedDataContainerRef); - Ref pdc = Ref((PackedDataContainer *)this); + Ref pdc = Ref(const_cast(this)); pdcr->from = pdc; pdcr->offset = p_ofs; diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 801bd8b0bf..30df46a6b4 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -98,7 +98,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { { Vector data; f->seek(trans_table_offset + i * 8); - uint32_t str_start = 0; uint32_t str_len = f->get_32(); uint32_t str_offset = f->get_32(); @@ -116,6 +115,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { translation->set_plural_rule(config.substr(p_start, p_end - p_start)); } } else { + uint32_t str_start = 0; Vector plural_msg; for (uint32_t j = 0; j < str_len + 1; j++) { if (data[j] == 0x00) { diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 84f9d12bb1..eb6703aff2 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -1002,7 +1002,7 @@ void Basis::rotate_sh(real_t *p_values) { const static real_t s_scale_dst2 = s_c3 * s_c_scale_inv; const static real_t s_scale_dst4 = s_c5 * s_c_scale_inv; - real_t src[9] = { p_values[0], p_values[1], p_values[2], p_values[3], p_values[4], p_values[5], p_values[6], p_values[7], p_values[8] }; + const real_t src[9] = { p_values[0], p_values[1], p_values[2], p_values[3], p_values[4], p_values[5], p_values[6], p_values[7], p_values[8] }; real_t m00 = elements[0][0]; real_t m01 = elements[0][1]; diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 5bc1bc25e6..fb92f6b0df 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -208,7 +208,7 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const { /** TEST ALL EDGES **/ - Vector3 edge_norms[3] = { + const Vector3 edge_norms[3] = { vertex[0] - vertex[1], vertex[1] - vertex[2], vertex[2] - vertex[0], diff --git a/core/math/face3.h b/core/math/face3.h index c61d6ad66e..23260336fa 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -133,7 +133,7 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const { #undef TEST_AXIS - Vector3 edge_norms[3] = { + const Vector3 edge_norms[3] = { vertex[0] - vertex[1], vertex[1] - vertex[2], vertex[2] - vertex[0], diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 44340b97ae..b741277872 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -473,16 +473,16 @@ public: uint32_t x = ci.ui; uint32_t sign = (unsigned short)(x >> 31); uint32_t mantissa; - uint32_t exp; + uint32_t exponent; uint16_t hf; // get mantissa mantissa = x & ((1 << 23) - 1); // get exponent bits - exp = x & (0xFF << 23); - if (exp >= 0x47800000) { + exponent = x & (0xFF << 23); + if (exponent >= 0x47800000) { // check if the original single precision float number is a NaN - if (mantissa && (exp == (0xFF << 23))) { + if (mantissa && (exponent == (0xFF << 23))) { // we have a single precision NaN mantissa = (1 << 23) - 1; } else { @@ -493,17 +493,18 @@ public: (uint16_t)(mantissa >> 13); } // check if exponent is <= -15 - else if (exp <= 0x38000000) { - /*// store a denorm half-float value or zero - exp = (0x38000000 - exp) >> 23; - mantissa >>= (14 + exp); - - hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa); - */ + else if (exponent <= 0x38000000) { + /* + // store a denorm half-float value or zero + exponent = (0x38000000 - exponent) >> 23; + mantissa >>= (14 + exponent); + + hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa); + */ hf = 0; //denormals do not work for 3D, convert to zero } else { hf = (((uint16_t)sign) << 15) | - (uint16_t)((exp - 0x38000000) >> 13) | + (uint16_t)((exponent - 0x38000000) >> 13) | (uint16_t)(mantissa >> 13); } diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h index 8eb1c97cce..dcacf19890 100644 --- a/core/object/ref_counted.h +++ b/core/object/ref_counted.h @@ -261,7 +261,7 @@ struct PtrToArg> { typedef Ref EncodeT; _FORCE_INLINE_ static void encode(Ref p_val, const void *p_ptr) { - *(Ref *)p_ptr = p_val; + *(const_cast *>(reinterpret_cast *>(p_ptr))) = p_val; } }; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 11440c37fe..a5d25bf533 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -144,7 +144,7 @@ void ScriptServer::register_language(ScriptLanguage *p_language) { _languages[_language_count++] = p_language; } -void ScriptServer::unregister_language(ScriptLanguage *p_language) { +void ScriptServer::unregister_language(const ScriptLanguage *p_language) { for (int i = 0; i < _language_count; i++) { if (_languages[i] == p_language) { _language_count--; diff --git a/core/object/script_language.h b/core/object/script_language.h index 08b82d798e..69002c81f4 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -68,7 +68,7 @@ public: _FORCE_INLINE_ static int get_language_count() { return _language_count; } static ScriptLanguage *get_language(int p_idx); static void register_language(ScriptLanguage *p_language); - static void unregister_language(ScriptLanguage *p_language); + static void unregister_language(const ScriptLanguage *p_language); static void set_reload_scripts_on_save(bool p_enable); static bool is_reload_scripts_on_save_enabled(); @@ -438,34 +438,34 @@ class PlaceHolderScriptInstance : public ScriptInstance { Ref