mirror of
https://github.com/godotengine/godot
synced 2024-09-05 06:58:29 +00:00
Merge pull request #87371 from AThousandShips/size_err_check
Replace error checks against `size` with `is_empty`
This commit is contained in:
commit
d00dc8facf
|
@ -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;
|
||||
|
|
|
@ -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<uint8_t> &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();
|
||||
|
|
|
@ -454,7 +454,7 @@ bool XMLParser::is_empty() const {
|
|||
}
|
||||
|
||||
Error XMLParser::open_buffer(const Vector<uint8_t> &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);
|
||||
|
|
|
@ -93,7 +93,7 @@ void Geometry2D::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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<String, TreeItem *> sections;
|
||||
TreeItem *first_section = nullptr;
|
||||
|
|
|
@ -3892,7 +3892,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
|
|||
}
|
||||
|
||||
void EditorInspector::_multiple_properties_changed(Vector<String> 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++) {
|
||||
|
|
|
@ -178,7 +178,7 @@ Transform3D Collada::Node::get_global_transform() const {
|
|||
}
|
||||
|
||||
Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const {
|
||||
ERR_FAIL_COND_V(keys.size() == 0, Vector<float>());
|
||||
ERR_FAIL_COND_V(keys.is_empty(), Vector<float>());
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < keys.size(); i++) {
|
||||
|
|
|
@ -306,7 +306,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
|
|||
Vector<String> 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++) {
|
||||
|
|
|
@ -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<String, HashMap<StringName, Variant>> &p_source_file_options, const HashMap<String, String> &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<EditorAtlasPacker::Chart> charts;
|
||||
Vector<PackData> pack_data_files;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<uint8_t> texdata;
|
||||
|
||||
|
|
|
@ -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> multimesh = memnew(MultiMesh);
|
||||
|
|
|
@ -969,7 +969,7 @@ void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMat
|
|||
|
||||
Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) {
|
||||
ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>());
|
||||
ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>());
|
||||
ERR_FAIL_COND_V(materials[p_name].is_empty(), Ref<StandardMaterial3D>());
|
||||
|
||||
if (p_gizmo.is_null() || materials[p_name].size() == 1) {
|
||||
return materials[p_name][0];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -269,7 +269,7 @@ void TileSetScenesCollectionSourceEditor::_scene_file_selected(const String &p_p
|
|||
|
||||
void TileSetScenesCollectionSourceEditor::_source_delete_pressed() {
|
||||
Vector<int> 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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Node>(selected_node_list[0]);
|
||||
|
||||
|
|
|
@ -2660,7 +2660,7 @@ void SceneTreeDock::_create() {
|
|||
|
||||
} else if (current_option == TOOL_REPLACE) {
|
||||
List<Node *> 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<Node *> 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;
|
||||
|
|
|
@ -3546,7 +3546,7 @@ bool Main::start() {
|
|||
Error err;
|
||||
|
||||
Vector<String> 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> gdscript = ResourceLoader::load(path);
|
||||
|
|
|
@ -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<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ Error GLTFDocument::_serialize_gltf_extensions(Ref<GLTFState> p_state) const {
|
|||
}
|
||||
|
||||
Error GLTFDocument::_serialize_scenes(Ref<GLTFState> 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;
|
||||
|
@ -806,7 +806,7 @@ Error GLTFDocument::_parse_buffers(Ref<GLTFState> 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);
|
||||
|
@ -1544,7 +1544,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_ints(Ref<GLTFState> p_state,
|
|||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(attribs.size() == 0, -1);
|
||||
ERR_FAIL_COND_V(attribs.is_empty(), -1);
|
||||
|
||||
Ref<GLTFAccessor> accessor;
|
||||
accessor.instantiate();
|
||||
|
@ -1903,7 +1903,7 @@ GLTFAccessorIndex GLTFDocument::_encode_accessor_as_floats(Ref<GLTFState> 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<GLTFAccessor> accessor;
|
||||
accessor.instantiate();
|
||||
|
@ -2221,7 +2221,7 @@ Error GLTFDocument::_serialize_meshes(Ref<GLTFState> p_state) {
|
|||
Dictionary attributes;
|
||||
{
|
||||
Vector<Vector3> 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();
|
||||
}
|
||||
|
@ -2788,7 +2788,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
|
|||
} else if (primitive == Mesh::PRIMITIVE_TRIANGLES) {
|
||||
//generate indices because they need to be swapped for CW/CCW
|
||||
const Vector<Vector3> &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<int> indices;
|
||||
const int vs = vertices.size();
|
||||
indices.resize(vs);
|
||||
|
@ -2919,7 +2919,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> p_state) {
|
|||
if (t.has("TANGENT")) {
|
||||
const Vector<Vector3> tangents_v3 = _decode_accessor_as_vec3(p_state, t["TANGENT"], true);
|
||||
const Vector<float> 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<float> tangents_v4;
|
||||
|
||||
|
@ -4414,7 +4414,7 @@ Error GLTFDocument::_verify_skin(Ref<GLTFState> p_state, Ref<GLTFSkin> 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);
|
||||
|
@ -6104,7 +6104,7 @@ struct SceneFormatImporterGLTFInterpolate<Quaternion> {
|
|||
|
||||
template <class T>
|
||||
T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T> &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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -110,7 +110,7 @@ Ref<AudioStreamMP3> 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<AudioStreamMP3>());
|
||||
ERR_FAIL_COND_V(mp3_stream->get_data().is_empty(), Ref<AudioStreamMP3>());
|
||||
|
||||
return mp3_stream;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ Error MultiplayerDebugger::_capture(void *p_user, const String &p_msg, const Arr
|
|||
// BandwidthProfiler
|
||||
|
||||
int MultiplayerDebugger::BandwidthProfiler::bandwidth_usage(const Vector<BandwidthFrame> &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);
|
||||
|
|
|
@ -440,7 +440,7 @@ void SceneMultiplayer::disconnect_peer(int p_id) {
|
|||
}
|
||||
|
||||
Error SceneMultiplayer::send_bytes(Vector<uint8_t> 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<uint8_t> p_data, int p_to, Multiplayer
|
|||
Error SceneMultiplayer::send_auth(int p_to, Vector<uint8_t> 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.");
|
||||
|
||||
|
|
|
@ -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<NodePath> 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<Variant> vars;
|
||||
vars.resize(props.size());
|
||||
int consumed = 0;
|
||||
|
|
|
@ -713,7 +713,7 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation
|
|||
Vector<unsigned char> 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());
|
||||
|
|
|
@ -2857,7 +2857,7 @@ bool OpenXRAPI::sync_action_sets(const Vector<RID> 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
|
||||
|
|
|
@ -265,7 +265,7 @@ void UPNP::clear_devices() {
|
|||
}
|
||||
|
||||
Ref<UPNPDevice> 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<UPNPDevice> dev = get_device(i);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ Dictionary VoxelGIData::_get_data() const {
|
|||
if (otsize != Vector3i()) {
|
||||
Ref<Image> img = Image::create_from_data(otsize.x * otsize.y, otsize.z, false, Image::FORMAT_L8, get_distance_field());
|
||||
Vector<uint8_t> 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<uint8_t>();
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<ArrayMesh> ImporterMesh::get_mesh(const Ref<ArrayMesh> &p_base) {
|
||||
ERR_FAIL_COND_V(surfaces.size() == 0, Ref<ArrayMesh>());
|
||||
ERR_FAIL_COND_V(surfaces.is_empty(), Ref<ArrayMesh>());
|
||||
|
||||
if (mesh.is_null()) {
|
||||
if (p_base.is_valid()) {
|
||||
|
|
|
@ -1192,7 +1192,7 @@ void SceneState::update_instance_resource(String p_path, Ref<PackedScene> 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()) {
|
||||
|
|
|
@ -52,7 +52,7 @@ void PrimitiveMesh::_update() const {
|
|||
|
||||
Vector<Vector3> 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();
|
||||
|
||||
|
|
|
@ -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<int> 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<int> 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);
|
||||
|
||||
|
|
|
@ -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<StringName> &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<StringName> &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.
|
||||
|
|
|
@ -204,7 +204,7 @@ Ref<AudioStreamWAV> AudioEffectRecord::get_recording() const {
|
|||
Vector<uint8_t> 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();
|
||||
|
|
|
@ -1589,7 +1589,7 @@ void AudioServer::remove_listener_changed_callback(AudioCallback p_callback, voi
|
|||
}
|
||||
|
||||
void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &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++) {
|
||||
|
|
|
@ -584,7 +584,7 @@ void GodotConvexPolygonShape2D::set_data(const Variant &p_data) {
|
|||
|
||||
if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) {
|
||||
Vector<Vector2> 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();
|
||||
|
|
|
@ -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<uint8_t> 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<String> &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<VariantDefine> &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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -859,7 +859,7 @@ void TextureStorage::texture_2d_initialize(RID p_texture, const Ref<Image> &p_im
|
|||
}
|
||||
|
||||
void TextureStorage::texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &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<R
|
|||
}
|
||||
|
||||
void TextureStorage::texture_3d_initialize(RID p_texture, Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &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<Image> TextureStorage::texture_2d_get(RID p_texture) const {
|
|||
}
|
||||
#endif
|
||||
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0);
|
||||
ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
|
||||
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
|
||||
Ref<Image> image;
|
||||
|
||||
// Expand RGB10_A2 into RGBAH. This is needed for capturing viewport data
|
||||
|
@ -1318,7 +1318,7 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
|
|||
ERR_FAIL_NULL_V(tex, Ref<Image>());
|
||||
|
||||
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
|
||||
ERR_FAIL_COND_V(data.size() == 0, Ref<Image>());
|
||||
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
|
||||
Ref<Image> image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
|
||||
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
|
||||
if (tex->format != tex->validated_format) {
|
||||
|
|
|
@ -146,7 +146,7 @@ String RenderingDevice::shader_get_spirv_cache_key() const {
|
|||
|
||||
RID RenderingDevice::shader_create_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, const String &p_shader_name) {
|
||||
Vector<uint8_t> 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<u
|
|||
RID RenderingDevice::uniform_set_create(const Vector<Uniform> &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.
|
||||
|
||||
|
|
|
@ -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<int> 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<int> 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<uint8_t> attrib_data = p_data.attribute_data;
|
||||
Vector<uint8_t> 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<uint8_t> index_data = p_data.index_data;
|
||||
|
|
Loading…
Reference in a new issue