From 3d15f0466804d46e0170cfcc2cdff4d38e5eaee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 4 May 2021 14:28:27 +0200 Subject: [PATCH] Style: clang-format: Disable AllowShortIfStatementsOnASingleLine --- .clang-format | 2 +- core/class_db.cpp | 9 +- core/color.cpp | 3 +- core/color_names.inc | 3 +- core/command_queue_mt.h | 24 ++-- core/cowdata.h | 3 +- core/image.cpp | 6 +- core/io/file_access_pack.cpp | 3 +- core/io/ip_address.h | 12 +- core/io/marshalls.h | 3 +- core/io/multiplayer_api.cpp | 8 +- core/io/resource_loader.h | 6 +- core/list.h | 3 +- core/math/a_star.cpp | 24 ++-- core/math/basis.cpp | 3 +- core/math/bvh_abb.h | 18 ++- core/math/camera_matrix.cpp | 9 +- core/math/geometry.h | 24 ++-- core/math/quat.cpp | 3 +- core/math/triangle_mesh.cpp | 15 +- core/math/triangulate.cpp | 21 ++- core/method_bind.h | 3 +- core/node_path.cpp | 3 +- core/object.cpp | 3 +- core/object.h | 3 +- core/os/dir_access.h | 3 +- core/os/file_access.h | 3 +- core/os/memory.h | 7 +- core/os/os.cpp | 6 +- core/pool_allocator.cpp | 3 +- core/self_list.h | 3 +- core/translation.cpp | 3 +- core/ustring.cpp | 3 +- core/variant.h | 3 +- core/variant_op.cpp | 133 ++++++++++-------- core/vector.h | 3 +- drivers/gles2/shaders/scene.glsl | 3 +- drivers/gles3/shaders/scene.glsl | 3 +- drivers/unix/ip_unix.cpp | 3 +- editor/code_editor.cpp | 6 +- editor/editor_file_dialog.cpp | 3 +- editor/editor_help.cpp | 3 +- editor/editor_node.cpp | 21 ++- editor/plugins/canvas_item_editor_plugin.cpp | 27 ++-- editor/plugins/path_2d_editor_plugin.cpp | 6 +- editor/plugins/path_editor_plugin.cpp | 3 +- editor/plugins/script_text_editor.cpp | 3 +- editor/plugins/spatial_editor_plugin.cpp | 42 ++++-- editor/plugins/tile_set_editor_plugin.cpp | 3 +- .../plugins/visual_shader_editor_plugin.cpp | 6 +- editor/project_settings_editor.cpp | 9 +- editor/scene_tree_dock.cpp | 12 +- editor/script_create_dialog.cpp | 18 ++- editor/script_editor_debugger.cpp | 3 +- editor/spatial_editor_gizmos.cpp | 15 +- main/tests/test_astar.cpp | 24 ++-- main/tests/test_string.cpp | 12 +- modules/bullet/shape_bullet.cpp | 3 +- modules/bullet/space_bullet.h | 3 +- modules/csg/csg.cpp | 45 ++++-- modules/csg/csg_shape.cpp | 12 +- modules/fbx/fbx_parser/FBXProperties.cpp | 6 +- modules/gdnative/gdnative/gdnative.cpp | 3 +- modules/gdscript/gdscript_compiler.cpp | 63 ++++++--- modules/gdscript/gdscript_compiler.h | 6 +- modules/gdscript/gdscript_function.h | 3 +- modules/gdscript/gdscript_parser.cpp | 81 +++++++---- modules/gdscript/gdscript_parser.h | 6 +- .../gdscript_extend_parser.cpp | 3 +- .../language_server/gdscript_workspace.cpp | 3 +- modules/gdscript/language_server/lsp.hpp | 33 +++-- modules/jsonrpc/jsonrpc.cpp | 3 +- modules/lightmapper_cpu/lightmapper_cpu.cpp | 3 +- modules/mbedtls/packet_peer_mbed_dtls.cpp | 6 +- modules/mbedtls/stream_peer_mbedtls.cpp | 6 +- modules/mobile_vr/mobile_vr_interface.cpp | 18 ++- modules/mono/editor/bindings_generator.h | 3 +- modules/mono/mono_gd/gd_mono_utils.cpp | 7 +- modules/opensimplex/noise_texture.cpp | 15 +- modules/opensimplex/open_simplex_noise.cpp | 12 +- modules/theora/video_stream_theora.cpp | 6 +- modules/webrtc/webrtc_multiplayer.cpp | 3 +- platform/android/export/export.cpp | 3 +- .../lib/src/org/godotengine/godot/Godot.java | 3 +- platform/iphone/export/export.cpp | 3 +- platform/iphone/godot_iphone.mm | 3 +- platform/osx/joypad_osx.cpp | 9 +- platform/osx/os_osx.mm | 6 +- platform/uwp/export/export.cpp | 39 +++-- platform/uwp/joypad_uwp.cpp | 3 +- platform/uwp/os_uwp.cpp | 6 +- platform/windows/joypad_windows.cpp | 3 +- platform/windows/os_windows.cpp | 18 ++- platform/x11/detect_prime.cpp | 3 +- platform/x11/joypad_linux.cpp | 3 +- platform/x11/os_x11.cpp | 12 +- scene/2d/canvas_item.h | 6 +- scene/2d/cpu_particles_2d.cpp | 6 +- scene/2d/physics_body_2d.cpp | 3 +- scene/2d/tile_map.cpp | 3 +- scene/3d/cpu_particles.cpp | 6 +- scene/3d/particles.cpp | 3 +- scene/3d/physics_body.cpp | 3 +- scene/3d/voxel_light_baker.cpp | 45 ++++-- scene/animation/animation_tree_player.cpp | 3 +- scene/animation/tween.cpp | 51 ++++--- scene/gui/file_dialog.cpp | 3 +- scene/gui/line_edit.cpp | 12 +- scene/gui/rich_text_label.cpp | 12 +- scene/gui/slider.cpp | 6 +- scene/gui/tabs.cpp | 6 +- scene/gui/text_edit.cpp | 3 +- scene/gui/tree.cpp | 18 ++- scene/main/scene_tree.cpp | 6 +- scene/resources/texture.cpp | 6 +- scene/resources/texture.h | 3 +- scene/resources/tile_set.cpp | 3 +- servers/audio/audio_filter_sw.cpp | 3 +- servers/audio/effects/audio_effect_filter.h | 9 +- .../audio_effect_spectrum_analyzer.cpp | 3 +- servers/physics/body_sw.h | 3 +- servers/physics/collision_object_sw.h | 3 +- .../physics/joints/generic_6dof_joint_sw.cpp | 6 +- servers/physics/space_sw.h | 3 +- servers/physics_2d/body_2d_sw.h | 3 +- servers/physics_2d/space_2d_sw.h | 3 +- servers/visual/rasterizer.h | 3 +- servers/visual/shader_language.cpp | 6 +- 128 files changed, 872 insertions(+), 455 deletions(-) diff --git a/.clang-format b/.clang-format index 286c22cbe9b..b588d9811f3 100644 --- a/.clang-format +++ b/.clang-format @@ -15,7 +15,7 @@ AllowAllParametersOfDeclarationOnNextLine: false # AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: true +# AllowShortIfStatementsOnASingleLine: false # AllowShortLoopsOnASingleLine: false # AlwaysBreakAfterDefinitionReturnType: None # AlwaysBreakAfterReturnType: None diff --git a/core/class_db.cpp b/core/class_db.cpp index 6b466591ba2..2d34aea3597 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -1436,16 +1436,19 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con } if (!default_values.has(p_class)) { - if (r_valid != NULL) *r_valid = false; + if (r_valid != NULL) + *r_valid = false; return Variant(); } if (!default_values[p_class].has(p_property)) { - if (r_valid != NULL) *r_valid = false; + if (r_valid != NULL) + *r_valid = false; return Variant(); } - if (r_valid != NULL) *r_valid = true; + if (r_valid != NULL) + *r_valid = true; return default_values[p_class][p_property]; } diff --git a/core/color.cpp b/core/color.cpp index 4b62c93668d..1dd32954b63 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -406,7 +406,8 @@ bool Color::html_is_valid(const String &p_color) { } Color Color::named(const String &p_name) { - if (_named_colors.empty()) _populate_named_colors(); // from color_names.inc + if (_named_colors.empty()) + _populate_named_colors(); // from color_names.inc String name = p_name; // Normalize name name = name.replace(" ", ""); diff --git a/core/color_names.inc b/core/color_names.inc index 428a8473fe6..f249ee98684 100644 --- a/core/color_names.inc +++ b/core/color_names.inc @@ -3,7 +3,8 @@ static Map _named_colors; static void _populate_named_colors() { - if (!_named_colors.empty()) return; + if (!_named_colors.empty()) + return; _named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00)); _named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84)); _named_colors.insert("aqua", Color(0.00, 1.00, 1.00)); diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index d71ef61cce6..fa3c4e28766 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -233,7 +233,8 @@ cmd->method = p_method; \ SEMIC_SEP_LIST(CMD_ASSIGN_PARAM, N); \ unlock(); \ - if (sync) sync->post(); \ + if (sync) \ + sync->post(); \ } #define CMD_RET_TYPE(N) CommandRet##N @@ -249,7 +250,8 @@ cmd->ret = r_ret; \ cmd->sync_sem = ss; \ unlock(); \ - if (sync) sync->post(); \ + if (sync) \ + sync->post(); \ ss->sem.wait(); \ ss->in_use = false; \ } @@ -266,7 +268,8 @@ SEMIC_SEP_LIST(CMD_ASSIGN_PARAM, N); \ cmd->sync_sem = ss; \ unlock(); \ - if (sync) sync->post(); \ + if (sync) \ + sync->post(); \ ss->sem.wait(); \ ss->in_use = false; \ } @@ -408,12 +411,14 @@ class CommandQueueMT { } bool flush_one(bool p_lock = true) { - if (p_lock) lock(); + if (p_lock) + lock(); tryagain: // tried to read an empty queue if (read_ptr_and_epoch == write_ptr_and_epoch) { - if (p_lock) unlock(); + if (p_lock) + unlock(); return false; } @@ -436,15 +441,18 @@ class CommandQueueMT { read_ptr_and_epoch = (read_ptr << 1) | (read_ptr_and_epoch & 1); - if (p_lock) unlock(); + if (p_lock) + unlock(); cmd->call(); - if (p_lock) lock(); + if (p_lock) + lock(); cmd->post(); cmd->~CommandBase(); *(uint32_t *)&command_mem[size_ptr] &= ~1; - if (p_lock) unlock(); + if (p_lock) + unlock(); return true; } diff --git a/core/cowdata.h b/core/cowdata.h index cdb187e322a..dbf4e28cea5 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -99,7 +99,8 @@ private: return false; } *out = next_power_of_2(o); - if (_add_overflow(o, static_cast(32), &p)) return false; //no longer allocated here + if (_add_overflow(o, static_cast(32), &p)) + return false; //no longer allocated here return true; #else // Speed is more important than correctness here, do the operations unchecked diff --git a/core/image.cpp b/core/image.cpp index 813973ee7cc..e472b972ba3 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2931,11 +2931,13 @@ void Image::bumpmap_to_normalmap(float bump_scale) { for (int ty = 0; ty < height; ty++) { int py = ty + 1; - if (py >= height) py -= height; + if (py >= height) + py -= height; for (int tx = 0; tx < width; tx++) { int px = tx + 1; - if (px >= width) px -= width; + if (px >= width) + px -= width; float here = read_ptr[ty * width + tx]; float to_right = read_ptr[ty * width + px]; float above = read_ptr[py * width + tx]; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 20b4a77f85f..1c4e5987542 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -431,7 +431,8 @@ PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) { nd = nd.simplify_path(); - if (nd == "") nd = "."; + if (nd == "") + nd = "."; if (nd.begins_with("/")) { nd = nd.replace_first("/", ""); diff --git a/core/io/ip_address.h b/core/io/ip_address.h index 2a21a87858f..98e657ae79c 100644 --- a/core/io/ip_address.h +++ b/core/io/ip_address.h @@ -52,16 +52,20 @@ protected: public: //operator Variant() const; bool operator==(const IP_Address &p_ip) const { - if (p_ip.valid != valid) return false; - if (!valid) return false; + if (p_ip.valid != valid) + return false; + if (!valid) + return false; for (int i = 0; i < 4; i++) if (field32[i] != p_ip.field32[i]) return false; return true; } bool operator!=(const IP_Address &p_ip) const { - if (p_ip.valid != valid) return true; - if (!valid) return true; + if (p_ip.valid != valid) + return true; + if (!valid) + return true; for (int i = 0; i < 4; i++) if (field32[i] != p_ip.field32[i]) return true; diff --git a/core/io/marshalls.h b/core/io/marshalls.h index c3c4a8085bf..01f6f77fcfb 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -121,7 +121,8 @@ static inline int encode_cstring(const char *p_string, uint8_t *p_data) { len++; }; - if (p_data) *p_data = 0; + if (p_data) + *p_data = 0; return len + 1; } diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 5a5c3434169..8db2f5c7796 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -142,7 +142,8 @@ Node *MultiplayerAPI::get_root_node() { void MultiplayerAPI::set_network_peer(const Ref &p_peer) { - if (p_peer == network_peer) return; // Nothing to do + if (p_peer == network_peer) + return; // Nothing to do ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Supplied NetworkedMultiplayerPeer must be connecting or connected."); @@ -504,8 +505,9 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p int ofs = 0; -#define MAKE_ROOM(m_amount) \ - if (packet_cache.size() < m_amount) packet_cache.resize(m_amount); +#define MAKE_ROOM(m_amount) \ + if (packet_cache.size() < m_amount) \ + packet_cache.resize(m_amount); // Encode type. MAKE_ROOM(1); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 5b9f9e8110a..6c0436422dc 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -161,7 +161,8 @@ public: static bool get_timestamp_on_load() { return timestamp_on_load; } static void notify_load_error(const String &p_err) { - if (err_notify) err_notify(err_notify_ud, p_err); + if (err_notify) + err_notify(err_notify_ud, p_err); } static void set_error_notify_func(void *p_ud, ResourceLoadErrorNotify p_err_notify) { err_notify = p_err_notify; @@ -169,7 +170,8 @@ public: } static void notify_dependency_error(const String &p_path, const String &p_dependency, const String &p_type) { - if (dep_err_notify) dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type); + if (dep_err_notify) + dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type); } static void set_dependency_error_notify_func(void *p_ud, DependencyErrorNotify p_err_notify) { dep_err_notify = p_err_notify; diff --git a/core/list.h b/core/list.h index b9a13dc7a83..becf9e2aac7 100644 --- a/core/list.h +++ b/core/list.h @@ -353,7 +353,8 @@ public: Element *it = front(); while (it) { - if (it->value == p_val) return it; + if (it->value == p_val) + return it; it = it->next(); }; diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 79d70e7a1e0..b9a3bad372e 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -164,7 +164,8 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) { } Segment s(p_id, p_with_id); - if (bidirectional) s.direction = Segment::BIDIRECTIONAL; + if (bidirectional) + s.direction = Segment::BIDIRECTIONAL; Set::Element *element = segments.find(s); if (element != NULL) { @@ -290,7 +291,8 @@ int AStar::get_closest_point(const Vector3 &p_point, bool p_include_disabled) co for (OAHashMap::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) { - if (!p_include_disabled && !(*it.value)->enabled) continue; // Disabled points should not be considered. + if (!p_include_disabled && !(*it.value)->enabled) + continue; // Disabled points should not be considered. // Keep the closest point's ID, and in case of multiple closest IDs, // the smallest one (makes it deterministic). @@ -344,7 +346,8 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { pass++; - if (!end_point->enabled) return false; + if (!end_point->enabled) + return false; bool found_route = false; @@ -455,7 +458,8 @@ PoolVector AStar::get_point_path(int p_from_id, int p_to_id) { Point *end_point = b; bool found_route = _solve(begin_point, end_point); - if (!found_route) return PoolVector(); + if (!found_route) + return PoolVector(); Point *p = end_point; int pc = 1; // Begin point @@ -503,7 +507,8 @@ PoolVector AStar::get_id_path(int p_from_id, int p_to_id) { Point *end_point = b; bool found_route = _solve(begin_point, end_point); - if (!found_route) return PoolVector(); + if (!found_route) + return PoolVector(); Point *p = end_point; int pc = 1; // Begin point @@ -733,7 +738,8 @@ PoolVector AStar2D::get_point_path(int p_from_id, int p_to_id) { AStar::Point *end_point = b; bool found_route = _solve(begin_point, end_point); - if (!found_route) return PoolVector(); + if (!found_route) + return PoolVector(); AStar::Point *p = end_point; int pc = 1; // Begin point @@ -781,7 +787,8 @@ PoolVector AStar2D::get_id_path(int p_from_id, int p_to_id) { AStar::Point *end_point = b; bool found_route = _solve(begin_point, end_point); - if (!found_route) return PoolVector(); + if (!found_route) + return PoolVector(); AStar::Point *p = end_point; int pc = 1; // Begin point @@ -813,7 +820,8 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) { astar.pass++; - if (!end_point->enabled) return false; + if (!end_point->enabled) + return false; bool found_route = false; diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 1731b5f1fac..c13d0902083 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -951,7 +951,8 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { real_t s = Math::sqrt((elements[1][2] - elements[2][1]) * (elements[1][2] - elements[2][1]) + (elements[2][0] - elements[0][2]) * (elements[2][0] - elements[0][2]) + (elements[0][1] - elements[1][0]) * (elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise angle = Math::acos((elements[0][0] + elements[1][1] + elements[2][2] - 1) / 2); - if (angle < 0) s = -s; + if (angle < 0) + s = -s; x = (elements[2][1] - elements[1][2]) / s; y = (elements[0][2] - elements[2][0]) / s; z = (elements[1][0] - elements[0][1]) / s; diff --git a/core/math/bvh_abb.h b/core/math/bvh_abb.h index 4c825da23d9..269867389b0 100644 --- a/core/math/bvh_abb.h +++ b/core/math/bvh_abb.h @@ -200,20 +200,26 @@ struct BVH_ABB { } bool intersects_point(const Point &p_pt) const { - if (_any_lessthan(-p_pt, neg_max)) return false; - if (_any_lessthan(p_pt, min)) return false; + if (_any_lessthan(-p_pt, neg_max)) + return false; + if (_any_lessthan(p_pt, min)) + return false; return true; } bool intersects(const BVH_ABB &p_o) const { - if (_any_morethan(p_o.min, -neg_max)) return false; - if (_any_morethan(min, -p_o.neg_max)) return false; + if (_any_morethan(p_o.min, -neg_max)) + return false; + if (_any_morethan(min, -p_o.neg_max)) + return false; return true; } bool is_other_within(const BVH_ABB &p_o) const { - if (_any_lessthan(p_o.neg_max, neg_max)) return false; - if (_any_lessthan(p_o.min, min)) return false; + if (_any_lessthan(p_o.neg_max, neg_max)) + return false; + if (_any_lessthan(p_o.min, min)) + return false; return true; } diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 2dd2dc4d151..4a8ac4d10d3 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -443,20 +443,23 @@ void CameraMatrix::invert() { /** Divide column by minus pivot value **/ for (i = 0; i < 4; i++) { - if (i != k) matrix[i][k] /= (-pvt_val); + if (i != k) + matrix[i][k] /= (-pvt_val); } /** Reduce the matrix **/ for (i = 0; i < 4; i++) { hold = matrix[i][k]; for (j = 0; j < 4; j++) { - if (i != k && j != k) matrix[i][j] += hold * matrix[k][j]; + if (i != k && j != k) + matrix[i][j] += hold * matrix[k][j]; } } /** Divide row by pivot **/ for (j = 0; j < 4; j++) { - if (j != k) matrix[k][j] /= pvt_val; + if (j != k) + matrix[k][j] /= pvt_val; } /** Replace pivot by reciprocal (at last we can touch it). **/ diff --git a/core/math/geometry.h b/core/math/geometry.h index 056977c5d0e..50ec3009b7e 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -113,10 +113,14 @@ public: real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1); // Clip the value between [0..1] constraining the solution to lie on the original curves. - if (mua < 0) mua = 0; - if (mub < 0) mub = 0; - if (mua > 1) mua = 1; - if (mub > 1) mub = 1; + if (mua < 0) + mua = 0; + if (mub < 0) + mub = 0; + if (mua > 1) + mua = 1; + if (mub > 1) + mub = 1; c1 = p1.linear_interpolate(p2, mua); c2 = q1.linear_interpolate(q2, mub); } @@ -506,7 +510,8 @@ public: bool orientation = an.cross(bn) > 0; - if ((bn.cross(cn) > 0) != orientation) return false; + if ((bn.cross(cn) > 0) != orientation) + return false; return (cn.cross(an) > 0) == orientation; } @@ -713,7 +718,8 @@ public: // If the term we intend to square root is less than 0 then the answer won't be real, // so it definitely won't be t in the range 0 to 1. - if (sqrtterm < 0) return -1; + if (sqrtterm < 0) + return -1; // If we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection) // then the following can be skipped and we can just return the equivalent of res1. @@ -721,8 +727,10 @@ public: real_t res1 = (-b - sqrtterm) / (2 * a); real_t res2 = (-b + sqrtterm) / (2 * a); - if (res1 >= 0 && res1 <= 1) return res1; - if (res2 >= 0 && res2 <= 1) return res2; + if (res1 >= 0 && res1 <= 1) + return res1; + if (res2 >= 0 && res2 <= 1) + return res2; return -1; } diff --git a/core/math/quat.cpp b/core/math/quat.cpp index 72d0a9923c2..11c023da606 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -206,7 +206,8 @@ Quat Quat::slerpni(const Quat &p_to, const real_t &p_weight) const { real_t dot = from.dot(p_to); - if (Math::absf(dot) > 0.9999) return from; + if (Math::absf(dot) > 0.9999) + return from; real_t theta = Math::acos(dot), sinT = 1.0 / Math::sin(theta), diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 123f3c3573b..779bb174379 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -570,14 +570,16 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou if (p.intersects_segment(point, next_point, &res)) { bool inisde = true; for (int k = 0; k < p_plane_count; k++) { - if (k == i) continue; + if (k == i) + continue; const Plane &pp = p_planes[k]; if (pp.is_point_over(res)) { inisde = false; break; } } - if (inisde) return true; + if (inisde) + return true; } if (p.is_point_over(point)) { @@ -585,7 +587,8 @@ bool TriangleMesh::intersect_convex_shape(const Plane *p_planes, int p_plane_cou break; } } - if (over) return true; + if (over) + return true; } stack[level] = (VISIT_DONE_BIT << VISITED_BIT_SHIFT) | node; @@ -667,7 +670,8 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count, case TEST_AABB_BIT: { bool intersects = scale.xform(b.aabb).intersects_convex_shape(p_planes, p_plane_count, p_points, p_point_count); - if (!intersects) return false; + if (!intersects) + return false; bool inside = scale.xform(b.aabb).inside_convex_shape(p_planes, p_plane_count); if (inside) { @@ -682,7 +686,8 @@ bool TriangleMesh::inside_convex_shape(const Plane *p_planes, int p_plane_count, Vector3 point = scale.xform(vertexptr[s.indices[j]]); for (int i = 0; i < p_plane_count; i++) { const Plane &p = p_planes[i]; - if (p.is_point_over(point)) return false; + if (p.is_point_over(point)) + return false; } } diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index 773337cb6eb..22afd333793 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -103,13 +103,16 @@ bool Triangulate::snip(const Vector &p_contour, int u, int v, int w, in // To avoid that we allow zero-area triangles if all else failed. float threshold = relaxed ? -CMP_EPSILON : CMP_EPSILON; - if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) return false; + if (threshold > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) + return false; for (p = 0; p < n; p++) { - if ((p == u) || (p == v) || (p == w)) continue; + if ((p == u) || (p == v) || (p == w)) + continue; Px = contour[V[p]].x; Py = contour[V[p]].y; - if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) return false; + if (is_inside_triangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py, relaxed)) + return false; } return true; @@ -119,7 +122,8 @@ bool Triangulate::triangulate(const Vector &contour, Vector &resul /* allocate and initialize list of Vertices in polygon */ int n = contour.size(); - if (n < 3) return false; + if (n < 3) + return false; Vector V; V.resize(n); @@ -161,11 +165,14 @@ bool Triangulate::triangulate(const Vector &contour, Vector &resul /* three consecutive vertices in current polygon, */ int u = v; - if (nv <= u) u = 0; /* previous */ + if (nv <= u) + u = 0; /* previous */ v = u + 1; - if (nv <= v) v = 0; /* new v */ + if (nv <= v) + v = 0; /* new v */ int w = v + 1; - if (nv <= w) w = 0; /* next */ + if (nv <= w) + w = 0; /* next */ if (snip(contour, u, v, w, nv, V, relaxed)) { int a, b, c, s, t; diff --git a/core/method_bind.h b/core/method_bind.h index 561b79e81b2..0d970e4bb41 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -165,7 +165,8 @@ struct VariantObjectClassChecker { #define CHECK_NOARG(m_arg) \ { \ if (p_arg##m_arg.get_type() != Variant::NIL) { \ - if (r_argerror) *r_argerror = (m_arg - 1); \ + if (r_argerror) \ + *r_argerror = (m_arg - 1); \ return CALL_ERROR_EXTRA_ARGUMENT; \ } \ } diff --git a/core/node_path.cpp b/core/node_path.cpp index 1e298811f30..fc3d890ca09 100644 --- a/core/node_path.cpp +++ b/core/node_path.cpp @@ -373,7 +373,8 @@ NodePath::NodePath(const String &p_path) { String str = path.substr(from, i - from); if (str == "") { - if (path[i] == 0) continue; // Allow end-of-path : + if (path[i] == 0) + continue; // Allow end-of-path : ERR_FAIL_MSG("Invalid NodePath '" + p_path + "'."); } diff --git a/core/object.cpp b/core/object.cpp index 27d95dcf252..ace5265e06d 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -561,7 +561,8 @@ void Object::set_indexed(const Vector &p_names, const Variant &p_val } bool valid = false; - if (!r_valid) r_valid = &valid; + if (!r_valid) + r_valid = &valid; List value_stack; diff --git a/core/object.h b/core/object.h index 8e20eea74dd..0b3b8a5005f 100644 --- a/core/object.h +++ b/core/object.h @@ -350,7 +350,8 @@ protected: return (bool (Object::*)(const StringName &, const Variant &)) & m_class::_set; \ } \ virtual bool _setv(const StringName &p_name, const Variant &p_property) { \ - if (m_inherits::_setv(p_name, p_property)) return true; \ + if (m_inherits::_setv(p_name, p_property)) \ + return true; \ if (m_class::_get_set() != m_inherits::_get_set()) { \ return _set(p_name, p_property); \ } \ diff --git a/core/os/dir_access.h b/core/os/dir_access.h index c78332c6b25..e9c98eb7bfc 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -146,7 +146,8 @@ struct DirAccessRef { DirAccess *f; DirAccessRef(DirAccess *fa) { f = fa; } ~DirAccessRef() { - if (f) memdelete(f); + if (f) + memdelete(f); } }; diff --git a/core/os/file_access.h b/core/os/file_access.h index 30ccf5667b5..ebaef6f83d2 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -192,7 +192,8 @@ struct FileAccessRef { operator FileAccess *() { return f; } FileAccessRef(FileAccess *fa) { f = fa; } ~FileAccessRef() { - if (f) memdelete(f); + if (f) + memdelete(f); } }; diff --git a/core/os/memory.h b/core/os/memory.h index 84ff44c3a21..a7333d460ca 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -130,9 +130,10 @@ void memdelete_allocator(T *p_class) { A::free(p_class); } -#define memdelete_notnull(m_v) \ - { \ - if (m_v) memdelete(m_v); \ +#define memdelete_notnull(m_v) \ + { \ + if (m_v) \ + memdelete(m_v); \ } #define memnew_arr(m_class, m_count) memnew_arr_template(m_count) diff --git a/core/os/os.cpp b/core/os/os.cpp index a5c0ea45169..926b2698d2a 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -388,7 +388,8 @@ Error OS::dialog_show(String p_title, String p_description, Vector p_but print("%ls\n--------\n%ls\n", p_title.c_str(), p_description.c_str()); for (int i = 0; i < p_buttons.size(); i++) { - if (i > 0) print(", "); + if (i > 0) + print(", "); print("%i=%ls", i + 1, p_buttons[i].c_str()); }; print("\n"); @@ -696,7 +697,8 @@ bool OS::has_feature(const String &p_feature) { void OS::center_window() { - if (is_window_fullscreen()) return; + if (is_window_fullscreen()) + return; Point2 sp = get_screen_position(get_current_screen()); Size2 scr = get_screen_size(get_current_screen()); diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index 6096238c6da..a36404653d4 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -181,7 +181,8 @@ PoolAllocator::ID PoolAllocator::alloc(int p_size) { ERR_FAIL_COND_V(p_size < 1, POOL_ALLOCATOR_INVALID_ID); #ifdef DEBUG_ENABLED - if (p_size > free_mem) OS::get_singleton()->debug_break(); + if (p_size > free_mem) + OS::get_singleton()->debug_break(); #endif ERR_FAIL_COND_V(p_size > free_mem, POOL_ALLOCATOR_INVALID_ID); diff --git a/core/self_list.h b/core/self_list.h index e361704fb9a..10ef9ea3bc1 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -121,7 +121,8 @@ private: public: _FORCE_INLINE_ bool in_list() const { return _root; } _FORCE_INLINE_ void remove_from_list() { - if (_root) _root->remove(this); + if (_root) + _root->remove(this); } _FORCE_INLINE_ SelfList *next() { return _next; } _FORCE_INLINE_ SelfList *prev() { return _prev; } diff --git a/core/translation.cpp b/core/translation.cpp index 2c491aafca8..ebfd30e996f 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -1002,7 +1002,8 @@ String TranslationServer::get_locale() const { String TranslationServer::get_locale_name(const String &p_locale) const { - if (!locale_name_map.has(p_locale)) return String(); + if (!locale_name_map.has(p_locale)) + return String(); return locale_name_map[p_locale]; } diff --git a/core/ustring.cpp b/core/ustring.cpp index d9fa7298f0e..6ba051df366 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1955,7 +1955,8 @@ bool String::is_numeric() const { }; int s = 0; - if (operator[](0) == '-') ++s; + if (operator[](0) == '-') + ++s; bool dot = false; for (int i = s; i < length(); i++) { diff --git a/core/variant.h b/core/variant.h index 0677c1f5dc5..484a57b9930 100644 --- a/core/variant.h +++ b/core/variant.h @@ -441,7 +441,8 @@ public: Variant(const Variant &p_variant); _FORCE_INLINE_ Variant() { type = NIL; } _FORCE_INLINE_ ~Variant() { - if (type != Variant::NIL) clear(); + if (type != Variant::NIL) + clear(); } }; diff --git a/core/variant_op.cpp b/core/variant_op.cpp index bd3c46a2ee7..c94821726bd 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -166,21 +166,26 @@ bool Variant::booleanize() const { return; \ } -#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \ - if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) \ + _RETURN(p_a._data.m_type m_op p_b._data._int); \ + if (p_b.type == REAL) \ + _RETURN(p_a._data.m_type m_op p_b._data._real); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \ - if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \ - if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) \ + _RETURN(p_a._data.m_type m_op p_b._data._int); \ + if (p_b.type == REAL) \ + _RETURN(p_a._data.m_type m_op p_b._data._real); \ + if (p_b.type == NIL) \ + _RETURN(!(p_b.type m_op NIL)); \ + \ + _RETURN_FAIL \ }; #ifdef DEBUG_ENABLED @@ -204,12 +209,14 @@ bool Variant::booleanize() const { _RETURN_FAIL \ }; #else -#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _RETURN(p_a._data.m_type / p_b._data._int); \ - if (p_b.type == REAL) _RETURN(p_a._data.m_type / p_b._data._real); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM_DIV(m_prefix, m_op_name, m_name, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) \ + _RETURN(p_a._data.m_type / p_b._data._int); \ + if (p_b.type == REAL) \ + _RETURN(p_a._data.m_type / p_b._data._real); \ + \ + _RETURN_FAIL \ }; #endif @@ -223,39 +230,50 @@ bool Variant::booleanize() const { _RETURN(p_a._data.m_type); \ }; -#define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == INT) _RETURN(p_a._data.m_type m_op p_b._data._int); \ - if (p_b.type == REAL) _RETURN(p_a._data.m_type m_op p_b._data._real); \ - if (p_b.type == VECTOR2) _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == VECTOR3) _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_NUM_VEC(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == INT) \ + _RETURN(p_a._data.m_type m_op p_b._data._int); \ + if (p_b.type == REAL) \ + _RETURN(p_a._data.m_type m_op p_b._data._real); \ + if (p_b.type == VECTOR2) \ + _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ + if (p_b.type == VECTOR3) \ + _RETURN(p_a._data.m_type m_op *reinterpret_cast(p_b._data._mem)); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == STRING) _RETURN(*reinterpret_cast(p_b._data._mem) m_op *reinterpret_cast(p_a._data._mem)); \ - if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast(p_b._data._mem) m_op *reinterpret_cast(p_a._data._mem)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_STR_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) \ + _RETURN(*reinterpret_cast(p_b._data._mem) m_op *reinterpret_cast(p_a._data._mem)); \ + if (p_b.type == NODE_PATH) \ + _RETURN(*reinterpret_cast(p_b._data._mem) m_op *reinterpret_cast(p_a._data._mem)); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == STRING) _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_STR(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ + if (p_b.type == NODE_PATH) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ + \ + _RETURN_FAIL \ }; -#define DEFAULT_OP_STR_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == STRING) _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == NODE_PATH) _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == NIL) _RETURN(!(p_b.type m_op NIL)); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_STR_NULL(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == STRING) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ + if (p_b.type == NODE_PATH) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ + if (p_b.type == NIL) \ + _RETURN(!(p_b.type m_op NIL)); \ + \ + _RETURN_FAIL \ }; #define DEFAULT_OP_LOCALMEM_REV(m_prefix, m_op_name, m_name, m_op, m_type) \ @@ -294,13 +312,16 @@ bool Variant::booleanize() const { _RETURN(*reinterpret_cast(p_a._data._mem)); \ } -#define DEFAULT_OP_LOCALMEM_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ - CASE_TYPE(m_prefix, m_op_name, m_name) { \ - if (p_b.type == m_name) _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ - if (p_b.type == INT) _RETURN(*reinterpret_cast(p_a._data._mem) m_op p_b._data._int); \ - if (p_b.type == REAL) _RETURN(*reinterpret_cast(p_a._data._mem) m_op p_b._data._real); \ - \ - _RETURN_FAIL \ +#define DEFAULT_OP_LOCALMEM_NUM(m_prefix, m_op_name, m_name, m_op, m_type) \ + CASE_TYPE(m_prefix, m_op_name, m_name) { \ + if (p_b.type == m_name) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op *reinterpret_cast(p_b._data._mem)); \ + if (p_b.type == INT) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op p_b._data._int); \ + if (p_b.type == REAL) \ + _RETURN(*reinterpret_cast(p_a._data._mem) m_op p_b._data._real); \ + \ + _RETURN_FAIL \ } #define DEFAULT_OP_PTR(m_op, m_name, m_sub) \ @@ -398,7 +419,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH(math, p_op, p_a.type) { SWITCH_OP(math, OP_EQUAL, p_a.type) { CASE_TYPE(math, OP_EQUAL, NIL) { - if (p_b.type == NIL) _RETURN(true); + if (p_b.type == NIL) + _RETURN(true); if (p_b.type == OBJECT) _RETURN(_UNSAFE_OBJ_PROXY_PTR(p_b) == NULL); @@ -485,7 +507,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, SWITCH_OP(math, OP_NOT_EQUAL, p_a.type) { CASE_TYPE(math, OP_NOT_EQUAL, NIL) { - if (p_b.type == NIL) _RETURN(false); + if (p_b.type == NIL) + _RETURN(false); if (p_b.type == OBJECT) _RETURN(_UNSAFE_OBJ_PROXY_PTR(p_b) != NULL); diff --git a/core/vector.h b/core/vector.h index 269bc23bdd0..4d093fa5fab 100644 --- a/core/vector.h +++ b/core/vector.h @@ -68,7 +68,8 @@ public: void remove(int p_index) { _cowdata.remove(p_index); } void erase(const T &p_val) { int idx = find(p_val); - if (idx >= 0) remove(idx); + if (idx >= 0) + remove(idx); }; void invert(); diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 0735839c75f..bc2b706ea37 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -1191,7 +1191,8 @@ float SchlickFresnel(float u) { } float GTR1(float NdotH, float a) { - if (a >= 1.0) return 1.0 / M_PI; + if (a >= 1.0) + return 1.0 / M_PI; float a2 = a * a; float t = 1.0 + (a2 - 1.0) * NdotH * NdotH; return (a2 - 1.0) / (M_PI * log(a2) * t); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index a1d3b3beeca..544afa9f7d7 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -985,7 +985,8 @@ float SchlickFresnel(float u) { } float GTR1(float NdotH, float a) { - if (a >= 1.0) return 1.0 / M_PI; + if (a >= 1.0) + return 1.0 / M_PI; float a2 = a * a; float t = 1.0 + (a2 - 1.0) * NdotH * NdotH; return (a2 - 1.0) / (M_PI * log(a2) * t); diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 27e81312356..f1f63126f92 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -248,7 +248,8 @@ void IP_Unix::get_local_interfaces(Map *r_interfaces) co info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr)); } - if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct); + if (ifAddrStruct != NULL) + freeifaddrs(ifAddrStruct); } #endif diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 691371a1888..288bb7d7049 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -333,7 +333,8 @@ void FindReplaceBar::_update_results_count() { results_count = 0; String searched = get_search_text(); - if (searched.empty()) return; + if (searched.empty()) + return; String full_text = text_edit->get_text(); @@ -341,7 +342,8 @@ void FindReplaceBar::_update_results_count() { while (true) { int pos = is_case_sensitive() ? full_text.find(searched, from_pos) : full_text.findn(searched, from_pos); - if (pos == -1) break; + if (pos == -1) + break; int pos_subsequent = pos + searched.length(); if (is_whole_words()) { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 3d7e89255d8..744024dd031 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -700,7 +700,8 @@ bool EditorFileDialog::_is_open_should_be_disabled() { void EditorFileDialog::update_file_name() { int idx = filter->get_selected() - 1; if ((idx == -1 && filter->get_item_count() == 2) || (filter->get_item_count() > 2 && idx >= 0 && idx < filter->get_item_count() - 2)) { - if (idx == -1) idx += 1; + if (idx == -1) + idx += 1; String filter_str = filters[idx]; String file_str = file->get_text(); String base_name = file_str.get_basename(); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 1db98faf0a3..55f3259630f 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1786,7 +1786,8 @@ void FindBar::_update_results_count() { results_count = 0; String searched = search_text->get_text(); - if (searched.empty()) return; + if (searched.empty()) + return; String full_text = rich_text_label->get_text(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index dcd61605f95..79531ba1872 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3063,12 +3063,18 @@ void EditorNode::_update_debug_options() { bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", true); bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", true); - if (check_deploy_remote) _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true); - if (check_file_server) _menu_option_confirm(RUN_FILE_SERVER, true); - if (check_debug_collisons) _menu_option_confirm(RUN_DEBUG_COLLISONS, true); - if (check_debug_navigation) _menu_option_confirm(RUN_DEBUG_NAVIGATION, true); - if (check_live_debug) _menu_option_confirm(RUN_LIVE_DEBUG, true); - if (check_reload_scripts) _menu_option_confirm(RUN_RELOAD_SCRIPTS, true); + if (check_deploy_remote) + _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true); + if (check_file_server) + _menu_option_confirm(RUN_FILE_SERVER, true); + if (check_debug_collisons) + _menu_option_confirm(RUN_DEBUG_COLLISONS, true); + if (check_debug_navigation) + _menu_option_confirm(RUN_DEBUG_NAVIGATION, true); + if (check_live_debug) + _menu_option_confirm(RUN_LIVE_DEBUG, true); + if (check_reload_scripts) + _menu_option_confirm(RUN_RELOAD_SCRIPTS, true); } void EditorNode::_update_file_menu_opened() { @@ -3342,7 +3348,8 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) { ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(editor_data.get_scene_path(old_index)); } - if (p_change_tab) _scene_tab_changed(new_index); + if (p_change_tab) + _scene_tab_changed(new_index); editor_data.remove_scene(old_index); editor_data.get_undo_redo().clear_history(false); _update_title(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 329f30f9896..b0116983a40 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1682,20 +1682,28 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref &p_event) { switch (drag_type) { case DRAG_ANCHOR_TOP_LEFT: - if (!use_single_axis || !use_y) control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); - if (!use_single_axis || use_y) control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); + if (!use_single_axis || !use_y) + control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); + if (!use_single_axis || use_y) + control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); break; case DRAG_ANCHOR_TOP_RIGHT: - if (!use_single_axis || !use_y) control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); - if (!use_single_axis || use_y) control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); + if (!use_single_axis || !use_y) + control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); + if (!use_single_axis || use_y) + control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); break; case DRAG_ANCHOR_BOTTOM_RIGHT: - if (!use_single_axis || !use_y) control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); - if (!use_single_axis || use_y) control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); + if (!use_single_axis || !use_y) + control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); + if (!use_single_axis || use_y) + control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); break; case DRAG_ANCHOR_BOTTOM_LEFT: - if (!use_single_axis || !use_y) control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); - if (!use_single_axis || use_y) control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); + if (!use_single_axis || !use_y) + control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); + if (!use_single_axis || use_y) + control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); break; case DRAG_ANCHOR_ALL: if (!use_single_axis || !use_y) { @@ -5139,7 +5147,8 @@ void CanvasItemEditor::_focus_selection(int p_op) { Map &selection = editor_selection->get_selection(); for (Map::Element *E = selection.front(); E; E = E->next()) { CanvasItem *canvas_item = Object::cast_to(E->key()); - if (!canvas_item) continue; + if (!canvas_item) + continue; if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) continue; diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index e4b0630afa8..0e7a5153bc5 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -288,8 +288,10 @@ bool Path2DEditor::forward_gui_input(const Ref &p_event) { Vector2 gpoint = mm->get_position(); Ref curve = node->get_curve(); - if (curve == NULL) return true; - if (curve->get_point_count() < 2) return true; + if (curve == NULL) + return true; + if (curve->get_point_count() < 2) + return true; // Find edge edge_point = xform.xform(curve->get_closest_point(xform.affine_inverse().xform(mm->get_position()))); diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 35eef6102e7..1a75c8facb8 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -635,7 +635,8 @@ Ref PathSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) Ref ref; Path *path = Object::cast_to(p_spatial); - if (path) ref = Ref(memnew(PathSpatialGizmo(path))); + if (path) + ref = Ref(memnew(PathSpatialGizmo(path))); return ref; } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 6128c483a50..df21bad9ddf 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -818,7 +818,8 @@ void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, void ScriptTextEditor::_code_complete_script(const String &p_code, List *r_options, bool &r_force) { - if (color_panel->is_visible_in_tree()) return; + if (color_panel->is_visible_in_tree()) + return; Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base, base, script); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 61a1e326ad1..e8f52fc2526 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -708,9 +708,11 @@ void SpatialEditorViewport::_select_region() { item = sel; } - if (selected.find(item) != -1) continue; + if (selected.find(item) != -1) + continue; - if (_is_node_locked(item)) continue; + if (_is_node_locked(item)) + continue; Ref seg = sp->get_gizmo(); @@ -1349,7 +1351,8 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) { if (cursor.region_select) { - if (!clicked_wants_append) _clear_selected(); + if (!clicked_wants_append) + _clear_selected(); _select_region(); cursor.region_select = false; @@ -2042,7 +2045,8 @@ void SpatialEditorViewport::_sinput(const Ref &p_event) { } if (k->get_scancode() == KEY_SPACE) { - if (!k->is_pressed()) emit_signal("toggle_maximize_view", this); + if (!k->is_pressed()) + emit_signal("toggle_maximize_view", this); } } @@ -4616,7 +4620,8 @@ Dictionary SpatialEditor::get_state() const { Dictionary gizmos_status; for (int i = 0; i < gizmo_plugins_by_name.size(); i++) { - if (!gizmo_plugins_by_name[i]->can_be_hidden()) continue; + if (!gizmo_plugins_by_name[i]->can_be_hidden()) + continue; int state = gizmos_menu->get_item_state(gizmos_menu->get_item_index(i)); String name = gizmo_plugins_by_name[i]->get_name(); gizmos_status[name] = state; @@ -4710,7 +4715,8 @@ void SpatialEditor::set_state(const Dictionary &p_state) { gizmos_status.get_key_list(&keys); for (int j = 0; j < gizmo_plugins_by_name.size(); ++j) { - if (!gizmo_plugins_by_name[j]->can_be_hidden()) continue; + if (!gizmo_plugins_by_name[j]->can_be_hidden()) + continue; int state = EditorSpatialGizmoPlugin::VISIBLE; for (int i = 0; i < keys.size(); i++) { if (gizmo_plugins_by_name.write[j]->get_name() == keys[i]) { @@ -5612,7 +5618,8 @@ void SpatialEditor::_update_gizmos_menu() { gizmos_menu->clear(); for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) { - if (!gizmo_plugins_by_name[i]->can_be_hidden()) continue; + if (!gizmo_plugins_by_name[i]->can_be_hidden()) + continue; String plugin_name = gizmo_plugins_by_name[i]->get_name(); const int plugin_state = gizmo_plugins_by_name[i]->get_state(); gizmos_menu->add_multistate_item(TTR(plugin_name), 3, plugin_state, i); @@ -5636,7 +5643,8 @@ void SpatialEditor::_update_gizmos_menu() { void SpatialEditor::_update_gizmos_menu_theme() { for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) { - if (!gizmo_plugins_by_name[i]->can_be_hidden()) continue; + if (!gizmo_plugins_by_name[i]->can_be_hidden()) + continue; const int plugin_state = gizmo_plugins_by_name[i]->get_state(); const int idx = gizmos_menu->get_item_index(i); switch (plugin_state) { @@ -6163,9 +6171,11 @@ void SpatialEditor::_request_gizmo(Object *p_obj) { } void SpatialEditor::_toggle_maximize_view(Object *p_viewport) { - if (!p_viewport) return; + if (!p_viewport) + return; SpatialEditorViewport *current_viewport = Object::cast_to(p_viewport); - if (!current_viewport) return; + if (!current_viewport) + return; int index = -1; bool maximized = false; @@ -6177,7 +6187,8 @@ void SpatialEditor::_toggle_maximize_view(Object *p_viewport) { break; } } - if (index == -1) return; + if (index == -1) + return; if (!maximized) { @@ -6904,7 +6915,8 @@ Ref EditorSpatialGizmoPlugin::get_material(const String &p_name ERR_FAIL_COND_V(!materials.has(p_name), Ref()); ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref()); - if (p_gizmo.is_null() || materials[p_name].size() == 1) return materials[p_name][0]; + if (p_gizmo.is_null() || materials[p_name].size() == 1) + return materials[p_name][0]; int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); @@ -6941,7 +6953,8 @@ Ref EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) Ref ref = create_gizmo(p_spatial); - if (ref.is_null()) return ref; + if (ref.is_null()) + return ref; ref->set_plugin(this); ref->set_spatial_node(p_spatial); @@ -7000,7 +7013,8 @@ Ref EditorSpatialGizmoPlugin::create_gizmo(Spatial *p_spatia } Ref ref; - if (has_gizmo(p_spatial)) ref.instance(); + if (has_gizmo(p_spatial)) + ref.instance(); return ref; } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 67d8f53ac3b..c7f814be7ce 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -126,7 +126,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref p_library) { sb->get_shape_owners(&shapes); for (List::Element *E = shapes.front(); E; E = E->next()) { - if (sb->is_shape_owner_disabled(E->get())) continue; + if (sb->is_shape_owner_disabled(E->get())) + continue; Transform2D shape_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get()); bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get()); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 6d3ad917889..0c555fc026d 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1266,11 +1266,13 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, List output_names; for (int i = 0; i < node->get_input_port_count(); i++) { - if (!p_output && i == p_port_id) continue; + if (!p_output && i == p_port_id) + continue; input_names.push_back(node->get_input_port_name(i)); } for (int i = 0; i < node->get_output_port_count(); i++) { - if (p_output && i == p_port_id) continue; + if (p_output && i == p_port_id) + continue; output_names.push_back(node->get_output_port_name(i)); } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index f0a23d0b967..2291c91448b 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -436,11 +436,13 @@ void ProjectSettingsEditor::_show_last_added(const Ref &p_event, con } child = child->get_next(); } - if (found) break; + if (found) + break; r = r->get_next(); } - if (found) input_editor->ensure_cursor_is_visible(); + if (found) + input_editor->ensure_cursor_is_visible(); } void ProjectSettingsEditor::_wait_for_key(const Ref &p_event) { @@ -1551,7 +1553,8 @@ void ProjectSettingsEditor::_update_translations() { String n = names[i]; String l = langs[i]; bool is_checked = l_filter.has(l); - if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && !is_checked) continue; + if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && !is_checked) + continue; TreeItem *t = translation_filter->create_item(root); t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1e8d818742b..0b852b52279 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -613,8 +613,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { for (List::Element *E = selection.front(); E; E = E->next()) { int index = E->get()->get_index(); - if (index > highest_id) highest_id = index; - if (index < lowest_id) lowest_id = index; + if (index > highest_id) + highest_id = index; + if (index < lowest_id) + lowest_id = index; if (E->get()->get_parent() != common_parent) common_parent = NULL; @@ -623,8 +625,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0)) break; // one or more nodes can not be moved - if (selection.size() == 1) editor_data->get_undo_redo().create_action(TTR("Move Node In Parent")); - if (selection.size() > 1) editor_data->get_undo_redo().create_action(TTR("Move Nodes In Parent")); + if (selection.size() == 1) + editor_data->get_undo_redo().create_action(TTR("Move Node In Parent")); + if (selection.size() > 1) + editor_data->get_undo_redo().create_action(TTR("Move Nodes In Parent")); for (int i = 0; i < selection.size(); i++) { Node *top_node = selection[i]; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index bdd7f0f429a..fa4827458de 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -165,11 +165,14 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must String p = p_path.strip_edges(); - if (p == "") return TTR("Path is empty."); - if (p.get_file().get_basename() == "") return TTR("Filename is empty."); + if (p == "") + return TTR("Path is empty."); + if (p.get_file().get_basename() == "") + return TTR("Filename is empty."); p = ProjectSettings::get_singleton()->localize_path(p); - if (!p.begins_with("res://")) return TTR("Path is not local."); + if (!p.begins_with("res://")) + return TTR("Path is not local."); DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (d->change_dir(p.get_base_dir()) != OK) { @@ -214,12 +217,15 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must index++; } - if (!found) return TTR("Invalid extension."); - if (!match) return TTR("Wrong extension chosen."); + if (!found) + return TTR("Invalid extension."); + if (!match) + return TTR("Wrong extension chosen."); /* Let ScriptLanguage do custom validation */ String path_error = ScriptServer::get_language(language_menu->get_selected())->validate_path(p); - if (path_error != "") return path_error; + if (path_error != "") + return path_error; /* All checks passed */ return ""; diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 082e70e0e07..d25fd6a027a 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -206,7 +206,8 @@ public: void ScriptEditorDebugger::debug_copy() { String msg = reason->get_text(); - if (msg == "") return; + if (msg == "") + return; OS::get_singleton()->set_clipboard(msg); } diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 7aec7e7afe6..dbbb220d890 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -421,7 +421,8 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector< ERR_FAIL_COND_V(!spatial_node, false); ERR_FAIL_COND_V(!valid, false); - if (hidden && !gizmo_plugin->is_selectable_when_hidden()) return false; + if (hidden && !gizmo_plugin->is_selectable_when_hidden()) + return false; if (selectable_icon_size > 0.0f) { Vector3 origin = spatial_node->get_global_transform().get_origin(); @@ -460,10 +461,12 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector< break; } } - if (any_out) break; + if (any_out) + break; } - if (!any_out) return true; + if (!any_out) + return true; } if (collision_mesh.is_valid()) { @@ -495,7 +498,8 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, ERR_FAIL_COND_V(!spatial_node, false); ERR_FAIL_COND_V(!valid, false); - if (hidden && !gizmo_plugin->is_selectable_when_hidden()) return false; + if (hidden && !gizmo_plugin->is_selectable_when_hidden()) + return false; if (r_gizmo_handle && !hidden) { @@ -776,7 +780,8 @@ EditorSpatialGizmo::EditorSpatialGizmo() { EditorSpatialGizmo::~EditorSpatialGizmo() { - if (gizmo_plugin != NULL) gizmo_plugin->unregister_gizmo(this); + if (gizmo_plugin != NULL) + gizmo_plugin->unregister_gizmo(this); clear(); } diff --git a/main/tests/test_astar.cpp b/main/tests/test_astar.cpp index cc63ae796e8..a69542b55bc 100644 --- a/main/tests/test_astar.cpp +++ b/main/tests/test_astar.cpp @@ -173,7 +173,8 @@ bool test_add_remove() { for (int i = 0; i < 20000; i++) { int u = Math::rand() % 5; int v = Math::rand() % 4; - if (u == v) v = 4; + if (u == v) + v = 4; if (Math::rand() % 2 == 1) { // Add a (possibly existing) directed edge and confirm connectivity a.connect_points(u, v, false); @@ -195,7 +196,8 @@ bool test_add_remove() { for (int j = 0; j < 10; j++) { int u = Math::rand() % 5; int v = Math::rand() % 4; - if (u == v) v = 4; + if (u == v) + v = 4; if (Math::rand() % 2 == 1) a.connect_points(u, v, false); else @@ -239,7 +241,8 @@ bool test_solutions() { int u, v; u = Math::rand() % N; v = Math::rand() % (N - 1); - if (u == v) v = N - 1; + if (u == v) + v = N - 1; // Pick a random operation int op = Math::rand(); @@ -253,14 +256,16 @@ bool test_solutions() { // Add edge (u, v); possibly bidirectional a.connect_points(u, v, op % 2); adj[u][v] = true; - if (op % 2) adj[v][u] = true; + if (op % 2) + adj[v][u] = true; break; case 6: case 7: // Remove edge (u, v); possibly bidirectional a.disconnect_points(u, v, op % 2); adj[u][v] = false; - if (op % 2) adj[v][u] = false; + if (op % 2) + adj[v][u] = false; break; case 8: // Remove point u and add it back; clears adjacent edges and changes coordinates @@ -291,12 +296,14 @@ bool test_solutions() { int count = 0; for (int u = 0; u < N; u++) for (int v = 0; v < N; v++) - if (adj[u][v]) count++; + if (adj[u][v]) + count++; printf("Test #%4d: %3d edges, ", test + 1, count); count = 0; for (int u = 0; u < N; u++) for (int v = 0; v < N; v++) - if (!Math::is_inf(d[u][v])) count++; + if (!Math::is_inf(d[u][v])) + count++; printf("%3d/%d pairs of reachable points\n", count - N, N * (N - 1)); // Check A*'s output @@ -339,7 +346,8 @@ bool test_solutions() { } exit: - if (!match) return false; + if (!match) + return false; } return true; } diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 4112e41d67b..1bebdc191b1 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -968,22 +968,26 @@ bool test_31() { String a = ""; success = a[0] == 0; OS::get_singleton()->print("Is 0 String[0]:, %s\n", success ? "OK" : "FAIL"); - if (!success) state = false; + if (!success) + state = false; String b = "Godot"; success = b[b.size()] == 0; OS::get_singleton()->print("Is 0 String[size()]:, %s\n", success ? "OK" : "FAIL"); - if (!success) state = false; + if (!success) + state = false; const String c = ""; success = c[0] == 0; OS::get_singleton()->print("Is 0 const String[0]:, %s\n", success ? "OK" : "FAIL"); - if (!success) state = false; + if (!success) + state = false; const String d = "Godot"; success = d[d.size()] == 0; OS::get_singleton()->print("Is 0 const String[size()]:, %s\n", success ? "OK" : "FAIL"); - if (!success) state = false; + if (!success) + state = false; return state; }; diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index 97a3715e6c3..b21197d3dc1 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -81,7 +81,8 @@ void ShapeBullet::add_owner(ShapeOwnerBullet *p_owner) { void ShapeBullet::remove_owner(ShapeOwnerBullet *p_owner, bool p_permanentlyFromThisBody) { Map::Element *E = owners.find(p_owner); - if (!E) return; + if (!E) + return; E->get()--; if (p_permanentlyFromThisBody || 0 >= E->get()) { owners.erase(E); diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 7e8f6059488..190a5ccd8f3 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -171,7 +171,8 @@ public: contactDebugCount = 0; } _FORCE_INLINE_ void add_debug_contact(const Vector3 &p_contact) { - if (contactDebugCount < contactDebug.size()) contactDebug.write[contactDebugCount++] = p_contact; + if (contactDebugCount < contactDebug.size()) + contactDebug.write[contactDebugCount++] = p_contact; } _FORCE_INLINE_ Vector get_debug_contacts() { return contactDebug; } _FORCE_INLINE_ int get_debug_contact_count() { return contactDebugCount; } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 4ba1065e844..b564c62823c 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -138,10 +138,12 @@ inline bool is_point_in_triangle(const Vector3 &p_point, const Vector3 p_vertice lambda[2] = p_vertices[0].cross(p_vertices[1]).dot(p_point) / det; // Point is in the plane if all lambdas sum to 1. - if (!Math::is_equal_approx(lambda[0] + lambda[1] + lambda[2], 1)) return false; + if (!Math::is_equal_approx(lambda[0] + lambda[1] + lambda[2], 1)) + return false; // Point is inside the triangle if all lambdas are positive. - if (lambda[0] < 0 || lambda[1] < 0 || lambda[2] < 0) return false; + if (lambda[0] < 0 || lambda[1] < 0 || lambda[2] < 0) + return false; return true; } @@ -532,7 +534,8 @@ void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, // Check if distance exists. for (const List::Element *E = intersections.front(); E; E = E->next()) - if (Math::is_equal_approx(**E, p_distance)) return; + if (Math::is_equal_approx(**E, p_distance)) + return; intersections.push_back(p_distance); } @@ -798,7 +801,8 @@ int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) { // Check if vertex exists. int vertex_id = _get_point_idx(p_vertex.point); - if (vertex_id != -1) return vertex_id; + if (vertex_id != -1) + return vertex_id; vertices.push_back(p_vertex); return vertices.size() - 1; @@ -824,7 +828,8 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vert // Sort along the axis with the greatest difference. int axis = 0; - if (Math::abs(new_point.x - first_point.x) < Math::abs(new_point.y - first_point.y)) axis = 1; + if (Math::abs(new_point.x - first_point.x) < Math::abs(new_point.y - first_point.y)) + axis = 1; // Add it to the beginning or the end appropriately. if (new_point[axis] < first_point[axis]) @@ -842,7 +847,8 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vert // Determine axis being sorted against i.e. the axis with the greatest difference. int axis = 0; - if (Math::abs(last_point.x - first_point.x) < Math::abs(last_point.y - first_point.y)) axis = 1; + if (Math::abs(last_point.x - first_point.x) < Math::abs(last_point.y - first_point.y)) + axis = 1; // Insert the point at the appropriate index. for (int insert_idx = 0; insert_idx < r_vertex_indices.size(); ++insert_idx) { @@ -861,7 +867,8 @@ void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vert void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_indices) { int segments = p_segment_indices.size() - 1; - if (segments < 2) return; + if (segments < 2) + return; // Faces around an inner vertex are merged by moving the inner vertex to the first vertex. for (int sorted_idx = 1; sorted_idx < segments; ++sorted_idx) { @@ -901,7 +908,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ // Skip flattened faces. if (outer_edge_idx[0] == p_segment_indices[closest_idx] || - outer_edge_idx[1] == p_segment_indices[closest_idx]) continue; + outer_edge_idx[1] == p_segment_indices[closest_idx]) + continue; //Don't create degenerate triangles. Vector2 edge1[2] = { @@ -934,7 +942,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ for (int i = 0; i < merge_faces_idx.size(); ++i) faces.remove(merge_faces_idx[i]); - if (degenerate_points.size() == 0) continue; + if (degenerate_points.size() == 0) + continue; // Split faces using degenerate points. for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { @@ -964,7 +973,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ break; } } - if (existing) continue; + if (existing) + continue; // Check if point is on an each edge. for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) { @@ -1053,10 +1063,12 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // Check if intersection point is an edge point. if ((intersection_point - edge_points[0]).length_squared() < vertex_snap2 || - (intersection_point - edge_points[1]).length_squared() < vertex_snap2) continue; + (intersection_point - edge_points[1]).length_squared() < vertex_snap2) + continue; // Check if edge exists, by checking if the intersecting segment is parallel to the edge. - if (are_segements_parallel(p_segment_points, edge_points, vertex_snap2)) continue; + if (are_segements_parallel(p_segment_points, edge_points, vertex_snap2)) + continue; // Add the intersection point as a new vertex. Vertex2D new_vertex; @@ -1387,7 +1399,8 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face p_collection.build2DFacesB[p_face_idx_b] = Build2DFaces(); has_degenerate = true; } - if (has_degenerate) return; + if (has_degenerate) + return; // Ensure B has points either side of or in the plane of A. int in_plane_count = 0, over_count = 0, under_count = 0; @@ -1403,7 +1416,8 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face under_count++; } // If all points under or over the plane, there is no intesection. - if (over_count == 3 || under_count == 3) return; + if (over_count == 3 || under_count == 3) + return; // Ensure A has points either side of or in the plane of B. in_plane_count = 0; @@ -1421,7 +1435,8 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face under_count++; } // If all points under or over the plane, there is no intesection. - if (over_count == 3 || under_count == 3) return; + if (over_count == 3 || under_count == 3) + return; // Check for intersection using the SAT theorem. { diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 1eb6a0f6b60..c7a9690b4ee 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1799,11 +1799,15 @@ CSGBrush *CSGPolygon::_build_brush() { final_polygon_min = p; final_polygon_max = final_polygon_min; } else { - if (p.x < final_polygon_min.x) final_polygon_min.x = p.x; - if (p.y < final_polygon_min.y) final_polygon_min.y = p.y; + if (p.x < final_polygon_min.x) + final_polygon_min.x = p.x; + if (p.y < final_polygon_min.y) + final_polygon_min.y = p.y; - if (p.x > final_polygon_max.x) final_polygon_max.x = p.x; - if (p.y > final_polygon_max.y) final_polygon_max.y = p.y; + if (p.x > final_polygon_max.x) + final_polygon_max.x = p.x; + if (p.y > final_polygon_max.y) + final_polygon_max.y = p.y; } } Vector2 final_polygon_size = final_polygon_max - final_polygon_min; diff --git a/modules/fbx/fbx_parser/FBXProperties.cpp b/modules/fbx/fbx_parser/FBXProperties.cpp index 62f2ba52d99..66d5a1b35cf 100644 --- a/modules/fbx/fbx_parser/FBXProperties.cpp +++ b/modules/fbx/fbx_parser/FBXProperties.cpp @@ -223,7 +223,8 @@ DirectPropertyMap PropertyTable::GetUnparsedProperties() const { for (const LazyPropertyMap::value_type &element : lazyProps) { // Skip parsed properties - if (props.end() != props.find(element.first)) continue; + if (props.end() != props.find(element.first)) + continue; // Read the element's value. // Wrap the naked pointer (since the call site is required to acquire ownership) @@ -231,7 +232,8 @@ DirectPropertyMap PropertyTable::GetUnparsedProperties() const { Property *prop = ReadTypedProperty(element.second); // Element could not be read. Skip it. - if (!prop) continue; + if (!prop) + continue; // Add to result result[element.first] = prop; diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index fb10690c4ef..d7e0741f434 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -181,7 +181,8 @@ void *godot_get_class_tag(const godot_string_name *p_class) { } godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) { - if (!p_object) return NULL; + if (!p_object) + return NULL; Object *o = (Object *)p_object; return o->is_class_ptr(p_class_tag) ? (godot_object *)o : NULL; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 712bdcefb49..f44e19fecd2 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -870,71 +870,92 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: } break; //unary operators case GDScriptParser::OperatorNode::OP_NEG: { - if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) return -1; + if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_POS: { - if (!_create_unary_operator(codegen, on, Variant::OP_POSITIVE, p_stack_level)) return -1; + if (!_create_unary_operator(codegen, on, Variant::OP_POSITIVE, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_NOT: { - if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) return -1; + if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_BIT_INVERT: { - if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) return -1; + if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) + return -1; } break; //binary operators (in precedence order) case GDScriptParser::OperatorNode::OP_IN: { - if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_EQUAL: { - if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_NOT_EQUAL: { - if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_LESS: { - if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_LESS_EQUAL: { - if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_GREATER: { - if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: { - if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_ADD: { - if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_SUB: { - if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_MUL: { - if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_DIV: { - if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_MOD: { - if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) + return -1; } break; //case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break; //case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break; case GDScriptParser::OperatorNode::OP_BIT_AND: { - if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_BIT_OR: { - if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_BIT_XOR: { - if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) + return -1; } break; //shift case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { - if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) + return -1; } break; case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { - if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) return -1; + if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) + return -1; } break; //assignment operators case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: diff --git a/modules/gdscript/gdscript_compiler.h b/modules/gdscript/gdscript_compiler.h index 4906bd0fbfa..d2891e74d01 100644 --- a/modules/gdscript/gdscript_compiler.h +++ b/modules/gdscript/gdscript_compiler.h @@ -123,10 +123,12 @@ class GDScriptCompiler { Vector opcodes; void alloc_stack(int p_level) { - if (p_level >= stack_max) stack_max = p_level + 1; + if (p_level >= stack_max) + stack_max = p_level + 1; } void alloc_call(int p_params) { - if (p_params >= call_max) call_max = p_params; + if (p_params >= call_max) + call_max = p_params; } int current_line; diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 90344a51a26..4fe503fb27d 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -57,7 +57,8 @@ struct GDScriptDataType { Ref