diff options
Diffstat (limited to 'core')
163 files changed, 682 insertions, 1705 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index e2774deb3c..ed0e7b1018 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<String> _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<uint8_t> &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<JSONParseResult> _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 d5f44cdc44..44e573ccbe 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<String> 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<Size2> &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<JSONParseResult> parse(const String &p_json); - _JSON(); + _JSON() { singleton = this; } }; #endif // CORE_BIND_H diff --git a/core/callable.cpp b/core/callable.cpp index 6a5dc151e5..447cf78bea 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 7fa024dccd..5fa1ebf1d1 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 ee93ac73ae..dd9fba16d3 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -258,19 +258,6 @@ HashMap<StringName, ClassDB::ClassInfo> ClassDB::classes; HashMap<StringName, StringName> ClassDB::resource_base_extensions; HashMap<StringName, StringName> 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 f760aa1738..32d2148048 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<StringName, MethodBind *> method_map; HashMap<StringName, int> constant_map; HashMap<StringName, List<StringName>> 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 <class T> diff --git a/core/color.h b/core/color.h index 8b689fdde1..066a3f6696 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 3ce769c72c..60ab5d133b 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 2f2b3b783c..af8bbb24c6 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 <class T> T *allocate() { diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 0225524bc8..9e6ba6cde2 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 d599240dfe..fff4350caa 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<Translation> &p_from); - PHashTranslation(); + PHashTranslation() {} }; #endif // COMPRESSED_TRANSLATION_H diff --git a/core/cowdata.h b/core/cowdata.h index 975a572906..e9cfa2925a 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<T> &p_from) { _ref(p_from); }; }; @@ -367,12 +367,6 @@ void CowData<T>::_ref(const CowData &p_from) { } template <class T> -CowData<T>::CowData() { - - _ptr = nullptr; -} - -template <class T> CowData<T>::~CowData() { _unref(_ptr); diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index 233f62bd15..585731ac9f 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -94,9 +94,6 @@ Ref<X509Certificate> Crypto::generate_self_signed_certificate(Ref<CryptoKey> 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 d9becab958..cf21648a4a 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<CryptoKey> generate_rsa(int p_bytes); virtual Ref<X509Certificate> generate_self_signed_certificate(Ref<CryptoKey> 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 af43bc9bad..0b21dead74 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 230ba7ee85..f9454fa891 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 04229c0afc..9ba316d997 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<ScriptLanguage::StackInfo> 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 5361e09a8a..86ce0395b9 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 8512779d4c..aa28b35814 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; - - 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; - - uint64_t _idle_frames; - bool _in_physics; + uint64_t frames_drawn = 0; + uint32_t _frame_delay = 0; + uint64_t _frame_ticks = 0; + float _frame_step = 0; + + 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 = 0; + bool _in_physics = false; List<Singleton> singletons; Map<StringName, Object *> 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 83f92129a5..eb2cc5215d 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 338c17946b..ad29f4488d 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 8cb3be6e61..07b361db2d 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 f27a86cc02..4a3bee04c5 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(const HashMap &p_table) { - - hash_table = nullptr; - elements = 0; - hash_table_power = 0; + HashMap() {} + HashMap(const HashMap &p_table) { copy_from(p_table); } ~HashMap() { - clear(); } }; diff --git a/core/image.cpp b/core/image.cpp index ff8acc54af..277f6e9bf0 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -3671,14 +3671,3 @@ Ref<Resource> 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 07b4f49751..dbdfaa917b 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<uint8_t> 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<uint8_t> &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 91ff676211..38a71994d8 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 9accf14a4f..f3150a8127 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<InputEvent> &p_event); private: - int mouse_button_mask; + int mouse_button_mask = 0; Set<int> keys_pressed; Set<int> 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<StringName, Action> 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<int, SpeedTrack> touch_speed_track; Map<int, Joypad> 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<InputEvent> &p_event, bool p_is_emulated); List<Ref<InputEvent>> 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 4b8c104f39..9d3f8f9424 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 99ea2efee9..18792076f5 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<InputEvent> &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<InputEvent> &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<InputEvent> 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<InputEvent> 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<InputEvent> 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<InputEvent> 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 8354b581fa..3e7c125d8e 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 5bda06e5b9..7cbf5c618e 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<X509Certificate>())); 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 7b08138f7f..ae1d3bcd98 100644 --- a/core/io/dtls_server.h +++ b/core/io/dtls_server.h @@ -51,7 +51,7 @@ public: virtual void stop() = 0; virtual Ref<PacketPeerDTLS> take_connection(Ref<PacketPeerUDP> 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 ab0fb3943c..2df91a4dd8 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 a6177c20be..2832367a8b 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 6ec77d503b..edb4ff9a9f 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<T>::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 c76142d22d..f2827b519e 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 0bb311faa8..f192be0883 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<uint8_t> 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<ReadBlock> read_blocks; - uint32_t read_total; + uint32_t read_total = 0; - String magic; + String magic = "GCMP"; mutable Vector<uint8_t> 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 a5b3807789..271c34ec4a 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 7a9f4ecdd8..e269c1e30c 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<uint8_t> key; - bool writing; - FileAccess *file; + bool writing = false; + FileAccess *file = nullptr; size_t base; size_t length; Vector<uint8_t> 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<uint8_t> &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 a2379ce88f..a3e04a4538 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 2db14db265..d8be989b20 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 a3f307393f..00f504c391 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 7f664b46f7..6cdd6af0b4 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -50,13 +50,14 @@ class FileAccessNetworkClient { List<BlockRequest> block_requests; Semaphore sem; - Thread *thread; - bool quit; + Thread *thread = nullptr; + bool quit = false; Mutex mutex; Mutex blockrequest_mutex; Map<int, FileAccessNetwork *> accesses; Ref<StreamPeerTCP> client; - int last_id; + int last_id = 0; + int lockcount = 0; Vector<uint8_t> 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<uint8_t> buffer; - Page() { - activity = 0; - queued = false; - } }; mutable Vector<Page> pages; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index fd9b83eaf9..d70f2ba445 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 8df6826ac9..aa3a14272b 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<String, PackedDir *> subdirs; Set<String> 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<uint8_t> p_buf) { a = *((uint64_t *)&p_buf[0]); b = *((uint64_t *)&p_buf[8]); - }; + } }; Map<PathMD5, PackedFile> files; @@ -98,10 +96,9 @@ private: Vector<PackSource *> sources; PackedDir *root; - //Map<String,PackedDir*> 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<String> list_dirs; List<String> 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 57de66afaf..9d068fe809 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 d5ce7d7a8d..17a3d085b6 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<Package> packages; diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 56f8f1ff91..672569c5db 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 03ba20f8dd..05690534ae 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<uint8_t> response_str; - bool chunked; + bool chunked = false; Vector<uint8_t> 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<StreamPeerTCP> tcp_connection; Ref<StreamPeer> connection; - int response_num; + int response_num = 0; Vector<String> 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 02cc78538e..23165b575e 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<Logger *> p_loggers) : loggers(p_loggers) { } diff --git a/core/io/logger.h b/core/io/logger.h index 7028551185..54f1a42da9 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 81bc45b2f7..abf27954b8 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 650c95364a..1ba786d5d9 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 94e2fdb72c..998bcfd3f3 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 <stdint.h> #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 4eb4a53e99..2603fb1e27 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -56,14 +56,14 @@ private: }; Ref<NetworkedMultiplayerPeer> network_peer; - int rpc_sender_id; + int rpc_sender_id = 0; Set<int> connected_peers; HashMap<NodePath, PathSentCache> path_send_cache; Map<int, PathGetCache> path_get_cache; int last_send_cache_id; Vector<uint8_t> 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 b2f810d212..332beb4c8c 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 c1f1924051..8792886ff3 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 38abb5c0d6..6d3e1341a7 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 62144259cc..b69efa531f 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -47,9 +47,9 @@ class PacketPeer : public Reference { Vector<uint8_t> _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<uint8_t> 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 6da115eed2..ada3cb10a2 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 4f9f4535bc..c2ff4e1a7f 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 f800ffc3db..8b6bd7ef90 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>(NetSocket::create())) { rb.resize(16); } diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index b5a9fc9ec3..23fc5460a6 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<NetSocket> _sock; static void _bind_methods(); diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 5c4b3379ee..124ac30b88 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 6058de8345..2848ac3a65 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 e0fea143bb..8ce17bcfbe 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 3c8d916c0a..57aa086022 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> 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<char> str_buf; List<RES> 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<ExtResource> external_resources; struct IntResource { @@ -77,9 +77,9 @@ class ResourceLoaderBinary { void _advance_padding(uint32_t p_len); Map<String, String> 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<String> *p_dependencies, bool p_add_types); - ResourceLoaderBinary(); + ResourceLoaderBinary() {} ~ResourceLoaderBinary(); }; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d90802d7e2..dc44be4e0b 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 b28b17aa95..9bbe92096d 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -536,8 +536,3 @@ Ref<StreamPeerBuffer> 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 9358a2c07c..a390fdc325 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<uint8_t> data; - int pointer; + int pointer = 0; protected: static void _bind_methods(); @@ -123,7 +123,7 @@ public: Ref<StreamPeerBuffer> 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 d98935f77c..1d86c35578 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 de3cb09c60..81b95b856d 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 f0c5816d73..6218b98758 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>(NetSocket::create())), - timeout(0), - status(STATUS_NONE), - peer_port(0) { + _sock(Ref<NetSocket>(NetSocket::create())) { } StreamPeerTCP::~StreamPeerTCP() { diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 86df9ab8cf..571f6b7c54 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -52,10 +52,10 @@ public: protected: Ref<NetSocket> _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 bce5361c76..6f79e2554b 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 137dfd1768..a196a37dc0 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 9613ad3f10..a4b64bf17c 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("<lt;"); special_characters.push_back(">gt;"); diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 26c3e6802f..42b7d6e0d4 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<String> 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 65d45ffdfc..eb74fa7917 100644 --- a/core/list.h +++ b/core/list.h @@ -54,9 +54,9 @@ public: friend class List<T, A>; 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 6b9dff51de..621b6c2842 100644 --- a/core/map.h +++ b/core/map.h @@ -51,12 +51,12 @@ public: private: friend class Map<K, V, C, A>; - 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 3aba753f51..d6d6101402 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 8c10ace33c..ffb437ee04 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<int, Point *> neighbours; - OAHashMap<int, Point *> unlinked_neighbours; + OAHashMap<int, Point *> neighbours = 4u; + OAHashMap<int, Point *> 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<int, Point *> points; Set<Segment> segments; @@ -159,7 +155,7 @@ public: Vector<Vector3> get_point_path(int p_from_id, int p_to_id); Vector<int> get_id_path(int p_from_id, int p_to_id); - AStar(); + AStar() {} ~AStar(); }; @@ -206,8 +202,8 @@ public: Vector<Vector2> get_point_path(int p_from_id, int p_to_id); Vector<int> 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 c565ea9b13..0000000000 --- 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 b8252e9d16..66b2f8f573 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 57f3a78d35..ab0993abc9 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 a508151ad3..0000000000 --- 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 f7a124eae3..c43831ddee 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 78de225ebf..bf710ecdd5 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<Input> 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<String> 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 b0a46036f9..f923b62542 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 ffb405bd0f..7d89c50f69 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<Element *, AL> pairable_elements; List<Element *, AL> 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<OctantOwner, AL> 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 d4f23ff2b6..f91f816556 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 b3135ad1ca..1ca6fe7ce3 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 173f919a73..89061ab415 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -75,18 +75,12 @@ public: private: struct FaceConnect { - List<Face>::Element *left, *right; - FaceConnect() { - left = nullptr; - right = nullptr; - } + List<Face>::Element *left, *right = nullptr; + FaceConnect() {} }; struct RetFaceConnect { - List<Geometry::MeshData::Face>::Element *left, *right; - RetFaceConnect() { - left = nullptr; - right = nullptr; - } + List<Geometry::MeshData::Face>::Element *left, *right = nullptr; + RetFaceConnect() {} }; public: diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp index 1a1bffb562..67f4c0b14a 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 e7f188bb42..2b125433b3 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 30dbfdbbe5..a3f3634bfb 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 c0057f2543..5a3e6a0660 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 a5e9d09208..7131063e04 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 6f9754d3b9..60e5b94c12 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 652c424492..ad4211f3da 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 9ba748bb42..180e0ce362 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 c513de9ca0..854e19cf8a 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 b3d4f1bf9b..0092527a25 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -208,18 +208,18 @@ struct PtrToArg<wchar_t> { class MethodBind { int method_id; - uint32_t hint_flags; + uint32_t hint_flags = METHOD_FLAGS_DEFAULT; StringName name; Vector<Variant> 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<StringName> 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 25f1b38346..f8001a354a 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<StringName> NodePath::get_names() const { if (data) @@ -285,35 +275,8 @@ NodePath NodePath::get_as_property_path() const { } } -NodePath::NodePath(const Vector<StringName> &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<StringName> &p_path, const Vector<StringName> &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 String &p_path) { +NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) { + if (p_path.size() == 0) + return; - data = nullptr; + 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<StringName> &p_path, const Vector<StringName> &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) { 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 76de36cd9f..fb15d017bf 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<StringName> &p_path, const Vector<StringName> &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 71e3ba9068..f7c31f8aae 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 94d957f3af..9ae2d2dcde 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 3dec8a0480..20defae095 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<PropertyInfo> arguments; Vector<Variant> 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<Variant> 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<Connection>::Element *cE; - Slot() { reference_count = 0; } + List<Connection>::Element *cE = nullptr; }; MethodInfo user; VMap<Callable, Slot> slot_map; - SignalData() {} }; HashMap<StringName, SignalData> 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<Object *> 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<String> 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<PropertyInfo> *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<PropertyInfo> *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 05debd529f..1f1be71741 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -55,9 +55,9 @@ public: class Element { friend class OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>; - 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<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>; - 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 b26cd46fd8..53b959a580 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 6c876cde5a..cac0d0ec7c 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 <class T> @@ -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 7055780f34..cb8705f706 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 0f85c447b6..0ee29abbc9 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 <class T> static FileAccess *_create_builtin() { @@ -176,7 +176,7 @@ public: create_func[p_access] = _create_builtin<T>; } - 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 0d1a080682..b29e3f6142 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -60,12 +60,6 @@ void MainLoop::set_init_script(const Ref<Script> &p_init_script) { init_script = p_init_script; } -MainLoop::MainLoop() { -} - -MainLoop::~MainLoop() { -} - void MainLoop::init() { if (init_script.is_valid()) diff --git a/core/os/main_loop.h b/core/os/main_loop.h index 8f6c8c91b1..c7cc8f01e0 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -64,8 +64,8 @@ public: void set_init_script(const Ref<Script> &p_init_script); - MainLoop(); - virtual ~MainLoop(); + MainLoop() {} + virtual ~MainLoop() {} }; #endif // MAIN_LOOP_H diff --git a/core/os/memory.cpp b/core/os/memory.cpp index d921c10ad4..0e48592cc1 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -204,8 +204,6 @@ uint64_t Memory::get_mem_max_usage() { } _GlobalNil::_GlobalNil() { - - color = 1; left = this; right = this; parent = this; diff --git a/core/os/memory.h b/core/os/memory.h index d377d54fad..0588e47289 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -194,7 +194,7 @@ void memdelete_arr(T *p_class) { struct _GlobalNil { - int color; + int color = 1; _GlobalNil *right; _GlobalNil *left; _GlobalNil *parent; diff --git a/core/os/mutex.h b/core/os/mutex.h index 526549dd93..69a15f96de 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -83,7 +83,7 @@ extern template class MutexLock<MutexImpl<std::mutex>>; class FakeMutex { - FakeMutex(){}; + FakeMutex() {} }; template <class MutexT> diff --git a/core/os/os.cpp b/core/os/os.cpp index 425132fbec..cdc9f1e0ff 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -508,25 +508,10 @@ void OS::close_midi_inputs() { OS::OS() { void *volatile stack_bottom; - restart_on_exit = false; singleton = this; - _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0. - low_processor_usage_mode = false; - low_processor_usage_mode_sleep_usec = 10000; - _verbose_stdout = false; - _no_window = false; - _exit_code = 0; - _render_thread_mode = RENDER_THREAD_SAFE; - - _allow_hidpi = false; - _allow_layered = false; _stack_bottom = (void *)(&stack_bottom); - _logger = nullptr; - - has_server_feature_callback = nullptr; - Vector<Logger *> loggers; loggers.push_back(memnew(StdLogger)); _set_logger(memnew(CompositeLogger(loggers))); diff --git a/core/os/os.h b/core/os/os.h index 38114e6814..4340823cf4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -46,17 +46,17 @@ class OS { static OS *singleton; String _execpath; List<String> _cmdline; - bool _keep_screen_on; - bool low_processor_usage_mode; - int low_processor_usage_mode_sleep_usec; - bool _verbose_stdout; + bool _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0. + bool low_processor_usage_mode = false; + int low_processor_usage_mode_sleep_usec = 10000; + bool _verbose_stdout = false; String _local_clipboard; uint64_t _msec_splash; - bool _no_window; - int _exit_code; + bool _no_window = false; + int _exit_code = 0; int _orientation; - bool _allow_hidpi; - bool _allow_layered; + bool _allow_hidpi = false; + bool _allow_layered = false; bool _use_vsync; bool _vsync_via_compositor; bool _disable_wintab; @@ -65,9 +65,9 @@ class OS { void *_stack_bottom; - CompositeLogger *_logger; + CompositeLogger *_logger = nullptr; - bool restart_on_exit; + bool restart_on_exit = false; List<String> restart_commandline; protected: @@ -87,8 +87,8 @@ public: protected: friend class Main; - HasServerFeatureCallback has_server_feature_callback; - RenderThreadMode _render_thread_mode; + HasServerFeatureCallback has_server_feature_callback = nullptr; + RenderThreadMode _render_thread_mode = RENDER_THREAD_SAFE; // functions used by main to initialize/deinitialize the OS void add_logger(Logger *p_logger); diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp index 1dd2c3bccb..81df7f7ea6 100644 --- a/core/os/rw_lock.cpp +++ b/core/os/rw_lock.cpp @@ -42,6 +42,3 @@ RWLock *RWLock::create() { return create_func(); } - -RWLock::~RWLock() { -} diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h index 2ef4df9b70..8dca8a230a 100644 --- a/core/os/rw_lock.h +++ b/core/os/rw_lock.h @@ -48,7 +48,7 @@ public: static RWLock *create(); ///< Create a rwlock - virtual ~RWLock(); + virtual ~RWLock() {} }; class RWLockRead { diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp deleted file mode 100644 index 93f1e2dff4..0000000000 --- a/core/os/semaphore.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* semaphore.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 "semaphore.h" diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 294b52f00c..a8eb0b2a9f 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -66,9 +66,3 @@ Error Thread::set_name(const String &p_name) { return ERR_UNAVAILABLE; }; - -Thread::Thread() { -} - -Thread::~Thread() { -} diff --git a/core/os/thread.h b/core/os/thread.h index 76d296bcf7..005217dca7 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -63,7 +63,7 @@ protected: static ID _main_thread_id; - Thread(); + Thread() {} public: virtual ID get_id() const = 0; @@ -74,7 +74,7 @@ public: static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback - virtual ~Thread(); + virtual ~Thread() {} }; #endif // THREAD_H diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 04deba2c14..17b5905a93 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -381,11 +381,6 @@ void PackedDataContainer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "__data__"), "_set_data", "_get_data"); } -PackedDataContainer::PackedDataContainer() { - - datalen = 0; -} - ////////////////// Variant PackedDataContainerRef::_iter_init(const Array &p_iter) { @@ -429,6 +424,3 @@ int PackedDataContainerRef::size() const { return from->_size(offset); }; - -PackedDataContainerRef::PackedDataContainerRef() { -} diff --git a/core/packed_data_container.h b/core/packed_data_container.h index 0f08a1cb7b..00ec4248ee 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -49,7 +49,7 @@ class PackedDataContainer : public Resource { }; Vector<uint8_t> data; - int datalen; + int datalen = 0; uint32_t _pack(const Variant &p_data, Vector<uint8_t> &tmpdata, Map<String, uint32_t> &string_cache); @@ -78,7 +78,7 @@ public: int size() const; - PackedDataContainer(); + PackedDataContainer() {} }; class PackedDataContainerRef : public Reference { @@ -100,7 +100,7 @@ public: int size() const; virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; - PackedDataContainerRef(); + PackedDataContainerRef() {} }; #endif // PACKED_DATA_CONTAINER_H diff --git a/core/path_remap.cpp b/core/path_remap.cpp deleted file mode 100644 index e1708e0350..0000000000 --- a/core/path_remap.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* path_remap.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 "path_remap.h" diff --git a/core/path_remap.h b/core/path_remap.h deleted file mode 100644 index 1580e88625..0000000000 --- a/core/path_remap.h +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************/ -/* path_remap.h */ -/*************************************************************************/ -/* 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. */ -/*************************************************************************/ - -#ifndef PATH_REMAP_H -#define PATH_REMAP_H - -#endif // PATH_REMAP_H diff --git a/core/pool_allocator.h b/core/pool_allocator.h index 8c1710ebe0..1cc21afb21 100644 --- a/core/pool_allocator.h +++ b/core/pool_allocator.h @@ -61,10 +61,10 @@ private: struct Entry { - unsigned int pos; - unsigned int len; - unsigned int lock; - unsigned int check; + unsigned int pos = 0; + unsigned int len = 0; + unsigned int lock = 0; + unsigned int check = 0; inline void clear() { pos = 0; @@ -72,7 +72,7 @@ private: lock = 0; check = 0; } - Entry() { clear(); } + Entry() {} }; typedef int EntryArrayPos; diff --git a/core/print_string.h b/core/print_string.h index d83cc35dd6..3e9125bddc 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -39,16 +39,12 @@ typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error); struct PrintHandlerList { - PrintHandlerFunc printfunc; - void *userdata; + PrintHandlerFunc printfunc = nullptr; + void *userdata = nullptr; - PrintHandlerList *next; + PrintHandlerList *next = nullptr; - PrintHandlerList() { - printfunc = 0; - next = 0; - userdata = 0; - } + PrintHandlerList() {} }; void add_print_handler(PrintHandlerList *p_handler); diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 12522281d0..e141e54e61 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -989,10 +989,6 @@ void ProjectSettings::_bind_methods() { ProjectSettings::ProjectSettings() { singleton = this; - last_order = NO_BUILTIN_ORDER_BASE; - last_builtin_order = 0; - disable_feature_overrides = false; - registering_order = true; Array events; Dictionary action; @@ -1203,8 +1199,6 @@ ProjectSettings::ProjectSettings() { Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION); custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); - - using_datapack = false; } ProjectSettings::~ProjectSettings() { diff --git a/core/project_settings.h b/core/project_settings.h index 7b3ca18c62..87f2a8273f 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -50,38 +50,31 @@ public: protected: struct VariantContainer { - int order; - bool persist; + int order = 0; + bool persist = false; Variant variant; Variant initial; - bool hide_from_editor; - bool overridden; - bool restart_if_changed; - VariantContainer() : - order(0), - persist(false), - hide_from_editor(false), - overridden(false), - restart_if_changed(false) { - } + bool hide_from_editor = false; + bool overridden = false; + bool restart_if_changed = false; + + VariantContainer() {} + VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) : order(p_order), persist(p_persist), - variant(p_variant), - hide_from_editor(false), - overridden(false), - restart_if_changed(false) { + variant(p_variant) { } }; - bool registering_order; - int last_order; - int last_builtin_order; + bool registering_order = true; + int last_order = 0; + int last_builtin_order = NO_BUILTIN_ORDER_BASE; Map<StringName, VariantContainer> props; String resource_path; Map<StringName, PropertyInfo> custom_prop_info; - bool disable_feature_overrides; - bool using_datapack; + bool disable_feature_overrides = false; + bool using_datapack = false; List<String> input_presets; Set<String> custom_features; diff --git a/core/reference.cpp b/core/reference.cpp index dd65ccce69..57b72dcaad 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -109,9 +109,6 @@ Reference::Reference() : refcount_init.init(); } -Reference::~Reference() { -} - Variant WeakRef::get_ref() const { if (ref.is_null()) @@ -138,9 +135,6 @@ void WeakRef::set_ref(const REF &p_ref) { ref = p_ref.is_valid() ? p_ref->get_instance_id() : ObjectID(); } -WeakRef::WeakRef() { -} - void WeakRef::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref); diff --git a/core/reference.h b/core/reference.h index 30a93d82a6..5190f6ab11 100644 --- a/core/reference.h +++ b/core/reference.h @@ -52,13 +52,13 @@ public: int reference_get_count() const; Reference(); - ~Reference(); + ~Reference() {} }; template <class T> class Ref { - T *reference; + T *reference = nullptr; void ref(const Ref &p_from) { @@ -189,15 +189,11 @@ public: } Ref(const Ref &p_from) { - - reference = nullptr; ref(p_from); } template <class T_Other> Ref(const Ref<T_Other> &p_from) { - - reference = nullptr; Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr())); if (!refb) { unref(); @@ -210,26 +206,20 @@ public: } Ref(T *p_reference) { - - reference = nullptr; if (p_reference) ref_pointer(p_reference); } Ref(const Variant &p_variant) { - Object *object = p_variant.get_validated_object(); if (!object) { - reference = nullptr; return; } T *r = Object::cast_to<T>(object); if (r && r->reference()) { reference = r; - } else { - reference = nullptr; } } @@ -252,13 +242,9 @@ public: ref(memnew(T)); } - Ref() { - - reference = nullptr; - } + Ref() {} ~Ref() { - unref(); } }; @@ -279,7 +265,7 @@ public: void set_obj(Object *p_object); void set_ref(const REF &p_ref); - WeakRef(); + WeakRef() {} }; #ifdef PTRCALL_ENABLED diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 4cf7e45205..f24397be5b 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -65,7 +65,6 @@ #include "core/math/triangle_mesh.h" #include "core/os/main_loop.h" #include "core/packed_data_container.h" -#include "core/path_remap.h" #include "core/project_settings.h" #include "core/translation.h" #include "core/undo_redo.h" diff --git a/core/resource.cpp b/core/resource.cpp index 8d5c441b21..f8948e9a59 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -429,17 +429,7 @@ void Resource::_bind_methods() { } Resource::Resource() : - remapped_list(this) { - -#ifdef TOOLS_ENABLED - last_modified_time = 0; - import_last_modified_time = 0; -#endif - - subindex = 0; - local_to_scene = false; - local_scene = nullptr; -} + remapped_list(this) {} Resource::~Resource() { diff --git a/core/resource.h b/core/resource.h index 3b7812c870..7d92b843dc 100644 --- a/core/resource.h +++ b/core/resource.h @@ -57,19 +57,19 @@ class Resource : public Reference { String name; String path_cache; - int subindex; + int subindex = 0; virtual bool _use_builtin_script() const { return true; } #ifdef TOOLS_ENABLED - uint64_t last_modified_time; - uint64_t import_last_modified_time; + uint64_t last_modified_time = 0; + uint64_t import_last_modified_time = 0; String import_path; #endif - bool local_to_scene; + bool local_to_scene = false; friend class SceneState; - Node *local_scene; + Node *local_scene = nullptr; SelfList<Resource> remapped_list; diff --git a/core/rid.h b/core/rid.h index a2f73423a3..ac07eacd08 100644 --- a/core/rid.h +++ b/core/rid.h @@ -37,7 +37,7 @@ class RID_AllocBase; class RID { friend class RID_AllocBase; - uint64_t _id; + uint64_t _id = 0; public: _FORCE_INLINE_ bool operator==(const RID &p_rid) const { @@ -65,9 +65,7 @@ public: _FORCE_INLINE_ uint64_t get_id() const { return _id; } - _FORCE_INLINE_ RID() { - _id = 0; - } + _FORCE_INLINE_ RID() {} }; #endif // RID_H diff --git a/core/rid_owner.h b/core/rid_owner.h index ad6996b9a7..77bbc3c83c 100644 --- a/core/rid_owner.h +++ b/core/rid_owner.h @@ -39,6 +39,7 @@ #include "core/safe_refcount.h" #include "core/set.h" #include "core/spin_lock.h" + #include <stdio.h> #include <typeinfo> @@ -68,15 +69,15 @@ public: template <class T, bool THREAD_SAFE = false> class RID_Alloc : public RID_AllocBase { - T **chunks; - uint32_t **free_list_chunks; - uint32_t **validator_chunks; + T **chunks = nullptr; + uint32_t **free_list_chunks = nullptr; + uint32_t **validator_chunks = nullptr; uint32_t elements_in_chunk; - uint32_t max_alloc; - uint32_t alloc_count; + uint32_t max_alloc = 0; + uint32_t alloc_count = 0; - const char *description; + const char *description = nullptr; SpinLock spin_lock; @@ -288,14 +289,7 @@ public: } RID_Alloc(uint32_t p_target_chunk_byte_size = 4096) { - chunks = nullptr; - free_list_chunks = nullptr; - validator_chunks = nullptr; - elements_in_chunk = sizeof(T) > p_target_chunk_byte_size ? 1 : (p_target_chunk_byte_size / sizeof(T)); - max_alloc = 0; - alloc_count = 0; - description = nullptr; } ~RID_Alloc() { @@ -412,4 +406,5 @@ public: RID_Owner(uint32_t p_target_chunk_byte_size = 4096) : alloc(p_target_chunk_byte_size) {} }; + #endif // RID_OWNER_H diff --git a/core/ring_buffer.h b/core/ring_buffer.h index 620a3a3846..8ef9b1a15c 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -37,8 +37,8 @@ template <typename T> class RingBuffer { Vector<T> data; - int read_pos; - int write_pos; + int read_pos = 0; + int write_pos = 0; int size_mask; inline int inc(int &p_var, int p_size) const { @@ -214,11 +214,9 @@ public: }; RingBuffer<T>(int p_power = 0) { - read_pos = 0; - write_pos = 0; resize(p_power); }; - ~RingBuffer<T>(){}; + ~RingBuffer<T>() {} }; #endif // RING_BUFFER_H diff --git a/core/script_language.cpp b/core/script_language.cpp index 82cac6bc9a..603b4dc13d 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -34,6 +34,7 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" #include "core/project_settings.h" + #include <stdint.h> ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES]; diff --git a/core/script_language.h b/core/script_language.h index 5cc240efcb..544de26d81 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -253,14 +253,12 @@ struct ScriptCodeCompletionOption { KIND_FILE_PATH, KIND_PLAIN_TEXT, }; - Kind kind; + Kind kind = KIND_PLAIN_TEXT; String display; String insert_text; RES icon; - ScriptCodeCompletionOption() { - kind = KIND_PLAIN_TEXT; - } + ScriptCodeCompletionOption() {} ScriptCodeCompletionOption(const String &p_text, Kind p_kind) { display = p_text; diff --git a/core/self_list.h b/core/self_list.h index 2c44b0caec..74c585e60e 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -39,8 +39,8 @@ class SelfList { public: class List { - SelfList<T> *_first; - SelfList<T> *_last; + SelfList<T> *_first = nullptr; + SelfList<T> *_last = nullptr; public: void add(SelfList<T> *p_elem) { @@ -105,18 +105,16 @@ public: _FORCE_INLINE_ SelfList<T> *first() { return _first; } _FORCE_INLINE_ const SelfList<T> *first() const { return _first; } - _FORCE_INLINE_ List() { - _first = nullptr; - _last = nullptr; - } + + _FORCE_INLINE_ List() {} _FORCE_INLINE_ ~List() { ERR_FAIL_COND(_first != nullptr); } }; private: - List *_root; + List *_root = nullptr; T *_self; - SelfList<T> *_next; - SelfList<T> *_prev; + SelfList<T> *_next = nullptr; + SelfList<T> *_prev = nullptr; public: _FORCE_INLINE_ bool in_list() const { return _root; } @@ -131,15 +129,10 @@ public: _FORCE_INLINE_ T *self() const { return _self; } _FORCE_INLINE_ SelfList(T *p_self) { - _self = p_self; - _next = nullptr; - _prev = nullptr; - _root = nullptr; } _FORCE_INLINE_ ~SelfList() { - if (_root) _root->remove(this); } diff --git a/core/set.h b/core/set.h index c17ee15350..851a33b43a 100644 --- a/core/set.h +++ b/core/set.h @@ -51,12 +51,12 @@ public: private: friend class Set<T, C, A>; - 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; T value; //_Data *data; @@ -80,22 +80,15 @@ public: const T &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 @@ -105,8 +98,6 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif - _root = nullptr; - size_cache = 0; } void _create_root() { @@ -625,11 +616,9 @@ public: _copy_from(p_set); } - _FORCE_INLINE_ Set() { - } + _FORCE_INLINE_ Set() {} ~Set() { - clear(); } }; diff --git a/core/spin_lock.h b/core/spin_lock.h index c48631f94a..1bb810bb29 100644 --- a/core/spin_lock.h +++ b/core/spin_lock.h @@ -32,6 +32,7 @@ #define SPIN_LOCK_H #include "core/typedefs.h" + #include <atomic> class SpinLock { diff --git a/core/string_buffer.h b/core/string_buffer.h index a140f0abf7..cfe7cdabfe 100644 --- a/core/string_buffer.h +++ b/core/string_buffer.h @@ -38,7 +38,7 @@ class StringBuffer { CharType short_buffer[SHORT_BUFFER_SIZE]; String buffer; - int string_length; + int string_length = 0; _FORCE_INLINE_ CharType *current_buffer_ptr() { return static_cast<String &>(buffer).empty() ? short_buffer : buffer.ptrw(); @@ -78,10 +78,6 @@ public: _FORCE_INLINE_ operator String() { return as_string(); } - - StringBuffer() { - string_length = 0; - } }; template <int SHORT_BUFFER_SIZE> diff --git a/core/string_builder.h b/core/string_builder.h index dd8a154890..8fcd6669bd 100644 --- a/core/string_builder.h +++ b/core/string_builder.h @@ -32,12 +32,11 @@ #define STRING_BUILDER_H #include "core/ustring.h" - #include "core/vector.h" class StringBuilder { - uint32_t string_length; + uint32_t string_length = 0; Vector<String> strings; Vector<const char *> c_strings; @@ -80,9 +79,7 @@ public: return as_string(); } - StringBuilder() { - string_length = 0; - } + StringBuilder() {} }; #endif // STRING_BUILDER_H diff --git a/core/string_name.cpp b/core/string_name.cpp index 9cbac97a7c..bfc10d96e4 100644 --- a/core/string_name.cpp +++ b/core/string_name.cpp @@ -388,12 +388,6 @@ StringName StringName::search(const String &p_name) { return StringName(); //does not exist } -StringName::StringName() { - - _data = nullptr; -} - StringName::~StringName() { - unref(); } diff --git a/core/string_name.h b/core/string_name.h index aec87b8e66..5f69f3a235 100644 --- a/core/string_name.h +++ b/core/string_name.h @@ -52,25 +52,20 @@ class StringName { struct _Data { SafeRefCount refcount; - const char *cname; + const char *cname = nullptr; String name; String get_name() const { return cname ? String(cname) : name; } - int idx; - uint32_t hash; - _Data *prev; - _Data *next; - _Data() { - cname = nullptr; - next = prev = nullptr; - idx = 0; - hash = 0; - } + int idx = 0; + uint32_t hash = 0; + _Data *prev = nullptr; + _Data *next = nullptr; + _Data() {} }; static _Data *_table[STRING_TABLE_LEN]; - _Data *_data; + _Data *_data = nullptr; union _HashUnion { @@ -160,7 +155,7 @@ public: StringName(const StringName &p_name); StringName(const String &p_name); StringName(const StaticCString &p_static_string); - StringName(); + StringName() {} ~StringName(); }; diff --git a/core/thread_work_pool.cpp b/core/thread_work_pool.cpp index c8311f102f..28e933ac4d 100644 --- a/core/thread_work_pool.cpp +++ b/core/thread_work_pool.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "thread_work_pool.h" + #include "core/os/os.h" void ThreadWorkPool::_thread_function(ThreadData *p_thread) { diff --git a/core/thread_work_pool.h b/core/thread_work_pool.h index 214d2c4aa7..8005bf80b8 100644 --- a/core/thread_work_pool.h +++ b/core/thread_work_pool.h @@ -33,8 +33,10 @@ #include "core/os/memory.h" #include "core/os/semaphore.h" + #include <atomic> #include <thread> + class ThreadWorkPool { std::atomic<uint32_t> index; diff --git a/core/translation.cpp b/core/translation.cpp index 5f31bc7399..191349e953 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -902,10 +902,6 @@ void Translation::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale"); } -Translation::Translation() : - locale("en") { -} - /////////////////////////////////////////////// bool TranslationServer::is_locale_valid(const String &p_locale) { @@ -1247,13 +1243,10 @@ void TranslationServer::load_translations() { } } -TranslationServer::TranslationServer() : - locale("en"), - enabled(true) { +TranslationServer::TranslationServer() { singleton = this; for (int i = 0; locale_list[i]; ++i) { - locale_name_map.insert(locale_list[i], String::utf8(locale_names[i])); } } diff --git a/core/translation.h b/core/translation.h index 29a068f450..423b3166b1 100644 --- a/core/translation.h +++ b/core/translation.h @@ -39,7 +39,7 @@ class Translation : public Resource { OBJ_SAVE_TYPE(Translation); RES_BASE_EXTENSION("translation"); - String locale; + String locale = "en"; Map<StringName, StringName> translation_map; Vector<String> _get_message_list() const; @@ -61,14 +61,14 @@ public: void get_message_list(List<StringName> *r_messages) const; int get_message_count() const; - Translation(); + Translation() {} }; class TranslationServer : public Object { GDCLASS(TranslationServer, Object); - String locale; + String locale = "en"; String fallback; Set<Ref<Translation>> translations; @@ -77,7 +77,7 @@ class TranslationServer : public Object { Map<String, String> locale_name_map; - bool enabled; + bool enabled = true; static TranslationServer *singleton; bool _load_translations(const String &p_from); diff --git a/core/typed_array.cpp b/core/typed_array.cpp deleted file mode 100644 index a655a1b563..0000000000 --- a/core/typed_array.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************/ -/* typed_array.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 "typed_array.h" diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 62ad3e9f98..9324dfb573 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -409,23 +409,6 @@ void UndoRedo::set_property_notify_callback(PropertyNotifyCallback p_property_ca prop_callback_ud = p_ud; } -UndoRedo::UndoRedo() { - - committing = 0; - version = 1; - action_level = 0; - current_action = -1; - merge_mode = MERGE_DISABLE; - merging = false; - callback = nullptr; - callback_ud = nullptr; - - method_callbck_ud = nullptr; - prop_callback_ud = nullptr; - method_callback = nullptr; - property_callback = nullptr; -} - UndoRedo::~UndoRedo() { clear_history(); diff --git a/core/undo_redo.h b/core/undo_redo.h index 3b91e9ce36..5b74ffcbb8 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -77,25 +77,25 @@ private: }; Vector<Action> actions; - int current_action; - int action_level; - MergeMode merge_mode; - bool merging; - uint64_t version; + int current_action = -1; + int action_level = 0; + MergeMode merge_mode = MERGE_DISABLE; + bool merging = false; + uint64_t version = 1; void _pop_history_tail(); void _process_operation_list(List<Operation>::Element *E); void _discard_redo(); - CommitNotifyCallback callback; - void *callback_ud; - void *method_callbck_ud; - void *prop_callback_ud; + CommitNotifyCallback callback = nullptr; + void *callback_ud = nullptr; + void *method_callbck_ud = nullptr; + void *prop_callback_ud = nullptr; - MethodNotifyCallback method_callback; - PropertyNotifyCallback property_callback; + MethodNotifyCallback method_callback = nullptr; + PropertyNotifyCallback property_callback = nullptr; - int committing; + int committing = 0; protected: static void _bind_methods(); @@ -128,7 +128,7 @@ public: void set_method_notify_callback(MethodNotifyCallback p_method_callback, void *p_ud); void set_property_notify_callback(PropertyNotifyCallback p_property_callback, void *p_ud); - UndoRedo(); + UndoRedo() {} ~UndoRedo(); }; diff --git a/core/ustring.cpp b/core/ustring.cpp index 3e8a1ddbe3..992424f057 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -28,10 +28,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS // to disable build-time warning which suggested to use strcpy_s instead strcpy -#endif - #include "ustring.h" #include "core/color.h" @@ -51,6 +47,10 @@ #include <stdlib.h> #endif +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS // to disable build-time warning which suggested to use strcpy_s instead strcpy +#endif + #if defined(MINGW_ENABLED) || defined(_MSC_VER) #define snprintf _snprintf_s #endif diff --git a/core/variant.cpp b/core/variant.cpp index 2eacb5d58c..162d409026 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -3189,16 +3189,9 @@ Variant::Variant(const IP_Address &p_address) { Variant::Variant(const Variant &p_variant) { - type = NIL; reference(p_variant); } -/* -Variant::~Variant() { - - clear(); -}*/ - uint32_t Variant::hash() const { switch (type) { diff --git a/core/variant.h b/core/variant.h index 8e924be00a..0498e93825 100644 --- a/core/variant.h +++ b/core/variant.h @@ -123,7 +123,7 @@ private: // Variant takes 20 bytes when real_t is float, and 36 if double // it only allocates extra memory for aabb/matrix. - Type type; + Type type = NIL; struct ObjData { @@ -469,10 +469,9 @@ public: static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = nullptr, void *p_construct_ud = nullptr); void operator=(const Variant &p_variant); // only this is enough for all the other types + Variant(const Variant &p_variant); - _FORCE_INLINE_ Variant() { - type = NIL; - } + _FORCE_INLINE_ Variant() {} _FORCE_INLINE_ ~Variant() { if (type != Variant::NIL) clear(); diff --git a/core/variant_parser.h b/core/variant_parser.h index 63ed51bcc9..af7d55d1b8 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -43,34 +43,33 @@ public: virtual bool is_utf8() const = 0; virtual bool is_eof() const = 0; - CharType saved; + CharType saved = 0; - Stream() : - saved(0) {} + Stream() {} virtual ~Stream() {} }; struct StreamFile : public Stream { - FileAccess *f; + FileAccess *f = nullptr; virtual CharType get_char(); virtual bool is_utf8() const; virtual bool is_eof() const; - StreamFile() { f = nullptr; } + StreamFile() {} }; struct StreamString : public Stream { String s; - int pos; + int pos = 0; virtual CharType get_char(); virtual bool is_utf8() const; virtual bool is_eof() const; - StreamString() { pos = 0; } + StreamString() {} }; typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str); diff --git a/core/vector.h b/core/vector.h index 74e0ab91c0..7ab464fe11 100644 --- a/core/vector.h +++ b/core/vector.h @@ -119,8 +119,6 @@ public: insert(i, p_val); } - _FORCE_INLINE_ Vector() {} - _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } inline Vector &operator=(const Vector &p_from) { _cowdata._ref(p_from._cowdata); return *this; @@ -157,6 +155,9 @@ public: return slice; } + _FORCE_INLINE_ Vector() {} + _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } + _FORCE_INLINE_ ~Vector() {} }; diff --git a/core/vmap.h b/core/vmap.h index 84ae1aaf66..848b5055fa 100644 --- a/core/vmap.h +++ b/core/vmap.h @@ -202,11 +202,13 @@ public: return _cowdata.get_m(pos).value; } - _FORCE_INLINE_ VMap(){}; + _FORCE_INLINE_ VMap() {} _FORCE_INLINE_ VMap(const VMap &p_from) { _cowdata._ref(p_from._cowdata); } + inline VMap &operator=(const VMap &p_from) { _cowdata._ref(p_from._cowdata); return *this; } }; + #endif // VMAP_H |