diff --git a/core/config/engine.h b/core/config/engine.h index 1adab9b96f3..eac96852b30 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -40,7 +40,7 @@ class Engine { public: struct Singleton { StringName name; - Object *ptr; + Object *ptr = nullptr; StringName class_name; //used for binding generation hinting bool user_created = false; Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr, const StringName &p_class_name = StringName()); diff --git a/core/core_bind.h b/core/core_bind.h index 907f37c5faa..4d26698f990 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -447,7 +447,7 @@ public: class Directory : public RefCounted { GDCLASS(Directory, RefCounted); - DirAccess *d; + DirAccess *d = nullptr; bool dir_open = false; bool include_navigational = false; diff --git a/core/io/file_access.h b/core/io/file_access.h index a6cb5d9fc66..a5150010da0 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -183,7 +183,7 @@ struct FileAccessRef { operator bool() const { return f != nullptr; } - FileAccess *f; + FileAccess *f = nullptr; operator FileAccess *() { return f; } diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 6eee2f593d9..fe4b12aef6b 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -64,7 +64,7 @@ public: uint64_t offset; //if offset is ZERO, the file was ERASED uint64_t size; uint8_t md5[16]; - PackSource *src; + PackSource *src = nullptr; bool encrypted; }; @@ -103,7 +103,7 @@ private: Vector sources; - PackedDir *root; + PackedDir *root = nullptr; static PackedData *singleton; bool disabled = false; @@ -150,7 +150,7 @@ class FileAccessPack : public FileAccess { mutable bool eof; uint64_t off; - FileAccess *f; + FileAccess *f = nullptr; virtual Error _open(const String &p_path, int p_mode_flags); virtual uint64_t _get_modified_time(const String &p_file) { return 0; } virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; } diff --git a/core/io/ip.h b/core/io/ip.h index ebd944a9497..06ff8a4d70f 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -62,7 +62,7 @@ public: typedef int ResolverID; private: - _IP_ResolverPrivate *resolver; + _IP_ResolverPrivate *resolver = nullptr; protected: static IP *singleton; diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index c80c9b0ac94..5403168a534 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -127,7 +127,7 @@ class ResourceFormatSaverBinaryInstance { bool skip_editor; bool big_endian; bool takeover_paths; - FileAccess *f; + FileAccess *f = nullptr; String magic; Set resource_set; diff --git a/core/io/resource_uid.h b/core/io/resource_uid.h index 1ea44b9d06e..0b7ffdf6d0c 100644 --- a/core/io/resource_uid.h +++ b/core/io/resource_uid.h @@ -46,7 +46,7 @@ public: static String get_cache_file(); private: - void *crypto; // CryptoCore::RandomGenerator (avoid including crypto_core.h) + void *crypto = nullptr; // CryptoCore::RandomGenerator (avoid including crypto_core.h) Mutex mutex; struct Cache { CharString cs; diff --git a/core/io/udp_server.h b/core/io/udp_server.h index 4a7546fddf2..47f06b24902 100644 --- a/core/io/udp_server.h +++ b/core/io/udp_server.h @@ -43,7 +43,7 @@ protected: }; struct Peer { - PacketPeerUDP *peer; + PacketPeerUDP *peer = nullptr; IPAddress ip; uint16_t port = 0; diff --git a/core/math/bvh.h b/core/math/bvh.h index f429ce189b4..9f6ab9f7361 100644 --- a/core/math/bvh.h +++ b/core/math/bvh.h @@ -763,19 +763,19 @@ private: tree._extra[p_handle.id()].last_updated_tick = 0; } - PairCallback pair_callback; - UnpairCallback unpair_callback; - CheckPairCallback check_pair_callback; - void *pair_callback_userdata; - void *unpair_callback_userdata; - void *check_pair_callback_userdata; + PairCallback pair_callback = nullptr; + UnpairCallback unpair_callback = nullptr; + CheckPairCallback check_pair_callback = nullptr; + void *pair_callback_userdata = nullptr; + void *unpair_callback_userdata = nullptr; + void *check_pair_callback_userdata = nullptr; BVHTREE_CLASS tree; // for collision pairing, // maintain a list of all items moved etc on each frame / tick LocalVector changed_items; - uint32_t _tick; + uint32_t _tick = 1; // Start from 1 so items with 0 indicate never updated. class BVHLockedFunction { public: @@ -801,23 +801,16 @@ private: } private: - Mutex *_mutex; + Mutex *_mutex = nullptr; }; Mutex _mutex; // local toggle for turning on and off thread safety in project settings - bool _thread_safe; + bool _thread_safe = BVH_THREAD_SAFE; public: - BVH_Manager() { - _tick = 1; // start from 1 so items with 0 indicate never updated - pair_callback = nullptr; - unpair_callback = nullptr; - pair_callback_userdata = nullptr; - unpair_callback_userdata = nullptr; - _thread_safe = BVH_THREAD_SAFE; - } + BVH_Manager() {} }; #undef BVHTREE_CLASS diff --git a/core/math/dynamic_bvh.h b/core/math/dynamic_bvh.h index 50ec2c2b304..74831089f3b 100644 --- a/core/math/dynamic_bvh.h +++ b/core/math/dynamic_bvh.h @@ -183,7 +183,7 @@ private: Node *parent = nullptr; union { Node *childs[2]; - void *data; + void *data = nullptr; }; _FORCE_INLINE_ bool is_leaf() const { return childs[1] == nullptr; } @@ -215,10 +215,7 @@ private: return axis.dot(volume.get_center() - org) <= 0; } - Node() { - childs[0] = nullptr; - childs[1] = nullptr; - } + Node() {} }; PagedAllocator node_allocator; diff --git a/core/math/expression.h b/core/math/expression.h index 9b87bdd6ec8..d43cc4091a5 100644 --- a/core/math/expression.h +++ b/core/math/expression.h @@ -147,7 +147,7 @@ private: bool is_op = false; union { Variant::Operator op; - ENode *node; + ENode *node = nullptr; }; }; diff --git a/core/math/octree.h b/core/math/octree.h index e73f8213b34..65ab9e2292e 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -134,7 +134,7 @@ private: List pair_list; struct OctantOwner { - Octant *octant; + Octant *octant = nullptr; typename List::Element *E; }; // an element can be in max 8 octants @@ -147,7 +147,7 @@ private: int refcount; bool intersect; Element *A, *B; - void *ud; + void *ud = nullptr; typename List::Element *eA, *eB; }; @@ -156,18 +156,18 @@ private: ElementMap element_map; PairMap pair_map; - PairCallback pair_callback; - UnpairCallback unpair_callback; - void *pair_callback_userdata; - void *unpair_callback_userdata; + PairCallback pair_callback = nullptr; + UnpairCallback unpair_callback = nullptr; + void *pair_callback_userdata = nullptr; + void *unpair_callback_userdata = nullptr; - OctreeElementID last_element_id; - uint64_t pass; + OctreeElementID last_element_id = 1; + uint64_t pass = 1; - real_t unit_size; - Octant *root; - int octant_count; - int pair_count; + real_t unit_size = 1.0; + Octant *root = nullptr; + int octant_count = 0; + int pair_count = 0; _FORCE_INLINE_ void _pair_check(PairData *p_pair) { bool intersect = p_pair->A->aabb.intersects_inclusive(p_pair->B->aabb); @@ -294,7 +294,7 @@ private: const Vector3 *points; int point_count; T **result_array; - int *result_idx; + int *result_idx = nullptr; int result_max; uint32_t mask; }; @@ -1265,18 +1265,7 @@ void Octree::set_unpair_callback(UnpairCallback p_callback, vo template Octree::Octree(real_t p_unit_size) { - last_element_id = 1; - pass = 1; unit_size = p_unit_size; - root = nullptr; - - octant_count = 0; - pair_count = 0; - - pair_callback = nullptr; - unpair_callback = nullptr; - pair_callback_userdata = nullptr; - unpair_callback_userdata = nullptr; } #endif // OCTREE_H diff --git a/core/object/callable_method_pointer.h b/core/object/callable_method_pointer.h index 3cd9ad38191..577d4b9fbdd 100644 --- a/core/object/callable_method_pointer.h +++ b/core/object/callable_method_pointer.h @@ -38,7 +38,7 @@ #include "core/variant/callable.h" class CallableCustomMethodPointerBase : public CallableCustom { - uint32_t *comp_ptr; + uint32_t *comp_ptr = nullptr; uint32_t comp_size; uint32_t h; #ifdef DEBUG_METHODS_ENABLED diff --git a/core/object/class_db.h b/core/object/class_db.h index b8a4b3ea2ba..5da85237430 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -85,8 +85,8 @@ public: int index; StringName setter; StringName getter; - MethodBind *_setptr; - MethodBind *_getptr; + MethodBind *_setptr = nullptr; + MethodBind *_getptr = nullptr; Variant::Type type; }; diff --git a/core/object/message_queue.h b/core/object/message_queue.h index eaab01d0aa3..2219cdb8f68 100644 --- a/core/object/message_queue.h +++ b/core/object/message_queue.h @@ -62,10 +62,10 @@ class MessageQueue { }; }; - uint8_t *buffer; + uint8_t *buffer = nullptr; uint32_t buffer_end = 0; uint32_t buffer_max_used = 0; - uint32_t buffer_size; + uint32_t buffer_size = 0; void _call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error); diff --git a/core/object/object.h b/core/object/object.h index b640c4e78a7..eeef03dcb9a 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -538,8 +538,8 @@ private: std::mutex _instance_binding_mutex; struct InstanceBinding { - void *binding; - void *token; + void *binding = nullptr; + void *token = nullptr; GDNativeInstanceBindingFreeCallback free_callback = nullptr; GDNativeInstanceBindingReferenceCallback reference_callback = nullptr; }; @@ -849,7 +849,7 @@ class ObjectDB { uint64_t validator : OBJECTDB_VALIDATOR_BITS; uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS; uint64_t is_ref_counted : 1; - Object *object; + Object *object = nullptr; }; static SpinLock spin_lock; diff --git a/core/object/script_language.h b/core/object/script_language.h index af4f276825f..08b82d798ed 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -430,11 +430,11 @@ public: extern uint8_t script_encryption_key[32]; class PlaceHolderScriptInstance : public ScriptInstance { - Object *owner; + Object *owner = nullptr; List properties; Map values; Map constants; - ScriptLanguage *language; + ScriptLanguage *language = nullptr; Ref