diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index d3b0039e722..fe9e468774e 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -527,7 +527,7 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } } else if (command == "set_skip_breakpoints") { - ERR_FAIL_COND(data.size() < 1); + ERR_FAIL_COND(data.is_empty()); script_debugger->set_skip_breakpoints(data[0]); } else { bool captured = false; @@ -631,7 +631,7 @@ Error RemoteDebugger::_core_capture(const String &p_cmd, const Array &p_data, bo } } else if (p_cmd == "set_skip_breakpoints") { - ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_data.is_empty(), ERR_INVALID_DATA); script_debugger->set_skip_breakpoints(p_data[0]); } else if (p_cmd == "break") { script_debugger->debug(script_debugger->get_break_language()); @@ -643,7 +643,7 @@ Error RemoteDebugger::_core_capture(const String &p_cmd, const Array &p_data, bo Error RemoteDebugger::_profiler_capture(const String &p_cmd, const Array &p_data, bool &r_captured) { r_captured = false; - ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_data.is_empty(), ERR_INVALID_DATA); ERR_FAIL_COND_V(p_data[0].get_type() != Variant::BOOL, ERR_INVALID_DATA); ERR_FAIL_COND_V(!has_profiler(p_cmd), ERR_UNAVAILABLE); Array opts; diff --git a/core/io/image.cpp b/core/io/image.cpp index 9aa7c9794a2..d85a2ead1b5 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -1029,7 +1029,7 @@ void Image::resize_to_po2(bool p_square, Interpolation p_interpolation) { } void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { - ERR_FAIL_COND_MSG(data.size() == 0, "Cannot resize image before creating it, use set_data() first."); + ERR_FAIL_COND_MSG(data.is_empty(), "Cannot resize image before creating it, use set_data() first."); ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats."); bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */; @@ -1700,7 +1700,7 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3 } void Image::shrink_x2() { - ERR_FAIL_COND(data.size() == 0); + ERR_FAIL_COND(data.is_empty()); if (mipmaps) { //just use the lower mipmap as base and copy all @@ -1710,7 +1710,7 @@ void Image::shrink_x2() { int new_size = data.size() - ofs; new_img.resize(new_size); - ERR_FAIL_COND(new_img.size() == 0); + ERR_FAIL_COND(new_img.is_empty()); { uint8_t *w = new_img.ptrw(); @@ -1729,8 +1729,8 @@ void Image::shrink_x2() { ERR_FAIL_COND(!_can_modify(format)); int ps = get_format_pixel_size(format); new_img.resize((width / 2) * (height / 2) * ps); - ERR_FAIL_COND(new_img.size() == 0); - ERR_FAIL_COND(data.size() == 0); + ERR_FAIL_COND(new_img.is_empty()); + ERR_FAIL_COND(data.is_empty()); { uint8_t *w = new_img.ptrw(); @@ -3323,7 +3323,7 @@ void Image::adjust_bcs(float p_brightness, float p_contrast, float p_saturation) } Image::UsedChannels Image::detect_used_channels(CompressSource p_source) const { - ERR_FAIL_COND_V(data.size() == 0, USED_CHANNELS_RGBA); + ERR_FAIL_COND_V(data.is_empty(), USED_CHANNELS_RGBA); ERR_FAIL_COND_V(is_compressed(), USED_CHANNELS_RGBA); bool r = false, g = false, b = false, a = false, c = false; @@ -3878,7 +3878,7 @@ Error Image::load_ktx_from_buffer(const Vector &p_array) { void Image::convert_rg_to_ra_rgba8() { ERR_FAIL_COND(format != FORMAT_RGBA8); - ERR_FAIL_COND(!data.size()); + ERR_FAIL_COND(data.is_empty()); int s = data.size(); uint8_t *w = data.ptrw(); @@ -3891,7 +3891,7 @@ void Image::convert_rg_to_ra_rgba8() { void Image::convert_ra_rgba8_to_rg() { ERR_FAIL_COND(format != FORMAT_RGBA8); - ERR_FAIL_COND(!data.size()); + ERR_FAIL_COND(data.is_empty()); int s = data.size(); uint8_t *w = data.ptrw(); @@ -3904,7 +3904,7 @@ void Image::convert_ra_rgba8_to_rg() { void Image::convert_rgba8_to_bgra8() { ERR_FAIL_COND(format != FORMAT_RGBA8); - ERR_FAIL_COND(!data.size()); + ERR_FAIL_COND(data.is_empty()); int s = data.size(); uint8_t *w = data.ptrw(); diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index faf7d75172b..06888c7cda2 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -454,7 +454,7 @@ bool XMLParser::is_empty() const { } Error XMLParser::open_buffer(const Vector &p_buffer) { - ERR_FAIL_COND_V(p_buffer.size() == 0, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_buffer.is_empty(), ERR_INVALID_DATA); if (data_copy) { memdelete_arr(data_copy); diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index 74cb92539a8..1e5f12bebf1 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -93,7 +93,7 @@ void Geometry2D::make_atlas(const Vector &p_rects, Vector &r_re // For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a // 256x8192 atlas (won't work anywhere). - ERR_FAIL_COND(p_rects.size() == 0); + ERR_FAIL_COND(p_rects.is_empty()); for (int i = 0; i < p_rects.size(); i++) { ERR_FAIL_COND(p_rects[i].width <= 0); ERR_FAIL_COND(p_rects[i].height <= 0); diff --git a/core/variant/array.cpp b/core/variant/array.cpp index ab0315ae345..5d6fbb8bed1 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -316,17 +316,17 @@ void Array::erase(const Variant &p_value) { } Variant Array::front() const { - ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array."); + ERR_FAIL_COND_V_MSG(_p->array.is_empty(), Variant(), "Can't take value from empty array."); return operator[](0); } Variant Array::back() const { - ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array."); + ERR_FAIL_COND_V_MSG(_p->array.is_empty(), Variant(), "Can't take value from empty array."); return operator[](_p->array.size() - 1); } Variant Array::pick_random() const { - ERR_FAIL_COND_V_MSG(_p->array.size() == 0, Variant(), "Can't take value from empty array."); + ERR_FAIL_COND_V_MSG(_p->array.is_empty(), Variant(), "Can't take value from empty array."); return operator[](Math::rand() % _p->array.size()); } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 90f7e7b44a7..b551a7059e8 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -885,7 +885,7 @@ struct _VariantCall { ERR_FAIL_COND_V_MSG(size % sizeof(int32_t), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit integer) to convert to PackedInt32Array."); const uint8_t *r = p_instance->ptr(); dest.resize(size / sizeof(int32_t)); - ERR_FAIL_COND_V(dest.size() == 0, dest); // Avoid UB in case resize failed. + ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. memcpy(dest.ptrw(), r, dest.size() * sizeof(int32_t)); return dest; } @@ -899,7 +899,7 @@ struct _VariantCall { ERR_FAIL_COND_V_MSG(size % sizeof(int64_t), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit integer) to convert to PackedInt64Array."); const uint8_t *r = p_instance->ptr(); dest.resize(size / sizeof(int64_t)); - ERR_FAIL_COND_V(dest.size() == 0, dest); // Avoid UB in case resize failed. + ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. memcpy(dest.ptrw(), r, dest.size() * sizeof(int64_t)); return dest; } @@ -913,7 +913,7 @@ struct _VariantCall { ERR_FAIL_COND_V_MSG(size % sizeof(float), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit float) to convert to PackedFloat32Array."); const uint8_t *r = p_instance->ptr(); dest.resize(size / sizeof(float)); - ERR_FAIL_COND_V(dest.size() == 0, dest); // Avoid UB in case resize failed. + ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. memcpy(dest.ptrw(), r, dest.size() * sizeof(float)); return dest; } @@ -927,7 +927,7 @@ struct _VariantCall { ERR_FAIL_COND_V_MSG(size % sizeof(double), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit double) to convert to PackedFloat64Array."); const uint8_t *r = p_instance->ptr(); dest.resize(size / sizeof(double)); - ERR_FAIL_COND_V(dest.size() == 0, dest); // Avoid UB in case resize failed. + ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed. memcpy(dest.ptrw(), r, dest.size() * sizeof(double)); return dest; } diff --git a/drivers/d3d12/d3d12_context.cpp b/drivers/d3d12/d3d12_context.cpp index da112d83766..d2d1cae5c87 100644 --- a/drivers/d3d12/d3d12_context.cpp +++ b/drivers/d3d12/d3d12_context.cpp @@ -329,7 +329,7 @@ Error D3D12Context::_select_adapter(int &r_index) { adapters.push_back(curr_adapter); } - ERR_FAIL_COND_V_MSG(adapters.size() == 0, ERR_CANT_CREATE, "Adapters enumeration reported zero accessible devices."); + ERR_FAIL_COND_V_MSG(adapters.is_empty(), ERR_CANT_CREATE, "Adapters enumeration reported zero accessible devices."); // The device should really be a preference, but for now choosing a discrete GPU over the // integrated one is better than the default. diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 475f3c33b87..928e4e23ce2 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -471,7 +471,7 @@ void MeshStorage::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, i Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); uint64_t data_size = p_data.size(); ERR_FAIL_COND(p_offset + data_size > mesh->surfaces[p_surface]->vertex_buffer_size); @@ -486,7 +486,7 @@ void MeshStorage::mesh_surface_update_attribute_region(RID p_mesh, int p_surface Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); uint64_t data_size = p_data.size(); ERR_FAIL_COND(p_offset + data_size > mesh->surfaces[p_surface]->attribute_buffer_size); @@ -501,7 +501,7 @@ void MeshStorage::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); uint64_t data_size = p_data.size(); ERR_FAIL_COND(p_offset + data_size > mesh->surfaces[p_surface]->skin_buffer_size); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 3c863bdc19e..93dcc341c1c 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -387,7 +387,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread } } else if (p_msg == "set_pid") { - ERR_FAIL_COND(p_data.size() < 1); + ERR_FAIL_COND(p_data.is_empty()); remote_pid = p_data[0]; } else if (p_msg == "scene:click_ctrl") { ERR_FAIL_COND(p_data.size() < 2); @@ -806,7 +806,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread } performance_profiler->update_monitors(monitors); } else if (p_msg == "filesystem:update_file") { - ERR_FAIL_COND(p_data.size() < 1); + ERR_FAIL_COND(p_data.is_empty()); if (EditorFileSystem::get_singleton()) { EditorFileSystem::get_singleton()->update_file(p_data[0]); } diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 567b686b856..d740641f570 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -63,7 +63,7 @@ float EditorCommandPalette::_score_path(const String &p_search, const String &p_ } void EditorCommandPalette::_update_command_search(const String &search_text) { - ERR_FAIL_COND(commands.size() == 0); + ERR_FAIL_COND(commands.is_empty()); HashMap sections; TreeItem *first_section = nullptr; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4501c52bc8e..6633121737f 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3892,7 +3892,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v } void EditorInspector::_multiple_properties_changed(Vector p_paths, Array p_values, bool p_changing) { - ERR_FAIL_COND(p_paths.size() == 0 || p_values.size() == 0); + ERR_FAIL_COND(p_paths.is_empty() || p_values.is_empty()); ERR_FAIL_COND(p_paths.size() != p_values.size()); String names; for (int i = 0; i < p_paths.size(); i++) { diff --git a/editor/import/3d/collada.cpp b/editor/import/3d/collada.cpp index ae8041d6fe9..d484476b35f 100644 --- a/editor/import/3d/collada.cpp +++ b/editor/import/3d/collada.cpp @@ -178,7 +178,7 @@ Transform3D Collada::Node::get_global_transform() const { } Vector Collada::AnimationTrack::get_value_at_time(float p_time) const { - ERR_FAIL_COND_V(keys.size() == 0, Vector()); + ERR_FAIL_COND_V(keys.is_empty(), Vector()); int i = 0; for (i = 0; i < keys.size(); i++) { diff --git a/editor/import/3d/resource_importer_obj.cpp b/editor/import/3d/resource_importer_obj.cpp index a5e51636af7..4b340ea997f 100644 --- a/editor/import/3d/resource_importer_obj.cpp +++ b/editor/import/3d/resource_importer_obj.cpp @@ -306,7 +306,7 @@ static Error _parse_obj(const String &p_path, List> &r_meshes, Vector face[3]; face[0] = v[1].split("/"); face[1] = v[2].split("/"); - ERR_FAIL_COND_V(face[0].size() == 0, ERR_FILE_CORRUPT); + ERR_FAIL_COND_V(face[0].is_empty(), ERR_FILE_CORRUPT); ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_FILE_CORRUPT); for (int i = 2; i < v.size() - 1; i++) { diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index d437f23740c..9edf468ec68 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -192,7 +192,7 @@ static void _plot_triangle(Vector2i *p_vertices, const Vector2i &p_offset, bool } Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const HashMap> &p_source_file_options, const HashMap &p_base_paths) { - ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen + ERR_FAIL_COND_V(p_source_file_options.is_empty(), ERR_BUG); //should never happen Vector charts; Vector pack_data_files; diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index f0fd40a77e8..eed09f289dd 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -201,7 +201,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { valid_normals.resize(vpc); } - ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image..."); + ERR_FAIL_COND_MSG(valid_positions.is_empty(), "No pixels with transparency > 128 in image..."); if (capture_colors) { PackedColorArray pca; diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index af04d45ba84..f9a2ffdd3b4 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -280,7 +280,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { valid_normals.resize(vpc); } - ERR_FAIL_COND_MSG(valid_positions.size() == 0, "No pixels with transparency > 128 in image..."); + ERR_FAIL_COND_MSG(valid_positions.is_empty(), "No pixels with transparency > 128 in image..."); Vector texdata; diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 370c423b40a..086abc0859a 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -154,7 +154,7 @@ void MultiMeshEditor::_populate() { area_accum += area; } - ERR_FAIL_COND_MSG(triangle_area_map.size() == 0, "Couldn't map area."); + ERR_FAIL_COND_MSG(triangle_area_map.is_empty(), "Couldn't map area."); ERR_FAIL_COND_MSG(area_accum == 0, "Couldn't map area."); Ref multimesh = memnew(MultiMesh); diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index a427d0359de..77ed48a6624 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -969,7 +969,7 @@ void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref &p_gizmo) { ERR_FAIL_COND_V(!materials.has(p_name), Ref()); - ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref()); + ERR_FAIL_COND_V(materials[p_name].is_empty(), Ref()); if (p_gizmo.is_null() || materials[p_name].size() == 1) { return materials[p_name][0]; diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 98d83b6e955..fe8fb79c566 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -473,7 +473,7 @@ void ShaderTextEditor::_validate_script() { if (last_compile_result != OK) { //preprocessor error - ERR_FAIL_COND(err_positions.size() == 0); + ERR_FAIL_COND(err_positions.is_empty()); String err_text = error_pp; int err_line = err_positions.front()->get().line; diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 4895e1d2912..1762efeab6c 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -269,7 +269,7 @@ void TileSetScenesCollectionSourceEditor::_scene_file_selected(const String &p_p void TileSetScenesCollectionSourceEditor::_source_delete_pressed() { Vector selected_indices = scene_tiles_list->get_selected_items(); - ERR_FAIL_COND(selected_indices.size() <= 0); + ERR_FAIL_COND(selected_indices.is_empty()); int scene_id = scene_tiles_list->get_item_metadata(selected_indices[0]); EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index ffb482d103a..6f7d571792f 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -996,7 +996,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) { const String &file = p_files[i]; folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir()); } - ERR_FAIL_COND(folders_set.size() == 0); // This can't really happen, we consume every dropped file path above. + ERR_FAIL_COND(folders_set.is_empty()); // This can't really happen, we consume every dropped file path above. PackedStringArray folders; for (const String &E : folders_set) { diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 07cb96b9bcf..367dd324c2a 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -368,7 +368,7 @@ void RenameDialog::_post_popup() { preview_node = nullptr; Array selected_node_list = editor_selection->get_selected_nodes(); - ERR_FAIL_COND(selected_node_list.size() == 0); + ERR_FAIL_COND(selected_node_list.is_empty()); preview_node = Object::cast_to(selected_node_list[0]); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 5b789c9445a..d7738e0ba52 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2660,7 +2660,7 @@ void SceneTreeDock::_create() { } else if (current_option == TOOL_REPLACE) { List selection = editor_selection->get_selected_node_list(); - ERR_FAIL_COND(selection.size() <= 0); + ERR_FAIL_COND(selection.is_empty()); EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); ur->create_action(TTR("Change type of node(s)"), UndoRedo::MERGE_DISABLE, selection.front()->get()); @@ -2679,7 +2679,7 @@ void SceneTreeDock::_create() { ur->commit_action(false); } else if (current_option == TOOL_REPARENT_TO_NEW_NODE) { List selection = editor_selection->get_selected_node_list(); - ERR_FAIL_COND(selection.size() <= 0); + ERR_FAIL_COND(selection.is_empty()); // Find top level node in selection bool only_one_top_node = true; diff --git a/main/main.cpp b/main/main.cpp index bc2a6107b55..f8fc3804aec 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -3546,7 +3546,7 @@ bool Main::start() { Error err; Vector paths = get_files_with_extension(gdscript_docs_path, "gd"); - ERR_FAIL_COND_V_MSG(paths.size() == 0, false, "Couldn't find any GDScript files under the given directory: " + gdscript_docs_path); + ERR_FAIL_COND_V_MSG(paths.is_empty(), false, "Couldn't find any GDScript files under the given directory: " + gdscript_docs_path); for (const String &path : paths) { Ref gdscript = ResourceLoader::load(path); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 1de76c60b5d..604ad5e1e4d 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -800,7 +800,7 @@ CSGBrush *CSGMesh3D::_build_brush() { if (arrays.size() == 0) { _make_dirty(); - ERR_FAIL_COND_V(arrays.size() == 0, memnew(CSGBrush)); + ERR_FAIL_COND_V(arrays.is_empty(), memnew(CSGBrush)); } Vector avertices = arrays[Mesh::ARRAY_VERTEX]; diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp index 63f12ea1c13..910c4ed242b 100644 --- a/modules/enet/enet_multiplayer_peer.cpp +++ b/modules/enet/enet_multiplayer_peer.cpp @@ -40,20 +40,20 @@ void ENetMultiplayerPeer::set_target_peer(int p_peer) { int ENetMultiplayerPeer::get_packet_peer() const { ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_V(incoming_packets.size() == 0, 1); + ERR_FAIL_COND_V(incoming_packets.is_empty(), 1); return incoming_packets.front()->get().from; } MultiplayerPeer::TransferMode ENetMultiplayerPeer::get_packet_mode() const { ERR_FAIL_COND_V_MSG(!_is_active(), TRANSFER_MODE_RELIABLE, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_V(incoming_packets.size() == 0, TRANSFER_MODE_RELIABLE); + ERR_FAIL_COND_V(incoming_packets.is_empty(), TRANSFER_MODE_RELIABLE); return incoming_packets.front()->get().transfer_mode; } int ENetMultiplayerPeer::get_packet_channel() const { ERR_FAIL_COND_V_MSG(!_is_active(), 1, "The multiplayer instance isn't currently active."); - ERR_FAIL_COND_V(incoming_packets.size() == 0, 1); + ERR_FAIL_COND_V(incoming_packets.is_empty(), 1); int ch = incoming_packets.front()->get().channel; if (ch >= SYSCH_MAX) { // First 2 channels are reserved. return ch - SYSCH_MAX + 1; @@ -321,7 +321,7 @@ int ENetMultiplayerPeer::get_available_packet_count() const { } Error ENetMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V_MSG(incoming_packets.size() == 0, ERR_UNAVAILABLE, "No incoming packets available."); + ERR_FAIL_COND_V_MSG(incoming_packets.is_empty(), ERR_UNAVAILABLE, "No incoming packets available."); _pop_current_packet(); diff --git a/modules/enet/enet_packet_peer.cpp b/modules/enet/enet_packet_peer.cpp index f2bf5337eef..edb33fc96b9 100644 --- a/modules/enet/enet_packet_peer.cpp +++ b/modules/enet/enet_packet_peer.cpp @@ -90,7 +90,7 @@ int ENetPacketPeer::get_available_packet_count() const { Error ENetPacketPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_NULL_V(peer, ERR_UNCONFIGURED); - ERR_FAIL_COND_V(!packet_queue.size(), ERR_UNAVAILABLE); + ERR_FAIL_COND_V(packet_queue.is_empty(), ERR_UNAVAILABLE); if (last_packet) { enet_packet_destroy(last_packet); last_packet = nullptr; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 3ba6e4d1607..649bd735c6a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -510,7 +510,7 @@ void GDScriptParser::push_multiline(bool p_state) { } void GDScriptParser::pop_multiline() { - ERR_FAIL_COND_MSG(multiline_stack.size() == 0, "Parser bug: trying to pop from multiline stack without available value."); + ERR_FAIL_COND_MSG(multiline_stack.is_empty(), "Parser bug: trying to pop from multiline stack without available value."); multiline_stack.pop_back(); tokenizer->set_multiline_mode(multiline_stack.size() > 0 ? multiline_stack.back()->get() : false); } diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7344dc054f2..4d9c3a5bc71 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -250,7 +250,7 @@ Error GLTFDocument::_serialize_gltf_extensions(Ref p_state) const { } Error GLTFDocument::_serialize_scenes(Ref p_state) { - ERR_FAIL_COND_V_MSG(p_state->root_nodes.size() == 0, ERR_INVALID_DATA, "GLTF export: The scene must have at least one root node."); + ERR_FAIL_COND_V_MSG(p_state->root_nodes.is_empty(), ERR_INVALID_DATA, "GLTF export: The scene must have at least one root node."); // Godot only supports one scene per glTF file. Array scenes; Dictionary scene_dict; @@ -807,7 +807,7 @@ Error GLTFDocument::_parse_buffers(Ref p_state, const String &p_base_ uri = uri.uri_decode(); uri = p_base_path.path_join(uri).replace("\\", "/"); // Fix for Windows. buffer_data = FileAccess::get_file_as_bytes(uri); - ERR_FAIL_COND_V_MSG(buffer.size() == 0, ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); + ERR_FAIL_COND_V_MSG(buffer.is_empty(), ERR_PARSE_ERROR, "glTF: Couldn't load binary file as an array: " + uri); } ERR_FAIL_COND_V(!buffer.has("byteLength"), ERR_PARSE_ERROR); @@ -1545,7 +1545,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref p_state, } } - ERR_FAIL_COND_V(attribs.size() == 0, -1); + ERR_FAIL_COND_V(attribs.is_empty(), -1); Ref accessor; accessor.instantiate(); @@ -1904,7 +1904,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref p_stat _calc_accessor_min_max(i, element_count, type_max, attribs, type_min); } - ERR_FAIL_COND_V(!attribs.size(), -1); + ERR_FAIL_COND_V(attribs.is_empty(), -1); Ref accessor; accessor.instantiate(); @@ -2222,7 +2222,7 @@ Error GLTFDocument::_serialize_meshes(Ref p_state) { Dictionary attributes; { Vector a = array[Mesh::ARRAY_VERTEX]; - ERR_FAIL_COND_V(!a.size(), ERR_INVALID_DATA); + ERR_FAIL_COND_V(a.is_empty(), ERR_INVALID_DATA); attributes["POSITION"] = _encode_accessor_as_vec3(p_state, a, true); vertex_num = a.size(); } @@ -2789,7 +2789,7 @@ Error GLTFDocument::_parse_meshes(Ref p_state) { } else if (primitive == Mesh::PRIMITIVE_TRIANGLES) { //generate indices because they need to be swapped for CW/CCW const Vector &vertices = array[Mesh::ARRAY_VERTEX]; - ERR_FAIL_COND_V(vertices.size() == 0, ERR_PARSE_ERROR); + ERR_FAIL_COND_V(vertices.is_empty(), ERR_PARSE_ERROR); Vector indices; const int vs = vertices.size(); indices.resize(vs); @@ -2920,7 +2920,7 @@ Error GLTFDocument::_parse_meshes(Ref p_state) { if (t.has("TANGENT")) { const Vector tangents_v3 = _decode_accessor_as_vec3(p_state, t["TANGENT"], true); const Vector src_tangents = array[Mesh::ARRAY_TANGENT]; - ERR_FAIL_COND_V(src_tangents.size() == 0, ERR_PARSE_ERROR); + ERR_FAIL_COND_V(src_tangents.is_empty(), ERR_PARSE_ERROR); Vector tangents_v4; @@ -4415,7 +4415,7 @@ Error GLTFDocument::_verify_skin(Ref p_state, Ref p_skin) { out_roots.sort(); - ERR_FAIL_COND_V(out_roots.size() == 0, FAILED); + ERR_FAIL_COND_V(out_roots.is_empty(), FAILED); // Make sure the roots are the exact same (they better be) ERR_FAIL_COND_V(out_roots.size() != p_skin->roots.size(), FAILED); @@ -6111,7 +6111,7 @@ struct SceneFormatImporterGLTFInterpolate { template T GLTFDocument::_interpolate_track(const Vector &p_times, const Vector &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { - ERR_FAIL_COND_V(!p_values.size(), T()); + ERR_FAIL_COND_V(p_values.is_empty(), T()); if (p_times.size() != (p_values.size() / (p_interp == GLTFAnimation::INTERP_CUBIC_SPLINE ? 3 : 1))) { ERR_PRINT_ONCE("The interpolated values are not corresponding to its times."); return p_values[0]; diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index 02b5aefc9fa..9ee281ad996 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -49,7 +49,7 @@ void LightmapperRD::add_mesh(const MeshData &p_mesh) { ERR_FAIL_COND(p_mesh.emission_on_uv2.is_null() || p_mesh.emission_on_uv2->is_empty()); ERR_FAIL_COND(p_mesh.albedo_on_uv2->get_width() != p_mesh.emission_on_uv2->get_width()); ERR_FAIL_COND(p_mesh.albedo_on_uv2->get_height() != p_mesh.emission_on_uv2->get_height()); - ERR_FAIL_COND(p_mesh.points.size() == 0); + ERR_FAIL_COND(p_mesh.points.is_empty()); MeshInstance mi; mi.data = p_mesh; mesh_instances.push_back(mi); @@ -1986,7 +1986,7 @@ Variant LightmapperRD::get_bake_mesh_userdata(int p_index) const { } Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const { - ERR_FAIL_COND_V(bake_textures.size() == 0, Rect2()); + ERR_FAIL_COND_V(bake_textures.is_empty(), Rect2()); Rect2 uv_ofs; Vector2 atlas_size = Vector2(bake_textures[0]->get_width(), bake_textures[0]->get_height()); uv_ofs.position = Vector2(mesh_instances[p_index].offset) / atlas_size; diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index 33c926689ab..e4b54ef0502 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -110,7 +110,7 @@ Ref ResourceImporterMP3::import_mp3(const String &p_path) { mp3_stream.instantiate(); mp3_stream->set_data(data); - ERR_FAIL_COND_V(!mp3_stream->get_data().size(), Ref()); + ERR_FAIL_COND_V(mp3_stream->get_data().is_empty(), Ref()); return mp3_stream; } diff --git a/modules/multiplayer/multiplayer_debugger.cpp b/modules/multiplayer/multiplayer_debugger.cpp index a4d2aed2d61..c816bd3b6bf 100644 --- a/modules/multiplayer/multiplayer_debugger.cpp +++ b/modules/multiplayer/multiplayer_debugger.cpp @@ -89,7 +89,7 @@ Error MultiplayerDebugger::_capture(void *p_user, const String &p_msg, const Arr // BandwidthProfiler int MultiplayerDebugger::BandwidthProfiler::bandwidth_usage(const Vector &p_buffer, int p_pointer) { - ERR_FAIL_COND_V(p_buffer.size() == 0, 0); + ERR_FAIL_COND_V(p_buffer.is_empty(), 0); int total_bandwidth = 0; uint64_t timestamp = OS::get_singleton()->get_ticks_msec(); @@ -174,7 +174,7 @@ Array MultiplayerDebugger::RPCFrame::serialize() { } bool MultiplayerDebugger::RPCFrame::deserialize(const Array &p_arr) { - ERR_FAIL_COND_V(p_arr.size() < 1, false); + ERR_FAIL_COND_V(p_arr.is_empty(), false); uint32_t size = p_arr[0]; ERR_FAIL_COND_V(size % 6, false); ERR_FAIL_COND_V((uint32_t)p_arr.size() != size + 1, false); @@ -279,7 +279,7 @@ Array MultiplayerDebugger::ReplicationFrame::serialize() { } bool MultiplayerDebugger::ReplicationFrame::deserialize(const Array &p_arr) { - ERR_FAIL_COND_V(p_arr.size() < 1, false); + ERR_FAIL_COND_V(p_arr.is_empty(), false); uint32_t size = p_arr[0]; ERR_FAIL_COND_V(size % 7, false); ERR_FAIL_COND_V((uint32_t)p_arr.size() != size + 1, false); diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp index 665b246bc54..5655467df71 100644 --- a/modules/multiplayer/scene_multiplayer.cpp +++ b/modules/multiplayer/scene_multiplayer.cpp @@ -440,7 +440,7 @@ void SceneMultiplayer::disconnect_peer(int p_id) { } Error SceneMultiplayer::send_bytes(Vector p_data, int p_to, MultiplayerPeer::TransferMode p_mode, int p_channel) { - ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet."); + ERR_FAIL_COND_V_MSG(p_data.is_empty(), ERR_INVALID_DATA, "Trying to send an empty raw packet."); ERR_FAIL_COND_V_MSG(!multiplayer_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no multiplayer peer is active."); ERR_FAIL_COND_V_MSG(multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a multiplayer peer which is not connected."); @@ -460,7 +460,7 @@ Error SceneMultiplayer::send_bytes(Vector p_data, int p_to, Multiplayer Error SceneMultiplayer::send_auth(int p_to, Vector p_data) { ERR_FAIL_COND_V(multiplayer_peer.is_null() || multiplayer_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED); ERR_FAIL_COND_V(!pending_peers.has(p_to), ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(p_data.size() < 1, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_data.is_empty(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V_MSG(pending_peers[p_to].local, ERR_FILE_CANT_WRITE, "The authentication session was previously marked as completed, no more authentication data can be sent."); ERR_FAIL_COND_V_MSG(pending_peers[p_to].remote, ERR_FILE_CANT_WRITE, "The remote peer notified that the authentication session was completed, no more authentication data can be sent."); diff --git a/modules/multiplayer/scene_replication_interface.cpp b/modules/multiplayer/scene_replication_interface.cpp index 35ff62dd06d..b61cf0bf1d8 100644 --- a/modules/multiplayer/scene_replication_interface.cpp +++ b/modules/multiplayer/scene_replication_interface.cpp @@ -783,7 +783,7 @@ Error SceneReplicationInterface::on_delta_receive(int p_from, const uint8_t *p_b ERR_CONTINUE_MSG(true, "Ignoring delta for non-authority or invalid synchronizer."); } List props = sync->get_delta_properties(indexes); - ERR_FAIL_COND_V(props.size() == 0, ERR_INVALID_DATA); + ERR_FAIL_COND_V(props.is_empty(), ERR_INVALID_DATA); Vector vars; vars.resize(props.size()); int consumed = 0; diff --git a/modules/navigation/nav_mesh_generator_3d.cpp b/modules/navigation/nav_mesh_generator_3d.cpp index b93d1dbd52f..95854f29e7b 100644 --- a/modules/navigation/nav_mesh_generator_3d.cpp +++ b/modules/navigation/nav_mesh_generator_3d.cpp @@ -713,7 +713,7 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref tri_areas; tri_areas.resize(ntris); - ERR_FAIL_COND(tri_areas.size() == 0); + ERR_FAIL_COND(tri_areas.is_empty()); memset(tri_areas.ptrw(), 0, ntris * sizeof(unsigned char)); rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle, verts, nverts, tris, ntris, tri_areas.ptrw()); diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 80ddfe703f1..36c3faaf750 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -2857,7 +2857,7 @@ bool OpenXRAPI::sync_action_sets(const Vector p_active_sets) { } } - ERR_FAIL_COND_V(active_sets.size() == 0, false); + ERR_FAIL_COND_V(active_sets.is_empty(), false); XrActionsSyncInfo sync_info = { XR_TYPE_ACTIONS_SYNC_INFO, // type diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index aef4f394b26..2812f37eb23 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -265,7 +265,7 @@ void UPNP::clear_devices() { } Ref UPNP::get_gateway() const { - ERR_FAIL_COND_V_MSG(devices.size() < 1, nullptr, "Couldn't find any UPNPDevices."); + ERR_FAIL_COND_V_MSG(devices.is_empty(), nullptr, "Couldn't find any UPNPDevices."); for (int i = 0; i < devices.size(); i++) { Ref dev = get_device(i); diff --git a/modules/websocket/remote_debugger_peer_websocket.cpp b/modules/websocket/remote_debugger_peer_websocket.cpp index 791b6d9ec9a..dc6833e8c3b 100644 --- a/modules/websocket/remote_debugger_peer_websocket.cpp +++ b/modules/websocket/remote_debugger_peer_websocket.cpp @@ -91,7 +91,7 @@ bool RemoteDebuggerPeerWebSocket::has_message() { } Array RemoteDebuggerPeerWebSocket::get_message() { - ERR_FAIL_COND_V(in_queue.size() < 1, Array()); + ERR_FAIL_COND_V(in_queue.is_empty(), Array()); Array msg = in_queue[0]; in_queue.pop_front(); return msg; diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 9e706dbeef7..332cf93d360 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -124,7 +124,7 @@ Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buff current_packet.data = nullptr; } - ERR_FAIL_COND_V(incoming_packets.size() == 0, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(incoming_packets.is_empty(), ERR_UNAVAILABLE); current_packet = incoming_packets.front()->get(); incoming_packets.pop_front(); @@ -164,7 +164,7 @@ void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) { } int WebSocketMultiplayerPeer::get_packet_peer() const { - ERR_FAIL_COND_V(incoming_packets.size() == 0, 1); + ERR_FAIL_COND_V(incoming_packets.is_empty(), 1); return incoming_packets.front()->get().source; } diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index 7c617e8bd22..011aecc7249 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -79,7 +79,7 @@ Dictionary VoxelGIData::_get_data() const { if (otsize != Vector3i()) { Ref img = Image::create_from_data(otsize.x * otsize.y, otsize.z, false, Image::FORMAT_L8, get_distance_field()); Vector df_png = img->save_png_to_buffer(); - ERR_FAIL_COND_V(df_png.size() == 0, Dictionary()); + ERR_FAIL_COND_V(df_png.is_empty(), Dictionary()); d["octree_df_png"] = df_png; } else { d["octree_df"] = Vector(); diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 5603b2dbe45..fb7d01f115b 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -100,22 +100,22 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra EngineDebugger::get_singleton()->send_message("filesystem:update_file", { arr }); } else if (p_msg == "inspect_object") { // Object Inspect - ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA); ObjectID id = p_args[0]; _send_object_id(id); } else if (p_msg == "override_camera_2D:set") { // Camera - ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA); bool enforce = p_args[0]; scene_tree->get_root()->enable_canvas_transform_override(enforce); } else if (p_msg == "override_camera_2D:transform") { - ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA); Transform2D transform = p_args[0]; scene_tree->get_root()->set_canvas_transform_override(transform); #ifndef _3D_DISABLED } else if (p_msg == "override_camera_3D:set") { - ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA); bool enable = p_args[0]; scene_tree->get_root()->enable_camera_3d_override(enable); @@ -200,7 +200,7 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra live_editor->_instance_node_func(p_args[0], p_args[1], p_args[2]); } else if (p_msg == "live_remove_node") { - ERR_FAIL_COND_V(p_args.size() < 1, ERR_INVALID_DATA); + ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA); live_editor->_remove_node_func(p_args[0]); } else if (p_msg == "live_remove_and_keep_node") { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 7bbc0a5ec5b..b9b68127dbe 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -82,7 +82,7 @@ Dictionary Control::_edit_get_state() const { } void Control::_edit_set_state(const Dictionary &p_state) { - ERR_FAIL_COND((p_state.size() <= 0) || + ERR_FAIL_COND(p_state.is_empty() || !p_state.has("rotation") || !p_state.has("scale") || !p_state.has("pivot") || !p_state.has("anchors") || !p_state.has("offsets") || !p_state.has("layout_mode") || !p_state.has("anchors_layout_preset")); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index e2925920a2e..95dc50f2030 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3927,7 +3927,7 @@ void TextEdit::end_complex_operation() { if (complex_operation_count > 0) { return; } - ERR_FAIL_COND(undo_stack.size() == 0); + ERR_FAIL_COND(undo_stack.is_empty()); undo_stack.back()->get().end_carets = carets; if (undo_stack.back()->get().chain_forward) { diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 6532a151140..0245584f172 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -4866,7 +4866,7 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol p.offset = data_tracks[i].data.size(); time_tracks[i].packets.push_back(p); } else { - ERR_FAIL_COND(time_tracks[i].packets.size() == 0); + ERR_FAIL_COND(time_tracks[i].packets.is_empty()); time_tracks[i].packets[time_tracks[i].packets.size() - 1].count++; } } @@ -4953,7 +4953,7 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol p.offset = data_tracks[comp_track].data.size(); time_tracks[comp_track].packets.push_back(p); } else { - ERR_CONTINUE(time_tracks[comp_track].packets.size() == 0); + ERR_CONTINUE(time_tracks[comp_track].packets.is_empty()); time_tracks[comp_track].packets[time_tracks[comp_track].packets.size() - 1].count++; } } diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index dde556c264c..a51e28c9fe2 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -147,7 +147,7 @@ void ImmediateMesh::surface_add_vertex_2d(const Vector2 &p_vertex) { void ImmediateMesh::surface_end() { ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it."); - ERR_FAIL_COND_MSG(!vertices.size(), "No vertices were added, surface can't be created."); + ERR_FAIL_COND_MSG(vertices.is_empty(), "No vertices were added, surface can't be created."); uint64_t format = ARRAY_FORMAT_VERTEX | ARRAY_FLAG_FORMAT_CURRENT_VERSION; diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index 2ffb8da46cc..952e99608d1 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -186,7 +186,7 @@ void ImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const Array &p_a Surface::LOD lod; lod.distance = E; lod.indices = p_lods[E]; - ERR_CONTINUE(lod.indices.size() == 0); + ERR_CONTINUE(lod.indices.is_empty()); s.lods.push_back(lod); } @@ -684,7 +684,7 @@ bool ImporterMesh::has_mesh() const { } Ref ImporterMesh::get_mesh(const Ref &p_base) { - ERR_FAIL_COND_V(surfaces.size() == 0, Ref()); + ERR_FAIL_COND_V(surfaces.is_empty(), Ref()); if (mesh.is_null()) { if (p_base.is_valid()) { diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index de81b9d7852..e90f163546c 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1192,7 +1192,7 @@ void SceneState::update_instance_resource(String p_path, Ref p_pack } int SceneState::find_node_by_path(const NodePath &p_node) const { - ERR_FAIL_COND_V_MSG(node_path_cache.size() == 0, -1, "This operation requires the node cache to have been built."); + ERR_FAIL_COND_V_MSG(node_path_cache.is_empty(), -1, "This operation requires the node cache to have been built."); if (!node_path_cache.has(p_node)) { if (get_base_scene_state().is_valid()) { diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index eb28c9e6019..b8b48541098 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -52,7 +52,7 @@ void PrimitiveMesh::_update() const { Vector points = arr[RS::ARRAY_VERTEX]; - ERR_FAIL_COND_MSG(points.size() == 0, "_create_mesh_array must return at least a vertex array."); + ERR_FAIL_COND_MSG(points.is_empty(), "_create_mesh_array must return at least a vertex array."); aabb = AABB(); diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 73baba6c939..653f234d3dc 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -690,7 +690,7 @@ Array SurfaceTool::commit_to_arrays() { } break; case Mesh::ARRAY_INDEX: { - ERR_CONTINUE(index_array.size() == 0); + ERR_CONTINUE(index_array.is_empty()); Vector array; array.resize(index_array.size()); @@ -1280,7 +1280,7 @@ SurfaceTool::CustomFormat SurfaceTool::get_custom_format(int p_channel_index) co } void SurfaceTool::optimize_indices_for_cache() { ERR_FAIL_NULL(optimize_vertex_cache_func); - ERR_FAIL_COND(index_array.size() == 0); + ERR_FAIL_COND(index_array.is_empty()); ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES); ERR_FAIL_COND(index_array.size() % 3 != 0); @@ -1290,7 +1290,7 @@ void SurfaceTool::optimize_indices_for_cache() { } AABB SurfaceTool::get_aabb() const { - ERR_FAIL_COND_V(vertex_array.size() == 0, AABB()); + ERR_FAIL_COND_V(vertex_array.is_empty(), AABB()); AABB aabb; for (uint32_t i = 0; i < vertex_array.size(); i++) { @@ -1310,8 +1310,8 @@ Vector SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun 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); + ERR_FAIL_COND_V(vertex_array.is_empty(), lod); + ERR_FAIL_COND_V(index_array.is_empty(), lod); ERR_FAIL_COND_V(index_array.size() % 3 != 0, lod); ERR_FAIL_COND_V(index_array.size() < (unsigned int)p_target_index_count, lod); diff --git a/scene/theme/theme_owner.cpp b/scene/theme/theme_owner.cpp index b559c8c58dd..8cdffe8c73a 100644 --- a/scene/theme/theme_owner.cpp +++ b/scene/theme/theme_owner.cpp @@ -250,7 +250,7 @@ void ThemeOwner::get_theme_type_dependencies(const Node *p_for_node, const Strin } Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List &p_theme_types) { - ERR_FAIL_COND_V_MSG(p_theme_types.size() == 0, Variant(), "At least one theme type must be specified."); + ERR_FAIL_COND_V_MSG(p_theme_types.is_empty(), Variant(), "At least one theme type must be specified."); // First, look through each control or window node in the branch, until no valid parent can be found. // Only nodes with a theme resource attached are considered. @@ -286,7 +286,7 @@ Variant ThemeOwner::get_theme_item_in_types(Theme::DataType p_data_type, const S } bool ThemeOwner::has_theme_item_in_types(Theme::DataType p_data_type, const StringName &p_name, const List &p_theme_types) { - ERR_FAIL_COND_V_MSG(p_theme_types.size() == 0, false, "At least one theme type must be specified."); + ERR_FAIL_COND_V_MSG(p_theme_types.is_empty(), false, "At least one theme type must be specified."); // First, look through each control or window node in the branch, until no valid parent can be found. // Only nodes with a theme resource attached are considered. diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index 6e49bb122b7..e1e92700742 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -204,7 +204,7 @@ Ref AudioEffectRecord::get_recording() const { Vector dst_data; ERR_FAIL_COND_V(current_instance.is_null(), nullptr); - ERR_FAIL_COND_V(current_instance->recording_data.size() == 0, nullptr); + ERR_FAIL_COND_V(current_instance->recording_data.is_empty(), nullptr); if (dst_format == AudioStreamWAV::FORMAT_8_BITS) { int data_size = current_instance->recording_data.size(); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index f340f7bbf8c..4a901897de0 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1589,7 +1589,7 @@ void AudioServer::remove_listener_changed_callback(AudioCallback p_callback, voi } void AudioServer::set_bus_layout(const Ref &p_bus_layout) { - ERR_FAIL_COND(p_bus_layout.is_null() || p_bus_layout->buses.size() == 0); + ERR_FAIL_COND(p_bus_layout.is_null() || p_bus_layout->buses.is_empty()); lock(); for (int i = 0; i < buses.size(); i++) { diff --git a/servers/physics_2d/godot_shape_2d.cpp b/servers/physics_2d/godot_shape_2d.cpp index 2b3f496fc02..db5e6b23535 100644 --- a/servers/physics_2d/godot_shape_2d.cpp +++ b/servers/physics_2d/godot_shape_2d.cpp @@ -584,7 +584,7 @@ void GodotConvexPolygonShape2D::set_data(const Variant &p_data) { if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) { Vector arr = p_data; - ERR_FAIL_COND(arr.size() == 0); + ERR_FAIL_COND(arr.is_empty()); point_count = arr.size(); points = memnew_arr(Point, point_count); const Vector2 *r = arr.ptr(); diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index 1c54ce56579..6230b93ebc4 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -138,7 +138,7 @@ void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, con RID ShaderRD::version_create() { //initialize() was never called - ERR_FAIL_COND_V(group_to_variant_map.size() == 0, RID()); + ERR_FAIL_COND_V(group_to_variant_map.is_empty(), RID()); Version version; version.dirty = true; @@ -301,7 +301,7 @@ void ShaderRD::_compile_variant(uint32_t p_variant, const CompileData *p_data) { Vector shader_data = RD::get_singleton()->shader_compile_binary_from_spirv(stages, name + ":" + itos(variant)); - ERR_FAIL_COND(shader_data.size() == 0); + ERR_FAIL_COND(shader_data.is_empty()); { MutexLock lock(variant_set_mutex); @@ -714,7 +714,7 @@ ShaderRD::ShaderRD() { void ShaderRD::initialize(const Vector &p_variant_defines, const String &p_general_defines) { ERR_FAIL_COND(variant_defines.size()); - ERR_FAIL_COND(p_variant_defines.size() == 0); + ERR_FAIL_COND(p_variant_defines.is_empty()); general_defines = p_general_defines.utf8(); @@ -776,7 +776,7 @@ void ShaderRD::_initialize_cache() { // Same as above, but allows specifying shader compilation groups. void ShaderRD::initialize(const Vector &p_variant_defines, const String &p_general_defines) { ERR_FAIL_COND(variant_defines.size()); - ERR_FAIL_COND(p_variant_defines.size() == 0); + ERR_FAIL_COND(p_variant_defines.is_empty()); general_defines = p_general_defines.utf8(); diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 245dac94ac6..05929a862ae 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -529,7 +529,7 @@ void MeshStorage::mesh_surface_update_vertex_region(RID p_mesh, int p_surface, i Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); ERR_FAIL_COND(mesh->surfaces[p_surface]->vertex_buffer.is_null()); uint64_t data_size = p_data.size(); const uint8_t *r = p_data.ptr(); @@ -541,7 +541,7 @@ void MeshStorage::mesh_surface_update_attribute_region(RID p_mesh, int p_surface Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); ERR_FAIL_COND(mesh->surfaces[p_surface]->attribute_buffer.is_null()); uint64_t data_size = p_data.size(); const uint8_t *r = p_data.ptr(); @@ -553,7 +553,7 @@ void MeshStorage::mesh_surface_update_skin_region(RID p_mesh, int p_surface, int Mesh *mesh = mesh_owner.get_or_null(p_mesh); ERR_FAIL_NULL(mesh); ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_surface, mesh->surface_count); - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); ERR_FAIL_COND(mesh->surfaces[p_surface]->skin_buffer.is_null()); uint64_t data_size = p_data.size(); const uint8_t *r = p_data.ptr(); diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp index 7784ad5d498..dd94982f1aa 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp @@ -859,7 +859,7 @@ void TextureStorage::texture_2d_initialize(RID p_texture, const Ref &p_im } void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector> &p_layers, RS::TextureLayeredType p_layered_type) { - ERR_FAIL_COND(p_layers.size() == 0); + ERR_FAIL_COND(p_layers.is_empty()); ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP && p_layers.size() != 6); ERR_FAIL_COND(p_layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY && (p_layers.size() < 6 || (p_layers.size() % 6) != 0)); @@ -971,7 +971,7 @@ void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector> &p_data) { - ERR_FAIL_COND(p_data.size() == 0); + ERR_FAIL_COND(p_data.is_empty()); Image::Image3DValidateError verr = Image::validate_3d_image(p_format, p_width, p_height, p_depth, p_mipmaps, p_data); if (verr != Image::VALIDATE_3D_OK) { @@ -1269,7 +1269,7 @@ Ref TextureStorage::texture_2d_get(RID p_texture) const { } #endif Vector data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0); - ERR_FAIL_COND_V(data.size() == 0, Ref()); + ERR_FAIL_COND_V(data.is_empty(), Ref()); Ref image; // Expand RGB10_A2 into RGBAH. This is needed for capturing viewport data @@ -1318,7 +1318,7 @@ Ref TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons ERR_FAIL_NULL_V(tex, Ref()); Vector data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer); - ERR_FAIL_COND_V(data.size() == 0, Ref()); + ERR_FAIL_COND_V(data.is_empty(), Ref()); Ref image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data); ERR_FAIL_COND_V(image->is_empty(), Ref()); if (tex->format != tex->validated_format) { diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 0c95301402e..5d65118159d 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -146,7 +146,7 @@ String RenderingDevice::shader_get_spirv_cache_key() const { RID RenderingDevice::shader_create_from_spirv(const Vector &p_spirv, const String &p_shader_name) { Vector bytecode = shader_compile_binary_from_spirv(p_spirv, p_shader_name); - ERR_FAIL_COND_V(bytecode.size() == 0, RID()); + ERR_FAIL_COND_V(bytecode.is_empty(), RID()); return shader_create_from_bytecode(bytecode); } @@ -2464,12 +2464,12 @@ RID RenderingDevice::uniform_buffer_create(uint32_t p_size_bytes, const Vector &p_uniforms, RID p_shader, uint32_t p_shader_set) { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND_V(p_uniforms.size() == 0, RID()); + ERR_FAIL_COND_V(p_uniforms.is_empty(), RID()); Shader *shader = shader_owner.get_or_null(p_shader); ERR_FAIL_NULL_V(shader, RID()); - ERR_FAIL_COND_V_MSG(p_shader_set >= (uint32_t)shader->uniform_sets.size() || shader->uniform_sets[p_shader_set].size() == 0, RID(), + ERR_FAIL_COND_V_MSG(p_shader_set >= (uint32_t)shader->uniform_sets.size() || shader->uniform_sets[p_shader_set].is_empty(), RID(), "Desired set (" + itos(p_shader_set) + ") not used by shader."); // See that all sets in shader are satisfied. diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 99b1c5631a7..99b0b1886cf 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -901,7 +901,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint64_t p_format, uint ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY, ERR_INVALID_PARAMETER); Vector indices = p_arrays[ai]; - ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(indices.is_empty(), ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(indices.size() != p_index_array_len, ERR_INVALID_PARAMETER); /* determine whether using 16 or 32 bits indices */ @@ -1326,7 +1326,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa float distance = E; ERR_CONTINUE(distance <= 0.0); Vector indices = p_lods[E]; - ERR_CONTINUE(indices.size() == 0); + ERR_CONTINUE(indices.is_empty()); uint32_t index_count = indices.size(); ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller.. @@ -1781,7 +1781,7 @@ Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p Vector attrib_data = p_data.attribute_data; Vector skin_data = p_data.skin_data; - ERR_FAIL_COND_V(vertex_data.size() == 0 && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array()); + ERR_FAIL_COND_V(vertex_data.is_empty() && (p_data.format & RS::ARRAY_FORMAT_VERTEX), Array()); int vertex_len = p_data.vertex_count; Vector index_data = p_data.index_data;