1
0
mirror of https://github.com/godotengine/godot synced 2024-07-01 09:19:20 +00:00

Replace find with contains/has where applicable

* Replaces `find(...) != -1` with `contains` for `String`
* Replaces `find(...) == -1` with `!contains` for `String`
* Replaces `find(...) != -1` with `has` for containers
* Replaces `find(...) == -1` with `!has` for containers
This commit is contained in:
A Thousand Ships 2024-05-06 16:20:20 +02:00
parent 281fe39929
commit a0dbdcc3ab
No known key found for this signature in database
GPG Key ID: 2033189A662F8BD7
55 changed files with 219 additions and 219 deletions

View File

@ -137,7 +137,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co
script_debugger = memnew(ScriptDebugger);
// Tell the OS that we want to handle termination signals.
OS::get_singleton()->initialize_debugging();
} else if (p_uri.find("://") >= 0) {
} else if (p_uri.contains("://")) {
const String proto = p_uri.substr(0, p_uri.find("://") + 3);
if (!protocols.has(proto)) {
return;

View File

@ -1201,7 +1201,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
if (F.name.begins_with("_")) {
continue; //hidden property
}
if (F.name.find("/") >= 0) {
if (F.name.contains("/")) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}

View File

@ -202,7 +202,7 @@ IPAddress::IPAddress(const String &p_string) {
// Wildcard (not a valid IP)
wildcard = true;
} else if (p_string.find(":") >= 0) {
} else if (p_string.contains(":")) {
// IPv6
_parse_ipv6(p_string);
valid = true;

View File

@ -3964,7 +3964,7 @@ String String::format(const Variant &values, const String &placeholder) const {
Variant v_val = values_arr[i];
String val = v_val;
if (placeholder.find("_") > -1) {
if (placeholder.contains("_")) {
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
} else {
new_string = new_string.replace_first(placeholder, val);

View File

@ -52,7 +52,7 @@ Error AudioDriverALSA::init_output_device() {
// If there is a specified output device check that it is really present
if (output_device_name != "Default") {
PackedStringArray list = get_output_device_list();
if (list.find(output_device_name) == -1) {
if (!list.has(output_device_name)) {
output_device_name = "Default";
new_output_device = "Default";
}

View File

@ -383,7 +383,7 @@ Error EGLManager::initialize() {
ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, ERR_BUG);
const char *platform = _get_platform_extension_name();
if (extensions_string.split(" ").find(platform) < 0) {
if (!extensions_string.split(" ").has(platform)) {
ERR_FAIL_V_MSG(ERR_UNAVAILABLE, vformat("EGL platform extension \"%s\" not found.", platform));
}

View File

@ -183,7 +183,7 @@ Error AudioDriverPulseAudio::init_output_device() {
// If there is a specified output device, check that it is really present
if (output_device_name != "Default") {
PackedStringArray list = get_output_device_list();
if (list.find(output_device_name) == -1) {
if (!list.has(output_device_name)) {
output_device_name = "Default";
new_output_device = "Default";
}
@ -695,7 +695,7 @@ Error AudioDriverPulseAudio::init_input_device() {
// If there is a specified input device, check that it is really present
if (input_device_name != "Default") {
PackedStringArray list = get_input_device_list();
if (list.find(input_device_name) == -1) {
if (!list.has(input_device_name)) {
input_device_name = "Default";
new_input_device = "Default";
}

View File

@ -376,7 +376,7 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co
score *= _is_type_preferred(p_type) ? 1.0f : 0.9f;
// Add score for being a favorite type.
score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.8f;
score *= favorite_list.has(p_type) ? 1.0f : 0.8f;
// Look through at most 5 recent items
bool in_recent = false;

View File

@ -358,7 +358,7 @@ Dictionary DebugAdapterParser::req_setBreakpoints(const Dictionary &p_params) co
}
// If path contains \, it's a Windows path, so we need to convert it to /, and make the drive letter uppercase
if (source.path.find("\\") != -1) {
if (source.path.contains("\\")) {
source.path = source.path.replace("\\", "/");
source.path = source.path.substr(0, 1).to_upper() + source.path.substr(1);
}

View File

@ -262,7 +262,7 @@ void EditorDebuggerNode::set_keep_open(bool p_keep_open) {
}
Error EditorDebuggerNode::start(const String &p_uri) {
ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!p_uri.contains("://"), ERR_INVALID_PARAMETER);
if (keep_open && current_uri == p_uri && server.is_valid()) {
return OK;
}

View File

@ -80,7 +80,7 @@ void EditorFileServer::_scan_files_changed(EditorFileSystemDirectory *efd, const
_add_file(remapped_path, mt, files_to_send, cached_files);
} else if (remap.begins_with("path.")) {
String feature = remap.get_slice(".", 1);
if (p_tags.find(feature) != -1) {
if (p_tags.has(feature)) {
String remapped_path = cf->get_value("remap", remap);
uint64_t mt = FileAccess::get_modified_time(remapped_path);
_add_file(remapped_path, mt, files_to_send, cached_files);

View File

@ -642,11 +642,11 @@ void DependencyRemoveDialog::ok_pressed() {
for (int i = 0; i < previous_favorites.size(); ++i) {
if (previous_favorites[i].ends_with("/")) {
if (dirs_to_delete.find(previous_favorites[i]) < 0) {
if (!dirs_to_delete.has(previous_favorites[i])) {
new_favorites.push_back(previous_favorites[i]);
}
} else {
if (files_to_delete.find(previous_favorites[i]) < 0) {
if (!files_to_delete.has(previous_favorites[i])) {
new_favorites.push_back(previous_favorites[i]);
}
}

View File

@ -1638,7 +1638,7 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
String schema_path;
if (p_use_relative_schema) {
// Modules are nested deep, so change the path to reference the same schema everywhere.
schema_path = save_path.find("modules/") != -1 ? "../../../doc/class.xsd" : "../class.xsd";
schema_path = save_path.contains("modules/") ? "../../../doc/class.xsd" : "../class.xsd";
} else {
schema_path = "https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd";
}

View File

@ -269,7 +269,7 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type = split[1];
if (fc.type.find("/") != -1) {
if (fc.type.contains("/")) {
fc.type = fc.type.get_slice("/", 0);
fc.resource_script_class = fc.type.get_slice("/", 1);
}
@ -2707,7 +2707,7 @@ void EditorFileSystem::_update_extensions() {
}
void EditorFileSystem::add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {
ERR_FAIL_COND(import_support_queries.find(p_query) != -1);
ERR_FAIL_COND(import_support_queries.has(p_query));
import_support_queries.push_back(p_query);
}
void EditorFileSystem::remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) {

View File

@ -744,7 +744,7 @@ String EditorHelpSearch::Runner::_match_keywords_in_all_terms(const String &p_ke
bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const {
if (search_flags & SEARCH_CASE_SENSITIVE) {
return p_string.find(p_term) > -1;
return p_string.contains(p_term);
} else {
return p_string.findn(p_term) > -1;
}

View File

@ -2391,7 +2391,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update
Ref<Resource> res = Object::cast_to<Resource>(current_obj);
if (p_skip_foreign && res.is_valid()) {
const int current_tab = scene_tabs->get_current_tab();
if (res->get_path().find("::") > -1 && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) {
if (res->get_path().contains("::") && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) {
// Trying to edit resource that belongs to another scene; abort.
current_obj = nullptr;
}

View File

@ -63,7 +63,7 @@ bool EditorPropertyNameProcessor::is_localization_available() {
return false;
}
const Vector<String> forbidden = String("en").split(",");
return forbidden.find(EDITOR_GET("interface/editor/editor_language")) == -1;
return !forbidden.has(EDITOR_GET("interface/editor/editor_language"));
}
String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const {

View File

@ -160,7 +160,7 @@ float EditorQuickOpen::_score_search_result(const PackedStringArray &p_search_to
}
// Prioritize matches at the front of the path token.
if (min_match_idx == 0 || p_path.find("/" + s) != -1) {
if (min_match_idx == 0 || p_path.contains("/" + s)) {
token_score += 1.0f;
}

View File

@ -969,7 +969,7 @@ bool EditorSettings::_save_text_editor_theme(const String &p_file) {
keys.sort();
for (const String &key : keys) {
if (key.begins_with("text_editor/theme/highlighting/") && key.find("color") >= 0) {
if (key.begins_with("text_editor/theme/highlighting/") && key.contains("color")) {
cf->set_value(theme_section, key.replace("text_editor/theme/highlighting/", ""), ((Color)props[key].variant).to_html());
}
}
@ -1448,7 +1448,7 @@ void EditorSettings::load_text_editor_theme() {
// don't load if it's not already there!
if (has_setting("text_editor/theme/highlighting/" + key)) {
// make sure it is actually a color
if (val.is_valid_html_color() && key.find("color") >= 0) {
if (val.is_valid_html_color() && key.contains("color")) {
props["text_editor/theme/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
}
}

View File

@ -261,7 +261,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
if (p_unfold_path && current_path.begins_with(lpath) && current_path != lpath) {
subdirectory_item->set_collapsed(false);
} else {
subdirectory_item->set_collapsed(uncollapsed_paths.find(lpath) < 0);
subdirectory_item->set_collapsed(!uncollapsed_paths.has(lpath));
}
if (!searched_tokens.is_empty() && _matches_all_search_tokens(dname)) {
parent_should_expand = true;
@ -407,7 +407,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
favorites_item->set_icon(0, get_editor_theme_icon(SNAME("Favorites")));
favorites_item->set_text(0, TTR("Favorites:"));
favorites_item->set_metadata(0, "Favorites");
favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0);
favorites_item->set_collapsed(!p_uncollapsed_paths.has("Favorites"));
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
@ -2300,7 +2300,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
TreeItem *selected = tree->get_root();
selected = tree->get_next_selected(selected);
while (selected) {
if (p_selected.find(selected->get_metadata(0)) >= 0) {
if (p_selected.has(selected->get_metadata(0))) {
selected->set_collapsed(false);
}
selected = tree->get_next_selected(selected);

View File

@ -217,7 +217,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
0x14c, // IMAGE_FILE_MACHINE_I386
0x200, // IMAGE_FILE_MACHINE_IA64
};
ERR_FAIL_COND_V_MSG(coff_header_machines.find(first_bytes) != -1, ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path));
ERR_FAIL_COND_V_MSG(coff_header_machines.has(first_bytes), ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path));
f->seek(0);
Ref<ImporterMesh> mesh;

View File

@ -2086,12 +2086,12 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor
p_options.has("generate/physics") &&
p_options["generate/physics"].operator bool();
if (p_option.find("physics/") >= 0) {
if (p_option.contains("physics/")) {
// Show if need to generate collisions.
return generate_physics;
}
if (p_option.find("decomposition/") >= 0) {
if (p_option.contains("decomposition/")) {
// Show if need to generate collisions.
if (generate_physics &&
// Show if convex is enabled.
@ -2285,8 +2285,8 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp
if (
p_option == "generate/physics" ||
p_option == "physics/shape_type" ||
p_option.find("decomposition/") >= 0 ||
p_option.find("primitive/") >= 0) {
p_option.contains("decomposition/") ||
p_option.contains("primitive/")) {
return true;
}
} break;

View File

@ -742,7 +742,7 @@ void ScriptEditor::_add_recent_script(const String &p_path) {
}
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array());
if (rc.find(p_path) != -1) {
if (rc.has(p_path)) {
rc.erase(p_path);
}
rc.push_front(p_path);

View File

@ -1312,7 +1312,7 @@ void SpriteFramesEditor::_update_library_impl() {
TreeItem *selected = nullptr;
for (const StringName &E : anim_names) {
String name = E;
if (searching && name.to_lower().find(searched_string) < 0) {
if (searching && !name.to_lower().contains(searched_string)) {
continue;
}
TreeItem *it = animations->create_item(anim_root);

View File

@ -473,7 +473,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *
String source_file = String::utf8(p_file);
// Only show first error that is related to "regex"
if (self->has_errors || source_file.find("regex") < 0) {
if (self->has_errors || !source_file.contains("regex")) {
return;
}

View File

@ -1297,7 +1297,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
StringName name = node->get_name();
if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) {
if (new_unique_names.has(name) || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) {
cant_be_set_unique_names.push_back(name);
} else {
new_unique_nodes.push_back(node);

View File

@ -2993,7 +2993,7 @@ Error Main::setup2() {
// Dummy text driver cannot draw any text, making the editor unusable if selected.
continue;
}
if (!text_driver_options.is_empty() && text_driver_options.find(",") == -1) {
if (!text_driver_options.is_empty() && !text_driver_options.contains(",")) {
// Not the first option; add a comma before it as a separator for the property hint.
text_driver_options += ",";
}

View File

@ -852,7 +852,7 @@ int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) {
}
void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector<int> &r_vertex_indices, int p_new_vertex_index) {
if (p_new_vertex_index >= 0 && r_vertex_indices.find(p_new_vertex_index) == -1) {
if (p_new_vertex_index >= 0 && !r_vertex_indices.has(p_new_vertex_index)) {
ERR_FAIL_COND_MSG(p_new_vertex_index >= vertices.size(), "Invalid vertex index.");
// The first vertex.

View File

@ -695,7 +695,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
} else {
ScriptLanguage::LookupResult ret;
if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").find("new(") > -1) {
if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").contains("new(")) {
symbol_identifier = "_init";
}
if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_required), symbol_identifier, path, nullptr, ret)) {

View File

@ -227,7 +227,7 @@ Vector<InlineTestData> read_tests(const String &p_path) {
if (InlineTestData::try_parse(lines, i, d)) {
if (!d.name.is_empty()) {
// Safety check: names must be unique.
if (names.find(d.name) != -1) {
if (names.has(d.name)) {
FAIL(vformat("Duplicated name '%s' in '%s'. Names must be unique!", d.name, p_path));
}
names.append(d.name);

View File

@ -7032,7 +7032,7 @@ void GLTFDocument::_build_parent_hierachy(Ref<GLTFState> p_state) {
Vector<Ref<GLTFDocumentExtension>> GLTFDocument::all_document_extensions;
void GLTFDocument::register_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension, bool p_first_priority) {
if (all_document_extensions.find(p_extension) == -1) {
if (!all_document_extensions.has(p_extension)) {
if (p_first_priority) {
all_document_extensions.insert(0, p_extension);
} else {

View File

@ -57,9 +57,9 @@ bool SkinTool::_capture_nodes_in_skin(const Vector<Ref<GLTFNode>> &nodes, Ref<GL
if (found_joint) {
// Mark it if we happen to find another skins joint...
if (current_node->joint && p_skin->joints.find(p_node_index) < 0) {
if (current_node->joint && !p_skin->joints.has(p_node_index)) {
p_skin->joints.push_back(p_node_index);
} else if (p_skin->non_joints.find(p_node_index) < 0) {
} else if (!p_skin->non_joints.has(p_node_index)) {
p_skin->non_joints.push_back(p_node_index);
}
}
@ -79,7 +79,7 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
if (p_skin->joints.find(parent) >= 0) {
if (p_skin->joints.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@ -109,9 +109,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
while (r_nodes[current_node]->height > maxHeight) {
SkinNodeIndex parent = r_nodes[current_node]->parent;
if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) {
if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) {
p_skin->joints.push_back(parent);
} else if (p_skin->non_joints.find(parent) < 0) {
} else if (!p_skin->non_joints.has(parent)) {
p_skin->non_joints.push_back(parent);
}
@ -138,9 +138,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector<Ref<GLTFNode>> &r_node
const SkinNodeIndex current_node = roots[i];
const SkinNodeIndex parent = r_nodes[current_node]->parent;
if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) {
if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) {
p_skin->joints.push_back(parent);
} else if (p_skin->non_joints.find(parent) < 0) {
} else if (!p_skin->non_joints.has(parent)) {
p_skin->non_joints.push_back(parent);
}
@ -166,7 +166,7 @@ Error SkinTool::_expand_skin(Vector<Ref<GLTFNode>> &r_nodes, Ref<GLTFSkin> p_ski
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
if (all_skin_nodes.find(parent) >= 0) {
if (all_skin_nodes.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@ -216,7 +216,7 @@ Error SkinTool::_verify_skin(Vector<Ref<GLTFNode>> &r_nodes, Ref<GLTFSkin> p_ski
const SkinNodeIndex parent = r_nodes[node_index]->parent;
disjoint_set.insert(node_index);
if (all_skin_nodes.find(parent) >= 0) {
if (all_skin_nodes.has(parent)) {
disjoint_set.create_union(parent, node_index);
}
}
@ -365,7 +365,7 @@ Error SkinTool::_determine_skeletons(
for (int j = 0; j < groups.size() && i != j; ++j) {
const Vector<SkinNodeIndex> &group = groups[j];
if (group.find(node_i_parent) >= 0) {
if (group.has(node_i_parent)) {
const SkinNodeIndex node_j = highest_group_members[j];
skeleton_sets.create_union(node_i, node_j);
}
@ -393,7 +393,7 @@ Error SkinTool::_determine_skeletons(
// If any of the the skeletons nodes exist in a skin, that skin now maps to the skeleton
for (int i = 0; i < skeleton_nodes.size(); ++i) {
SkinNodeIndex skel_node_i = skeleton_nodes[i];
if (skin->joints.find(skel_node_i) >= 0 || skin->non_joints.find(skel_node_i) >= 0) {
if (skin->joints.has(skel_node_i) || skin->non_joints.has(skel_node_i)) {
skin->skeleton = skel_i;
continue;
}
@ -454,7 +454,7 @@ Error SkinTool::_reparent_non_joint_skeleton_subtrees(
subtree_set.insert(node_i);
const SkinNodeIndex parent_i = nodes[node_i]->parent;
if (parent_i >= 0 && p_non_joints.find(parent_i) >= 0 && !nodes[parent_i]->joint) {
if (parent_i >= 0 && p_non_joints.has(parent_i) && !nodes[parent_i]->joint) {
subtree_set.create_union(parent_i, node_i);
}
}

View File

@ -873,7 +873,7 @@ void BindingsGenerator::_append_text_method(StringBuilder &p_output, const TypeI
}
void BindingsGenerator::_append_text_member(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) {
if (p_link_target.find("/") >= 0) {
if (p_link_target.contains("/")) {
// Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference.
_append_text_undeclared(p_output, p_link_target);
} else if (!p_target_itype || !p_target_itype->is_object_type) {
@ -1154,7 +1154,7 @@ void BindingsGenerator::_append_xml_method(StringBuilder &p_xml_output, const Ty
}
void BindingsGenerator::_append_xml_member(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector<String> &p_link_target_parts) {
if (p_link_target.find("/") >= 0) {
if (p_link_target.contains("/")) {
// Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference.
_append_xml_undeclared(p_xml_output, p_link_target);
} else if (!p_target_itype || !p_target_itype->is_object_type) {
@ -3654,7 +3654,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
continue;
}
if (property.name.find("/") >= 0) {
if (property.name.contains("/")) {
// Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector.
continue;
}

View File

@ -59,7 +59,7 @@ void OpenXRActionMap::set_action_sets(Array p_action_sets) {
for (int i = 0; i < p_action_sets.size(); i++) {
Ref<OpenXRActionSet> action_set = p_action_sets[i];
if (action_set.is_valid() && action_sets.find(action_set) == -1) {
if (action_set.is_valid() && !action_sets.has(action_set)) {
action_sets.push_back(action_set);
}
}
@ -93,7 +93,7 @@ Ref<OpenXRActionSet> OpenXRActionMap::get_action_set(int p_idx) const {
void OpenXRActionMap::add_action_set(Ref<OpenXRActionSet> p_action_set) {
ERR_FAIL_COND(p_action_set.is_null());
if (action_sets.find(p_action_set) == -1) {
if (!action_sets.has(p_action_set)) {
action_sets.push_back(p_action_set);
emit_changed();
}
@ -112,7 +112,7 @@ void OpenXRActionMap::set_interaction_profiles(Array p_interaction_profiles) {
for (int i = 0; i < p_interaction_profiles.size(); i++) {
Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profiles[i];
if (interaction_profile.is_valid() && interaction_profiles.find(interaction_profile) == -1) {
if (interaction_profile.is_valid() && !interaction_profiles.has(interaction_profile)) {
interaction_profiles.push_back(interaction_profile);
}
}
@ -146,7 +146,7 @@ Ref<OpenXRInteractionProfile> OpenXRActionMap::get_interaction_profile(int p_idx
void OpenXRActionMap::add_interaction_profile(Ref<OpenXRInteractionProfile> p_interaction_profile) {
ERR_FAIL_COND(p_interaction_profile.is_null());
if (interaction_profiles.find(p_interaction_profile) == -1) {
if (!interaction_profiles.has(p_interaction_profile)) {
interaction_profiles.push_back(p_interaction_profile);
emit_changed();
}

View File

@ -124,7 +124,7 @@ Ref<OpenXRAction> OpenXRActionSet::get_action(const String p_name) const {
void OpenXRActionSet::add_action(Ref<OpenXRAction> p_action) {
ERR_FAIL_COND(p_action.is_null());
if (actions.find(p_action) == -1) {
if (!actions.has(p_action)) {
if (p_action->action_set && p_action->action_set != this) {
// action should only relate to our action set
p_action->action_set->remove_action(p_action);

View File

@ -172,7 +172,7 @@ Ref<OpenXRIPBinding> OpenXRInteractionProfile::get_binding_for_action(const Ref<
void OpenXRInteractionProfile::add_binding(Ref<OpenXRIPBinding> p_binding) {
ERR_FAIL_COND(p_binding.is_null());
if (bindings.find(p_binding) == -1) {
if (!bindings.has(p_binding)) {
ERR_FAIL_COND_MSG(get_binding_for_action(p_binding->get_action()).is_valid(), "There is already a binding for this action in this interaction profile");
bindings.push_back(p_binding);

View File

@ -391,7 +391,7 @@ OpenXRInterface::Action *OpenXRInterface::create_action(ActionSet *p_action_set,
// we link our actions back to our trackers so we know which actions to check when we're processing our trackers
for (int i = 0; i < p_trackers.size(); i++) {
if (p_trackers[i]->actions.find(action) == -1) {
if (!p_trackers[i]->actions.has(action)) {
p_trackers[i]->actions.push_back(action);
}
}

View File

@ -370,7 +370,7 @@ PackedStringArray RegEx::get_names() const {
for (uint32_t i = 0; i < count; i++) {
String name = &table[i * entry_size + 1];
if (result.find(name) < 0) {
if (!result.has(name)) {
result.append(name);
}
}

View File

@ -389,54 +389,54 @@ class TextServerAdvanced : public TextServerExtension {
_FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const;
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) {
if (sty_name.contains("thin") || sty_name.contains("hairline")) {
return 100;
} else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) {
} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
return 200;
} else if (sty_name.find("light") >= 0) {
} else if (sty_name.contains("light")) {
return 300;
} else if (sty_name.find("semilight") >= 0) {
} else if (sty_name.contains("semilight")) {
return 350;
} else if (sty_name.find("regular") >= 0) {
} else if (sty_name.contains("regular")) {
return 400;
} else if (sty_name.find("medium") >= 0) {
} else if (sty_name.contains("medium")) {
return 500;
} else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) {
} else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {
return 600;
} else if (sty_name.find("bold") >= 0) {
} else if (sty_name.contains("bold")) {
return 700;
} else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) {
} else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {
return 800;
} else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) {
} else if (sty_name.contains("black") || sty_name.contains("heavy")) {
return 900;
} else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) {
} else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {
return 950;
}
return 400;
}
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
if (sty_name.find("ultracondensed") >= 0) {
if (sty_name.contains("ultracondensed")) {
return 50;
} else if (sty_name.find("extracondensed") >= 0) {
} else if (sty_name.contains("extracondensed")) {
return 63;
} else if (sty_name.find("condensed") >= 0) {
} else if (sty_name.contains("condensed")) {
return 75;
} else if (sty_name.find("semicondensed") >= 0) {
} else if (sty_name.contains("semicondensed")) {
return 87;
} else if (sty_name.find("semiexpanded") >= 0) {
} else if (sty_name.contains("semiexpanded")) {
return 113;
} else if (sty_name.find("expanded") >= 0) {
} else if (sty_name.contains("expanded")) {
return 125;
} else if (sty_name.find("extraexpanded") >= 0) {
} else if (sty_name.contains("extraexpanded")) {
return 150;
} else if (sty_name.find("ultraexpanded") >= 0) {
} else if (sty_name.contains("ultraexpanded")) {
return 200;
}
return 100;
}
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {
return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0);
return p_sty_name.contains("italic") || p_sty_name.contains("oblique");
}
// Shaped text cache data.

View File

@ -335,54 +335,54 @@ class TextServerFallback : public TextServerExtension {
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) {
if (sty_name.contains("thin") || sty_name.contains("hairline")) {
return 100;
} else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) {
} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
return 200;
} else if (sty_name.find("light") >= 0) {
} else if (sty_name.contains("light")) {
return 300;
} else if (sty_name.find("semilight") >= 0) {
} else if (sty_name.contains("semilight")) {
return 350;
} else if (sty_name.find("regular") >= 0) {
} else if (sty_name.contains("regular")) {
return 400;
} else if (sty_name.find("medium") >= 0) {
} else if (sty_name.contains("medium")) {
return 500;
} else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) {
} else if (sty_name.contains("semibold") || sty_name.contains("demibold")) {
return 600;
} else if (sty_name.find("bold") >= 0) {
} else if (sty_name.contains("bold")) {
return 700;
} else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) {
} else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) {
return 800;
} else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) {
} else if (sty_name.contains("black") || sty_name.contains("heavy")) {
return 900;
} else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) {
} else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) {
return 950;
}
return 400;
}
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
if (sty_name.find("ultracondensed") >= 0) {
if (sty_name.contains("ultracondensed")) {
return 50;
} else if (sty_name.find("extracondensed") >= 0) {
} else if (sty_name.contains("extracondensed")) {
return 63;
} else if (sty_name.find("condensed") >= 0) {
} else if (sty_name.contains("condensed")) {
return 75;
} else if (sty_name.find("semicondensed") >= 0) {
} else if (sty_name.contains("semicondensed")) {
return 87;
} else if (sty_name.find("semiexpanded") >= 0) {
} else if (sty_name.contains("semiexpanded")) {
return 113;
} else if (sty_name.find("expanded") >= 0) {
} else if (sty_name.contains("expanded")) {
return 125;
} else if (sty_name.find("extraexpanded") >= 0) {
} else if (sty_name.contains("extraexpanded")) {
return 150;
} else if (sty_name.find("ultraexpanded") >= 0) {
} else if (sty_name.contains("ultraexpanded")) {
return 200;
}
return 100;
}
_FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const {
return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0);
return p_sty_name.contains("italic") || p_sty_name.contains("oblique");
}
// Shaped text cache data.

View File

@ -37,10 +37,10 @@
bool UPNP::is_common_device(const String &dev) const {
return dev.is_empty() ||
dev.find("InternetGatewayDevice") >= 0 ||
dev.find("WANIPConnection") >= 0 ||
dev.find("WANPPPConnection") >= 0 ||
dev.find("rootdevice") >= 0;
dev.contains("InternetGatewayDevice") ||
dev.contains("WANIPConnection") ||
dev.contains("WANPPPConnection") ||
dev.contains("rootdevice");
}
int UPNP::discover(int timeout, int ttl, const String &device_filter) {

View File

@ -816,11 +816,11 @@ Error EditorExportPlatformAndroid::copy_gradle_so(void *p_userdata, const Shared
}
bool EditorExportPlatformAndroid::_has_read_write_storage_permission(const Vector<String> &p_permissions) {
return p_permissions.find("android.permission.READ_EXTERNAL_STORAGE") != -1 || p_permissions.find("android.permission.WRITE_EXTERNAL_STORAGE") != -1;
return p_permissions.has("android.permission.READ_EXTERNAL_STORAGE") || p_permissions.has("android.permission.WRITE_EXTERNAL_STORAGE");
}
bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const Vector<String> &p_permissions) {
return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1;
return p_permissions.has("android.permission.MANAGE_EXTERNAL_STORAGE");
}
bool EditorExportPlatformAndroid::_uses_vulkan() {
@ -924,7 +924,7 @@ void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset>
}
}
if (p_give_internet) {
if (r_permissions.find("android.permission.INTERNET") == -1) {
if (!r_permissions.has("android.permission.INTERNET")) {
r_permissions.push_back("android.permission.INTERNET");
}
}
@ -2716,7 +2716,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
}
String package_name = p_preset->get("package/unique_name");
if (package_name.find("$genname") >= 0 && !is_project_name_valid()) {
if (package_name.contains("$genname") && !is_project_name_valid()) {
// Warning only, so don't override `valid`.
err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename());
err += "\n";

View File

@ -586,11 +586,11 @@ Vector<String> OS_Android::get_system_font_path_for_text(const String &p_font_na
}
if (score > best_score) {
best_score = score;
if (ret.find(root.path_join(E->get().filename)) < 0) {
if (!ret.has(root.path_join(E->get().filename))) {
ret.insert(0, root.path_join(E->get().filename));
}
} else if (score == best_score || E->get().script.is_empty()) {
if (ret.find(root.path_join(E->get().filename)) < 0) {
if (!ret.has(root.path_join(E->get().filename))) {
ret.push_back(root.path_join(E->get().filename));
}
}

View File

@ -400,65 +400,65 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
str.parse_utf8((const char *)pfile.ptr(), pfile.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
if (lines[i].find("$binary") != -1) {
if (lines[i].contains("$binary")) {
strnew += lines[i].replace("$binary", p_config.binary_name) + "\n";
} else if (lines[i].find("$modules_buildfile") != -1) {
} else if (lines[i].contains("$modules_buildfile")) {
strnew += lines[i].replace("$modules_buildfile", p_config.modules_buildfile) + "\n";
} else if (lines[i].find("$modules_fileref") != -1) {
} else if (lines[i].contains("$modules_fileref")) {
strnew += lines[i].replace("$modules_fileref", p_config.modules_fileref) + "\n";
} else if (lines[i].find("$modules_buildphase") != -1) {
} else if (lines[i].contains("$modules_buildphase")) {
strnew += lines[i].replace("$modules_buildphase", p_config.modules_buildphase) + "\n";
} else if (lines[i].find("$modules_buildgrp") != -1) {
} else if (lines[i].contains("$modules_buildgrp")) {
strnew += lines[i].replace("$modules_buildgrp", p_config.modules_buildgrp) + "\n";
} else if (lines[i].find("$name") != -1) {
} else if (lines[i].contains("$name")) {
strnew += lines[i].replace("$name", p_config.pkg_name) + "\n";
} else if (lines[i].find("$bundle_identifier") != -1) {
} else if (lines[i].contains("$bundle_identifier")) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
} else if (lines[i].find("$short_version") != -1) {
} else if (lines[i].contains("$short_version")) {
strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n";
} else if (lines[i].find("$version") != -1) {
} else if (lines[i].contains("$version")) {
strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n";
} else if (lines[i].find("$min_version") != -1) {
} else if (lines[i].contains("$min_version")) {
strnew += lines[i].replace("$min_version", p_preset->get("application/min_ios_version")) + "\n";
} else if (lines[i].find("$signature") != -1) {
} else if (lines[i].contains("$signature")) {
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
} else if (lines[i].find("$team_id") != -1) {
} else if (lines[i].contains("$team_id")) {
strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n";
} else if (lines[i].find("$default_build_config") != -1) {
} else if (lines[i].contains("$default_build_config")) {
strnew += lines[i].replace("$default_build_config", p_debug ? "Debug" : "Release") + "\n";
} else if (lines[i].find("$export_method") != -1) {
} else if (lines[i].contains("$export_method")) {
int export_method = p_preset->get(p_debug ? "application/export_method_debug" : "application/export_method_release");
strnew += lines[i].replace("$export_method", export_method_string[export_method]) + "\n";
} else if (lines[i].find("$provisioning_profile_uuid_release") != -1) {
} else if (lines[i].contains("$provisioning_profile_uuid_release")) {
strnew += lines[i].replace("$provisioning_profile_uuid_release", p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE)) + "\n";
} else if (lines[i].find("$provisioning_profile_uuid_debug") != -1) {
} else if (lines[i].contains("$provisioning_profile_uuid_debug")) {
strnew += lines[i].replace("$provisioning_profile_uuid_debug", p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG)) + "\n";
} else if (lines[i].find("$code_sign_style_debug") != -1) {
} else if (lines[i].contains("$code_sign_style_debug")) {
if (dbg_manual) {
strnew += lines[i].replace("$code_sign_style_debug", "Manual") + "\n";
} else {
strnew += lines[i].replace("$code_sign_style_debug", "Automatic") + "\n";
}
} else if (lines[i].find("$code_sign_style_release") != -1) {
} else if (lines[i].contains("$code_sign_style_release")) {
if (rel_manual) {
strnew += lines[i].replace("$code_sign_style_release", "Manual") + "\n";
} else {
strnew += lines[i].replace("$code_sign_style_release", "Automatic") + "\n";
}
} else if (lines[i].find("$provisioning_profile_uuid") != -1) {
} else if (lines[i].contains("$provisioning_profile_uuid")) {
String uuid = p_debug ? p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG) : p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE);
strnew += lines[i].replace("$provisioning_profile_uuid", uuid) + "\n";
} else if (lines[i].find("$code_sign_identity_debug") != -1) {
} else if (lines[i].contains("$code_sign_identity_debug")) {
strnew += lines[i].replace("$code_sign_identity_debug", dbg_sign_id) + "\n";
} else if (lines[i].find("$code_sign_identity_release") != -1) {
} else if (lines[i].contains("$code_sign_identity_release")) {
strnew += lines[i].replace("$code_sign_identity_release", rel_sign_id) + "\n";
} else if (lines[i].find("$additional_plist_content") != -1) {
} else if (lines[i].contains("$additional_plist_content")) {
strnew += lines[i].replace("$additional_plist_content", p_config.plist_content) + "\n";
} else if (lines[i].find("$godot_archs") != -1) {
} else if (lines[i].contains("$godot_archs")) {
strnew += lines[i].replace("$godot_archs", p_config.architectures) + "\n";
} else if (lines[i].find("$linker_flags") != -1) {
} else if (lines[i].contains("$linker_flags")) {
strnew += lines[i].replace("$linker_flags", p_config.linker_flags) + "\n";
} else if (lines[i].find("$targeted_device_family") != -1) {
} else if (lines[i].contains("$targeted_device_family")) {
String xcode_value;
switch ((int)p_preset->get("application/targeted_device_family")) {
case 0: // iPhone
@ -472,16 +472,16 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
break;
}
strnew += lines[i].replace("$targeted_device_family", xcode_value) + "\n";
} else if (lines[i].find("$cpp_code") != -1) {
} else if (lines[i].contains("$cpp_code")) {
strnew += lines[i].replace("$cpp_code", p_config.cpp_code) + "\n";
} else if (lines[i].find("$docs_in_place") != -1) {
} else if (lines[i].contains("$docs_in_place")) {
strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "<true/>" : "<false/>") + "\n";
} else if (lines[i].find("$docs_sharing") != -1) {
} else if (lines[i].contains("$docs_sharing")) {
strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "<true/>" : "<false/>") + "\n";
} else if (lines[i].find("$entitlements_push_notifications") != -1) {
} else if (lines[i].contains("$entitlements_push_notifications")) {
bool is_on = p_preset->get("capabilities/push_notifications");
strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "<key>aps-environment</key><string>development</string>" : "") + "\n";
} else if (lines[i].find("$required_device_capabilities") != -1) {
} else if (lines[i].contains("$required_device_capabilities")) {
String capabilities;
// I've removed armv7 as we can run on 64bit only devices
@ -503,7 +503,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$required_device_capabilities", capabilities);
} else if (lines[i].find("$interface_orientations") != -1) {
} else if (lines[i].contains("$interface_orientations")) {
String orientations;
const DisplayServer::ScreenOrientation screen_orientation =
DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")));
@ -541,35 +541,35 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$interface_orientations", orientations);
} else if (lines[i].find("$camera_usage_description") != -1) {
} else if (lines[i].contains("$camera_usage_description")) {
String description = p_preset->get("privacy/camera_usage_description");
strnew += lines[i].replace("$camera_usage_description", description) + "\n";
} else if (lines[i].find("$microphone_usage_description") != -1) {
} else if (lines[i].contains("$microphone_usage_description")) {
String description = p_preset->get("privacy/microphone_usage_description");
strnew += lines[i].replace("$microphone_usage_description", description) + "\n";
} else if (lines[i].find("$photolibrary_usage_description") != -1) {
} else if (lines[i].contains("$photolibrary_usage_description")) {
String description = p_preset->get("privacy/photolibrary_usage_description");
strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n";
} else if (lines[i].find("$plist_launch_screen_name") != -1) {
} else if (lines[i].contains("$plist_launch_screen_name")) {
String value = "<key>UILaunchStoryboardName</key>\n<string>Launch Screen</string>";
strnew += lines[i].replace("$plist_launch_screen_name", value) + "\n";
} else if (lines[i].find("$pbx_launch_screen_file_reference") != -1) {
} else if (lines[i].contains("$pbx_launch_screen_file_reference")) {
String value = "90DD2D9D24B36E8000717FE1 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = \"Launch Screen.storyboard\"; sourceTree = \"<group>\"; };";
strnew += lines[i].replace("$pbx_launch_screen_file_reference", value) + "\n";
} else if (lines[i].find("$pbx_launch_screen_copy_files") != -1) {
} else if (lines[i].contains("$pbx_launch_screen_copy_files")) {
String value = "90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */,";
strnew += lines[i].replace("$pbx_launch_screen_copy_files", value) + "\n";
} else if (lines[i].find("$pbx_launch_screen_build_phase") != -1) {
} else if (lines[i].contains("$pbx_launch_screen_build_phase")) {
String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */,";
strnew += lines[i].replace("$pbx_launch_screen_build_phase", value) + "\n";
} else if (lines[i].find("$pbx_launch_screen_build_reference") != -1) {
} else if (lines[i].contains("$pbx_launch_screen_build_reference")) {
String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */; };";
strnew += lines[i].replace("$pbx_launch_screen_build_reference", value) + "\n";
#ifndef DISABLE_DEPRECATED
} else if (lines[i].find("$pbx_launch_image_usage_setting") != -1) {
} else if (lines[i].contains("$pbx_launch_image_usage_setting")) {
strnew += lines[i].replace("$pbx_launch_image_usage_setting", "") + "\n";
#endif
} else if (lines[i].find("$launch_screen_image_mode") != -1) {
} else if (lines[i].contains("$launch_screen_image_mode")) {
int image_scale_mode = p_preset->get("storyboard/image_scale_mode");
String value;
@ -586,7 +586,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += lines[i].replace("$launch_screen_image_mode", value) + "\n";
} else if (lines[i].find("$launch_screen_background_color") != -1) {
} else if (lines[i].contains("$launch_screen_background_color")) {
bool use_custom = p_preset->get("storyboard/use_custom_bg_color");
Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : GLOBAL_GET("application/boot_splash/bg_color");
const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\"";
@ -599,7 +599,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
String value = value_format.format(value_dictionary, "$_");
strnew += lines[i].replace("$launch_screen_background_color", value) + "\n";
} else if (lines[i].find("$pbx_locale_file_reference") != -1) {
} else if (lines[i].contains("$pbx_locale_file_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
if (translations.size() > 0) {
@ -618,7 +618,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
}
strnew += lines[i].replace("$pbx_locale_file_reference", locale_files);
} else if (lines[i].find("$pbx_locale_build_reference") != -1) {
} else if (lines[i].contains("$pbx_locale_build_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
if (translations.size() > 0) {
@ -637,10 +637,10 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
}
strnew += lines[i].replace("$pbx_locale_build_reference", locale_files);
} else if (lines[i].find("$swift_runtime_migration") != -1) {
} else if (lines[i].contains("$swift_runtime_migration")) {
String value = !p_config.use_swift_runtime ? "" : "LastSwiftMigration = 1250;";
strnew += lines[i].replace("$swift_runtime_migration", value) + "\n";
} else if (lines[i].find("$swift_runtime_build_settings") != -1) {
} else if (lines[i].contains("$swift_runtime_build_settings")) {
String value = !p_config.use_swift_runtime ? "" : R"(
CLANG_ENABLE_MODULES = YES;
SWIFT_OBJC_BRIDGING_HEADER = "$binary/dummy.h";
@ -648,25 +648,25 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
)";
value = value.replace("$binary", p_config.binary_name);
strnew += lines[i].replace("$swift_runtime_build_settings", value) + "\n";
} else if (lines[i].find("$swift_runtime_fileref") != -1) {
} else if (lines[i].contains("$swift_runtime_fileref")) {
String value = !p_config.use_swift_runtime ? "" : R"(
90B4C2AA2680BC560039117A /* dummy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummy.h"; sourceTree = "<group>"; };
90B4C2B52680C7E90039117A /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "dummy.swift"; sourceTree = "<group>"; };
)";
strnew += lines[i].replace("$swift_runtime_fileref", value) + "\n";
} else if (lines[i].find("$swift_runtime_binary_files") != -1) {
} else if (lines[i].contains("$swift_runtime_binary_files")) {
String value = !p_config.use_swift_runtime ? "" : R"(
90B4C2AA2680BC560039117A /* dummy.h */,
90B4C2B52680C7E90039117A /* dummy.swift */,
)";
strnew += lines[i].replace("$swift_runtime_binary_files", value) + "\n";
} else if (lines[i].find("$swift_runtime_buildfile") != -1) {
} else if (lines[i].contains("$swift_runtime_buildfile")) {
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B4C2B52680C7E90039117A /* dummy.swift */; };";
strnew += lines[i].replace("$swift_runtime_buildfile", value) + "\n";
} else if (lines[i].find("$swift_runtime_build_phase") != -1) {
} else if (lines[i].contains("$swift_runtime_build_phase")) {
String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift */,";
strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n";
} else if (lines[i].find("$priv_collection") != -1) {
} else if (lines[i].contains("$priv_collection")) {
bool section_opened = false;
for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) {
bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name));
@ -710,7 +710,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
if (section_opened) {
strnew += "\t</array>\n";
}
} else if (lines[i].find("$priv_tracking") != -1) {
} else if (lines[i].contains("$priv_tracking")) {
bool tracking = p_preset->get("privacy/tracking_enabled");
strnew += "\t<key>NSPrivacyTracking</key>\n";
if (tracking) {
@ -727,7 +727,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
strnew += "\t</array>\n";
}
} else if (lines[i].find("$priv_api_types") != -1) {
} else if (lines[i].contains("$priv_api_types")) {
strnew += "\t<array>\n";
for (uint64_t j = 0; j < sizeof(api_info) / sizeof(api_info[0]); ++j) {
int api_access = p_preset->get(vformat("privacy/%s_access_reasons", api_info[j].prop_name));

View File

@ -175,7 +175,7 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) {
if (devnode) {
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
if (!devnode_str.contains(ignore_str)) {
open_joypad(devnode);
}
}
@ -214,7 +214,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) {
const char *devnode = udev_device_get_devnode(dev);
if (devnode) {
String devnode_str = devnode;
if (devnode_str.find(ignore_str) == -1) {
if (!devnode_str.contains(ignore_str)) {
if (action == "add") {
open_joypad(devnode);
} else if (String(action) == "remove") {
@ -244,7 +244,7 @@ void JoypadLinux::monitor_joypads() {
continue;
}
sprintf(fname, "/dev/input/%.*s", 16, current->d_name);
if (attached_devices.find(fname) == -1) {
if (!attached_devices.has(fname)) {
open_joypad(fname);
}
}

View File

@ -184,7 +184,7 @@ String OS_LinuxBSD::get_processor_name() const {
while (!f->eof_reached()) {
const String line = f->get_line();
if (line.find("model name") != -1) {
if (line.contains("model name")) {
return line.split(":")[1].strip_edges();
}
}
@ -269,7 +269,7 @@ String OS_LinuxBSD::get_systemd_os_release_info_value(const String &key) const {
if (f.is_valid()) {
while (!f->eof_reached()) {
const String line = f->get_line();
if (line.find(key) != -1) {
if (line.contains(key)) {
String value = line.split("=")[1].strip_edges();
value = value.trim_prefix("\"");
return value.trim_suffix("\"");

View File

@ -650,42 +650,42 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &p_pres
str.parse_utf8((const char *)plist.ptr(), plist.size());
Vector<String> lines = str.split("\n");
for (int i = 0; i < lines.size(); i++) {
if (lines[i].find("$binary") != -1) {
if (lines[i].contains("$binary")) {
strnew += lines[i].replace("$binary", p_binary) + "\n";
} else if (lines[i].find("$name") != -1) {
} else if (lines[i].contains("$name")) {
strnew += lines[i].replace("$name", GLOBAL_GET("application/config/name")) + "\n";
} else if (lines[i].find("$bundle_identifier") != -1) {
} else if (lines[i].contains("$bundle_identifier")) {
strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n";
} else if (lines[i].find("$short_version") != -1) {
} else if (lines[i].contains("$short_version")) {
strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n";
} else if (lines[i].find("$version") != -1) {
} else if (lines[i].contains("$version")) {
strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n";
} else if (lines[i].find("$signature") != -1) {
} else if (lines[i].contains("$signature")) {
strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n";
} else if (lines[i].find("$app_category") != -1) {
} else if (lines[i].contains("$app_category")) {
String cat = p_preset->get("application/app_category");
strnew += lines[i].replace("$app_category", cat.to_lower()) + "\n";
} else if (lines[i].find("$copyright") != -1) {
} else if (lines[i].contains("$copyright")) {
strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n";
} else if (lines[i].find("$min_version") != -1) {
} else if (lines[i].contains("$min_version")) {
strnew += lines[i].replace("$min_version", p_preset->get("application/min_macos_version")) + "\n";
} else if (lines[i].find("$highres") != -1) {
} else if (lines[i].contains("$highres")) {
strnew += lines[i].replace("$highres", p_preset->get("display/high_res") ? "\t<true/>" : "\t<false/>") + "\n";
} else if (lines[i].find("$additional_plist_content") != -1) {
} else if (lines[i].contains("$additional_plist_content")) {
strnew += lines[i].replace("$additional_plist_content", p_preset->get("application/additional_plist_content")) + "\n";
} else if (lines[i].find("$platfbuild") != -1) {
} else if (lines[i].contains("$platfbuild")) {
strnew += lines[i].replace("$platfbuild", p_preset->get("xcode/platform_build")) + "\n";
} else if (lines[i].find("$sdkver") != -1) {
} else if (lines[i].contains("$sdkver")) {
strnew += lines[i].replace("$sdkver", p_preset->get("xcode/sdk_version")) + "\n";
} else if (lines[i].find("$sdkname") != -1) {
} else if (lines[i].contains("$sdkname")) {
strnew += lines[i].replace("$sdkname", p_preset->get("xcode/sdk_name")) + "\n";
} else if (lines[i].find("$sdkbuild") != -1) {
} else if (lines[i].contains("$sdkbuild")) {
strnew += lines[i].replace("$sdkbuild", p_preset->get("xcode/sdk_build")) + "\n";
} else if (lines[i].find("$xcodever") != -1) {
} else if (lines[i].contains("$xcodever")) {
strnew += lines[i].replace("$xcodever", p_preset->get("xcode/xcode_version")) + "\n";
} else if (lines[i].find("$xcodebuild") != -1) {
} else if (lines[i].contains("$xcodebuild")) {
strnew += lines[i].replace("$xcodebuild", p_preset->get("xcode/xcode_build")) + "\n";
} else if (lines[i].find("$usage_descriptions") != -1) {
} else if (lines[i].contains("$usage_descriptions")) {
String descriptions;
if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) {
descriptions += "\t<key>NSMicrophoneUsageDescription</key>\n";
@ -1081,7 +1081,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres
continue;
}
if (extensions_to_sign.find(current_file.get_extension()) > -1) {
if (extensions_to_sign.has(current_file.get_extension())) {
int ftype = MachO::get_filetype(current_file_path);
Error code_sign_error{ _code_sign(p_preset, current_file_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)) };
if (code_sign_error != OK) {
@ -1202,7 +1202,7 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access
// If it is a directory, find and sign all dynamic libraries.
err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign);
} else {
if (extensions_to_sign.find(p_in_app_path.get_extension()) > -1) {
if (extensions_to_sign.has(p_in_app_path.get_extension())) {
int ftype = MachO::get_filetype(p_in_app_path);
err = _code_sign(p_preset, p_in_app_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5));
}
@ -1260,7 +1260,7 @@ Error EditorExportPlatformMacOS::_create_pkg(const Ref<EditorExportPreset> &p_pr
}
print_verbose("productbuild returned: " + str);
if (str.find("productbuild: error:") != -1) {
if (str.contains("productbuild: error:")) {
add_message(EXPORT_MESSAGE_ERROR, TTR("PKG Creation"), TTR("`productbuild` failed."));
return FAILED;
}
@ -1292,8 +1292,8 @@ Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const Str
}
print_verbose("hdiutil returned: " + str);
if (str.find("create failed") != -1) {
if (str.find("File exists") != -1) {
if (str.contains("create failed")) {
if (str.contains("File exists")) {
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed - file exists."));
} else {
add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed."));

View File

@ -347,7 +347,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport
PackedStringArray version_array = file_version.split(".", false);
if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
!version_array[3].is_valid_int() || file_version.find("-") > -1) {
!version_array[3].is_valid_int() || file_version.contains("-")) {
return TTR("Invalid file version.");
}
}
@ -357,7 +357,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport
PackedStringArray version_array = product_version.split(".", false);
if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
!version_array[3].is_valid_int() || product_version.find("-") > -1) {
!version_array[3].is_valid_int() || product_version.contains("-")) {
return TTR("Invalid product version.");
}
}
@ -569,13 +569,13 @@ Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset
DirAccess::remove_file_or_error(tmp_icon_path);
}
if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
if (err != OK || str.contains("not found") || str.contains("not recognized")) {
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), TTR("Could not start rcedit executable. Configure rcedit path in the Editor Settings (Export > Windows > rcedit), or disable \"Application > Modify Resources\" in the export preset."));
return err;
}
print_line("rcedit (" + p_path + "): " + str);
if (str.find("Fatal error") != -1) {
if (str.contains("Fatal error")) {
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("rcedit failed to modify executable: %s."), str));
return FAILED;
}
@ -718,7 +718,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
String str;
Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true);
if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
if (err != OK || str.contains("not found") || str.contains("not recognized")) {
#ifdef WINDOWS_ENABLED
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start signtool executable. Configure signtool path in the Editor Settings (Export > Windows > signtool), or disable \"Codesign\" in the export preset."));
#else
@ -729,9 +729,9 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
print_line("codesign (" + p_path + "): " + str);
#ifndef WINDOWS_ENABLED
if (str.find("SignTool Error") != -1) {
if (str.contains("SignTool Error")) {
#else
if (str.find("Failed") != -1) {
if (str.contains("Failed")) {
#endif
add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Signtool failed to sign executable: %s."), str));
return FAILED;

View File

@ -253,7 +253,7 @@ void Skeleton3D::_update_process_order() {
int parent_bone_idx = bonesptr[i].parent;
// Check to see if this node is already added to the parent.
if (bonesptr[parent_bone_idx].child_bones.find(i) < 0) {
if (!bonesptr[parent_bone_idx].child_bones.has(i)) {
// Add the child node.
bonesptr[parent_bone_idx].child_bones.push_back(i);
} else {

View File

@ -526,7 +526,7 @@ void TextureProgressBar::_notification(int p_what) {
Vector<Point2> points;
for (const float &f : pts) {
Point2 uv = unit_val_to_uv(f);
if (uvs.find(uv) >= 0) {
if (uvs.has(uv)) {
continue;
}
points.push_back(progress_offset + Point2(uv.x * s.x, uv.y * s.y));

View File

@ -1880,7 +1880,7 @@ void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) {
do {
shape_name = String(p_name) + " " + itos(count);
count++;
} while (blend_shapes.find(shape_name) != -1);
} while (blend_shapes.has(shape_name));
}
blend_shapes.write[p_index] = shape_name;

View File

@ -618,7 +618,7 @@ Ref<AudioStreamPlayback> AudioStreamRandomizer::instance_playback_sequential() {
if (entry.stream.is_null()) {
continue;
}
if (local_pool.find(entry.stream) != -1) {
if (local_pool.has(entry.stream)) {
WARN_PRINT("Duplicate stream in sequential playback pool");
continue;
}

View File

@ -671,9 +671,9 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
TextureFormat format = p_format;
if (format.shareable_formats.size()) {
ERR_FAIL_COND_V_MSG(format.shareable_formats.find(format.format) == -1, RID(),
ERR_FAIL_COND_V_MSG(!format.shareable_formats.has(format.format), RID(),
"If supplied a list of shareable formats, the current format must be present in the list");
ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && format.shareable_formats.find(p_view.format_override) == -1, RID(),
ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && !format.shareable_formats.has(p_view.format_override), RID(),
"If supplied a list of shareable formats, the current view format override must be present in the list");
}
@ -854,7 +854,7 @@ RID RenderingDevice::texture_create_shared(const TextureView &p_view, RID p_with
} else {
ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID());
ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(),
ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(),
"Format override is not in the list of allowed shareable formats for original texture.");
tv.format = p_view.format_override;
}
@ -984,7 +984,7 @@ RID RenderingDevice::texture_create_shared_from_slice(const TextureView &p_view,
} else {
ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID());
ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(),
ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(),
"Format override is not in the list of allowed shareable formats for original texture.");
tv.format = p_view.format_override;
}

View File

@ -195,12 +195,12 @@ struct Context {
}
bool has_type(const TypeReference &p_type_ref) const {
if (builtin_types.find(p_type_ref.name) >= 0) {
if (builtin_types.has(p_type_ref.name)) {
return true;
}
if (p_type_ref.is_enum) {
if (enum_types.find(p_type_ref.name) >= 0) {
if (enum_types.has(p_type_ref.name)) {
return true;
}
@ -355,7 +355,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
const ArgumentData &idx_arg = getter->arguments.front()->get();
if (idx_arg.type.name != p_context.names_cache.int_type) {
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
TEST_COND(!p_context.enum_types.has(idx_arg.type.name),
"Invalid type '", idx_arg.type.name, "' for index argument of property getter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
@ -367,7 +367,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co
if (idx_arg.type.name != p_context.names_cache.int_type) {
// Assume the index parameter is an enum
// If not an int, it can be an enum
TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0,
TEST_COND(!p_context.enum_types.has(idx_arg.type.name),
"Invalid type '", idx_arg.type.name, "' for index argument of property setter: '", p_class.name, ".", String(p_prop.name), "'.");
}
}
@ -736,7 +736,7 @@ void add_exposed_classes(Context &r_context) {
for (const StringName &E : K.value.constants) {
const StringName &constant_name = E;
TEST_FAIL_COND(String(constant_name).find("::") != -1,
TEST_FAIL_COND(String(constant_name).contains("::"),
"Enum constant contains '::', check bindings to remove the scope: '",
String(class_name), ".", String(enum_.name), ".", String(constant_name), "'.");
int64_t *value = class_info->constant_map.getptr(constant_name);
@ -758,7 +758,7 @@ void add_exposed_classes(Context &r_context) {
for (const String &E : constants) {
const String &constant_name = E;
TEST_FAIL_COND(constant_name.find("::") != -1,
TEST_FAIL_COND(constant_name.contains("::"),
"Constant contains '::', check bindings to remove the scope: '",
String(class_name), ".", constant_name, "'.");
int64_t *value = class_info->constant_map.getptr(StringName(E));

View File

@ -242,7 +242,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
String name = String(p_in.m_name);
String suite_name = String(p_in.m_test_suite);
if (name.find("[SceneTree]") != -1 || name.find("[Editor]") != -1) {
if (name.contains("[SceneTree]") || name.contains("[Editor]")) {
memnew(MessageQueue);
memnew(Input);
@ -291,7 +291,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
#ifdef TOOLS_ENABLED
if (name.find("[Editor]") != -1) {
if (name.contains("[Editor]")) {
Engine::get_singleton()->set_editor_hint(true);
EditorPaths::create();
EditorSettings::create();
@ -301,7 +301,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
return;
}
if (name.find("Audio") != -1) {
if (name.contains("Audio")) {
// The last driver index should always be the dummy driver.
int dummy_idx = AudioDriverManager::get_driver_count() - 1;
AudioDriverManager::initialize(dummy_idx);
@ -311,7 +311,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
#ifndef _3D_DISABLED
if (suite_name.find("[Navigation]") != -1 && navigation_server_2d == nullptr && navigation_server_3d == nullptr) {
if (suite_name.contains("[Navigation]") && navigation_server_2d == nullptr && navigation_server_3d == nullptr) {
ERR_PRINT_OFF;
navigation_server_3d = NavigationServer3DManager::new_default_server();
navigation_server_2d = NavigationServer2DManager::new_default_server();