diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-16 13:56:32 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-16 14:06:29 +0100 |
commit | b8b45804485f7ca18f035f1eeb7a1ac0cf591cac (patch) | |
tree | c0fb75bd8d45125f436ccf0b64fcbae464b11ad9 | |
parent | f5b9cbaff6f0a058d08187b3124948ae68848cd0 (diff) |
Style: Cleanup single-line blocks, semicolons, dead code
Remove currently unused implementation of TextureBasisU, could be re-added
later on if needed and ported.
137 files changed, 847 insertions, 1269 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 810284d5d0..bb4b49d9cd 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2291,8 +2291,8 @@ void Engine::register_singleton(const StringName &p_name, Object *p_object) { s.ptr = p_object; s.user_created = true; ::Engine::get_singleton()->add_singleton(s); - ; } + void Engine::unregister_singleton(const StringName &p_name) { ERR_FAIL_COND_MSG(!has_singleton(p_name), "Attempt to remove unregistered singleton: " + String(p_name)); ERR_FAIL_COND_MSG(!::Engine::get_singleton()->is_singleton_user_created(p_name), "Attempt to remove non-user created singleton: " + String(p_name)); diff --git a/core/input/input.cpp b/core/input/input.cpp index d36d0f4da0..656bb92203 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1145,7 +1145,6 @@ Input::JoyEvent Input::_get_mapped_axis_event(const JoyDeviceMapping &mapping, J // It doesn't make sense for a full axis to map to a button, // but keeping as a default for a trigger with a positive half-axis. event.value = (shifted_positive_value * 2) - 1; - ; break; } return event; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 5c39b2fa1b..12de2f582e 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1417,19 +1417,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo d.get_key_list(&keys); for (const Variant &E : keys) { - /* - CharString utf8 = E->->utf8(); - - if (buf) { - encode_uint32(utf8.length()+1,buf); - buf+=4; - memcpy(buf,utf8.get_data(),utf8.length()+1); - } - - r_len+=4+utf8.length()+1; - while (r_len%4) - r_len++; //pad - */ int len; Error err = encode_variant(E, buf, len, p_full_objects, p_depth + 1); ERR_FAIL_COND_V(err, err); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index ed58b4be7b..611f371229 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1607,11 +1607,6 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia d.get_key_list(&keys); for (const Variant &E : keys) { - /* - if (!_check_type(dict[E])) - continue; - */ - write_variant(f, E, resource_map, external_resources, string_map); write_variant(f, d[E], resource_map, external_resources, string_map); } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 21bf566b1b..2419c76dd3 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -672,10 +672,6 @@ int ResourceLoader::get_import_order(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->get_import_order(p_path); } @@ -690,10 +686,6 @@ String ResourceLoader::get_import_group_file(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->get_import_group_file(p_path); } @@ -708,10 +700,6 @@ bool ResourceLoader::is_import_valid(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->is_import_valid(p_path); } @@ -726,10 +714,6 @@ bool ResourceLoader::is_imported(const String &p_path) { if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->is_imported(p_path); } @@ -744,10 +728,6 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ loader[i]->get_dependencies(local_path, p_dependencies, p_add_types); } @@ -760,10 +740,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String if (!loader[i]->recognize_path(local_path)) { continue; } - /* - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) - continue; - */ return loader[i]->rename_dependencies(local_path, p_map); } diff --git a/core/math/bvh_cull.inc b/core/math/bvh_cull.inc index d7edc8a884..ab468bfd29 100644 --- a/core/math/bvh_cull.inc +++ b/core/math/bvh_cull.inc @@ -508,8 +508,9 @@ bool _cull_convex_iterative(uint32_t p_node_id, CullParams &r_params, bool p_ful uint32_t child_id = leaf.get_item_ref_id(n); // full up with results? exit early, no point in further testing - if (!_cull_hit(child_id, r_params)) + if (!_cull_hit(child_id, r_params)) { return false; + } } } #endif // BVH_CONVEX_CULL_OPTIMIZED diff --git a/core/math/bvh_debug.inc b/core/math/bvh_debug.inc index 55db794ee3..896c36ecf1 100644 --- a/core/math/bvh_debug.inc +++ b/core/math/bvh_debug.inc @@ -1,8 +1,9 @@ public: #ifdef BVH_VERBOSE void _debug_recursive_print_tree(int p_tree_id) const { - if (_root_node_id[p_tree_id] != BVHCommon::INVALID) + if (_root_node_id[p_tree_id] != BVHCommon::INVALID) { _debug_recursive_print_tree_node(_root_node_id[p_tree_id]); + } } String _debug_aabb_to_string(const BVHABB_CLASS &aabb) const { @@ -42,8 +43,9 @@ void _debug_recursive_print_tree_node(uint32_t p_node_id, int depth = 0) const { sz += "["; for (int n = 0; n < leaf.num_items; n++) { - if (n) + if (n) { sz += ", "; + } sz += "r"; sz += itos(leaf.get_item_ref_id(n)); } diff --git a/core/math/octree.h b/core/math/octree.h index 23ba4c1aa3..e73f8213b3 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -211,11 +211,6 @@ private: E = pair_map.insert(key, pdata); E->get().eA = p_A->pair_list.push_back(&E->get()); E->get().eB = p_B->pair_list.push_back(&E->get()); - - /* - if (pair_callback) - pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata); - */ } else { E->get().refcount++; } @@ -854,11 +849,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { Octant *o = F->get().octant; typename List<typename Element::OctantOwner, AL>::Element *N = F->next(); - /* - if (!use_pairs) - o->elements.erase( F->get().E ); - */ - if (use_pairs && e.pairable) { o->pairable_elements.erase(F->get().E); } else { diff --git a/core/object/object.cpp b/core/object/object.cpp index f966607e03..a8a49bd22e 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -402,13 +402,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid #endif } - //try built-in setgetter + // Try built-in setter. { if (ClassDB::set_property(this, p_name, p_value, r_valid)) { - /* - if (r_valid) - *r_valid=true; - */ return; } } @@ -421,7 +417,6 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid return; } else if (p_name == CoreStringNames::get_singleton()->_meta) { - //set_meta(p_name,p_value); metadata = p_value.duplicate(); if (r_valid) { *r_valid = true; @@ -429,7 +424,7 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid return; } - //something inside the object... :| + // Something inside the object... :| bool success = _setv(p_name, p_value); if (success) { if (r_valid) { @@ -485,7 +480,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { #endif } - //try built-in setgetter + // Try built-in getter. { if (ClassDB::get_property(const_cast<Object *>(this), p_name, ret)) { if (r_valid) { @@ -510,7 +505,7 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { return ret; } else { - //something inside the object... :| + // Something inside the object... :| bool success = _getv(p_name, ret); if (success) { if (r_valid) { diff --git a/core/object/object.h b/core/object/object.h index be360703bc..b5be1cf0e7 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -245,13 +245,7 @@ struct 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); }; -// old cast_to -//if ( is_type(T::get_class_static()) ) -//return static_cast<T*>(this); -////else -//return nullptr; - -// API used to extend in GDNative and other C compatible compiled languages +// API used to extend in GDNative and other C compatible compiled languages. class MethodBind; struct ObjectNativeExtension { @@ -297,8 +291,10 @@ struct ObjectNativeExtension { #define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden() /* - the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model. -*/ + * The following is an incomprehensible blob of hacks and workarounds to + * compensate for many of the fallacies in C++. As a plus, this macro pretty + * much alone defines the object model. + */ #define REVERSE_GET_PROPERTY_LIST \ public: \ @@ -534,7 +530,7 @@ private: Set<String> editor_section_folding; #endif ScriptInstance *script_instance = nullptr; - Variant script; //reference does not yet exist, store it in a + Variant script; // Reference does not exist yet, store it in a Variant. Dictionary metadata; mutable StringName _class_name; mutable const StringName *_class_ptr = nullptr; @@ -583,6 +579,7 @@ protected: } return can_die; } + friend class NativeExtensionMethodBind; _ALWAYS_INLINE_ const ObjectNativeExtension *_get_extension() const { return _extension; } _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; } @@ -617,9 +614,6 @@ protected: static void get_valid_parents_static(List<String> *p_parents); static void _get_valid_parents_static(List<String> *p_parents); - //Variant _call_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant()); - //void _call_deferred_bind(const StringName& p_name, const Variant& p_arg1 = Variant(), const Variant& p_arg2 = Variant(), const Variant& p_arg3 = Variant(), const Variant& p_arg4 = Variant()); - Variant _call_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error); @@ -641,7 +635,7 @@ protected: void _disconnect(const StringName &p_signal, const Callable &p_callable, bool p_force = false); -public: //should be protected, but bug in clang++ +public: // Should be protected, but bug in clang++. static void initialize_class(); _FORCE_INLINE_ static void register_custom_data_to_otdb() {} @@ -729,8 +723,6 @@ public: } /* IAPI */ - //void set(const String& p_name, const Variant& p_value); - //Variant get(const String& p_name) const; void set(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr); Variant get(const StringName &p_name, bool *r_valid = nullptr) const; @@ -748,7 +740,7 @@ public: void notification(int p_notification, bool p_reversed = false); virtual String to_string(); - //used mainly by script, get and set all INCLUDING string + // Used mainly by script, get and set all INCLUDING string. virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; virtual void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = nullptr); @@ -757,8 +749,6 @@ public: void set_script(const Variant &p_script); Variant get_script() const; - /* SCRIPT */ - bool has_meta(const StringName &p_name) const; void set_meta(const StringName &p_name, const Variant &p_value); void remove_meta(const StringName &p_name); @@ -768,13 +758,15 @@ public: #ifdef TOOLS_ENABLED void set_edited(bool p_edited); bool is_edited() const; - uint32_t get_edited_version() const; //this function is used to check when something changed beyond a point, it's used mainly for generating previews + // This function is used to check when something changed beyond a point, it's used mainly for generating previews. + uint32_t get_edited_version() const; #endif void set_script_instance(ScriptInstance *p_instance); _FORCE_INLINE_ ScriptInstance *get_script_instance() const { return script_instance; } - void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process + // Some script languages can't control instance creation, so this function eases the process. + void set_script_and_instance(const Variant &p_script, ScriptInstance *p_instance); void add_user_signal(const MethodInfo &p_signal); Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST); @@ -803,10 +795,11 @@ public: virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; - String tr(const StringName &p_message, const StringName &p_context = "") const; // translate message (internationalization) + // Translate message (internationalization). + String tr(const StringName &p_message, const StringName &p_context = "") const; String tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const; - bool _is_queued_for_deletion = false; // 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; } @@ -838,14 +831,14 @@ bool predelete_handler(Object *p_object); void postinitialize_handler(Object *p_object); class ObjectDB { -//this needs to add up to 63, 1 bit is for reference +// This needs to add up to 63, 1 bit is for reference. #define OBJECTDB_VALIDATOR_BITS 39 #define OBJECTDB_VALIDATOR_MASK ((uint64_t(1) << OBJECTDB_VALIDATOR_BITS) - 1) #define OBJECTDB_SLOT_MAX_COUNT_BITS 24 #define OBJECTDB_SLOT_MAX_COUNT_MASK ((uint64_t(1) << OBJECTDB_SLOT_MAX_COUNT_BITS) - 1) #define OBJECTDB_REFERENCE_BIT (uint64_t(1) << (OBJECTDB_SLOT_MAX_COUNT_BITS + OBJECTDB_VALIDATOR_BITS)) - struct ObjectSlot { //128 bits per slot + struct ObjectSlot { // 128 bits per slot. uint64_t validator : OBJECTDB_VALIDATOR_BITS; uint64_t next_free : OBJECTDB_SLOT_MAX_COUNT_BITS; uint64_t is_ref_counted : 1; @@ -875,7 +868,7 @@ public: uint64_t id = p_instance_id; uint32_t slot = id & OBJECTDB_SLOT_MAX_COUNT_MASK; - ERR_FAIL_COND_V(slot >= slot_max, nullptr); //this should never happen unless RID is corrupted + ERR_FAIL_COND_V(slot >= slot_max, nullptr); // This should never happen unless RID is corrupted. spin_lock.lock(); diff --git a/core/os/os.cpp b/core/os/os.cpp index 9558a6978e..9837b6e0aa 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -391,16 +391,18 @@ bool OS::has_feature(const String &p_feature) { return true; } #else - if (p_feature == "release") + if (p_feature == "release") { return true; + } #endif #ifdef TOOLS_ENABLED if (p_feature == "editor") { return true; } #else - if (p_feature == "standalone") + if (p_feature == "standalone") { return true; + } #endif if (sizeof(void *) == 8 && p_feature == "64") { diff --git a/core/os/spin_lock.h b/core/os/spin_lock.h index 27d915e0ae..6e8d7f46d5 100644 --- a/core/os/spin_lock.h +++ b/core/os/spin_lock.h @@ -41,7 +41,7 @@ class SpinLock { public: _ALWAYS_INLINE_ void lock() { while (locked.test_and_set(std::memory_order_acquire)) { - ; + // Continue. } } _ALWAYS_INLINE_ void unlock() { diff --git a/core/variant/type_info.h b/core/variant/type_info.h index 5ae35c92d3..ee050cff4f 100644 --- a/core/variant/type_info.h +++ b/core/variant/type_info.h @@ -245,8 +245,9 @@ namespace godot { namespace details { inline String enum_qualified_name_to_class_info_name(const String &p_qualified_name) { Vector<String> parts = p_qualified_name.split("::", false); - if (parts.size() <= 2) + if (parts.size() <= 2) { return String(".").join(parts); + } // Contains namespace. We only want the class and enum names. return parts[parts.size() - 2] + "." + parts[parts.size() - 1]; } diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index e37a53fede..e2b195350f 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -174,9 +174,9 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { AudioBuffer *abuf = &ioData->mBuffers[i]; memset(abuf->mData, 0, abuf->mDataByteSize); - }; + } return 0; - }; + } ad->start_counting_ticks(); @@ -195,14 +195,14 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon, frames_left -= frames; out += frames * ad->channels; - }; - }; + } + } ad->stop_counting_ticks(); ad->unlock(); return 0; -}; +} OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, @@ -251,7 +251,7 @@ void AudioDriverCoreAudio::start() { active = true; } } -}; +} void AudioDriverCoreAudio::stop() { if (active) { @@ -266,19 +266,19 @@ void AudioDriverCoreAudio::stop() { int AudioDriverCoreAudio::get_mix_rate() const { return mix_rate; -}; +} AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const { return get_speaker_mode_by_total_channels(channels); -}; +} void AudioDriverCoreAudio::lock() { mutex.lock(); -}; +} void AudioDriverCoreAudio::unlock() { mutex.unlock(); -}; +} bool AudioDriverCoreAudio::try_lock() { return mutex.try_lock() == OK; @@ -521,8 +521,9 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) { AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; - for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) + for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) { channelCount += bufferList->mBuffers[j].mNumberChannels; + } memfree(bufferList); @@ -579,8 +580,9 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) { AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; - for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) + for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) { channelCount += bufferList->mBuffers[j].mNumberChannels; + } memfree(bufferList); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 121dc86fb2..1382573461 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "rasterizer_scene_gles3.h" + #ifdef GLES3_ENABLED // TODO: 3D support not implemented yet. diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index a7638b49ec..abbba13ee6 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "rasterizer_storage_gles3.h" + #ifdef GLES3_ENABLED #include "core/config/project_settings.h" @@ -3716,10 +3717,11 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, co->lines = p_lines; if (p_lines.size() != co->len) { - if (co->index_id) + if (co->index_id) { glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) + } if (co->vertex_id) { glDeleteBuffers(1, &co->vertex_id); + } co->index_id = 0; co->vertex_id = 0; @@ -4014,10 +4016,12 @@ bool RasterizerStorageGLES3::free(RID p_rid) { } else if (canvas_occluder_owner.owns(p_rid)) { CanvasOccluder *co = canvas_occluder_owner.get_or_null(p_rid); - if (co->index_id) + if (co->index_id) { glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) + } + if (co->vertex_id) { glDeleteBuffers(1, &co->vertex_id); + } canvas_occluder_owner.free(p_rid); memdelete(co); diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 7ae8b4e3bf..9349722625 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "shader_gles3.h" + #ifdef GLES3_ENABLED #include "core/io/compression.h" diff --git a/drivers/gles3/texture_loader_gles3.cpp b/drivers/gles3/texture_loader_gles3.cpp index 1cbda02121..f8d4cfdc61 100644 --- a/drivers/gles3/texture_loader_gles3.cpp +++ b/drivers/gles3/texture_loader_gles3.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "texture_loader_gles3.h" + #ifdef GLES3_ENABLED #include "core/io/file_access.h" diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 77390a5915..ca84fb6be9 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -46,7 +46,7 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 Error err = save_image(p_path, img); return err; -}; +} Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img) { Vector<uint8_t> buffer; @@ -89,4 +89,4 @@ void ResourceSaverPNG::get_recognized_extensions(const RES &p_resource, List<Str ResourceSaverPNG::ResourceSaverPNG() { Image::save_png_func = &save_image; Image::save_png_buffer_func = &save_image_to_buffer; -}; +} diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 5fdfde4913..af47173b41 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -138,9 +138,9 @@ uint64_t DirAccessUnix::get_modified_time(String p_file) { return flags.st_mtime; } else { ERR_FAIL_V(0); - }; + } return 0; -}; +} String DirAccessUnix::get_next() { if (!dir_stream) { @@ -320,11 +320,11 @@ Error DirAccessUnix::make_dir(String p_dir) { if (success) { return OK; - }; + } if (err == EEXIST) { return ERR_ALREADY_EXISTS; - }; + } return ERR_CANT_CREATE; } @@ -474,14 +474,14 @@ uint64_t DirAccessUnix::get_space_left() { struct statvfs vfs; if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) { return 0; - }; + } return (uint64_t)vfs.f_bavail * (uint64_t)vfs.f_frsize; #else // FIXME: Implement this. return 0; #endif -}; +} String DirAccessUnix::get_filesystem_type() const { return ""; //TODO this should be implemented diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 80ae999ac9..ea442ad8bf 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -246,7 +246,7 @@ uint64_t FileAccessUnix::get_buffer(uint8_t *p_dst, uint64_t p_length) const { uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; -}; +} Error FileAccessUnix::get_error() const { return last_error; @@ -285,8 +285,9 @@ bool FileAccessUnix::file_exists(const String &p_path) { return false; } #else - if (_access(filename.utf8().get_data(), 4) == -1) + if (_access(filename.utf8().get_data(), 4) == -1) { return false; + } #endif // See if this is a regular file @@ -309,7 +310,7 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { } else { print_verbose("Failed to get modified time for: " + p_file + ""); return 0; - }; + } } uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { @@ -321,7 +322,7 @@ uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { return flags.st_mode & 0x7FF; //only permissions } else { ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + "."); - }; + } } Error FileAccessUnix::_set_unix_permissions(const String &p_file, uint32_t p_permissions) { diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index d82dcb8a8d..d442e521bf 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -72,10 +72,10 @@ static IPAddress _sockaddr2ip(struct sockaddr *p_addr) { } else if (p_addr->sa_family == AF_INET6) { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)p_addr; ip.set_ipv6(addr6->sin6_addr.s6_addr); - }; + } return ip; -}; +} void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hostname, Type p_type) const { struct addrinfo hints; @@ -90,14 +90,14 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos } else { hints.ai_family = AF_UNSPEC; hints.ai_flags = AI_ADDRCONFIG; - }; + } hints.ai_flags &= ~AI_NUMERICHOST; int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result); if (s != 0) { ERR_PRINT("getaddrinfo failed! Cannot resolve hostname."); return; - }; + } if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); @@ -105,7 +105,7 @@ void IPUnix::_resolve_hostname(List<IPAddress> &r_addresses, const String &p_hos freeaddrinfo(result); } return; - }; + } struct addrinfo *next = result; @@ -138,8 +138,9 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con for (int i = 0; i < hostnames->Size; i++) { auto hostname = hostnames->GetAt(i); - if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) + if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) { continue; + } String name = hostname->RawName->Data(); Map<String, Interface_Info>::Element *E = r_interfaces->find(name); @@ -171,14 +172,14 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con nullptr, addrs, &buf_size); if (err == NO_ERROR) { break; - }; + } memfree(addrs); if (err == ERROR_BUFFER_OVERFLOW) { continue; // will go back and alloc the right size - }; + } ERR_FAIL_MSG("Call to GetAdaptersAddresses failed with error " + itos(err) + "."); - }; + } IP_ADAPTER_ADDRESSES *adapter = addrs; @@ -191,19 +192,21 @@ void IPUnix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) con IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; while (address != nullptr) { int family = address->Address.lpSockaddr->sa_family; - if (family != AF_INET && family != AF_INET6) + if (family != AF_INET && family != AF_INET6) { continue; + } info.ip_addresses.push_front(_sockaddr2ip(address->Address.lpSockaddr)); address = address->Next; } adapter = adapter->Next; // Only add interface if it has at least one IP - if (info.ip_addresses.size() > 0) + if (info.ip_addresses.size() > 0) { r_interfaces->insert(info.name, info); - }; + } + } memfree(addrs); -}; +} #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index bdfd264a0c..3130d5cae2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -147,7 +147,7 @@ void NetSocketPosix::_set_ip_port(struct sockaddr_storage *p_addr, IPAddress *r_ if (r_port) { *r_port = ntohs(addr6->sin6_port); } - }; + } } NetSocket *NetSocketPosix::_create_func() { @@ -325,8 +325,9 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) { #if defined(__OpenBSD__) // OpenBSD does not support dual stacking, fallback to IPv4 only. - if (ip_type == IP::TYPE_ANY) + if (ip_type == IP::TYPE_ANY) { ip_type = IP::TYPE_IPV4; + } #endif int family = ip_type == IP::TYPE_IPV4 ? AF_INET : AF_INET6; @@ -420,7 +421,7 @@ Error NetSocketPosix::listen(int p_max_pending) { print_verbose("Failed to listen from socket."); close(); return FAILED; - }; + } return OK; } @@ -494,8 +495,9 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (ret == 0) + if (ret == 0) { return ERR_BUSY; + } if (FD_ISSET(_sock, &ex)) { _get_socket_error(); @@ -503,10 +505,12 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { return FAILED; } - if (rdp && FD_ISSET(_sock, rdp)) + if (rdp && FD_ISSET(_sock, rdp)) { ready = true; - if (wrp && FD_ISSET(_sock, wrp)) + } + if (wrp && FD_ISSET(_sock, wrp)) { ready = true; + } return ready ? OK : ERR_BUSY; #else diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 7d57926757..088525647c 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -106,7 +106,7 @@ static void _setup_clock() { void OS_Unix::debug_break() { assert(false); -}; +} static void handle_interrupt(int sig) { if (!EngineDebugger::is_active()) { @@ -198,7 +198,7 @@ double OS_Unix::get_unix_time() const { struct timeval tv_now; gettimeofday(&tv_now, nullptr); return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000; -}; +} OS::Date OS_Unix::get_date(bool p_utc) const { time_t t = time(nullptr); @@ -410,7 +410,7 @@ Error OS_Unix::kill(const ProcessID &p_pid) { int OS_Unix::get_process_id() const { return getpid(); -}; +} bool OS_Unix::has_environment(const String &p_var) const { return getenv(p_var.utf8().get_data()) != nullptr; @@ -555,8 +555,9 @@ String OS_Unix::get_executable_path() const { char *resolved_path = new char[buff_size + 1]; - if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) + if (_NSGetExecutablePath(resolved_path, &buff_size) == 1) { WARN_PRINT("MAXPATHLEN is too small"); + } String path(resolved_path); delete[] resolved_path; diff --git a/drivers/unix/syslog_logger.cpp b/drivers/unix/syslog_logger.cpp index 0e1a1a89a3..6189d645c6 100644 --- a/drivers/unix/syslog_logger.cpp +++ b/drivers/unix/syslog_logger.cpp @@ -31,7 +31,9 @@ #ifdef UNIX_ENABLED #include "syslog_logger.h" + #include "core/string/print_string.h" + #include <syslog.h> void SyslogLogger::logv(const char *p_format, va_list p_list, bool p_err) { diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 1d6d9d56e8..247961b358 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1200,7 +1200,7 @@ uint32_t RenderingDeviceVulkan::get_image_required_mipmaps(uint32_t p_width, uin d = MAX(1, d >> 1); mipmaps++; - }; + } return mipmaps; } @@ -3679,7 +3679,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF // Set view masks for each subpass for (uint32_t i = 0; i < subpasses.size(); i++) { view_masks.push_back(view_mask); - }; + } render_pass_multiview_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO; render_pass_multiview_create_info.pNext = nullptr; @@ -6326,7 +6326,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma attachment_states.push_back(state); idx++; - }; + } } ERR_FAIL_COND_V(attachment_states.size() != p_blend_state.attachments.size(), RID()); @@ -9013,49 +9013,49 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R switch (p_resource) { case DRIVER_RESOURCE_VULKAN_DEVICE: { return (uint64_t)context->get_device(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE: { return (uint64_t)context->get_physical_device(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_INSTANCE: { return (uint64_t)context->get_instance(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_QUEUE: { return (uint64_t)context->get_graphics_queue(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX: { return context->get_graphics_queue_family_index(); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return (uint64_t)tex->image; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE_VIEW: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return (uint64_t)tex->view; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT: { Texture *tex = texture_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(tex, 0); return vulkan_formats[tex->format]; - }; break; + } break; case DRIVER_RESOURCE_VULKAN_SAMPLER: { VkSampler *sampler = sampler_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(sampler, 0); return uint64_t(*sampler); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET: { UniformSet *uniform_set = uniform_set_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(uniform_set, 0); return uint64_t(uniform_set->descriptor_set); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_BUFFER: { Buffer *buffer = nullptr; if (vertex_buffer_owner.owns(p_rid)) { @@ -9073,23 +9073,23 @@ uint64_t RenderingDeviceVulkan::get_driver_resource(DriverResource p_resource, R ERR_FAIL_NULL_V(buffer, 0); return uint64_t(buffer->buffer); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE: { ComputePipeline *compute_pipeline = compute_pipeline_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(compute_pipeline, 0); return uint64_t(compute_pipeline->pipeline); - }; break; + } break; case DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE: { RenderPipeline *render_pipeline = render_pipeline_owner.get_or_null(p_rid); ERR_FAIL_NULL_V(render_pipeline, 0); return uint64_t(render_pipeline->pipeline); - }; break; + } break; default: { // not supported for this driver return 0; - }; break; + } break; } } diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index c7a2d04436..c9609b469a 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -454,8 +454,9 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c Error AudioDriverWASAPI::init_render_device(bool reinit) { Error err = audio_device_init(&audio_output, false, reinit); - if (err != OK) + if (err != OK) { return err; + } switch (audio_output.channels) { case 2: // Stereo @@ -485,8 +486,9 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) { Error AudioDriverWASAPI::init_capture_device(bool reinit) { Error err = audio_device_init(&audio_input, true, reinit); - if (err != OK) + if (err != OK) { return err; + } // Get the max frames UINT32 max_frames; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index cfd5d65f60..59dc1d8e77 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -87,7 +87,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { if (!S_ISREG(st.st_mode)) { return ERR_FILE_CANT_OPEN; } - }; + } #ifdef TOOLS_ENABLED // Windows is case insensitive, but all other platforms are sensitive to it @@ -269,7 +269,7 @@ uint64_t FileAccessWindows::get_buffer(uint8_t *p_dst, uint64_t p_length) const uint64_t read = fread(p_dst, 1, p_length, f); check_errors(); return read; -}; +} Error FileAccessWindows::get_error() const { return last_error; @@ -326,8 +326,9 @@ bool FileAccessWindows::file_exists(const String &p_name) { uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { String file = fix_path(p_file); - if (file.ends_with("/") && file != "/") + if (file.ends_with("/") && file != "/") { file = file.substr(0, file.length() - 1); + } struct _stat st; int rv = _wstat((LPCWSTR)(file.utf16().get_data()), &st); diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 40b5de2ec7..cc9c6c26c5 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -1281,10 +1281,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { // 3-move the keys (re insert them) for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - /* - if (newpos<0) - continue; //no add at the beginning - */ Array key = animation->track_get_key_value(E->get().first, E->get().second); float h = key[0]; h += moving_selection_offset.y; @@ -1295,10 +1291,6 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { // 4-(undo) remove inserted keys for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { float newpos = editor->snap_time(animation->track_get_key_time(E->get().first, E->get().second) + moving_selection_offset.x); - /* - if (newpos<0) - continue; //no remove what no inserted - */ undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", E->get().first, newpos); } diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 3cb5d3513d..4b821f2a12 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -41,7 +41,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { } frame_metrics.write[last_metric] = p_metric; - // _make_metric_ptrs(frame_metrics.write[last_metric]); List<String> stack; for (int i = 0; i < frame_metrics[last_metric].areas.size(); i++) { @@ -478,19 +477,6 @@ void EditorVisualProfiler::_graph_tex_draw() { graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); graph->draw_string(font, Vector2(font->get_string_size("X", font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, Color(1, 1, 1, 0.8)); - - /* - if (hover_metric != -1 && frame_metrics[hover_metric].valid) { - int max_frames = frame_metrics.size(); - int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1); - if (frame < 0) - frame = 0; - - int cur_x = frame * graph->get_size().x / max_frames; - - graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), Color(1, 1, 1, 0.4)); - } -*/ } void EditorVisualProfiler::_graph_tex_mouse_exit() { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 91bd89b201..69c7e9d52c 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -589,11 +589,6 @@ void EditorData::remove_scene(int p_idx) { } bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { - /* - if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) - return false; - */ - Ref<SceneState> ss; if (p_node == p_root) { diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index d5cd61d792..c56ebaa499 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1858,7 +1858,6 @@ int EditorInspectorArray::_drop_position() const { void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) { bool valid = false; - ; if (p_text.is_valid_int()) { int val = p_text.to_int(); if (val > 0 && val != count) { @@ -1870,7 +1869,6 @@ void EditorInspectorArray::_new_size_line_edit_text_changed(String p_text) { void EditorInspectorArray::_new_size_line_edit_text_submitted(String p_text) { bool valid = false; - ; if (p_text.is_valid_int()) { int val = p_text.to_int(); if (val > 0 && val != count) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 208640a2e3..a10eecbca1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3916,8 +3916,9 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons if (script.is_valid()) { // Uncommenting would break things! Consider adding a parameter if you need it. // StringName name = EditorNode::get_editor_data().script_class_get_name(base_script->get_path()); - // if (name != StringName()) + // if (name != StringName()) { // return name; + // } // should probably be deprecated in 4.x StringName base = script->get_instance_base_type(); @@ -5745,7 +5746,6 @@ static void _execute_thread(void *p_ud) { } eta->done.set(); - ; } int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 605f385de2..fe32399fc6 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -1009,11 +1009,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name String source = _uri_to_id(parser.get_attribute_value("source")); if (semantic == "TEXCOORD") { - /* - if (parser.has_attribute("set"))// a texcoord - semantic+=parser.get_attribute_value("set"); - else - semantic="TEXCOORD0";*/ semantic = "TEXCOORD" + itos(last_ref++); } int offset = parser.get_attribute_value("offset").to_int(); @@ -1194,11 +1189,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { skindata.weights = weights; } - /* - else if (!parser.is_empty()) - parser.skip_section(); - */ - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin") { break; } @@ -1258,19 +1248,8 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } else if (section == "Name_array" || section == "IDREF_array") { // create a new array and read it. - - /* - if (section=="IDREF_array") - morphdata.use_idrefs=true; - */ if (morphdata.sources.has(current_source)) { morphdata.sources[current_source].sarray = _read_string_array(parser); - /* - if (section=="IDREF_array") { - Vector<String> sa = morphdata.sources[current_source].sarray; - for(int i=0;i<sa.size();i++) - state.idref_joints.insert(sa[i]); - }*/ COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values."); } } else if (section == "technique_common") { @@ -1303,11 +1282,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } } - /* - else if (!parser.is_empty()) - parser.skip_section(); - */ - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph") { break; } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 96645665aa..9042f1e32c 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -317,8 +317,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_FILE_CORRUPT); Vector3 vertex = vertices[vtx]; - //if (weld_vertices) - // vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance)); if (!smoothing) { smooth_group++; } diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index a5b576ceb9..2316ce80e5 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTWAV_H -#define RESOURCEIMPORTWAV_H +#ifndef RESOURCE_IMPORTER_WAV_H +#define RESOURCE_IMPORTER_WAV_H #include "core/io/resource_importer.h" @@ -50,9 +50,6 @@ public: virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override; static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) { - /*p_sample_data->data = (void*)malloc(len); - xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/ - static const int16_t _ima_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, @@ -81,15 +78,14 @@ public: int i, step_idx = 0, prev = 0; uint8_t *out = w; - //int16_t xm_prev=0; const float *in = p_data.ptr(); - /* initial value is zero */ + // Initial value is zero. *(out++) = 0; *(out++) = 0; - /* Table index initial value */ + // Table index initial value. *(out++) = 0; - /* unused */ + // Unused. *(out++) = 0; for (i = 0; i < datalen; i++) { @@ -101,15 +97,8 @@ public: xm_sample = 0; } else { xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767); - /* - if (xm_sample==32767 || xm_sample==-32768) - printf("clippy!\n",xm_sample); - */ } - //xm_sample=xm_sample+xm_prev; - //xm_prev=xm_sample; - diff = (int)xm_sample - prev; nibble = 0; @@ -129,7 +118,7 @@ public: step >>= 1; mask >>= 1; - }; + } if (nibble & 8) { prev -= vpdiff; @@ -137,20 +126,10 @@ public: prev += vpdiff; } - if (prev > 32767) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev = 32767; - } else if (prev < -32768) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev = -32768; - } + prev = CLAMP(prev, -32768, 32767); step_idx += _ima_adpcm_index_table[nibble]; - if (step_idx < 0) { - step_idx = 0; - } else if (step_idx > 88) { - step_idx = 88; - } + step_idx = CLAMP(step_idx, 0, 88); if (i & 1) { *out |= nibble << 4; @@ -158,7 +137,6 @@ public: } else { *out = nibble; } - /*dataptr[i]=prev>>8;*/ } } @@ -167,4 +145,4 @@ public: ResourceImporterWAV(); }; -#endif // RESOURCEIMPORTWAV_H +#endif // RESOURCE_IMPORTER_WAV_H diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 9f432a1fc7..46b33f62fe 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -1069,7 +1069,6 @@ void EditorNode3DGizmoPlugin::_bind_methods() { GDVIRTUAL_BIND(_get_subgizmo_transform, "gizmo", "subgizmo_id"); GDVIRTUAL_BIND(_set_subgizmo_transform, "gizmo", "subgizmo_id", "transform"); GDVIRTUAL_BIND(_commit_subgizmos, "gizmo", "ids", "restores", "cancel"); - ; } bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 22b79921bb..910af24743 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1068,7 +1068,7 @@ void Polygon2DEditor::_uv_draw() { if (uv_create && i == uvs.size() - 1) { next_point = uv_create_to; } - if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead) + if (i < uv_draw_max) { // If using or creating polygons, do not show outline (will show polygons instead). uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE)); } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 25906f33de..cea1a0e808 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -464,14 +464,6 @@ void ShaderEditor::_bind_methods() { } void ShaderEditor::ensure_select_current() { - /* - if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { - ShaderTextEditor *ste = Object::cast_to<ShaderTextEditor>(tab_container->get_child(tab_container->get_current_tab())); - if (!ste) - return; - Ref<Shader> shader = ste->get_edited_shader(); - get_scene()->get_root_node()->call("_resource_selected",shader); - }*/ } void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) { diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 12f9c6fc00..a3c662ba08 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -32,7 +32,6 @@ #include "core/os/os.h" #include "servers/rendering_server.h" -#include "texture_basisu.h" #ifdef TOOLS_ENABLED #include <encoder/basisu_comp.h> @@ -272,7 +271,6 @@ void register_basis_universal_types() { Image::basis_universal_packer = basis_universal_packer; #endif Image::basis_universal_unpacker = basis_universal_unpacker; - //GDREGISTER_CLASS(TextureBasisU); } void unregister_basis_universal_types() { diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp deleted file mode 100644 index 1ac4df8d19..0000000000 --- a/modules/basis_universal/texture_basisu.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/*************************************************************************/ -/* texture_basisu.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 "texture_basisu.h" -#if 0 -#include "core/os/os.h" - -#ifdef TOOLS_ENABLED -#include <encoder/basisu_comp.h> -#endif - -#include <transcoder/basisu_transcoder.h> - -void TextureBasisU::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data); - ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data); - ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import); - - ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data"); -}; - -int TextureBasisU::get_width() const { - return tex_size.x; -}; - -int TextureBasisU::get_height() const { - return tex_size.y; -}; - -RID TextureBasisU::get_rid() const { - return texture; -}; - - -bool TextureBasisU::has_alpha() const { - return false; -}; - -void TextureBasisU::set_flags(uint32_t p_flags) { - flags = p_flags; - RenderingServer::get_singleton()->texture_set_flags(texture, p_flags); -}; - -uint32_t TextureBasisU::get_flags() const { - return flags; -}; - - -void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { - -#ifdef TOOLS_ENABLED - data = p_data; -#endif - - const uint8_t* r = p_data.ptr(); - const void* ptr = r.ptr(); - int size = p_data.size(); - - basist::transcoder_texture_format format; - Image::Format imgfmt; - - if (OS::get_singleton()->has_feature("s3tc")) { - format = basist::cTFBC3; // get this from renderer - imgfmt = Image::FORMAT_DXT5; - - } else if (OS::get_singleton()->has_feature("etc2")) { - format = basist::cTFETC2; - imgfmt = Image::FORMAT_ETC2_RGBA8; - }; - - basist::basisu_transcoder tr(nullptr); - - ERR_FAIL_COND(!tr.validate_header(ptr, size)); - - basist::basisu_image_info info; - tr.get_image_info(ptr, size, info, 0); - tex_size = Size2(info.m_width, info.m_height); - - int block_size = basist::basis_get_bytes_per_block(format); - Vector<uint8_t> gpudata; - gpudata.resize(info.m_total_blocks * block_size); - - { - uint8_t* w = gpudata.ptrw(); - uint8_t* dst = w.ptr(); - for (int i=0; i<gpudata.size(); i++) - dst[i] = 0x00; - - int ofs = 0; - tr.start_transcoding(ptr, size); - for (int i=0; i<info.m_total_levels; i++) { - basist::basisu_image_level_info level; - tr.get_image_level_info(ptr, size, level, 0, i); - - bool ret = tr.transcode_image_level(ptr, size, 0, i, dst + ofs, level.m_total_blocks - i, format); - if (!ret) { - printf("failed! on level %i\n", i); - break; - }; - - ofs += level.m_total_blocks * block_size; - }; - }; - - Ref<Image> img; - img.instantiate(); - img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); - - RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags); - RenderingServer::get_singleton()->texture_set_data(texture, img); -}; - -Error TextureBasisU::import(const Ref<Image>& p_img) { - -#ifdef TOOLS_ENABLED - - Vector<uint8_t> budata; - - { - Image::Format format = p_img->get_format(); - if (format != Image::FORMAT_RGB8 && format != Image::FORMAT_RGBA8) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - Ref<Image> copy = p_img->duplicate(); - if (format == Image::FORMAT_RGB8) - copy->convert(Image::FORMAT_RGBA8); - - basisu::image buimg(p_img->get_width(), p_img->get_height()); - int size = p_img->get_width() * p_img->get_height() * 4; - - Vector<uint8_t> vec = copy->get_data(); - { - const uint8_t* r = vec.ptr(); - memcpy(buimg.get_ptr(), r.ptr(), size); - }; - - basisu::basis_compressor_params params; - params.m_max_endpoint_clusters = 512; - params.m_max_selector_clusters = 512; - params.m_multithreading = true; - - basisu::job_pool jpool(1); - params.m_pJob_pool = &jpool; - - params.m_mip_gen = p_img->get_mipmap_count() > 0; - params.m_source_images.push_back(buimg); - - basisu::basis_compressor c; - c.init(params); - - int buerr = c.process(); - if (buerr != basisu::basis_compressor::cECSuccess) { - ERR_FAIL_V(ERR_INVALID_PARAMETER); - return ERR_INVALID_PARAMETER; - }; - - const basisu::uint8_vec& buvec = c.get_output_basis_file(); - budata.resize(buvec.size()); - - { - uint8_t* w = budata.ptrw(); - memcpy(w.ptr(), &buvec[0], budata.size()); - }; - }; - - set_basisu_data(budata); - - return OK; -#else - - return ERR_UNAVAILABLE; -#endif -}; - - -Vector<uint8_t> TextureBasisU::get_basisu_data() const { - return data; -}; - -TextureBasisU::TextureBasisU() { - texture = RenderingServer::get_singleton()->texture_create(); -}; - - -TextureBasisU::~TextureBasisU() { - RenderingServer::get_singleton()->free(texture); -}; - -#endif diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h deleted file mode 100644 index 8c8be68254..0000000000 --- a/modules/basis_universal/texture_basisu.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************/ -/* texture_basisu.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 BASIS_UNIVERSAL_TEXTURE_BASISU_H -#define BASIS_UNIVERSAL_TEXTURE_BASISU_H - -#include "scene/resources/texture.h" - -#ifdef TOOLS_ENABLED -#include <encoder/basisu_comp.h> -#endif - -#include <transcoder/basisu_transcoder.h> - -#if 0 -class TextureBasisU : public Texture { - GDCLASS(TextureBasisU, Texture); - RES_BASE_EXTENSION("butex"); - - RID texture; - Size2 tex_size; - - uint32_t flags = FLAGS_DEFAULT; - - Vector<uint8_t> data; - - static void _bind_methods(); - -public: - - virtual int get_width() const; - virtual int get_height() const; - virtual RID get_rid() const; - virtual bool has_alpha() const; - - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - - Error import(const Ref<Image> &p_img); - - void set_basisu_data(const Vector<uint8_t>& p_data); - - Vector<uint8_t> get_basisu_data() const; - String get_img_path() const; - - TextureBasisU(); - ~TextureBasisU(); -}; - -#endif - -#endif // BASIS_UNIVERSAL_TEXTURE_BASISU_H diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index 61c3b3b0a3..b06cdeaa6a 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -334,7 +334,6 @@ real_t SliderJointBullet::getMaxAngMotorForce() { real_t SliderJointBullet::getLinearPos() { return sliderConstraint->getLinearPos(); - ; } void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) { diff --git a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp index b3956af762..591f2e5503 100644 --- a/modules/fbx/fbx_parser/FBXMeshGeometry.cpp +++ b/modules/fbx/fbx_parser/FBXMeshGeometry.cpp @@ -212,32 +212,6 @@ MeshGeometry::MeshGeometry(uint64_t id, const ElementPtr element, const std::str m_normals = resolve_vertex_data_array<Vector3>(layer_scope, MappingInformationType, ReferenceInformationType, "Normals"); } else if (layer_type_name == "LayerElementColor") { m_colors = resolve_vertex_data_array<Color>(layer_scope, MappingInformationType, ReferenceInformationType, "Colors", "ColorIndex"); - // NOTE: this is a useful sanity check to ensure you're getting any color data which is not default. - // const Color first_color_check = m_colors.data[0]; - // bool colors_are_all_the_same = true; - // size_t i = 1; - // for(i = 1; i < m_colors.data.size(); i++) - // { - // const Color current_color = m_colors.data[i]; - // if(current_color.is_equal_approx(first_color_check)) - // { - // continue; - // } - // else - // { - // colors_are_all_the_same = false; - // break; - // } - // } - // - // if(colors_are_all_the_same) - // { - // print_error("Color serialisation is not working for vertex colors some should be different in the test asset."); - // } - // else - // { - // print_verbose("Color array has unique colors at index: " + itos(i)); - // } } } } diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 2de923c125..d6cd9e6e57 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -53,8 +53,9 @@ class CSharpLanguage; #ifdef NO_SAFE_CAST template <typename TScriptInstance, typename TScriptLanguage> TScriptInstance *cast_script_instance(ScriptInstance *p_inst) { - if (!p_inst) + if (!p_inst) { return nullptr; + } return p_inst->get_language() == TScriptLanguage::get_singleton() ? static_cast<TScriptInstance *>(p_inst) : nullptr; } #else diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index f345dff333..07128770b7 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2149,8 +2149,9 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } output.append("#ifdef TOOLS_ENABLED\n"); - for (const InternalCall &internal_call : editor_custom_icalls) + for (const InternalCall &internal_call : editor_custom_icalls) { ADD_INTERNAL_CALL_REGISTRATION(internal_call); + } output.append("#endif // TOOLS_ENABLED\n"); for (const InternalCall &internal_call : method_icalls) { diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index a7269d7f87..4cd4772d2c 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -151,8 +151,9 @@ void gd_mono_debug_init() { .utf8(); } #else - if (da_args.length() == 0) + if (da_args.length() == 0) { return; // Exported games don't use the project settings to setup the debugger agent + } #endif // Debugging enabled @@ -226,8 +227,9 @@ void GDMono::add_mono_shared_libs_dir_to_path() { path_value += mono_reg_info.bin_dir; } #else - if (DirAccess::exists(bundled_bin_dir)) + if (DirAccess::exists(bundled_bin_dir)) { path_value += bundled_bin_dir; + } #endif // TOOLS_ENABLED #else @@ -1269,8 +1271,9 @@ GDMono::~GDMono() { print_verbose("Mono: Finalizing scripts domain..."); - if (mono_domain_get() != root_domain) + if (mono_domain_get() != root_domain) { mono_domain_set(root_domain, true); + } finalizing_scripts_domain = true; diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp index eb8bbab948..4797d5dae1 100644 --- a/modules/mono/mono_gd/support/android_support.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -134,8 +134,9 @@ String determine_app_native_lib_dir() { } String get_app_native_lib_dir() { - if (app_native_lib_dir_cache.is_empty()) + if (app_native_lib_dir_cache.is_empty()) { app_native_lib_dir_cache = determine_app_native_lib_dir(); + } return app_native_lib_dir_cache; } @@ -144,10 +145,11 @@ int gd_mono_convert_dl_flags(int flags) { int lflags = flags & MONO_DL_LOCAL ? 0 : RTLD_GLOBAL; - if (flags & MONO_DL_LAZY) + if (flags & MONO_DL_LAZY) { lflags |= RTLD_LAZY; - else + } else { lflags |= RTLD_NOW; + } return lflags; } @@ -164,8 +166,9 @@ void *godot_dl_handle = nullptr; void *try_dlopen(const String &p_so_path, int p_flags) { if (!FileAccess::exists(p_so_path)) { - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data()); + } return nullptr; } @@ -174,13 +177,15 @@ void *try_dlopen(const String &p_so_path, int p_flags) { void *handle = dlopen(p_so_path.utf8().get_data(), lflags); if (!handle) { - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror()); + } return nullptr; } - if (OS::get_singleton()->is_stdout_verbose()) + if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Successfully loaded shared library: '%s'\n", p_so_path.utf8().get_data()); + } return handle; } @@ -217,20 +222,23 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) { void *sym_addr = dlsym(p_handle, p_name); - if (sym_addr) + if (sym_addr) { return sym_addr; + } if (p_handle == mono_dl_handle && godot_dl_handle) { // Looking up for '__Internal' P/Invoke. We want to search in both the Mono and Godot shared libraries. // This is needed to resolve the monodroid P/Invoke functions that are defined at the bottom of the file. sym_addr = dlsym(godot_dl_handle, p_name); - if (sym_addr) + if (sym_addr) { return sym_addr; + } } - if (r_err) + if (r_err) { *r_err = str_format_new("%s\n", dlerror()); + } return nullptr; } @@ -239,8 +247,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { dlclose(p_handle); // Not sure if this ever happens. Does Mono close the handle for the main module? - if (p_handle == mono_dl_handle) + if (p_handle == mono_dl_handle) { mono_dl_handle = nullptr; + } return nullptr; } @@ -292,13 +301,15 @@ MonoBoolean _gd_mono_init_cert_store() { ScopedLocalRef<jobject> certStoreLocal(env, env->CallStaticObjectMethod(keyStoreClass, getInstance, androidCAStoreString.get())); - if (jni_exception_check(env)) + if (jni_exception_check(env)) { return 0; + } env->CallVoidMethod(certStoreLocal, load, nullptr); - if (jni_exception_check(env)) + if (jni_exception_check(env)) { return 0; + } certStore = env->NewGlobalRef(certStoreLocal); @@ -309,8 +320,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { // The JNI code is the equivalent of: // // Certificate certificate = certStore.getCertificate(alias); - // if (certificate == null) + // if (certificate == null) { // return null; + // } // return certificate.getEncoded(); MonoError mono_error; @@ -340,8 +352,9 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get())); - if (!certificate) + if (!certificate) { return nullptr; + } ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded)); jsize encodedLength = env->GetArrayLength(encoded); @@ -374,11 +387,13 @@ void initialize() { void cleanup() { // This is called after shutting down the Mono runtime - if (mono_dl_handle) + if (mono_dl_handle) { gd_mono_android_dlclose(mono_dl_handle, nullptr); + } - if (godot_dl_handle) + if (godot_dl_handle) { gd_mono_android_dlclose(godot_dl_handle, nullptr); + } JNIEnv *env = get_jni_env(); @@ -431,8 +446,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char // // NetworkInterface.getByName(p_ifname).isUp() - if (!r_is_up || !p_ifname || strlen(p_ifname) == 0) + if (!r_is_up || !p_ifname || strlen(p_ifname) == 0) { return 0; + } *r_is_up = 0; @@ -450,8 +466,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_up_state(const char ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname)); ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get())); - if (!networkInterface) + if (!networkInterface) { return 0; + } *r_is_up = (mono_bool)env->CallBooleanMethod(networkInterface, isUp); @@ -463,8 +480,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast( // // NetworkInterface.getByName(p_ifname).supportsMulticast() - if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0) + if (!r_supports_multicast || !p_ifname || strlen(p_ifname) == 0) { return 0; + } *r_supports_multicast = 0; @@ -482,8 +500,9 @@ GD_PINVOKE_EXPORT mono_bool _monodroid_get_network_interface_supports_multicast( ScopedLocalRef<jstring> js_ifname(env, env->NewStringUTF(p_ifname)); ScopedLocalRef<jobject> networkInterface(env, env->CallStaticObjectMethod(networkInterfaceClass, getByName, js_ifname.get())); - if (!networkInterface) + if (!networkInterface) { return 0; + } *r_supports_multicast = (mono_bool)env->CallBooleanMethod(networkInterface, supportsMulticast); @@ -528,8 +547,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> connectivityManager(env, env->CallObjectMethod(applicationContext, getSystemService, connectivityServiceString.get())); - if (!connectivityManager) + if (!connectivityManager) { return; + } ScopedLocalRef<jclass> connectivityManagerClass(env, env->FindClass("android/net/ConnectivityManager")); ERR_FAIL_NULL(connectivityManagerClass); @@ -539,8 +559,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> activeNetwork(env, env->CallObjectMethod(connectivityManager, getActiveNetwork)); - if (!activeNetwork) + if (!activeNetwork) { return; + } jmethodID getLinkProperties = env->GetMethodID(connectivityManagerClass, "getLinkProperties", "(Landroid/net/Network;)Landroid/net/LinkProperties;"); @@ -548,8 +569,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> linkProperties(env, env->CallObjectMethod(connectivityManager, getLinkProperties, activeNetwork.get())); - if (!linkProperties) + if (!linkProperties) { return; + } ScopedLocalRef<jclass> linkPropertiesClass(env, env->FindClass("android/net/LinkProperties")); ERR_FAIL_NULL(linkPropertiesClass); @@ -559,8 +581,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn ScopedLocalRef<jobject> dnsServers(env, env->CallObjectMethod(linkProperties, getDnsServers)); - if (!dnsServers) + if (!dnsServers) { return; + } ScopedLocalRef<jclass> listClass(env, env->FindClass("java/util/List")); ERR_FAIL_NULL(listClass); @@ -570,11 +593,13 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn int dnsServersCount = env->CallIntMethod(dnsServers, listSize); - if (dnsServersCount > dns_servers_len) + if (dnsServersCount > dns_servers_len) { dnsServersCount = dns_servers_len; + } - if (dnsServersCount <= 0) + if (dnsServersCount <= 0) { return; + } jmethodID listGet = env->GetMethodID(listClass, "get", "(I)Ljava/lang/Object;"); ERR_FAIL_NULL(listGet); @@ -587,8 +612,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn for (int i = 0; i < dnsServersCount; i++) { ScopedLocalRef<jobject> dnsServer(env, env->CallObjectMethod(dnsServers, listGet, (jint)i)); - if (!dnsServer) + if (!dnsServer) { continue; + } ScopedLocalRef<jstring> hostAddress(env, (jstring)env->CallObjectMethod(dnsServer, getHostAddress)); const char *host_address = env->GetStringUTFChars(hostAddress, 0); @@ -603,8 +629,9 @@ static void interop_get_active_network_dns_servers(char **r_dns_servers, int *dn } GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) { - if (!r_dns_servers_array) + if (!r_dns_servers_array) { return -1; + } *r_dns_servers_array = nullptr; @@ -661,13 +688,15 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() { ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault)); - if (!defaultTimeZone) + if (!defaultTimeZone) { return nullptr; + } ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID)); - if (!defaultTimeZoneID) + if (!defaultTimeZoneID) { return nullptr; + } const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0); diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm index e66b88db32..df97dfba49 100644 --- a/modules/mono/mono_gd/support/ios_support.mm +++ b/modules/mono/mono_gd/support/ios_support.mm @@ -94,8 +94,9 @@ GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() { GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) { int length = 0; const uint16_t *ptr = p_unicode_message; - while (*ptr++) + while (*ptr++) { length += sizeof(uint16_t); + } NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding]; os_log_info(OS_LOG_DEFAULT, "%{public}@", msg); diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index f388661207..8e37e6943c 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -60,8 +60,9 @@ REGSAM _get_bitness_sam() { LONG _RegOpenKey(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult) { LONG res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ, phkResult); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { res = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ | _get_bitness_sam(), phkResult); + } return res; } @@ -92,31 +93,37 @@ LONG _find_mono_in_reg(const String &p_subkey, MonoRegInfo &r_info, bool p_old_r HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } if (!p_old_reg) { res = _RegKeyQueryString(hKey, "Version", r_info.version); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } } res = _RegKeyQueryString(hKey, "SdkInstallRoot", r_info.install_root_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "FrameworkAssemblyDirectory", r_info.assembly_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "MonoConfigDir", r_info.config_dir); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } - if (r_info.install_root_dir.ends_with("\\")) + if (r_info.install_root_dir.ends_with("\\")) { r_info.bin_dir = r_info.install_root_dir + "bin"; - else + } else { r_info.bin_dir = r_info.install_root_dir + "\\bin"; + } cleanup: RegCloseKey(hKey); @@ -129,8 +136,9 @@ LONG _find_mono_in_reg_old(const String &p_subkey, MonoRegInfo &r_info) { HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)(p_subkey.utf16().get_data()), &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "DefaultCLR", default_clr); @@ -147,11 +155,13 @@ cleanup: MonoRegInfo find_mono() { MonoRegInfo info; - if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS) + if (_find_mono_in_reg("Software\\Mono", info) == ERROR_SUCCESS) { return info; + } - if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS) + if (_find_mono_in_reg_old("Software\\Novell\\Mono", info) == ERROR_SUCCESS) { return info; + } return MonoRegInfo(); } @@ -212,13 +222,15 @@ String find_msbuild_tools_path() { HKEY hKey; LONG res = _RegOpenKey(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\14.0", &hKey); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } res = _RegKeyQueryString(hKey, "MSBuildToolsPath", msbuild_tools_path); - if (res != ERROR_SUCCESS) + if (res != ERROR_SUCCESS) { goto cleanup; + } cleanup: RegCloseKey(hKey); diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 89851fc4d3..15a0b28181 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -57,8 +57,9 @@ String cwd() { Char16String buffer; buffer.resize((int)expected_size); - if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) + if (::GetCurrentDirectoryW(expected_size, (wchar_t *)buffer.ptrw()) == 0) { return "."; + } String result; if (result.parse_utf16(buffer.ptr())) { @@ -95,8 +96,9 @@ String realpath(const String &p_path) { FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - if (hFile == INVALID_HANDLE_VALUE) + if (hFile == INVALID_HANDLE_VALUE) { return p_path; + } const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED); @@ -177,8 +179,9 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { #ifdef WINDOWS_ENABLED String get_drive_letter(const String &p_norm_path) { int idx = p_norm_path.find(":/"); - if (idx != -1 && idx < p_norm_path.find("/")) + if (idx != -1 && idx < p_norm_path.find("/")) { return p_norm_path.substr(0, idx + 1); + } return String(); } #endif diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 88445f2f98..9549137aef 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -930,8 +930,6 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const { get_variable_list(&vars); for (const StringName &E : vars) { - //if (!variables[E]._export) - // continue; PropertyInfo pi = variables[E].info; pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_list->push_back(pi); diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 4c41a4c7ee..0fb074b0c2 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "webrtc_data_channel_js.h" + #include "emscripten.h" extern "C" { @@ -104,8 +105,9 @@ int WebRTCDataChannelJS::get_available_packet_count() const { Error WebRTCDataChannelJS::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(get_ready_state() != STATE_OPEN, ERR_UNCONFIGURED); - if (queue_count == 0) + if (queue_count == 0) { return ERR_UNAVAILABLE; + } uint32_t to_read = 0; uint32_t left = 0; diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp index 2d029dfbbc..e051a3b564 100644 --- a/modules/websocket/emws_client.cpp +++ b/modules/websocket/emws_client.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "emws_client.h" + #include "core/config/project_settings.h" #include "core/io/ip.h" #include "emscripten.h" @@ -45,8 +46,9 @@ void EMWSClient::_esws_on_message(void *obj, const uint8_t *p_data, int p_data_s EMWSClient *client = static_cast<EMWSClient *>(obj); Error err = static_cast<EMWSPeer *>(*client->get_peer(1))->read_msg(p_data, p_data_size, p_is_string == 1); - if (err == OK) + if (err == OK) { client->_on_peer_packet(); + } } void EMWSClient::_esws_on_error(void *obj) { @@ -71,8 +73,9 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, String proto_string; for (int i = 0; i < p_protocols.size(); i++) { - if (i != 0) + if (i != 0) { proto_string += ","; + } proto_string += p_protocols[i]; } @@ -109,8 +112,9 @@ Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const { MultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const { if (_peer->is_connected_to_host()) { - if (_is_connecting) + if (_is_connecting) { return CONNECTION_CONNECTING; + } return CONNECTION_CONNECTED; } diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index 77a96c8e4f..86169f88e9 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -31,6 +31,7 @@ #ifdef JAVASCRIPT_ENABLED #include "emws_peer.h" + #include "core/io/ip.h" void EMWSPeer::set_sock(int p_sock, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size) { @@ -66,8 +67,9 @@ Error EMWSPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { } Error EMWSPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - if (_in_buffer.packets_left() == 0) + if (_in_buffer.packets_left() == 0) { return ERR_UNAVAILABLE; + } int read = 0; Error err = _in_buffer.read_packet(_packet_buffer.ptrw(), _packet_buffer.size(), &_is_string, read); @@ -109,7 +111,7 @@ void EMWSPeer::close(int p_code, String p_reason) { IPAddress EMWSPeer::get_connected_host() const { ERR_FAIL_V_MSG(IPAddress(), "Not supported in HTML5 export."); -}; +} uint16_t EMWSPeer::get_connected_port() const { ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 86b857f72c..06b0e31801 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -31,11 +31,13 @@ #ifdef JAVASCRIPT_ENABLED #include "webxr_interface_js.h" + #include "core/input/input.h" #include "core/os/os.h" #include "emscripten.h" #include "godot_webxr.h" #include "servers/rendering/renderer_compositor.h" + #include <stdlib.h> void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) { @@ -481,7 +483,6 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) { sprintf(name, "axis_%i", i); float value = *((float *)axes + (i + 1)); - ; tracker->set_input(name, value); } free(axes); diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index 246ec6b198..10f23b320b 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -165,8 +165,9 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector ERR_CONTINUE(idx == -1); - if (touch[i].pos == p_points[idx].pos) - continue; //no move unncesearily + if (touch[i].pos == p_points[idx].pos) { + continue; // Don't move unnecessarily. + } Ref<InputEventScreenDrag> ev; ev.instantiate(); diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index d8503b6caf..57d08ac83e 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -31,10 +31,10 @@ #ifndef JNI_SINGLETON_H #define JNI_SINGLETON_H -#include <core/config/engine.h> -#include <core/variant/variant.h> +#include "core/config/engine.h" +#include "core/variant/variant.h" #ifdef ANDROID_ENABLED -#include <platform/android/jni_utils.h> +#include "platform/android/jni_utils.h" #endif class JNISingleton : public Object { @@ -93,8 +93,9 @@ public: for (int i = 0; i < p_argcount; i++) { jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]); v[i] = vr.val; - if (vr.obj) + if (vr.obj) { to_erase.push_back(vr.obj); + } } Variant ret; @@ -197,18 +198,19 @@ public: } void add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args) { - if (p_args.size() == 0) + if (p_args.size() == 0) { ADD_SIGNAL(MethodInfo(p_name)); - else if (p_args.size() == 1) + } else if (p_args.size() == 1) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"))); - else if (p_args.size() == 2) + } else if (p_args.size() == 2) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"))); - else if (p_args.size() == 3) + } else if (p_args.size() == 3) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"))); - else if (p_args.size() == 4) + } else if (p_args.size() == 4) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"))); - else if (p_args.size() == 5) + } else if (p_args.size() == 5) { ADD_SIGNAL(MethodInfo(p_name, PropertyInfo(p_args[0], "arg1"), PropertyInfo(p_args[1], "arg2"), PropertyInfo(p_args[2], "arg3"), PropertyInfo(p_args[3], "arg4"), PropertyInfo(p_args[4], "arg5"))); + } } #endif diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index cd478bb90f..8495d2cc18 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -56,8 +56,9 @@ void AudioDriverOpenSL::_buffer_callback( } } - if (mix) + if (mix) { mutex.unlock(); + } const int32_t *src_buff = mixdown_buffer; @@ -312,13 +313,15 @@ AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const { } void AudioDriverOpenSL::lock() { - if (active) + if (active) { mutex.lock(); + } } void AudioDriverOpenSL::unlock() { - if (active) + if (active) { mutex.unlock(); + } } void AudioDriverOpenSL::finish() { diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 5461a3aefa..7fb4f54fca 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "dir_access_jandroid.h" + #include "core/string/print_string.h" #include "file_access_android.h" #include "string_android.h" @@ -51,8 +52,9 @@ Error DirAccessJAndroid::list_dir_begin() { jstring js = env->NewStringUTF(current_dir.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); - if (res <= 0) + if (res <= 0) { return ERR_CANT_OPEN; + } id = res; @@ -64,8 +66,9 @@ String DirAccessJAndroid::get_next() { JNIEnv *env = get_jni_env(); jstring str = (jstring)env->CallObjectMethod(io, _dir_next, id); - if (!str) + if (!str) { return ""; + } String ret = jstring_to_string((jstring)str, env); env->DeleteLocalRef((jobject)str); @@ -83,8 +86,9 @@ bool DirAccessJAndroid::current_is_hidden() const { } void DirAccessJAndroid::list_dir_end() { - if (id == 0) + if (id == 0) { return; + } JNIEnv *env = get_jni_env(); env->CallVoidMethod(io, _dir_close, id); @@ -102,22 +106,25 @@ String DirAccessJAndroid::get_drive(int p_drive) { Error DirAccessJAndroid::change_dir(String p_dir) { JNIEnv *env = get_jni_env(); - if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) + if (p_dir.is_empty() || p_dir == "." || (p_dir == ".." && current_dir.is_empty())) { return OK; + } String new_dir; - if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) + if (p_dir != "res://" && p_dir.length() > 1 && p_dir.ends_with("/")) { p_dir = p_dir.substr(0, p_dir.length() - 1); + } - if (p_dir.begins_with("/")) + if (p_dir.begins_with("/")) { new_dir = p_dir.substr(1, p_dir.length()); - else if (p_dir.begins_with("res://")) + } else if (p_dir.begins_with("res://")) { new_dir = p_dir.substr(6, p_dir.length()); - else if (current_dir.is_empty()) + } else if (current_dir.is_empty()) { new_dir = p_dir; - else + } else { new_dir = current_dir.plus_file(p_dir); + } //test if newdir exists new_dir = new_dir.simplify_path(); @@ -125,8 +132,9 @@ Error DirAccessJAndroid::change_dir(String p_dir) { jstring js = env->NewStringUTF(new_dir.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); env->DeleteLocalRef(js); - if (res <= 0) + if (res <= 0) { return ERR_INVALID_PARAMETER; + } env->CallVoidMethod(io, _dir_close, res); @@ -141,10 +149,11 @@ String DirAccessJAndroid::get_current_dir(bool p_include_drive) { bool DirAccessJAndroid::file_exists(String p_file) { String sd; - if (current_dir.is_empty()) + if (current_dir.is_empty()) { sd = p_file; - else + } else { sd = current_dir.plus_file(p_file); + } FileAccessAndroid *f = memnew(FileAccessAndroid); bool exists = f->file_exists(sd); @@ -158,27 +167,30 @@ bool DirAccessJAndroid::dir_exists(String p_dir) { String sd; - if (current_dir.is_empty()) + if (current_dir.is_empty()) { sd = p_dir; - else { - if (p_dir.is_relative_path()) + } else { + if (p_dir.is_relative_path()) { sd = current_dir.plus_file(p_dir); - else + } else { sd = fix_path(p_dir); + } } String path = sd.simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } jstring js = env->NewStringUTF(path.utf8().get_data()); int res = env->CallIntMethod(io, _dir_open, js); env->DeleteLocalRef(js); - if (res <= 0) + if (res <= 0) { return false; + } env->CallVoidMethod(io, _dir_close, res); diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 26bdcb9520..c84a919b6b 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -29,30 +29,28 @@ /*************************************************************************/ #include "file_access_android.h" + #include "core/string/print_string.h" AAssetManager *FileAccessAndroid::asset_manager = nullptr; -/*void FileAccessAndroid::make_default() { - create_func=create_android; -}*/ - FileAccess *FileAccessAndroid::create_android() { return memnew(FileAccessAndroid); } Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { String path = fix_path(p_path).simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, ERR_UNAVAILABLE); //can't write on android.. a = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING); - if (!a) + if (!a) { return ERR_CANT_OPEN; - //ERR_FAIL_COND_V(!a,ERR_FILE_NOT_FOUND); + } len = AAsset_getLength(a); pos = 0; eof = false; @@ -61,8 +59,9 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { } void FileAccessAndroid::close() { - if (!a) + if (!a) { return; + } AAsset_close(a); a = nullptr; } @@ -146,15 +145,17 @@ void FileAccessAndroid::store_8(uint8_t p_dest) { bool FileAccessAndroid::file_exists(const String &p_path) { String path = fix_path(p_path).simplify_path(); - if (path.begins_with("/")) + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } AAsset *at = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING); - if (!at) + if (!at) { return false; + } AAsset_close(at); return true; diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java index 8fc16ab7ba..4525c5c212 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GLUtils.java @@ -147,8 +147,9 @@ public class GLUtils { Log.i(TAG, String.format(" %s: %d\n", name, value[0])); } else { // Log.w(TAG, String.format(" %s: failed\n", name)); - while (egl.eglGetError() != EGL10.EGL_SUCCESS) - ; + while (egl.eglGetError() != EGL10.EGL_SUCCESS) { + // Continue. + } } } } diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index f823e2c27f..7c788b4dc4 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -29,13 +29,15 @@ /*************************************************************************/ #include "api/java_class_wrapper.h" + #include "string_android.h" #include "thread_jandroid.h" bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret) { Map<StringName, List<MethodInfo>>::Element *M = methods.find(p_method); - if (!M) + if (!M) { return false; + } JNIEnv *env = get_jni_env(); ERR_FAIL_COND_V(env == nullptr, false); @@ -68,8 +70,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, //bug? } break; case ARG_TYPE_BOOLEAN: { - if (p_args[i]->get_type() != Variant::BOOL) + if (p_args[i]->get_type() != Variant::BOOL) { arg_expected = Variant::BOOL; + } } break; case ARG_NUMBER_CLASS_BIT | ARG_TYPE_BYTE: case ARG_NUMBER_CLASS_BIT | ARG_TYPE_CHAR: @@ -81,27 +84,27 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, case ARG_TYPE_SHORT: case ARG_TYPE_INT: case ARG_TYPE_LONG: { - if (!p_args[i]->is_num()) + if (!p_args[i]->is_num()) { arg_expected = Variant::INT; - + } } break; case ARG_NUMBER_CLASS_BIT | ARG_TYPE_FLOAT: case ARG_NUMBER_CLASS_BIT | ARG_TYPE_DOUBLE: case ARG_TYPE_FLOAT: case ARG_TYPE_DOUBLE: { - if (!p_args[i]->is_num()) + if (!p_args[i]->is_num()) { arg_expected = Variant::FLOAT; - + } } break; case ARG_TYPE_STRING: { - if (p_args[i]->get_type() != Variant::STRING) + if (p_args[i]->get_type() != Variant::STRING) { arg_expected = Variant::STRING; - + } } break; case ARG_TYPE_CLASS: { - if (p_args[i]->get_type() != Variant::OBJECT) + if (p_args[i]->get_type() != Variant::OBJECT) { arg_expected = Variant::OBJECT; - else { + } else { Ref<RefCounted> ref = *p_args[i]; if (!ref.is_null()) { if (Object::cast_to<JavaObject>(ref.ptr())) { @@ -118,12 +121,11 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } } } - } break; default: { - if (p_args[i]->get_type() != Variant::ARRAY) + if (p_args[i]->get_type() != Variant::ARRAY) { arg_expected = Variant::ARRAY; - + } } break; } @@ -135,15 +137,17 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, break; } } - if (!valid) + if (!valid) { continue; + } method = &E; break; } - if (!method) + if (!method) { return true; //no version convinces + } r_error.error = Callable::CallError::CALL_OK; @@ -780,9 +784,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { bool val = env->CallBooleanMethod(o, JavaClassWrapper::singleton->Boolean_booleanValue); ret.push_back(val); } @@ -801,9 +805,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallByteMethod(o, JavaClassWrapper::singleton->Byte_byteValue); ret.push_back(val); } @@ -821,9 +825,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallCharMethod(o, JavaClassWrapper::singleton->Character_characterValue); ret.push_back(val); } @@ -841,9 +845,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallShortMethod(o, JavaClassWrapper::singleton->Short_shortValue); ret.push_back(val); } @@ -861,9 +865,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int val = env->CallIntMethod(o, JavaClassWrapper::singleton->Integer_integerValue); ret.push_back(val); } @@ -881,9 +885,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { int64_t val = env->CallLongMethod(o, JavaClassWrapper::singleton->Long_longValue); ret.push_back(val); } @@ -901,9 +905,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { float val = env->CallFloatMethod(o, JavaClassWrapper::singleton->Float_floatValue); ret.push_back(val); } @@ -921,9 +925,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { double val = env->CallDoubleMethod(o, JavaClassWrapper::singleton->Double_doubleValue); ret.push_back(val); } @@ -942,9 +946,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va for (int i = 0; i < count; i++) { jobject o = env->GetObjectArrayElement(arr, i); - if (!o) + if (!o) { ret.push_back(Variant()); - else { + } else { String val = jstring_to_string((jstring)o, env); ret.push_back(val); } @@ -962,8 +966,9 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va } Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { - if (class_cache.has(p_class)) + if (class_cache.has(p_class)) { return class_cache[p_class]; + } JNIEnv *env = get_jni_env(); ERR_FAIL_COND_V(env == nullptr, Ref<JavaClass>()); @@ -971,10 +976,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { jclass bclass = env->FindClass(p_class.utf8().get_data()); ERR_FAIL_COND_V(!bclass, Ref<JavaClass>()); - //jmethodID getDeclaredMethods = env->GetMethodID(bclass,"getDeclaredMethods", "()[Ljava/lang/reflect/Method;"); - - //ERR_FAIL_COND_V(!getDeclaredMethods,Ref<JavaClass>()); - jobjectArray methods = (jobjectArray)env->CallObjectMethod(bclass, getDeclaredMethods); ERR_FAIL_COND_V(!methods, Ref<JavaClass>()); @@ -1057,8 +1058,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { float new_likeliness = 0; float existing_likeliness = 0; - if (E->get().param_types.size() != mi.param_types.size()) + if (E->get().param_types.size() != mi.param_types.size()) { continue; + } bool valid = true; for (int j = 0; j < E->get().param_types.size(); j++) { Variant::Type _new; @@ -1075,8 +1077,9 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { existing_likeliness = existing_l; } - if (!valid) + if (!valid) { continue; + } if (new_likeliness > existing_likeliness) { java_class->methods[str_method].erase(E); @@ -1087,10 +1090,11 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { } if (!discard) { - if (mi._static) + if (mi._static) { mi.method = env->GetStaticMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data()); - else + } else { mi.method = env->GetMethodID(bclass, str_method.utf8().get_data(), signature.utf8().get_data()); + } ERR_CONTINUE(!mi.method); @@ -1100,7 +1104,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); - }; + } env->DeleteLocalRef(methods); diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index ff0bcf0716..d6e3ad90b1 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "java_godot_io_wrapper.h" + #include "core/error/error_list.h" // JNIEnv is only valid within the thread it belongs to, in a multi threading environment diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index e7ab0ef7ed..dd4fa9de7b 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -200,8 +200,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz) { - if (step.get() == 0) + if (step.get() == 0) { return; + } if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) { dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST); @@ -209,8 +210,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jcl } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz) { - if (step.get() == -1) + if (step.get() == -1) { return; + } if (step.get() == 0) { // Since Godot is initialized on the UI thread, main_thread_id was set to that thread's id, @@ -243,8 +245,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl } void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask, jfloat vertical_factor, jfloat horizontal_factor) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } Vector<AndroidInputHandler::TouchPos> points; for (int i = 0; i < pointer_count; i++) { @@ -279,32 +282,36 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch__IIII_3FIFF(JNI // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_hover(JNIEnv *env, jclass clazz, jint p_type, jfloat p_x, jfloat p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_hover(p_type, Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_doubleTap(JNIEnv *env, jclass clazz, jint p_button_mask, jint p_x, jint p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_double_tap(p_button_mask, Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_scroll(JNIEnv *env, jclass clazz, jint p_x, jint p_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_scroll(Point2(p_x, p_y)); } // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } AndroidInputHandler::JoypadEvent jevent; jevent.device = p_device; @@ -369,8 +376,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged( // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } input_handler->process_key_event(p_keycode, p_scancode, p_unicode_char, p_pressed); } @@ -392,15 +400,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } os_android->main_loop_focusin(); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } os_android->main_loop_focusout(); } @@ -426,13 +436,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en for (int i = 0; i < count; i++) { jobject obj = env->GetObjectArrayElement(params, i); Variant v; - if (obj) + if (obj) { v = _jobject_to_variant(env, obj); + } memnew_placement(&vlist[i], Variant); vlist[i] = v; vptr[i] = &vlist[i]; env->DeleteLocalRef(obj); - }; + } Callable::CallError err; obj->call(str_method, (const Variant **)vptr, count, err); @@ -455,10 +466,11 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * for (int i = 0; i < MIN(count, VARIANT_ARG_MAX); i++) { jobject obj = env->GetObjectArrayElement(params, i); - if (obj) + if (obj) { args[i] = _jobject_to_variant(env, obj); + } env->DeleteLocalRef(obj); - }; + } static_assert(VARIANT_ARG_MAX == 8, "This code needs to be updated if VARIANT_ARG_MAX != 8"); obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); @@ -478,8 +490,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResu } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } if (os_android->get_main_loop()) { os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_RESUMED); @@ -487,8 +500,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNI } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } if (os_android->get_main_loop()) { os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED); diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 5beec6b611..754267c834 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -92,8 +92,9 @@ jobject GodotJavaWrapper::get_activity() { jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) { if (godot_class) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND_V(p_env == nullptr, nullptr); @@ -129,8 +130,9 @@ GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() { void GodotJavaWrapper::on_video_init(JNIEnv *p_env) { if (_on_video_init) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _on_video_init); @@ -158,8 +160,9 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) { void GodotJavaWrapper::restart(JNIEnv *p_env) { if (_restart) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _restart); @@ -168,8 +171,9 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) { void GodotJavaWrapper::force_quit(JNIEnv *p_env) { if (_finish) { - if (p_env == nullptr) + if (p_env == nullptr) { p_env = get_jni_env(); + } ERR_FAIL_COND(p_env == nullptr); p_env->CallVoidMethod(godot_instance, _finish); diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp index 7e81565d9d..e2573d10f8 100644 --- a/platform/android/jni_utils.cpp +++ b/platform/android/jni_utils.cpp @@ -46,7 +46,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a env->DeleteLocalRef(bclass); } else { v.val.z = *p_arg; - }; + } } break; case Variant::INT: { if (force_jobject) { @@ -61,7 +61,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a } else { v.val.i = *p_arg; - }; + } } break; case Variant::FLOAT: { if (force_jobject) { @@ -76,7 +76,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a } else { v.val.f = *p_arg; - }; + } } break; case Variant::STRING: { String s = *p_arg; @@ -111,7 +111,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a jstring str = env->NewStringUTF(String(keys[j]).utf8().get_data()); env->SetObjectArrayElement(jkeys, j, str); env->DeleteLocalRef(str); - }; + } jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V"); jvalue val; @@ -128,7 +128,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a if (v.obj) { env->DeleteLocalRef(v.obj); } - }; + } jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V"); val.l = jvalues; @@ -205,7 +205,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { if (name == "java.lang.String") { return jstring_to_string((jstring)obj, env); - }; + } if (name == "[Ljava.lang.String;") { jobjectArray arr = (jobjectArray)obj; @@ -219,20 +219,20 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { } return sarr; - }; + } if (name == "java.lang.Boolean") { jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z"); bool ret = env->CallBooleanMethod(obj, boolValue); return ret; - }; + } if (name == "java.lang.Integer" || name == "java.lang.Long") { jclass nclass = env->FindClass("java/lang/Number"); jmethodID longValue = env->GetMethodID(nclass, "longValue", "()J"); jlong ret = env->CallLongMethod(obj, longValue); return ret; - }; + } if (name == "[I") { jintArray arr = (jintArray)obj; @@ -243,7 +243,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { int *w = sarr.ptrw(); env->GetIntArrayRegion(arr, 0, fCount, w); return sarr; - }; + } if (name == "[B") { jbyteArray arr = (jbyteArray)obj; @@ -254,14 +254,14 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { uint8_t *w = sarr.ptrw(); env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w)); return sarr; - }; + } if (name == "java.lang.Float" || name == "java.lang.Double") { jclass nclass = env->FindClass("java/lang/Number"); jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D"); double ret = env->CallDoubleMethod(obj, doubleValue); return ret; - }; + } if (name == "[D") { jdoubleArray arr = (jdoubleArray)obj; @@ -275,9 +275,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { double n; env->GetDoubleArrayRegion(arr, i, 1, &n); w[i] = n; - }; + } return sarr; - }; + } if (name == "[F") { jfloatArray arr = (jfloatArray)obj; @@ -291,9 +291,9 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { float n; env->GetFloatArrayRegion(arr, i, 1, &n); w[i] = n; - }; + } return sarr; - }; + } if (name == "[Ljava.lang.Object;") { jobjectArray arr = (jobjectArray)obj; @@ -308,7 +308,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { } return varr; - }; + } if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") { Dictionary ret; @@ -327,10 +327,10 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { for (int i = 0; i < keys.size(); i++) { ret[keys[i]] = vals[i]; - }; + } return ret; - }; + } env->DeleteLocalRef(c); @@ -359,8 +359,9 @@ Variant::Type get_jni_type(const String &p_type) { int idx = 0; while (_type_to_vtype[idx].name) { - if (p_type == _type_to_vtype[idx].name) + if (p_type == _type_to_vtype[idx].name) { return _type_to_vtype[idx].type; + } idx++; } @@ -390,8 +391,9 @@ const char *get_jni_sig(const String &p_type) { int idx = 0; while (_type_to_vtype[idx].name) { - if (p_type == _type_to_vtype[idx].name) + if (p_type == _type_to_vtype[idx].name) { return _type_to_vtype[idx].sig; + } idx++; } diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp index 620df539e4..a65e7c6724 100644 --- a/platform/android/net_socket_android.cpp +++ b/platform/android/net_socket_android.cpp @@ -77,18 +77,21 @@ NetSocketAndroid::~NetSocketAndroid() { void NetSocketAndroid::close() { NetSocketPosix::close(); - if (wants_broadcast) + if (wants_broadcast) { multicast_lock_release(); - if (multicast_groups) + } + if (multicast_groups) { multicast_lock_release(); + } wants_broadcast = false; multicast_groups = 0; } Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled); - if (err != OK) + if (err != OK) { return err; + } if (p_enabled != wants_broadcast) { if (p_enabled) { @@ -105,11 +108,13 @@ Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) { Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, String p_if_name) { Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name); - if (err != OK) + if (err != OK) { return err; + } - if (!multicast_groups) + if (!multicast_groups) { multicast_lock_acquire(); + } multicast_groups++; return OK; @@ -117,14 +122,16 @@ Error NetSocketAndroid::join_multicast_group(const IPAddress &p_multi_address, S Error NetSocketAndroid::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) { Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name); - if (err != OK) + if (err != OK) { return err; + } ERR_FAIL_COND_V(multicast_groups == 0, ERR_BUG); multicast_groups--; - if (!multicast_groups) + if (!multicast_groups) { multicast_lock_release(); + } return OK; } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index d1672d6ea3..b17b0f3139 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -81,17 +81,18 @@ void OS_Android::alert(const String &p_alert, const String &p_title) { void OS_Android::initialize_core() { OS_Unix::initialize_core(); - if (use_apk_expansion) + if (use_apk_expansion) { FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES); - else { + } else { FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES); } FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA); FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM); - if (use_apk_expansion) + if (use_apk_expansion) { DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES); - else + } else { DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES); + } DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA); DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM); @@ -162,20 +163,23 @@ MainLoop *OS_Android::get_main_loop() const { } void OS_Android::main_loop_begin() { - if (main_loop) + if (main_loop) { main_loop->initialize(); + } } bool OS_Android::main_loop_iterate() { - if (!main_loop) + if (!main_loop) { return false; + } DisplayServerAndroid::get_singleton()->process_events(); return Main::iteration(); } void OS_Android::main_loop_end() { - if (main_loop) + if (main_loop) { main_loop->finalize(); + } } void OS_Android::main_loop_focusout() { @@ -207,8 +211,9 @@ String OS_Android::get_locale() const { String OS_Android::get_model_name() const { String model = godot_io_java->get_model(); - if (!model.is_empty()) + if (!model.is_empty()) { return model; + } return OS_Unix::get_model_name(); } @@ -218,8 +223,9 @@ String OS_Android::get_data_path() const { } String OS_Android::get_user_data_dir() const { - if (!data_dir_cache.is_empty()) + if (!data_dir_cache.is_empty()) { return data_dir_cache; + } String data_dir = godot_io_java->get_user_data_dir(); if (!data_dir.is_empty()) { @@ -230,8 +236,9 @@ String OS_Android::get_user_data_dir() const { } String OS_Android::get_cache_path() const { - if (!cache_dir_cache.is_empty()) + if (!cache_dir_cache.is_empty()) { return cache_dir_cache; + } String cache_dir = godot_io_java->get_cache_dir(); if (!cache_dir.is_empty()) { @@ -243,8 +250,9 @@ String OS_Android::get_cache_path() const { String OS_Android::get_unique_id() const { String unique_id = godot_io_java->get_unique_id(); - if (!unique_id.is_empty()) + if (!unique_id.is_empty()) { return unique_id; + } return OS::get_unique_id(); } diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 5130a26f15..c5c9b5a5f9 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "app_delegate.h" + #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #import "godot_view.h" @@ -76,7 +77,7 @@ static ViewController *mainViewController = nil; // bail, things did not go very well for us, should probably output a message on screen with our error code... exit(0); return NO; - }; + } ViewController *viewController = [[ViewController alloc] init]; viewController.godotView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO; @@ -99,7 +100,7 @@ static ViewController *mainViewController = nil; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; return YES; -}; +} - (void)onAudioInterruption:(NSNotification *)notification { if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) { @@ -111,17 +112,17 @@ static ViewController *mainViewController = nil; OSIPhone::get_singleton()->on_focus_in(); } } -}; +} - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING); } -}; +} - (void)applicationWillTerminate:(UIApplication *)application { iphone_finish(); -}; +} // When application goes to background (e.g. user switches to another app or presses Home), // then applicationWillResignActive -> applicationDidEnterBackground are called. diff --git a/platform/iphone/display_layer.mm b/platform/iphone/display_layer.mm index 7448dfed4a..92e81448ac 100644 --- a/platform/iphone/display_layer.mm +++ b/platform/iphone/display_layer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "display_layer.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" #include "display_server_iphone.h" @@ -153,17 +154,6 @@ return NO; } - // if (OS::get_singleton()) { - // OS::VideoMode vm; - // vm.fullscreen = true; - // vm.width = backingWidth; - // vm.height = backingHeight; - // vm.resizable = false; - // OS::get_singleton()->set_video_mode(vm); - // OSIPhone::get_singleton()->set_base_framebuffer(viewFramebuffer); - // }; - // gl_view_base_fb = viewFramebuffer; - return YES; } diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index 9491c9cf90..a0f8daf5a0 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #include "display_server_iphone.h" + #import "app_delegate.h" #include "core/config/project_settings.h" #include "core/io/file_access_pack.h" @@ -231,7 +232,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse ev->set_position(Vector2(p_x, p_y)); perform_event(ev); } -}; +} void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) { if (!GLOBAL_DEF("debug/disable_touch", false)) { @@ -241,16 +242,16 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int ev->set_position(Vector2(p_x, p_y)); ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y)); perform_event(ev); - }; -}; + } +} void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) { Input::get_singleton()->parse_input_event(p_event); -}; +} void DisplayServerIPhone::touches_cancelled(int p_idx) { touch_press(p_idx, -1, -1, false, false); -}; +} // MARK: Keyboard @@ -263,13 +264,13 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) { ev->set_physical_keycode(p_key); ev->set_unicode((char32_t)p_key); perform_event(ev); -}; +} // MARK: Motion void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z)); -}; +} void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) { // Found out the Z should not be negated! Pass as is! @@ -279,15 +280,15 @@ void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) p_z / kDisplayServerIPhoneAcceleration); Input::get_singleton()->set_accelerometer(v_accelerometer); -}; +} void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) { Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z)); -}; +} void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) { Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z)); -}; +} // MARK: - @@ -520,7 +521,7 @@ void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) { float DisplayServerIPhone::screen_get_max_scale() const { return screen_get_scale(SCREEN_OF_MAIN_WINDOW); -}; +} void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) { screen_orientation = p_orientation; diff --git a/platform/iphone/godot_iphone.mm b/platform/iphone/godot_iphone.mm index a76276e815..49474ef554 100644 --- a/platform/iphone/godot_iphone.mm +++ b/platform/iphone/godot_iphone.mm @@ -53,7 +53,7 @@ int add_path(int p_argc, char **p_args) { p_args[p_argc] = nullptr; return p_argc; -}; +} int add_cmdline(int p_argc, char **p_args) { NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"]; @@ -67,12 +67,12 @@ int add_cmdline(int p_argc, char **p_args) { continue; } p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding]; - }; + } p_args[p_argc] = nullptr; return p_argc; -}; +} int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { size_t len = strlen(argv[0]); @@ -103,7 +103,7 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { char *fargv[64]; for (int i = 0; i < argc; i++) { fargv[i] = argv[i]; - }; + } fargv[argc] = nullptr; argc = add_path(argc, fargv); argc = add_cmdline(argc, fargv); @@ -119,10 +119,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) { os->initialize_modules(); return 0; -}; +} void iphone_finish() { printf("iphone_finish\n"); Main::cleanup(); delete os; -}; +} diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm index ae92f32851..da71312fc4 100644 --- a/platform/iphone/godot_view.mm +++ b/platform/iphone/godot_view.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view.h" + #include "core/os/keyboard.h" #include "core/string/ustring.h" #import "display_layer.h" @@ -226,8 +227,9 @@ static const float earth_gravity = 9.80665; [self.displayLink setPaused:YES]; // Process all input events - while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) - ; + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) { + // Continue. + } // We are good to go, resume the CADisplayLink [self.displayLink setPaused:NO]; diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/iphone/godot_view_gesture_recognizer.mm index a46c42765a..18939f7108 100644 --- a/platform/iphone/godot_view_gesture_recognizer.mm +++ b/platform/iphone/godot_view_gesture_recognizer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view_gesture_recognizer.h" + #import "godot_view.h" #include "core/config/project_settings.h" diff --git a/platform/iphone/godot_view_renderer.mm b/platform/iphone/godot_view_renderer.mm index e49edf5b74..32477ae41c 100644 --- a/platform/iphone/godot_view_renderer.mm +++ b/platform/iphone/godot_view_renderer.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "godot_view_renderer.h" + #include "core/config/project_settings.h" #include "core/os/keyboard.h" #import "display_server_iphone.h" @@ -101,7 +102,7 @@ double dval = [n doubleValue]; ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval); - }; + } // do stuff } } diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm index da21ad0ace..ad1ea70c10 100644 --- a/platform/iphone/ios.mm +++ b/platform/iphone/ios.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #include "ios.h" + #import "app_delegate.h" #import "view_controller.h" #import <UIKit/UIKit.h> @@ -36,7 +37,7 @@ void iOS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url); -}; +} void iOS::alert(const char *p_alert, const char *p_title) { NSString *title = [NSString stringWithUTF8String:p_title]; @@ -75,6 +76,6 @@ String iOS::get_rate_url(int p_app_id) const { printf("returning rate url %s\n", ret.utf8().get_data()); return ret; -}; +} iOS::iOS() {} diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm index f45f4da5a8..9c2feeaaca 100644 --- a/platform/iphone/joypad_iphone.mm +++ b/platform/iphone/joypad_iphone.mm @@ -29,6 +29,7 @@ /*************************************************************************/ #import "joypad_iphone.h" + #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" #include "main/main.h" @@ -139,10 +140,10 @@ void JoypadIPhone::start_processing() { for (NSNumber *key in keys) { int joy_id = [key intValue]; return joy_id; - }; + } return -1; -}; +} - (void)addiOSJoypad:(GCController *)controller { // get a new id for our controller @@ -156,7 +157,7 @@ void JoypadIPhone::start_processing() { // assign our player index if (controller.playerIndex == GCControllerPlayerIndexUnset) { controller.playerIndex = [self getFreePlayerIndex]; - }; + } // tell Godot about our new controller Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String])); @@ -202,8 +203,8 @@ void JoypadIPhone::start_processing() { // and remove it from our dictionary [self.connectedJoypads removeObjectForKey:key]; - }; -}; + } +} - (GCControllerPlayerIndex)getFreePlayerIndex { bool have_player_1 = false; @@ -223,9 +224,9 @@ void JoypadIPhone::start_processing() { have_player_3 = true; } else if (controller.playerIndex == GCControllerPlayerIndex4) { have_player_4 = true; - }; - }; - }; + } + } + } if (!have_player_1) { return GCControllerPlayerIndex1; @@ -237,7 +238,7 @@ void JoypadIPhone::start_processing() { return GCControllerPlayerIndex4; } else { return GCControllerPlayerIndexUnset; - }; + } } - (void)setControllerInputHandler:(GCController *)controller { @@ -285,7 +286,7 @@ void JoypadIPhone::start_processing() { gamepad.dpad.left.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); - }; + } if (element == gamepad.leftThumbstick) { float value = gamepad.leftThumbstick.xAxis.value; @@ -303,7 +304,7 @@ void JoypadIPhone::start_processing() { } else if (element == gamepad.rightTrigger) { float value = gamepad.rightTrigger.value; Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, value); - }; + } }; } else if (controller.microGamepad != nil) { // micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad @@ -329,7 +330,7 @@ void JoypadIPhone::start_processing() { gamepad.dpad.down.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed); Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); - }; + } }; } @@ -338,6 +339,6 @@ void JoypadIPhone::start_processing() { ///@TODO need to add support for controllerPausedHandler which should be a /// toggle -}; +} @end diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 9fb6426b21..56cb49318c 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -31,6 +31,7 @@ #ifdef IPHONE_ENABLED #include "os_iphone.h" + #import "app_delegate.h" #include "core/config/project_settings.h" #include "core/io/dir_access.h" @@ -169,7 +170,7 @@ void OSIPhone::delete_main_loop() { if (main_loop) { main_loop->finalize(); memdelete(main_loop); - }; + } main_loop = nullptr; } @@ -198,7 +199,7 @@ void OSIPhone::finalize() { deinitialize_modules(); // Already gets called - // delete_main_loop(); + //delete_main_loop(); } // MARK: Dynamic Libraries @@ -231,12 +232,13 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const String OSIPhone::get_name() const { return "iOS"; -}; +} String OSIPhone::get_model_name() const { String model = ios->get_model(); - if (model != "") + if (model != "") { return model; + } return OS_Unix::get_model_name(); } @@ -254,7 +256,7 @@ Error OSIPhone::shell_open(String p_uri) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; return OK; -}; +} void OSIPhone::set_user_data_dir(String p_dir) { DirAccess *da = DirAccess::open(p_dir); diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index e1fc645c13..4f4ef4f046 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -203,7 +203,7 @@ case DisplayServer::SCREEN_LANDSCAPE: return UIInterfaceOrientationMaskLandscapeLeft; } -}; +} - (BOOL)prefersStatusBarHidden { return YES; diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index a0e1246c55..2caf369354 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "platform/javascript/display_server_javascript.h" +#include "display_server_javascript.h" #ifdef GLES3_ENABLED #include "drivers/gles3/rasterizer_gles3.h" @@ -325,12 +325,13 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso image = image->duplicate(); - if (atlas_texture.is_valid()) + if (atlas_texture.is_valid()) { image->crop_from_point( atlas_rect.position.x, atlas_rect.position.y, texture_size.width, texture_size.height); + } if (image->get_format() != Image::FORMAT_RGBA8) { image->convert(Image::FORMAT_RGBA8); @@ -618,8 +619,9 @@ void DisplayServerJavaScript::set_icon(const Ref<Image> &p_icon) { ERR_FAIL_COND(icon->decompress() != OK); } if (icon->get_format() != Image::FORMAT_RGBA8) { - if (icon == p_icon) + if (icon == p_icon) { icon = icon->duplicate(); + } icon->convert(Image::FORMAT_RGBA8); } @@ -891,8 +893,9 @@ Size2i DisplayServerJavaScript::window_get_real_size(WindowID p_window) const { } void DisplayServerJavaScript::window_set_mode(WindowMode p_mode, WindowID p_window) { - if (window_mode == p_mode) + if (window_mode == p_mode) { return; + } switch (p_mode) { case WINDOW_MODE_WINDOWED: { diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp index 77858bff01..eb5c02822f 100644 --- a/platform/javascript/javascript_singleton.cpp +++ b/platform/javascript/javascript_singleton.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "api/javascript_singleton.h" + #include "emscripten.h" #include "os_javascript.h" diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index de5ca44f9d..da88ea18b0 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -175,7 +175,7 @@ String OS_JavaScript::get_name() const { String OS_JavaScript::get_user_data_dir() const { return "/userfs"; -}; +} String OS_JavaScript::get_cache_path() const { return "/home/web_user/.cache"; diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 86c3534fc9..bca38d9f20 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -4794,7 +4794,7 @@ DisplayServerX11::~DisplayServerX11() { if (img[i] != nullptr) { XcursorImageDestroy(img[i]); } - }; + } if (xim) { XCloseIM(xim); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 8e963238e3..65d53b266f 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -238,7 +238,7 @@ void JoypadLinux::close_joypad(int p_id) { if (p_id == -1) { for (int i = 0; i < JOYPADS_MAX; i++) { close_joypad(i); - }; + } return; } else if (p_id < 0) { return; @@ -251,7 +251,7 @@ void JoypadLinux::close_joypad(int p_id) { joy.fd = -1; attached_devices.remove_at(attached_devices.find(joy.devpath)); input->joy_connection_changed(p_id, false, ""); - }; + } } static String _hex_str(uint8_t p_byte) { @@ -516,7 +516,7 @@ void JoypadLinux::process_joypads() { } if (len == 0 || (len < 0 && errno != EAGAIN)) { close_joypad(i); - }; + } if (joy->force_feedback) { uint64_t timestamp = input->get_joy_vibration_timestamp(i); diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 5e8656c79f..d876932a83 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -356,7 +356,7 @@ void OS_LinuxBSD::run() { if (Main::iteration()) { break; } - }; + } main_loop->finalize(); } diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp index e2fd8c76d2..b4f585726f 100644 --- a/platform/linuxbsd/vulkan_context_x11.cpp +++ b/platform/linuxbsd/vulkan_context_x11.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "vulkan_context_x11.h" + #ifdef USE_VOLK #include <volk.h> #else diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm index 3e640b3bf3..06ed91907c 100644 --- a/platform/osx/crash_handler_osx.mm +++ b/platform/osx/crash_handler_osx.mm @@ -89,8 +89,9 @@ static void handle_crash(int sig) { fprintf(stderr, "\n================================================================\n"); fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig); - if (OS::get_singleton()->get_main_loop()) + if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH); + } // Print the engine version just before, so that people are reminded to include the version in backtrace reports. if (String(VERSION_HASH).is_empty()) { @@ -119,8 +120,9 @@ static void handle_crash(int sig) { snprintf(fname, 1024, "%s", demangled); } - if (demangled) + if (demangled) { free(demangled); + } } } @@ -177,8 +179,9 @@ CrashHandler::~CrashHandler() { } void CrashHandler::disable() { - if (disabled) + if (disabled) { return; + } #ifdef CRASH_HANDLER_ENABLED signal(SIGSEGV, nullptr); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index b7258e6cf4..b2201eabbc 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -790,8 +790,9 @@ String DisplayServerOSX::global_menu_get_item_submenu(const String &p_menu_root, const NSMenu *sub_menu = [menu_item submenu]; if (sub_menu) { for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) { - if (E->get() == sub_menu) + if (E->get() == sub_menu) { return E->key(); + } } } } diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm index 7fabfaa1b7..f3db363151 100644 --- a/platform/osx/godot_main_osx.mm +++ b/platform/osx/godot_main_osx.mm @@ -49,7 +49,7 @@ int main(int argc, char **argv) { first_arg = i + 2; } printf("%i: %s\n", i, argv[i]); - }; + } #ifdef DEBUG_ENABLED // Lets report the path we made current after all that. @@ -84,4 +84,4 @@ int main(int argc, char **argv) { Main::cleanup(); return os.get_exit_code(); -}; +} diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index d518206f04..7d31ede61d 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -322,10 +322,11 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { // Bluetooth device. String guid = "05000000"; for (int i = 0; i < 12; i++) { - if (i < name.size()) + if (i < name.size()) { guid += _hex_str(name[i]); - else + } else { guid += "00"; + } } input->joy_connection_changed(id, true, name, guid); } @@ -381,8 +382,9 @@ bool joypad::check_ff_features() { if (ret == FF_OK && (features.supportedEffects & FFCAP_ET_CONSTANTFORCE)) { uint32_t val; ret = FFDeviceGetForceFeedbackProperty(ff_device, FFPROP_FFGAIN, &val, sizeof(val)); - if (ret != FF_OK) + if (ret != FF_OK) { return false; + } int num_axes = features.numFfAxes; ff_axes = (DWORD *)memalloc(sizeof(DWORD) * num_axes); ff_directions = (LONG *)memalloc(sizeof(LONG) * num_axes); @@ -509,16 +511,18 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { int JoypadOSX::get_joy_index(int p_id) const { for (int i = 0; i < device_list.size(); i++) { - if (device_list[i].id == p_id) + if (device_list[i].id == p_id) { return i; + } } return -1; } int JoypadOSX::get_joy_ref(IOHIDDeviceRef p_device) const { for (int i = 0; i < device_list.size(); i++) { - if (device_list[i].device_ref == p_device) + if (device_list[i].device_ref == p_device) { return i; + } } return -1; } diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 868721e875..6700f8fe82 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -441,7 +441,7 @@ void OS_OSX::run() { } @catch (NSException *exception) { ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String)); } - }; + } main_loop->finalize(); } diff --git a/platform/osx/osx_terminal_logger.mm b/platform/osx/osx_terminal_logger.mm index c1dca111a7..48e26f42bf 100644 --- a/platform/osx/osx_terminal_logger.mm +++ b/platform/osx/osx_terminal_logger.mm @@ -40,10 +40,11 @@ void OSXTerminalLogger::log_error(const char *p_function, const char *p_file, in } const char *err_details; - if (p_rationale && p_rationale[0]) + if (p_rationale && p_rationale[0]) { err_details = p_rationale; - else + } else { err_details = p_code; + } switch (p_type) { case ERR_WARNING: diff --git a/platform/uwp/app_uwp.cpp b/platform/uwp/app_uwp.cpp index 6832d71a6f..6460c43447 100644 --- a/platform/uwp/app_uwp.cpp +++ b/platform/uwp/app_uwp.cpp @@ -177,7 +177,7 @@ static MouseButton _get_button(Windows::UI::Input::PointerPoint ^ pt) { #endif return MOUSE_BUTTON_NONE; -}; +} static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP @@ -231,11 +231,11 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windo outputPosition.Y *= vm.height; return outputPosition; -}; +} static int _get_finger(uint32_t p_touch_id) { return p_touch_id % 31; // for now -}; +} void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed, bool p_is_wheel) { Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint; @@ -281,15 +281,15 @@ void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Cor os->input_event(mouse_button); } } -}; +} void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, true); -}; +} void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, false); -}; +} void App::OnPointerWheelChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, true, true); @@ -416,8 +416,9 @@ void App::Load(Platform::String ^ entryPoint) { // This method is called after the window becomes active. void App::Run() { - if (Main::start()) + if (Main::start()) { os->run(); + } } // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp index a08693c72f..8ec7bdfcee 100644 --- a/platform/uwp/context_egl_uwp.cpp +++ b/platform/uwp/context_egl_uwp.cpp @@ -36,26 +36,26 @@ using Platform::Exception; void ContextEGL_UWP::release_current() { eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext); -}; +} void ContextEGL_UWP::make_current() { eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); -}; +} int ContextEGL_UWP::get_window_width() { return width; -}; +} int ContextEGL_UWP::get_window_height() { return height; -}; +} void ContextEGL_UWP::reset() { cleanup(); window = CoreWindow::GetForCurrentThread(); initialize(); -}; +} void ContextEGL_UWP::swap_buffers() { if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) { @@ -66,7 +66,7 @@ void ContextEGL_UWP::swap_buffers() { // tell rasterizer to reload textures and stuff? } -}; +} Error ContextEGL_UWP::initialize() { EGLint configAttribList[] = { @@ -170,7 +170,7 @@ Error ContextEGL_UWP::initialize() { } } catch (...) { return FAILED; - }; + } mEglDisplay = display; mEglSurface = surface; @@ -180,7 +180,7 @@ Error ContextEGL_UWP::initialize() { eglQuerySurface(display, surface, EGL_HEIGHT, &height); return OK; -}; +} void ContextEGL_UWP::cleanup() { if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) { @@ -197,7 +197,7 @@ void ContextEGL_UWP::cleanup() { eglTerminate(mEglDisplay); mEglDisplay = EGL_NO_DISPLAY; } -}; +} ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) : mEglDisplay(EGL_NO_DISPLAY), @@ -209,4 +209,4 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) : ContextEGL_UWP::~ContextEGL_UWP() { cleanup(); -}; +} diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index e48016919b..85c8959cf1 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "joypad_uwp.h" + #include "core/os/os.h" using namespace Windows::Gaming::Input; @@ -45,8 +46,9 @@ void JoypadUWP::process_controllers() { for (int i = 0; i < MAX_CONTROLLERS; i++) { ControllerDevice &joy = controllers[i]; - if (!joy.connected) + if (!joy.connected) { break; + } switch (joy.type) { case ControllerType::GAMEPAD_CONTROLLER: { @@ -76,8 +78,9 @@ void JoypadUWP::process_controllers() { } } else if (joy.vibrating && joy.ff_end_timestamp != 0) { uint64_t current_time = OS::get_singleton()->get_ticks_usec(); - if (current_time >= joy.ff_end_timestamp) + if (current_time >= joy.ff_end_timestamp) { joypad_vibration_stop(i, current_time); + } } break; @@ -87,8 +90,9 @@ void JoypadUWP::process_controllers() { } JoypadUWP::JoypadUWP() { - for (int i = 0; i < MAX_CONTROLLERS; i++) + for (int i = 0; i < MAX_CONTROLLERS; i++) { controllers[i].id = i; + } } JoypadUWP::JoypadUWP(InputDefault *p_input) { diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index b6dde9c63f..22a54911f9 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -95,12 +95,12 @@ void OS_UWP::set_window_fullscreen(bool p_enabled) { video_mode.fullscreen = view->IsFullScreenMode; - if (video_mode.fullscreen == p_enabled) + if (video_mode.fullscreen == p_enabled) { return; + } if (p_enabled) { video_mode.fullscreen = view->TryEnterFullScreenMode(); - } else { view->ExitFullScreenMode(); video_mode.fullscreen = false; @@ -112,13 +112,15 @@ bool OS_UWP::is_window_fullscreen() const { } void OS_UWP::set_keep_screen_on(bool p_enabled) { - if (is_keep_screen_on() == p_enabled) + if (is_keep_screen_on() == p_enabled) { return; + } - if (p_enabled) + if (p_enabled) { display_request->RequestActive(); - else + } else { display_request->RequestRelease(); + } OS::set_keep_screen_on(p_enabled); } @@ -150,7 +152,7 @@ void OS_UWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) { void OS_UWP::screen_size_changed() { gl_context->reset(); -}; +} Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { main_loop = nullptr; @@ -269,8 +271,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a _ensure_user_data_dir(); - if (is_keep_screen_on()) + if (is_keep_screen_on()) { display_request->RequestActive(); + } set_keep_screen_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)); @@ -283,22 +286,24 @@ void OS_UWP::set_clipboard(const String &p_text) { clip->SetText(ref new Platform::String((LPCWSTR)(p_text.utf16().get_data()))); Clipboard::SetContent(clip); -}; +} String OS_UWP::get_clipboard() const { - if (managed_object->clipboard != nullptr) + if (managed_object->clipboard != nullptr) { return managed_object->clipboard->Data(); - else + } else { return ""; -}; + } +} void OS_UWP::input_event(const Ref<InputEvent> &p_event) { input->parse_input_event(p_event); -}; +} void OS_UWP::delete_main_loop() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -308,16 +313,18 @@ void OS_UWP::set_main_loop(MainLoop *p_main_loop) { } void OS_UWP::finalize() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; rendering_server->finish(); memdelete(rendering_server); #ifdef GLES3_ENABLED - if (gl_context) + if (gl_context) { memdelete(gl_context); + } #endif memdelete(input); @@ -472,8 +479,9 @@ OS::Time OS_UWP::get_time(bool p_utc) const { OS::TimeZoneInfo OS_UWP::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; - if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) + if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { daylight = true; + } TimeZoneInfo ret; if (daylight) { @@ -507,7 +515,7 @@ uint64_t OS_UWP::get_unix_time() const { SystemTimeToFileTime(&ep, &fep); return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000; -}; +} void OS_UWP::delay_usec(uint32_t p_usec) const { int msec = p_usec < 1000 ? 1 : p_usec / 1000; @@ -590,8 +598,9 @@ void OS_UWP::queue_key_event(KeyEvent &p_event) { void OS_UWP::set_cursor_shape(CursorShape p_shape) { ERR_FAIL_INDEX(p_shape, CURSOR_MAX); - if (cursor_shape == p_shape) + if (cursor_shape == p_shape) { return; + } static const CoreCursorType uwp_cursors[CURSOR_MAX] = { CoreCursorType::Arrow, @@ -628,15 +637,15 @@ void OS_UWP::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c Error OS_UWP::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) { return FAILED; -}; +} Error OS_UWP::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { return FAILED; -}; +} Error OS_UWP::kill(const ProcessID &p_pid) { return FAILED; -}; +} Error OS_UWP::set_cwd(const String &p_cwd) { return FAILED; @@ -651,11 +660,11 @@ void OS_UWP::set_icon(const Ref<Image> &p_icon) { bool OS_UWP::has_environment(const String &p_var) const { return false; -}; +} String OS_UWP::get_environment(const String &p_var) const { return ""; -}; +} bool OS_UWP::set_environment(const String &p_var, const String &p_value) const { return false; @@ -751,8 +760,9 @@ Error OS_UWP::get_dynamic_library_symbol_handle(void *p_library_handle, const St } void OS_UWP::run() { - if (!main_loop) + if (!main_loop) { return; + } main_loop->init(); @@ -763,12 +773,14 @@ void OS_UWP::run() { while (!force_quit) { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); - if (managed_object->alert_close_handle) + if (managed_object->alert_close_handle) { continue; + } process_events(); // get rid of pending events - if (Main::iteration()) + if (Main::iteration()) { break; - }; + } + } main_loop->finish(); } diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp index 5064f6b97f..3b2c6fe9f6 100644 --- a/platform/windows/crash_handler_windows.cpp +++ b/platform/windows/crash_handler_windows.cpp @@ -80,8 +80,9 @@ public: std::string name() { return std::string(sym->Name); } std::string undecorated_name() { - if (*sym->Name == '\0') + if (*sym->Name == '\0') { return "<couldn't map PC to fn name>"; + } std::vector<char> und_name(max_name_len); UnDecorateSymbolName(sym->Name, &und_name[0], max_name_len, UNDNAME_COMPLETE); return std::string(&und_name[0], strlen(&und_name[0])); @@ -131,12 +132,14 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { fprintf(stderr, "\n================================================================\n"); fprintf(stderr, "%s: Program crashed\n", __FUNCTION__); - if (OS::get_singleton()->get_main_loop()) + if (OS::get_singleton()->get_main_loop()) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH); + } // Load the symbols: - if (!SymInitialize(process, nullptr, false)) + if (!SymInitialize(process, nullptr, false)) { return EXCEPTION_CONTINUE_SEARCH; + } SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); EnumProcessModules(process, &module_handles[0], module_handles.size() * sizeof(HMODULE), &cbNeeded); @@ -193,18 +196,21 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { if (frame.AddrPC.Offset != 0) { std::string fnName = symbol(process, frame.AddrPC.Offset).undecorated_name(); - if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) + if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &offset_from_symbol, &line)) { fprintf(stderr, "[%d] %s (%s:%d)\n", n, fnName.c_str(), line.FileName, line.LineNumber); - else + } else { fprintf(stderr, "[%d] %s\n", n, fnName.c_str()); - } else + } + } else { fprintf(stderr, "[%d] ???\n", n); + } n++; } - if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) + if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) { break; + } } while (frame.AddrReturn.Offset != 0 && n < 256); fprintf(stderr, "-- END OF BACKTRACE --\n"); @@ -225,8 +231,9 @@ CrashHandler::~CrashHandler() { } void CrashHandler::disable() { - if (disabled) + if (disabled) { return; + } disabled = true; } diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index c7955ebf31..2f0b3b4490 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -231,7 +231,7 @@ String DisplayServerWindows::clipboard_get() const { String ret; if (!OpenClipboard(windows[last_focused_window].hWnd)) { ERR_FAIL_V_MSG("", "Unable to open clipboard."); - }; + } if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); @@ -240,8 +240,8 @@ String DisplayServerWindows::clipboard_get() const { if (ptr != nullptr) { ret = String::utf16((const char16_t *)ptr); GlobalUnlock(mem); - }; - }; + } + } } else if (IsClipboardFormatAvailable(CF_TEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); @@ -250,9 +250,9 @@ String DisplayServerWindows::clipboard_get() const { if (ptr != nullptr) { ret.parse_utf8((const char *)ptr); GlobalUnlock(mem); - }; - }; - }; + } + } + } CloseClipboard(); @@ -422,8 +422,9 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr; if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) { - if (Shcore) + if (Shcore) { FreeLibrary(Shcore); + } Shcore = (HMODULE)INVALID_HANDLE_VALUE; } } @@ -1326,8 +1327,9 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI wd.im_position = p_pos; HIMC himc = ImmGetContext(wd.hWnd); - if (himc == (HIMC)0) + if (himc == (HIMC)0) { return; + } COMPOSITIONFORM cps; cps.dwStyle = CFS_FORCE_POSITION; @@ -2026,7 +2028,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else { return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - }; + } WindowID window_id = INVALID_WINDOW_ID; bool window_created = false; @@ -2131,8 +2133,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case SC_MONITORPOWER: // Monitor trying to enter powersave? return 0; // Prevent from happening. case SC_KEYMENU: - if ((lParam >> 16) <= 0) + if ((lParam >> 16) <= 0) { return 0; + } } } break; case WM_CLOSE: // Did we receive a close message? @@ -2164,8 +2167,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA return 0; } - if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) + if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) { OutputDebugString(TEXT("GetRawInputData does not return correct size !\n")); + } RAWINPUT *raw = (RAWINPUT *)lpb; @@ -2260,8 +2264,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA ScreenToClient(windows[window_id].hWnd, &coords); // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode. - if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) + if (!windows[window_id].window_has_focus && mouse_mode == MOUSE_MODE_CAPTURED) { break; + } Ref<InputEventMouseMotion> mm; mm.instantiate(); @@ -2306,8 +2311,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y))); old_x = mm->get_position().x; old_y = mm->get_position().y; - if (windows[window_id].window_has_focus) + if (windows[window_id].window_has_focus) { Input::get_singleton()->parse_input_event(mm); + } } return 0; } @@ -2547,8 +2553,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_relative(Vector2(mm->get_position() - Vector2(old_x, old_y))); old_x = mm->get_position().x; old_y = mm->get_position().y; - if (windows[window_id].window_has_focus) + if (windows[window_id].window_has_focus) { Input::get_singleton()->parse_input_event(mm); + } } break; case WM_LBUTTONDOWN: @@ -2694,8 +2701,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (uMsg != WM_MOUSEWHEEL && uMsg != WM_MOUSEHWHEEL) { if (mb->is_pressed()) { - if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) + if (++pressrc > 0 && mouse_mode != MOUSE_MODE_CAPTURED) { SetCapture(hWnd); + } } else { if (--pressrc <= 0) { if (mouse_mode != MOUSE_MODE_CAPTURED) { @@ -2823,14 +2831,17 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_SYSKEYUP: case WM_KEYUP: case WM_KEYDOWN: { - if (wParam == VK_SHIFT) + if (wParam == VK_SHIFT) { shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); - if (wParam == VK_CONTROL) + } + if (wParam == VK_CONTROL) { control_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); + } if (wParam == VK_MENU) { alt_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); - if (lParam & (1 << 24)) + if (lParam & (1 << 24)) { gr_mem = alt_mem; + } } if (mouse_mode == MOUSE_MODE_CAPTURED) { @@ -2839,10 +2850,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); } } - /* - if (wParam==VK_WIN) TODO wtf is this? - meta_mem=uMsg==WM_KEYDOWN; - */ [[fallthrough]]; } case WM_CHAR: { @@ -2857,10 +2864,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA ke.uMsg = uMsg; ke.window_id = window_id; - if (ke.uMsg == WM_SYSKEYDOWN) + if (ke.uMsg == WM_SYSKEYDOWN) { ke.uMsg = WM_KEYDOWN; - if (ke.uMsg == WM_SYSKEYUP) + } + if (ke.uMsg == WM_SYSKEYUP) { ke.uMsg = WM_KEYUP; + } ke.wParam = wParam; ke.lParam = lParam; @@ -2888,7 +2897,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA _drag_event(window_id, touch_pos.x, touch_pos.y, ti.dwID); } else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) { _touch_event(window_id, ti.dwFlags & TOUCHEVENTF_DOWN, touch_pos.x, touch_pos.y, ti.dwID); - }; + } } bHandled = TRUE; } else { @@ -2901,7 +2910,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (bHandled) { CloseTouchInputHandle((HTOUCHINPUT)lParam); return 0; - }; + } } break; case WM_DEVICECHANGE: { @@ -2955,8 +2964,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA default: { if (user_proc) { return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam); - }; - }; + } + } } return DefWindowProcW(hWnd, uMsg, wParam, lParam); @@ -2964,10 +2973,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton()); - if (ds_win) + if (ds_win) { return ds_win->WndProc(hWnd, uMsg, wParam, lParam); - else + } else { return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } } void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM wParam, LPARAM lParam) { @@ -3034,8 +3044,9 @@ void DisplayServerWindows::_process_key_events() { k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) + if (k->get_unicode() < 32) { k->set_unicode(0); + } Input::get_singleton()->parse_input_event(k); } else { @@ -3090,8 +3101,9 @@ void DisplayServerWindows::_process_key_events() { k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) + if (k->get_unicode() < 32) { k->set_unicode(0); + } k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30)))); @@ -3395,7 +3407,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win wc.cbWndExtra = 0; wc.hInstance = hInstance ? hInstance : GetModuleHandle(nullptr); wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); - wc.hCursor = nullptr; //LoadCursor(nullptr, IDC_ARROW); + wc.hCursor = nullptr; wc.hbrBackground = nullptr; wc.lpszMenuName = nullptr; wc.lpszClassName = L"Engine"; @@ -3446,7 +3458,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win return; } - // gl_manager->set_use_vsync(current_videomode.use_vsync); + //gl_manager->set_use_vsync(current_videomode.use_vsync); RasterizerGLES3::make_current(); } #endif @@ -3476,14 +3488,13 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } #endif - //set_ime_active(false); - if (!OS::get_singleton()->is_in_low_processor_usage_mode()) { SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); DWORD index = 0; HANDLE handle = AvSetMmThreadCharacteristics("Games", &index); - if (handle) + if (handle) { AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL); + } // This is needed to make sure that background work does not starve the main thread. // This is only setting the priority of this thread, not the whole process. @@ -3537,10 +3548,10 @@ DisplayServerWindows::~DisplayServerWindows() { if (user_proc) { SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); - }; + } #ifdef GLES3_ENABLED - // destroy windows .. NYI? + // destroy windows .. NYI? #endif if (windows.has(MAIN_WINDOW_ID)) { diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index 74b5f48502..a97fa99d7f 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -56,14 +56,9 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int int GLManager_Windows::_find_or_create_display(GLWindow &win) { // find display NYI, only 1 supported so far - if (_displays.size()) + if (_displays.size()) { return 0; - - // for (unsigned int n = 0; n < _displays.size(); n++) { - // const GLDisplay &d = _displays[n]; - // if (d.x11_display == p_x11_display) - // return n; - // } + } // create GLDisplay d_temp = {}; @@ -230,23 +225,27 @@ void GLManager_Windows::window_destroy(DisplayServer::WindowID p_window_id) { } void GLManager_Windows::release_current() { - if (!_current_window) + if (!_current_window) { return; + } wglMakeCurrent(_current_window->hDC, nullptr); } void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) { - if (p_window_id == -1) + if (p_window_id == -1) { return; + } GLWindow &win = _windows[p_window_id]; - if (!win.in_use) + if (!win.in_use) { return; + } // noop - if (&win == _current_window) + if (&win == _current_window) { return; + } const GLDisplay &disp = get_display(win.gldisplay_id); wglMakeCurrent(win.hDC, disp.hRC); @@ -255,8 +254,9 @@ void GLManager_Windows::window_make_current(DisplayServer::WindowID p_window_id) } void GLManager_Windows::make_current() { - if (!_current_window) + if (!_current_window) { return; + } if (!_current_window->in_use) { WARN_PRINT("current window not in use!"); return; @@ -269,8 +269,9 @@ void GLManager_Windows::swap_buffers() { // NO NEED TO CALL SWAP BUFFERS for each window... // see https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXSwapBuffers.xml - if (!_current_window) + if (!_current_window) { return; + } if (!_current_window->in_use) { WARN_PRINT("current window not in use!"); return; @@ -304,12 +305,15 @@ void GLManager_Windows::set_use_vsync(bool p_use) { if (!setup) { setup = true; String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display)); - if (extensions.find("GLX_EXT_swap_control") != -1) + if (extensions.find("GLX_EXT_swap_control") != -1) { glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalEXT"); - if (extensions.find("GLX_MESA_swap_control") != -1) + } + if (extensions.find("GLX_MESA_swap_control") != -1) { glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA"); - if (extensions.find("GLX_SGI_swap_control") != -1) + } + if (extensions.find("GLX_SGI_swap_control") != -1) { glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI"); + } } int val = p_use ? 1 : 0; if (glXSwapIntervalMESA) { @@ -319,8 +323,9 @@ void GLManager_Windows::set_use_vsync(bool p_use) { } else if (glXSwapIntervalEXT) { GLXDrawable drawable = glXGetCurrentDrawable(); glXSwapIntervalEXT(x11_display, drawable, val); - } else + } else { return; + } use_vsync = p_use; */ } diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp index 618d5670d2..ad4e3ae77c 100644 --- a/platform/windows/godot_windows.cpp +++ b/platform/windows/godot_windows.cpp @@ -163,8 +163,9 @@ int widechar_main(int argc, wchar_t **argv) { return 255; } - if (Main::start()) + if (Main::start()) { os.run(); + } Main::cleanup(); for (int i = 0; i < argc; ++i) { @@ -173,7 +174,7 @@ int widechar_main(int argc, wchar_t **argv) { delete[] argv_utf8; return os.get_exit_code(); -}; +} int _main() { LPWSTR *wc_argv; diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index b0dd86a4b7..494e0b9105 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -60,8 +60,9 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { load_xinput(); - for (int i = 0; i < JOYPADS_MAX; i++) + for (int i = 0; i < JOYPADS_MAX; i++) { attached_joypads[i] = false; + } HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr); if (result == DI_OK) { @@ -144,8 +145,9 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { HRESULT hr; int num = input->get_unused_joy_id(); - if (have_device(instance->guidInstance) || num == -1) + if (have_device(instance->guidInstance) || num == -1) { return false; + } d_joypads[num] = dinput_gamepad(); dinput_gamepad *joy = &d_joypads[num]; @@ -196,27 +198,28 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ DIPROPRANGE prop_range; DIPROPDWORD dilong; LONG ofs; - if (ob->guidType == GUID_XAxis) + if (ob->guidType == GUID_XAxis) { ofs = DIJOFS_X; - else if (ob->guidType == GUID_YAxis) + } else if (ob->guidType == GUID_YAxis) { ofs = DIJOFS_Y; - else if (ob->guidType == GUID_ZAxis) + } else if (ob->guidType == GUID_ZAxis) { ofs = DIJOFS_Z; - else if (ob->guidType == GUID_RxAxis) + } else if (ob->guidType == GUID_RxAxis) { ofs = DIJOFS_RX; - else if (ob->guidType == GUID_RyAxis) + } else if (ob->guidType == GUID_RyAxis) { ofs = DIJOFS_RY; - else if (ob->guidType == GUID_RzAxis) + } else if (ob->guidType == GUID_RzAxis) { ofs = DIJOFS_RZ; - else if (ob->guidType == GUID_Slider) { + } else if (ob->guidType == GUID_Slider) { if (slider_count < 2) { ofs = DIJOFS_SLIDER(slider_count); slider_count++; } else { return; } - } else + } else { return; + } prop_range.diph.dwSize = sizeof(DIPROPRANGE); prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); prop_range.diph.dwObj = ob->dwType; @@ -227,8 +230,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ dinput_gamepad &joy = d_joypads[p_joy_id]; res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_RANGE, &prop_range.diph); - if (FAILED(res)) + if (FAILED(res)) { return; + } dilong.diph.dwSize = sizeof(dilong); dilong.diph.dwHeaderSize = sizeof(dilong.diph); @@ -237,8 +241,9 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_ dilong.dwData = 0; res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_DEADZONE, &dilong.diph); - if (FAILED(res)) + if (FAILED(res)) { return; + } joy.joy_axis.push_back(ofs); } @@ -268,8 +273,9 @@ void JoypadWindows::close_joypad(int id) { return; } - if (!d_joypads[id].attached) + if (!d_joypads[id].attached) { return; + } d_joypads[id].di_joy->Unacquire(); d_joypads[id].di_joy->Release(); @@ -355,16 +361,18 @@ void JoypadWindows::process_joypads() { } } else if (joy.vibrating && joy.ff_end_timestamp != 0) { uint64_t current_time = OS::get_singleton()->get_ticks_usec(); - if (current_time >= joy.ff_end_timestamp) + if (current_time >= joy.ff_end_timestamp) { joypad_vibration_stop_xinput(i, current_time); + } } } for (int i = 0; i < JOYPADS_MAX; i++) { dinput_gamepad *joy = &d_joypads[i]; - if (!joy->attached) + if (!joy->attached) { continue; + } DIJOYSTATE2 js; hr = joy->di_joy->Poll(); @@ -404,9 +412,9 @@ void JoypadWindows::process_joypads() { if (joy->joy_axis[j] == axes[k]) { input->joy_axis(joy->id, (JoyAxis)j, axis_correct(values[k])); break; - }; - }; - }; + } + } + } } return; } @@ -446,7 +454,7 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) { dpad_val = (HatMask)(HatMask::LEFT | HatMask::UP); } input->joy_hat(p_device, dpad_val); -}; +} float JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { if (Math::abs(p_val) < MIN_JOY_AXIS) { diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index 0e3d03fa52..4f15bcf080 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -86,8 +86,9 @@ private: attached = false; confirmed = false; - for (int i = 0; i < MAX_JOY_BUTTONS; i++) + for (int i = 0; i < MAX_JOY_BUTTONS; i++) { last_buttons[i] = false; + } } }; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 99c9712834..13e3aa7883 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -107,8 +107,9 @@ void RedirectIOToConsole() { } BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { - if (!EngineDebugger::is_active()) + if (!EngineDebugger::is_active()) { return FALSE; + } switch (dwCtrlType) { case CTRL_C_EVENT: @@ -166,8 +167,9 @@ void OS_Windows::initialize() { } void OS_Windows::delete_main_loop() { - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -180,8 +182,9 @@ void OS_Windows::finalize() { driver_midi.close(); #endif - if (main_loop) + if (main_loop) { memdelete(main_loop); + } main_loop = nullptr; } @@ -288,8 +291,9 @@ OS::Time OS_Windows::get_time(bool p_utc) const { OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { TIME_ZONE_INFORMATION info; bool daylight = false; - if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) + if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { daylight = true; + } TimeZoneInfo ret; if (daylight) { @@ -322,10 +326,11 @@ double OS_Windows::get_unix_time() const { } void OS_Windows::delay_usec(uint32_t p_usec) const { - if (p_usec < 1000) + if (p_usec < 1000) { Sleep(1); - else + } else { Sleep(p_usec / 1000); + } } uint64_t OS_Windows::get_ticks_usec() const { @@ -430,7 +435,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (p_pipe_mutex) { p_pipe_mutex->unlock(); } - }; + } CloseHandle(pipe[0]); // Close pipe read handle. } else { WaitForSingleObject(pi.pi.hProcess, INFINITE); @@ -446,7 +451,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, CloseHandle(pi.pi.hThread); return OK; -}; +} Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id, bool p_open_console) { String path = p_path.replace("/", "\\"); @@ -478,7 +483,7 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg process_map->insert(pid, pi); return OK; -}; +} Error OS_Windows::kill(const ProcessID &p_pid) { ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); @@ -492,15 +497,16 @@ Error OS_Windows::kill(const ProcessID &p_pid) { CloseHandle(pi.hThread); return ret != 0 ? OK : FAILED; -}; +} int OS_Windows::get_process_id() const { return _getpid(); } Error OS_Windows::set_cwd(const String &p_cwd) { - if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) + if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) { return ERR_CANT_OPEN; + } return OK; } @@ -523,7 +529,7 @@ bool OS_Windows::has_environment(const String &p_var) const { free(env); return has_env; #endif -}; +} String OS_Windows::get_environment(const String &p_var) const { WCHAR wval[0x7fff]; // MSDN says 32767 char is the maximum @@ -542,7 +548,7 @@ String OS_Windows::get_stdin_string(bool p_block) { if (p_block) { char buff[1024]; return fgets(buff, 1024, stdin); - }; + } return String(); } @@ -580,17 +586,20 @@ String OS_Windows::get_locale() const { int sublang = SUBLANGID(langid); while (wl->locale) { - if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL) + if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL) { neutral = wl->locale; + } - if (lang == wl->main_lang && sublang == wl->sublang) + if (lang == wl->main_lang && sublang == wl->sublang) { return String(wl->locale).replace("-", "_"); + } wl++; } - if (!neutral.is_empty()) + if (!neutral.is_empty()) { return String(neutral).replace("-", "_"); + } return "en"; } @@ -617,10 +626,11 @@ BOOL is_wow64() { int OS_Windows::get_processor_count() const { SYSTEM_INFO sysinfo; - if (is_wow64()) + if (is_wow64()) { GetNativeSystemInfo(&sysinfo); - else + } else { GetSystemInfo(&sysinfo); + } return sysinfo.dwNumberOfProcessors; } @@ -646,16 +656,18 @@ String OS_Windows::get_processor_name() const { } void OS_Windows::run() { - if (!main_loop) + if (!main_loop) { return; + } main_loop->initialize(); while (!force_quit) { DisplayServer::get_singleton()->process_events(); // get rid of pending events - if (Main::iteration()) + if (Main::iteration()) { break; - }; + } + } main_loop->finalize(); } diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 0d5f0e617c..df21977698 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -44,25 +44,29 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er const unsigned int BUFFER_SIZE = 16384; char buf[BUFFER_SIZE + 1]; // +1 for the terminating character int len = vsnprintf(buf, BUFFER_SIZE, p_format, p_list); - if (len <= 0) + if (len <= 0) { return; - if ((unsigned int)len >= BUFFER_SIZE) + } + if ((unsigned int)len >= BUFFER_SIZE) { len = BUFFER_SIZE; // Output is too big, will be truncated + } buf[len] = 0; int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, nullptr, 0); - if (wlen < 0) + if (wlen < 0) { return; + } wchar_t *wbuf = (wchar_t *)memalloc((len + 1) * sizeof(wchar_t)); ERR_FAIL_NULL_MSG(wbuf, "Out of memory."); MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen); wbuf[wlen] = 0; - if (p_err) + if (p_err) { fwprintf(stderr, L"%ls", wbuf); - else + } else { wprintf(L"%ls", wbuf); + } memfree(wbuf); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 1f4dec6864..1fe4adb4db 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -428,15 +428,6 @@ Vector<Color> Polygon2D::get_vertex_colors() const { void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; - - /*if (texture.is_valid()) { - uint32_t flags=texture->get_flags(); - flags&=~Texture::FLAG_REPEAT; - if (tex_tile) - flags|=Texture::FLAG_REPEAT; - - texture->set_flags(flags); - }*/ update(); } diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 375692d049..4eace17cc0 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -82,12 +82,6 @@ void Camera3D::_update_camera() { RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform()); - // here goes listener stuff - /* - if (viewport_ptr && is_inside_scene() && is_current()) - get_viewport()->_camera_3d_transform_changed_notify(); - */ - if (get_tree()->is_node_being_edited(this) || !is_current()) { return; } diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 2488bfb8ba..855922c341 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -192,7 +192,6 @@ void QuadOccluder3D::set_size(const Vector2 &p_size) { } size = p_size.max(Vector2()); - ; _update(); } @@ -237,7 +236,6 @@ void BoxOccluder3D::set_size(const Vector3 &p_size) { } size = Vector3(MAX(p_size.x, 0.0f), MAX(p_size.y, 0.0f), MAX(p_size.z, 0.0f)); - ; _update(); } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 68c9ff8ece..b9fb3e9287 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -696,10 +696,6 @@ Rect2 Sprite3D::get_item_rect() const { if (texture.is_null()) { return Rect2(0, 0, 1, 1); } - /* - if (texture.is_null()) - return CanvasItem::get_item_rect(); - */ Size2 s; diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index a5fd3a7dd0..8d02d26fc4 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -116,9 +116,7 @@ TypedArray<String> VehicleWheel3D::get_configuration_warnings() const { } void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { - if (m_raycastInfo.m_isInContact) - - { + if (m_raycastInfo.m_isInContact) { real_t project = m_raycastInfo.m_contactNormalWS.dot(m_raycastInfo.m_wheelDirectionWS); Vector3 chassis_velocity_at_contactPoint; Vector3 relpos = m_raycastInfo.m_contactPointWS - s->get_transform().origin; @@ -135,11 +133,7 @@ void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { m_suspensionRelativeVelocity = projVel * inv; m_clippedInvContactDotSuspension = inv; } - - } - - else // Not in contact : position wheel in a nice (rest length) position - { + } else { // Not in contact : position wheel in a nice (rest length) position m_raycastInfo.m_suspensionLength = m_suspensionRestLength; m_suspensionRelativeVelocity = real_t(0.0); m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 7ad76e43a2..e243915c13 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -595,18 +595,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE || (p_delta == 0 && update_mode == Animation::UPDATE_DISCRETE)) { //delta == 0 means seek - Variant value = a->value_track_interpolate(i, p_time); if (value == Variant()) { continue; } - //thanks to trigger mode, this should be solved now.. - /* - if (p_delta==0 && value.get_type()==Variant::STRING) - continue; // doing this with strings is messy, should find another way - */ if (pa->accum_pass != accum_pass) { ERR_CONTINUE(cache_update_prop_size >= NODE_CACHE_UPDATE_MAX); cache_update_prop[cache_update_prop_size++] = pa; diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 7940056e2f..4f34ece86f 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -95,10 +95,6 @@ void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { } texture = p_tex; update(); - /* - if (texture.is_valid()) - texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites - */ update_minimum_size(); emit_signal(SceneStringNames::get_singleton()->texture_changed); } diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index b04cb39920..e1b0e8cca8 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -426,11 +426,6 @@ double ScrollBar::get_grabber_size() const { } float page = (get_page() > 0) ? get_page() : 0; - /* - if (grabber_range < get_step()) - grabber_range=get_step(); - */ - double area_size = get_area_size(); double grabber_size = page / range * area_size; return grabber_size + get_grabber_min_size(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index fc0258a760..73cf2b9c6e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1701,8 +1701,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 bool skip = (p_item == root && hide_root); if (!skip && (p_pos.y + label_h - cache.offset.y) > 0) { - //draw separation. - //if (p_item->get_parent()!=root || !hide_root) + // Draw separation. ERR_FAIL_COND_V(cache.font.is_null(), -1); @@ -2259,11 +2258,6 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c emit_signal(SNAME("item_selected")); emitted_row = true; } - /* - if (p_col==i) - p_current->selected_signal.call(p_col); - */ - } else if (c.selected) { if (p_selected != p_current) { // Deselect other rows. @@ -4065,10 +4059,6 @@ int Tree::get_edited_column() const { } TreeItem *Tree::get_next_selected(TreeItem *p_item) { - /* - if (!p_item) - return nullptr; - */ if (!root) { return nullptr; } diff --git a/scene/gui/video_stream_player.cpp b/scene/gui/video_stream_player.cpp index 17dd3123f5..d7c76aa070 100644 --- a/scene/gui/video_stream_player.cpp +++ b/scene/gui/video_stream_player.cpp @@ -240,11 +240,11 @@ void VideoStreamPlayer::set_stream(const Ref<VideoStream> &p_stream) { if (!expand) { update_minimum_size(); } -}; +} Ref<VideoStream> VideoStreamPlayer::get_stream() const { return stream; -}; +} void VideoStreamPlayer::play() { ERR_FAIL_COND(!is_inside_tree()); @@ -254,10 +254,8 @@ void VideoStreamPlayer::play() { playback->stop(); playback->play(); set_process_internal(true); - // AudioServer::get_singleton()->stream_set_active(stream_rid,true); - // AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume); last_audio_time = 0; -}; +} void VideoStreamPlayer::stop() { if (!is_inside_tree()) { @@ -268,11 +266,10 @@ void VideoStreamPlayer::stop() { } playback->stop(); - // AudioServer::get_singleton()->stream_set_active(stream_rid,false); resampler.flush(); set_process_internal(false); last_audio_time = 0; -}; +} bool VideoStreamPlayer::is_playing() const { if (playback.is_null()) { @@ -280,16 +277,16 @@ bool VideoStreamPlayer::is_playing() const { } return playback->is_playing(); -}; +} void VideoStreamPlayer::set_paused(bool p_paused) { paused = p_paused; if (playback.is_valid()) { playback->set_paused(p_paused); set_process_internal(!p_paused); - }; + } last_audio_time = 0; -}; +} bool VideoStreamPlayer::is_paused() const { return paused; @@ -313,11 +310,11 @@ int VideoStreamPlayer::get_audio_track() const { void VideoStreamPlayer::set_volume(float p_vol) { volume = p_vol; -}; +} float VideoStreamPlayer::get_volume() const { return volume; -}; +} void VideoStreamPlayer::set_volume_db(float p_db) { if (p_db < -79) { @@ -325,7 +322,7 @@ void VideoStreamPlayer::set_volume_db(float p_db) { } else { set_volume(Math::db2linear(p_db)); } -}; +} float VideoStreamPlayer::get_volume_db() const { if (volume == 0) { @@ -333,21 +330,21 @@ float VideoStreamPlayer::get_volume_db() const { } else { return Math::linear2db(volume); } -}; +} String VideoStreamPlayer::get_stream_name() const { if (stream.is_null()) { return "<No Stream>"; } return stream->get_name(); -}; +} float VideoStreamPlayer::get_stream_position() const { if (playback.is_null()) { return 0; } return playback->get_playback_position(); -}; +} void VideoStreamPlayer::set_stream_position(float p_position) { if (playback.is_valid()) { @@ -365,14 +362,14 @@ Ref<Texture2D> VideoStreamPlayer::get_video_texture() const { void VideoStreamPlayer::set_autoplay(bool p_enable) { autoplay = p_enable; -}; +} bool VideoStreamPlayer::has_autoplay() const { return autoplay; -}; +} void VideoStreamPlayer::set_bus(const StringName &p_bus) { - //if audio is active, must lock this + // If audio is active, must lock this. AudioServer::get_singleton()->lock(); bus = p_bus; AudioServer::get_singleton()->unlock(); @@ -446,7 +443,6 @@ void VideoStreamPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "audio_track", PROPERTY_HINT_RANGE, "0,128,1"), "set_audio_track", "get_audio_track"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VideoStream"), "set_stream", "get_stream"); - //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), "set_loop", "has_loop") ; ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_RANGE, "0,15,0.01,exp", PROPERTY_USAGE_NONE), "set_volume", "get_volume"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay"); @@ -461,7 +457,5 @@ void VideoStreamPlayer::_bind_methods() { VideoStreamPlayer::VideoStreamPlayer() {} VideoStreamPlayer::~VideoStreamPlayer() { - // if (stream_rid.is_valid()) - // AudioServer::get_singleton()->free(stream_rid); - resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes -}; + resampler.clear(); // Not necessary here, but make in consistent with other "stream_player" classes. +} diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index f9a4eba978..9d388d465d 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -529,10 +529,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map if (!gi.persistent) { continue; } - /* - if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name)) - continue; //group was instantiated, don't add here - */ bool skip = false; for (const SceneState::PackState &ia : states_stack) { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 52151ae846..8ff1fde2cf 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -150,12 +150,15 @@ uint32_t SurfaceTool::TriangleHasher::hash(const int *p_triangle) { int t1 = p_triangle[1]; int t2 = p_triangle[2]; - if (t0 > t1) + if (t0 > t1) { SWAP(t0, t1); - if (t1 > t2) + } + if (t1 > t2) { SWAP(t1, t2); - if (t0 > t1) + } + if (t0 > t1) { SWAP(t0, t1); + } return (t0 * 73856093) ^ (t1 * 19349663) ^ (t2 * 83492791); } @@ -165,23 +168,29 @@ bool SurfaceTool::TriangleHasher::compare(const int *p_lhs, const int *p_rhs) { int r1 = p_rhs[1]; int r2 = p_rhs[2]; - if (r0 > r1) + if (r0 > r1) { SWAP(r0, r1); - if (r1 > r2) + } + if (r1 > r2) { SWAP(r1, r2); - if (r0 > r1) + } + if (r0 > r1) { SWAP(r0, r1); + } int l0 = p_lhs[0]; int l1 = p_lhs[1]; int l2 = p_lhs[2]; - if (l0 > l1) + if (l0 > l1) { SWAP(l0, l1); - if (l1 > l2) + } + if (l1 > l2) { SWAP(l1, l2); - if (l0 > l1) + } + if (l0 > l1) { SWAP(l0, l1); + } return l0 == r0 && l1 == r1 && l2 == r2; } diff --git a/scene/resources/visual_shader_particle_nodes.cpp b/scene/resources/visual_shader_particle_nodes.cpp index 1885211d57..398c33c452 100644 --- a/scene/resources/visual_shader_particle_nodes.cpp +++ b/scene/resources/visual_shader_particle_nodes.cpp @@ -1318,7 +1318,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual code += tab + "TRANSFORM = " + p_input_vars[5] + ";\n"; } } else { - if (!p_input_vars[0].is_empty()) { // active (begin) + if (!p_input_vars[0].is_empty()) { // Active (begin). code += tab + "ACTIVE = " + p_input_vars[0] + ";\n"; code += tab + "if(ACTIVE) {\n"; tab += " "; @@ -1381,7 +1381,7 @@ String VisualShaderNodeParticleOutput::generate_code(Shader::Mode p_mode, Visual code += tab + "TRANSFORM " + op + " mat4(vec4(" + p_input_vars[scale] + ", 0, 0, 0), vec4(0, " + p_input_vars[scale] + ", 0, 0), vec4(0, 0, " + p_input_vars[scale] + ", 0), vec4(0, 0, 0, 1));\n"; } } - if (!p_input_vars[0].is_empty()) { // active (end) + if (!p_input_vars[0].is_empty()) { // Active (end). code += " }\n"; } } diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index bddd235204..1909ab6eae 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -54,15 +54,12 @@ void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames, Au float tap_1_level_f = base->tap_1_active ? Math::db2linear(base->tap_1_level) : 0.0; int tap_1_delay_frames = int((base->tap_1_delay_ms / 1000.0) * mix_rate); - ; float tap_2_level_f = base->tap_2_active ? Math::db2linear(base->tap_2_level) : 0.0; int tap_2_delay_frames = int((base->tap_2_delay_ms / 1000.0) * mix_rate); - ; float feedback_level_f = base->feedback_active ? Math::db2linear(base->feedback_level) : 0.0; unsigned int feedback_delay_frames = int((base->feedback_delay_ms / 1000.0) * mix_rate); - ; AudioFrame tap1_vol = AudioFrame(tap_1_level_f, tap_1_level_f); diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp index 757edd6d43..c81efc55e2 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.cpp +++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp @@ -61,7 +61,6 @@ void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames, A //r is delayed r = delay_ringbuff[(ringbuff_pos - delay_frames) & ringbuff_mask]; - ; } p_dst_frames[i].l = l; diff --git a/servers/physics_2d/godot_body_pair_2d.cpp b/servers/physics_2d/godot_body_pair_2d.cpp index 1986191cc3..2bf1e5a1d4 100644 --- a/servers/physics_2d/godot_body_pair_2d.cpp +++ b/servers/physics_2d/godot_body_pair_2d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "godot_body_pair_2d.h" + #include "godot_collision_solver_2d.h" #include "godot_space_2d.h" @@ -303,7 +304,7 @@ bool GodotBodyPair2D::setup(real_t p_step) { bool valid = false; for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; - if (c.normal.dot(direction) > -CMP_EPSILON) { //greater (normal inverted) + if (c.normal.dot(direction) > -CMP_EPSILON) { // Greater (normal inverted). continue; } valid = true; @@ -321,7 +322,7 @@ bool GodotBodyPair2D::setup(real_t p_step) { bool valid = false; for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; - if (c.normal.dot(direction) < CMP_EPSILON) { //less (normal ok) + if (c.normal.dot(direction) < CMP_EPSILON) { // Less (normal ok). continue; } valid = true; diff --git a/servers/physics_2d/godot_collision_solver_2d_sat.cpp b/servers/physics_2d/godot_collision_solver_2d_sat.cpp index a965795bee..ded3ff356b 100644 --- a/servers/physics_2d/godot_collision_solver_2d_sat.cpp +++ b/servers/physics_2d/godot_collision_solver_2d_sat.cpp @@ -41,10 +41,6 @@ struct _CollectorCallback2D { Vector2 *sep_axis = nullptr; _FORCE_INLINE_ void call(const Vector2 &p_point_A, const Vector2 &p_point_B) { - /* - if (normal.dot(p_point_A) >= normal.dot(p_point_B)) - return; - */ if (swap) { callback(p_point_B, p_point_A, userdata); } else { diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp index 5e099e27ec..a9b499c6b5 100644 --- a/servers/physics_2d/godot_physics_server_2d.cpp +++ b/servers/physics_2d/godot_physics_server_2d.cpp @@ -1188,14 +1188,6 @@ void GodotPhysicsServer2D::free(RID p_rid) { } else if (body_owner.owns(p_rid)) { GodotBody2D *body = body_owner.get_or_null(p_rid); - /* - if (body->get_state_query()) - _clear_query(body->get_state_query()); - - if (body->get_direct_state_query()) - _clear_query(body->get_direct_state_query()); - */ - body_set_space(p_rid, RID()); while (body->get_shape_count()) { @@ -1208,11 +1200,6 @@ void GodotPhysicsServer2D::free(RID p_rid) { } else if (area_owner.owns(p_rid)) { GodotArea2D *area = area_owner.get_or_null(p_rid); - /* - if (area->get_monitor_query()) - _clear_query(area->get_monitor_query()); - */ - area->set_space(nullptr); while (area->get_shape_count()) { diff --git a/servers/physics_2d/godot_shape_2d.cpp b/servers/physics_2d/godot_shape_2d.cpp index 1e8799a727..b5dbb8a2dd 100644 --- a/servers/physics_2d/godot_shape_2d.cpp +++ b/servers/physics_2d/godot_shape_2d.cpp @@ -544,12 +544,6 @@ bool GodotConvexPolygonShape2D::intersect_segment(const Vector2 &p_begin, const bool inters = false; for (int i = 0; i < point_count; i++) { - //hmm.. no can do.. - /* - if (d.dot(points[i].normal)>=0) - continue; - */ - Vector2 res; if (!Geometry2D::segment_intersects_segment(p_begin, p_end, points[i].pos, points[(i + 1) % point_count].pos, &res)) { diff --git a/servers/physics_3d/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp index 928ffe0980..23c8079538 100644 --- a/servers/physics_3d/gjk_epa.cpp +++ b/servers/physics_3d/gjk_epa.cpp @@ -918,7 +918,7 @@ bool Distance( const GodotShape3D* shape0, { results.status = gjk_status==GJK::eStatus::Inside? sResults::Penetrating : - sResults::GJK_Failed ; + sResults::GJK_Failed; return(false); } } diff --git a/servers/physics_3d/godot_collision_solver_3d_sat.cpp b/servers/physics_3d/godot_collision_solver_3d_sat.cpp index 82e04a7e31..ca429040f5 100644 --- a/servers/physics_3d/godot_collision_solver_3d_sat.cpp +++ b/servers/physics_3d/godot_collision_solver_3d_sat.cpp @@ -345,10 +345,6 @@ static void _generate_contacts_face_face(const Vector3 *p_points_A, int p_point_ for (int i = 0; i < clipbuf_len; i++) { real_t d = plane_B.distance_to(clipbuf_src[i]); - /* - if (d>CMP_EPSILON) - continue; - */ Vector3 closest_B = clipbuf_src[i] - plane_B.normal * d; diff --git a/servers/physics_3d/godot_physics_server_3d.cpp b/servers/physics_3d/godot_physics_server_3d.cpp index 4e1680e6ac..a1912dc660 100644 --- a/servers/physics_3d/godot_physics_server_3d.cpp +++ b/servers/physics_3d/godot_physics_server_3d.cpp @@ -1540,14 +1540,6 @@ void GodotPhysicsServer3D::free(RID p_rid) { } else if (body_owner.owns(p_rid)) { GodotBody3D *body = body_owner.get_or_null(p_rid); - /* - if (body->get_state_query()) - _clear_query(body->get_state_query()); - - if (body->get_direct_state_query()) - _clear_query(body->get_direct_state_query()); - */ - body->set_space(nullptr); while (body->get_shape_count()) { @@ -1566,11 +1558,6 @@ void GodotPhysicsServer3D::free(RID p_rid) { } else if (area_owner.owns(p_rid)) { GodotArea3D *area = area_owner.get_or_null(p_rid); - /* - if (area->get_monitor_query()) - _clear_query(area->get_monitor_query()); - */ - area->set_space(nullptr); while (area->get_shape_count()) { diff --git a/servers/physics_3d/godot_shape_3d.cpp b/servers/physics_3d/godot_shape_3d.cpp index 666e773c1c..7762c4829e 100644 --- a/servers/physics_3d/godot_shape_3d.cpp +++ b/servers/physics_3d/godot_shape_3d.cpp @@ -1284,12 +1284,6 @@ Vector3 GodotConcavePolygonShape3D::get_support(const Vector3 &p_normal) const { void GodotConcavePolygonShape3D::_cull_segment(int p_idx, _SegmentCullParams *p_params) const { const BVH *bvh = &p_params->bvh[p_idx]; - /* - if (p_params->dir.dot(bvh->aabb.get_support(-p_params->dir))>p_params->min_d) - return; //test against whole AABB, which isn't very costly - */ - - //printf("addr: %p\n",bvh); if (!bvh->aabb.intersects_segment(p_params->from, p_params->to)) { return; } diff --git a/servers/physics_3d/joints/godot_hinge_joint_3d.cpp b/servers/physics_3d/joints/godot_hinge_joint_3d.cpp index a7a7843499..1c4d5dec23 100644 --- a/servers/physics_3d/joints/godot_hinge_joint_3d.cpp +++ b/servers/physics_3d/joints/godot_hinge_joint_3d.cpp @@ -213,16 +213,12 @@ bool GodotHingeJoint3D::setup(real_t p_step) { m_solveLimit = false; m_accLimitImpulse = real_t(0.); - //if (m_lowerLimit < m_upperLimit) if (m_useLimit && m_lowerLimit <= m_upperLimit) { - //if (hingeAngle <= m_lowerLimit*m_limitSoftness) if (hingeAngle <= m_lowerLimit) { m_correction = (m_lowerLimit - hingeAngle); m_limitSign = 1.0f; m_solveLimit = true; - } - //else if (hingeAngle >= m_upperLimit*m_limitSoftness) - else if (hingeAngle >= m_upperLimit) { + } else if (hingeAngle >= m_upperLimit) { m_correction = m_upperLimit - hingeAngle; m_limitSign = -1.0f; m_solveLimit = true; diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index cb07c75db4..1a84bafbd0 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1894,7 +1894,6 @@ void RendererSceneGIRD::SDFGI::render_static_lights(RID p_render_buffers, uint32 RD::get_singleton()->draw_command_begin_label("SDFGI Render Static Lighs"); update_cascades(); - ; //need cascades updated for this SDFGIShader::Light lights[SDFGI::MAX_STATIC_LIGHTS]; uint32_t light_count[SDFGI::MAX_STATIC_LIGHTS]; diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 97f7e0a6e6..5d65b00bee 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -552,7 +552,6 @@ void cluster_get_item_range(uint p_offset, out uint item_min, out uint item_max, uint item_min_max = cluster_buffer.data[p_offset]; item_min = item_min_max & 0xFFFF; item_max = item_min_max >> 16; - ; item_from = item_min >> 5; item_to = (item_max == 0) ? 0 : ((item_max - 1) >> 5) + 1; //side effect of how it is stored, as item_max 0 means no elements diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl index 7c8d4f7f99..7a0cea421e 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl @@ -235,7 +235,6 @@ void cluster_get_item_range(uint p_offset, out uint item_min, out uint item_max, uint item_min_max = cluster_buffer.data[p_offset]; item_min = item_min_max & 0xFFFF; item_max = item_min_max >> 16; - ; item_from = item_min >> 5; item_to = (item_max == 0) ? 0 : ((item_max - 1) >> 5) + 1; //side effect of how it is stored, as item_max 0 means no elements diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 5b43ca4bcd..a0b0b31a7b 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -609,7 +609,6 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene r_gen_code.uniforms += uniform_defines[i]; } -#if 1 // add up int offset = 0; for (int i = 0; i < uniform_sizes.size(); i++) { @@ -629,41 +628,6 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene if (r_gen_code.uniform_total_size % 16 != 0) { //UBO sizes must be multiples of 16 r_gen_code.uniform_total_size += 16 - (r_gen_code.uniform_total_size % 16); } -#else - // add up - for (int i = 0; i < uniform_sizes.size(); i++) { - if (i > 0) { - int align = uniform_sizes[i - 1] % uniform_alignments[i]; - if (align != 0) { - uniform_sizes[i - 1] += uniform_alignments[i] - align; - } - - uniform_sizes[i] = uniform_sizes[i] + uniform_sizes[i - 1]; - } - } - //offset - r_gen_code.uniform_offsets.resize(uniform_sizes.size()); - for (int i = 0; i < uniform_sizes.size(); i++) { - if (i > 0) - r_gen_code.uniform_offsets[i] = uniform_sizes[i - 1]; - else - r_gen_code.uniform_offsets[i] = 0; - } - /* - for(Map<StringName,SL::ShaderNode::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) { - if (SL::is_sampler_type(E->get().type)) { - continue; - } - - } - -*/ - if (uniform_sizes.size()) { - r_gen_code.uniform_total_size = uniform_sizes[uniform_sizes.size() - 1]; - } else { - r_gen_code.uniform_total_size = 0; - } -#endif uint32_t index = p_default_actions.base_varying_index; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 91201b2028..7683cf20b3 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "shader_language.h" + #include "core/os/os.h" #include "core/string/print_string.h" #include "servers/rendering_server.h" @@ -632,7 +633,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { char32_t last_char = str[str.length() - 1]; - if (hexa_found) { // Integer(hex) + if (hexa_found) { // Integer (hex). if (str.size() > 11 || !str.is_valid_hex_number(true)) { // > 0xFFFFFFFF return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant"); } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 2037268134..a7fcbcce42 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -429,7 +429,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], &value, 4); } - } else { // if (type == Variant::PACKED_FLOAT64_ARRAY) + } else { // PACKED_FLOAT64_ARRAY Vector<double> array = p_arrays[ai]; ERR_FAIL_COND_V(array.size() != p_vertex_array_len * 4, ERR_INVALID_PARAMETER); const double *src = array.ptr(); @@ -573,7 +573,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint memcpy(&sw[p_offsets[ai] + i * p_skin_stride], data, 2 * bone_count); } } - } else { // if (type == Variant::PACKED_FLOAT64_ARRAY) + } else { // PACKED_FLOAT64_ARRAY Vector<double> array = p_arrays[ai]; ERR_FAIL_COND_V(array.size() != (int32_t)(p_vertex_array_len * bone_count), ERR_INVALID_PARAMETER); const double *src = array.ptr(); diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index bf78298450..87016dddf6 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -39,7 +39,7 @@ namespace TestString { int u32scmp(const char32_t *l, const char32_t *r) { for (; *l == *r && *l && *r; l++, r++) { - ; + // Continue. } return *l - *r; } diff --git a/tests/servers/test_physics_2d.cpp b/tests/servers/test_physics_2d.cpp index 8b77458a33..138412ec09 100644 --- a/tests/servers/test_physics_2d.cpp +++ b/tests/servers/test_physics_2d.cpp @@ -84,6 +84,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].shape = segment_shape; } + // CIRCLE { @@ -182,10 +183,7 @@ class TestPhysics2DMainLoop : public MainLoop { } void _do_ray_query() { - /* - PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); - ps->query_intersection_segment(ray_query,ray_from,ray_to); - */ + // FIXME: Do something? } protected: @@ -231,11 +229,10 @@ protected: ps->body_set_continuous_collision_detection_mode(body, PhysicsServer2D::CCD_MODE_CAST_SHAPE); ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform); - //print_line("add body with xform: "+p_xform); RID sprite = vs->canvas_item_create(); vs->canvas_item_set_parent(sprite, canvas); vs->canvas_item_set_transform(sprite, p_xform); - Size2 imgsize(5, 5); //vs->texture_get_width(body_shape_data[p_shape].image), vs->texture_get_height(body_shape_data[p_shape].image)); + Size2 imgsize(5, 5); vs->canvas_item_add_texture_rect(sprite, Rect2(-imgsize / 2.0, imgsize), body_shape_data[p_shape].image); ps->body_set_force_integration_callback(body, callable_mp(this, &TestPhysics2DMainLoop::_body_moved), sprite); @@ -326,21 +323,11 @@ public: vs->viewport_set_size(vp, screen_size.x, screen_size.y); vs->viewport_attach_to_screen(vp, Rect2(Vector2(), screen_size)); vs->viewport_set_active(vp, true); - - Transform2D smaller; - //smaller.scale(Vector2(0.6,0.6)); - //smaller.elements[2]=Vector2(100,0); - - //view_xform = smaller; vs->viewport_set_canvas_transform(vp, canvas, view_xform); } ray = vs->canvas_item_create(); vs->canvas_item_set_parent(ray, canvas); - //ray_query = ps->query_create(this,"_ray_query_callback",Variant()); - //ps->query_intersection(ray_query,space); - - _create_body_shape_data(); for (int i = 0; i < 32; i++) { PhysicsServer2D::ShapeType types[4] = { @@ -352,17 +339,9 @@ public: }; PhysicsServer2D::ShapeType type = types[i % 4]; - //type=PhysicsServer2D::SHAPE_SEGMENT; _add_body(type, Transform2D(i * 0.8, Point2(152 + i * 40, 100 - 40 * i))); - /* - if (i==0) - ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); - */ } - //RID b= _add_body(PhysicsServer2D::SHAPE_CIRCLE,Transform2D(0,Point2(101,140))); - //ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); - Point2 prev; Vector<Point2> parr; @@ -376,9 +355,6 @@ public: } _add_concave(parr); - //_add_world_boundary(Vector2(0.0,-1).normalized(),-300); - //_add_world_boundary(Vector2(1,0).normalized(),50); - //_add_world_boundary(Vector2(-1,0).normalized(),-600); } virtual bool process(double p_time) override { |