From 8230bf0a2f39f0849b670d26067207c45edcca1a Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Wed, 6 Sep 2017 23:50:18 +0200 Subject: Remove assignment and declarations in if statements After discussing with @reduz and @akien-mga it was decided that we do not allow assignments or declarations in if statements. This PR removes the instances of this I could find by automated means. --- scene/3d/bone_attachment.cpp | 6 ++++-- scene/3d/collision_shape.cpp | 3 ++- scene/3d/gi_probe.cpp | 3 ++- scene/3d/interpolated_camera.cpp | 4 ++-- scene/3d/path.cpp | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index e1a5329fb0..2580b645e2 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -71,7 +71,8 @@ void BoneAttachment::_get_property_list(List *p_list) const { void BoneAttachment::_check_bind() { - if (Skeleton *sk = Object::cast_to(get_parent())) { + Skeleton *sk = Object::cast_to(get_parent()); + if (sk) { int idx = sk->find_bone(bone_name); if (idx != -1) { @@ -86,7 +87,8 @@ void BoneAttachment::_check_unbind() { if (bound) { - if (Skeleton *sk = Object::cast_to(get_parent())) { + Skeleton *sk = Object::cast_to(get_parent()); + if (sk) { int idx = sk->find_bone(bone_name); if (idx != -1) { diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index 5f1151f8e9..f49d89122d 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -50,7 +50,8 @@ void CollisionShape::make_convex_from_brothers() { for (int i = 0; i < p->get_child_count(); i++) { Node *n = p->get_child(i); - if (MeshInstance *mi = Object::cast_to(n)) { + MeshInstance *mi = Object::cast_to(n); + if (mi) { Ref m = mi->get_mesh(); if (m.is_valid()) { diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 7792a86b4a..c2b5283b9c 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -1113,7 +1113,8 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { } } - if (Spatial *s = Object::cast_to(p_at_node)) { + Spatial *s = Object::cast_to(p_at_node); + if (s) { if (s->is_visible_in_tree()) { diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp index 157ae42571..0f281b694d 100644 --- a/scene/3d/interpolated_camera.cpp +++ b/scene/3d/interpolated_camera.cpp @@ -55,8 +55,8 @@ void InterpolatedCamera::_notification(int p_what) { Transform local_transform = get_global_transform(); local_transform = local_transform.interpolate_with(target_xform, delta); set_global_transform(local_transform); - - if (Camera *cam = Object::cast_to(node)) { + Camera *cam = Object::cast_to(node); + if (cam) { if (cam->get_projection() == get_projection()) { diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index ed4d88417c..60245fe6ce 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -155,8 +155,8 @@ void PathFollow::_notification(int p_what) { Node *parent = get_parent(); if (parent) { - - if ((path = Object::cast_to(parent))) { + path = Object::cast_to(parent); + if (path) { _update_transform(); } } -- cgit v1.2.3