diff --git a/main/main.cpp b/main/main.cpp index 32262b50b32..aa2f5f2451a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -289,7 +289,7 @@ void initialize_physics() { // Physics server not found, Use the default physics physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server(); } - ERR_FAIL_COND(!physics_server_3d); + ERR_FAIL_NULL(physics_server_3d); physics_server_3d->init(); // 2D Physics server @@ -299,7 +299,7 @@ void initialize_physics() { // Physics server not found, Use the default physics physics_server_2d = PhysicsServer2DManager::get_singleton()->new_default_server(); } - ERR_FAIL_COND(!physics_server_2d); + ERR_FAIL_NULL(physics_server_2d); physics_server_2d->init(); } @@ -3022,7 +3022,7 @@ bool Main::start() { return false; } else { Object *ml = ClassDB::instantiate(main_loop_type); - ERR_FAIL_COND_V_MSG(!ml, false, "Can't instance MainLoop type."); + ERR_FAIL_NULL_V_MSG(ml, false, "Can't instance MainLoop type."); main_loop = Object::cast_to(ml); if (!main_loop) { @@ -3302,7 +3302,7 @@ bool Main::start() { scene = scenedata->instantiate(); } - ERR_FAIL_COND_V_MSG(!scene, false, "Failed loading scene: " + local_game_path); + ERR_FAIL_NULL_V_MSG(scene, false, "Failed loading scene: " + local_game_path + "."); sml->add_current_scene(scene); #ifdef MACOS_ENABLED diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 7de6219b103..bf3783966b1 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -447,7 +447,7 @@ void AnimatedSprite2D::play(const StringName &p_name, float p_custom_scale, bool name = animation; } - ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", name)); + ERR_FAIL_NULL_MSG(frames, vformat("There is no animation with name '%s'.", name)); ERR_FAIL_COND_MSG(!frames->get_animation_names().has(name), vformat("There is no animation with name '%s'.", name)); if (frames->get_frame_count(name) == 0) { diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index dac31058bd9..6a9dd6137d8 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -119,7 +119,7 @@ StringName AudioStreamPlayer2D::_get_actual_bus() { ERR_FAIL_COND_V(world_2d.is_null(), SceneStringNames::get_singleton()->Master); PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space()); - ERR_FAIL_COND_V(space_state == nullptr, SceneStringNames::get_singleton()->Master); + ERR_FAIL_NULL_V(space_state, SceneStringNames::get_singleton()->Master); PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS]; PhysicsDirectSpaceState2D::PointParameters point_params; diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index 6aeaf300d11..1b3b0bcef0b 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -560,7 +560,7 @@ Vector2 NavigationAgent2D::get_next_path_position() { const Vector &navigation_path = navigation_result->get_path(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector2(), "The agent has no parent."); + ERR_FAIL_NULL_V_MSG(agent_parent, Vector2(), "The agent has no parent."); return agent_parent->get_global_position(); } else { return navigation_path[navigation_path_index]; @@ -568,7 +568,7 @@ Vector2 NavigationAgent2D::get_next_path_position() { } real_t NavigationAgent2D::distance_to_target() const { - ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent."); + ERR_FAIL_NULL_V_MSG(agent_parent, 0.0, "The agent has no parent."); return agent_parent->get_global_position().distance_to(target_position); } diff --git a/scene/2d/physical_bone_2d.cpp b/scene/2d/physical_bone_2d.cpp index efffa56f176..64cf56fa85d 100644 --- a/scene/2d/physical_bone_2d.cpp +++ b/scene/2d/physical_bone_2d.cpp @@ -71,7 +71,7 @@ void PhysicalBone2D::_position_at_bone2d() { // Reset to Bone2D position if (parent_skeleton) { Bone2D *bone_to_use = parent_skeleton->get_bone(bone2d_index); - ERR_FAIL_COND_MSG(bone_to_use == nullptr, "It's not possible to position the bone with ID: " + itos(bone2d_index)); + ERR_FAIL_NULL_MSG(bone_to_use, "It's not possible to position the bone with ID: " + itos(bone2d_index) + "."); set_global_transform(bone_to_use->get_global_transform()); } } diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 93acf38fa8e..3c119671ec1 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -602,7 +602,7 @@ Vector3 NavigationAgent3D::get_next_path_position() { const Vector &navigation_path = navigation_result->get_path(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector3(), "The agent has no parent."); + ERR_FAIL_NULL_V_MSG(agent_parent, Vector3(), "The agent has no parent."); return agent_parent->get_global_position(); } else { return navigation_path[navigation_path_index] - Vector3(0, path_height_offset, 0); @@ -610,7 +610,7 @@ Vector3 NavigationAgent3D::get_next_path_position() { } real_t NavigationAgent3D::distance_to_target() const { - ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent."); + ERR_FAIL_NULL_V_MSG(agent_parent, 0.0, "The agent has no parent."); return agent_parent->get_global_position().distance_to(target_position); } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 1345cfcdb82..8250263c353 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -1231,7 +1231,7 @@ void AnimatedSprite3D::play(const StringName &p_name, float p_custom_scale, bool name = animation; } - ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", name)); + ERR_FAIL_NULL_MSG(frames, vformat("There is no animation with name '%s'.", name)); ERR_FAIL_COND_MSG(!frames->get_animation_names().has(name), vformat("There is no animation with name '%s'.", name)); if (frames->get_frame_count(name) == 0) { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 0254419d228..eeacef4ef71 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -1100,7 +1100,7 @@ bool AnimationNodeStateMachinePlayback::_check_advance_condition(const Refexpression.is_valid()) { AnimationTree *tree_base = state_machine->get_animation_tree(); - ERR_FAIL_COND_V(tree_base == nullptr, false); + ERR_FAIL_NULL_V(tree_base, false); NodePath advance_expression_base_node_path = tree_base->get_advance_expression_base_node(); Node *expression_base = tree_base->get_node_or_null(advance_expression_base_node_path); diff --git a/scene/gui/graph_edit_arranger.cpp b/scene/gui/graph_edit_arranger.cpp index c1750a7b0f3..1dc778254bd 100644 --- a/scene/gui/graph_edit_arranger.cpp +++ b/scene/gui/graph_edit_arranger.cpp @@ -33,7 +33,7 @@ #include "scene/gui/graph_edit.h" void GraphEditArranger::arrange_nodes() { - ERR_FAIL_COND(!graph_edit); + ERR_FAIL_NULL(graph_edit); if (!arranging_graph) { arranging_graph = true; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 3f4fd880538..58babee0a44 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -216,7 +216,7 @@ String RichTextLabel::_letters(int p_num, bool p_capitalize) const { } void RichTextLabel::_update_line_font(ItemFrame *p_frame, int p_line, const Ref &p_base_font, int p_base_font_size) { - ERR_FAIL_COND(p_frame == nullptr); + ERR_FAIL_NULL(p_frame); ERR_FAIL_COND(p_line < 0 || p_line >= (int)p_frame->lines.size()); Line &l = p_frame->lines[p_line]; @@ -267,7 +267,7 @@ void RichTextLabel::_update_line_font(ItemFrame *p_frame, int p_line, const Ref< } float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref &p_base_font, int p_base_font_size, int p_width, float p_h) { - ERR_FAIL_COND_V(p_frame == nullptr, p_h); + ERR_FAIL_NULL_V(p_frame, p_h); ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), p_h); Line &l = p_frame->lines[p_line]; @@ -448,7 +448,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref &p_base_font, int p_base_font_size, int p_width, float p_h, int *r_char_offset) { - ERR_FAIL_COND_V(p_frame == nullptr, p_h); + ERR_FAIL_NULL_V(p_frame, p_h); ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), p_h); Line &l = p_frame->lines[p_line]; @@ -748,7 +748,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref } int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs, int &r_processed_glyphs) { - ERR_FAIL_COND_V(p_frame == nullptr, 0); + ERR_FAIL_NULL_V(p_frame, 0); ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), 0); Vector2 off; @@ -5025,7 +5025,7 @@ bool RichTextLabel::_search_table(ItemTable *p_table, List::Element *p_f } bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p_string, int p_char_idx, bool p_reverse_search) { - ERR_FAIL_COND_V(p_frame == nullptr, false); + ERR_FAIL_NULL_V(p_frame, false); ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), false); Line &l = p_frame->lines[p_line]; @@ -5110,14 +5110,14 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p while (parent_element->get() != selection.from_frame) { parent_element = p_search_previous ? parent_element->prev() : parent_element->next(); - ERR_FAIL_COND_V(parent_element == nullptr, false); + ERR_FAIL_NULL_V(parent_element, false); } // Search remainder of table if (!(p_search_previous && parent_element == parent_table->subitems.front()) && parent_element != parent_table->subitems.back()) { parent_element = p_search_previous ? parent_element->prev() : parent_element->next(); // Don't want to search current item - ERR_FAIL_COND_V(parent_element == nullptr, false); + ERR_FAIL_NULL_V(parent_element, false); // Search for next element if (_search_table(parent_table, parent_element, p_string, p_search_previous)) { @@ -5166,7 +5166,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p_selection) const { String txt; - ERR_FAIL_COND_V(p_frame == nullptr, txt); + ERR_FAIL_NULL_V(p_frame, txt); ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), txt); Line &l = p_frame->lines[p_line]; diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index baa829b1a11..b4e28a1f1b5 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -351,7 +351,7 @@ void ScrollContainer::_notification(int p_what) { case NOTIFICATION_READY: { Viewport *viewport = get_viewport(); - ERR_FAIL_COND(!viewport); + ERR_FAIL_NULL(viewport); viewport->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_gui_focus_changed)); _reposition_children(); } break; diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 0f2bf860790..06acdd0237a 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -303,7 +303,7 @@ void CanvasItem::_notification(int p_what) { parent = parent->get_parent(); } - ERR_FAIL_COND(!viewport); + ERR_FAIL_NULL(viewport); window = Object::cast_to(viewport); if (window) { diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index af8beb1d256..2523215d4dc 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -1279,7 +1279,7 @@ SurfaceTool::CustomFormat SurfaceTool::get_custom_format(int p_channel_index) co return last_custom_format[p_channel_index]; } void SurfaceTool::optimize_indices_for_cache() { - ERR_FAIL_COND(optimize_vertex_cache_func == nullptr); + ERR_FAIL_NULL(optimize_vertex_cache_func); ERR_FAIL_COND(index_array.size() == 0); ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES); ERR_FAIL_COND(index_array.size() % 3 != 0); @@ -1308,7 +1308,7 @@ Vector SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun Vector lod; - ERR_FAIL_COND_V(simplify_func == nullptr, lod); + ERR_FAIL_NULL_V(simplify_func, lod); ERR_FAIL_COND_V(p_target_index_count < 0, lod); ERR_FAIL_COND_V(vertex_array.size() == 0, lod); ERR_FAIL_COND_V(index_array.size() == 0, lod); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 4b705bbb34e..b372fcb1e9d 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -5500,13 +5500,13 @@ int TileData::get_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit) const } bool TileData::is_valid_terrain_peering_bit(TileSet::CellNeighbor p_peering_bit) const { - ERR_FAIL_COND_V(!tile_set, false); + ERR_FAIL_NULL_V(tile_set, false); return tile_set->is_valid_terrain_peering_bit(terrain_set, p_peering_bit); } TileSet::TerrainsPattern TileData::get_terrains_pattern() const { - ERR_FAIL_COND_V(!tile_set, TileSet::TerrainsPattern()); + ERR_FAIL_NULL_V(tile_set, TileSet::TerrainsPattern()); TileSet::TerrainsPattern output(tile_set, terrain_set); output.set_terrain(terrain); @@ -5542,14 +5542,14 @@ float TileData::get_probability() const { // Custom data void TileData::set_custom_data(String p_layer_name, Variant p_value) { - ERR_FAIL_COND(!tile_set); + ERR_FAIL_NULL(tile_set); int p_layer_id = tile_set->get_custom_data_layer_by_name(p_layer_name); ERR_FAIL_COND_MSG(p_layer_id < 0, vformat("TileSet has no layer with name: %s", p_layer_name)); set_custom_data_by_layer_id(p_layer_id, p_value); } Variant TileData::get_custom_data(String p_layer_name) const { - ERR_FAIL_COND_V(!tile_set, Variant()); + ERR_FAIL_NULL_V(tile_set, Variant()); int p_layer_id = tile_set->get_custom_data_layer_by_name(p_layer_name); ERR_FAIL_COND_V_MSG(p_layer_id < 0, Variant(), vformat("TileSet has no layer with name: %s", p_layer_name)); return get_custom_data_by_layer_id(p_layer_id); diff --git a/scene/theme/theme_db.cpp b/scene/theme/theme_db.cpp index f94f92134f2..c0e7636f5a7 100644 --- a/scene/theme/theme_db.cpp +++ b/scene/theme/theme_db.cpp @@ -353,7 +353,7 @@ void ThemeDB::bind_class_external_item(const StringName &p_class_name, const Str } void ThemeDB::update_class_instance_items(Node *p_instance) { - ERR_FAIL_COND(!p_instance); + ERR_FAIL_NULL(p_instance); // Use the hierarchy to initialize all inherited theme caches. Setters carry the necessary // context and will set the values appropriately.