diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-04-07 13:23:40 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-04-20 10:34:00 +0300 |
commit | de4c97758af117af97fad58e4a80ffeba0154ba8 (patch) | |
tree | 2139631cc24a59900a840b9371d5043183558fbd /core | |
parent | f4b0c7a1ea8d86c1dfd96478ca12ad1360903d9d (diff) |
Fix more issues found by cppcheck.
Diffstat (limited to 'core')
-rw-r--r-- | core/debugger/remote_debugger.cpp | 2 | ||||
-rw-r--r-- | core/debugger/remote_debugger.h | 2 | ||||
-rw-r--r-- | core/extension/native_extension.cpp | 16 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 2 | ||||
-rw-r--r-- | core/io/logger.h | 12 | ||||
-rw-r--r-- | core/io/resource.cpp | 2 | ||||
-rw-r--r-- | core/math/convex_hull.cpp | 6 | ||||
-rw-r--r-- | core/math/geometry_3d.cpp | 4 | ||||
-rw-r--r-- | core/math/math_funcs.h | 3 | ||||
-rw-r--r-- | core/object/method_bind.h | 90 | ||||
-rw-r--r-- | core/os/keyboard.h | 2 | ||||
-rw-r--r-- | core/string/ustring.cpp | 5 | ||||
-rw-r--r-- | core/variant/variant.cpp | 4 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 6 | ||||
-rw-r--r-- | core/variant/variant_parser.cpp | 1 |
15 files changed, 78 insertions, 79 deletions
diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 425261aa6c..c3506a7eea 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -169,7 +169,7 @@ public: EngineDebugger::get_singleton()->send_message("performance:profile_frame", arr); } - PerformanceProfiler(Object *p_performance) { + explicit PerformanceProfiler(Object *p_performance) { performance = p_performance; } }; diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h index aada92da60..fdb312ae68 100644 --- a/core/debugger/remote_debugger.h +++ b/core/debugger/remote_debugger.h @@ -108,7 +108,7 @@ public: void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, bool p_editor_notify, ErrorHandlerType p_type); void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false); - RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer); + explicit RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer); ~RemoteDebugger(); }; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 34a11758f8..076d04a5eb 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -49,10 +49,10 @@ class NativeExtensionMethodBind : public MethodBind { bool vararg; protected: - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { return Variant::Type(get_argument_type_func(method_userdata, p_arg)); } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { GDNativePropertyInfo pinfo; get_argument_info_func(method_userdata, p_arg, &pinfo); PropertyInfo ret; @@ -66,11 +66,13 @@ protected: } public: - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { +#ifdef DEBUG_METHODS_ENABLED + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return GodotTypeInfo::Metadata(get_argument_metadata_func(method_userdata, p_arg)); } +#endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance(); GDNativeCallError ce{ GDNATIVE_CALL_OK, 0, 0 }; @@ -80,16 +82,16 @@ public: r_error.expected = ce.expected; return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { ERR_FAIL_COND_MSG(vararg, "Vararg methods don't have ptrcall support. This is most likely an engine bug."); GDExtensionClassInstancePtr extension_instance = p_object->_get_extension_instance(); ptrcall_func(method_userdata, extension_instance, (const GDNativeTypePtr *)p_args, (GDNativeTypePtr)r_ret); } - virtual bool is_vararg() const { + virtual bool is_vararg() const override { return false; } - NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) { + explicit NativeExtensionMethodBind(const GDNativeExtensionClassMethodInfo *p_method_info) { method_userdata = p_method_info->method_userdata; call_func = p_method_info->call_func; ptrcall_func = p_method_info->ptrcall_func; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 44df2029bd..17e87c835a 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -93,7 +93,7 @@ private: PathMD5() {} - PathMD5(const Vector<uint8_t> &p_buf) { + explicit PathMD5(const Vector<uint8_t> &p_buf) { a = *((uint64_t *)&p_buf[0]); b = *((uint64_t *)&p_buf[8]); } diff --git a/core/io/logger.h b/core/io/logger.h index e3ac00f11c..8ac086e376 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -67,7 +67,7 @@ public: */ 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 void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; virtual ~StdLogger() {} }; @@ -87,19 +87,19 @@ class RotatedFileLogger : public Logger { void rotate_file(); public: - RotatedFileLogger(const String &p_base_path, int p_max_files = 10); + explicit RotatedFileLogger(const String &p_base_path, int p_max_files = 10); - virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; + virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; }; class CompositeLogger : public Logger { Vector<Logger *> loggers; public: - CompositeLogger(Vector<Logger *> p_loggers); + explicit CompositeLogger(Vector<Logger *> p_loggers); - virtual void logv(const char *p_format, va_list p_list, bool p_err) _PRINTF_FORMAT_ATTRIBUTE_2_0; - virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR); + virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0; + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) override; void add_logger(Logger *p_logger); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index bf91438810..96efffd49b 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -257,7 +257,7 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { List<PropertyInfo> plist; get_property_list(&plist); - Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class()); + Ref<Resource> r = static_cast<Resource *>(ClassDB::instantiate(get_class())); ERR_FAIL_COND_V(r.is_null(), Ref<Resource>()); for (const PropertyInfo &E : plist) { diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index bd292f4c2a..23a0b5dd54 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -509,7 +509,7 @@ public: Face() { } - void init(Vertex *p_a, Vertex *p_b, Vertex *p_c) { + void init(Vertex *p_a, const Vertex *p_b, const Vertex *p_c) { nearby_vertex = p_a; origin = p_a->point; dir0 = *p_b - *p_a; @@ -614,7 +614,7 @@ private: static Orientation get_orientation(const Edge *p_prev, const Edge *p_next, const Point32 &p_s, const Point32 &p_t); Edge *find_max_angle(bool p_ccw, const Vertex *p_start, const Point32 &p_s, const Point64 &p_rxs, const Point64 &p_ssxrxs, Rational64 &p_min_cot); - void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1); + void find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1); Edge *new_edge_pair(Vertex *p_from, Vertex *p_to); @@ -1189,7 +1189,7 @@ ConvexHullInternal::Edge *ConvexHullInternal::find_max_angle(bool p_ccw, const V return min_edge; } -void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, Vertex *p_stop0, Vertex *p_stop1) { +void ConvexHullInternal::find_edge_for_coplanar_faces(Vertex *p_c0, Vertex *p_c1, Edge *&p_e0, Edge *&p_e1, const Vertex *p_stop0, const Vertex *p_stop1) { Edge *start0 = p_e0; Edge *start1 = p_e1; Point32 et0 = start0 ? start0->target->point : p_c0->point; diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index bd22bffb1f..f76de079e4 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -904,8 +904,8 @@ Vector<Vector3> Geometry3D::compute_convex_mesh_points(const Plane *p_planes, in /* dt of 1d function using squared distance */ static void edt(float *f, int stride, int n) { float *d = (float *)alloca(sizeof(float) * n + sizeof(int) * n + sizeof(float) * (n + 1)); - int *v = (int *)&(d[n]); - float *z = (float *)&v[n]; + int *v = reinterpret_cast<int *>(&(d[n])); + float *z = reinterpret_cast<float *>(&v[n]); int k = 0; v[0] = 0; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index b741277872..068bc0397e 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -103,6 +103,9 @@ public: static _ALWAYS_INLINE_ double log(double p_x) { return ::log(p_x); } static _ALWAYS_INLINE_ float log(float p_x) { return ::logf(p_x); } + static _ALWAYS_INLINE_ double log1p(double p_x) { return ::log1p(p_x); } + static _ALWAYS_INLINE_ float log1p(float p_x) { return ::log1pf(p_x); } + static _ALWAYS_INLINE_ double log2(double p_x) { return ::log2(p_x); } static _ALWAYS_INLINE_ float log2(float p_x) { return ::log2f(p_x); } diff --git a/core/object/method_bind.h b/core/object/method_bind.h index bde6cba199..2870195911 100644 --- a/core/object/method_bind.h +++ b/core/object/method_bind.h @@ -152,7 +152,7 @@ protected: MethodInfo method_info; public: - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg < 0) { return _gen_return_type_info(); } else if (p_arg < method_info.arguments.size()) { @@ -162,23 +162,23 @@ public: } } - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { return _gen_argument_type_info(p_arg).type; } #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int) const override { return GodotTypeInfo::METADATA_NONE; } #endif - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { ERR_FAIL(); // Can't call. } virtual bool is_const() const { return false; } - virtual bool is_vararg() const { return true; } + virtual bool is_vararg() const override { return true; } MethodBindVarArgBase( R (T::*p_method)(const Variant **, int, Callable::CallError &), @@ -224,7 +224,7 @@ class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, v friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>; public: - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>::method)(p_args, p_arg_count, r_error); return {}; } @@ -255,7 +255,7 @@ class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>, friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>; public: - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { return (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)(p_args, p_arg_count, r_error); } @@ -303,7 +303,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -314,7 +314,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); return pi; @@ -322,25 +322,25 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata<P...>(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { #ifdef TYPED_METHOD_BIND call_with_variant_args_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #else - call_with_variant_args_dv((MB_T *)(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); + call_with_variant_args_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #endif return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args<T, P...>(static_cast<T *>(p_object), method, p_args); #else - call_with_ptr_args<MB_T, P...>((MB_T *)(p_object), method, p_args); + call_with_ptr_args<MB_T, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args); #endif } @@ -378,7 +378,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -389,7 +389,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); return pi; @@ -397,25 +397,25 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata<P...>(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { #ifdef TYPED_METHOD_BIND call_with_variant_argsc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #else - call_with_variant_argsc_dv((MB_T *)(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); + call_with_variant_argsc_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, r_error, get_default_arguments()); #endif return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_argsc<T, P...>(static_cast<T *>(p_object), method, p_args); #else - call_with_ptr_argsc<MB_T, P...>((MB_T *)(p_object), method, p_args); + call_with_ptr_argsc<MB_T, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args); #endif } @@ -455,7 +455,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -463,7 +463,7 @@ protected: } } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); @@ -478,7 +478,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata<P...>(p_arg); } else { @@ -487,21 +487,21 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_ret_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #else - call_with_variant_args_ret_dv((MB_T *)p_object, method, p_args, p_arg_count, ret, r_error, get_default_arguments()); + call_with_variant_args_ret_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #endif return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args_ret<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret); #else - call_with_ptr_args_ret<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret); + call_with_ptr_args_ret<MB_T, R, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret); #endif } @@ -542,7 +542,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -550,7 +550,7 @@ protected: } } - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); @@ -565,7 +565,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata<P...>(p_arg); } else { @@ -574,21 +574,21 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; #ifdef TYPED_METHOD_BIND call_with_variant_args_retc_dv(static_cast<T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #else - call_with_variant_args_retc_dv((MB_T *)(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); + call_with_variant_args_retc_dv(reinterpret_cast<MB_T *>(p_object), method, p_args, p_arg_count, ret, r_error, get_default_arguments()); #endif return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { #ifdef TYPED_METHOD_BIND call_with_ptr_args_retc<T, R, P...>(static_cast<T *>(p_object), method, p_args, r_ret); #else - call_with_ptr_args_retc<MB_T, R, P...>((MB_T *)(p_object), method, p_args, r_ret); + call_with_ptr_args_retc<MB_T, R, P...>(reinterpret_cast<MB_T *>(p_object), method, p_args, r_ret); #endif } @@ -626,7 +626,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -637,7 +637,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); return pi; @@ -645,18 +645,18 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { return call_get_argument_metadata<P...>(p_arg); } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { (void)p_object; // unused call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments()); return Variant(); } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { (void)p_object; (void)r_ret; call_with_ptr_args_static_method(function, p_args); @@ -689,7 +689,7 @@ protected: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wlogical-op" #endif - virtual Variant::Type _gen_argument_type(int p_arg) const { + virtual Variant::Type _gen_argument_type(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { return call_get_argument_type<P...>(p_arg); } else { @@ -700,7 +700,7 @@ protected: #pragma GCC diagnostic pop #endif - virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + virtual PropertyInfo _gen_argument_type_info(int p_arg) const override { if (p_arg >= 0 && p_arg < (int)sizeof...(P)) { PropertyInfo pi; call_get_argument_type_info<P...>(p_arg, pi); @@ -712,7 +712,7 @@ protected: public: #ifdef DEBUG_METHODS_ENABLED - virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const { + virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override { if (p_arg >= 0) { return call_get_argument_metadata<P...>(p_arg); } else { @@ -721,13 +721,13 @@ public: } #endif - virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { + virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) override { Variant ret; call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments()); return ret; } - virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) { + virtual void ptrcall(Object *p_object, const void **p_args, void *r_ret) override { (void)p_object; call_with_ptr_args_static_method_ret(function, p_args, r_ret); } diff --git a/core/os/keyboard.h b/core/os/keyboard.h index a21d81b2e7..3176a8a210 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -294,7 +294,7 @@ enum class Key { enum class KeyModifierMask { CODE_MASK = ((1 << 25) - 1), ///< Apply this mask to any keycode to remove modifiers. - MODIFIER_MASK = (0xFF << 24), ///< Apply this mask to isolate modifiers. + MODIFIER_MASK = (0x7F << 24), ///< Apply this mask to isolate modifiers. SHIFT = (1 << 25), ALT = (1 << 26), META = (1 << 27), diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 7cfd34b53e..f4a3512d3a 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4123,15 +4123,11 @@ String String::path_to(const String &p_path) const { dst += "/"; } - String base; - if (src.begins_with("res://") && dst.begins_with("res://")) { - base = "res:/"; src = src.replace("res://", "/"); dst = dst.replace("res://", "/"); } else if (src.begins_with("user://") && dst.begins_with("user://")) { - base = "user:/"; src = src.replace("user://", "/"); dst = dst.replace("user://", "/"); @@ -4146,7 +4142,6 @@ String String::path_to(const String &p_path) const { return p_path; //impossible to do this } - base = src_begin; src = src.substr(src_begin.length(), src.length()); dst = dst.substr(dst_begin.length(), dst.length()); } diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index b3e909b489..da5d73d519 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -184,7 +184,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { if (p_type_from == p_type_to) { return true; } - if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything + if (p_type_to == NIL) { //nil can convert to anything return true; } @@ -490,7 +490,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type if (p_type_from == p_type_to) { return true; } - if (p_type_to == NIL && p_type_from != NIL) { //nil can convert to anything + if (p_type_to == NIL) { //nil can convert to anything return true; } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index f1daf1de13..9dae0720d9 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1239,10 +1239,10 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const { void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) { ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; + const _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type]; #ifdef DEBUG_ENABLED - for (List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) { + for (const List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else for (const KeyValue<StringName, int> &E : cd.value) { @@ -1251,7 +1251,7 @@ void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_c } #ifdef DEBUG_ENABLED - for (List<StringName>::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { + for (const List<StringName>::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else for (const KeyValue<StringName, Variant> &E : cd.variant_value) { diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index e889a1bb40..5fc6df8f39 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -344,7 +344,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri if (string_name) { r_token.type = TK_STRING_NAME; r_token.value = StringName(str); - string_name = false; //reset } else { r_token.type = TK_STRING; r_token.value = str; |