diff --git a/core/map.h b/core/map.h index 75a38a3440f..a37d898a9cb 100644 --- a/core/map.h +++ b/core/map.h @@ -453,8 +453,9 @@ private: if (!rp) rp = _data._nil; Element *node = (rp->left == _data._nil) ? rp->right : rp->left; + node->parent = rp->parent; - if (_data._root == (node->parent = rp->parent)) { + if (_data._root == node->parent) { _data._root->left = node; } else { if (rp == rp->parent->left) { diff --git a/core/set.h b/core/set.h index 317e180869a..f68d78cea17 100644 --- a/core/set.h +++ b/core/set.h @@ -438,8 +438,9 @@ private: if (!rp) rp = _data._nil; Element *node = (rp->left == _data._nil) ? rp->right : rp->left; + node->parent = rp->parent; - if (_data._root == (node->parent = rp->parent)) { + if (_data._root == node->parent) { _data._root->left = node; } else { if (rp == rp->parent->left) { diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 30c8332fa35..fe2069089c0 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -159,7 +159,8 @@ void FileAccessWindows::seek_end(int64_t p_position) { size_t FileAccessWindows::get_pos() const { size_t aux_position = 0; - if (!(aux_position = ftell(f))) { + aux_position = ftell(f); + if (!aux_position) { check_errors(); }; return aux_position; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 594728d2e0d..e78d083a568 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -230,8 +230,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map(p_node)) { + MeshInstance *mi = Object::cast_to(p_node); + if (mi) { Node *col = mi->create_trimesh_collision_node(); ERR_FAIL_COND_V(!col, NULL); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3d5732c7497..f7c56bdc2e0 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -580,7 +580,8 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE } else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT - if (Node2D *node_2d = Object::cast_to(canvas_item)) { + Node2D *node_2d = Object::cast_to(canvas_item); + if (node_2d) { if (p_move_mode == MOVE_LOCAL_WITH_ROT) { Transform2D m; @@ -589,9 +590,10 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE } node_2d->set_position(node_2d->get_position() + drag); - } else if (Control *control = Object::cast_to(canvas_item)) { - - control->set_position(control->get_position() + drag); + } else { + Control *control = Object::cast_to(canvas_item); + if (control) + control->set_position(control->get_position() + drag); } } } @@ -742,7 +744,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op float radius = 0.05 / zoom; float basic_anchors[3] = { 0.0, 0.5, 1.0 }; for (int i = 0; i < 3; i++) { - if ((dist = fabs(p_anchor - basic_anchors[i])) < radius) { + dist = fabs(p_anchor - basic_anchors[i]); + if (dist < radius) { if (!snapped || dist <= dist_min) { p_anchor = basic_anchors[i]; dist_min = dist; @@ -750,7 +753,8 @@ float CanvasItemEditor::_anchor_snap(float p_anchor, bool *p_snapped, float p_op } } } - if (p_opposite_anchor >= 0 && (dist = fabs(p_anchor - p_opposite_anchor)) < radius) { + dist = fabs(p_anchor - p_opposite_anchor); + if (p_opposite_anchor >= 0 && dist < radius) { if (!snapped || dist <= dist_min) { p_anchor = p_opposite_anchor; dist_min = dist; @@ -2269,7 +2273,6 @@ void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_FIXED_PROCESS) { - EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); List &selection = editor_selection->get_selected_node_list(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index afdf48b3148..232b5e980a8 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -582,13 +582,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { new_scene_from_dialog->popup_centered_ratio(); new_scene_from_dialog->set_title(TTR("Save New Scene As..")); - } break; case TOOL_COPY_NODE_PATH: { List selection = editor_selection->get_selected_node_list(); - - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { Node *root = EditorNode::get_singleton()->get_edited_scene(); NodePath path = root->get_path().rel_path_to(node->get_path()); OS::get_singleton()->set_clipboard(path); @@ -597,8 +597,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_EDITABLE_CHILDREN: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder")); @@ -617,8 +619,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_USE_PLACEHOLDER: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { bool placeholder = node->get_scene_instance_load_placeholder(); placeholder = !placeholder; int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children")); @@ -635,15 +639,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_CLEAR_INSTANCING: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { Node *root = EditorNode::get_singleton()->get_edited_scene(); UndoRedo *undo_redo = &editor_data->get_undo_redo(); if (!root) break; ERR_FAIL_COND(node->get_filename() == String()); - undo_redo->create_action(TTR("Discard Instancing")); undo_redo->add_do_method(node, "set_filename", ""); undo_redo->add_undo_method(node, "set_filename", node->get_filename()); @@ -656,8 +661,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_OPEN: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { scene_tree->emit_signal("open", node->get_filename()); } } @@ -667,8 +674,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { node->set_scene_inherited_state(Ref()); scene_tree->update_tree(); EditorNode::get_singleton()->get_property_editor()->update_tree(); @@ -677,8 +686,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_SCENE_OPEN_INHERITED: { List selection = editor_selection->get_selected_node_list(); - if (List::Element *e = selection.front()) { - if (Node *node = e->get()) { + List::Element *e = selection.front(); + if (e) { + Node *node = e->get(); + if (node) { if (node && node->get_scene_inherited_state().is_valid()) { scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path()); } diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 2a24f8d4d1f..02b994f8db2 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -414,7 +414,8 @@ void VideoStreamPlaybackTheora::update(float p_delta) { bool buffer_full = false; /* if there's pending, decoded audio, grab it */ - if ((ret = vorbis_synthesis_pcmout(&vd, &pcm)) > 0) { + ret = vorbis_synthesis_pcmout(&vd, &pcm); + if (ret > 0) { const int AUXBUF_LEN = 4096; int to_read = ret; diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 328b987f1f7..8640f276994 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -130,24 +130,28 @@ Error ContextGL_Win::initialize() { 0, 0, 0 // Layer Masks Ignored }; - if (!(hDC = GetDC(hWnd))) { + hDC = GetDC(hWnd); + if (!hDC) { MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } - if (!(pixel_format = ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format? + pixel_format = ChoosePixelFormat(hDC, &pfd); + if (!pixel_format) // Did Windows Find A Matching Pixel Format? { MessageBox(NULL, "Can't Find A Suitable pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } - if (!SetPixelFormat(hDC, pixel_format, &pfd)) // Are We Able To Set The Pixel Format? + BOOL ret = SetPixelFormat(hDC, pixel_format, &pfd); + if (!ret) // Are We Able To Set The Pixel Format? { MessageBox(NULL, "Can't Set The pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE } - if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? + hRC = wglCreateContext(hDC); + if (!hRC) // Are We Able To Get A Rendering Context? { MessageBox(NULL, "Can't Create A Temporary GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return FALSE @@ -175,8 +179,8 @@ Error ContextGL_Win::initialize() { return ERR_CANT_CREATE; } - HGLRC new_hRC; - if (!(new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs))) { + HGLRC new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs); + if (!new_hRC) { wglDeleteContext(hRC); MessageBox(NULL, "Can't Create An OpenGL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return ERR_CANT_CREATE; // Return false diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index 00cfa812dec..0c7358f499f 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -379,7 +379,9 @@ void JoypadWindows::process_joypads() { IDirectInputDevice8_Acquire(joy->di_joy); joy->di_joy->Poll(); } - if (FAILED(hr = joy->di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js))) { + + hr = joy->di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js); + if (FAILED(hr)) { //printf("failed to read joy #%d\n", i); continue; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index deb9c255768..5814d883cde 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -996,7 +996,16 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int video_mode.fullscreen = false; } else { - if (!(hWnd = CreateWindowExW(dwExStyle, L"Engine", L"", dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, hInstance, NULL))) { + hWnd = CreateWindowExW( + dwExStyle, + L"Engine", L"", + dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + (GetSystemMetrics(SM_CXSCREEN) - WindowRect.right) / 2, + (GetSystemMetrics(SM_CYSCREEN) - WindowRect.bottom) / 2, + WindowRect.right - WindowRect.left, + WindowRect.bottom - WindowRect.top, + NULL, NULL, hInstance, NULL); + if (!hWnd) { MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION); return; // Return FALSE } diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 1d7bd8fc2a7..9bd5576d91d 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -137,7 +137,8 @@ void PathFollow2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - if ((path = Object::cast_to(get_parent()))) { + path = Object::cast_to(get_parent()); + if (path) { _update_transform(); } diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index e1a5329fb09..2580b645e21 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 5f1151f8e9e..f49d89122d0 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 7792a86b4ad..c2b5283b9c2 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 157ae425715..0f281b694d9 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 ed4d88417ca..60245fe6ceb 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(); } } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 990c0f3d964..87a232e766e 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -183,8 +183,8 @@ void FileDialog::_action_pressed() { String path = dir_access->get_current_dir(); path = path.replace("\\", "/"); - - if (TreeItem *item = tree->get_selected()) { + TreeItem *item = tree->get_selected(); + if (item) { Dictionary d = item->get_metadata(0); if (d["dir"]) { path = path.plus_file(d["name"]);