diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-24 14:21:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-24 14:21:06 +0200 |
commit | 96d7bc62af25b85b8b9cc091eeea1e7a784ba624 (patch) | |
tree | 83d8a70c911fe7f8d20080a1395d195eb8370d05 | |
parent | 9ac27b58c53b50b5c7085a8fdee653e9eff159d1 (diff) | |
parent | 4e6efd1b07f1c6d53d226977ddc729333b74306a (diff) |
Merge pull request #50511 from aaronfranke/iterators
Use C++ range iterators for Lists in many situations
218 files changed, 2755 insertions, 3004 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp index ad31966a65..c03c872f17 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -214,8 +214,8 @@ bool Engine::has_singleton(const String &p_name) const { } void Engine::get_singletons(List<Singleton> *p_singletons) { - for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) { - p_singletons->push_back(E->get()); + for (Singleton &E : singletons) { + p_singletons->push_back(E); } } diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 84860b648d..22acb23bce 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -700,9 +700,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str int count = 0; for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) { - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - count++; - } + count += E->get().size(); } if (p_custom_features != String()) { @@ -734,8 +732,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str } for (Map<String, List<String>>::Element *E = props.front(); E; E = E->next()) { - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (String &key : E->get()) { if (E->key() != "") { key = E->key() + "/" + key; } @@ -803,8 +800,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin if (E->key() != "") { file->store_string("[" + E->key() + "]\n\n"); } - for (List<String>::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (String &F : E->get()) { + String key = F; if (E->key() != "") { key = E->key() + "/" + key; } @@ -817,7 +814,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin String vstr; VariantWriter::write_to_string(value, vstr); - file->store_string(F->get().property_name_encode() + "=" + vstr + "\n"); + file->store_string(F.property_name_encode() + "=" + vstr + "\n"); } } @@ -931,11 +928,11 @@ Vector<String> ProjectSettings::get_optimizer_presets() const { ProjectSettings::get_singleton()->get_property_list(&pi); Vector<String> names; - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!E->get().name.begins_with("optimizer_presets/")) { + for (PropertyInfo &E : pi) { + if (!E.name.begins_with("optimizer_presets/")) { continue; } - names.push_back(E->get().name.get_slicec('/', 1)); + names.push_back(E.name.get_slicec('/', 1)); } names.sort(); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 8ec934db62..7a1ba63233 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -75,8 +75,8 @@ Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String List<String> exts; ResourceLoader::get_recognized_extensions_for_type(p_type, &exts); Vector<String> ret; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : exts) { + ret.push_back(E); } return ret; @@ -91,8 +91,8 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); PackedStringArray ret; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : deps) { + ret.push_back(E); } return ret; @@ -141,8 +141,8 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) List<String> exts; ResourceSaver::get_recognized_extensions(p_resource, &exts); Vector<String> ret; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : exts) { + ret.push_back(E); } return ret; } @@ -268,8 +268,8 @@ String _OS::get_name() const { Vector<String> _OS::get_cmdline_args() { List<String> cmdline = OS::get_singleton()->get_cmdline_args(); Vector<String> cmdlinev; - for (List<String>::Element *E = cmdline.front(); E; E = E->next()) { - cmdlinev.push_back(E->get()); + for (String &E : cmdline) { + cmdlinev.push_back(E); } return cmdlinev; @@ -355,20 +355,20 @@ void _OS::print_all_textures_by_size() { List<Ref<Resource>> rsrc; ResourceCache::get_cached_resources(&rsrc); - for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) { - if (!E->get()->is_class("ImageTexture")) { + for (Ref<Resource> E : rsrc) { + if (!E->is_class("ImageTexture")) { continue; } - Size2 size = E->get()->call("get_size"); - int fmt = E->get()->call("get_format"); + Size2 size = E->call("get_size"); + int fmt = E->call("get_format"); _OSCoreBindImg img; img.size = size; img.fmt = fmt; - img.path = E->get()->get_path(); + img.path = E->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get()->get_instance_id(); + img.id = E->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -376,8 +376,8 @@ void _OS::print_all_textures_by_size() { imgs.sort(); - for (List<_OSCoreBindImg>::Element *E = imgs.front(); E; E = E->next()) { - total -= E->get().vram; + for (_OSCoreBindImg &E : imgs) { + total -= E.vram; } } @@ -387,9 +387,7 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) { List<Ref<Resource>> resources; ResourceCache::get_cached_resources(&resources); - for (List<Ref<Resource>>::Element *E = resources.front(); E; E = E->next()) { - Ref<Resource> r = E->get(); - + for (Ref<Resource> r : resources) { bool found = false; for (int i = 0; i < p_types.size(); i++) { @@ -1824,8 +1822,8 @@ PackedStringArray _ClassDB::get_class_list() const { PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1838,8 +1836,8 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1893,8 +1891,8 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_signal_list(p_class, &signals, p_no_inheritance); Array ret; - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (MethodInfo &E : signals) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1904,8 +1902,8 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con List<PropertyInfo> plist; ClassDB::get_property_list(p_class, &plist, p_no_inheritance); Array ret; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (PropertyInfo &E : plist) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1937,12 +1935,12 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_method_list(p_class, &methods, p_no_inheritance); Array ret; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { + for (MethodInfo &E : methods) { #ifdef DEBUG_METHODS_ENABLED - ret.push_back(E->get().operator Dictionary()); + ret.push_back(E.operator Dictionary()); #else Dictionary dict; - dict["name"] = E->get().name; + dict["name"] = E.name; ret.push_back(dict); #endif } @@ -1957,8 +1955,8 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, PackedStringArray ret; ret.resize(constants.size()); int idx = 0; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (String &E : constants) { + ret.set(idx++, E); } return ret; diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp index 26f82c2658..b832dd58d5 100644 --- a/core/debugger/debugger_marshalls.cpp +++ b/core/debugger/debugger_marshalls.cpp @@ -40,11 +40,11 @@ Array DebuggerMarshalls::ResourceUsage::serialize() { Array arr; arr.push_back(infos.size() * 4); - for (List<ResourceInfo>::Element *E = infos.front(); E; E = E->next()) { - arr.push_back(E->get().path); - arr.push_back(E->get().format); - arr.push_back(E->get().type); - arr.push_back(E->get().vram); + for (ResourceInfo &E : infos) { + arr.push_back(E.path); + arr.push_back(E.format); + arr.push_back(E.type); + arr.push_back(E.vram); } return arr; } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index ab368471e4..24833711d5 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -320,13 +320,13 @@ void LocalDebugger::print_variables(const List<String> &names, const List<Varian String value; Vector<String> value_lines; const List<Variant>::Element *V = values.front(); - for (const List<String>::Element *E = names.front(); E; E = E->next()) { + for (const String &E : names) { value = String(V->get()); if (variable_prefix.is_empty()) { - print_line(E->get() + ": " + String(V->get())); + print_line(E + ": " + String(V->get())); } else { - print_line(E->get() + ":"); + print_line(E + ":"); value_lines = value.split("\n"); for (int i = 0; i < value_lines.size(); ++i) { print_line(variable_prefix + value_lines[i]); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index bdbb7766fa..7d3abc9b46 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -427,16 +427,16 @@ void RemoteDebugger::_send_resource_usage() { List<RS::TextureInfo> tinfo; RS::get_singleton()->texture_debug_usage(&tinfo); - for (List<RS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) { + for (RS::TextureInfo &E : tinfo) { DebuggerMarshalls::ResourceInfo info; - info.path = E->get().path; - info.vram = E->get().bytes; - info.id = E->get().texture; + info.path = E.path; + info.vram = E.bytes; + info.id = E.texture; info.type = "Texture"; - if (E->get().depth == 0) { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + " " + Image::get_format_name(E->get().format); + if (E.depth == 0) { + info.format = itos(E.width) + "x" + itos(E.height) + " " + Image::get_format_name(E.format); } else { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + "x" + itos(E->get().depth) + " " + Image::get_format_name(E->get().format); + info.format = itos(E.width) + "x" + itos(E.height) + "x" + itos(E.depth) + " " + Image::get_format_name(E.format); } usage.infos.push_back(info); } diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 3c132a619d..cc2974cbdb 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -276,10 +276,10 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Dictionary d1; d1["name"] = E->key(); Array values; - for (List<Pair<String, int>>::Element *F = E->get().front(); F; F = F->next()) { + for (Pair<String, int> &F : E->get()) { Dictionary d2; - d2["name"] = F->get().first; - d2["value"] = F->get().second; + d2["name"] = F.first; + d2["value"] = F.second; values.push_back(d2); } d1["values"] = values; @@ -294,8 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> utility_func_names; Variant::get_utility_function_list(&utility_func_names); - for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) { - StringName name = E->get(); + for (StringName &name : utility_func_names) { Dictionary func; func["name"] = String(name); if (Variant::has_utility_function_return_value(name)) { @@ -363,8 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> member_names; Variant::get_member_list(type, &member_names); - for (List<StringName>::Element *E = member_names.front(); E; E = E->next()) { - StringName member_name = E->get(); + for (StringName &member_name : member_names) { Dictionary d2; d2["name"] = String(member_name); d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name)); @@ -380,8 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> constant_names; Variant::get_constants_for_type(type, &constant_names); - for (List<StringName>::Element *E = constant_names.front(); E; E = E->next()) { - StringName constant_name = E->get(); + for (StringName &constant_name : constant_names) { Dictionary d2; d2["name"] = String(constant_name); Variant constant = Variant::get_constant_value(type, constant_name); @@ -420,8 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<StringName> method_names; Variant::get_builtin_method_list(type, &method_names); - for (List<StringName>::Element *E = method_names.front(); E; E = E->next()) { - StringName method_name = E->get(); + for (StringName &method_name : method_names) { Dictionary d2; d2["name"] = String(method_name); if (Variant::has_builtin_method_return_value(type, method_name)) { @@ -503,9 +499,8 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { class_list.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) { + for (StringName &class_name : class_list) { Dictionary d; - StringName class_name = E->get(); d["name"] = String(class_name); d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted"); d["is_instantiable"] = ClassDB::can_instantiate(class_name); @@ -525,15 +520,15 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array constants; List<String> constant_list; ClassDB::get_integer_constant_list(class_name, &constant_list, true); - for (List<String>::Element *F = constant_list.front(); F; F = F->next()) { - StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F->get()); + for (String &F : constant_list) { + StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F); if (enum_name != StringName()) { continue; //enums will be handled on their own } Dictionary d2; - d2["name"] = String(F->get()); - d2["value"] = ClassDB::get_integer_constant(class_name, F->get()); + d2["name"] = String(F); + d2["value"] = ClassDB::get_integer_constant(class_name, F); constants.push_back(d2); } @@ -547,13 +542,13 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array enums; List<StringName> enum_list; ClassDB::get_enum_list(class_name, &enum_list, true); - for (List<StringName>::Element *F = enum_list.front(); F; F = F->next()) { + for (StringName &F : enum_list) { Dictionary d2; - d2["name"] = String(F->get()); + d2["name"] = String(F); Array values; List<StringName> enum_constant_list; - ClassDB::get_enum_constants(class_name, F->get(), &enum_constant_list, true); + ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true); for (List<StringName>::Element *G = enum_constant_list.front(); G; G = G->next()) { Dictionary d3; d3["name"] = String(G->get()); @@ -575,14 +570,14 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array methods; List<MethodInfo> method_list; ClassDB::get_method_list(class_name, &method_list, true); - for (List<MethodInfo>::Element *F = method_list.front(); F; F = F->next()) { - StringName method_name = F->get().name; - if (F->get().flags & METHOD_FLAG_VIRTUAL) { + for (MethodInfo &F : method_list) { + StringName method_name = F.name; + if (F.flags & METHOD_FLAG_VIRTUAL) { //virtual method - const MethodInfo &mi = F->get(); + const MethodInfo &mi = F; Dictionary d2; d2["name"] = String(method_name); - d2["is_const"] = (F->get().flags & METHOD_FLAG_CONST) ? true : false; + d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false; d2["is_vararg"] = false; d2["is_virtual"] = true; // virtual functions have no hash since no MethodBind is involved @@ -619,7 +614,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { methods.push_back(d2); - } else if (F->get().name.begins_with("_")) { + } else if (F.name.begins_with("_")) { //hidden method, ignore } else { @@ -692,19 +687,19 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array signals; List<MethodInfo> signal_list; ClassDB::get_signal_list(class_name, &signal_list, true); - for (List<MethodInfo>::Element *F = signal_list.front(); F; F = F->next()) { - StringName signal_name = F->get().name; + for (MethodInfo &F : signal_list) { + StringName signal_name = F.name; Dictionary d2; d2["name"] = String(signal_name); Array arguments; - for (int i = 0; i < F->get().arguments.size(); i++) { + for (int i = 0; i < F.arguments.size(); i++) { Dictionary d3; - d3["name"] = F->get().arguments[i].name; - Variant::Type type = F->get().arguments[i].type; - if (F->get().arguments[i].class_name != StringName()) { - d3["type"] = String(F->get().arguments[i].class_name); + d3["name"] = F.arguments[i].name; + Variant::Type type = F.arguments[i].type; + if (F.arguments[i].class_name != StringName()) { + d3["type"] = String(F.arguments[i].class_name); } else if (type == Variant::NIL) { d3["type"] = "Variant"; } else { @@ -728,28 +723,28 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array properties; List<PropertyInfo> property_list; ClassDB::get_property_list(class_name, &property_list, true); - for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) { - if (F->get().usage & PROPERTY_USAGE_CATEGORY || F->get().usage & PROPERTY_USAGE_GROUP || F->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (PropertyInfo &F : property_list) { + if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) { continue; //not real properties } - if (F->get().name.begins_with("_")) { + if (F.name.begins_with("_")) { continue; //hidden property } - StringName property_name = F->get().name; + StringName property_name = F.name; Dictionary d2; d2["name"] = String(property_name); - if (F->get().class_name != StringName()) { - d2["type"] = String(F->get().class_name); - } else if (F->get().type == Variant::NIL && F->get().usage & PROPERTY_USAGE_NIL_IS_VARIANT) { + if (F.class_name != StringName()) { + d2["type"] = String(F.class_name); + } else if (F.type == Variant::NIL && F.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { d2["type"] = "Variant"; } else { - d2["type"] = Variant::get_type_name(F->get().type); + d2["type"] = Variant::get_type_name(F.type); } - d2["setter"] = ClassDB::get_property_setter(class_name, F->get().name); - d2["getter"] = ClassDB::get_property_getter(class_name, F->get().name); - d2["index"] = ClassDB::get_property_index(class_name, F->get().name); + d2["setter"] = ClassDB::get_property_setter(class_name, F.name); + d2["getter"] = ClassDB::get_property_getter(class_name, F.name); + d2["index"] = ClassDB::get_property_index(class_name, F.name); properties.push_back(d2); } @@ -771,8 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List<Engine::Singleton> singleton_list; Engine::get_singleton()->get_singletons(&singleton_list); - for (List<Engine::Singleton>::Element *E = singleton_list.front(); E; E = E->next()) { - const Engine::Singleton &s = E->get(); + for (Engine::Singleton &s : singleton_list) { Dictionary d; d["name"] = s.name; if (s.class_name != StringName()) { diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 65718a7507..5f91e61102 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -351,8 +351,8 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or String library_path; - for (List<String>::Element *E = libraries.front(); E; E = E->next()) { - Vector<String> tags = E->get().split("."); + for (String &E : libraries) { + Vector<String> tags = E.split("."); bool all_tags_met = true; for (int i = 0; i < tags.size(); i++) { String tag = tags[i].strip_edges(); @@ -363,7 +363,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or } if (all_tags_met) { - library_path = config->get_value("libraries", E->get()); + library_path = config->get_value("libraries", E); break; } } diff --git a/core/input/input.cpp b/core/input/input.cpp index 6bcf2b4777..e30e7c814f 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -174,9 +174,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S List<PropertyInfo> pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index b5f067d499..0c8705b263 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -65,11 +65,11 @@ String InputMap::_suggest_actions(const StringName &p_action) const { float closest_similarity = 0.0; // Find the most action with the most similar name. - for (List<StringName>::Element *E = actions.front(); E; E = E->next()) { - const float similarity = String(E->get()).similarity(p_action); + for (StringName &action : actions) { + const float similarity = String(action).similarity(p_action); if (similarity > closest_similarity) { - closest_action = E->get(); + closest_action = action; closest_similarity = similarity; } } @@ -105,8 +105,8 @@ Array InputMap::_get_actions() { return ret; } - for (const List<StringName>::Element *E = actions.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : actions) { + ret.push_back(E); } return ret; @@ -129,13 +129,11 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re ERR_FAIL_COND_V(!p_event.is_valid(), nullptr); for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) { - const Ref<InputEvent> e = E->get(); - - int device = e->get_device(); + int device = E->get()->get_device(); if (device == ALL_DEVICES || device == p_event->get_device()) { - if (p_exact_match && e->is_match(p_event, true)) { + if (p_exact_match && E->get()->is_match(p_event, true)) { return E; - } else if (!p_exact_match && e->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { + } else if (!p_exact_match && E->get()->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { return E; } } @@ -198,7 +196,7 @@ Array InputMap::_action_get_events(const StringName &p_action) { const List<Ref<InputEvent>> *al = action_get_events(p_action); if (al) { for (const List<Ref<InputEvent>>::Element *E = al->front(); E; E = E->next()) { - ret.push_back(E->get()); + ret.push_back(E); } } @@ -263,9 +261,7 @@ void InputMap::load_from_project_settings() { List<PropertyInfo> pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 10f68f3cef..aeaf25f321 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -40,8 +40,8 @@ PackedStringArray ConfigFile::_get_sections() const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List<String>::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; @@ -53,8 +53,8 @@ PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List<String>::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index dfba00067f..e30a8dfdd0 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -93,8 +93,8 @@ static Error _erase_recursive(DirAccess *da) { da->list_dir_end(); - for (List<String>::Element *E = dirs.front(); E; E = E->next()) { - Error err = da->change_dir(E->get()); + for (String &E : dirs) { + Error err = da->change_dir(E); if (err == OK) { err = _erase_recursive(da); if (err) { @@ -105,7 +105,7 @@ static Error _erase_recursive(DirAccess *da) { if (err) { return err; } - err = da->remove(da->get_current_dir().plus_file(E->get())); + err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -114,8 +114,8 @@ static Error _erase_recursive(DirAccess *da) { } } - for (List<String>::Element *E = files.front(); E; E = E->next()) { - Error err = da->remove(da->get_current_dir().plus_file(E->get())); + for (String &E : files) { + Error err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -362,16 +362,15 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag list_dir_end(); - for (List<String>::Element *E = dirs.front(); E; E = E->next()) { - String rel_path = E->get(); + for (String &rel_path : dirs) { String target_dir = p_to + rel_path; if (!p_target_da->dir_exists(target_dir)) { Error err = p_target_da->make_dir(target_dir); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'."); } - Error err = change_dir(E->get()); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'."); + Error err = change_dir(rel_path); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + rel_path + "'."); err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links); if (err) { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 8000dd4290..5c1352c1b6 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -93,8 +93,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() { List<String> rh; get_response_headers(&rh); Dictionary ret; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - const String &s = E->get(); + for (const String &s : rh) { int sp = s.find(":"); if (sp == -1) { continue; @@ -113,8 +112,8 @@ PackedStringArray HTTPClient::_get_response_headers() { PackedStringArray ret; ret.resize(rh.size()); int idx = 0; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const String &E : rh) { + ret.set(idx++, E); } return ret; diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index b45e9d26b1..b0bd328d21 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -35,8 +35,8 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { List<String> extensions; get_recognized_extensions(&extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(p_extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(p_extension) == 0) { return true; } } diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 001b1c4757..132c69b7da 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -252,8 +252,8 @@ Array IP::_get_local_addresses() const { Array addresses; List<IPAddress> ip_addresses; get_local_addresses(&ip_addresses); - for (List<IPAddress>::Element *E = ip_addresses.front(); E; E = E->next()) { - addresses.push_back(E->get()); + for (IPAddress &E : ip_addresses) { + addresses.push_back(E); } return addresses; @@ -271,8 +271,8 @@ Array IP::_get_local_interfaces() const { rc["index"] = c.index; Array ips; - for (const List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) { - ips.push_front(F->get()); + for (const IPAddress &F : c.ip_addresses) { + ips.push_front(F); } rc["addresses"] = ips; @@ -286,8 +286,8 @@ void IP::get_local_addresses(List<IPAddress> *r_addresses) const { Map<String, Interface_Info> interfaces; get_local_interfaces(&interfaces); for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) { - for (const List<IPAddress>::Element *F = E->get().ip_addresses.front(); F; F = F->next()) { - r_addresses->push_front(F->get()); + for (const IPAddress &F : E->get().ip_addresses) { + r_addresses->push_front(F); } } } diff --git a/core/io/json.cpp b/core/io/json.cpp index b3a2498212..77a6181931 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -121,14 +121,14 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_ keys.sort(); } - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { if (E != keys.front()) { s += ","; s += end_statement; } - s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); s += colon; - s += _stringify(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _stringify(d[E], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); } s += end_statement + _make_indent(p_indent, p_cur_indent) + "}"; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index f342db2dad..34d37dc99b 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1358,8 +1358,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo obj->get_property_list(&props); int pc = 0; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } pc++; @@ -1372,15 +1372,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - _encode_string(E->get().name, buf, r_len); + _encode_string(E.name, buf, r_len); int len; - Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects); + Error err = encode_variant(obj->get(E.name), buf, len, p_full_objects); if (err) { return err; } @@ -1418,7 +1418,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { /* CharString utf8 = E->->utf8(); @@ -1433,13 +1433,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len++; //pad */ int len; - encode_variant(E->get(), buf, len, p_full_objects); + encode_variant(E, buf, len, p_full_objects); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { buf += len; } - Variant *v = d.getptr(E->get()); + Variant *v = d.getptr(E); ERR_FAIL_COND_V(!v, ERR_BUG); encode_variant(*v, buf, len, p_full_objects); ERR_FAIL_COND_V(len % 4, ERR_BUG); diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index e99c60613a..ee49335f55 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -555,12 +555,12 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC ofs += encode_cstring(path.get_data(), &packet.write[ofs]); - for (List<int>::Element *E = peers_to_add.front(); E; E = E->next()) { - network_peer->set_target_peer(E->get()); // To all of you. + for (int &E : peers_to_add) { + network_peer->set_target_peer(E); // To all of you. network_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE); network_peer->put_packet(packet.ptr(), packet.size()); - psc->confirmed_peers.insert(E->get(), false); // Insert into confirmed, but as false since it was not confirmed. + psc->confirmed_peers.insert(E, false); // Insert into confirmed, but as false since it was not confirmed. } } @@ -917,8 +917,8 @@ void MultiplayerAPI::_del_peer(int p_id) { // Some refactoring is needed to make this faster and do paths GC. List<NodePath> keys; path_send_cache.get_key_list(&keys); - for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) { - PathSentCache *psc = path_send_cache.getptr(E->get()); + for (NodePath &E : keys) { + PathSentCache *psc = path_send_cache.getptr(E); psc->confirmed_peers.erase(p_id); } emit_signal(SNAME("network_peer_disconnected"), p_id); diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index cf6a0b6027..ec43ea9311 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -268,21 +268,21 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd d.get_key_list(&keys); List<DictKey> sortk; - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &key : keys) { DictKey dk; - dk.hash = E->get().hash(); - dk.key = E->get(); + dk.hash = key.hash(); + dk.key = key; sortk.push_back(dk); } sortk.sort(); int idx = 0; - for (List<DictKey>::Element *E = sortk.front(); E; E = E->next()) { - encode_uint32(E->get().hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); - uint32_t ofs = _pack(E->get().key, tmpdata, string_cache); + for (DictKey &E : sortk) { + encode_uint32(E.hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); + uint32_t ofs = _pack(E.key, tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]); - ofs = _pack(d[E->get().key], tmpdata, string_cache); + ofs = _pack(d[E.key], tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 8]); idx++; } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 91a1386965..695988bd71 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -165,15 +165,15 @@ Error Resource::copy_from(const Ref<Resource> &p_resource) { List<PropertyInfo> pi; p_resource->get_property_list(&pi); - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "resource_path") { + if (E.name == "resource_path") { continue; //do not change path } - set(E->get().name, p_resource->get(E->get().name)); + set(E.name, p_resource->get(E.name)); } return OK; } @@ -201,11 +201,11 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res r->local_scene = p_for_scene; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -221,7 +221,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res } } - r->set(E->get().name, p); + r->set(E.name, p); } return r; @@ -233,11 +233,11 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R local_scene = p_for_scene; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -259,21 +259,21 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { Ref<Resource> r = (Resource *)ClassDB::instantiate(get_class()); ERR_FAIL_COND_V(r.is_null(), Ref<Resource>()); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) { - r->set(E->get().name, p.duplicate(p_subresources)); - } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { + r->set(E.name, p.duplicate(p_subresources)); + } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { RES sr = p; if (sr.is_valid()) { - r->set(E->get().name, sr->duplicate(p_subresources)); + r->set(E.name, sr->duplicate(p_subresources)); } } else { - r->set(E->get().name, p); + r->set(E.name, p); } } @@ -317,9 +317,9 @@ uint32_t Resource::hash_edited_version() const { List<PropertyInfo> plist; get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE && E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - RES res = get(E->get().name); + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + RES res = get(E.name); if (res.is_valid()) { hash = hash_djb2_one_32(res->hash_edited_version(), hash); } diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index e889586afc..a8eeaa6602 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1025,8 +1025,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String extensions.sort(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1036,8 +1036,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List<String> *p_exten ClassDB::get_resource_base_extensions(&extensions); extensions.sort(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1528,14 +1528,14 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ - write_variant(f, E->get(), resource_map, external_resources, string_map); - write_variant(f, d[E->get()], resource_map, external_resources, string_map); + write_variant(f, E, resource_map, external_resources, string_map); + write_variant(f, d[E], resource_map, external_resources, string_map); } } break; @@ -1685,15 +1685,15 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant res->get_property_list(&property_list); - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - Variant value = res->get(E->get().name); - if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + for (PropertyInfo &E : property_list) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + Variant value = res->get(E.name); + if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { RES sres = value; if (sres.is_valid()) { NonPersistentKey npk; npk.base = res; - npk.property = E->get().name; + npk.property = E.name; non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); @@ -1723,9 +1723,9 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant Dictionary d = p_variant; List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _find_resources(E->get()); - Variant v = d[E->get()]; + for (Variant &E : keys) { + _find_resources(E); + Variant v = d[E]; _find_resources(v); } } break; @@ -1832,39 +1832,39 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p List<ResourceData> resources; { - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { + for (RES &E : saved_resources) { ResourceData &rd = resources.push_back(ResourceData())->get(); - rd.type = E->get()->get_class(); + rd.type = E->get_class(); List<PropertyInfo> property_list; - E->get()->get_property_list(&property_list); + E->get_property_list(&property_list); - for (List<PropertyInfo>::Element *F = property_list.front(); F; F = F->next()) { - if (skip_editor && F->get().name.begins_with("__editor")) { + for (PropertyInfo &F : property_list) { + if (skip_editor && F.name.begins_with("__editor")) { continue; } - if ((F->get().usage & PROPERTY_USAGE_STORAGE)) { + if ((F.usage & PROPERTY_USAGE_STORAGE)) { Property p; - p.name_idx = get_string_index(F->get().name); + p.name_idx = get_string_index(F.name); - if (F->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + if (F.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { NonPersistentKey npk; - npk.base = E->get(); - npk.property = F->get().name; + npk.base = E; + npk.property = F.name; if (non_persistent_map.has(npk)) { p.value = non_persistent_map[npk]; } } else { - p.value = E->get()->get(F->get().name); + p.value = E->get(F.name); } - Variant default_value = ClassDB::class_get_default_property_value(E->get()->get_class(), F->get().name); + Variant default_value = ClassDB::class_get_default_property_value(E->get_class(), F.name); if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, p.value, default_value))) { continue; } - p.pi = F->get(); + p.pi = F; rd.properties.push_back(p); } @@ -1897,8 +1897,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector<uint64_t> ofs_pos; Set<String> used_unique_ids; - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { if (r->get_scene_unique_id() != "") { if (used_unique_ids.has(r->get_scene_unique_id())) { @@ -1912,8 +1911,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Map<RES, int> resource_map; int res_index = 0; - for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { if (r->get_scene_unique_id() == "") { String new_id; @@ -1947,17 +1945,15 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector<uint64_t> ofs_table; //now actually save the resources - for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) { - ResourceData &rd = E->get(); - + for (ResourceData &rd : resources) { ofs_table.push_back(f->get_position()); save_unicode_string(f, rd.type); f->store_32(rd.properties.size()); - for (List<Property>::Element *F = rd.properties.front(); F; F = F->next()) { - Property &p = F->get(); + for (Property &F : rd.properties) { + Property &p = F; f->store_32(p.name_idx); - write_variant(f, p.value, resource_map, external_resources, string_map, F->get().pi); + write_variant(f, p.value, resource_map, external_resources, string_map, F.pi); } } diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index f612b84404..511c145f2b 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -146,10 +146,10 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -175,10 +175,10 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -372,8 +372,8 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get()) { + for (String &F : local_exts) { + if (p_extension.to_lower() == F) { r_importers->push_back(importers[i]); } } @@ -393,8 +393,8 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St for (int i = 0; i < importers.size(); i++) { List<String> local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List<String>::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get() && importers[i]->get_priority() > priority) { + for (String &F : local_exts) { + if (p_extension.to_lower() == F && importers[i]->get_priority() > priority) { importer = importers[i]; priority = importers[i]->get_priority(); } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index c5dfe1f2b0..0c825a62bb 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -58,8 +58,8 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ get_recognized_extensions_for_type(p_for_type, &extensions); } - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { return true; } } @@ -978,15 +978,15 @@ void ResourceLoader::load_translation_remaps() { Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps"); List<Variant> keys; remaps.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - Array langs = remaps[E->get()]; + for (Variant &E : keys) { + Array langs = remaps[E]; Vector<String> lang_remaps; lang_remaps.resize(langs.size()); for (int i = 0; i < langs.size(); i++) { lang_remaps.write[i] = langs[i]; } - translation_remaps[String(E->get())] = lang_remaps; + translation_remaps[String(E)] = lang_remaps; } } @@ -1071,8 +1071,7 @@ void ResourceLoader::add_custom_loaders() { List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_loader_base_class) { diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 80cb85fba3..e1bd4ed7fe 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -94,8 +94,8 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t bool recognized = false; saver[i]->get_recognized_extensions(p_resource, &extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { recognized = true; } } @@ -236,8 +236,7 @@ void ResourceSaver::add_custom_savers() { List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_saver_base_class) { diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h index 6f7209556e..81adf4d19a 100644 --- a/core/math/delaunay_3d.h +++ b/core/math/delaunay_3d.h @@ -375,8 +375,7 @@ public: OutputSimplex *ret_simplicesw = ret_simplices.ptrw(); uint32_t simplices_written = 0; - for (List<Simplex *>::Element *E = simplex_list.front(); E; E = E->next()) { - Simplex *simplex = E->get(); + for (Simplex *simplex : simplex_list) { bool invalid = false; for (int j = 0; j < 4; j++) { if (simplex->points[j] >= point_count) { diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 0d77bfe933..9b506269ea 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -192,9 +192,9 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ continue; } - for (List<Face>::Element *E = faces.front(); E; E = E->next()) { - if (E->get().plane.distance_to(p_points[i]) > over_tolerance) { - E->get().points_over.push_back(i); + for (Face &E : faces) { + if (E.plane.distance_to(p_points[i]) > over_tolerance) { + E.points_over.push_back(i); break; } } @@ -292,8 +292,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ //distribute points into new faces - for (List<List<Face>::Element *>::Element *F = lit_faces.front(); F; F = F->next()) { - Face &lf = F->get()->get(); + for (List<Face>::Element *&F : lit_faces) { + Face &lf = F->get(); for (int i = 0; i < lf.points_over.size(); i++) { if (lf.points_over[i] == f.points_over[next]) { //do not add current one @@ -301,8 +301,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ } Vector3 p = p_points[lf.points_over[i]]; - for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List<Face>::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.plane.distance_to(p) > over_tolerance) { f2.points_over.push_back(lf.points_over[i]); break; @@ -320,10 +320,10 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ //put faces that contain no points on the front - for (List<List<Face>::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List<Face>::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.points_over.size() == 0) { - faces.move_to_front(E->get()); + faces.move_to_front(E); } } @@ -336,19 +336,19 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ Map<Edge, RetFaceConnect> ret_edges; List<Geometry3D::MeshData::Face> ret_faces; - for (List<Face>::Element *E = faces.front(); E; E = E->next()) { + for (Face &E : faces) { Geometry3D::MeshData::Face f; - f.plane = E->get().plane; + f.plane = E.plane; for (int i = 0; i < 3; i++) { - f.indices.push_back(E->get().vertices[i]); + f.indices.push_back(E.vertices[i]); } List<Geometry3D::MeshData::Face>::Element *F = ret_faces.push_back(f); for (int i = 0; i < 3; i++) { - uint32_t a = E->get().vertices[i]; - uint32_t b = E->get().vertices[(i + 1) % 3]; + uint32_t a = E.vertices[i]; + uint32_t b = E.vertices[(i + 1) % 3]; Edge e(a, b); Map<Edge, RetFaceConnect>::Element *G = ret_edges.find(e); @@ -439,8 +439,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_ r_mesh.faces.resize(ret_faces.size()); int idx = 0; - for (List<Geometry3D::MeshData::Face>::Element *E = ret_faces.front(); E; E = E->next()) { - r_mesh.faces.write[idx++] = E->get(); + for (Geometry3D::MeshData::Face &E : ret_faces) { + r_mesh.faces.write[idx++] = E; } r_mesh.edges.resize(ret_edges.size()); idx = 0; diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index e2db5918e3..a0ed5db70a 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -359,9 +359,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - ClassInfo *t = classes.getptr(E->get()); - ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'."); + for (StringName &E : names) { + ClassInfo *t = classes.getptr(E); + ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E) + "'."); if (t->api != p_api || !t->exposed) { continue; } @@ -388,8 +388,8 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - MethodBind *mb = t->method_map[F->get()]; + for (StringName &F : snames) { + MethodBind *mb = t->method_map[F]; hash = hash_djb2_one_64(mb->get_name().hash(), hash); hash = hash_djb2_one_64(mb->get_argument_count(), hash); hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return @@ -426,9 +426,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().hash(), hash); - hash = hash_djb2_one_64(t->constant_map[F->get()], hash); + for (StringName &F : snames) { + hash = hash_djb2_one_64(F.hash(), hash); + hash = hash_djb2_one_64(t->constant_map[F], hash); } } @@ -444,9 +444,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - MethodInfo &mi = t->signal_map[F->get()]; - hash = hash_djb2_one_64(F->get().hash(), hash); + for (StringName &F : snames) { + MethodInfo &mi = t->signal_map[F]; + hash = hash_djb2_one_64(F.hash(), hash); for (int i = 0; i < mi.arguments.size(); i++) { hash = hash_djb2_one_64(mi.arguments[i].type, hash); } @@ -465,23 +465,23 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { - PropertySetGet *psg = t->property_setget.getptr(F->get()); + for (StringName &F : snames) { + PropertySetGet *psg = t->property_setget.getptr(F); ERR_FAIL_COND_V(!psg, 0); - hash = hash_djb2_one_64(F->get().hash(), hash); + hash = hash_djb2_one_64(F.hash(), hash); hash = hash_djb2_one_64(psg->setter.hash(), hash); hash = hash_djb2_one_64(psg->getter.hash(), hash); } } //property list - for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().name.hash(), hash); - hash = hash_djb2_one_64(F->get().type, hash); - hash = hash_djb2_one_64(F->get().hint, hash); - hash = hash_djb2_one_64(F->get().hint_string.hash(), hash); - hash = hash_djb2_one_64(F->get().usage, hash); + for (PropertyInfo &F : t->property_list) { + hash = hash_djb2_one_64(F.name.hash(), hash); + hash = hash_djb2_one_64(F.type, hash); + hash = hash_djb2_one_64(F.hint, hash); + hash = hash_djb2_one_64(F.hint_string.hash(), hash); + hash = hash_djb2_one_64(F.usage, hash); } } @@ -619,16 +619,16 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met #ifdef DEBUG_METHODS_ENABLED - for (List<MethodInfo>::Element *E = type->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (MethodInfo &E : type->virtual_methods) { + p_methods->push_back(E); } - for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) { - if (p_exclude_from_properties && type->methods_in_properties.has(E->get())) { + for (StringName &E : type->method_order) { + if (p_exclude_from_properties && type->methods_in_properties.has(E)) { continue; } - MethodBind *method = type->method_map.get(E->get()); + MethodBind *method = type->method_map.get(E); MethodInfo minfo = info_from_bind(method); p_methods->push_back(minfo); @@ -763,8 +763,8 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String> while (type) { #ifdef DEBUG_METHODS_ENABLED - for (List<StringName>::Element *E = type->constant_order.front(); E; E = E->next()) { - p_constants->push_back(E->get()); + for (StringName &E : type->constant_order) { + p_constants->push_back(E); } #else const StringName *K = nullptr; @@ -1073,13 +1073,12 @@ void ClassDB::get_property_list(const StringName &p_class, List<PropertyInfo> *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (List<PropertyInfo>::Element *E = check->property_list.front(); E; E = E->next()) { + for (PropertyInfo pi : check->property_list) { if (p_validator) { - PropertyInfo pi = E->get(); p_validator->_validate_property(pi); p_list->push_back(pi); } else { - p_list->push_back(E->get()); + p_list->push_back(pi); } } @@ -1429,8 +1428,8 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (List<MethodInfo>::Element *E = check->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (MethodInfo &E : check->virtual_methods) { + p_methods->push_back(E); } if (p_no_inheritance) { @@ -1530,11 +1529,11 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (c) { List<PropertyInfo> plist; c->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { - if (!default_values[p_class].has(E->get().name)) { - Variant v = c->get(E->get().name); - default_values[p_class][E->get().name] = v; + for (PropertyInfo &E : plist) { + if (E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { + if (!default_values[p_class].has(E.name)) { + Variant v = c->get(E.name); + default_values[p_class][E.name] = v; } } } diff --git a/core/object/object.cpp b/core/object/object.cpp index 66a4d17b7b..0e397d8518 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -969,8 +969,8 @@ Vector<StringName> Object::_get_meta_list_bind() const { List<Variant> keys; metadata.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _metaret.push_back(E->get()); + for (Variant &E : keys) { + _metaret.push_back(E); } return _metaret; @@ -979,8 +979,8 @@ Vector<StringName> Object::_get_meta_list_bind() const { void Object::get_meta_list(List<StringName> *p_list) const { List<Variant> keys; metadata.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (Variant &E : keys) { + p_list->push_back(E); } } @@ -1184,8 +1184,8 @@ Array Object::_get_signal_list() const { get_signal_list(&signal_list); Array ret; - for (List<MethodInfo>::Element *E = signal_list.front(); E; E = E->next()) { - ret.push_back(Dictionary(E->get())); + for (MethodInfo &E : signal_list) { + ret.push_back(Dictionary(E)); } return ret; @@ -1197,8 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const { Array ret; - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { - Connection &c = E->get(); + for (Connection &c : conns) { if (c.signal.get_name() == p_signal) { ret.push_back(c); } @@ -1297,8 +1296,8 @@ int Object::get_persistent_signal_connection_count() const { } void Object::get_signals_connected_to_this(List<Connection> *p_connections) const { - for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) { - p_connections->push_back(E->get()); + for (const Connection &E : connections) { + p_connections->push_back(E); } } @@ -1500,9 +1499,9 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - _clear_internal_resource_paths(E->get()); - _clear_internal_resource_paths(d[E->get()]); + for (Variant &E : keys) { + _clear_internal_resource_paths(E); + _clear_internal_resource_paths(d[E]); } } break; default: { @@ -1531,8 +1530,8 @@ void Object::clear_internal_resource_paths() { get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - _clear_internal_resource_paths(get(E->get().name)); + for (PropertyInfo &E : pinfo) { + _clear_internal_resource_paths(get(E.name)); } } @@ -1666,12 +1665,12 @@ void Object::get_translatable_strings(List<String> *p_strings) const { List<PropertyInfo> plist; get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) { continue; } - String text = get(E->get().name); + String text = get(E.name); if (text == "") { continue; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 626a7413e7..5aa032192e 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -63,8 +63,8 @@ Array Script::_get_script_property_list() { Array ret; List<PropertyInfo> list; get_script_property_list(&list); - for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (PropertyInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -73,8 +73,8 @@ Array Script::_get_script_method_list() { Array ret; List<MethodInfo> list; get_script_method_list(&list); - for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -83,8 +83,8 @@ Array Script::_get_script_signal_list() { Array ret; List<MethodInfo> list; get_script_signal_list(&list); - for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -257,8 +257,8 @@ void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) { classes.push_back(*K); } classes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - r_global_classes->push_back(E->get()); + for (StringName &E : classes) { + r_global_classes->push_back(E); } } @@ -266,12 +266,12 @@ void ScriptServer::save_global_classes() { List<StringName> gc; get_global_class_list(&gc); Array gcarr; - for (List<StringName>::Element *E = gc.front(); E; E = E->next()) { + for (StringName &E : gc) { Dictionary d; - d["class"] = E->get(); - d["language"] = global_classes[E->get()].language; - d["path"] = global_classes[E->get()].path; - d["base"] = global_classes[E->get()].base; + d["class"] = E; + d["language"] = global_classes[E].language; + d["path"] = global_classes[E].path; + d["base"] = global_classes[E].base; gcarr.push_back(d); } @@ -297,10 +297,10 @@ void ScriptServer::save_global_classes() { void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) { List<PropertyInfo> pinfo; get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { + for (PropertyInfo &E : pinfo) { + if (E.usage & PROPERTY_USAGE_STORAGE) { Pair<StringName, Variant> p; - p.first = E->get().name; + p.first = E.name; if (get(p.first, p.second)) { state.push_back(p); } @@ -430,16 +430,16 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { if (script->is_placeholder_fallback_enabled()) { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - p_properties->push_back(E->get()); + for (const PropertyInfo &E : properties) { + p_properties->push_back(E); } } else { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pinfo = E->get(); + for (const PropertyInfo &E : properties) { + PropertyInfo pinfo = E; if (!values.has(pinfo.name)) { pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE; } - p_properties->push_back(E->get()); + p_properties->push_back(E); } } } @@ -489,11 +489,11 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const Map<StringName, Variant> &p_values) { Set<StringName> new_values; - for (const List<PropertyInfo>::Element *E = p_properties.front(); E; E = E->next()) { - StringName n = E->get().name; + for (const PropertyInfo &E : p_properties) { + StringName n = E.name; new_values.insert(n); - if (!values.has(n) || values[n].get_type() != E->get().type) { + if (!values.has(n) || values[n].get_type() != E.type) { if (p_values.has(n)) { values[n] = p_values[n]; } @@ -511,7 +511,7 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c Variant defval; if (script->get_property_default_value(E->key(), defval)) { //remove because it's the same as the default value - if (defval == E->get()) { + if (defval == E) { to_remove.push_back(E->key()); } } @@ -542,8 +542,8 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, } bool found = false; - for (const List<PropertyInfo>::Element *F = properties.front(); F; F = F->next()) { - if (F->get().name == p_name) { + for (const PropertyInfo &F : properties) { + if (F.name == p_name) { found = true; break; } diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 6808d7602d..adf068eb2f 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -39,12 +39,12 @@ void UndoRedo::_discard_redo() { } for (int i = current_action + 1; i < actions.size(); i++) { - for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - if (E->get().ref.is_valid()) { - E->get().ref.unref(); + for (Operation &E : actions.write[i].do_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); } else { - Object *obj = ObjectDB::get_instance(E->get().object); + Object *obj = ObjectDB::get_instance(E.object); if (obj) { memdelete(obj); } @@ -244,12 +244,12 @@ void UndoRedo::_pop_history_tail() { return; } - for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - if (E->get().ref.is_valid()) { - E->get().ref.unref(); + for (Operation &E : actions.write[0].undo_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); } else { - Object *obj = ObjectDB::get_instance(E->get().object); + Object *obj = ObjectDB::get_instance(E.object); if (obj) { memdelete(obj); } diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index 268562d971..cf0b8d10db 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -66,9 +66,9 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) { int total_compression_size = 0; int total_string_size = 0; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { + for (StringName &E : keys) { //hash string - CharString cs = E->get().operator String().utf8(); + CharString cs = E.operator String().utf8(); uint32_t h = hash(0, cs.get_data()); Pair<int, CharString> p; p.first = idx; @@ -76,7 +76,7 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) { buckets.write[h % size].push_back(p); //compress string - CharString src_s = p_from->get_message(E->get()).operator String().utf8(); + CharString src_s = p_from->get_message(E).operator String().utf8(); CompressedString ps; ps.orig_len = src_s.size(); ps.offset = total_compression_size; diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 678f8fb207..981954c8ae 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -841,8 +841,8 @@ Vector<String> Translation::_get_message_list() const { void Translation::_set_messages(const Dictionary &p_messages) { List<Variant> keys; p_messages.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - translation_map[E->get()] = p_messages[E->get()]; + for (Variant &E : keys) { + translation_map[E] = p_messages[E]; } } diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index f9b4e661e4..afd3b76588 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -47,8 +47,7 @@ void TranslationPO::print_translation_map() { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (StringName &ctx : context_l) { file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== "); const HashMap<StringName, Vector<StringName>> &inner_map = translation_map[ctx]; @@ -74,8 +73,7 @@ Dictionary TranslationPO::_get_messages() const { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (StringName &ctx : context_l) { const HashMap<StringName, Vector<StringName>> &id_str_map = translation_map[ctx]; Dictionary d2; @@ -98,8 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) { List<Variant> context_l; p_messages.get_key_list(&context_l); - for (List<Variant>::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (Variant &ctx : context_l) { const Dictionary &id_str_map = p_messages[ctx]; HashMap<StringName, Vector<StringName>> temp_map; @@ -121,8 +118,8 @@ Vector<String> TranslationPO::_get_message_list() const { get_message_list(&msgs); Vector<String> v; - for (List<StringName>::Element *E = msgs.front(); E; E = E->next()) { - v.push_back(E->get()); + for (StringName &E : msgs) { + v.push_back(E); } return v; @@ -281,13 +278,13 @@ void TranslationPO::get_message_list(List<StringName> *r_messages) const { List<StringName> context_l; translation_map.get_key_list(&context_l); - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - if (String(E->get()) != "") { + for (StringName &E : context_l) { + if (String(E) != "") { continue; } List<StringName> msgid_l; - translation_map[E->get()].get_key_list(&msgid_l); + translation_map[E].get_key_list(&msgid_l); for (List<StringName>::Element *E2 = msgid_l.front(); E2; E2 = E2->next()) { r_messages->push_back(E2->get()); @@ -300,8 +297,8 @@ int TranslationPO::get_message_count() const { translation_map.get_key_list(&context_l); int count = 0; - for (List<StringName>::Element *E = context_l.front(); E; E = E->next()) { - count += translation_map[E->get()].size(); + for (StringName &E : context_l) { + count += translation_map[E].size(); } return count; } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 4cd2915ffa..dbb8dc8283 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3421,11 +3421,8 @@ String String::format(const Variant &values, String placeholder) const { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); - String val = d[E->get()]; - - new_string = new_string.replace(placeholder.replace("_", key), val); + for (Variant &key : keys) { + new_string = new_string.replace(placeholder.replace("_", key), d[key]); } } else { ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index ca6f3d615e..2a3a9a4f1a 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -407,8 +407,8 @@ Array Signal::get_connections() const { object->get_signal_connection_list(name, &connections); Array arr; - for (List<Object::Connection>::Element *E = connections.front(); E; E = E->next()) { - arr.push_back(E->get()); + for (Object::Connection &E : connections) { + arr.push_back(E); } return arr; } diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index badb5ba103..12b6465005 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1681,10 +1681,10 @@ String Variant::stringify(List<const void *> &stack) const { Vector<_VariantStrPair> pairs; - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { _VariantStrPair sp; - sp.key = E->get().stringify(stack); - sp.value = d[E->get()].stringify(stack); + sp.key = E.stringify(stack); + sp.value = d[E].stringify(stack); pairs.push_back(sp); } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 65ad27d0b4..c77a5af6d7 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1088,8 +1088,8 @@ bool Variant::has_builtin_method_return_value(Variant::Type p_type, const String void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) { ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - for (List<StringName>::Element *E = builtin_method_names[p_type].front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (StringName &E : builtin_method_names[p_type]) { + p_list->push_back(E); } } @@ -1152,12 +1152,12 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const { obj->get_method_list(p_list); } } else { - for (List<StringName>::Element *E = builtin_method_names[type].front(); E; E = E->next()) { - const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E->get()); + for (StringName &E : builtin_method_names[type]) { + const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E); ERR_CONTINUE(!method); MethodInfo mi; - mi.name = E->get(); + mi.name = E; //return type if (method->has_return_type) { diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index f9c604fe3e..dc92ac8ac4 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1586,8 +1586,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str List<PropertyInfo> props; obj->get_property_list(&props); bool first = true; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE || E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { + for (PropertyInfo &E : props) { + if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { //must be serialized if (first) { @@ -1596,8 +1596,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, ","); } - p_store_string_func(p_store_string_ud, "\"" + E->get().name + "\":"); - write(obj->get(E->get().name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + p_store_string_func(p_store_string_ud, "\"" + E.name + "\":"); + write(obj->get(E.name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); } } @@ -1615,7 +1615,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "{\n"); for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index de1deace63..62228ea87c 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -1093,9 +1093,9 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { const Dictionary *dic = reinterpret_cast<const Dictionary *>(_data._mem); List<Variant> keys; dic->get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - if (E->get().get_type() == Variant::STRING) { - p_list->push_back(PropertyInfo(Variant::STRING, E->get())); + for (Variant &E : keys) { + if (E.get_type() == Variant::STRING) { + p_list->push_back(PropertyInfo(Variant::STRING, E)); } } } else if (type == OBJECT) { @@ -1106,10 +1106,10 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { } else { List<StringName> members; get_member_list(type, &members); - for (List<StringName>::Element *E = members.front(); E; E = E->next()) { + for (StringName &E : members) { PropertyInfo pi; - pi.name = E->get(); - pi.type = get_member_type(type, E->get()); + pi.name = E; + pi.type = get_member_type(type, E); p_list->push_back(pi); } } diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index 1f69e81d99..e9fa952af3 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -1397,8 +1397,8 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) { } void Variant::get_utility_function_list(List<StringName> *r_functions) { - for (List<StringName>::Element *E = utility_function_name_table.front(); E; E = E->next()) { - r_functions->push_back(E->get()); + for (StringName &E : utility_function_name_table) { + r_functions->push_back(E); } } diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index efeaf32ff7..4c33feb52c 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -269,11 +269,11 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str break; // IPv6 uses index. } - for (List<IPAddress>::Element *F = c.ip_addresses.front(); F; F = F->next()) { - if (!F->get().is_ipv4()) { + for (IPAddress &F : c.ip_addresses) { + if (!F.is_ipv4()) { continue; // Wrong IP type } - if_ip = F->get(); + if_ip = F; break; } break; diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 5bf3bbf8a4..48e4be498b 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8542,8 +8542,8 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) { } else { WARN_PRINT(vformat("%d RIDs of type \"%s\" were leaked.", owned.size(), p_type)); } - for (List<RID>::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (RID E : owned) { + free(E); } } } @@ -8764,13 +8764,13 @@ void RenderingDeviceVulkan::finalize() { List<RID>::Element *N = E->next(); if (texture_is_shared(E->get())) { free(E->get()); - owned.erase(E->get()); + owned.erase(E); } E = N; } //free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. - for (List<RID>::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (RID E : owned) { + free(E); } } } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 05db9045bd..0b4f4964c1 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -898,8 +898,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } // 6-(undo) reinsert overlapped keys - for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - AnimMoveRestore &amr = E->get(); + for (AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -1091,9 +1090,9 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 174f19280a..2adfc29f74 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -598,12 +598,12 @@ public: if (ap) { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { + for (StringName &E : anims) { if (animations != String()) { animations += ","; } - animations += String(E->get()); + animations += String(E); } } } @@ -702,8 +702,8 @@ public: for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; if (from != key_ofs) { key++; continue; @@ -728,8 +728,8 @@ public: bool change_notify_deserved = false; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +986,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,8 +1137,8 @@ public: same_key_type = false; } - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); + for (float &F : E->value()) { + int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { first_key = key; @@ -3356,9 +3356,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) { + for (InsertData &E : insert_data) { //prevent insertion of multiple tracks - if (E->get().path == p_id.path) { + if (E.path == p_id.path) { return; //already inserted a track for this on this frame } } @@ -3843,9 +3843,9 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List<PropertyInfo> pinfo; property_info_base.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { - return E->get(); + for (PropertyInfo &E : pinfo) { + if (E.name == leftover_path[leftover_path.size() - 1]) { + return E; } } @@ -4675,21 +4675,21 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List<MethodInfo> minfo; base->get_method_list(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - if (E->get().name == p_method) { + for (MethodInfo &E : minfo) { + if (E.name == p_method) { Dictionary d; d["method"] = p_method; Array params; - int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); + int first_defarg = E.arguments.size() - E.default_arguments.size(); - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.arguments.size(); i++) { if (i >= first_defarg) { - Variant arg = E->get().default_arguments[i - first_defarg]; + Variant arg = E.default_arguments[i - first_defarg]; params.push_back(arg); } else { Callable::CallError ce; Variant arg; - Variant::construct(E->get().arguments[i].type, arg, nullptr, 0, ce); + Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce); params.push_back(arg); } } @@ -4936,8 +4936,7 @@ void AnimationTrackEditor::_move_selection_commit() { } // 6 - (undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5151,9 +5150,9 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map<SelectedKey, KeyInfo> new_selection; - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); @@ -5462,8 +5461,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } // 6-(undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5543,8 +5541,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List<StringName> names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + for (StringName &E : names) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { _cleanup_animation(animation); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index b0ec346afe..012276fe10 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -854,9 +854,7 @@ void CodeTextEditor::_complete_request() { return; } - for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) { - ScriptCodeCompletionOption &e = E->get(); - + for (ScriptCodeCompletionOption &e : entries) { Color font_color = completion_font_color; if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { font_color = completion_string_color; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c439d6a1d4..f5cfe0fe57 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -944,9 +944,7 @@ void ConnectionsDock::update_tree() { node_signals2.sort(); } - for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); - + for (MethodInfo &mi : node_signals2) { StringName signal_name = mi.name; String signaldesc = "("; PackedStringArray argnames; @@ -1025,8 +1023,8 @@ void ConnectionsDock::update_tree() { List<Object::Connection> connections; selectedNode->get_signal_connection_list(signal_name, &connections); - for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) { - Connection cn = F->get(); + for (Object::Connection &F : connections) { + Connection cn = F; if (!(cn.flags & CONNECT_PERSIST)) { continue; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index bfbd697409..abe17bf427 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -447,8 +447,7 @@ Variant CreateDialog::instance_selected() { List<PropertyInfo> pinfo; ((Object *)obj)->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) { Object *prop = ClassDB::instantiate(pi.class_name); ((Object *)obj)->set(pi.name, prop); diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index a629bf6159..a1eb71235c 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -56,8 +56,8 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const { p_list->clear(); //sorry, no want category - for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : prop_list) { + p_list->push_back(E); } } diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index a61e9bd73e..f17ad0d36c 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -365,13 +365,13 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } TreeItem *category = variables->create_item(parent); - for (List<TreeItem *>::Element *E = stack.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); + for (TreeItem *E : stack) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); total_cpu += cpu_time; total_gpu += gpu_time; - E->get()->set_metadata(1, cpu_time); - E->get()->set_metadata(2, gpu_time); + E->set_metadata(1, cpu_time); + E->set_metadata(2, gpu_time); } category->set_icon(0, track_icon); @@ -392,11 +392,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } } - for (List<TreeItem *>::Element *E = categories.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); - E->get()->set_text(1, _get_time_as_text(total_cpu)); - E->get()->set_text(2, _get_time_as_text(total_gpu)); + for (TreeItem *E : categories) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); + E->set_text(1, _get_time_as_text(total_cpu)); + E->set_text(2, _get_time_as_text(total_gpu)); } if (ensure_selected) { diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 06b02cceb4..8af59a62de 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -347,13 +347,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da uint64_t total = 0; - for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { + for (DebuggerMarshalls::ResourceInfo &E : usage.infos) { TreeItem *it = vmem_tree->create_item(root); - String type = E->get().type; - int bytes = E->get().vram; - it->set_text(0, E->get().path); + String type = E.type; + int bytes = E.vram; + it->set_text(0, E.path); it->set_text(1, type); - it->set_text(2, E->get().format); + it->set_text(2, E.format); it->set_text(3, String::humanize_size(bytes)); total += bytes; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index c18b8743cd..0631798b4b 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -55,8 +55,8 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->clear_filters(); List<String> ext; ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - search->add_filter("*" + E->get()); + for (String &E : ext) { + search->add_filter("*" + E); } search->popup_file_dialog(); } @@ -120,13 +120,13 @@ void DependencyEditor::_fix_all() { Map<String, Map<String, String>> candidates; - for (List<String>::Element *E = missing.front(); E; E = E->next()) { - String base = E->get().get_file(); + for (String &E : missing) { + String base = E.get_file(); if (!candidates.has(base)) { candidates[base] = Map<String, String>(); } - candidates[base][E->get()] = ""; + candidates[base][E] = ""; } _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates); @@ -166,10 +166,8 @@ void DependencyEditor::_update_list() { bool broken = false; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { + for (String &n : deps) { TreeItem *item = tree->create_item(root); - - String n = E->get(); String path; String type; @@ -741,9 +739,9 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path void OrphanResourcesDialog::_delete_confirm() { DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); - EditorFileSystem::get_singleton()->update_file(E->get()); + for (String &E : paths) { + da->remove(E); + EditorFileSystem::get_singleton()->update_file(E); } memdelete(da); refresh(); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index befafec6cb..9258ff8043 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -266,20 +266,20 @@ void DocTools::generate(bool p_basic_types) { } List<PropertyInfo>::Element *EO = own_properties.front(); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (PropertyInfo &E : properties) { bool inherited = EO == nullptr; - if (EO && EO->get() == E->get()) { + if (EO && EO->get() == E) { inherited = false; EO = EO->next(); } - if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) { + if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) { continue; } DocData::PropertyDoc prop; - prop.name = E->get().name; + prop.name = E.name; prop.overridden = inherited; @@ -288,20 +288,20 @@ void DocTools::generate(bool p_basic_types) { if (name == "ProjectSettings") { // Special case for project settings, so that settings are not taken from the current project's settings - if (E->get().name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E->get().name)) { + if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { continue; } - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E->get().name)) { - default_value = ProjectSettings::get_singleton()->property_get_revert(E->get().name); + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E.name)) { + default_value = ProjectSettings::get_singleton()->property_get_revert(E.name); default_value_valid = true; } } } else { - default_value = get_documentation_default_value(name, E->get().name, default_value_valid); + default_value = get_documentation_default_value(name, E.name, default_value_valid); if (inherited) { bool base_default_value_valid = false; - Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { continue; } @@ -309,13 +309,13 @@ void DocTools::generate(bool p_basic_types) { } //used to track uninitialized values using valgrind - //print_line("getting default value for " + String(name) + "." + String(E->get().name)); + //print_line("getting default value for " + String(name) + "." + String(E.name)); if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); + StringName setter = ClassDB::get_property_setter(name, E.name); + StringName getter = ClassDB::get_property_getter(name, E.name); prop.setter = setter; prop.getter = getter; @@ -353,10 +353,10 @@ void DocTools::generate(bool p_basic_types) { } if (!found_type) { - if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - prop.type = E->get().hint_string; + if (E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + prop.type = E.hint_string; } else { - prop.type = Variant::get_type_name(E->get().type); + prop.type = Variant::get_type_name(E.type); } } @@ -367,62 +367,62 @@ void DocTools::generate(bool p_basic_types) { ClassDB::get_method_list(name, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) { + for (MethodInfo &E : method_list) { + if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } - if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { + if (skip_setter_getter_methods && setters_getters.has(E.name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. // E.g. CPUParticles3D::set_param(Parameter param, float value). - if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { + if (E.arguments.size() == 0 /* getter */ || (E.arguments.size() == 1 && E.return_val.type == Variant::NIL /* setter */)) { continue; } } DocData::MethodDoc method; - method.name = E->get().name; + method.name = E.name; - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (E.flags & METHOD_FLAG_VIRTUAL) { method.qualifiers = "virtual"; } - if (E->get().flags & METHOD_FLAG_CONST) { + if (E.flags & METHOD_FLAG_CONST) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "const"; } - if (E->get().flags & METHOD_FLAG_VARARG) { + if (E.flags & METHOD_FLAG_VARARG) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "vararg"; } - if (E->get().flags & METHOD_FLAG_STATIC) { + if (E.flags & METHOD_FLAG_STATIC) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "static"; } - for (int i = -1; i < E->get().arguments.size(); i++) { + for (int i = -1; i < E.arguments.size(); i++) { if (i == -1) { #ifdef DEBUG_METHODS_ENABLED - DocData::return_doc_from_retinfo(method, E->get().return_val); + DocData::return_doc_from_retinfo(method, E.return_val); #endif } else { - const PropertyInfo &arginfo = E->get().arguments[i]; + const PropertyInfo &arginfo = E.arguments[i]; DocData::ArgumentDoc argument; DocData::argument_doc_from_arginfo(argument, arginfo); - int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size()); + int darg_idx = i - (E.arguments.size() - E.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = E.default_arguments[darg_idx]; argument.default_value = default_arg.get_construct_string(); } @@ -455,12 +455,12 @@ void DocTools::generate(bool p_basic_types) { List<String> constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); - for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { + for (String &E : constant_list) { DocData::ConstantDoc constant; - constant.name = E->get(); - constant.value = itos(ClassDB::get_integer_constant(name, E->get())); + constant.name = E; + constant.value = itos(ClassDB::get_integer_constant(name, E)); constant.is_value_valid = true; - constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get()); + constant.enumeration = ClassDB::get_integer_constant_enum(name, E); c.constants.push_back(constant); } @@ -469,53 +469,53 @@ void DocTools::generate(bool p_basic_types) { { List<StringName> l; Theme::get_default()->get_constant_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; - pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname)); + pd.default_value = itos(Theme::get_default()->get_constant(E, cname)); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Color"; - pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string(); + pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_size_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "StyleBox"; c.theme_properties.push_back(pd); } @@ -621,8 +621,7 @@ void DocTools::generate(bool p_basic_types) { method_list.push_back(mi); } - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : method_list) { DocData::MethodDoc method; method.name = mi.name; @@ -675,8 +674,7 @@ void DocTools::generate(bool p_basic_types) { List<PropertyInfo> properties; v.get_property_list(&properties); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : properties) { DocData::PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); @@ -688,10 +686,10 @@ void DocTools::generate(bool p_basic_types) { List<StringName> constants; Variant::get_constants_for_type(Variant::Type(i), &constants); - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + for (StringName &E : constants) { DocData::ConstantDoc constant; - constant.name = E->get(); - Variant value = Variant::get_constant_value(Variant::Type(i), E->get()); + constant.name = E; + Variant value = Variant::get_constant_value(Variant::Type(i), E); constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string(); constant.is_value_valid = true; c.constants.push_back(constant); @@ -723,9 +721,8 @@ void DocTools::generate(bool p_basic_types) { Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (Engine::Singleton &s : singletons) { DocData::PropertyDoc pd; - Engine::Singleton &s = E->get(); if (!s.ptr) { continue; } @@ -743,13 +740,13 @@ void DocTools::generate(bool p_basic_types) { List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); utility_functions.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { + for (StringName &E : utility_functions) { DocData::MethodDoc md; - md.name = E->get(); + md.name = E; //return - if (Variant::has_utility_function_return_value(E->get())) { + if (Variant::has_utility_function_return_value(E)) { PropertyInfo pi; - pi.type = Variant::get_utility_function_return_type(E->get()); + pi.type = Variant::get_utility_function_return_type(E); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -758,13 +755,13 @@ void DocTools::generate(bool p_basic_types) { md.return_type = ad.type; } - if (Variant::is_utility_function_vararg(E->get())) { + if (Variant::is_utility_function_vararg(E)) { md.qualifiers = "vararg"; } else { - for (int i = 0; i < Variant::get_utility_function_argument_count(E->get()); i++) { + for (int i = 0; i < Variant::get_utility_function_argument_count(E); i++) { PropertyInfo pi; - pi.type = Variant::get_utility_function_argument_type(E->get(), i); - pi.name = Variant::get_utility_function_argument_name(E->get(), i); + pi.type = Variant::get_utility_function_argument_type(E, i); + pi.name = Variant::get_utility_function_argument_name(E, i); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -793,8 +790,7 @@ void DocTools::generate(bool p_basic_types) { List<MethodInfo> minfo; lang->get_public_functions(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : minfo) { DocData::MethodDoc md; md.name = mi.name; @@ -813,7 +809,7 @@ void DocTools::generate(bool p_basic_types) { int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = mi.default_arguments[darg_idx]; ad.default_value = default_arg.get_construct_string(); } @@ -827,10 +823,10 @@ void DocTools::generate(bool p_basic_types) { List<Pair<String, Variant>> cinfo; lang->get_public_constants(&cinfo); - for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) { + for (Pair<String, Variant> &E : cinfo) { DocData::ConstantDoc cd; - cd.name = E->get().first; - cd.value = E->get().second; + cd.name = E.first; + cd.value = E.second; cd.is_value_valid = true; c.constants.push_back(cd); } diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index d94ac21837..5a85c8b31b 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -920,15 +920,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { List<StringName> effects; ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = effects.front(); E; E = E->next()) { - if (!ClassDB::can_instantiate(E->get())) { + for (StringName &E : effects) { + if (!ClassDB::can_instantiate(E)) { continue; } - Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get()); - String name = E->get().operator String().replace("AudioEffect", ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E); + String name = E.operator String().replace("AudioEffect", ""); effect_options->add_item(name); - effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); + effect_options->set_item_metadata(effect_options->get_item_count() - 1, E); effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } @@ -1331,8 +1331,8 @@ EditorAudioBuses::EditorAudioBuses() { file_dialog = memnew(EditorFileDialog); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + "; Audio Bus Layout"); + for (String &E : ext) { + file_dialog->add_filter("*." + E + "; Audio Bus Layout"); } add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorAudioBuses::_file_dialog_callback)); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index c6d52107cd..e81f788290 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -46,12 +46,11 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - for (List<String>::Element *E = afn.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); + for (String &E : afn) { + file_dialog->add_filter("*." + E); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (AutoLoadInfo &info : autoload_cache) { if (info.node && info.in_editor) { get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } @@ -102,8 +101,8 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin for (int i = 0; i < ScriptServer::get_language_count(); i++) { List<String> keywords; ScriptServer::get_language(i)->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (E->get() == p_name) { + for (String &E : keywords) { + if (E == p_name) { if (r_error) { *r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name."); } @@ -379,8 +378,7 @@ void EditorAutoloadSettings::update_autoload() { Map<String, AutoLoadInfo> to_remove; List<AutoLoadInfo *> to_add; - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (AutoLoadInfo &info : autoload_cache) { to_remove.insert(info.name, info); } @@ -392,9 +390,7 @@ void EditorAutoloadSettings::update_autoload() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -483,9 +479,7 @@ void EditorAutoloadSettings::update_autoload() { // Load new/changed autoloads List<Node *> nodes_to_add; - for (List<AutoLoadInfo *>::Element *E = to_add.front(); E; E = E->next()) { - AutoLoadInfo *info = E->get(); - + for (AutoLoadInfo *info : to_add) { info->node = _create_autoload(info->path); ERR_CONTINUE(!info->node); @@ -518,8 +512,8 @@ void EditorAutoloadSettings::update_autoload() { } } - for (List<Node *>::Element *E = nodes_to_add.front(); E; E = E->next()) { - get_tree()->get_root()->add_child(E->get()); + for (Node *E : nodes_to_add) { + get_tree()->get_root()->add_child(E); } updating_autoload = false; @@ -649,8 +643,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - orders.write[i++] = F->get().order; + for (AutoLoadInfo &F : autoload_cache) { + orders.write[i++] = F.order; } orders.sort(); @@ -661,9 +655,9 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, orders[i++]); - undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, F->get().order); + for (AutoLoadInfo &F : autoload_cache) { + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[i++]); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order); } orders.clear(); @@ -764,9 +758,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { // Make first cache List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -799,9 +791,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_cache.push_back(info); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); - + for (AutoLoadInfo &info : autoload_cache) { info.node = _create_autoload(info.path); if (info.node) { @@ -904,8 +894,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } EditorAutoloadSettings::~EditorAutoloadSettings() { - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (AutoLoadInfo &info : autoload_cache) { if (info.node && !info.in_editor) { memdelete(info.node); } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 3529a4fbdc..9204974d1a 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -299,13 +299,13 @@ void EditorData::copy_object_params(Object *p_object) { List<PropertyInfo> pinfo; p_object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") { + for (PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) || E.name == "script" || E.name == "scripts") { continue; } PropertyData pd; - pd.name = E->get().name; + pd.name = E.name; pd.value = p_object->get(pd.name); clipboard.push_back(pd); } @@ -404,9 +404,9 @@ void EditorData::restore_editor_global_states() { void EditorData::paste_object_params(Object *p_object) { ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); - for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) { - String name = E->get().name; - undo_redo.add_do_property(p_object, name, E->get().value); + for (PropertyData &E : clipboard) { + String name = E.name; + undo_redo.add_do_property(p_object, name, E.value); undo_redo.add_undo_property(p_object, name, p_object->get(name)); } undo_redo.commit_action(); @@ -616,8 +616,8 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List<Node *> new_selection; - for (List<Node *>::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) { - NodePath p = edited_scene[p_idx].root->get_path_to(E->get()); + for (Node *E : edited_scene.write[p_idx].selection) { + NodePath p = edited_scene[p_idx].root->get_path_to(E); Node *new_node = new_scene->get_node(p); if (new_node) { new_selection.push_back(new_node); @@ -841,8 +841,8 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, p_history->history = es.history_stored; p_selection->clear(); - for (List<Node *>::Element *E = es.selection.front(); E; E = E->next()) { - p_selection->add_node(E->get()); + for (Node *E : es.selection) { + p_selection->add_node(E); } set_editor_states(es.editor_states); @@ -964,9 +964,9 @@ void EditorData::script_class_save_icon_paths() { _script_class_icon_paths.get_key_list(&keys); Dictionary d; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (ScriptServer::is_global_class(E->get())) { - d[E->get()] = _script_class_icon_paths[E->get()]; + for (StringName &E : keys) { + if (ScriptServer::is_global_class(E)) { + d[E] = _script_class_icon_paths[E]; } } @@ -996,8 +996,8 @@ void EditorData::script_class_load_icon_paths() { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String name = E->get().operator String(); + for (Variant &E : keys) { + String name = E.operator String(); _script_class_icon_paths[name] = d[name]; String path = ScriptServer::get_global_class_path(name); @@ -1038,8 +1038,8 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; Object *meta = nullptr; - for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); + for (Object *E : editor_plugins) { + meta = E->call("_get_editor_data", p_node); if (meta) { break; } @@ -1076,8 +1076,8 @@ bool EditorSelection::is_selected(Node *p_node) const { Array EditorSelection::_get_transformable_selected_nodes() { Array ret; - for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (Node *E : selected_node_list) { + ret.push_back(E); } return ret; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index fc483b46b7..2c36c1dea1 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -80,9 +80,9 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { } void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (platform->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (platform->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -436,9 +436,9 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { List<ExportOption> options; get_export_options(&options); - for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); - preset->values[E->get().option.name] = E->get().default_value; + for (ExportOption &E : options) { + preset->properties.push_back(E.option); + preset->values[E.option.name] = E.default_value; } return preset; @@ -679,9 +679,9 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai platform->get_preset_features(p_preset, &feature_list); FeatureContainers result; - for (List<String>::Element *E = feature_list.front(); E; E = E->next()) { - result.features.insert(E->get()); - result.features_pv.push_back(E->get()); + for (String &E : feature_list) { + result.features.insert(E); + result.features_pv.push_back(E); } if (p_preset->get_custom_features() != String()) { @@ -752,9 +752,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -899,8 +897,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Set<String> remap_features; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (String &F : remaps) { + String remap = F; String feature = remap.get_slice(".", 1); if (features.has(feature)) { remap_features.insert(feature); @@ -913,8 +911,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & err = OK; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (String &F : remaps) { + String remap = F; if (remap == "path") { String remapped_path = config->get_value("remap", remap); Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path); @@ -1362,7 +1360,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags if (breakpoints.size()) { r_flags.push_back("--breakpoints"); String bpoints; - for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { + for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) { bpoints += E->get().replace(" ", "%20"); if (E->next()) { bpoints += ","; @@ -1436,8 +1434,8 @@ void EditorExport::_save() { String option_section = "preset." + itos(i) + ".options"; - for (const List<PropertyInfo>::Element *E = preset->get_properties().front(); E; E = E->next()) { - config->set_value(option_section, E->get().name, preset->get(E->get().name)); + for (const PropertyInfo &E : preset->get_properties()) { + config->set_value(option_section, E.name, preset->get(E.name)); } } @@ -1642,10 +1640,10 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); - for (List<String>::Element *E = options.front(); E; E = E->next()) { - Variant value = config->get_value(option_section, E->get()); + for (String &E : options) { + Variant value = config->get_value(option_section, E); - preset->set(E->get(), value); + preset->set(E, value); } add_export_preset(preset); @@ -1684,11 +1682,11 @@ void EditorExport::update_export_presets() { preset->properties.clear(); preset->values.clear(); - for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); + for (EditorExportPlatform::ExportOption &E : options) { + preset->properties.push_back(E.option); - StringName option_name = E->get().option.name; - preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value; + StringName option_name = E.option.name; + preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; } } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index e36cc7bc2e..1bc852000d 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -527,9 +527,8 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S ClassDB::get_direct_inheriters_from_class(p_class, &child_classes); child_classes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = child_classes.front(); E; E = E->next()) { - String name = E->get(); - if (name.begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { + for (StringName &name : child_classes) { + if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { continue; } _fill_classes_from(class_item, name, p_selected); @@ -597,9 +596,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (PropertyInfo &E : props) { + String name = E.name; + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } TreeItem *property = property_list->create_item(properties); @@ -609,7 +608,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, name.capitalize()); property->set_metadata(0, name); - String icon_type = Variant::get_type_name(E->get().type); + String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index ed2edb5a5d..f11e8d350d 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -830,8 +830,8 @@ void EditorFileDialog::update_file_list() { while (!files.is_empty()) { bool match = patterns.is_empty(); - for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { + for (String &E : patterns) { + if (files.front()->get().matchn(E)) { match = true; break; } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 82a71c0e0c..72c0c0794e 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -457,8 +457,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); //imported files are gone, reimport - for (List<String>::Element *E = to_check.front(); E; E = E->next()) { - if (!FileAccess::exists(E->get())) { + for (String &E : to_check) { + if (!FileAccess::exists(E)) { return true; } } @@ -497,9 +497,7 @@ bool EditorFileSystem::_update_scan_actions() { Vector<String> reimports; Vector<String> reloads; - for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) { - ItemAction &ia = E->get(); - + for (ItemAction &ia : scan_actions) { switch (ia.action) { case ItemAction::ACTION_NONE: { } break; @@ -1027,8 +1025,8 @@ void EditorFileSystem::_delete_internal_files(String p_file) { List<String> paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); + for (String &E : paths) { + da->remove(E); } da->remove(p_file + ".import"); memdelete(da); @@ -1368,8 +1366,8 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); Vector<String> ret; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : deps) { + ret.push_back(E); } return ret; @@ -1549,15 +1547,14 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - source_file_options[p_files[i]][E->get().option.name] = E->get().default_value; + for (ResourceImporter::ImportOption &E : options) { + source_file_options[p_files[i]][E.option.name] = E.default_value; } if (config->has_section("params")) { List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - String param = E->get(); + for (String ¶m : sk) { Variant value = config->get_value("params", param); //override with whathever is in file source_file_options[p_files[i]][param] = value; @@ -1631,9 +1628,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *F = options.front(); F; F = F->next()) { - String base = F->get().option.name; - Variant v = F->get().default_value; + for (ResourceImporter::ImportOption &F : options) { + String base = F.option.name; + Variant v = F.default_value; if (source_file_options[file].has(base)) { v = source_file_options[file][base]; } @@ -1712,8 +1709,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (cf->has_section("params")) { List<String> sk; cf->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - params[E->get()] = cf->get_value("params", E->get()); + for (String &E : sk) { + params[E] = cf->get_value("params", E); } } if (p_custom_importer == String() && cf->has_section("remap")) { @@ -1754,9 +1751,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<ResourceImporter::ImportOption> opts; importer->get_import_options(&opts); - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - if (!params.has(E->get().option.name)) { //this one is not present - params[E->get().option.name] = E->get().default_value; + for (ResourceImporter::ImportOption &E : opts) { + if (!params.has(E.option.name)) { //this one is not present + params[E.option.name] = E.default_value; } } @@ -1766,8 +1763,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<Variant> v; d.get_key_list(&v); - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params[E->get()] = d[E->get()]; + for (Variant &E : v) { + params[E] = d[E]; } } @@ -1807,10 +1804,10 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //no path } else if (import_variants.size()) { //import with variants - for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); + for (String &E : import_variants) { + String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension(); - f->store_line("path." + E->get() + "=\"" + path + "\""); + f->store_line("path." + E + "=\"" + path + "\""); dest_paths.push_back(path); } } else { @@ -1833,9 +1830,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (gen_files.size()) { Array genf; - for (List<String>::Element *E = gen_files.front(); E; E = E->next()) { - genf.push_back(E->get()); - dest_paths.push_back(E->get()); + for (String &E : gen_files) { + genf.push_back(E); + dest_paths.push_back(E); } String value; @@ -1859,8 +1856,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - String base = E->get().option.name; + for (ResourceImporter::ImportOption &E : opts) { + String base = E.option.name; String value; VariantWriter::write_to_string(params[base], value); f->store_line(base + "=" + value); @@ -2080,9 +2077,8 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { + for (String ¶m : sk) { //not very clean, but should work - String param = E->get(); String value = config->get_value("params", param); if (value == p_group_file) { config->set_value("params", param, p_new_location); @@ -2131,14 +2127,14 @@ void EditorFileSystem::_update_extensions() { List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (String &E : extensionsl) { + valid_extensions.insert(E); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - import_extensions.insert(E->get()); + for (String &E : extensionsl) { + import_extensions.insert(E); } } diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 5d6c415d39..7b7cf0bf48 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -109,10 +109,10 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p List<PropertyInfo> plist; p_node->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (E->get().type == Variant::OBJECT) { - RES res = p_node->get(E->get().name); + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (E.type == Variant::OBJECT) { + RES res = p_node->get(E.name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { Vector<String> res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); @@ -228,41 +228,41 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { Set<String> unfold_group; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_CATEGORY) { + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; } - if (E->get().usage & PROPERTY_USAGE_GROUP) { - group = E->get().name; - group_base = E->get().hint_string; + if (E.usage & PROPERTY_USAGE_GROUP) { + group = E.name; + group_base = E.hint_string; if (group_base.ends_with("_")) { group_base = group_base.substr(0, group_base.length() - 1); } } //can unfold - if (E->get().usage & PROPERTY_USAGE_EDITOR) { + if (E.usage & PROPERTY_USAGE_EDITOR) { if (group != "") { //group - if (group_base == String() || E->get().name.begins_with(group_base)) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + if (group_base == String() || E.name.begins_with(group_base)) { + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { unfold_group.insert(group); } } } else { //path - int last = E->get().name.rfind("/"); + int last = E.name.rfind("/"); if (last != -1) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { - unfold_group.insert(E->get().name.substr(0, last)); + unfold_group.insert(E.name.substr(0, last)); } } } - if (E->get().type == Variant::OBJECT) { - RES res = p_object->get(E->get().name); - print_line("res: " + String(E->get().name) + " valid " + itos(res.is_valid())); + if (E.type == Variant::OBJECT) { + RES res = p_object->get(E.name); + print_line("res: " + String(E.name) + " valid " + itos(res.is_valid())); if (res.is_valid()) { print_line("path " + res->get_path()); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9fa2007597..9a0dd4e3bc 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1508,9 +1508,9 @@ String EditorInspector::get_selected_path() const { } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) { - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); - current_vbox->add_child(F->get().property_editor); + for (EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->object = object; @@ -1524,19 +1524,19 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit ep->connect("resource_selected", callable_mp(this, &EditorInspector::_resource_selected), varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = 0; } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1648,8 +1648,7 @@ void EditorInspector::update_tree() { Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(main_vbox, ped); } @@ -1746,8 +1745,7 @@ void EditorInspector::update_tree() { category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> ped : valid_plugins) { ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); } @@ -1948,36 +1946,35 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector ped->added_editors.clear(); - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); + for (EditorInspectorPlugin::AddedEditor &F : editors) { + EditorProperty *ep = Object::cast_to<EditorProperty>(F.property_editor); if (ep) { //set all this before the control gets the ENTER_TREE notification ep->object = object; - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = p.usage; //and set label? } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } else { //use existin one ep->set_label(name); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List<EditorProperty *>(); @@ -1995,7 +1992,7 @@ void EditorInspector::update_tree() { ep->set_deletable(deletable_properties); } - current_vbox->add_child(F->get().property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); @@ -2031,8 +2028,7 @@ void EditorInspector::update_tree() { } } - for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref<EditorInspectorPlugin> ped = E->get(); + for (Ref<EditorInspectorPlugin> ped : valid_plugins) { ped->parse_end(); _parse_added_editors(main_vbox, ped); } @@ -2045,10 +2041,10 @@ void EditorInspector::update_property(const String &p_prop) { return; } - for (List<EditorProperty *>::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2157,24 +2153,24 @@ bool EditorInspector::is_using_folding() { } void EditorInspector::collapse_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->fold(); + for (EditorInspectorSection *E : sections) { + E->fold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->collapse_all_folding(); + for (EditorProperty *E : F->get()) { + E->collapse_all_folding(); } } } void EditorInspector::expand_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { - E->get()->unfold(); + for (EditorInspectorSection *E : sections) { + E->unfold(); } for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - E->get()->expand_all_folding(); + for (EditorProperty *E : F->get()) { + E->expand_all_folding(); } } } @@ -2239,9 +2235,9 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { if (autoclear && editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - if (E->get()->is_checkable()) { - E->get()->set_checked(true); + for (EditorProperty *E : editor_property_map[p_name]) { + if (E->is_checkable()) { + E->set_checked(true); } } } @@ -2308,8 +2304,8 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } if (editor_property_map.has(p_name)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - E->get()->update_reload_status(); + for (EditorProperty *E : editor_property_map[p_name]) { + E->update_reload_status(); } } } @@ -2395,10 +2391,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { Variant to_create; List<PropertyInfo> pinfo; object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == p_path) { + for (PropertyInfo &E : pinfo) { + if (E.name == p_path) { Callable::CallError ce; - Variant::construct(E->get().type, to_create, nullptr, 0, ce); + Variant::construct(E.type, to_create, nullptr, 0, ce); break; } } @@ -2406,10 +2402,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } if (editor_property_map.has(p_path)) { - for (List<EditorProperty *>::Element *E = editor_property_map[p_path].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_path]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2426,9 +2422,9 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) if (F->key() == property_selected) { continue; } - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (E->get()->is_selected()) { - E->get()->deselect(); + for (EditorProperty *E : F->get()) { + if (E->is_selected()) { + E->deselect(); } } } @@ -2485,11 +2481,11 @@ void EditorInspector::_notification(int p_what) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { - if (!E->get()->is_cache_valid()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : F->get()) { + if (!E->is_cache_valid()) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } @@ -2508,10 +2504,10 @@ void EditorInspector::_notification(int p_what) { while (pending.size()) { StringName prop = pending.front()->get(); if (editor_property_map.has(prop)) { - for (List<EditorProperty *>::Element *E = editor_property_map[prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } pending.erase(pending.front()); @@ -2599,8 +2595,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li } Set<StringName> added; - for (List<Ref<Script>>::Element *E = classes.front(); E; E = E->next()) { - Ref<Script> s = E->get(); + for (Ref<Script> s : classes) { String path = s->get_path(); String name = EditorNode::get_editor_data().script_class_get_name(path); if (name.is_empty()) { diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 16538a2376..1f70c59e66 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -92,8 +92,8 @@ void EditorLayoutsDialog::_post_popup() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - layout_names->add_item(**E); + for (String &E : layouts) { + layout_names->add_item(E); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6bdf428f81..ce5f762b13 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -797,8 +797,8 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } if (changed.size()) { - for (List<Ref<Resource>>::Element *E = changed.front(); E; E = E->next()) { - E->get()->reload_from_file(); + for (Ref<Resource> E : changed) { + E->reload_from_file(); } } } @@ -914,8 +914,8 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) { } } - for (List<String>::Element *E = scenes.front(); E; E = E->next()) { - reload_scene(E->get()); + for (String &E : scenes) { + reload_scene(E); } scene_tabs->set_current_tab(current_tab); @@ -1143,13 +1143,13 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->clear_filters(); List<String> preferred; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (p_resource->is_class("Script") && (E->get() == "tres" || E->get() == "res")) { + for (String &E : extensions) { + if (p_resource->is_class("Script") && (E == "tres" || E == "res")) { //this serves no purpose and confused people continue; } - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - preferred.push_back(E->get()); + file->add_filter("*." + E + " ; " + E.to_upper()); + preferred.push_back(E); } // Lowest priority extension List<String>::Element *res_element = preferred.find("res"); @@ -1259,10 +1259,10 @@ void EditorNode::_get_scene_metadata(const String &p_file) { cf->get_section_keys("editor_states", &esl); Dictionary md; - for (List<String>::Element *E = esl.front(); E; E = E->next()) { - Variant st = cf->get_value("editor_states", E->get()); + for (String &E : esl) { + Variant st = cf->get_value("editor_states", E); if (st.get_type() != Variant::NIL) { - md[E->get()] = st; + md[E] = st; } } @@ -1295,8 +1295,8 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { List<Variant> keys; md.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - cf->set_value("editor_states", E->get(), md[E->get()]); + for (Variant &E : keys) { + cf->set_value("editor_states", E, md[E]); } Error err = cf->save(path); @@ -1334,14 +1334,14 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> bool ret_changed = false; List<PropertyInfo> pi; obj->get_property_list(&pi); - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - switch (E->get().type) { + switch (E.type) { case Variant::OBJECT: { - RES res = obj->get(E->get().name); + RES res = obj->get(E.name); if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1349,7 +1349,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::ARRAY: { - Array varray = obj->get(E->get().name); + Array varray = obj->get(E.name); int len = varray.size(); for (int i = 0; i < len; i++) { const Variant &v = varray.get(i); @@ -1361,11 +1361,11 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::DICTIONARY: { - Dictionary d = obj->get(E->get().name); + Dictionary d = obj->get(E.name); List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *F = keys.front(); F; F = F->next()) { - Variant v = d[F->get()]; + for (Variant &F : keys) { + Variant v = d[F]; RES res = v; if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1520,9 +1520,9 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso p_resource->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_STORAGE && !(E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { - RES res = p_resource->get(E->get().name); + for (PropertyInfo &E : plist) { + if (E.type == Variant::OBJECT && E.usage & PROPERTY_USAGE_STORAGE && !(E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { + RES res = p_resource->get(E.name); if (res.is_null()) { continue; } @@ -1551,8 +1551,7 @@ int EditorNode::_save_external_resources() { int saved = 0; List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> res = E->get(); + for (Ref<Resource> res : cached) { if (!res->get_path().is_resource_file()) { continue; } @@ -1642,8 +1641,8 @@ void EditorNode::_save_scene(String p_file, int idx) { editor_data.save_editor_external_data(); - for (List<Ref<AnimatedValuesBackup>>::Element *E = anim_backups.front(); E; E = E->next()) { - E->get()->restore(); + for (Ref<AnimatedValuesBackup> E : anim_backups) { + E->restore(); } if (err == OK) { @@ -1884,8 +1883,8 @@ void EditorNode::_dialog_action(String p_file) { // erase List<String> keys; config->get_section_keys(p_file, &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - config->set_value(p_file, E->get(), Variant()); + for (String &E : keys) { + config->set_value(p_file, E, Variant()); } config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); @@ -2533,8 +2532,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Ref<MeshLibrary> ml(memnew(MeshLibrary)); ResourceSaver::get_recognized_extensions(ml, &extensions); file_export_lib->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_export_lib->add_filter("*." + E->get()); + for (String &E : extensions) { + file_export_lib->add_filter("*." + E); } file_export_lib->popup_file_dialog(); @@ -4055,11 +4054,11 @@ void EditorNode::_build_icon_type_cache() { List<StringName> tl; StringName ei = "EditorIcons"; theme_base->get_theme()->get_icon_list(ei, &tl); - for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - if (!ClassDB::class_exists(E->get())) { + for (StringName &E : tl) { + if (!ClassDB::class_exists(E)) { continue; } - icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei); + icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei); } } @@ -4784,9 +4783,7 @@ void EditorNode::_update_layouts_menu() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - String layout = E->get(); - + for (String &layout : layouts) { if (layout == TTR("Default")) { editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT)); overridden_default_layout = editor_layouts->get_item_count(); @@ -5343,9 +5340,9 @@ void EditorNode::reload_scene(const String &p_path) { List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene - to_clear.push_back(E->get()); + for (Ref<Resource> E : cached) { + if (E->get_path().begins_with(p_path + "::")) { //subresources of existing scene + to_clear.push_back(E); } } @@ -6741,8 +6738,8 @@ EditorNode::EditorNode() { file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); - for (List<String>::Element *E = sexts.front(); E; E = E->next()) { - file_script->add_filter("*." + E->get()); + for (String &E : sexts) { + file_script->add_filter("*." + E); } gui_base->add_child(file_script); file_script->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index a31b9fd0c7..c52861a2a2 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -40,15 +40,15 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -60,7 +60,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); String proper_name = ""; - Vector<String> name_parts = E->get().name.split("/"); + Vector<String> name_parts = E.name.split("/"); for (int i = 0; i < name_parts.size(); i++) { if (i > 0) { diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 8bb6c590dc..967f2aa47b 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -221,8 +221,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (String &E : extensions) { + valid_extensions.insert(E); } if (!file_dialog) { @@ -260,9 +260,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { List<PropertyInfo> property_list; edited_resource->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = edited_resource->get(pi.name); @@ -276,8 +275,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { Ref<Resource> unique_resource = Ref<Resource>(Object::cast_to<Resource>(inst)); ERR_FAIL_COND(unique_resource.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (Pair<String, Variant> &p : propvalues) { unique_resource->set(p.first, p.second); } @@ -467,13 +465,13 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> * List<StringName> inheriters; ClassDB::get_inheriters_from_class(base, &inheriters); - for (List<StringName>::Element *E = inheriters.front(); E; E = E->next()) { - p_vector->insert(E->get()); + for (StringName &E : inheriters) { + p_vector->insert(E); } - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - if (EditorNode::get_editor_data().script_class_is_parent(E->get(), base)) { - p_vector->insert(E->get()); + for (StringName &E : global_classes) { + if (EditorNode::get_editor_data().script_class_is_parent(E, base)) { + p_vector->insert(E); } } diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 5e6d2ab69c..b446f922f6 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -228,8 +228,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } printf("Running: %s", exec.utf8().get_data()); - for (List<String>::Element *E = args.front(); E; E = E->next()) { - printf(" %s", E->get().utf8().get_data()); + for (String &E : args) { + printf(" %s", E.utf8().get_data()); }; printf("\n"); @@ -250,8 +250,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } bool EditorRun::has_child_process(OS::ProcessID p_pid) const { - for (const List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - if (E->get() == p_pid) { + for (const OS::ProcessID &E : pids) { + if (E == p_pid) { return true; } } @@ -267,8 +267,8 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) { void EditorRun::stop() { if (status != STATUS_STOP && pids.size() > 0) { - for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - OS::get_singleton()->kill(E->get()); + for (OS::ProcessID &E : pids) { + OS::get_singleton()->kill(E); } } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 1209df50ed..751cc7a574 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -76,8 +76,7 @@ class SectionedInspectorFilter : public Object { List<PropertyInfo> pinfo; edited->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { int sp = pi.name.find("/"); if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) { //skip resource stuff @@ -221,9 +220,7 @@ void SectionedInspector::update_category_list() { filter = search_box->get_text(); } - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (pi.usage & PROPERTY_USAGE_CATEGORY) { continue; } else if (!(pi.usage & PROPERTY_USAGE_EDITOR) || (restrict_to_basic && !(pi.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 0667d7116f..a14ab1d4f8 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -759,8 +759,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { List<String> keys; p_extra_config->get_section_keys("presets", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (String &key : keys) { Variant val = p_extra_config->get_value("presets", key); set(key, val); } @@ -815,8 +814,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { props.get_key_list(&keys); keys.sort(); - for (const List<String>::Element *E = keys.front(); E; E = E->next()) { - const String &key = E->get(); + for (const String &key : keys) { if (key.begins_with("text_editor/highlighting/") && key.find("color") >= 0) { cf->set_value(theme_section, key.replace("text_editor/highlighting/", ""), ((Color)props[key].variant).to_html()); } @@ -1015,15 +1013,13 @@ void EditorSettings::setup_network() { String selected = "127.0.0.1"; // Check that current remote_host is a valid interface address and populate hints. - for (List<IPAddress>::Element *E = local_ip.front(); E; E = E->next()) { - String ip = E->get(); - + for (IPAddress &ip : local_ip) { // link-local IPv6 addresses don't work, skipping them - if (ip.begins_with("fe80:0:0:0:")) { // fe80::/64 + if (String(ip).begins_with("fe80:0:0:0:")) { // fe80::/64 continue; } // Same goes for IPv4 link-local (APIPA) addresses. - if (ip.begins_with("169.254.")) { // 169.254.0.0/16 + if (String(ip).begins_with("169.254.")) { // 169.254.0.0/16 continue; } // Select current IP (found) @@ -1303,8 +1299,8 @@ void EditorSettings::list_text_editor_themes() { memdelete(d); custom_themes.sort(); - for (List<String>::Element *E = custom_themes.front(); E; E = E->next()) { - themes += "," + E->get(); + for (String &E : custom_themes) { + themes += "," + E; } } add_property_hint(PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, themes)); @@ -1332,8 +1328,7 @@ void EditorSettings::load_text_editor_theme() { List<String> keys; cf->get_section_keys("color_theme", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (String &key : keys) { String val = cf->get_value("color_theme", key); // don't load if it's not already there! @@ -1585,8 +1580,8 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr int event_idx = 0; // Check equality of each event. - for (List<Ref<InputEvent>>::Element *E = builtin_events.front(); E; E = E->next()) { - if (!E->get()->is_match(p_events[event_idx])) { + for (Ref<InputEvent> E : builtin_events) { + if (!E->is_match(p_events[event_idx])) { same_as_builtin = false; break; } @@ -1615,8 +1610,8 @@ const Array EditorSettings::get_builtin_action_overrides(const String &p_name) c Array event_array; List<Ref<InputEvent>> events_list = AO->get(); - for (List<Ref<InputEvent>>::Element *E = events_list.front(); E; E = E->next()) { - event_array.push_back(E->get()); + for (Ref<InputEvent> E : events_list) { + event_array.push_back(E); } return event_array; } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 49c2a84e18..225eac36a5 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -135,9 +135,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory _sort_file_info_list(file_list); // Build the tree. - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo fi = E->get(); - + for (FileInfo &fi : file_list) { TreeItem *file_item = tree->create_item(subdirectory_item); file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); @@ -869,8 +867,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Fills the ItemList control node from the FileInfos. String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene"); String oi = "Object"; - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo *finfo = &(E->get()); + for (FileInfo &E : file_list) { + FileInfo *finfo = &(E); String fname = finfo->name; String fpath = finfo->path; String ftype = finfo->type; @@ -966,8 +964,8 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit List<String> importer_exts; ResourceImporterScene::get_singleton()->get_recognized_extensions(&importer_exts); String extension = fpath.get_extension(); - for (List<String>::Element *E = importer_exts.front(); E; E = E->next()) { - if (extension.nocasecmp_to(E->get()) == 0) { + for (String &E : importer_exts) { + if (extension.nocasecmp_to(E) == 0) { is_imported = true; break; } @@ -1239,9 +1237,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> r = E->get(); - + for (Ref<Resource> r : cached) { String base_path = r->get_path(); String extra_path; int sep_pos = r->get_path().find("::"); @@ -1317,16 +1313,16 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin // Also search for the file in autoload, as they are stored differently from normal files. List<PropertyInfo> property_list; ProjectSettings::get_singleton()->get_property_list(&property_list); - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().name.begins_with("autoload/")) { + for (const PropertyInfo &E : property_list) { + if (E.name.begins_with("autoload/")) { // If the autoload resource paths has a leading "*", it indicates that it is a Singleton, // so we have to handle both cases when updating. - String autoload = GLOBAL_GET(E->get().name); + String autoload = GLOBAL_GET(E.name); String autoload_singleton = autoload.substr(1, autoload.length()); if (p_renames.has(autoload)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]); + ProjectSettings::get_singleton()->set_setting(E.name, p_renames[autoload]); } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]); + ProjectSettings::get_singleton()->set_setting(E.name, "*" + p_renames[autoload_singleton]); } } } @@ -1417,8 +1413,8 @@ void FileSystemDock::_make_scene_confirm() { ResourceSaver::get_recognized_extensions(sd, &extensions); bool extension_correct = false; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get() == extension) { + for (String &E : extensions) { + if (E == extension) { extension_correct = true; break; } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 0a39768b9a..deedbe104c 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -240,8 +240,7 @@ void GroupDialog::_group_renamed() { List<Node *> nodes; scene_tree->get_nodes_in_group(selected_group, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : nodes) { if (_can_edit(node, selected_group)) { undo_redo->add_do_method(node, "remove_from_group", selected_group); undo_redo->add_undo_method(node, "remove_from_group", name); @@ -286,11 +285,11 @@ void GroupDialog::_load_groups(Node *p_current) { List<Node::GroupInfo> gi; p_current->get_groups(&gi); - for (List<Node::GroupInfo>::Element *E = gi.front(); E; E = E->next()) { - if (!E->get().persistent) { + for (Node::GroupInfo &E : gi) { + if (!E.persistent) { continue; } - _add_group(E->get().name); + _add_group(E.name); } for (int i = 0; i < p_current->get_child_count(); i++) { @@ -311,10 +310,10 @@ void GroupDialog::_delete_group_pressed(Object *p_item, int p_column, int p_id) List<Node *> nodes; scene_tree->get_nodes_in_group(name, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - if (_can_edit(E->get(), name)) { - undo_redo->add_do_method(E->get(), "remove_from_group", name); - undo_redo->add_undo_method(E->get(), "add_to_group", name, true); + for (Node *E : nodes) { + if (_can_edit(E, name)) { + undo_redo->add_do_method(E, "remove_from_group", name); + undo_redo->add_undo_method(E, "add_to_group", name, true); } else { removed_all = false; } @@ -628,8 +627,7 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo gi = E->get(); + for (GroupInfo &gi : groups) { if (!gi.persistent) { continue; } diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index ddf89f077b..b615c73422 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -894,8 +894,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor surftool->add_vertex(vertex_array[k].vertex); } - for (List<int>::Element *E = indices_list.front(); E; E = E->next()) { - surftool->add_index(E->get()); + for (int &E : indices_list) { + surftool->add_index(E); } if (!normal_src) { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 01603c0a6a..8b6bd8066f 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -438,17 +438,16 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in Node3D *scene = memnew(Node3D); - for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { + for (Ref<Mesh> m : meshes) { Ref<EditorSceneImporterMesh> mesh; mesh.instantiate(); - Ref<Mesh> m = E->get(); for (int i = 0; i < m->get_surface_count(); i++) { mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i)); } EditorSceneImporterMeshNode3D *mi = memnew(EditorSceneImporterMeshNode3D); mi->set_mesh(mesh); - mi->set_name(E->get()->get_name()); + mi->set_name(m->get_name()); scene->add_child(mi); mi->set_owner(scene); } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index c14b948dae..e1aa858b90 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -312,8 +312,8 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + for (StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); ERR_CONTINUE(anim.is_null()); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); @@ -328,14 +328,14 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E } } - String animname = E->get(); + String animname = E; const int loop_string_count = 3; static const char *loop_strings[loop_string_count] = { "loops", "loop", "cycle" }; for (int i = 0; i < loop_string_count; i++) { if (_teststr(animname, loop_strings[i])) { anim->set_loop(true); animname = _fixstr(animname, loop_strings[i]); - ap->rename_animation(E->get(), animname); + ap->rename_animation(E, animname); } } } @@ -659,9 +659,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } int idx = 0; - for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { + for (Ref<Shape3D> &E : shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); base->add_child(cshape); cshape->set_owner(base->get_owner()); @@ -712,9 +712,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill node settings for this node with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts); - for (List<ImportOption>::Element *E = iopts.front(); E; E = E->next()) { - if (!node_settings.has(E->get().option.name)) { - node_settings[E->get().option.name] = E->get().default_value; + for (ImportOption &E : iopts) { + if (!node_settings.has(E.option.name)) { + node_settings[E.option.name] = E.default_value; } } } @@ -756,8 +756,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } else { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String name = E->get(); + for (StringName &name : anims) { Ref<Animation> anim = ap->get_animation(name); if (p_animation_data.has(name)) { Dictionary anim_settings = p_animation_data[name]; @@ -765,9 +764,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION, &iopts); - for (List<ImportOption>::Element *F = iopts.front(); F; F = F->next()) { - if (!anim_settings.has(F->get().option.name)) { - anim_settings[F->get().option.name] = F->get().default_value; + for (ImportOption &F : iopts) { + if (!anim_settings.has(F.option.name)) { + anim_settings[F.option.name] = F.default_value; } } } @@ -936,8 +935,8 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_ void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle) { List<StringName> anim_names; anim->get_animation_list(&anim_names); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - Ref<Animation> a = anim->get_animation(E->get()); + for (StringName &E : anim_names) { + Ref<Animation> a = anim->get_animation(E); a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle)); } } @@ -1046,11 +1045,11 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in String script_ext_hint; - for (List<String>::Element *E = script_extentions.front(); E; E = E->next()) { + for (String &E : script_extentions) { if (script_ext_hint != "") { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); @@ -1089,9 +1088,9 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1119,9 +1118,9 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1291,9 +1290,9 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } void ResourceImporterScene::_add_shapes(Node *p_node, const List<Ref<Shape3D>> &p_shapes) { - for (const List<Ref<Shape3D>>::Element *E = p_shapes.front(); E; E = E->next()) { + for (const Ref<Shape3D> &E : p_shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); p_node->add_child(cshape); cshape->set_owner(p_node->get_owner()); @@ -1311,9 +1310,9 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1351,9 +1350,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 5dc494d6df..ad271eaf04 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -71,9 +71,9 @@ class SceneImportSettingsData : public Object { return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E->get().option.name, current)) { - p_list->push_back(E->get().option); + for (const ResourceImporter::ImportOption &E : options) { + if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E.option.name, current)) { + p_list->push_back(E.option); } } } @@ -305,8 +305,8 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { if (anim_node) { List<StringName> animations; anim_node->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - _fill_animation(scene_tree, anim_node->get_animation(E->get()), E->get(), item); + for (StringName &E : animations) { + _fill_animation(scene_tree, anim_node->get_animation(E), E, item); } } @@ -394,8 +394,8 @@ void SceneImportSettings::_load_default_subresource_settings(Map<StringName, Var d = d[p_import_id]; List<ResourceImporterScene::ImportOption> options; ResourceImporterScene::get_singleton()->get_internal_import_options(p_category, &options); - for (List<ResourceImporterScene::ImportOption>::Element *E = options.front(); E; E = E->next()) { - String key = E->get().option.name; + for (ResourceImporterScene::ImportOption &E : options) { + String key = E.option.name; if (d.has(key)) { settings[key] = d[key]; } @@ -440,12 +440,12 @@ void SceneImportSettings::open_settings(const String &p_path) { if (err == OK) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - Variant value = config->get_value("params", E->get()); - if (E->get() == "_subresources") { + for (String &E : keys) { + Variant value = config->get_value("params", E); + if (E == "_subresources") { base_subresource_settings = value; } else { - defaults[E->get()] = value; + defaults[E] = value; } } } @@ -605,13 +605,13 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) { scene_import_settings_data->defaults.clear(); scene_import_settings_data->current.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - scene_import_settings_data->defaults[E->get().option.name] = E->get().default_value; + for (ResourceImporter::ImportOption &E : options) { + scene_import_settings_data->defaults[E.option.name] = E.default_value; //needed for visibility toggling (fails if something is missing) - if (scene_import_settings_data->settings->has(E->get().option.name)) { - scene_import_settings_data->current[E->get().option.name] = (*scene_import_settings_data->settings)[E->get().option.name]; + if (scene_import_settings_data->settings->has(E.option.name)) { + scene_import_settings_data->current[E.option.name] = (*scene_import_settings_data->settings)[E.option.name]; } else { - scene_import_settings_data->current[E->get().option.name] = E->get().default_value; + scene_import_settings_data->current[E.option.name] = E.default_value; } } scene_import_settings_data->options = options; diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index f8e93df382..5b8f7015fe 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -79,11 +79,11 @@ void EditorSceneImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const List<Variant> lods; p_lods.get_key_list(&lods); - for (List<Variant>::Element *E = lods.front(); E; E = E->next()) { - ERR_CONTINUE(!E->get().is_num()); + for (Variant &E : lods) { + ERR_CONTINUE(!E.is_num()); Surface::LOD lod; - lod.distance = E->get(); - lod.indices = p_lods[E->get()]; + lod.distance = E; + lod.indices = p_lods[E]; ERR_CONTINUE(lod.indices.size() == 0); s.lods.push_back(lod); } diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 8c506e938d..0b12f86882 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -61,9 +61,9 @@ protected: if (importer.is_null()) { return; } - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (importer->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (importer->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -106,9 +106,9 @@ void ImportDefaultsEditor::_update_importer() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Ref<ResourceImporter> importer; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - if (E->get()->get_visible_name() == importers->get_item_text(importers->get_selected())) { - importer = E->get(); + for (Ref<ResourceImporter> E : importer_list) { + if (E->get_visible_name() == importers->get_item_text(importers->get_selected())) { + importer = E; break; } } @@ -125,14 +125,14 @@ void ImportDefaultsEditor::_update_importer() { d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name()); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - settings->properties.push_back(E->get().option); - if (d.has(E->get().option.name)) { - settings->values[E->get().option.name] = d[E->get().option.name]; + for (ResourceImporter::ImportOption &E : options) { + settings->properties.push_back(E.option); + if (d.has(E.option.name)) { + settings->values[E.option.name] = d[E.option.name]; } else { - settings->values[E->get().option.name] = E->get().default_value; + settings->values[E.option.name] = E.default_value; } - settings->default_values[E->get().option.name] = E->get().default_value; + settings->default_values[E.option.name] = E.default_value; } save_defaults->set_disabled(false); @@ -166,8 +166,8 @@ void ImportDefaultsEditor::clear() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Vector<String> names; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - String vn = E->get()->get_visible_name(); + for (Ref<ResourceImporter> E : importer_list) { + String vn = E->get_visible_name(); names.push_back(vn); } names.sort(); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 4110912ff3..3927832eb9 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -65,14 +65,14 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!importer->get_option_visibility(E->get().name, values)) { + for (const PropertyInfo &E : properties) { + if (!importer->get_option_visibility(E.name, values)) { continue; } - PropertyInfo pi = E->get(); + PropertyInfo pi = E; if (checking) { pi.usage |= PROPERTY_USAGE_CHECKABLE; - if (checked.has(E->get().name)) { + if (checked.has(E.name)) { pi.usage |= PROPERTY_USAGE_CHECKED; } } @@ -111,18 +111,18 @@ void ImportDock::set_edit_path(const String &p_path) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (Ref<ResourceImporter> E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == importer_name) { + for (Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == importer_name) { import_as->select(import_as->get_item_count() - 1); } } @@ -153,12 +153,12 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { params->checking = params->paths.size() > 1; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); - if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) { - params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name); + for (ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); + if (p_config.is_valid() && p_config->has_section_key("params", E.option.name)) { + params->values[E.option.name] = p_config->get_value("params", E.option.name); } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -201,17 +201,17 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - if (!value_frequency.has(E->get())) { - value_frequency[E->get()] = Dictionary(); + for (String &E : keys) { + if (!value_frequency.has(E)) { + value_frequency[E] = Dictionary(); } - Variant value = config->get_value("params", E->get()); + Variant value = config->get_value("params", E); - if (value_frequency[E->get()].has(value)) { - value_frequency[E->get()][value] = int(value_frequency[E->get()][value]) + 1; + if (value_frequency[E].has(value)) { + value_frequency[E][value] = int(value_frequency[E][value]) + 1; } else { - value_frequency[E->get()][value] = 1; + value_frequency[E][value] = 1; } } } @@ -226,25 +226,25 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { params->checking = true; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); + for (ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); - if (value_frequency.has(E->get().option.name)) { - Dictionary d = value_frequency[E->get().option.name]; + if (value_frequency.has(E.option.name)) { + Dictionary d = value_frequency[E.option.name]; int freq = 0; List<Variant> v; d.get_key_list(&v); Variant value; - for (List<Variant>::Element *F = v.front(); F; F = F->next()) { - int f = d[F->get()]; + for (Variant &F : v) { + int f = d[F]; if (f > freq) { - value = F->get(); + value = F; } } - params->values[E->get().option.name] = value; + params->values[E.option.name] = value; } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -254,18 +254,18 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (Ref<ResourceImporter> E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == params->importer->get_importer_name()) { + for (Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == params->importer->get_importer_name()) { import_as->select(import_as->get_item_count() - 1); } } @@ -345,8 +345,8 @@ void ImportDock::_preset_selected(int p_idx) { case ITEM_SET_AS_DEFAULT: { Dictionary d; - for (const List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - d[E->get().name] = params->values[E->get().name]; + for (const PropertyInfo &E : params->properties) { + d[E.name] = params->values[E.name]; } ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d); @@ -363,10 +363,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params->values[E->get()] = d[E->get()]; + for (Variant &E : v) { + params->values[E] = d[E]; if (params->checking) { - params->checked.insert(E->get()); + params->checked.insert(E); } } params->update(); @@ -384,10 +384,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->values[E->get().option.name] = E->get().default_value; + for (ResourceImporter::ImportOption &E : options) { + params->values[E.option.name] = E.default_value; if (params->checking) { - params->checked.insert(E->get().option.name); + params->checked.insert(E.option.name); } } params->update(); @@ -486,9 +486,9 @@ void ImportDock::_reimport() { if (params->checking && config->get_value("remap", "importer") == params->importer->get_importer_name()) { //update only what is edited (checkboxes) if the importer is the same - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - if (params->checked.has(E->get().name)) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (PropertyInfo &E : params->properties) { + if (params->checked.has(E.name)) { + config->set_value("params", E.name, params->values[E.name]); } } } else { @@ -498,8 +498,8 @@ void ImportDock::_reimport() { config->erase_section("params"); } - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (PropertyInfo &E : params->properties) { + config->set_value("params", E.name, params->values[E.name]); } } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index ab307500e7..b1c601a41c 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -87,12 +87,12 @@ void InspectorDock::_menu_option(int p_option) { List<PropertyInfo> props; current->get_property_list(&props); Map<RES, RES> duplicates; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = current->get(E->get().name); + Variant v = current->get(E.name); if (v.is_ref()) { REF ref = v; if (ref.is_valid()) { @@ -103,8 +103,8 @@ void InspectorDock::_menu_option(int p_option) { } res = duplicates[res]; - current->set(E->get().name, res); - editor->get_inspector()->update_property(E->get().name); + current->set(E.name, res); + editor->get_inspector()->update_property(E.name); } } } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index f51decd9dc..d4b712b6a3 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -43,15 +43,15 @@ void LocalizationEditor::_notification(int p_what) { List<String> tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); - for (List<String>::Element *E = tfn.front(); E; E = E->next()) { - translation_file_open->add_filter("*." + E->get()); + for (String &E : tfn) { + translation_file_open->add_filter("*." + E); } List<String> rfn; ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); - for (List<String>::Element *E = rfn.front(); E; E = E->next()) { - translation_res_file_open_dialog->add_filter("*." + E->get()); - translation_res_option_file_open_dialog->add_filter("*." + E->get()); + for (String &E : rfn) { + translation_res_file_open_dialog->add_filter("*." + E); + translation_res_option_file_open_dialog->add_filter("*." + E); } _update_pot_file_extensions(); @@ -430,8 +430,8 @@ void LocalizationEditor::_update_pot_file_extensions() { pot_file_open_dialog->clear_filters(); List<String> translation_parse_file_extensions; EditorTranslationParser::get_singleton()->get_recognized_extensions(&translation_parse_file_extensions); - for (List<String>::Element *E = translation_parse_file_extensions.front(); E; E = E->next()) { - pot_file_open_dialog->add_filter("*." + E->get()); + for (String &E : translation_parse_file_extensions) { + pot_file_open_dialog->add_filter("*." + E); } } @@ -560,8 +560,8 @@ void LocalizationEditor::update_translations() { List<Variant> rk; remaps.get_key_list(&rk); Vector<String> keys; - for (List<Variant>::Element *E = rk.front(); E; E = E->next()) { - keys.push_back(E->get()); + for (Variant &E : rk) { + keys.push_back(E); } keys.sort(); diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index b714109af7..910b242c41 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -52,12 +52,12 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS); - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -98,12 +98,12 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { name = "script"; } - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - const Node *n = es->get_node(E->get()); + const Node *n = es->get_node(E); if (!n) { continue; } @@ -130,12 +130,12 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PLData *> data_list; - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -143,30 +143,30 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> plist; n->get_property_list(&plist, true); - for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) { - if (F->get().name == "script") { + for (PropertyInfo &F : plist) { + if (F.name == "script") { continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) } - if (!usage.has(F->get().name)) { + if (!usage.has(F.name)) { PLData pld; pld.uses = 0; - pld.info = F->get(); - usage[F->get().name] = pld; - data_list.push_back(usage.getptr(F->get().name)); + pld.info = F; + usage[F.name] = pld; + data_list.push_back(usage.getptr(F.name)); } // Make sure only properties with the same exact PropertyInfo data will appear - if (usage[F->get().name].info == F->get()) { - usage[F->get().name].uses++; + if (usage[F.name].info == F) { + usage[F.name].uses++; } } nc++; } - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (nc == E->get()->uses) { - p_list->push_back(E->get()->info); + for (PLData *E : data_list) { + if (nc == E->uses) { + p_list->push_back(E->info); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 9e58332e41..ab11680e2f 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,22 +72,22 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E->get()); - animations_to_add.push_back(E->get()); + for (StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -373,8 +373,8 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index bbf88bbd8f..3fb90eb4ff 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -96,21 +96,21 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E->get()); - animations_to_add.push_back(E->get()); + for (StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -295,8 +295,8 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 7930bc1e1c..705a1d0fc0 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -121,21 +121,21 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> nodes; blend_tree->get_node_list(&nodes); - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { + for (StringName &E : nodes) { GraphNode *node = memnew(GraphNode); graph->add_child(node); - Ref<AnimationNode> agnode = blend_tree->get_node(E->get()); + Ref<AnimationNode> agnode = blend_tree->get_node(E); - node->set_position_offset(blend_tree->get_node_position(E->get()) * EDSCALE); + node->set_position_offset(blend_tree->get_node_position(E) * EDSCALE); node->set_title(agnode->get_caption()); - node->set_name(E->get()); + node->set_name(E); int base = 0; - if (String(E->get()) != "output") { + if (String(E) != "output") { LineEdit *name = memnew(LineEdit); - name->set_text(E->get()); + name->set_text(E); name->set_expand_to_text_length_enabled(true); node->add_child(name); node->set_slot(0, false, 0, Color(), true, 0, get_theme_color(SNAME("font_color"), SNAME("Label"))); @@ -143,7 +143,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out), varray(name, agnode), CONNECT_DEFERRED); base = 1; node->set_show_close_button(true); - node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E->get()), CONNECT_DEFERRED); + node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E), CONNECT_DEFERRED); } for (int i = 0; i < agnode->get_input_count(); i++) { @@ -155,12 +155,12 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<PropertyInfo> pinfo; agnode->get_parameter_list(&pinfo); - for (List<PropertyInfo>::Element *F = pinfo.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR)) { + for (PropertyInfo &F : pinfo) { + if (!(F.usage & PROPERTY_USAGE_EDITOR)) { continue; } - String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->get()) + "/" + F->get().name; - EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F->get().type, base_path, F->get().hint, F->get().hint_string, F->get().usage); + String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name; + EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F.type, base_path, F.hint, F.hint_string, F.usage); if (prop) { prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_tree(), base_path); prop->update_property(); @@ -171,7 +171,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } } - node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E->get())); + node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E)); if (AnimationTreeEditor::get_singleton()->can_edit(agnode)) { node->add_child(memnew(HSeparator)); @@ -179,7 +179,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { open_in_editor->set_text(TTR("Open Editor")); open_in_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); node->add_child(open_in_editor); - open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E->get()), CONNECT_DEFERRED); + open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E), CONNECT_DEFERRED); open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -189,7 +189,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { edit_filters->set_text(TTR("Edit Filters")); edit_filters->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); node->add_child(edit_filters); - edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED); + edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E), CONNECT_DEFERRED); edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -212,9 +212,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *F = anims.front(); F; F = F->next()) { - mb->get_popup()->add_item(F->get()); - options.push_back(F->get()); + for (StringName &F : anims) { + mb->get_popup()->add_item(F); + options.push_back(F); } if (ap->has_animation(anim->get_animation())) { @@ -225,10 +225,10 @@ void AnimationNodeBlendTreeEditor::_update_graph() { pb->set_percent_visible(false); pb->set_custom_minimum_size(Vector2(0, 14) * EDSCALE); - animations[E->get()] = pb; + animations[E] = pb; node->add_child(pb); - mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E->get()), CONNECT_DEFERRED); + mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E), CONNECT_DEFERRED); } Ref<StyleBoxFlat> sb = node->get_theme_stylebox(SNAME("frame"), SNAME("GraphNode")); @@ -246,10 +246,10 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } @@ -274,8 +274,8 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -394,9 +394,9 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().output_node == p_which || E->get().input_node == p_which) { - undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E->get().input_node, E->get().input_index, E->get().output_node); + for (AnimationNodeBlendTree::NodeConnection &E : conns) { + if (E.output_node == p_which || E.input_node == p_which) { + undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E.input_node, E.input_index, E.output_node); } } @@ -423,8 +423,8 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { undo_redo->create_action(TTR("Delete Node(s)")); - for (List<StringName>::Element *F = to_erase.front(); F; F = F->next()) { - _delete_request(F->get()); + for (StringName &F : to_erase) { + _delete_request(F); } undo_redo->commit_action(); @@ -517,8 +517,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); paths.insert(track_path); @@ -718,13 +718,13 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { + for (AnimationNodeBlendTree::NodeConnection &E : conns) { float activity = 0; - StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E->get().input_index); + activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); } - graph->set_connection_activity(E->get().output_node, 0, E->get().input_node, E->get().input_index, activity); + graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); } AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); @@ -741,7 +741,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { Ref<Animation> anim = player->get_animation(an->get_animation()); if (anim.is_valid()) { E->get()->set_max(anim->get_length()); - //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->key()) + "/time"; E->get()->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); } @@ -828,10 +828,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index cbce5bb3f5..1bdbc2980c 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -350,8 +350,8 @@ void AnimationPlayerEditor::_animation_load() { List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -584,8 +584,7 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->clear(); blend_editor.next->add_item("", i); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String to = E->get(); + for (StringName &to : anims) { TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); blend->set_editable(1, true); @@ -830,20 +829,20 @@ void AnimationPlayerEditor::_update_player() { } int active_idx = -1; - for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) { + for (StringName &E : animlist) { Ref<Texture2D> icon; - if (E->get() == player->get_autoplay()) { - if (E->get() == "RESET") { + if (E == player->get_autoplay()) { + if (E == "RESET") { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (E->get() == "RESET") { + } else if (E == "RESET") { icon = reset_icon; } - animation->add_icon_item(icon, E->get()); + animation->add_icon_item(icon, E); - if (player->get_assigned_animation() == E->get()) { + if (player->get_assigned_animation() == E) { active_idx = animation->get_item_count() - 1; } } @@ -966,9 +965,9 @@ void AnimationPlayerEditor::_animation_duplicate() { Ref<Animation> new_anim = memnew(Animation); List<PropertyInfo> plist; anim->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - new_anim->set(E->get().name, anim->get(E->get().name)); + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + new_anim->set(E.name, anim->get(E.name)); } } new_anim->set_path(""); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 8abe20c3c9..bee6af3cbb 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -93,21 +93,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E->get()); - animations_to_add.push_back(E->get()); + for (StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -318,24 +318,24 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv float best_d_x = 1e20; float best_d_y = 1e20; - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - if (E->get() == selected_node) { + for (StringName &E : nodes) { + if (E == selected_node) { continue; } - Vector2 npos = state_machine->get_node_position(E->get()); + Vector2 npos = state_machine->get_node_position(E); float d_x = ABS(npos.x - cpos.x); if (d_x < MIN(5, best_d_x)) { drag_ofs.x -= cpos.x - npos.x; best_d_x = d_x; - snap_x = E->get(); + snap_x = E; } float d_y = ABS(npos.y - cpos.y); if (d_y < MIN(5, best_d_y)) { drag_ofs.y -= cpos.y - npos.y; best_d_y = d_y; - snap_y = E->get(); + snap_y = E; } } } @@ -409,8 +409,8 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -606,11 +606,11 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } //pre pass nodes so we know the rectangles - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - Ref<AnimationNode> anode = state_machine->get_node(E->get()); - String name = E->get(); + for (StringName &E : nodes) { + Ref<AnimationNode> anode = state_machine->get_node(E); + String name = E; bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); - Ref<StyleBox> sb = E->get() == selected_node ? style_selected : style; + Ref<StyleBox> sb = E == selected_node ? style_selected : style; Size2 s = sb->get_minimum_size(); int strsize = font->get_string_size(name, font_size).width; @@ -622,8 +622,8 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } Vector2 offset; - offset += state_machine->get_node_position(E->get()) * EDSCALE; - if (selected_node == E->get() && dragging_selected) { + offset += state_machine->get_node_position(E) * EDSCALE; + if (selected_node == E && dragging_selected) { offset += drag_ofs; } offset -= s / 2; @@ -633,7 +633,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { NodeRect nr; nr.node = Rect2(offset, s); - nr.node_name = E->get(); + nr.node_name = E; scroll_range = scroll_range.merge(nr.node); //merge with range diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 9c28e023dd..67d5600a3c 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -215,8 +215,8 @@ Vector<String> AnimationTreeEditor::get_animation_list() { List<StringName> anims; ap->get_animation_list(&anims); Vector<String> ret; - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (StringName &E : anims) { + ret.push_back(E); } return ret; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 556f35d4b0..785bab42cf 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -607,7 +607,7 @@ void EditorAssetLibrary::_update_repository_options() { Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true); repository->clear(); Array keys = available_urls.keys(); - for (int i = 0; i < available_urls.size(); i++) { + for (int i = 0; i < keys.size(); i++) { String key = keys[i]; repository->add_item(key); repository->set_item_metadata(i, available_urls[key]); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index d5ef13e426..6bdb9eceb8 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -301,8 +301,8 @@ void CanvasItemEditor::_snap_other_nodes( // Check if the element is in the exception bool exception = false; - for (List<const CanvasItem *>::Element *E = p_exceptions.front(); E; E = E->next()) { - if (E->get() == p_current) { + for (const CanvasItem *&E : p_exceptions) { + if (E == p_current) { exception = true; break; } @@ -399,8 +399,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) { Transform2D to_snap_transform = Transform2D(); List<const CanvasItem *> exceptions = List<const CanvasItem *>(); - for (List<CanvasItem *>::Element *E = p_other_nodes_exceptions.front(); E; E = E->next()) { - exceptions.push_back(E->get()); + for (CanvasItem *E : p_other_nodes_exceptions) { + exceptions.push_back(E); } if (p_self_canvas_item) { exceptions.push_back(p_self_canvas_item); @@ -527,8 +527,7 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().position + canvas_item->_edit_get_rect().size / 2), Size2()); // Expand with the other ones - for (List<CanvasItem *>::Element *E = p_list.front(); E; E = E->next()) { - CanvasItem *canvas_item2 = E->get(); + for (CanvasItem *canvas_item2 : p_list) { Transform2D xform = canvas_item2->get_global_transform_with_canvas(); Rect2 current_rect = canvas_item2->_edit_get_rect(); @@ -760,9 +759,9 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retreive_lock if (remove_canvas_item_if_parent_in_selection) { List<CanvasItem *> filtered_selection; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!selection.find(E->get()->get_parent())) { - filtered_selection.push_back(E->get()); + for (CanvasItem *E : selection) { + if (!selection.find(E->get_parent())) { + filtered_selection.push_back(E); } } return filtered_selection; @@ -800,8 +799,7 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2 } void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items, bool save_bones) { - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { se->undo_state = canvas_item->_edit_get_state(); @@ -816,8 +814,7 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items } void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) { - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); canvas_item->_edit_set_state(se->undo_state); } @@ -825,8 +822,7 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state; Dictionary new_state = canvas_item->_edit_get_state(); @@ -840,17 +836,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } undo_redo->create_action(action_name); - for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : modified_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); if (commit_bones) { - for (List<Dictionary>::Element *F = se->pre_drag_bones_undo_state.front(); F; F = F->next()) { + for (Dictionary &F : se->pre_drag_bones_undo_state) { canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F->get()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); } } } @@ -1304,8 +1299,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Filters the selection with nodes that allow setting the pivot drag_selection = List<CanvasItem *>(); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { if (canvas_item->_edit_use_pivot()) { drag_selection.push_back(canvas_item); } @@ -1321,8 +1315,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } @@ -1343,8 +1336,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } return true; @@ -1387,8 +1379,8 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { List<CanvasItem *> selection = _get_edited_canvas_items(); // Remove not movable nodes - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!_is_node_movable(E->get(), true)) { + for (CanvasItem *E : selection) { + if (!_is_node_movable(E, true)) { selection.erase(E); } } @@ -1414,8 +1406,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { // Rotate the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { drag_to = transform.affine_inverse().xform(m->get_position()); //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); @@ -2046,8 +2037,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2162,8 +2152,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2375,8 +2364,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (selitems.size() == 1 && editor_selection->get_selected_node_list().is_empty()) { editor->push_item(selitems[0]); } - for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) { - editor_selection->add_node(E->get()); + for (CanvasItem *E : selitems) { + editor_selection->add_node(E); } } @@ -3248,8 +3237,8 @@ void CanvasItemEditor::_draw_selection() { List<CanvasItem *> selection = _get_edited_canvas_items(true, false); bool single = selection.size() == 1; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (CanvasItem *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); bool item_locked = canvas_item->has_meta("_edit_lock_"); @@ -3566,9 +3555,9 @@ void CanvasItemEditor::_draw_hover() { Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4); // Rectify the position to avoid overlapping items - for (List<Rect2>::Element *E = previous_rects.front(); E; E = E->next()) { - if (E->get().intersects(Rect2(pos, item_size))) { - pos.y = E->get().get_position().y - item_size.y; + for (Rect2 &E : previous_rects) { + if (E.intersects(Rect2(pos, item_size))) { + pos.y = E.get_position().y - item_size.y; } } @@ -3642,14 +3631,14 @@ void CanvasItemEditor::_draw_viewport() { all_locked = false; all_group = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_group_")) { all_group = false; break; } @@ -3716,8 +3705,7 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); Rect2 rect; @@ -3932,8 +3920,8 @@ void CanvasItemEditor::_selection_changed() { int nbValidControls = 0; int nbAnchorsMode = 0; List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control) { continue; } @@ -4101,8 +4089,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_preset(Control::LayoutPreset p_p undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); switch (p_preset) { @@ -4142,8 +4130,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_to_keep_ratio() { undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { Point2 top_left_anchor = _position_to_anchor(control, Point2()); Point2 bottom_right_anchor = _position_to_anchor(control, control->get_size()); @@ -4169,8 +4157,8 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state()); @@ -4295,15 +4283,15 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } if (has_chain && ik_chain.size()) { - for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) { + for (Node2D *&F : ik_chain) { if (key_pos) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "position", F->get_position(), p_on_existing); } if (key_rot) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation", F->get()->get_rotation(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "rotation", F->get_rotation(), p_on_existing); } if (key_scale) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "scale", F->get_scale(), p_on_existing); } } } @@ -4327,8 +4315,8 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) { List<CanvasItem *> selection = _get_edited_canvas_items(false, false); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (CanvasItem *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control || Object::cast_to<Container>(control->get_parent())) { continue; } @@ -4441,13 +4429,13 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_SHOW_BONES: { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + for (Node *E : selection) { // Add children nodes so they are processed - for (int child = 0; child < E->get()->get_child_count(); child++) { - selection.push_back(E->get()->get_child(child)); + for (int child = 0; child < E->get_child_count(); child++) { + selection.push_back(E->get_child(child)); } - Bone2D *bone_2d = Object::cast_to<Bone2D>(E->get()); + Bone2D *bone_2d = Object::cast_to<Bone2D>(E); if (!bone_2d || !bone_2d->is_inside_tree()) { continue; } @@ -4477,8 +4465,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Lock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4499,8 +4487,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Unlock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4521,8 +4509,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Group Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4543,8 +4531,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4711,14 +4699,14 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->create_action(TTR("Paste Pose")); - for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id)); + for (PoseClipboard &E : pose_clipboard) { + Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E.id)); if (!n2d) { continue; } - undo_redo->add_do_method(n2d, "set_position", E->get().pos); - undo_redo->add_do_method(n2d, "set_rotation", E->get().rot); - undo_redo->add_do_method(n2d, "set_scale", E->get().scale); + undo_redo->add_do_method(n2d, "set_position", E.pos); + undo_redo->add_do_method(n2d, "set_rotation", E.rot); + undo_redo->add_do_method(n2d, "set_scale", E.scale); undo_redo->add_undo_method(n2d, "set_position", n2d->get_position()); undo_redo->add_undo_method(n2d, "set_rotation", n2d->get_rotation()); undo_redo->add_undo_method(n2d, "set_scale", n2d->get_scale()); @@ -5819,14 +5807,14 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & String property = "texture"; List<PropertyInfo> props; child->get_property_list(&props); - for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == "config/texture") { // Particles2D + for (const PropertyInfo &E : props) { + if (E.name == "config/texture") { // Particles2D property = "config/texture"; break; - } else if (E->get().name == "texture/texture") { // Polygon2D + } else if (E.name == "texture/texture") { // Polygon2D property = "texture/texture"; break; - } else if (E->get().name == "normal") { // TouchScreenButton + } else if (E.name == "normal") { // TouchScreenButton property = "normal"; break; } diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index c4deb296fb..7e0eb89359 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -253,8 +253,8 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a233d66d82..19204e3bf8 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -490,11 +490,11 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set<String> control_flow_keywords; Set<String> keywords; - for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - if (scr->get_language()->is_control_flow_keyword(E->get())) { - control_flow_keywords.insert(E->get()); + for (String &E : kwors) { + if (scr->get_language()->is_control_flow_keyword(E)) { + control_flow_keywords.insert(E); } else { - keywords.insert(E->get()); + keywords.insert(E); } } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index cc5793a1f9..4412d51077 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -361,8 +361,8 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 7105d351b0..32d5865d0b 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -265,15 +265,15 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + for (PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself - Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); + Ref<Texture2D> texture = mat->get_texture_by_name(E.name); if (texture.is_valid()) { - smat->set_shader_param(E->get().name, texture); + smat->set_shader_param(E.name, texture); } else { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } } @@ -309,9 +309,9 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -346,9 +346,9 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -383,9 +383,9 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -420,9 +420,9 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -457,9 +457,9 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 91415f4883..9ee1fcb325 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -90,8 +90,8 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->create_action(TTR("Create Static Trimesh Body")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get()); + for (Node *E : selection) { + MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E); if (!instance) { continue; } diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 15b6a0f3a0..b3f92c9d95 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -122,23 +122,23 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, List<uint32_t> shapes; sb->get_shape_owners(&shapes); - for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) { - if (sb->is_shape_owner_disabled(E->get())) { + for (uint32_t &E : shapes) { + if (sb->is_shape_owner_disabled(E)) { continue; } - //Transform3D shape_transform = sb->shape_owner_get_transform(E->get()); + //Transform3D shape_transform = sb->shape_owner_get_transform(E); //shape_transform.set_origin(shape_transform.get_origin() - phys_offset); - for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k); + for (int k = 0; k < sb->shape_owner_get_shape_count(E); k++) { + Ref<Shape3D> collision = sb->shape_owner_get_shape(E, k); if (!collision.is_valid()) { continue; } MeshLibrary::ShapeData shape_data; shape_data.shape = collision; - shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get()); + shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E); collisions.push_back(shape_data); } } diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 492ba51b8a..393aaff207 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -4013,8 +4013,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { List<uint32_t> owners; co->get_shape_owners(&owners); - for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) { - uint32_t owner_id = E->get(); + for (uint32_t &owner_id : owners) { Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. @@ -4747,9 +4746,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); - + for (Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index ebf593e556..6292ef9f6a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1327,8 +1327,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1771,8 +1771,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1870,8 +1870,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1955,8 +1955,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -2186,8 +2186,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -3052,8 +3052,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { undo_redo->create_action(TTR("Align Transform with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -3088,8 +3088,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Align Rotation with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -3741,8 +3741,8 @@ void Node3DEditorViewport::focus_selection() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -5176,8 +5176,8 @@ void Node3DEditor::_xform_dialog_action() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -5413,8 +5413,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5438,8 +5438,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5463,8 +5463,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5487,8 +5487,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -6243,14 +6243,14 @@ void Node3DEditor::_refresh_menu_icons() { all_locked = false; all_grouped = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_group_")) { all_grouped = false; break; } @@ -6303,8 +6303,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() { List<Node *> &selection = editor_selection->get_selected_node_list(); Dictionary snap_data; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (sp) { Vector3 from = Vector3(); Vector3 position_offset = Vector3(); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index e099c8b5fd..0cb5a2e1e4 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -181,21 +181,21 @@ void ResourcePreloaderEditor::_update_library() { preloader->get_resource_list(&rnames); List<String> names; - for (List<StringName>::Element *E = rnames.front(); E; E = E->next()) { - names.push_back(E->get()); + for (StringName &E : rnames) { + names.push_back(E); } names.sort(); - for (List<String>::Element *E = names.front(); E; E = E->next()) { + for (String &E : names) { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); ti->set_selectable(0, true); - ti->set_text(0, E->get()); - ti->set_metadata(0, E->get()); + ti->set_text(0, E); + ti->set_metadata(0, E); - RES r = preloader->get_resource(E->get()); + RES r = preloader->get_resource(E); ERR_CONTINUE(r.is_null()); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index cea76f5233..95e23d0c57 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -70,8 +70,8 @@ void EditorPropertyRootMotion::_node_assign() { List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1851ffdc34..ab783c87e9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -103,8 +103,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); + for (StringName &E : types) { + String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); } @@ -115,8 +115,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), usertype_color); + for (StringName &E : global_classes) { + highlighter->add_keyword_color(E, usertype_color); } /* Autoloads. */ @@ -134,8 +134,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; script->get_language()->get_core_type_words(&core_types); - for (List<String>::Element *E = core_types.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), basetype_color); + for (String &E : core_types) { + highlighter->add_keyword_color(E, basetype_color); } /* Reserved words. */ @@ -143,11 +143,11 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (script->get_language()->is_control_flow_keyword(E->get())) { - highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (String &E : keywords) { + if (script->get_language()->is_control_flow_keyword(E)) { + highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - highlighter->add_keyword_color(E->get(), keyword_color); + highlighter->add_keyword_color(E, keyword_color); } } @@ -157,9 +157,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - String name = E->get().name; - if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (PropertyInfo &E : plist) { + String name = E.name; + if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } if (name.find("/") != -1) { @@ -170,8 +170,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (List<String>::Element *E = clist.front(); E; E = E->next()) { - highlighter->add_member_keyword_color(E->get(), member_variable_color); + for (String &E : clist) { + highlighter->add_member_keyword_color(E, member_variable_color); } } @@ -179,8 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; script->get_language()->get_comment_delimiters(&comments); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, comment_color, end == ""); @@ -190,8 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; script->get_language()->get_string_delimiters(&strings); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, string_color, end == ""); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1a6dfa273e..f9a0f307c3 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -50,9 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n List<Connection> all_connections; p_nodes[i]->get_signals_connected_to_this(&all_connections); - for (List<Connection>::Element *E = all_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (Connection &connection : all_connections) { if (connection.callable.get_method() != p_method) { continue; } @@ -116,8 +114,8 @@ Vector<String> ScriptTextEditor::get_functions() { if (script->get_language()->validate(text, script->get_path(), &fnc)) { //if valid rewrite functions to latest functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (String &E : fnc) { + functions.push_back(E); } } @@ -203,8 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> strings; script->get_language()->get_string_delimiters(&strings); text_edit->clear_string_delimiters(); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); text_edit->add_string_delimiter(beg, end, end == ""); @@ -213,8 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> comments; script->get_language()->get_comment_delimiters(&comments); text_edit->clear_comment_delimiters(); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); text_edit->add_comment_delimiter(beg, end, end == ""); @@ -417,8 +413,8 @@ void ScriptTextEditor::_validate_script() { } functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (String &E : fnc) { + functions.push_back(E); } script_is_valid = true; } @@ -432,9 +428,7 @@ void ScriptTextEditor::_validate_script() { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); - for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (Connection &connection : missing_connections) { String base_path = base->get_name(); String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object())); String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())); @@ -456,9 +450,7 @@ void ScriptTextEditor::_validate_script() { // Add script warnings. warnings_panel->push_table(3); - for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) { - ScriptLanguage::Warning w = E->get(); - + for (ScriptLanguage::Warning &w : warnings) { Dictionary ignore_meta; ignore_meta["line"] = w.start_line; ignore_meta["code"] = w.string_code.to_lower(); @@ -488,9 +480,7 @@ void ScriptTextEditor::_validate_script() { errors_panel->clear(); errors_panel->push_table(2); - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - ScriptLanguage::ScriptError err = E->get(); - + for (ScriptLanguage::ScriptError &err : errors) { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); @@ -511,8 +501,8 @@ void ScriptTextEditor::_validate_script() { if (errors.is_empty()) { te->set_line_background_color(i, Color(0, 0, 0, 0)); } else { - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - bool error_line = i == E->get().line - 1; + for (ScriptLanguage::ScriptError &E : errors) { + bool error_line = i == E.line - 1; te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0)); if (error_line) { break; @@ -910,8 +900,7 @@ void ScriptTextEditor::_update_connected_methods() { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Connection connection = E->get(); + for (Connection &connection : connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } @@ -1286,8 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() { List<String> comment_delimiters; script->get_language()->get_comment_delimiters(&comment_delimiters); - for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) { - String script_delimiter = E->get(); + for (String &script_delimiter : comment_delimiters) { if (script_delimiter.find(" ") == -1) { delimiter = script_delimiter; break; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 0d65dec87b..6c589ee07c 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -118,11 +118,11 @@ void ShaderTextEditor::_load_theme_settings() { const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (String &E : keywords) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } @@ -144,8 +144,8 @@ void ShaderTextEditor::_load_theme_settings() { const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); - for (List<String>::Element *E = built_ins.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), member_variable_color); + for (String &E : built_ins) { + syntax_highlighter->add_keyword_color(E, member_variable_color); } // Colorize comments. diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 9bb8fbacbb..486a40a4fd 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -365,8 +365,8 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ int count = 0; - for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) { - undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); + for (Ref<Texture2D> &E : resources) { + undo_redo->add_do_method(frames, "add_frame", edited_anim, E, p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); count++; } @@ -624,10 +624,10 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->add_do_method(frames, "rename_animation", edited_anim, name); undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", edited_anim); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", edited_anim); } undo_redo->add_do_method(this, "_update_library"); @@ -655,10 +655,10 @@ void SpriteFramesEditor::_animation_add() { undo_redo->add_do_method(this, "_update_library"); undo_redo->add_undo_method(this, "_update_library"); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", current); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", current); } edited_anim = name; @@ -788,8 +788,8 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - String name = E->get(); + for (StringName &E : anim_names) { + String name = E; TreeItem *it = animations->create_item(anim_root); @@ -798,7 +798,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { it->set_text(0, name); it->set_editable(0, true); - if (E->get() == edited_anim) { + if (E == edited_anim) { it->select(0); } } diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index e323f1571d..34227ee894 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -144,8 +144,7 @@ void TextureRegionEditor::_region_draw() { } } } else if (snap_mode == SNAP_AUTOSLICE) { - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 r = E->get(); + for (Rect2 &r : autoslice_cache) { Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), @@ -328,9 +327,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { Vector2 point = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y)); - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - if (E->get().has_point(point)) { - rect = E->get(); + for (Rect2 &E : autoslice_cache) { + if (E.has_point(point)) { + rect = E; if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { Rect2 r; if (node_sprite) { @@ -749,12 +748,12 @@ void TextureRegionEditor::_update_autoslice() { for (int x = 0; x < texture->get_width(); x++) { if (texture->is_pixel_opaque(x, y)) { bool found = false; - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 grown = E->get().grow(1.5); + for (Rect2 &E : autoslice_cache) { + Rect2 grown = E.grow(1.5); if (grown.has_point(Point2(x, y))) { - E->get().expand_to(Point2(x, y)); - E->get().expand_to(Point2(x + 1, y + 1)); - x = E->get().position.x + E->get().size.x - 1; + E.expand_to(Point2(x, y)); + E.expand_to(Point2(x + 1, y + 1)); + x = E.position.x + E.size.x - 1; bool merged = true; while (merged) { merged = false; @@ -764,12 +763,12 @@ void TextureRegionEditor::_update_autoslice() { autoslice_cache.erase(F->prev()); queue_erase = false; } - if (F == E) { + if (F->get() == E) { continue; } - if (E->get().grow(1).intersects(F->get())) { - E->get().expand_to(F->get().position); - E->get().expand_to(F->get().position + F->get().size); + if (E.grow(1).intersects(F->get())) { + E.expand_to(F->get().position); + E.expand_to(F->get().position + F->get().size); if (F->prev()) { F = F->prev(); autoslice_cache.erase(F->next()); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 9338ea6ddd..991c298caa 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -65,8 +65,8 @@ void ThemeItemImportTree::_update_items_tree() { tree_icon_items.clear(); tree_stylebox_items.clear(); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String type_name = (String)E->get(); + for (StringName &E : types) { + String type_name = (String)E; TreeItem *type_node = import_items_tree->create_item(root); type_node->set_meta("_can_be_imported", false); @@ -89,12 +89,12 @@ void ThemeItemImportTree::_update_items_tree() { names.clear(); filtered_names.clear(); - base_theme->get_theme_item_list(dt, E->get(), &names); + base_theme->get_theme_item_list(dt, E, &names); bool data_type_has_filtered_items = false; - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - String item_name = (String)F->get(); + for (StringName &F : names) { + String item_name = (String)F; bool is_item_matching_filter = (item_name.findn(filter_text) > -1); if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) { continue; @@ -105,7 +105,7 @@ void ThemeItemImportTree::_update_items_tree() { has_filtered_items = true; data_type_has_filtered_items = true; } - filtered_names.push_back(F->get()); + filtered_names.push_back(F); } if (filtered_names.size() == 0) { @@ -182,10 +182,10 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_any_checked_with_data = false; filtered_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = filtered_names.front(); F; F = F->next()) { + for (StringName &F : filtered_names) { TreeItem *item_node = import_items_tree->create_item(data_type_node); item_node->set_meta("_can_be_imported", true); - item_node->set_text(0, F->get()); + item_node->set_text(0, F); item_node->set_cell_mode(IMPORT_ITEM, TreeItem::CELL_MODE_CHECK); item_node->set_checked(IMPORT_ITEM, false); item_node->set_editable(IMPORT_ITEM, true); @@ -1236,16 +1236,16 @@ void ThemeItemEditorDialog::_update_edit_types() { bool item_reselected = false; edit_type_list->clear(); int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { + if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - edit_type_list->add_item(E->get(), item_icon); + edit_type_list->add_item(E, item_icon); - if (E->get() == edited_item_type) { + if (E == edited_item_type) { edit_type_list->select(e_idx); item_reselected = true; } @@ -1318,9 +1318,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1339,9 +1339,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1360,9 +1360,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1381,9 +1381,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1402,9 +1402,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1423,9 +1423,9 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); - item->set_text(0, E->get()); + item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } @@ -1507,8 +1507,8 @@ void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, edited_theme->_freeze_change_propagation(); edited_theme->get_theme_item_list(p_data_type, p_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(p_data_type, E->get(), p_item_type); + for (StringName &E : names) { + edited_theme->clear_theme_item(p_data_type, E, p_item_type); } // Allow changes to be reported now that the operation is finished. @@ -1526,9 +1526,9 @@ void ThemeItemEditorDialog::_remove_class_items() { names.clear(); Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (edited_theme->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (StringName &E : names) { + if (edited_theme->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1550,9 +1550,9 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!Theme::get_default()->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (StringName &E : names) { + if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1574,8 +1574,8 @@ void ThemeItemEditorDialog::_remove_all_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (StringName &E : names) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } @@ -1927,8 +1927,8 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { import_another_theme_dialog->set_title(TTR("Select Another Theme Resource:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - import_another_theme_dialog->add_filter("*." + E->get() + "; Theme Resource"); + for (String &E : ext) { + import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); } import_another_file_hb->add_child(import_another_theme_dialog); import_another_theme_dialog->connect("file_selected", callable_mp(this, &ThemeItemEditorDialog::_select_another_theme_cbk)); @@ -1969,26 +1969,26 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { names.sort_custom<StringName::AlphCompare>(); Vector<StringName> unique_names; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { // Filter out undesired values. - if (!p_filter.is_subsequence_ofi(String(E->get()))) { + if (!p_filter.is_subsequence_ofi(String(E))) { continue; } // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - unique_names.append(E->get()); + unique_names.append(E); Ref<Texture2D> item_icon; - if (E->get() == "") { + if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - add_type_options->add_item(E->get(), item_icon); + add_type_options->add_item(E, item_icon); } } @@ -2132,16 +2132,16 @@ void ThemeTypeEditor::_update_type_list() { bool item_reselected = false; int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { + if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - theme_type_list->add_icon_item(item_icon, E->get()); + theme_type_list->add_icon_item(item_icon, E); - if (E->get() == edited_type) { + if (E == edited_type) { theme_type_list->select(e_idx); item_reselected = true; } @@ -2182,8 +2182,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ (Theme::get_default().operator->()->*get_list_func)(default_type, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = false; + for (StringName &E : names) { + items[E] = false; } } @@ -2191,8 +2191,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ names.clear(); (edited_theme.operator->()->*get_list_func)(p_type_name, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = true; + for (StringName &E : names) { + items[E] = true; } } @@ -2203,8 +2203,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ keys.sort_custom<StringName::AlphCompare>(); OrderedHashMap<StringName, bool> ordered_items; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - ordered_items[E->get()] = items[E->get()]; + for (StringName &E : keys) { + ordered_items[E] = items[E]; } return ordered_items; @@ -2580,54 +2580,54 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_icon_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_icon(E->get(), edited_type)) { - edited_theme->set_icon(E->get(), edited_type, Ref<Texture2D>()); + for (StringName &E : names) { + if (!edited_theme->has_icon(E, edited_type)) { + edited_theme->set_icon(E, edited_type, Ref<Texture2D>()); } } } { names.clear(); Theme::get_default()->get_stylebox_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_stylebox(E->get(), edited_type)) { - edited_theme->set_stylebox(E->get(), edited_type, Ref<StyleBox>()); + for (StringName &E : names) { + if (!edited_theme->has_stylebox(E, edited_type)) { + edited_theme->set_stylebox(E, edited_type, Ref<StyleBox>()); } } } { names.clear(); Theme::get_default()->get_font_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font(E->get(), edited_type)) { - edited_theme->set_font(E->get(), edited_type, Ref<Font>()); + for (StringName &E : names) { + if (!edited_theme->has_font(E, edited_type)) { + edited_theme->set_font(E, edited_type, Ref<Font>()); } } } { names.clear(); Theme::get_default()->get_font_size_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font_size(E->get(), edited_type)) { - edited_theme->set_font_size(E->get(), edited_type, Theme::get_default()->get_font_size(E->get(), default_type)); + for (StringName &E : names) { + if (!edited_theme->has_font_size(E, edited_type)) { + edited_theme->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, default_type)); } } } { names.clear(); Theme::get_default()->get_color_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_color(E->get(), edited_type)) { - edited_theme->set_color(E->get(), edited_type, Theme::get_default()->get_color(E->get(), default_type)); + for (StringName &E : names) { + if (!edited_theme->has_color(E, edited_type)) { + edited_theme->set_color(E, edited_type, Theme::get_default()->get_color(E, default_type)); } } } { names.clear(); Theme::get_default()->get_constant_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_constant(E->get(), edited_type)) { - edited_theme->set_constant(E->get(), edited_type, Theme::get_default()->get_constant(E->get(), default_type)); + for (StringName &E : names) { + if (!edited_theme->has_constant(E, edited_type)) { + edited_theme->set_constant(E, edited_type, Theme::get_default()->get_constant(E, default_type)); } } } @@ -2882,12 +2882,12 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<StringName> names; edited_theme->get_stylebox_list(edited_type, &names); List<Ref<StyleBox>> styleboxes; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (E->get() == leading_stylebox.item_name) { + for (StringName &E : names) { + if (E == leading_stylebox.item_name) { continue; } - Ref<StyleBox> sb = edited_theme->get_stylebox(E->get(), edited_type); + Ref<StyleBox> sb = edited_theme->get_stylebox(E, edited_type); if (sb->get_class() == leading_stylebox.stylebox->get_class()) { styleboxes.push_back(sb); } @@ -2895,20 +2895,20 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<PropertyInfo> props; leading_stylebox.stylebox->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant value = leading_stylebox.stylebox->get(E->get().name); - Variant ref_value = leading_stylebox.ref_stylebox->get(E->get().name); + Variant value = leading_stylebox.stylebox->get(E.name); + Variant ref_value = leading_stylebox.ref_stylebox->get(E.name); if (value == ref_value) { continue; } - for (List<Ref<StyleBox>>::Element *F = styleboxes.front(); F; F = F->next()) { - Ref<StyleBox> sb = F->get(); - sb->set(E->get().name, value); + for (Ref<StyleBox> F : styleboxes) { + Ref<StyleBox> sb = F; + sb->set(E.name, value); } } @@ -3301,8 +3301,8 @@ ThemeEditor::ThemeEditor() { preview_scene_dialog->set_title(TTR("Select UI Scene:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - preview_scene_dialog->add_filter("*." + E->get() + "; Scene"); + for (String &E : ext) { + preview_scene_dialog->add_filter("*." + E + "; Scene"); } main_hs->add_child(preview_scene_dialog); preview_scene_dialog->connect("file_selected", callable_mp(this, &ThemeEditor::_preview_scene_dialog_cbk)); @@ -3343,12 +3343,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_font_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (StringName &E : types) { names.clear(); - edited_theme->get_font_list(E->get(), &names); + edited_theme->get_font_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (font_item == edited_theme->get_font(F->get(), E->get())) { + for (StringName &F : names) { + if (font_item == edited_theme->get_font(F, E)) { belongs_to_theme = true; break; } @@ -3360,12 +3360,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_stylebox_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (StringName &E : types) { names.clear(); - edited_theme->get_stylebox_list(E->get(), &names); + edited_theme->get_stylebox_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (stylebox_item == edited_theme->get_stylebox(F->get(), E->get())) { + for (StringName &F : names) { + if (stylebox_item == edited_theme->get_stylebox(F, E)) { belongs_to_theme = true; break; } @@ -3377,12 +3377,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_icon_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (StringName &E : types) { names.clear(); - edited_theme->get_icon_list(E->get(), &names); + edited_theme->get_icon_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (icon_item == edited_theme->get_icon(F->get(), E->get())) { + for (StringName &F : names) { + if (icon_item == edited_theme->get_icon(F, E)) { belongs_to_theme = true; break; } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index de910dfd32..ab26e1c380 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -303,9 +303,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro } // Add only properties that are common to all tiles. - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (E->get()->uses == tiles.size()) { - p_list->push_back(E->get()->property_info); + for (PLData *E : data_list) { + if (E->uses == tiles.size()) { + p_list->push_back(E->property_info); } } } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index f49279aa33..7e3244dddf 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -666,8 +666,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().to_node == p_id && E->get().to_port == j) { + for (VisualShader::Connection &E : connections) { + if (E.to_node == p_id && E.to_port == j) { port_left_used = true; } } @@ -899,11 +899,11 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->set_syntax_highlighter(expression_syntax_highlighter); expression_box->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - expression_syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (String &E : VisualShaderEditor::get_singleton()->keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + expression_syntax_highlighter->add_keyword_color(E, keyword_color); } } @@ -961,7 +961,7 @@ void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_fro void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { if (visual_shader->get_shader_type() == p_type) { VisualShaderEditor::get_singleton()->graph->disconnect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { + for (const List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { connections.erase(E); break; @@ -1470,11 +1470,11 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - int from = E->get().from_node; - int from_idx = E->get().from_port; - int to = E->get().to_node; - int to_idx = E->get().to_port; + for (VisualShader::Connection &E : connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; graph->connect_node(itos(from), from_idx, itos(to), to_idx); } @@ -1634,11 +1634,11 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (p_expand) { @@ -1708,11 +1708,11 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (to_node == p_node) { if (to_port == p_port) { @@ -1757,11 +1757,11 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (from_port == p_port) { @@ -2518,11 +2518,11 @@ void VisualShaderEditor::_nodes_dragged() { undo_redo->create_action(TTR("Node(s) Moved")); - for (List<DragOp>::Element *E = drag_buffer.front(); E; E = E->next()) { - undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); - undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); + for (DragOp &E : drag_buffer) { + undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.from); + undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.from); } drag_buffer.clear(); @@ -2544,12 +2544,12 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == to && E->get().to_port == p_to_index) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (VisualShader::Connection &E : conns) { + if (E.to_node == to && E.to_port == p_to_index) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } @@ -2597,22 +2597,22 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const int &F : p_nodes) { + for (VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } Set<String> uniform_names; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get()); + for (const int &F : p_nodes) { + Ref<VisualShaderNode> node = visual_shader->get_node(type, F); - undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get()); - undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F->get()), F->get()); - undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F->get()); + undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F); + undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F), F); + undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F); undo_redo->add_do_method(this, "_clear_buffer"); undo_redo->add_undo_method(this, "_clear_buffer"); @@ -2638,28 +2638,28 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } List<VisualShader::Connection> used_conns; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { + for (const int &F : p_nodes) { + for (VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { bool cancel = false; for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) { - if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) { + if (R->get().from_node == E.from_node && R->get().from_port == E.from_port && R->get().to_node == E.to_node && R->get().to_port == E.to_port) { cancel = true; // to avoid ERR_ALREADY_EXISTS warning break; } } if (!cancel) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - used_conns.push_back(E->get()); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + used_conns.push_back(E); } } } } // delete nodes from the graph - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F->get()); + for (const int &F : p_nodes) { + undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); } // update uniform refs if any uniform has been deleted @@ -3094,11 +3094,11 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (String &E : keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } @@ -3206,9 +3206,9 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in Map<int, int> connection_remap; Set<int> unsupported_set; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { - connection_remap[E->get()] = id_from; - Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get()); + for (int &E : r_nodes) { + connection_remap[E] = id_from; + Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E); bool unsupported = false; for (int i = 0; i < add_options.size(); i++) { @@ -3220,13 +3220,13 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in } } if (unsupported) { - unsupported_set.insert(E->get()); + unsupported_set.insert(E); continue; } Ref<VisualShaderNode> dupli = node->duplicate(); - undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E->get()) + p_offset, id_from); + undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E) + p_offset, id_from); undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from); // duplicate size, inputs and outputs if node is group @@ -3249,19 +3249,19 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in List<VisualShader::Connection> conns; visual_shader->get_node_connections(pasted_type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (unsupported_set.has(E->get().from_node) || unsupported_set.has(E->get().to_node)) { + for (VisualShader::Connection &E : conns) { + if (unsupported_set.has(E.from_node) || unsupported_set.has(E.to_node)) { continue; } - if (connection_remap.has(E->get().from_node) && connection_remap.has(E->get().to_node)) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); + if (connection_remap.has(E.from_node) && connection_remap.has(E.to_node)) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); } } id_from = base_id; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { + for (int i = 0; i < r_nodes.size(); i++) { undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from); undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from); id_from++; @@ -3399,17 +3399,17 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -3445,15 +3445,15 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_ if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { + for (VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -4825,10 +4825,10 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<PropertyInfo> pinfo; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + for (PropertyInfo &E : props) { for (int i = 0; i < properties.size(); i++) { - if (E->get().name == String(properties[i])) { - pinfo.push_back(E->get()); + if (E.name == String(properties[i])) { + pinfo.push_back(E); } } } @@ -4894,9 +4894,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { VisualShader::Type type = VisualShader::Type(i); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == VisualShader::NODE_ID_OUTPUT) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (VisualShader::Connection &E : conns) { + if (E.to_node == VisualShader::NODE_ID_OUTPUT) { + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -4918,9 +4918,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { List<PropertyInfo> props; visual_shader->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) { - undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name)); + for (PropertyInfo &E : props) { + if (E.name.begins_with("flags/") || E.name.begins_with("modes/")) { + undo_redo->add_undo_property(visual_shader.ptr(), E.name, visual_shader->get(E.name)); } } @@ -5024,8 +5024,8 @@ void VisualShaderNodePortPreview::_shader_changed() { if (src_mat && src_mat->get_shader().is_valid()) { List<PropertyInfo> params; src_mat->get_shader()->get_param_list(¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - material->set(E->get().name, src_mat->get(E->get().name)); + for (PropertyInfo &E : params) { + material->set(E.name, src_mat->get(E.name)); } } } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 1e818b9d43..3f320ef12a 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -340,8 +340,8 @@ void ProjectExportDialog::_update_feature_list() { } } - for (List<String>::Element *E = features.front(); E; E = E->next()) { - fset.insert(E->get()); + for (String &E : features) { + fset.insert(E); } custom_feature_display->clear(); @@ -567,8 +567,8 @@ void ProjectExportDialog::_duplicate_preset() { preset->set_exclude_filter(current->get_exclude_filter()); preset->set_custom_features(current->get_custom_features()); - for (const List<PropertyInfo>::Element *E = current->get_properties().front(); E; E = E->next()) { - preset->set(E->get().name, current->get(E->get().name)); + for (const PropertyInfo &E : current->get_properties()) { + preset->set(E.name, current->get(E.name)); } EditorExport::get_singleton()->add_export_preset(preset); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 447fe6424f..4f9d849bc0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1238,16 +1238,16 @@ void ProjectList::load_projects() { Set<String> favorites; // Find favourites... - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String property_key = E->get().name; + for (PropertyInfo &E : properties) { + String property_key = E.name; if (property_key.begins_with("favorite_projects/")) { favorites.insert(property_key); } } - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (PropertyInfo &E : properties) { // This is actually something like "projects/C:::Documents::Godot::Projects::MyGame" - String property_key = E->get().name; + String property_key = E.name; if (!property_key.begins_with("projects/")) { continue; } @@ -1582,8 +1582,8 @@ int ProjectList::refresh_project(const String &dir_path) { String favorite_property_key = "favorite_projects/" + project_key; bool found = false; - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String prop = E->get().name; + for (PropertyInfo &E : properties) { + String prop = E.name; if (!found && prop == property_key) { found = true; } else if (!is_favourite && prop == favorite_property_key) { @@ -2188,9 +2188,9 @@ void ProjectManager::_scan_begin(const String &p_base) { _scan_dir(p_base, &projects); print_line("Found " + itos(projects.size()) + " projects."); - for (List<String>::Element *E = projects.front(); E; E = E->next()) { - String proj = get_project_key_from_path(E->get()); - EditorSettings::get_singleton()->set("projects/" + proj, E->get()); + for (String &E : projects) { + String proj = get_project_key_from_path(E); + EditorSettings::get_singleton()->set("projects/" + proj, E); } EditorSettings::get_singleton()->save(); _load_recent_projects(); @@ -2625,8 +2625,7 @@ ProjectManager::ProjectManager() { Vector<String> editor_languages; List<PropertyInfo> editor_settings_properties; EditorSettings::get_singleton()->get_property_list(&editor_settings_properties); - for (List<PropertyInfo>::Element *E = editor_settings_properties.front(); E; E = E->next()) { - PropertyInfo &pi = E->get(); + for (PropertyInfo &pi : editor_settings_properties) { if (pi.name == "interface/editor/editor_language") { editor_languages = pi.hint_string.split(","); break; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 2c4b28e13d..bc44fccfa0 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -229,16 +229,16 @@ void ProjectSettingsEditor::_add_feature_overrides() { for (int i = 0; i < ee->get_export_platform_count(); i++) { List<String> p; ee->get_export_platform(i)->get_platform_features(&p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (String &E : p) { + presets.insert(E); } } for (int i = 0; i < ee->get_export_preset_count(); i++) { List<String> p; ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (String &E : p) { + presets.insert(E); } String custom = ee->get_export_preset(i)->get_custom_features(); @@ -391,8 +391,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const undo_redo->create_action(TTR("Update Input Action Order")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - PropertyInfo prop = E->get(); + for (PropertyInfo &prop : props) { // Skip builtins and non-inputs if (ProjectSettings::get_singleton()->is_builtin_setting(prop.name) || !prop.name.begins_with("input/")) { continue; @@ -445,8 +444,8 @@ void ProjectSettingsEditor::_update_action_map_editor() { ProjectSettings::get_singleton()->get_property_list(&props); const Ref<Texture2D> builtin_icon = get_theme_icon(SNAME("PinPressed"), SNAME("EditorIcons")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const String property_name = E->get().name; + for (PropertyInfo &E : props) { + const String property_name = E.name; if (!property_name.begins_with("input/")) { continue; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index db8334b485..6fc77500c3 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -143,8 +143,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (String &E : extensions) { + valid_extensions.insert(E); } file->clear_filters(); @@ -179,9 +179,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -198,8 +197,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } @@ -1293,8 +1291,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type, &extensions); file->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -1321,9 +1319,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -1336,8 +1333,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index d26fc6ad9d..471fec76f2 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -156,43 +156,43 @@ void PropertySelector::_update_search() { search_options->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage == PROPERTY_USAGE_CATEGORY) { + for (PropertyInfo &E : props) { + if (E.usage == PROPERTY_USAGE_CATEGORY) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name); + category->set_text(0, E.name); category->set_selectable(0, false); Ref<Texture2D> icon; - if (E->get().name == "Script Variables") { + if (E.name == "Script Variables") { icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); } else { - icon = EditorNode::get_singleton()->get_class_icon(E->get().name); + icon = EditorNode::get_singleton()->get_class_icon(E.name); } category->set_icon(0, icon); continue; } - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) && !(E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } - if (search_box->get_text() != String() && E->get().name.findn(search_text) == -1) { + if (search_box->get_text() != String() && E.name.findn(search_text) == -1) { continue; } - if (type_filter.size() && type_filter.find(E->get().type) == -1) { + if (type_filter.size() && type_filter.find(E.type) == -1) { continue; } TreeItem *item = search_options->create_item(category ? category : root); - item->set_text(0, E->get().name); - item->set_metadata(0, E->get().name); - item->set_icon(0, type_icons[E->get().type]); + item->set_text(0, E.name); + item->set_metadata(0, E.name); + item->set_icon(0, type_icons[E.type]); - if (!found && search_box->get_text() != String() && E->get().name.findn(search_text) != -1) { + if (!found && search_box->get_text() != String() && E.name.findn(search_text) != -1) { item->select(0); found = true; } @@ -231,19 +231,19 @@ void PropertySelector::_update_search() { bool found = false; bool script_methods = false; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("*")) { + for (MethodInfo &mi : methods) { + if (mi.name.begins_with("*")) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name.replace_first("*", "")); + category->set_text(0, mi.name.replace_first("*", "")); category->set_selectable(0, false); Ref<Texture2D> icon; script_methods = false; - String rep = E->get().name.replace("*", ""); - if (E->get().name == "*Script Methods") { + String rep = mi.name.replace("*", ""); + if (mi.name == "*Script Methods") { icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); script_methods = true; } else { @@ -254,16 +254,16 @@ void PropertySelector::_update_search() { continue; } - String name = E->get().name.get_slice(":", 0); - if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + String name = mi.name.get_slice(":", 0); + if (!script_methods && name.begins_with("_") && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (virtuals_only && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (!virtuals_only && (mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } @@ -273,8 +273,6 @@ void PropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); - MethodInfo mi = E->get(); - String desc; if (mi.name.find(":") != -1) { desc = mi.name.get_slice(":", 1) + " "; @@ -306,11 +304,11 @@ void PropertySelector::_update_search() { desc += ")"; - if (E->get().flags & METHOD_FLAG_CONST) { + if (mi.flags & METHOD_FLAG_CONST) { desc += " const"; } - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (mi.flags & METHOD_FLAG_VIRTUAL) { desc += " virtual"; } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index f453f4102d..2586a36966 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -263,8 +263,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) List<Node *> owned; base->get_owned_by(base->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene); undo_redo->add_undo_method(this, "_set_owners", edited_scene, owners); @@ -441,8 +441,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { selection.sort_custom<Node::Comparator>(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); @@ -462,8 +461,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { bool has_cycle = false; if (edited_scene->get_filename() != String()) { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - if (edited_scene->get_filename() == E->get()->get_filename()) { + for (Node *E : node_clipboard) { + if (edited_scene->get_filename() == E->get_filename()) { has_cycle = true; break; } @@ -496,16 +495,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (target_scene != clipboard_source_scene) { if (!clipboard_resource_remap.has(target_scene)) { Map<RES, RES> remap; - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - _create_remap_for_node(E->get(), remap); + for (Node *E : node_clipboard) { + _create_remap_for_node(E, remap); } clipboard_resource_remap[target_scene] = remap; } resource_remap = clipboard_resource_remap[target_scene]; } - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : node_clipboard) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap, resource_remap); @@ -627,8 +625,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { int lowest_id = common_parent->get_child_count() - 1; int highest_id = 0; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - int index = E->get()->get_index(); + for (Node *E : selection) { + int index = E->get_index(); if (index > highest_id) { highest_id = index; @@ -637,7 +635,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { lowest_id = index; } - if (E->get()->get_parent() != common_parent) { + if (E->get_parent() != common_parent) { common_parent = nullptr; } } @@ -704,8 +702,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *add_below_node = selection.back()->get(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Node *parent = node->get_parent(); List<Node *> owned; @@ -724,11 +721,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(add_below_node, "add_sibling", dup); - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - if (!duplimap.has(F->get())) { + for (Node *F : owned) { + if (!duplimap.has(F)) { continue; } - Node *d = duplimap[F->get()]; + Node *d = duplimap[F]; editor_data->get_undo_redo().add_do_method(d, "set_owner", node->get_owner()); } editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", dup); @@ -771,8 +768,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> nodes = editor_selection->get_selected_node_list(); Set<Node *> nodeset; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - nodeset.insert(E->get()); + for (Node *E : nodes) { + nodeset.insert(E); } reparent_dialog->set_current(nodeset); reparent_dialog->popup_centered_clamped(Size2(350, 700) * EDSCALE); @@ -1534,11 +1531,11 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ List<PropertyInfo> properties; p_base->get_property_list(&properties); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!(E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { + for (PropertyInfo &E : properties) { + if (!(E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { continue; } - String propertyname = E->get().name; + String propertyname = E.name; Variant old_variant = p_base->get(propertyname); Variant updated_variant = old_variant; if (_check_node_path_recursive(p_base, updated_variant, p_renames)) { @@ -1560,8 +1557,8 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ Map<Node *, NodePath>::Element *found_root_path = p_renames->find(root); NodePath new_root_path = found_root_path ? found_root_path->get() : root->get_path(); if (!new_root_path.is_empty()) { // No renaming if root node is deleted. - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + for (StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { r_rem_anims->insert(anim, Set<int>()); Set<int> &ran = r_rem_anims->find(anim)->get(); @@ -1663,8 +1660,8 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { bool SceneTreeDock::_validate_no_foreign() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) { + for (Node *E : selection) { + if (E != edited_scene && E->get_owner() != edited_scene) { accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); accept->popup_centered(); return false; @@ -1673,11 +1670,11 @@ bool SceneTreeDock::_validate_no_foreign() { // When edited_scene inherits from another one the root Node will be the parent Scene, // we don't want to consider that Node a foreign one otherwise we would not be able to // delete it. - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E->get()) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E) { continue; } - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); accept->popup_centered(); return false; @@ -1690,8 +1687,8 @@ bool SceneTreeDock::_validate_no_foreign() { bool SceneTreeDock::_validate_no_instance() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_filename() != "") { + for (Node *E : selection) { + if (E != edited_scene && E->get_filename() != "") { accept->set_text(TTR("This operation can't be done on instantiated scenes.")); accept->popup_centered(); return false; @@ -1713,8 +1710,8 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } _do_reparent(new_parent, -1, nodes, p_keep_global_xform); @@ -1771,8 +1768,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni) { @@ -1847,8 +1844,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } int child_pos = node->get_index(); @@ -1928,10 +1925,10 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { } editor_data->get_undo_redo().create_action(TTR("Attach Script")); - for (List<Node *>::Element *E = selected.front(); E; E = E->next()) { - Ref<Script> existing = E->get()->get_script(); - editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script); - editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing); + for (Node *E : selected) { + Ref<Script> existing = E->get_script(); + editor_data->get_undo_redo().add_do_method(E, "set_script", p_script); + editor_data->get_undo_redo().add_undo_method(E, "set_script", existing); editor_data->get_undo_redo().add_do_method(this, "_update_script_button"); editor_data->get_undo_redo().add_undo_method(this, "_update_script_button"); } @@ -2006,8 +2003,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { bool entire_scene = false; - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - if (E->get() == edited_scene) { + for (Node *E : remove_list) { + if (E == edited_scene) { entire_scene = true; } } @@ -2024,8 +2021,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { Map<Node *, NodePath> path_renames; //delete from animation - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2035,8 +2031,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { perform_node_renames(nullptr, &path_renames); //delete for read - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2044,8 +2039,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { List<Node *> owned; n->get_owned_by(n->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n); @@ -2198,8 +2193,7 @@ void SceneTreeDock::_create() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change type of node(s)")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : selection) { ERR_FAIL_COND(!n); Variant c = create_dialog->instance_selected(); @@ -2256,8 +2250,8 @@ void SceneTreeDock::_create() { _do_create(parent); Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } // This works because editor_selection was cleared and populated with last created node in _do_create() @@ -2277,13 +2271,13 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<PropertyInfo> pinfo; n->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "__meta__") { - Dictionary metadata = n->get(E->get().name); + if (E.name == "__meta__") { + Dictionary metadata = n->get(E.name); if (metadata.has("_editor_description_")) { newnode->set_meta("_editor_description_", metadata["_editor_description_"]); } @@ -2300,8 +2294,8 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop continue; } - if (default_oldnode->get(E->get().name) != n->get(E->get().name)) { - newnode->set(E->get().name, n->get(E->get().name)); + if (default_oldnode->get(E.name) != n->get(E.name)) { + newnode->set(E.name, n->get(E.name)); } } @@ -2314,12 +2308,12 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<MethodInfo> sl; n->get_signal_list(&sl); - for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { + for (MethodInfo &E : sl) { List<Object::Connection> cl; - n->get_signal_connection_list(E->get().name, &cl); + n->get_signal_connection_list(E.name, &cl); - for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { - Object::Connection &c = F->get(); + for (Object::Connection &F : cl) { + Object::Connection &c = F; if (!(c.flags & Object::CONNECT_PERSIST)) { continue; } @@ -2586,8 +2580,8 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { } Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } int to_pos = -1; @@ -2603,15 +2597,15 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -2626,7 +2620,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources"); } int index = menu_subresources->get_item_count(); - menu_subresources->add_icon_item(icon, E->get().name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); + menu_subresources->add_icon_item(icon, E.name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); menu_subresources->set_item_h_offset(index, p_depth * 10 * EDSCALE); subresources.push_back(obj->get_instance_id()); @@ -2708,8 +2702,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } else if (full_selection.size() > 1) { bool script_exists = false; - for (List<Node *>::Element *E = full_selection.front(); E; E = E->next()) { - if (!E->get()->get_script().is_null()) { + for (Node *E : full_selection) { + if (!E->get_script().is_null()) { script_exists = true; break; } @@ -2732,8 +2726,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } bool can_replace = true; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && (E->get()->get_owner() != edited_scene || E->get()->get_filename() != "")) { + for (Node *E : selection) { + if (E != edited_scene && (E->get_owner() != edited_scene || E->get_filename() != "")) { can_replace = false; break; } @@ -3046,8 +3040,8 @@ void SceneTreeDock::_feature_profile_changed() { } void SceneTreeDock::_clear_clipboard() { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - memdelete(E->get()); + for (Node *E : node_clipboard) { + memdelete(E); } node_clipboard.clear(); clipboard_resource_remap.clear(); @@ -3058,18 +3052,18 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) p_node->get_property_list(&props); bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_node->get(E->get().name); + Variant v = p_node->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (is_instantiated) { Variant orig; - if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E->get().name, orig)) { + if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E.name, orig)) { if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) { continue; } @@ -3094,12 +3088,12 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_ List<PropertyInfo> props; p_resource->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_resource->get(E->get().name); + Variant v = p_resource->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 0468fe4ee0..83b0203f32 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -79,8 +79,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() > 1 && selection.find(n) != nullptr) { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *nv = E->get(); + for (Node *nv : selection) { ERR_FAIL_COND(!nv); if (nv == n) { continue; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 2601382009..90481b2107 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -205,12 +205,12 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must bool found = false; bool match = false; int index = 0; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { //FIXME (?) - changing language this way doesn't update controls, needs rework //language_menu->select(index); // change Language option by extension found = true; - if (E->get() == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { + if (E == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { match = true; } break; @@ -373,8 +373,8 @@ void ScriptCreateDialog::_lang_changed(int l) { ScriptServer::get_language(m)->get_recognized_extensions(&extensions); } - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { path = path.get_basename() + selected_ext; _path_changed(path); break; @@ -534,8 +534,8 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { int lang = language_menu->get_selected(); ScriptServer::get_language(lang)->get_recognized_extensions(&extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_browse->add_filter("*." + E->get()); + for (String &E : extensions) { + file_browse->add_filter("*." + E); } file_browse->set_current_path(file_path->get_text()); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 0524b91634..89e102ee22 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -324,15 +324,15 @@ void EditorSettingsDialog::_update_shortcuts() { List<String> slist; EditorSettings::get_singleton()->get_shortcut_list(&slist); - for (List<String>::Element *E = slist.front(); E; E = E->next()) { - Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E->get()); + for (String &E : slist) { + Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E); if (!sc->has_meta("original")) { continue; } Ref<InputEvent> original = sc->get_meta("original"); - String section_name = E->get().get_slice("/", 0); + String section_name = E.get_slice("/", 0); TreeItem *section; @@ -372,8 +372,8 @@ void EditorSettingsDialog::_update_shortcuts() { item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), 1); - item->set_tooltip(0, E->get()); - item->set_metadata(0, E->get()); + item->set_tooltip(0, E); + item->set_metadata(0, E); } } @@ -403,10 +403,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column List<Ref<InputEvent>> defaults = InputMap::get_singleton()->get_builtins()[current_action]; // Convert the list to an array, and only keep key events as this is for the editor. - for (List<Ref<InputEvent>>::Element *E = defaults.front(); E; E = E->next()) { - Ref<InputEventKey> k = E->get(); + for (Ref<InputEvent> k : defaults) { if (k.is_valid()) { - events.append(E->get()); + events.append(k); } } diff --git a/main/main.cpp b/main/main.cpp index b7f67e8f6c..1ad9a16992 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2169,8 +2169,8 @@ bool Main::start() { } } - for (List<Node *>::Element *E = to_add.front(); E; E = E->next()) { - sml->get_root()->add_child(E->get()); + for (Node *E : to_add) { + sml->get_root()->add_child(E); } } } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 57206ae18b..cb82b65307 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -530,8 +530,8 @@ void CSGBrushOperation::MeshMerge::_add_distance(List<real_t> &r_intersectionsA, List<real_t> &intersections = p_from_B ? r_intersectionsB : r_intersectionsA; // Check if distance exists. - for (const List<real_t>::Element *E = intersections.front(); E; E = E->next()) { - if (Math::is_equal_approx(**E, p_distance)) { + for (const real_t E : intersections) { + if (Math::is_equal_approx(E, p_distance)) { return; } } diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 1ff591a87f..b585ad15bf 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -129,9 +129,7 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { config_file->get_section_keys("entry", &entry_key_list); } - for (List<String>::Element *E = entry_key_list.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : entry_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -147,9 +145,7 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { config_file->get_section_keys("dependencies", &dependency_key_list); } - for (List<String>::Element *E = dependency_key_list.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : dependency_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -175,9 +171,7 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { p_config_file->get_section_keys("entry", &entry_keys); } - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -207,9 +201,7 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) { p_config_file->get_section_keys("dependencies", &dependency_keys); } - for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : dependency_keys) { Vector<String> tags = key.split("."); bool skip = false; diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index cfb57137bb..1d75ea206c 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -915,8 +915,8 @@ void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godo List<StringName> list; Variant::get_builtin_method_list((Variant::Type)p_type, &list); int i = 0; - for (const List<StringName>::Element *E = list.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i], StringName, StringName(E->get())); + for (const StringName &E : list) { + memnew_placement_custom(&r_list[i], StringName, StringName(E)); } } @@ -970,8 +970,8 @@ void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string List<StringName> members; Variant::get_member_list((Variant::Type)p_type, &members); int i = 0; - for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + for (const StringName &E : members) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E)); } } @@ -1075,8 +1075,8 @@ void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_str List<StringName> constants; int i = 0; Variant::get_constants_for_type((Variant::Type)p_type, &constants); - for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { - memnew_placement_custom(&r_list[i++], StringName, StringName(E->get())); + for (const StringName &E : constants) { + memnew_placement_custom(&r_list[i++], StringName, StringName(E)); } } @@ -1227,8 +1227,8 @@ void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_function godot_string_name *func = r_functions; Variant::get_utility_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - memnew_placement_custom(func++, StringName, StringName(E->get())); + for (const StringName &E : functions) { + memnew_placement_custom(func++, StringName, StringName(E)); } } diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 477bc9f74d..0a3225fcc5 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -425,11 +425,11 @@ List<ClassAPI> generate_c_api_classes() { List<EnumAPI> enums; List<StringName> enum_names; ClassDB::get_enum_list(class_name, &enum_names, true); - for (List<StringName>::Element *E = enum_names.front(); E; E = E->next()) { + for (StringName &E : enum_names) { List<StringName> value_names; EnumAPI enum_api; - enum_api.name = E->get(); - ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); + enum_api.name = E; + ClassDB::get_enum_constants(class_name, E, &value_names, true); for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); @@ -459,8 +459,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); - for (const List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { - const StringName &function_name = E->get(); + for (const StringName &E : utility_functions) { + const StringName &function_name = E; MethodAPI function_api; function_api.method_name = function_name; @@ -521,8 +521,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> methods; Variant::get_builtin_method_list(type, &methods); - for (const List<StringName>::Element *E = methods.front(); E; E = E->next()) { - const StringName &method_name = E->get(); + for (const StringName &E : methods) { + const StringName &method_name = E; MethodAPI method_api; @@ -578,8 +578,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> constants; Variant::get_constants_for_type(type, &constants); - for (const List<StringName>::Element *E = constants.front(); E; E = E->next()) { - const StringName &constant_name = E->get(); + for (const StringName &E : constants) { + const StringName &constant_name = E; ConstantAPI constant_api; constant_api.constant_name = constant_name; @@ -593,8 +593,8 @@ List<ClassAPI> generate_c_builtin_api_types() { List<StringName> members; Variant::get_member_list(type, &members); - for (const List<StringName>::Element *E = members.front(); E; E = E->next()) { - const StringName &member_name = E->get(); + for (const StringName &E : members) { + const StringName &member_name = E; PropertyAPI member_api; member_api.name = member_name; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index d7943827c2..dba348c20d 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -98,10 +98,10 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) List<PropertyInfo> info; get_script_property_list(&info); Map<StringName, Variant> values; - for (List<PropertyInfo>::Element *E = info.front(); E; E = E->next()) { + for (PropertyInfo &E : info) { Variant value; - get_property_default_value(E->get().name, value); - values[E->get().name] = value; + get_property_default_value(E.name, value); + values[E.name] = value; } p_placeholder->update(info, values); diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 8e5ae29ed9..c3a6a3267f 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -79,9 +79,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> entry_keys; config->get_section_keys("entry", &entry_keys); - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -112,9 +110,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> dependency_keys; config->get_section_keys("dependencies", &dependency_keys); - for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : dependency_keys) { Vector<String> tags = key.split("."); bool skip = false; @@ -149,9 +145,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List<String> entry_keys; config->get_section_keys("entry", &entry_keys); - for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { - String key = E->get(); - + for (String &key : entry_keys) { Vector<String> tags = key.split("."); bool skip = false; diff --git a/modules/gdnative/tests/test_variant.h b/modules/gdnative/tests/test_variant.h index 2850036604..c506882283 100644 --- a/modules/gdnative/tests/test_variant.h +++ b/modules/gdnative/tests/test_variant.h @@ -191,8 +191,8 @@ TEST_CASE("[GDNative Variant] Get utility function list") { godot_string_name *cur = c_list; - for (const List<StringName>::Element *E = cpp_list.front(); E; E = E->next()) { - const StringName &cpp_name = E->get(); + for (const StringName &E : cpp_list) { + const StringName &cpp_name = E; StringName *c_name = (StringName *)cur++; CHECK(*c_name == cpp_name); diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 9a4c22f49f..b19a57d56a 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -458,8 +458,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color types_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); + for (StringName &E : types) { + String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); } @@ -470,8 +470,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - keywords[String(E->get())] = usertype_color; + for (StringName &E : global_classes) { + keywords[String(E)] = usertype_color; } /* Autoloads. */ @@ -489,8 +489,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; gdscript->get_core_type_words(&core_types); - for (List<String>::Element *E = core_types.front(); E; E = E->next()) { - keywords[E->get()] = basetype_color; + for (String &E : core_types) { + keywords[E] = basetype_color; } /* Reserved words. */ @@ -498,11 +498,11 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keyword_list; gdscript->get_reserved_words(&keyword_list); - for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - if (gdscript->is_control_flow_keyword(E->get())) { - keywords[E->get()] = control_flow_keyword_color; + for (String &E : keyword_list) { + if (gdscript->is_control_flow_keyword(E)) { + keywords[E] = control_flow_keyword_color; } else { - keywords[E->get()] = keyword_color; + keywords[E] = keyword_color; } } @@ -510,8 +510,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; gdscript->get_comment_delimiters(&comments); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); add_color_region(beg, end, comment_color, end == ""); @@ -521,8 +520,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; gdscript->get_string_delimiters(&strings); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); add_color_region(beg, end, string_color, end == ""); @@ -536,9 +534,9 @@ void GDScriptSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - String name = E->get().name; - if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (PropertyInfo &E : plist) { + String name = E.name; + if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } if (name.find("/") != -1) { @@ -549,8 +547,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (List<String>::Element *E = clist.front(); E; E = E->next()) { - member_keywords[E->get()] = member_variable_color; + for (String &E : clist) { + member_keywords[E] = member_variable_color; } } } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index f7113674ec..79cc90b92f 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -291,8 +291,8 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl sptr = sptr->_base; } - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - r_list->push_back(E->get()); + for (PropertyInfo &E : props) { + r_list->push_back(E); } } @@ -401,8 +401,8 @@ void GDScript::_update_exports_values(Map<StringName, Variant> &values, List<Pro values[E->key()] = E->get(); } - for (List<PropertyInfo>::Element *E = members_cache.front(); E; E = E->next()) { - propnames.push_back(E->get()); + for (PropertyInfo &E : members_cache) { + propnames.push_back(E); } } @@ -861,8 +861,8 @@ Error GDScript::reload(bool p_keep_state) { } } #ifdef DEBUG_ENABLED - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E; E = E->next()) { - const GDScriptWarning &warning = E->get(); + for (const GDScriptWarning &E : parser.get_warnings()) { + const GDScriptWarning &warning = E; if (EngineDebugger::is_active()) { Vector<ScriptLanguage::StackInfo> si; EngineDebugger::get_script_debugger()->send_error("", get_path(), warning.start_line, warning.get_name(), warning.get_message(), ERR_HANDLER_WARNING, si); @@ -1445,8 +1445,8 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const sptr = sptr->_base; } - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - p_properties->push_back(E->get()); + for (PropertyInfo &E : props) { + p_properties->push_back(E); } } @@ -1644,8 +1644,7 @@ void GDScriptLanguage::init() { List<StringName> class_list; ClassDB::get_class_list(&class_list); - for (List<StringName>::Element *E = class_list.front(); E; E = E->next()) { - StringName n = E->get(); + for (StringName &n : class_list) { String s = String(n); if (s.begins_with("_")) { n = s.substr(1, s.length()); @@ -1654,7 +1653,7 @@ void GDScriptLanguage::init() { if (globals.has(n)) { continue; } - Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get())); + Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(n)); _add_global(n, nc); } @@ -1662,8 +1661,8 @@ void GDScriptLanguage::init() { List<Engine::Singleton> singletons; Engine::get_singleton()->get_singletons(&singletons); - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { - _add_global(E->get().name, E->get().ptr); + for (Engine::Singleton &E : singletons) { + _add_global(E.name, E.ptr); } #ifdef TESTS_ENABLED @@ -1806,10 +1805,10 @@ void GDScriptLanguage::reload_all_scripts() { scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) { - print_verbose("GDScript: Reloading: " + E->get()->get_path()); - E->get()->load_source_code(E->get()->get_path()); - E->get()->reload(true); + for (Ref<GDScript> E : scripts) { + print_verbose("GDScript: Reloading: " + E->get_path()); + E->load_source_code(E->get_path()); + E->reload(true); } #endif } @@ -1838,21 +1837,21 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so scripts.sort_custom<GDScriptDepSort>(); //update in inheritance dependency order - for (List<Ref<GDScript>>::Element *E = scripts.front(); E; E = E->next()) { - bool reload = E->get() == p_script || to_reload.has(E->get()->get_base()); + for (Ref<GDScript> E : scripts) { + bool reload = E == p_script || to_reload.has(E->get_base()); if (!reload) { continue; } - to_reload.insert(E->get(), Map<ObjectID, List<Pair<StringName, Variant>>>()); + to_reload.insert(E, Map<ObjectID, List<Pair<StringName, Variant>>>()); if (!p_soft_reload) { //save state and remove script from instances - Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[E->get()]; + Map<ObjectID, List<Pair<StringName, Variant>>> &map = to_reload[E]; - while (E->get()->instances.front()) { - Object *obj = E->get()->instances.front()->get(); + while (E->instances.front()) { + Object *obj = E->instances.front()->get(); //save instance info List<Pair<StringName, Variant>> state; if (obj->get_script_instance()) { @@ -1865,8 +1864,8 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so //same thing for placeholders #ifdef TOOLS_ENABLED - while (E->get()->placeholders.size()) { - Object *obj = E->get()->placeholders.front()->get()->get_owner(); + while (E->placeholders.size()) { + Object *obj = E->placeholders.front()->get()->get_owner(); //save instance info if (obj->get_script_instance()) { @@ -1876,13 +1875,13 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so obj->set_script(Variant()); } else { // no instance found. Let's remove it so we don't loop forever - E->get()->placeholders.erase(E->get()->placeholders.front()->get()); + E->placeholders.erase(E->placeholders.front()->get()); } } #endif - for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->get()->pending_reload_state.front(); F; F = F->next()) { + for (Map<ObjectID, List<Pair<StringName, Variant>>>::Element *F = E->pending_reload_state.front(); F; F = F->next()) { map[F->key()] = F->get(); //pending to reload, use this one instead } } @@ -2025,8 +2024,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - p_words->push_back(String(E->get())); + for (const StringName &E : functions) { + p_words->push_back(String(E)); } } @@ -2296,8 +2295,8 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S return; } - for (const List<String>::Element *E = parser.get_dependencies().front(); E; E = E->next()) { - p_dependencies->push_back(E->get()); + for (const String &E : parser.get_dependencies()) { + p_dependencies->push_back(E); } } diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e7fb33a6a7..ab37e54cf1 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -115,8 +115,8 @@ static GDScriptParser::DataType make_native_enum_type(const StringName &p_native StringName real_native_name = GDScriptParser::get_real_class_name(p_native_class); ClassDB::get_enum_constants(real_native_name, p_enum_name, &enum_values); - for (const List<StringName>::Element *E = enum_values.front(); E != nullptr; E = E->next()) { - type.enum_values[E->get()] = ClassDB::get_integer_constant(real_native_name, E->get()); + for (const StringName &E : enum_values) { + type.enum_values[E] = ClassDB::get_integer_constant(real_native_name, E); } return type; @@ -573,8 +573,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.variable->set_datatype(datatype); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.variable->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.variable); + for (GDScriptParser::AnnotationNode *&E : member.variable->annotations) { + E->apply(parser, member.variable); } } break; case GDScriptParser::ClassNode::Member::CONSTANT: { @@ -622,8 +622,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.constant->set_datatype(datatype); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.constant->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.constant); + for (GDScriptParser::AnnotationNode *&E : member.constant->annotations) { + E->apply(parser, member.constant); } } break; case GDScriptParser::ClassNode::Member::SIGNAL: { @@ -641,8 +641,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.signal->set_datatype(signal_type); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.signal->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.signal); + for (GDScriptParser::AnnotationNode *&E : member.signal->annotations) { + E->apply(parser, member.signal); } } break; case GDScriptParser::ClassNode::Member::ENUM: { @@ -688,8 +688,8 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas member.m_enum->set_datatype(enum_type); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.m_enum->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.m_enum); + for (GDScriptParser::AnnotationNode *&E : member.m_enum->annotations) { + E->apply(parser, member.m_enum); } } break; case GDScriptParser::ClassNode::Member::FUNCTION: @@ -761,8 +761,8 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class) { resolve_function_body(member.function); // Apply annotations. - for (List<GDScriptParser::AnnotationNode *>::Element *E = member.function->annotations.front(); E; E = E->next()) { - E->get()->apply(parser, member.function); + for (GDScriptParser::AnnotationNode *&E : member.function->annotations) { + E->apply(parser, member.function); } } @@ -1927,9 +1927,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa Variant::get_constructor_list(builtin_type, &constructors); bool match = false; - for (const List<MethodInfo>::Element *E = constructors.front(); E != nullptr; E = E->next()) { - const MethodInfo &info = E->get(); - + for (const MethodInfo &info : constructors) { if (p_call->arguments.size() < info.arguments.size() - info.default_arguments.size()) { continue; } @@ -2326,8 +2324,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod Variant::construct(base.builtin_type, dummy, nullptr, 0, temp); List<PropertyInfo> properties; dummy.get_property_list(&properties); - for (const List<PropertyInfo>::Element *E = properties.front(); E != nullptr; E = E->next()) { - const PropertyInfo &prop = E->get(); + for (const PropertyInfo &prop : properties) { if (prop.name == name) { p_identifier->set_datatype(type_from_property(prop)); return; @@ -3125,8 +3122,8 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_variant(const Variant &p_va GDScriptParser::ClassNode *found = ref->get_parser()->head; // It should be okay to assume this exists, since we have a complete script already. - for (const List<StringName>::Element *E = class_chain.front(); E; E = E->next()) { - found = found->get_member(E->get()).m_class; + for (const StringName &E : class_chain) { + found = found->get_member(E).m_class; } result.class_type = found; @@ -3222,9 +3219,9 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, GD List<MethodInfo> methods; dummy.get_method_list(&methods); - for (const List<MethodInfo>::Element *E = methods.front(); E != nullptr; E = E->next()) { - if (E->get().name == p_function) { - return function_signature_from_info(E->get(), r_return_type, r_par_types, r_default_arg_count, r_static, r_vararg); + for (const MethodInfo &E : methods) { + if (E.name == p_function) { + return function_signature_from_info(E, r_return_type, r_par_types, r_default_arg_count, r_static, r_vararg); } } @@ -3321,8 +3318,8 @@ bool GDScriptAnalyzer::function_signature_from_info(const MethodInfo &p_info, GD r_default_arg_count = p_info.default_arguments.size(); r_vararg = (p_info.flags & METHOD_FLAG_VARARG) != 0; - for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E != nullptr; E = E->next()) { - r_par_types.push_back(type_from_property(E->get())); + for (const PropertyInfo &E : p_info.arguments) { + r_par_types.push_back(type_from_property(E)); } return true; } @@ -3330,8 +3327,8 @@ bool GDScriptAnalyzer::function_signature_from_info(const MethodInfo &p_info, GD bool GDScriptAnalyzer::validate_call_arg(const MethodInfo &p_method, const GDScriptParser::CallNode *p_call) { List<GDScriptParser::DataType> arg_types; - for (const List<PropertyInfo>::Element *E = p_method.arguments.front(); E != nullptr; E = E->next()) { - arg_types.push_back(type_from_property(E->get())); + for (const PropertyInfo &E : p_method.arguments) { + arg_types.push_back(type_from_property(E)); } return validate_call_arg(arg_types, p_method.default_arguments.size(), (p_method.flags & METHOD_FLAG_VARARG) != 0, p_call); @@ -3658,11 +3655,11 @@ Error GDScriptAnalyzer::resolve_program() { List<String> parser_keys; depended_parsers.get_key_list(&parser_keys); - for (const List<String>::Element *E = parser_keys.front(); E != nullptr; E = E->next()) { - if (depended_parsers[E->get()].is_null()) { + for (const String &E : parser_keys) { + if (depended_parsers[E].is_null()) { return ERR_PARSE_ERROR; } - depended_parsers[E->get()]->raise_status(GDScriptParserRef::FULLY_SOLVED); + depended_parsers[E]->raise_status(GDScriptParserRef::FULLY_SOLVED); } return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR; } diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index 9ff5a342ec..5958326315 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -1459,8 +1459,8 @@ void GDScriptByteCodeGenerator::write_endfor() { } // Patch break statements. - for (const List<int>::Element *E = current_breaks_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : current_breaks_to_patch.back()->get()) { + patch_jump(E); } current_breaks_to_patch.pop_back(); @@ -1494,8 +1494,8 @@ void GDScriptByteCodeGenerator::write_endwhile() { while_jmp_addrs.pop_back(); // Patch break statements. - for (const List<int>::Element *E = current_breaks_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : current_breaks_to_patch.back()->get()) { + patch_jump(E); } current_breaks_to_patch.pop_back(); } @@ -1506,8 +1506,8 @@ void GDScriptByteCodeGenerator::start_match() { void GDScriptByteCodeGenerator::start_match_branch() { // Patch continue statements. - for (const List<int>::Element *E = match_continues_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : match_continues_to_patch.back()->get()) { + patch_jump(E); } match_continues_to_patch.pop_back(); // Start a new list for next branch. @@ -1516,8 +1516,8 @@ void GDScriptByteCodeGenerator::start_match_branch() { void GDScriptByteCodeGenerator::end_match() { // Patch continue statements. - for (const List<int>::Element *E = match_continues_to_patch.back()->get().front(); E; E = E->next()) { - patch_jump(E->get()); + for (const int &E : match_continues_to_patch.back()->get()) { + patch_jump(E); } match_continues_to_patch.pop_back(); } diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index fbe791a109..3289f8978b 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -981,8 +981,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code assigned = prev_base; // Set back the values into their bases. - for (List<ChainInfo>::Element *E = set_chain.front(); E; E = E->next()) { - const ChainInfo &info = E->get(); + for (ChainInfo &info : set_chain) { if (!info.is_named) { gen->write_set(info.base, info.key, assigned); if (info.key.mode == GDScriptCodeGenerator::Address::TEMPORARY) { diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 79023df284..3ac9db3645 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -141,8 +141,8 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li } #ifdef DEBUG_ENABLED if (r_warnings) { - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E; E = E->next()) { - const GDScriptWarning &warn = E->get(); + for (const GDScriptWarning &E : parser.get_warnings()) { + const GDScriptWarning &warn = E; ScriptLanguage::Warning w; w.start_line = warn.start_line; w.end_line = warn.end_line; @@ -157,8 +157,8 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li #endif if (err) { if (r_errors) { - for (const List<GDScriptParser::ParserError>::Element *E = parser.get_errors().front(); E; E = E->next()) { - const GDScriptParser::ParserError &pe = E->get(); + for (const GDScriptParser::ParserError &E : parser.get_errors()) { + const GDScriptParser::ParserError &pe = E; ScriptLanguage::ScriptError e; e.line = pe.line; e.column = pe.column; @@ -319,9 +319,9 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p List<Pair<StringName, int>> locals; f->debug_get_stack_member_state(*_call_stack[l].line, &locals); - for (List<Pair<StringName, int>>::Element *E = locals.front(); E; E = E->next()) { - p_locals->push_back(E->get().first); - p_values->push_back(_call_stack[l].stack[E->get().second]); + for (Pair<StringName, int> &E : locals) { + p_locals->push_back(E.first); + p_values->push_back(_call_stack[l].stack[E.second]); } } @@ -421,8 +421,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - p_functions->push_back(GDScriptUtilityFunctions::get_function_info(E->get())); + for (const StringName &E : functions) { + p_functions->push_back(GDScriptUtilityFunctions::get_function_info(E)); } // Not really "functions", but show in documentation. @@ -548,7 +548,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool int def_args = p_info.arguments.size() - p_info.default_arguments.size(); int i = 0; - for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E; E = E->next()) { + for (const PropertyInfo &E : p_info.arguments) { if (i > 0) { arghint += ", "; } @@ -556,7 +556,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool if (i == p_arg_idx) { arghint += String::chr(0xFFFF); } - arghint += E->get().name + ": " + _get_visual_datatype(E->get(), true); + arghint += E.name + ": " + _get_visual_datatype(E, true); if (i - def_args >= 0) { arghint += String(" = ") + p_info.default_arguments[i - def_args].get_construct_string(); @@ -662,11 +662,11 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a r_result.insert(node.display, node); List<StringName> node_types; ClassDB::get_inheriters_from_class("Node", &node_types); - for (const List<StringName>::Element *E = node_types.front(); E != nullptr; E = E->next()) { - if (!ClassDB::is_class_exposed(E->get())) { + for (const StringName &E : node_types) { + if (!ClassDB::is_class_exposed(E)) { continue; } - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } } @@ -675,9 +675,9 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptCodeCompletionOption> &r_result) { List<StringName> native_types; ClassDB::get_class_list(&native_types); - for (const List<StringName>::Element *E = native_types.front(); E != nullptr; E = E->next()) { - if (ClassDB::is_class_exposed(E->get()) && !Engine::get_singleton()->has_singleton(E->get())) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + for (const StringName &E : native_types) { + if (ClassDB::is_class_exposed(E) && !Engine::get_singleton()->has_singleton(E)) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } } @@ -687,8 +687,8 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio // Native enums from base class List<StringName> enums; ClassDB::get_enum_list(p_context.current_class->base_type.native_type, &enums); - for (const List<StringName>::Element *E = enums.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_ENUM); + for (const StringName &E : enums) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_ENUM); r_result.insert(option.display, option); } } @@ -725,8 +725,8 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio // Global scripts List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (const List<StringName>::Element *E = global_classes.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CLASS); + for (const StringName &E : global_classes) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS); r_result.insert(option.display, option); } @@ -865,8 +865,8 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!_static) { List<PropertyInfo> members; scr->get_script_property_list(&members); - for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + for (PropertyInfo &E : members) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -879,20 +879,20 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> signals; scr->get_script_signal_list(&signals); - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_SIGNAL); + for (MethodInfo &E : signals) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_SIGNAL); r_result.insert(option.display, option); } } List<MethodInfo> methods; scr->get_script_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("@")) { + for (MethodInfo &E : methods) { + if (E.name.begins_with("@")) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -920,22 +920,22 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!p_only_functions) { List<String> constants; ClassDB::get_integer_constant_list(type, &constants); - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CONSTANT); + for (String &E : constants) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); r_result.insert(option.display, option); } if (!_static || Engine::get_singleton()->has_singleton(type)) { List<PropertyInfo> pinfo; ClassDB::get_property_list(type, &pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) { + for (PropertyInfo &E : pinfo) { + if (E.usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) { continue; } - if (E->get().name.find("/") != -1) { + if (E.name.find("/") != -1) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -945,12 +945,12 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> methods; bool is_autocompleting_getters = GLOBAL_GET("debug/gdscript/completion/autocomplete_setters_and_getters").booleanize(); ClassDB::get_method_list(type, &methods, false, !is_autocompleting_getters); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("_")) { + for (MethodInfo &E : methods) { + if (E.name.begins_with("_")) { continue; } - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -977,9 +977,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base tmp.get_property_list(&members); } - for (List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - if (String(E->get().name).find("/") == -1) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_MEMBER); + for (PropertyInfo &E : members) { + if (String(E.name).find("/") == -1) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } } @@ -987,9 +987,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List<MethodInfo> methods; tmp.get_method_list(&methods); - for (const List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name, ScriptCodeCompletionOption::KIND_FUNCTION); - if (E->get().arguments.size()) { + for (const MethodInfo &E : methods) { + ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION); + if (E.arguments.size()) { option.insert_text += "("; } else { option.insert_text += "()"; @@ -1019,9 +1019,9 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool List<StringName> functions; GDScriptUtilityFunctions::get_function_list(&functions); - for (const List<StringName>::Element *E = functions.front(); E; E = E->next()) { - MethodInfo function = GDScriptUtilityFunctions::get_function_info(E->get()); - ScriptCodeCompletionOption option(String(E->get()), ScriptCodeCompletionOption::KIND_FUNCTION); + for (const StringName &E : functions) { + MethodInfo function = GDScriptUtilityFunctions::get_function_info(E); + ScriptCodeCompletionOption option(String(E), ScriptCodeCompletionOption::KIND_FUNCTION); if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) { option.insert_text += "("; } else { @@ -1768,9 +1768,9 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context, StringName real_native = GDScriptParser::get_real_class_name(base_type.native_type); MethodInfo info; if (ClassDB::get_method_info(real_native, p_context.current_function->identifier->name, &info)) { - for (const List<PropertyInfo>::Element *E = info.arguments.front(); E; E = E->next()) { - if (E->get().name == p_identifier) { - r_type = _type_from_property(E->get()); + for (const PropertyInfo &E : info.arguments) { + if (E.name == p_identifier) { + r_type = _type_from_property(E); return true; } } @@ -1932,8 +1932,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext & if (!is_static) { List<PropertyInfo> members; scr->get_script_property_list(&members); - for (const List<PropertyInfo>::Element *E = members.front(); E; E = E->next()) { - const PropertyInfo &prop = E->get(); + for (const PropertyInfo &prop : members) { if (prop.name == p_identifier) { r_type = _type_from_property(prop); return true; @@ -2096,8 +2095,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex if (scr.is_valid()) { List<MethodInfo> methods; scr->get_script_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2137,8 +2135,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex List<MethodInfo> methods; tmp.get_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2183,8 +2180,8 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co List<StringName> enum_constants; ClassDB::get_enum_constants(class_name, enum_name, &enum_constants); - for (List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - String candidate = class_name + "." + E->get(); + for (StringName &E : enum_constants) { + String candidate = class_name + "." + E; ScriptCodeCompletionOption option(candidate, ScriptCodeCompletionOption::KIND_ENUM); r_result.insert(option.display, option); } @@ -2228,8 +2225,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (obj) { List<String> options; obj->get_argument_options(p_method, p_argidx, &options); - for (List<String>::Element *F = options.front(); F; F = F->next()) { - ScriptCodeCompletionOption option(F->get(), ScriptCodeCompletionOption::KIND_FUNCTION); + for (String &F : options) { + ScriptCodeCompletionOption option(F, ScriptCodeCompletionOption::KIND_FUNCTION); r_result.insert(option.display, option); } } @@ -2250,8 +2247,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String s = E->get().name; + for (PropertyInfo &E : props) { + String s = E.name; if (!s.begins_with("autoload/")) { continue; } @@ -2266,8 +2263,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c // Get input actions List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String s = E->get().name; + for (PropertyInfo &E : props) { + String s = E.name; if (!s.begins_with("input/")) { continue; } @@ -2291,9 +2288,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<MethodInfo> methods; base.get_method_list(&methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == p_method) { - r_arghint = _make_arguments_hint(E->get(), p_argidx); + for (MethodInfo &E : methods) { + if (E.name == p_method) { + r_arghint = _make_arguments_hint(E, p_argidx); return; } } @@ -2340,14 +2337,14 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); int i = 0; - for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) { - if (p_argidx >= E->get().arguments.size()) { + for (MethodInfo &E : constructors) { + if (p_argidx >= E.arguments.size()) { continue; } if (i > 0) { r_arghint += "\n"; } - r_arghint += _make_arguments_hint(E->get(), p_argidx); + r_arghint += _make_arguments_hint(E, p_argidx); i++; } return; @@ -2406,9 +2403,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c case GDScriptParser::COMPLETION_ANNOTATION: { List<MethodInfo> annotations; parser.get_annotation_list(&annotations); - for (const List<MethodInfo>::Element *E = annotations.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get().name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); - if (E->get().arguments.size() > 0) { + for (const MethodInfo &E : annotations) { + ScriptCodeCompletionOption option(E.name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + if (E.arguments.size() > 0) { option.insert_text += "("; } options.insert(option.display, option); @@ -2426,10 +2423,10 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { List<StringName> constants; Variant::get_constants_for_type(completion_context.builtin_type, &constants); - for (const List<StringName>::Element *E = constants.front(); E != nullptr; E = E->next()) { - ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_CONSTANT); + for (const StringName &E : constants) { + ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); bool valid = false; - Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E->get(), &valid); + Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E, &valid); if (valid) { option.default_value = default_value; } @@ -2606,8 +2603,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<MethodInfo> virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods); - for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : virtual_methods) { String method_hint = mi.name; if (method_hint.find(":") != -1) { method_hint = method_hint.get_slice(":", 0); @@ -2656,8 +2652,8 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List<String> opts; p_owner->get_argument_options("get_node", 0, &opts); - for (List<String>::Element *E = opts.front(); E; E = E->next()) { - String opt = E->get().strip_edges(); + for (String &E : opts) { + String opt = E.strip_edges(); if (opt.is_quoted()) { r_forced = true; String idopt = opt.unquote(); @@ -2841,8 +2837,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List<MethodInfo> virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods, true); - for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) { - if (E->get().name == p_symbol) { + for (MethodInfo &E : virtual_methods) { + if (E.name == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; @@ -2860,8 +2856,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List<String> constants; ClassDB::get_integer_constant_list(class_name, &constants, true); - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == p_symbol) { + for (String &E : constants) { + if (E == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = base_type.native_type; r_result.class_member = p_symbol; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index f300d5a2c9..876c508689 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -94,8 +94,7 @@ struct _GDFKCS { void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const { int oc = 0; Map<StringName, _GDFKC> sdmap; - for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) { - const StackDebug &sd = E->get(); + for (const StackDebug &sd : stack_debug) { if (sd.line > p_line) { break; } @@ -131,10 +130,10 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String stackpositions.sort(); - for (List<_GDFKCS>::Element *E = stackpositions.front(); E; E = E->next()) { + for (_GDFKCS &E : stackpositions) { Pair<StringName, int> p; - p.first = E->get().id; - p.second = E->get().pos; + p.first = E.id; + p.second = E.pos; r_stackvars->push_back(p); } } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index e103d86b15..9949d0db56 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -136,8 +136,8 @@ void GDScriptParser::cleanup() { void GDScriptParser::get_annotation_list(List<MethodInfo> *r_annotations) const { List<StringName> keys; valid_annotations.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E != nullptr; E = E->next()) { - r_annotations->push_back(valid_annotations[E->get()].info); + for (const StringName &E : keys) { + r_annotations->push_back(valid_annotations[E].info); } } @@ -248,7 +248,7 @@ void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_ warning.rightmost_column = p_source->rightmost_column; List<GDScriptWarning>::Element *before = nullptr; - for (List<GDScriptWarning>::Element *E = warnings.front(); E != nullptr; E = E->next()) { + for (List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) { if (E->get().start_line > warning.start_line) { break; } @@ -1332,8 +1332,7 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali } void GDScriptParser::clear_unused_annotations() { - for (const List<AnnotationNode *>::Element *E = annotation_stack.front(); E != nullptr; E = E->next()) { - AnnotationNode *annotation = E->get(); + for (AnnotationNode *annotation : annotation_stack) { push_error(vformat(R"(Annotation "%s" does not precedes a valid target, so it will have no effect.)", annotation->name), annotation); } @@ -1796,8 +1795,8 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() { List<StringName> binds; branch->patterns[0]->binds.get_key_list(&binds); - for (List<StringName>::Element *E = binds.front(); E != nullptr; E = E->next()) { - SuiteNode::Local local(branch->patterns[0]->binds[E->get()], current_function); + for (StringName &E : binds) { + SuiteNode::Local local(branch->patterns[0]->binds[E], current_function); suite->add_local(local); } } @@ -3993,8 +3992,8 @@ void GDScriptParser::TreePrinter::print_for(ForNode *p_for) { } void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, const String &p_context) { - for (const List<AnnotationNode *>::Element *E = p_function->annotations.front(); E != nullptr; E = E->next()) { - print_annotation(E->get()); + for (AnnotationNode *E : p_function->annotations) { + print_annotation(E); } push_text(p_context); push_text(" "); @@ -4333,8 +4332,8 @@ void GDScriptParser::TreePrinter::print_unary_op(UnaryOpNode *p_unary_op) { } void GDScriptParser::TreePrinter::print_variable(VariableNode *p_variable) { - for (const List<AnnotationNode *>::Element *E = p_variable->annotations.front(); E != nullptr; E = E->next()) { - print_annotation(E->get()); + for (AnnotationNode *E : p_variable->annotations) { + print_annotation(E); } push_text("Variable "); diff --git a/modules/gdscript/gdscript_utility_functions.cpp b/modules/gdscript/gdscript_utility_functions.cpp index 64c629662c..62531473c3 100644 --- a/modules/gdscript/gdscript_utility_functions.cpp +++ b/modules/gdscript/gdscript_utility_functions.cpp @@ -706,8 +706,8 @@ bool GDScriptUtilityFunctions::function_exists(const StringName &p_function) { } void GDScriptUtilityFunctions::get_function_list(List<StringName> *r_functions) { - for (const List<StringName>::Element *E = utility_function_name_table.front(); E; E = E->next()) { - r_functions->push_back(E->get()); + for (const StringName &E : utility_function_name_table) { + r_functions->push_back(E); } } diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index e9a7bf3830..eb68e38840 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -39,8 +39,7 @@ void ExtendGDScriptParser::update_diagnostics() { diagnostics.clear(); const List<ParserError> &errors = get_errors(); - for (const List<ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const ParserError &error = E->get(); + for (const ParserError &error : errors) { lsp::Diagnostic diagnostic; diagnostic.severity = lsp::DiagnosticSeverity::Error; diagnostic.message = error.message; @@ -61,8 +60,7 @@ void ExtendGDScriptParser::update_diagnostics() { } const List<GDScriptWarning> &warnings = get_warnings(); - for (const List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) { - const GDScriptWarning &warning = E->get(); + for (const GDScriptWarning &warning : warnings) { lsp::Diagnostic diagnostic; diagnostic.severity = lsp::DiagnosticSeverity::Warning; diagnostic.message = "(" + warning.get_name() + "): " + warning.get_message(); @@ -467,8 +465,8 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) { } String doc; - for (List<String>::Element *E = doc_lines.front(); E; E = E->next()) { - doc += E->get() + "\n"; + for (String &E : doc_lines) { + doc += E + "\n"; } return doc; } diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index 55aff618aa..69ddbe5d1e 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -157,8 +157,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) { int i = 0; arr.resize(options.size()); - for (const List<ScriptCodeCompletionOption>::Element *E = options.front(); E; E = E->next()) { - const ScriptCodeCompletionOption &option = E->get(); + for (const ScriptCodeCompletionOption &option : options) { lsp::CompletionItem item; item.label = option.display; item.data = request_data; @@ -294,8 +293,8 @@ Array GDScriptTextDocument::documentLink(const Dictionary &p_params) { List<lsp::DocumentLink> links; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_document_links(params.textDocument.uri, links); - for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) { - ret.push_back(E->get().to_json()); + for (const lsp::DocumentLink &E : links) { + ret.push_back(E.to_json()); } return ret; } @@ -322,8 +321,8 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) { Array contents; List<const lsp::DocumentSymbol *> list; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list); - for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) { - if (const lsp::DocumentSymbol *s = E->get()) { + for (const lsp::DocumentSymbol *&E : list) { + if (const lsp::DocumentSymbol *s = E) { contents.push_back(s->render().value); } } @@ -430,8 +429,8 @@ Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams & } else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) { List<const lsp::DocumentSymbol *> list; GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(p_location, list); - for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) { - if (const lsp::DocumentSymbol *s = E->get()) { + for (const lsp::DocumentSymbol *&E : list) { + if (const lsp::DocumentSymbol *s = E) { if (!s->uri.is_empty()) { lsp::Location location; location.uri = s->uri; diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 1915c92cbf..eb60433859 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -119,8 +119,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_ void GDScriptWorkspace::reload_all_workspace_scripts() { List<String> paths; list_script_files("res://", paths); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - const String &path = E->get(); + for (String &path : paths) { Error err; String content = FileAccess::get_file_as_string(path, &err); ERR_CONTINUE(err != OK); @@ -559,8 +558,8 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) { if (const ExtendGDScriptParser *parser = get_parse_successed_script(get_file_path(p_uri))) { const List<lsp::DocumentLink> &links = parser->get_document_links(); - for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) { - r_list.push_back(E->get()); + for (const lsp::DocumentLink &E : links) { + r_list.push_back(E); } } } @@ -587,8 +586,7 @@ Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(text_pos, symbols); } - for (List<const lsp::DocumentSymbol *>::Element *E = symbols.front(); E; E = E->next()) { - const lsp::DocumentSymbol *symbol = E->get(); + for (const lsp::DocumentSymbol *symbol : symbols) { if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) { lsp::SignatureInformation signature_info; signature_info.label = symbol->detail; diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp index b7faebb4ef..03a48bf071 100644 --- a/modules/gdscript/tests/gdscript_test_runner.cpp +++ b/modules/gdscript/tests/gdscript_test_runner.cpp @@ -295,7 +295,7 @@ void GDScriptTestRunner::handle_cmdline() { String test_cmd = "--gdscript-test"; String gen_cmd = "--gdscript-generate-tests"; - for (List<String>::Element *E = cmdline_args.front(); E != nullptr; E = E->next()) { + for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { String &cmd = E->get(); if (cmd == test_cmd || cmd == gen_cmd) { if (E->next() == nullptr) { @@ -440,8 +440,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { result.output = get_text_for_status(result.status) + "\n"; const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E; E = E->next()) { - result.output += E->get().message + "\n"; // TODO: line, column? + for (const GDScriptParser::ParserError &E : errors) { + result.output += E.message + "\n"; // TODO: line, column? break; // Only the first error since the following might be cascading. } if (!p_is_generating) { @@ -459,8 +459,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { result.output = get_text_for_status(result.status) + "\n"; const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E; E = E->next()) { - result.output += E->get().message + "\n"; // TODO: line, column? + for (const GDScriptParser::ParserError &E : errors) { + result.output += E.message + "\n"; // TODO: line, column? break; // Only the first error since the following might be cascading. } if (!p_is_generating) { @@ -470,8 +470,8 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) { } StringBuilder warning_string; - for (const List<GDScriptWarning>::Element *E = parser.get_warnings().front(); E != nullptr; E = E->next()) { - const GDScriptWarning warning = E->get(); + for (const GDScriptWarning &E : parser.get_warnings()) { + const GDScriptWarning warning = E; warning_string.append(">> WARNING"); warning_string.append("\n>> Line: "); warning_string.append(itos(warning.start_line)); diff --git a/modules/gdscript/tests/test_gdscript.cpp b/modules/gdscript/tests/test_gdscript.cpp index 7aa5895981..52e9d92223 100644 --- a/modules/gdscript/tests/test_gdscript.cpp +++ b/modules/gdscript/tests/test_gdscript.cpp @@ -113,8 +113,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const if (err != OK) { const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } } @@ -124,8 +123,7 @@ static void test_parser(const String &p_code, const String &p_script_path, const if (err != OK) { const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } } @@ -143,8 +141,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con if (err != OK) { print_line("Error in parser:"); const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } return; @@ -156,8 +153,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con if (err != OK) { print_line("Error in analyzer:"); const List<GDScriptParser::ParserError> &errors = parser.get_errors(); - for (const List<GDScriptParser::ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) { - const GDScriptParser::ParserError &error = E->get(); + for (const GDScriptParser::ParserError &error : errors) { print_line(vformat("%02d:%02d: %s", error.line, error.column, error.message)); } return; diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 0cd41133f1..ca461566d3 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -519,14 +519,14 @@ bool GridMap::_octant_update(const OctantKey &p_key) { RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; - for (List<Pair<Transform3D, IndexKey>>::Element *F = E->get().front(); F; F = F->next()) { - RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first); + for (Pair<Transform3D, IndexKey> &F : E->get()) { + RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F.first); #ifdef TOOLS_ENABLED Octant::MultimeshInstance::Item it; it.index = idx; - it.transform = F->get().first; - it.key = F->get().second; + it.transform = F.first; + it.key = F.second; mmi.items.push_back(it); #endif diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 046f8c0adb..9530122e04 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -497,8 +497,8 @@ void GridMapEditor::_fill_selection() { } void GridMapEditor::_clear_clipboard_data() { - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get().instance); + for (ClipboardItem &E : clipboard_items) { + RenderingServer::get_singleton()->free(E.instance); } clipboard_items.clear(); @@ -552,9 +552,7 @@ void GridMapEditor::_update_paste_indicator() { RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf); - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - ClipboardItem &item = E->get(); - + for (ClipboardItem &item : clipboard_items) { xf = Transform3D(); xf.origin = (paste_indicator.begin + (paste_indicator.current - paste_indicator.click) + center) * node->get_cell_size(); xf.basis = rot * xf.basis; @@ -578,9 +576,7 @@ void GridMapEditor::_do_paste() { Vector3 ofs = paste_indicator.current - paste_indicator.click; undo_redo->create_action(TTR("GridMap Paste Selection")); - for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - ClipboardItem &item = E->get(); - + for (ClipboardItem &item : clipboard_items) { Vector3 position = rot.xform(item.grid_offset) + paste_indicator.begin + ofs; Basis orm; @@ -663,8 +659,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In if ((mb->get_button_index() == MOUSE_BUTTON_RIGHT && input_action == INPUT_ERASE) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && input_action == INPUT_PAINT)) { if (set_items.size()) { undo_redo->create_action(TTR("GridMap Paint")); - for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) { - const SetItem &si = E->get(); + for (SetItem &si : set_items) { undo_redo->add_do_method(node, "set_cell_item", si.position, si.new_value, si.new_orientation); } for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) { @@ -869,8 +864,8 @@ void GridMapEditor::update_palette() { int item = 0; - for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) { - int id = E->get().id; + for (_CGMEItemSort &E : il) { + int id = E.id; String name = mesh_library->get_item_name(id); Ref<Texture2D> preview = mesh_library->get_item_preview(id); diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 25193a1352..01d0e13515 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -50,8 +50,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - ClassDB::ClassInfo *t = ClassDB::classes.getptr(E->get()); + for (StringName &E : names) { + ClassDB::ClassInfo *t = ClassDB::classes.getptr(E); ERR_FAIL_COND(!t); if (t->api != p_api || !t->exposed) { continue; @@ -84,11 +84,11 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array methods; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary method_dict; methods.push_back(method_dict); - MethodBind *mb = t->method_map[F->get()]; + MethodBind *mb = t->method_map[F]; method_dict["name"] = mb->get_name(); method_dict["argument_count"] = mb->get_argument_count(); method_dict["return_type"] = mb->get_argument_type(-1); @@ -141,12 +141,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array constants; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary constant_dict; constants.push_back(constant_dict); - constant_dict["name"] = F->get(); - constant_dict["value"] = t->constant_map[F->get()]; + constant_dict["name"] = F; + constant_dict["value"] = t->constant_map[F]; } if (!constants.is_empty()) { @@ -168,12 +168,12 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array signals; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary signal_dict; signals.push_back(signal_dict); - MethodInfo &mi = t->signal_map[F->get()]; - signal_dict["name"] = F->get(); + MethodInfo &mi = t->signal_map[F]; + signal_dict["name"] = F; Array arguments; signal_dict["arguments"] = arguments; @@ -203,13 +203,13 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array properties; - for (List<StringName>::Element *F = snames.front(); F; F = F->next()) { + for (StringName &F : snames) { Dictionary property_dict; properties.push_back(property_dict); - ClassDB::PropertySetGet *psg = t->property_setget.getptr(F->get()); + ClassDB::PropertySetGet *psg = t->property_setget.getptr(F); - property_dict["name"] = F->get(); + property_dict["name"] = F; property_dict["setter"] = psg->setter; property_dict["getter"] = psg->getter; } @@ -222,15 +222,15 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array property_list; //property list - for (List<PropertyInfo>::Element *F = t->property_list.front(); F; F = F->next()) { + for (PropertyInfo &F : t->property_list) { Dictionary property_dict; property_list.push_back(property_dict); - property_dict["name"] = F->get().name; - property_dict["type"] = F->get().type; - property_dict["hint"] = F->get().hint; - property_dict["hint_string"] = F->get().hint_string; - property_dict["usage"] = F->get().usage; + property_dict["name"] = F.name; + property_dict["type"] = F.type; + property_dict["hint"] = F.hint; + property_dict["hint_string"] = F.hint_string; + property_dict["usage"] = F.usage; } if (!property_list.is_empty()) { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 80675feb3b..0eea0f543b 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -874,9 +874,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // As scripts are going to be reloaded, must proceed without locking here - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> script : scripts) { to_reload.push_back(script); if (script->get_path().is_empty()) { @@ -936,9 +934,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } // After the state of all instances is saved, clear scripts and script instances - for (List<Ref<CSharpScript>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<CSharpScript> &script = E->get(); - + for (Ref<CSharpScript> script : scripts) { while (script->instances.front()) { Object *obj = script->instances.front()->get(); obj->set_script(REF()); // Remove script and existing script instances (placeholder are not removed before domain reload) @@ -951,9 +947,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { if (gdmono->reload_scripts_domain() != OK) { // Failed to reload the scripts domain // Make sure to add the scripts back to their owners before returning - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> scr = E->get(); - + for (Ref<CSharpScript> scr : to_reload) { for (const Map<ObjectID, CSharpScript::StateBackup>::Element *F = scr->pending_reload_state.front(); F; F = F->next()) { Object *obj = ObjectDB::get_instance(F->key()); @@ -988,9 +982,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript>> to_reload_state; - for (List<Ref<CSharpScript>>::Element *E = to_reload.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - + for (Ref<CSharpScript> script : to_reload) { #ifdef TOOLS_ENABLED script->exports_invalidated = true; #endif @@ -1095,9 +1087,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { to_reload_state.push_back(script); } - for (List<Ref<CSharpScript>>::Element *E = to_reload_state.front(); E; E = E->next()) { - Ref<CSharpScript> script = E->get(); - + for (Ref<CSharpScript> script : to_reload_state) { for (Set<ObjectID>::Element *F = script->pending_reload_instances.front(); F; F = F->next()) { ObjectID obj_id = F->get(); Object *obj = ObjectDB::get_instance(obj_id); @@ -1741,9 +1731,9 @@ void CSharpInstance::get_properties_state_for_reloading(List<Pair<StringName, Va List<PropertyInfo> pinfo; get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + for (PropertyInfo &E : pinfo) { Pair<StringName, Variant> state_pair; - state_pair.first = E->get().name; + state_pair.first = E.name; ManagedType managedType; @@ -2049,8 +2039,7 @@ void CSharpInstance::connect_event_signals() { } void CSharpInstance::disconnect_event_signals() { - for (const List<Callable>::Element *E = connected_event_signals.front(); E; E = E->next()) { - const Callable &callable = E->get(); + for (const Callable &callable : connected_event_signals) { const EventSignalCallable *event_signal_callable = static_cast<const EventSignalCallable *>(callable.get_custom()); owner->disconnect(event_signal_callable->get_signal(), callable); } @@ -2324,8 +2313,8 @@ void CSharpScript::_update_exports_values(Map<StringName, Variant> &values, List values[E->key()] = E->get(); } - for (List<PropertyInfo>::Element *E = exported_members_cache.front(); E; E = E->next()) { - propnames.push_back(E->get()); + for (PropertyInfo &E : exported_members_cache) { + propnames.push_back(E); } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 620b031ddb..6ae7c88213 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -416,8 +416,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as global enum constant const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &E : global_enums) { + target_ienum = &E; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -455,8 +455,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf // Try to find as enum constant in the current class const EnumInterface *target_ienum = nullptr; - for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { - target_ienum = &E->get(); + for (const EnumInterface &E : target_itype->enums) { + target_ienum = &E; target_iconst = find_constant_by_name(target_name, target_ienum->constants); if (target_iconst) { break; @@ -682,10 +682,10 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) { if (p_prefix_length > 0) { - for (List<ConstantInterface>::Element *E = p_ienum.constants.front(); E; E = E->next()) { + for (ConstantInterface &E : p_ienum.constants) { int curr_prefix_length = p_prefix_length; - ConstantInterface &curr_const = E->get(); + ConstantInterface &curr_const = E; String constant_name = curr_const.name; @@ -719,9 +719,7 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI } void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { - for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); - + for (const MethodInterface &imethod : p_itype.methods) { if (imethod.is_virtual) { continue; } @@ -735,8 +733,8 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = imethod.arguments.front(); F; F = F->next()) { - const TypeInterface *arg_type = _get_type_or_placeholder(F->get().type); + for (const ArgumentInterface &F : imethod.arguments) { + const TypeInterface *arg_type = _get_type_or_placeholder(F.type); im_sig += ", "; im_sig += arg_type->im_type_in; @@ -776,10 +774,10 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { if (p_itype.api_type != ClassDB::API_EDITOR) { match->get().editor_only = false; } - method_icalls_map.insert(&E->get(), &match->get()); + method_icalls_map.insert(&E, &match->get()); } else { List<InternalCall>::Element *added = method_icalls.push_back(im_icall); - method_icalls_map.insert(&E->get(), &added->get()); + method_icalls_map.insert(&E, &added->get()); } } } @@ -859,9 +857,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK); p_output.append(INDENT1 "public static partial class " BINDINGS_GLOBAL_SCOPE_CLASS "\n" INDENT1 "{"); - for (const List<ConstantInterface>::Element *E = global_constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : global_constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -894,9 +890,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { // Enums - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (EnumInterface &ienum : global_enums) { CRASH_COND(ienum.constants.is_empty()); String enum_proxy_name = ienum.cname.operator String(); @@ -921,8 +915,8 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { p_output.append(enum_proxy_name); p_output.append("\n" INDENT1 OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); + for (const ConstantInterface &F : ienum.constants) { + const ConstantInterface &iconstant = F; if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); @@ -1053,11 +1047,11 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : core_custom_icalls) { + ADD_INTERNAL_CALL(E); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : method_icalls) { + ADD_INTERNAL_CALL(E); } #undef ADD_INTERNAL_CALL @@ -1161,11 +1155,11 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) { cs_icalls_content.append(m_icall.im_sig + ");\n"); \ } - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : editor_custom_icalls) { + ADD_INTERNAL_CALL(E); } - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { - ADD_INTERNAL_CALL(E->get()); + for (const InternalCall &E : method_icalls) { + ADD_INTERNAL_CALL(E); } #undef ADD_INTERNAL_CALL @@ -1327,9 +1321,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add constants - for (const List<ConstantInterface>::Element *E = itype.constants.front(); E; E = E->next()) { - const ConstantInterface &iconstant = E->get(); - + for (const ConstantInterface &iconstant : itype.constants) { if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); @@ -1360,17 +1352,15 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add enums - for (const List<EnumInterface>::Element *E = itype.enums.front(); E; E = E->next()) { - const EnumInterface &ienum = E->get(); - + for (const EnumInterface &ienum : itype.enums) { ERR_FAIL_COND_V(ienum.constants.is_empty(), ERR_BUG); output.append(MEMBER_BEGIN "public enum "); output.append(ienum.cname.operator String()); output.append(MEMBER_BEGIN OPEN_BLOCK); - for (const List<ConstantInterface>::Element *F = ienum.constants.front(); F; F = F->next()) { - const ConstantInterface &iconstant = F->get(); + for (const ConstantInterface &F : ienum.constants) { + const ConstantInterface &iconstant = F; if (iconstant.const_doc && iconstant.const_doc->description.size()) { String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype); @@ -1401,8 +1391,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str // Add properties - for (const List<PropertyInterface>::Element *E = itype.properties.front(); E; E = E->next()) { - const PropertyInterface &iprop = E->get(); + for (const PropertyInterface &iprop : itype.properties) { Error prop_err = _generate_cs_property(itype, iprop, output); ERR_FAIL_COND_V_MSG(prop_err != OK, prop_err, "Failed to generate property '" + iprop.cname.operator String() + @@ -1463,15 +1452,13 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str } int method_bind_count = 0; - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_cs_method(itype, imethod, method_bind_count, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); } - for (const List<SignalInterface>::Element *E = itype.signals_.front(); E; E = E->next()) { - const SignalInterface &isignal = E->get(); + for (const SignalInterface &isignal : itype.signals_) { Error method_err = _generate_cs_signal(itype, isignal, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate signal '" + isignal.name + "' for class '" + itype.name + "'."); @@ -1678,8 +1665,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf StringBuilder default_args_doc; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_imethod.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -1855,9 +1842,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf p_output.append(p_imethod.name); p_output.append("\""); - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { + for (const ArgumentInterface &F : p_imethod.arguments) { p_output.append(", "); - p_output.append(F->get().name); + p_output.append(F.name); } p_output.append(");\n" CLOSE_BLOCK_L2); @@ -1899,8 +1886,8 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf String arguments_sig; // Retrieve information from the arguments - for (const List<ArgumentInterface>::Element *F = p_isignal.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_isignal.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG, @@ -2042,8 +2029,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { String ctor_method(ICALL_PREFIX + itype.proxy_name + "_Ctor"); // Used only for derived types - for (const List<MethodInterface>::Element *E = itype.methods.front(); E; E = E->next()) { - const MethodInterface &imethod = E->get(); + for (const MethodInterface &imethod : itype.methods) { Error method_err = _generate_glue_method(itype, imethod, output); ERR_FAIL_COND_V_MSG(method_err != OK, method_err, "Failed to generate method '" + imethod.name + "' for class '" + itype.name + "'."); @@ -2114,20 +2100,20 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } bool tools_sequence = false; - for (const List<InternalCall>::Element *E = core_custom_icalls.front(); E; E = E->next()) { + for (const InternalCall &E : core_custom_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!E.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (E.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(E); } if (tools_sequence) { @@ -2136,24 +2122,24 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { } output.append("#ifdef TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = editor_custom_icalls.front(); E; E = E->next()) - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + for (const InternalCall &E : editor_custom_icalls) + ADD_INTERNAL_CALL_REGISTRATION(E); output.append("#endif // TOOLS_ENABLED\n"); - for (const List<InternalCall>::Element *E = method_icalls.front(); E; E = E->next()) { + for (const InternalCall &E : method_icalls) { if (tools_sequence) { - if (!E->get().editor_only) { + if (!E.editor_only) { tools_sequence = false; output.append("#endif\n"); } } else { - if (E->get().editor_only) { + if (E.editor_only) { output.append("#ifdef TOOLS_ENABLED\n"); tools_sequence = true; } } - ADD_INTERNAL_CALL_REGISTRATION(E->get()); + ADD_INTERNAL_CALL_REGISTRATION(E); } if (tools_sequence) { @@ -2209,8 +2195,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte // Get arguments information int i = 0; - for (const List<ArgumentInterface>::Element *F = p_imethod.arguments.front(); F; F = F->next()) { - const ArgumentInterface &iarg = F->get(); + for (const ArgumentInterface &F : p_imethod.arguments) { + const ArgumentInterface &iarg = F; const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type); String c_param_name = "arg" + itos(i + 1); @@ -2623,9 +2609,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { Map<StringName, StringName> accessor_methods; - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - const PropertyInfo &property = E->get(); - + for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; } @@ -2684,8 +2668,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_method_list(type_cname, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - const MethodInfo &method_info = E->get(); + for (MethodInfo &E : method_list) { + const MethodInfo &method_info = E; int argc = method_info.arguments.size(); @@ -2840,8 +2824,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // Classes starting with an underscore are ignored unless they're used as a property setter or getter if (!imethod.is_virtual && imethod.name[0] == '_') { - for (const List<PropertyInterface>::Element *F = itype.properties.front(); F; F = F->next()) { - const PropertyInterface &iprop = F->get(); + for (const PropertyInterface &F : itype.properties) { + const PropertyInterface &iprop = F; if (iprop.setter == imethod.name || iprop.getter == imethod.name) { imethod.is_internal = true; @@ -2952,8 +2936,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() { } EnumInterface ienum(enum_proxy_cname); const List<StringName> &enum_constants = enum_map.get(*k); - for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - const StringName &constant_cname = E->get(); + for (const StringName &E : enum_constants) { + const StringName &constant_cname = E; String constant_name = constant_cname.operator String(); int *value = class_info->constant_map.getptr(constant_cname); ERR_FAIL_NULL_V(value, false); @@ -2989,9 +2973,9 @@ bool BindingsGenerator::_populate_object_type_interfaces() { enum_types.insert(enum_itype.cname, enum_itype); } - for (const List<String>::Element *E = constants.front(); E; E = E->next()) { - const String &constant_name = E->get(); - int *value = class_info->constant_map.getptr(StringName(E->get())); + for (const String &E : constants) { + const String &constant_name = E; + int *value = class_info->constant_map.getptr(StringName(E)); ERR_FAIL_NULL_V(value, false); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -3539,9 +3523,7 @@ void BindingsGenerator::_populate_global_constants() { } } - for (List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { - EnumInterface &ienum = E->get(); - + for (EnumInterface &ienum : global_enums) { TypeInterface enum_itype; enum_itype.is_enum = true; enum_itype.name = ienum.cname.operator String(); @@ -3571,13 +3553,13 @@ void BindingsGenerator::_populate_global_constants() { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) { + for (StringName &E : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore TypeInterface enum_itype; enum_itype.is_enum = true; - enum_itype.name = E->get().operator String(); - enum_itype.cname = E->get(); + enum_itype.name = E.operator String(); + enum_itype.cname = E; enum_itype.proxy_name = enum_itype.name; TypeInterface::postsetup_enum_type(enum_itype); enum_types.insert(enum_itype.cname, enum_itype); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 48c0e02723..a649181b20 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -357,9 +357,9 @@ class BindingsGenerator { List<SignalInterface> signals_; const MethodInterface *find_method_by_name(const StringName &p_cname) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.cname == p_cname) { + return &E; } } @@ -367,9 +367,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_name(const StringName &p_cname) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().cname == p_cname) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.cname == p_cname) { + return &E; } } @@ -377,9 +377,9 @@ class BindingsGenerator { } const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { - for (const List<PropertyInterface>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const PropertyInterface &E : properties) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -387,9 +387,9 @@ class BindingsGenerator { } const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { - for (const List<MethodInterface>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().proxy_name == p_proxy_name) { - return &E->get(); + for (const MethodInterface &E : methods) { + if (E.proxy_name == p_proxy_name) { + return &E; } } @@ -613,9 +613,9 @@ class BindingsGenerator { } const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { - for (const List<ConstantInterface>::Element *E = p_constants.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const ConstantInterface &E : p_constants) { + if (E.name == p_name) { + return &E; } } diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index bbfba83e6f..308c15e7c9 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -109,9 +109,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<PropertyInfo> project_props; ProjectSettings::get_singleton()->get_property_list(&project_props); - for (List<PropertyInfo>::Element *E = project_props.front(); E; E = E->next()) { - const PropertyInfo &prop = E->get(); - + for (PropertyInfo &prop : project_props) { if (!prop.name.begins_with("input/")) { continue; } @@ -187,8 +185,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr ClassDB::get_signal_list(native, &signals, /* p_no_inheritance: */ false); } - for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) { - const String &signal = E->get().name; + for (MethodInfo &E : signals) { + const String &signal = E.name; suggestions.push_back(quoted(signal)); } } break; @@ -199,8 +197,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_color_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -211,8 +209,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_constant_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -223,8 +221,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -235,8 +233,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_font_size_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; @@ -247,8 +245,8 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List<StringName> sn; Theme::get_default()->get_stylebox_list(base->get_class(), &sn); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - suggestions.push_back(quoted(E->get())); + for (StringName &E : sn) { + suggestions.push_back(quoted(E)); } } } break; diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 2d04cedb9b..358e390784 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -177,8 +177,8 @@ MonoArray *godot_icall_DynamicGodotObject_SetMemberList(Object *p_ptr) { MonoArray *result = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), property_list.size()); int i = 0; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get().name); + for (PropertyInfo &E : property_list) { + MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E.name); mono_array_setref(result, i, boxed); i++; } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 02d875f669..d7c5850005 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -100,8 +100,8 @@ void gd_mono_setup_runtime_main_args() { main_args.write[0] = execpath.ptrw(); int i = 1; - for (List<String>::Element *E = cmdline_args.front(); E; E = E->next()) { - CharString &stored = cmdline_args_utf8.push_back(E->get().utf8())->get(); + for (String &E : cmdline_args) { + CharString &stored = cmdline_args_utf8.push_back(E.utf8())->get(); main_args.write[i] = stored.ptrw(); i++; } diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 7aeb9e1858..41cd75fd22 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -514,11 +514,11 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) } Transform3D navmesh_xform = Object::cast_to<Node3D>(p_node)->get_transform().affine_inverse(); - for (const List<Node *>::Element *E = parse_nodes.front(); E; E = E->next()) { + for (Node *E : parse_nodes) { int geometry_type = p_nav_mesh->get_parsed_geometry_type(); uint32_t collision_mask = p_nav_mesh->get_collision_mask(); bool recurse_children = p_nav_mesh->get_source_geometry_mode() != NavigationMesh::SOURCE_GEOMETRY_GROUPS_EXPLICIT; - _parse_geometry(navmesh_xform, E->get(), vertices, indices, geometry_type, collision_mask, recurse_children); + _parse_geometry(navmesh_xform, E, vertices, indices, geometry_type, collision_mask, recurse_children); } if (vertices.size() > 0 && indices.size() > 0) { diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 2513039e8e..6493464759 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -927,14 +927,14 @@ void TextServerAdvanced::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List<RID> fonts; font_owner.get_owned_list(&fonts); - for (List<RID>::Element *E = fonts.front(); E; E = E->next()) { - font_owner.getornull(E->get())->clear_cache(); + for (RID E : fonts) { + font_owner.getornull(E)->clear_cache(); } List<RID> text_bufs; shaped_owner.get_owned_list(&text_bufs); - for (List<RID>::Element *E = text_bufs.front(); E; E = E->next()) { - invalidate(shaped_owner.getornull(E->get())); + for (RID E : text_bufs) { + invalidate(shaped_owner.getornull(E)); } } } diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 9ad7dabbcc..cc90dfb4b8 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -473,8 +473,8 @@ void TextServerFallback::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List<RID> fonts; font_owner.get_owned_list(&fonts); - for (List<RID>::Element *E = fonts.front(); E; E = E->next()) { - font_owner.getornull(E->get())->clear_cache(); + for (RID E : fonts) { + font_owner.getornull(E)->clear_cache(); } } } diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 0de39512ae..5828529103 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -588,14 +588,14 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p variables.erase(p_name); List<int> ids; get_node_list(&ids); - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - Ref<VisualScriptVariableGet> nodeget = get_node(E->get()); + for (int &E : ids) { + Ref<VisualScriptVariableGet> nodeget = get_node(E); if (nodeget.is_valid()) { if (nodeget->get_variable() == p_name) { nodeget->set_variable(p_new_name); } } else { - Ref<VisualScriptVariableSet> nodeset = get_node(E->get()); + Ref<VisualScriptVariableSet> nodeset = get_node(E); if (nodeset.is_valid()) { if (nodeset->get_variable() == p_name) { nodeset->set_variable(p_new_name); @@ -715,9 +715,9 @@ int VisualScript::get_available_id() const { List<int> nds; nodes.get_key_list(&nds); int max = -1; - for (const List<int>::Element *E = nds.front(); E; E = E->next()) { - if (E->get() > max) { - max = E->get(); + for (const int &E : nds) { + if (E > max) { + max = E; } } return (max + 1); @@ -752,15 +752,15 @@ void VisualScript::_update_placeholders() { List<StringName> keys; variables.get_key_list(&keys); - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (!variables[E->get()]._export) { + for (StringName &E : keys) { + if (!variables[E]._export) { continue; } - PropertyInfo p = variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = variables[E].info; + p.name = String(E); pinfo.push_back(p); - values[p.name] = variables[E->get()].default_value; + values[p.name] = variables[E].default_value; } for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) { @@ -783,15 +783,15 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) { List<StringName> keys; variables.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (!variables[E->get()]._export) { + for (const StringName &E : keys) { + if (!variables[E]._export) { continue; } - PropertyInfo p = variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = variables[E].info; + p.name = String(E); pinfo.push_back(p); - values[p.name] = variables[E->get()].default_value; + values[p.name] = variables[E].default_value; } sins->update(pinfo, values); @@ -874,11 +874,11 @@ void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const { List<StringName> funcs; functions.get_key_list(&funcs); - for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) { + for (StringName &E : funcs) { MethodInfo mi; - mi.name = E->get(); - if (functions[E->get()].func_id >= 0) { - Ref<VisualScriptFunction> func = nodes[functions[E->get()].func_id].node; + mi.name = E; + if (functions[E].func_id >= 0) { + Ref<VisualScriptFunction> func = nodes[functions[E].func_id].node; if (func.is_valid()) { for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arg; @@ -928,10 +928,10 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const { List<StringName> vars; get_variable_list(&vars); - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { - //if (!variables[E->get()]._export) + for (StringName &E : vars) { + //if (!variables[E]._export) // continue; - PropertyInfo pi = variables[E->get()].info; + PropertyInfo pi = variables[E].info; pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_list->push_back(pi); } @@ -945,8 +945,8 @@ int VisualScript::get_member_line(const StringName &p_member) const { bool VisualScript::are_subnodes_edited() const { List<int> keys; nodes.get_key_list(&keys); - for (const List<int>::Element *F = keys.front(); F; F = F->next()) { - if (nodes[F->get()].node->is_edited()) { + for (const int &F : keys) { + if (nodes[F].node->is_edited()) { return true; } } @@ -1017,13 +1017,13 @@ void VisualScript::_set_data(const Dictionary &p_data) { rpc_functions.clear(); List<StringName> fns; functions.get_key_list(&fns); - for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { - if (functions[E->get()].func_id >= 0 && nodes.has(functions[E->get()].func_id)) { - Ref<VisualScriptFunction> vsf = nodes[functions[E->get()].func_id].node; + for (const StringName &E : fns) { + if (functions[E].func_id >= 0 && nodes.has(functions[E].func_id)) { + Ref<VisualScriptFunction> vsf = nodes[functions[E].func_id].node; if (vsf.is_valid()) { if (vsf->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) { MultiplayerAPI::RPCConfig nd; - nd.name = E->get(); + nd.name = E; nd.rpc_mode = vsf->get_rpc_mode(); nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; // TODO if (rpc_functions.find(nd) == -1) { @@ -1045,11 +1045,11 @@ Dictionary VisualScript::_get_data() const { Array vars; List<StringName> var_names; variables.get_key_list(&var_names); - for (const List<StringName>::Element *E = var_names.front(); E; E = E->next()) { - Dictionary var = _get_variable_info(E->get()); - var["name"] = E->get(); // Make sure it's the right one. - var["default_value"] = variables[E->get()].default_value; - var["export"] = variables[E->get()]._export; + for (const StringName &E : var_names) { + Dictionary var = _get_variable_info(E); + var["name"] = E; // Make sure it's the right one. + var["default_value"] = variables[E].default_value; + var["export"] = variables[E]._export; vars.push_back(var); } d["variables"] = vars; @@ -1073,10 +1073,10 @@ Dictionary VisualScript::_get_data() const { Array funcs; List<StringName> func_names; functions.get_key_list(&func_names); - for (const List<StringName>::Element *E = func_names.front(); E; E = E->next()) { + for (const StringName &E : func_names) { Dictionary func; - func["name"] = E->get(); - func["function_id"] = functions[E->get()].func_id; + func["name"] = E; + func["function_id"] = functions[E].func_id; funcs.push_back(func); } d["functions"] = funcs; @@ -1084,10 +1084,10 @@ Dictionary VisualScript::_get_data() const { Array nds; List<int> node_ids; nodes.get_key_list(&node_ids); - for (const List<int>::Element *F = node_ids.front(); F; F = F->next()) { - nds.push_back(F->get()); - nds.push_back(nodes[F->get()].pos); - nds.push_back(nodes[F->get()].node); + for (const int &F : node_ids) { + nds.push_back(F); + nds.push_back(nodes[F].pos); + nds.push_back(nodes[F].node); } d["nodes"] = nds; @@ -1202,8 +1202,8 @@ VisualScript::~VisualScript() { // Remove all nodes and stuff that hold data refs. List<int> nds; nodes.get_key_list(&nds); - for (const List<int>::Element *E = nds.front(); E; E = E->next()) { - remove_node(E->get()); + for (const int &E : nds) { + remove_node(E); } } @@ -1233,12 +1233,12 @@ bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const { void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { List<StringName> vars; script->variables.get_key_list(&vars); - for (const List<StringName>::Element *E = vars.front(); E; E = E->next()) { - if (!script->variables[E->get()]._export) { + for (const StringName &E : vars) { + if (!script->variables[E]._export) { continue; } - PropertyInfo p = script->variables[E->get()].info; - p.name = String(E->get()); + PropertyInfo p = script->variables[E].info; + p.name = String(E); p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE; p_properties->push_back(p); } @@ -1262,11 +1262,11 @@ Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { List<StringName> fns; script->functions.get_key_list(&fns); - for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) { + for (const StringName &E : fns) { MethodInfo mi; - mi.name = E->get(); - if (script->functions[E->get()].func_id >= 0 && script->nodes.has(script->functions[E->get()].func_id)) { - Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E->get()].func_id].node; + mi.name = E; + if (script->functions[E].func_id >= 0 && script->nodes.has(script->functions[E].func_id)) { + Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E].func_id].node; if (vsf.is_valid()) { for (int i = 0; i < vsf->get_argument_count(); i++) { PropertyInfo arg; @@ -1868,8 +1868,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o { List<StringName> keys; script->variables.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - variables[E->get()] = script->variables[E->get()].default_value; + for (const StringName &E : keys) { + variables[E] = script->variables[E].default_value; } } @@ -1877,8 +1877,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o { List<StringName> keys; script->functions.get_key_list(&keys); - for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) { - const VisualScript::Function vsfn = p_script->functions[E->get()]; + for (const StringName &E : keys) { + const VisualScript::Function vsfn = p_script->functions[E]; Function function; function.node = vsfn.func_id; function.max_stack = 0; @@ -1889,7 +1889,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o Map<StringName, int> local_var_indices; if (function.node < 0) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E->get())); + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E)); ERR_CONTINUE(function.node < 0); } @@ -1897,7 +1897,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o Ref<VisualScriptFunction> func_node = script->get_node(vsfn.func_id); if (func_node.is_null()) { - VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E->get())); + VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E)); } ERR_CONTINUE(!func_node.is_valid()); @@ -1938,12 +1938,12 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o while (!nd_queue.is_empty()) { int ky = nd_queue.front()->get(); dc_lut[ky].get_key_list(&dc_keys); - for (const List<int>::Element *F = dc_keys.front(); F; F = F->next()) { + for (const int &F : dc_keys) { VisualScript::DataConnection dc; - dc.from_node = dc_lut[ky][F->get()].first; - dc.from_port = dc_lut[ky][F->get()].second; + dc.from_node = dc_lut[ky][F].first; + dc.from_port = dc_lut[ky][F].second; dc.to_node = ky; - dc.to_port = F->get(); + dc.to_port = F; dataconns.insert(dc); nd_queue.push_back(dc.from_node); node_ids.insert(dc.from_node); @@ -2093,7 +2093,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o } } - functions[E->get()] = function; + functions[E] = function; } } } @@ -2467,10 +2467,10 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin List<StringName> vars; vs->get_variable_list(&vars); - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (StringName &E : vars) { Variant v; - if (_call_stack[l].instance->get_variable(E->get(), &v)) { - p_members->push_back("variables/" + E->get()); + if (_call_stack[l].instance->get_variable(E, &v)) { + p_members->push_back("variables/" + E); p_values->push_back(v); } } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index ed0583a133..16313d58d0 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -561,18 +561,16 @@ void VisualScriptEditor::_update_graph_connections() { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0); + for (VisualScript::SequenceConnection &E : sequence_conns) { + graph->connect_node(itos(E.from_node), E.from_output, itos(E.to_node), 0); } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - VisualScript::DataConnection dc = E->get(); - - Ref<VisualScriptNode> from_node = script->get_node(E->get().from_node); - Ref<VisualScriptNode> to_node = script->get_node(E->get().to_node); + for (VisualScript::DataConnection &dc : data_conns) { + Ref<VisualScriptNode> from_node = script->get_node(dc.from_node); + Ref<VisualScriptNode> to_node = script->get_node(dc.to_node); if (to_node->has_input_sequence_port()) { dc.to_port++; @@ -580,7 +578,7 @@ void VisualScriptEditor::_update_graph_connections() { dc.from_port += from_node->get_output_sequence_port_count(); - graph->connect_node(itos(E->get().from_node), dc.from_port, itos(E->get().to_node), dc.to_port); + graph->connect_node(itos(dc.from_node), dc.from_port, itos(dc.to_node), dc.to_port); } } @@ -656,27 +654,27 @@ void VisualScriptEditor::_update_graph(int p_only_id) { script->get_node_list(&ids); StringName editor_icons = "EditorIcons"; - for (List<int>::Element *E = ids.front(); E; E = E->next()) { - if (p_only_id >= 0 && p_only_id != E->get()) { + for (int &E : ids) { + if (p_only_id >= 0 && p_only_id != E) { continue; } - Ref<VisualScriptNode> node = script->get_node(E->get()); - Vector2 pos = script->get_node_position(E->get()); + Ref<VisualScriptNode> node = script->get_node(E); + Vector2 pos = script->get_node_position(E); GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); gnode->set_position_offset(pos * EDSCALE); - if (error_line == E->get()) { + if (error_line == E) { gnode->set_overlay(GraphNode::OVERLAY_POSITION); } else if (node->is_breakpoint()) { gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT); } gnode->set_meta("__vnode", node); - gnode->set_name(itos(E->get())); - gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E->get())); - gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E->get()), CONNECT_DEFERRED); + gnode->set_name(itos(E)); + gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E)); + gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E), CONNECT_DEFERRED); { Ref<VisualScriptFunction> v = node; @@ -696,7 +694,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Button *btn = memnew(Button); btn->set_text(TTR("Add Input Port")); hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E), CONNECT_DEFERRED); } if (nd_list->is_output_port_editable()) { if (nd_list->is_input_port_editable()) { @@ -706,7 +704,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Button *btn = memnew(Button); btn->set_text(TTR("Add Output Port")); hbnc->add_child(btn); - btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E->get()), CONNECT_DEFERRED); + btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E), CONNECT_DEFERRED); } gnode->add_child(hbnc); } else if (Object::cast_to<VisualScriptExpression>(node.ptr())) { @@ -716,7 +714,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { line_edit->set_expand_to_text_length_enabled(true); line_edit->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); gnode->add_child(line_edit); - line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get())); + line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E)); } else { String text = node->get_text(); if (!text.is_empty()) { @@ -732,7 +730,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->set_comment(true); gnode->set_resizable(true); gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); - gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E->get())); + gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E)); } if (node_styles.has(node->get_category())) { @@ -835,8 +833,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); name_box->set_text(left_name); name_box->set_expand_to_text_length_enabled(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true)); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E)); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, true)); } else { hbc->add_child(memnew(Label(left_name))); } @@ -849,18 +847,18 @@ void VisualScriptEditor::_update_graph(int p_only_id) { opbtn->select(left_type); opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, true), CONNECT_DEFERRED); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, true), CONNECT_DEFERRED); } Button *rmbtn = memnew(Button); rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E, i), CONNECT_DEFERRED); } else { hbc->add_child(memnew(Label(left_name))); } - if (left_type != Variant::NIL && !script->is_input_value_port_connected(E->get(), i)) { + if (left_type != Variant::NIL && !script->is_input_value_port_connected(E, i)) { PropertyInfo pi = node->get_input_value_port_info(i); Button *button = memnew(Button); Variant value = node->get_default_input_value(i); @@ -887,7 +885,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } else { button->set_text(value); } - button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i)); + button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E, i)); hbc2->add_child(button); } } else { @@ -911,7 +909,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Button *rmbtn = memnew(Button); rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); hbc->add_child(rmbtn); - rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED); + rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E, i), CONNECT_DEFERRED); if (nd_list->is_output_port_type_editable()) { OptionButton *opbtn = memnew(OptionButton); @@ -921,7 +919,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { opbtn->select(right_type); opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); hbc->add_child(opbtn); - opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, false), CONNECT_DEFERRED); + opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, false), CONNECT_DEFERRED); } if (nd_list->is_output_port_name_editable()) { @@ -930,8 +928,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) { name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0)); name_box->set_text(right_name); name_box->set_expand_to_text_length_enabled(true); - name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get())); - name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false)); + name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E)); + name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, false)); } else { hbc->add_child(memnew(Label(right_name))); } @@ -1047,13 +1045,13 @@ void VisualScriptEditor::_update_members() { List<StringName> func_names; script->get_function_list(&func_names); func_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) { + for (StringName &E : func_names) { TreeItem *ti = members->create_item(functions); - ti->set_text(0, E->get()); + ti->set_text(0, E); ti->set_selectable(0, true); - ti->set_metadata(0, E->get()); + ti->set_metadata(0, E); ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); - if (selected == E->get()) { + if (selected == E) { ti->select(0); } } @@ -1101,18 +1099,18 @@ void VisualScriptEditor::_update_members() { List<StringName> var_names; script->get_variable_list(&var_names); - for (List<StringName>::Element *E = var_names.front(); E; E = E->next()) { + for (StringName &E : var_names) { TreeItem *ti = members->create_item(variables); - ti->set_text(0, E->get()); + ti->set_text(0, E); - ti->set_suffix(0, "= " + _sanitized_variant_text(E->get())); - ti->set_icon(0, type_icons[script->get_variable_info(E->get()).type]); + ti->set_suffix(0, "= " + _sanitized_variant_text(E)); + ti->set_icon(0, type_icons[script->get_variable_info(E).type]); ti->set_selectable(0, true); ti->set_editable(0, true); - ti->set_metadata(0, E->get()); - if (selected == E->get()) { + ti->set_metadata(0, E); + if (selected == E) { ti->select(0); } } @@ -1125,13 +1123,13 @@ void VisualScriptEditor::_update_members() { List<StringName> signal_names; script->get_custom_signal_list(&signal_names); - for (List<StringName>::Element *E = signal_names.front(); E; E = E->next()) { + for (StringName &E : signal_names) { TreeItem *ti = members->create_item(_signals); - ti->set_text(0, E->get()); + ti->set_text(0, E); ti->set_selectable(0, true); ti->set_editable(0, true); - ti->set_metadata(0, E->get()); - if (selected == E->get()) { + ti->set_metadata(0, E); + if (selected == E) { ti->select(0); } } @@ -1237,8 +1235,8 @@ void VisualScriptEditor::_member_edited() { // Also fix all function calls. List<int> lst; script->get_node_list(&lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + for (int &F : lst) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F); if (!fncall.is_valid()) { continue; } @@ -1572,13 +1570,13 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { script->get_data_connection_list(&data_connections); HashMap<int, Set<int>> conn_map; - for (const List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (E->get().from_node == p_id && E->get().from_port == p_port) { + for (const VisualScript::DataConnection &E : data_connections) { + if (E.from_node == p_id && E.from_port == p_port) { // Push into the connections map. - if (!conn_map.has(E->get().to_node)) { - conn_map.set(E->get().to_node, Set<int>()); + if (!conn_map.has(E.to_node)) { + conn_map.set(E.to_node, Set<int>()); } - conn_map[E->get().to_node].insert(E->get().to_port); + conn_map[E.to_node].insert(E.to_port); } } @@ -1587,9 +1585,9 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) { List<int> keys; conn_map.get_key_list(&keys); - for (const List<int>::Element *E = keys.front(); E; E = E->next()) { - for (const Set<int>::Element *F = conn_map[E->get()].front(); F; F = F->next()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E->get(), F->get()); + for (const int &E : keys) { + for (const Set<int>::Element *F = conn_map[E].front(); F; F = F->next()) { + undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E, F); } } @@ -1642,8 +1640,8 @@ Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) c bool exists = false; List<int> existing; script->get_node_list(&existing); - for (List<int>::Element *E = existing.front(); E; E = E->next()) { - Point2 pos = script->get_node_position(E->get()); + for (int &E : existing) { + Point2 pos = script->get_node_position(E); if (pos.distance_to(p_pos) < 50) { p_pos += Vector2(graph->get_snap(), graph->get_snap()); exists = true; @@ -1698,8 +1696,8 @@ void VisualScriptEditor::_on_nodes_delete() { undo_redo->create_action(TTR("Remove VisualScript Nodes")); - for (List<int>::Element *F = to_erase.front(); F; F = F->next()) { - int cr_node = F->get(); + for (int &F : to_erase) { + int cr_node = F; undo_redo->add_do_method(script.ptr(), "remove_node", cr_node); undo_redo->add_undo_method(script.ptr(), "add_node", cr_node, script->get_node(cr_node), script->get_node_position(cr_node)); @@ -1707,18 +1705,18 @@ void VisualScriptEditor::_on_nodes_delete() { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - if (E->get().from_node == cr_node || E->get().to_node == cr_node) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); + for (VisualScript::SequenceConnection &E : sequence_conns) { + if (E.from_node == cr_node || E.to_node == cr_node) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (VisualScript::DataConnection &E : data_conns) { + if (E.from_node == F || E.to_node == F) { + undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -1767,17 +1765,17 @@ void VisualScriptEditor::_on_nodes_duplicate() { List<VisualScript::SequenceConnection> seqs; script->get_sequence_connection_list(&seqs); - for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]); + for (VisualScript::SequenceConnection &E : seqs) { + if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { + undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]); } } List<VisualScript::DataConnection> data; script->get_data_connection_list(&data); - for (List<VisualScript::DataConnection>::Element *E = data.front(); E; E = E->next()) { - if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) { - undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port); + for (VisualScript::DataConnection &E : data) { + if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { + undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port); } } @@ -1903,8 +1901,8 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_ // Also fix all function calls. List<int> lst; script->get_node_list(&lst); - for (List<int>::Element *F = lst.front(); F; F = F->next()) { - Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get()); + for (int &F : lst) { + Ref<VisualScriptFunctionCall> fncall = script->get_node(F); if (!fncall.is_valid()) { continue; } @@ -2221,8 +2219,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da undo_redo->commit_action(); } - for (List<int>::Element *E = new_ids.front(); E; E = E->next()) { - Node *node = graph->get_node(itos(E->get())); + for (int &E : new_ids) { + Node *node = graph->get_node(itos(E)); if (node) { graph->set_selected(node); _node_selected(node); @@ -2554,12 +2552,12 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { List<StringName> functions; script->get_function_list(&functions); - for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { + for (StringName &E : functions) { if (script->has_node(p_line)) { _update_graph(); _update_members(); - call_deferred(SNAME("call_deferred"), "_center_on_node", E->get(), p_line); //editor might be just created and size might not exist yet + call_deferred(SNAME("call_deferred"), "_center_on_node", E, p_line); //editor might be just created and size might not exist yet return; } } @@ -2600,13 +2598,13 @@ Array VisualScriptEditor::get_breakpoints() { Array breakpoints; List<StringName> functions; script->get_function_list(&functions); - for (List<StringName>::Element *E = functions.front(); E; E = E->next()) { + for (int i = 0; i < functions.size(); i++) { List<int> nodes; script->get_node_list(&nodes); - for (List<int>::Element *F = nodes.front(); F; F = F->next()) { - Ref<VisualScriptNode> vsn = script->get_node(F->get()); + for (int &F : nodes) { + Ref<VisualScriptNode> vsn = script->get_node(F); if (vsn->is_breakpoint()) { - breakpoints.push_back(F->get() - 1); // Subtract 1 because breakpoints in text start from zero. + breakpoints.push_back(F - 1); // Subtract 1 because breakpoints in text start from zero. } } } @@ -2775,18 +2773,18 @@ void VisualScriptEditor::_remove_node(int p_id) { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node); + for (VisualScript::SequenceConnection &E : sequence_conns) { + if (E.from_node == p_id || E.to_node == p_id) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> data_conns; script->get_data_connection_list(&data_conns); - for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) { - if (E->get().from_node == p_id || E->get().to_node == p_id) { - undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (VisualScript::DataConnection &E : data_conns) { + if (E.from_node == p_id || E.to_node == p_id) { + undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } } @@ -2804,9 +2802,9 @@ bool VisualScriptEditor::node_has_sequence_connections(int p_id) { List<VisualScript::SequenceConnection> sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; + for (VisualScript::SequenceConnection &E : sequence_conns) { + int from = E.from_node; + int to = E.to_node; if (to == p_id || from == p_id) { return true; @@ -3462,9 +3460,9 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons List<MethodInfo> methods; bool found = false; ClassDB::get_virtual_methods(script->get_instance_base_type(), &methods); - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == name) { - minfo = E->get(); + for (MethodInfo &E : methods) { + if (E.name == name) { + minfo = E; found = true; } } @@ -3734,8 +3732,8 @@ void VisualScriptEditor::_menu_option(int p_what) { _update_graph(); - for (List<String>::Element *E = reselect.front(); E; E = E->next()) { - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E->get())); + for (String &E : reselect) { + GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E)); gn->set_selected(true); } @@ -3774,18 +3772,18 @@ void VisualScriptEditor::_menu_option(int p_what) { List<VisualScript::SequenceConnection> sequence_connections; script->get_sequence_connection_list(&sequence_connections); - for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->sequence_connections.insert(E->get()); + for (VisualScript::SequenceConnection &E : sequence_connections) { + if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { + clipboard->sequence_connections.insert(E); } } List<VisualScript::DataConnection> data_connections; script->get_data_connection_list(&data_connections); - for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) { - if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) { - clipboard->data_connections.insert(E->get()); + for (VisualScript::DataConnection &E : data_connections) { + if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { + clipboard->data_connections.insert(E); } } if (p_what == EDIT_CUT_NODES) { @@ -3811,8 +3809,8 @@ void VisualScriptEditor::_menu_option(int p_what) { { List<int> nodes; script->get_node_list(&nodes); - for (List<int>::Element *E = nodes.front(); E; E = E->next()) { - Vector2 pos = script->get_node_position(E->get()).snapped(Vector2(2, 2)); + for (int &E : nodes) { + Vector2 pos = script->get_node_position(E).snapped(Vector2(2, 2)); existing_positions.insert(pos); } } @@ -3935,22 +3933,22 @@ void VisualScriptEditor::_menu_option(int p_what) { // Pick the node with input sequence. Set<int> nodes_from; Set<int> nodes_to; - for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) { - if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { - seqmove.insert(E->get()); - nodes_from.insert(E->get().from_node); - } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) { - seqext.insert(E->get()); - } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { + for (VisualScript::SequenceConnection &E : seqs) { + if (nodes.has(E.from_node) && nodes.has(E.to_node)) { + seqmove.insert(E); + nodes_from.insert(E.from_node); + } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) { + seqext.insert(E); + } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) { if (start_node == -1) { - seqext.insert(E->get()); - start_node = E->get().to_node; + seqext.insert(E); + start_node = E.to_node; } else { EditorNode::get_singleton()->show_warning(TTR("Try to only have one sequence input in selection.")); return; } } - nodes_to.insert(E->get().to_node); + nodes_to.insert(E.to_node); } // To use to add return nodes. @@ -3978,20 +3976,20 @@ void VisualScriptEditor::_menu_option(int p_what) { { List<VisualScript::DataConnection> dats; script->get_data_connection_list(&dats); - for (List<VisualScript::DataConnection>::Element *E = dats.front(); E; E = E->next()) { - if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { - datamove.insert(E->get()); - } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) { + for (VisualScript::DataConnection &E : dats) { + if (nodes.has(E.from_node) && nodes.has(E.to_node)) { + datamove.insert(E); + } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) { // Add all these as inputs for the Function. - Ref<VisualScriptNode> node = script->get_node(E->get().to_node); + Ref<VisualScriptNode> node = script->get_node(E.to_node); if (node.is_valid()) { - dataext.insert(E->get()); - PropertyInfo pi = node->get_input_value_port_info(E->get().to_port); + dataext.insert(E); + PropertyInfo pi = node->get_input_value_port_info(E.to_port); inputs.push_back(pi.type); - input_connections.push_back(Pair<int, int>(E->get().to_node, E->get().to_port)); + input_connections.push_back(Pair<int, int>(E.to_node, E.to_port)); } - } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) { - dataext.insert(E->get()); + } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) { + dataext.insert(E); } } } @@ -4092,9 +4090,9 @@ void VisualScriptEditor::_menu_option(int p_what) { // but I hope that it will not be a problem considering that we won't be creating functions so frequently, // and cyclic connections would be a problem but hopefully we won't let them get to this point. void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes) { - for (const List<VisualScript::SequenceConnection>::Element *E = p_seqs.front(); E; E = E->next()) { - int from = E->get().from_node; - int to = E->get().to_node; + for (const VisualScript::SequenceConnection &E : p_seqs) { + int from = E.from_node; + int to = E.to_node; if (from == p_node && p_selected.has(to)) { // This is an interior connection move forward to the to node. @@ -4168,16 +4166,16 @@ void VisualScriptEditor::_member_option(int p_option) { undo_redo->add_undo_method(script.ptr(), "add_node", fn_node, script->get_node(fn_node), script->get_node_position(fn_node)); List<VisualScript::SequenceConnection> seqcons; script->get_sequence_connection_list(&seqcons); - for (const List<VisualScript::SequenceConnection>::Element *E = seqcons.front(); E; E = E->next()) { - if (E->get().from_node == fn_node) { - undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E->get().from_output, E->get().to_node); + for (const VisualScript::SequenceConnection &E : seqcons) { + if (E.from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E.from_output, E.to_node); } } List<VisualScript::DataConnection> datcons; script->get_data_connection_list(&datcons); - for (const List<VisualScript::DataConnection>::Element *E = datcons.front(); E; E = E->next()) { - if (E->get().from_node == fn_node) { - undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualScript::DataConnection &E : datcons) { + if (E.from_node == fn_node) { + undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E.from_port, E.to_node, E.to_port); } } undo_redo->add_do_method(this, "_update_members"); diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index af86f90b25..ddf6169015 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -852,11 +852,11 @@ void VisualScriptTypeCast::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index a6c52a0f8c..c694d6b8e0 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -538,11 +538,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const Engine::get_singleton()->get_singletons(&names); property.hint = PROPERTY_HINT_ENUM; String sl; - for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) { + for (Engine::Singleton &E : names) { if (sl != String()) { sl += ","; } - sl += E->get().name; + sl += E.name; } property.hint_string = sl; } @@ -683,11 +683,11 @@ void VisualScriptFunctionCall::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode"); @@ -1004,13 +1004,13 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const List<PropertyInfo> props; ClassDB::get_property_list(_get_base_type(), &props, false); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == property) { + for (PropertyInfo &E : props) { + if (E.name == property) { String detail_prop_name = property; if (index != StringName()) { detail_prop_name += "." + String(index); } - PropertyInfo pinfo = PropertyInfo(E->get().type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E->get().hint_string); + PropertyInfo pinfo = PropertyInfo(E.type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E.hint_string); _adjust_input_index(pinfo); return pinfo; } @@ -1135,9 +1135,9 @@ void VisualScriptPropertySet::_update_cache() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get(); + for (PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E; } } @@ -1186,9 +1186,9 @@ void VisualScriptPropertySet::_update_cache() { script->get_script_property_list(&pinfo); } - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get(); + for (PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E; return; } } @@ -1354,8 +1354,8 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - options += "," + E->get().name; + for (PropertyInfo &E : plist) { + options += "," + E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -1410,11 +1410,11 @@ void VisualScriptPropertySet::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); @@ -1820,9 +1820,9 @@ void VisualScriptPropertyGet::_update_cache() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get().type; + for (PropertyInfo &E : pinfo) { + if (E.name == property) { + type_cache = E.type; return; } } @@ -2059,8 +2059,8 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - options += "," + E->get().name; + for (PropertyInfo &E : plist) { + options += "," + E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -2112,11 +2112,11 @@ void VisualScriptPropertyGet::_bind_methods() { } String script_ext_hint; - for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) { + for (String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } - script_ext_hint += "." + E->get(); + script_ext_hint += "." + E; } ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode"); @@ -2323,11 +2323,11 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { } String ml; - for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) { + for (StringName &E : sigs) { if (ml != String()) { ml += ","; } - ml += E->get(); + ml += E; } property.hint_string = ml; @@ -2418,8 +2418,8 @@ void register_visual_script_func_nodes() { List<MethodInfo> ml; vt.get_method_list(&ml); - for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) { - VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E->get().name, create_basic_type_call_node); + for (MethodInfo &E : ml) { + VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E.name, create_basic_type_call_node); } } } diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 86d8050acb..e6511792aa 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1306,12 +1306,12 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (StringName &E : vars) { if (vhint != String()) { vhint += ","; } - vhint += E->get().operator String(); + vhint += E.operator String(); } property.hint = PROPERTY_HINT_ENUM; @@ -1416,12 +1416,12 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (List<StringName>::Element *E = vars.front(); E; E = E->next()) { + for (StringName &E : vars) { if (vhint != String()) { vhint += ","; } - vhint += E->get().operator String(); + vhint += E.operator String(); } property.hint = PROPERTY_HINT_ENUM; @@ -1944,8 +1944,8 @@ void VisualScriptClassConstant::set_base_type(const StringName &p_which) { ClassDB::get_integer_constant_list(base_type, &constants, true); if (constants.size() > 0) { bool found_name = false; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == name) { + for (String &E : constants) { + if (E == name) { found_name = true; break; } @@ -1993,11 +1993,11 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const ClassDB::get_integer_constant_list(base_type, &constants, true); property.hint_string = ""; - for (List<String>::Element *E = constants.front(); E; E = E->next()) { + for (String &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } - property.hint_string += E->get(); + property.hint_string += E; } } } @@ -2078,8 +2078,8 @@ void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) { Variant::get_constants_for_type(type, &constants); if (constants.size() > 0) { bool found_name = false; - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - if (E->get() == name) { + for (StringName &E : constants) { + if (E == name) { found_name = true; break; } @@ -2131,11 +2131,11 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c return; } property.hint_string = ""; - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + for (StringName &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } - property.hint_string += String(E->get()); + property.hint_string += String(E); } } } @@ -2358,15 +2358,15 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con Engine::get_singleton()->get_singletons(&singletons); - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { - if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D") { + for (Engine::Singleton &E : singletons) { + if (E.name == "VS" || E.name == "PS" || E.name == "PS2D" || E.name == "AS" || E.name == "TS" || E.name == "SS" || E.name == "SS2D") { continue; //skip these, too simple named } if (cc != String()) { cc += ","; } - cc += E->get().name; + cc += E.name; } property.hint = PROPERTY_HINT_ENUM; @@ -3749,9 +3749,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const { ProjectSettings::get_singleton()->get_property_list(&pinfo); Vector<String> al; - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } @@ -3844,10 +3842,10 @@ void VisualScriptDeconstruct::_update_elements() { List<PropertyInfo> pinfo; v.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + for (PropertyInfo &E : pinfo) { Element e; - e.name = E->get().name; - e.type = E->get().type; + e.name = E.name; + e.type = E.type; elements.push_back(e); } } @@ -4025,24 +4023,24 @@ void register_visual_script_nodes() { List<MethodInfo> constructors; Variant::get_constructor_list(Variant::Type(i), &constructors); - for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) { - if (E->get().arguments.size() > 0) { + for (MethodInfo &E : constructors) { + if (E.arguments.size() > 0) { String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "("; - for (int j = 0; j < E->get().arguments.size(); j++) { + for (int j = 0; j < E.arguments.size(); j++) { if (j > 0) { name += ", "; } - if (E->get().arguments.size() == 1) { - name += Variant::get_type_name(E->get().arguments[j].type); + if (E.arguments.size() == 1) { + name += Variant::get_type_name(E.arguments[j].type); } else { - name += E->get().arguments[j].name; + name += E.arguments[j].name; } } name += ")"; VisualScriptLanguage::singleton->add_register_func(name, create_constructor_node); Pair<Variant::Type, MethodInfo> pair; pair.first = Variant::Type(i); - pair.second = E->get(); + pair.second = E; constructor_map[name] = pair; } } diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index ccb2e2df75..5e9ecbe615 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -93,7 +93,7 @@ void VisualScriptPropertySelector::_update_search() { base = ClassDB::get_parent_class_nocheck(base); } - for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) { + for (StringName &E : base_list) { List<MethodInfo> methods; List<PropertyInfo> props; TreeItem *category = nullptr; @@ -135,7 +135,7 @@ void VisualScriptPropertySelector::_update_search() { vbc->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; { - String b = String(E->get()); + String b = String(E); category = search_options->create_item(root); if (category) { category->set_text(0, b.replace_first("*", "")); @@ -154,30 +154,30 @@ void VisualScriptPropertySelector::_update_search() { if (Object::cast_to<Script>(obj)) { Object::cast_to<Script>(obj)->get_script_property_list(&props); } else { - ClassDB::get_property_list(E->get(), &props, true); + ClassDB::get_property_list(E, &props, true); } } - for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { + for (PropertyInfo &F : props) { + if (!(F.usage & PROPERTY_USAGE_EDITOR) && !(F.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } - if (type_filter.size() && type_filter.find(F->get().type) == -1) { + if (type_filter.size() && type_filter.find(F.type) == -1) { continue; } // capitalize() also converts underscore to space, we'll match again both possible styles - String get_text_raw = String(vformat(TTR("Get %s"), F->get().name)); + String get_text_raw = String(vformat(TTR("Get %s"), F.name)); String get_text = get_text_raw.capitalize(); - String set_text_raw = String(vformat(TTR("Set %s"), F->get().name)); + String set_text_raw = String(vformat(TTR("Set %s"), F.name)); String set_text = set_text_raw.capitalize(); String input = search_box->get_text().capitalize(); if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, get_text); - item->set_metadata(0, F->get().name); - item->set_icon(0, type_icons[F->get().type]); + item->set_metadata(0, F.name); + item->set_icon(0, type_icons[F.type]); item->set_metadata(1, "get"); item->set_collapsed(true); item->set_selectable(0, true); @@ -189,8 +189,8 @@ void VisualScriptPropertySelector::_update_search() { if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, set_text); - item->set_metadata(0, F->get().name); - item->set_icon(0, type_icons[F->get().type]); + item->set_metadata(0, F.name); + item->set_icon(0, type_icons[F.type]); item->set_metadata(1, "set"); item->set_selectable(0, true); item->set_selectable(1, false); @@ -211,7 +211,7 @@ void VisualScriptPropertySelector::_update_search() { Object::cast_to<Script>(obj)->get_script_method_list(&methods); } - ClassDB::get_method_list(E->get(), &methods, true, true); + ClassDB::get_method_list(E, &methods, true, true); } } for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) { @@ -340,11 +340,11 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt List<String> fnodes; VisualScriptLanguage::singleton->get_registered_node_names(&fnodes); - for (List<String>::Element *E = fnodes.front(); E; E = E->next()) { - if (!E->get().begins_with(root_filter)) { + for (String &E : fnodes) { + if (!E.begins_with(root_filter)) { continue; } - Vector<String> path = E->get().split("/"); + Vector<String> path = E.split("/"); // check if the name has the filter bool in_filter = false; @@ -355,7 +355,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } else { in_filter = false; } - if (E->get().findn(tx_filters[i]) != -1) { + if (E.findn(tx_filters[i]) != -1) { in_filter = true; break; } @@ -366,7 +366,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt bool in_modifier = p_modifiers.is_empty(); for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) { - if (E->get().findn(F->get()) != -1) { + if (E.findn(F->get()) != -1) { in_modifier = true; } } @@ -375,7 +375,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } TreeItem *item = search_options->create_item(root); - Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get()); + Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E); Ref<VisualScriptOperator> vnode_operator = vnode; String type_name; if (vnode_operator.is_valid()) { @@ -409,7 +409,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt item->set_text(0, type_name + String("").join(desc)); item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"))); item->set_selectable(0, true); - item->set_metadata(0, E->get()); + item->set_metadata(0, E); item->set_selectable(0, true); item->set_metadata(1, "visualscript"); item->set_selectable(1, false); diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index d8bc926a1d..bf269b1d7a 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -438,21 +438,21 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { ClassDB::get_signal_list(_get_base_type(), &methods); List<String> mstring; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("_")) { + for (MethodInfo &E : methods) { + if (E.name.begins_with("_")) { continue; } - mstring.push_back(E->get().name.get_slice(":", 0)); + mstring.push_back(E.name.get_slice(":", 0)); } mstring.sort(); String ml; - for (List<String>::Element *E = mstring.front(); E; E = E->next()) { + for (String &E : mstring) { if (ml != String()) { ml += ","; } - ml += E->get(); + ml += E; } property.hint_string = ml; diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp index 51101e3124..77857255c1 100644 --- a/modules/webrtc/webrtc_multiplayer_peer.cpp +++ b/modules/webrtc/webrtc_multiplayer_peer.cpp @@ -112,22 +112,22 @@ void WebRTCMultiplayerPeer::poll() { } } // Remove disconnected peers - for (List<int>::Element *E = remove.front(); E; E = E->next()) { - remove_peer(E->get()); - if (next_packet_peer == E->get()) { + for (int &E : remove) { + remove_peer(E); + if (next_packet_peer == E) { next_packet_peer = 0; } } // Signal newly connected peers - for (List<int>::Element *E = add.front(); E; E = E->next()) { + for (int &E : add) { // Already connected to server: simply notify new peer. // NOTE: Mesh is always connected. if (connection_status == CONNECTION_CONNECTED) { - emit_signal(SNAME("peer_connected"), E->get()); + emit_signal(SNAME("peer_connected"), E); } // Server emulation mode suppresses peer_conencted until server connects. - if (server_compat && E->get() == TARGET_PEER_SERVER) { + if (server_compat && E == TARGET_PEER_SERVER) { // Server connected. connection_status = CONNECTION_CONNECTED; emit_signal(SNAME("peer_connected"), TARGET_PEER_SERVER); @@ -154,8 +154,8 @@ void WebRTCMultiplayerPeer::_find_next_peer() { } // After last. while (E) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - if (F->get()->get_available_packet_count()) { + for (Ref<WebRTCDataChannel> F : E->get()->channels) { + if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; } @@ -165,8 +165,8 @@ void WebRTCMultiplayerPeer::_find_next_peer() { E = peer_map.front(); // Before last while (E) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - if (F->get()->get_available_packet_count()) { + for (Ref<WebRTCDataChannel> F : E->get()->channels) { + if (F->get_available_packet_count()) { next_packet_peer = E->key(); return; } @@ -213,8 +213,8 @@ int WebRTCMultiplayerPeer::get_unique_id() const { void WebRTCMultiplayerPeer::_peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict) { Array channels; - for (List<Ref<WebRTCDataChannel>>::Element *F = p_connected_peer->channels.front(); F; F = F->next()) { - channels.push_back(F->get()); + for (Ref<WebRTCDataChannel> F : p_connected_peer->channels) { + channels.push_back(F); } r_dict["connection"] = p_connected_peer->connection; r_dict["connected"] = p_connected_peer->connected; @@ -297,9 +297,9 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_ _find_next_peer(); ERR_FAIL_V(ERR_UNAVAILABLE); } - for (List<Ref<WebRTCDataChannel>>::Element *E = peer_map[next_packet_peer]->channels.front(); E; E = E->next()) { - if (E->get()->get_available_packet_count()) { - Error err = E->get()->get_packet(r_buffer, r_buffer_size); + for (Ref<WebRTCDataChannel> E : peer_map[next_packet_peer]->channels) { + if (E->get_available_packet_count()) { + Error err = E->get_packet(r_buffer, r_buffer_size); _find_next_peer(); return err; } @@ -357,8 +357,8 @@ int WebRTCMultiplayerPeer::get_available_packet_count() const { } int size = 0; for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) { - for (List<Ref<WebRTCDataChannel>>::Element *F = E->get()->channels.front(); F; F = F->next()) { - size += F->get()->get_available_packet_count(); + for (Ref<WebRTCDataChannel> F : E->get()->channels) { + size += F->get_available_packet_count(); } } return size; diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index ddd8e190df..589bb8931a 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -65,9 +65,9 @@ void WebSocketMultiplayerPeer::_clear() { memfree(_current_packet.data); } - for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) { - memfree(E->get().data); - E->get().data = nullptr; + for (Packet &E : _incoming_packets) { + memfree(E.data); + E.data = nullptr; } _incoming_packets.clear(); diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index 5f794415af..1df001f86e 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -190,15 +190,15 @@ void WSLServer::poll() { remove_ids.push_back(E->key()); } } - for (List<int>::Element *E = remove_ids.front(); E; E = E->next()) { - _peer_map.erase(E->get()); + for (int &E : remove_ids) { + _peer_map.erase(E); } remove_ids.clear(); List<Ref<PendingPeer>> remove_peers; - for (List<Ref<PendingPeer>>::Element *E = _pending.front(); E; E = E->next()) { + for (Ref<PendingPeer> E : _pending) { String resource_name; - Ref<PendingPeer> ppeer = E->get(); + Ref<PendingPeer> ppeer = E; Error err = ppeer->do_handshake(_protocols, handshake_timeout, resource_name); if (err == ERR_BUSY) { continue; @@ -224,8 +224,8 @@ void WSLServer::poll() { remove_peers.push_back(ppeer); _on_connect(id, ppeer->protocol, resource_name); } - for (List<Ref<PendingPeer>>::Element *E = remove_peers.front(); E; E = E->next()) { - _pending.erase(E->get()); + for (Ref<PendingPeer> E : remove_peers) { + _pending.erase(E); } remove_peers.clear(); diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index ed6b5c3e14..49891cd739 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -41,13 +41,13 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, ERR_FAIL_COND_V(env == nullptr, false); MethodInfo *method = nullptr; - for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) { - if (!p_instance && !E->get()._static) { + for (MethodInfo &E : M->get()) { + if (!p_instance && !E._static) { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; continue; } - int pc = E->get().param_types.size(); + int pc = E.param_types.size(); if (pc > p_argcount) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = pc; @@ -58,7 +58,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, r_error.argument = pc; continue; } - uint32_t *ptypes = E->get().param_types.ptrw(); + uint32_t *ptypes = E.param_types.ptrw(); bool valid = true; for (int i = 0; i < pc; i++) { @@ -107,7 +107,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (Object::cast_to<JavaObject>(ref.ptr())) { Ref<JavaObject> jo = ref; //could be faster - jclass c = env->FindClass(E->get().param_sigs[i].operator String().utf8().get_data()); + jclass c = env->FindClass(E.param_sigs[i].operator String().utf8().get_data()); if (!c || !env->IsInstanceOf(jo->instance, c)) { arg_expected = Variant::OBJECT; } else { @@ -138,7 +138,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, if (!valid) continue; - method = &E->get(); + method = &E; break; } @@ -474,8 +474,8 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } break; } - for (List<jobject>::Element *E = to_free.front(); E; E = E->next()) { - env->DeleteLocalRef(E->get()); + for (jobject &E : to_free) { + env->DeleteLocalRef(E); } return success; diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 549c1d47ec..76102d941b 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -115,8 +115,8 @@ Error OS_JavaScript::execute(const String &p_path, const List<String> &p_argumen Error OS_JavaScript::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { Array args; - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - args.push_back(E->get()); + for (const String &E : p_arguments) { + args.push_back(E); } String json_args = Variant(args).to_json_string(); int failed = godot_js_os_execute(json_args.utf8().get_data()); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index a06362b9b0..2c8afaf7de 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -411,8 +411,8 @@ String OS_Windows::_quote_command_line_argument(const String &p_text) const { Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } if (r_pipe) { @@ -467,8 +467,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Error OS_Windows::create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id) { String path = p_path.replace("/", "\\"); String command = _quote_command_line_argument(path); - for (const List<String>::Element *E = p_arguments.front(); E; E = E->next()) { - command += " " + _quote_command_line_argument(E->get()); + for (const String &E : p_arguments) { + command += " " + _quote_command_line_argument(E); } ProcessInfo pi; diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 9ee37670d1..da2ab6ada8 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -123,7 +123,7 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { } property.hint_string += String(E->get()); - if (animation == E->get()) { + if (animation == E) { current_found = true; } } diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 5b12da8b57..8709acf7f1 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -145,8 +145,7 @@ TypedArray<PhysicsBody2D> PhysicsBody2D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (RID body : exceptions) { ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(obj); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index bf2f8f8947..4a15a1dc46 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1596,8 +1596,8 @@ void TileMap::set_light_mask(int p_light_mask) { // Occlusion: set light mask. CanvasItem::set_light_mask(p_light_mask); for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { - for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) { - RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask()); + for (RID F : E->get().canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_light_mask(F, get_light_mask()); } } } @@ -1609,8 +1609,8 @@ void TileMap::set_material(const Ref<Material> &p_material) { // Update material for the whole tilemap. for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_use_parent_material(F->get(), get_use_parent_material() || get_material().is_valid()); + for (RID F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } } @@ -1622,8 +1622,8 @@ void TileMap::set_use_parent_material(bool p_use_parent_material) { // Update use_parent_material for the whole tilemap. for (Map<Vector2i, TileMapQuadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_use_parent_material(F->get(), get_use_parent_material() || get_material().is_valid()); + for (RID F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } } @@ -1633,8 +1633,8 @@ void TileMap::set_texture_filter(TextureFilter p_texture_filter) { CanvasItem::set_texture_filter(p_texture_filter); for (Map<Vector2i, TileMapQuadrant>::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E->get(), RS::CanvasItemTextureFilter(p_texture_filter)); + for (RID E : q.canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E, RS::CanvasItemTextureFilter(p_texture_filter)); _make_quadrant_dirty(F); } } @@ -1645,8 +1645,8 @@ void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) { CanvasItem::set_texture_repeat(p_texture_repeat); for (Map<Vector2i, TileMapQuadrant>::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E->get(), RS::CanvasItemTextureRepeat(p_texture_repeat)); + for (RID E : q.canvas_items) { + RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E, RS::CanvasItemTextureRepeat(p_texture_repeat)); _make_quadrant_dirty(F); } } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index df7d7be1fd..97b562837a 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -397,9 +397,7 @@ Ref<Image> GPUParticlesCollisionSDF::bake() { bake_step_function(0, "Finding Meshes"); } - for (List<PlotMesh>::Element *E = plot_meshes.front(); E; E = E->next()) { - const PlotMesh &pm = E->get(); - + for (PlotMesh &pm : plot_meshes) { for (int i = 0; i < pm.mesh->get_surface_count(); i++) { if (pm.mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; //only triangles diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 5bb598227c..93cd088418 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -94,8 +94,8 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const { ls.sort(); - for (List<String>::Element *E = ls.front(); E; E = E->next()) { - p_list->push_back(PropertyInfo(Variant::FLOAT, E->get(), PROPERTY_HINT_RANGE, "-1,1,0.00001")); + for (String &E : ls) { + p_list->push_back(PropertyInfo(Variant::FLOAT, E, PROPERTY_HINT_RANGE, "-1,1,0.00001")); } if (mesh.is_valid()) { diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index d1f96230e0..0daee69ee5 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -103,11 +103,11 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) { data.children_lock++; - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - if (E->get()->data.top_level_active) { + for (Node3D *&E : data.children) { + if (E->data.top_level_active) { continue; //don't propagate to a top_level } - E->get()->_propagate_transform_changed(p_origin); + E->_propagate_transform_changed(p_origin); } #ifdef TOOLS_ENABLED if ((!data.gizmos.is_empty() || data.notify_transform) && !data.ignore_notification && !xform_change.in_list()) { @@ -527,8 +527,7 @@ void Node3D::_propagate_visibility_changed() { } #endif - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); + for (Node3D *c : data.children) { if (!c || !c->data.visible) { continue; } @@ -753,8 +752,7 @@ void Node3D::_update_visibility_parent(bool p_update_root) { RS::get_singleton()->instance_set_visibility_parent(vi->get_instance(), data.visibility_parent); } - for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) { - Node3D *c = E->get(); + for (Node3D *c : data.children) { c->_update_visibility_parent(false); } } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 0e3180bcdf..6736a4ec40 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -78,8 +78,7 @@ TypedArray<PhysicsBody3D> PhysicsBody3D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (RID body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index ba70a6eb41..fb5e9639c7 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -264,8 +264,8 @@ void Skeleton3D::_notification(int p_what) { b.global_pose_override_amount = 0.0; } - for (List<ObjectID>::Element *E = b.nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); + for (ObjectID &E : b.nodes_bound) { + Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); Node3D *node_3d = Object::cast_to<Node3D>(obj); ERR_CONTINUE(!node_3d); @@ -524,8 +524,8 @@ void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) { ObjectID id = p_node->get_instance_id(); - for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - if (E->get() == id) { + for (const ObjectID &E : bones[p_bone].nodes_bound) { + if (E == id) { return; // already here } } @@ -544,8 +544,8 @@ void Skeleton3D::unbind_child_node_from_bone(int p_bone, Node *p_node) { void Skeleton3D::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const { ERR_FAIL_INDEX(p_bone, bones.size()); - for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); + for (const ObjectID &E : bones[p_bone].nodes_bound) { + Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); p_bound->push_back(Object::cast_to<Node>(obj)); } diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 05530c39a1..0d00d10d32 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -592,8 +592,7 @@ Array SoftBody3D::get_collision_exceptions() { List<RID> exceptions; PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); Array ret; - for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { - RID body = E->get(); + for (RID body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index fd3bf99e0a..a901920dbe 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -60,8 +60,8 @@ void SpriteBase3D::_propagate_color_changed() { color_dirty = true; _queue_update(); - for (List<SpriteBase3D *>::Element *E = children.front(); E; E = E->next()) { - E->get()->_propagate_color_changed(); + for (SpriteBase3D *&E : children) { + E->_propagate_color_changed(); } } @@ -996,7 +996,7 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } property.hint_string += String(E->get()); - if (animation == E->get()) { + if (animation == E) { current_found = true; } } diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index bd47af8100..70a7021f22 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -238,8 +238,7 @@ bool GeometryInstance3D::_get(const StringName &p_name, Variant &r_ret) const { void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> pinfo; RS::get_singleton()->instance_geometry_get_shader_parameter_list(get_instance(), &pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { bool has_def_value = false; Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), pi.name); if (def_value.get_type() != Variant::NIL) { diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index bc52db5387..5cf7522667 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -384,14 +384,14 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) { int pmc = 0; - for (List<PlotMesh>::Element *E = mesh_list.front(); E; E = E->next()) { + for (PlotMesh &E : mesh_list) { if (bake_step_function) { bake_step_function(pmc, RTR("Plotting Meshes") + " " + itos(pmc) + "/" + itos(mesh_list.size())); } pmc++; - baker.plot_mesh(E->get().local_xform, E->get().mesh, E->get().instance_materials, E->get().override_material); + baker.plot_mesh(E.local_xform, E.mesh, E.instance_materials, E.override_material); } if (bake_step_function) { bake_step_function(pmc++, RTR("Finishing Plot")); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 200a688067..495f60d4c9 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -1089,10 +1089,10 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons conns.resize(nc.size() * 3); int idx = 0; - for (List<NodeConnection>::Element *E = nc.front(); E; E = E->next()) { - conns[idx * 3 + 0] = E->get().input_node; - conns[idx * 3 + 1] = E->get().input_index; - conns[idx * 3 + 2] = E->get().output_node; + for (NodeConnection &E : nc) { + conns[idx * 3 + 0] = E.input_node; + conns[idx * 3 + 1] = E.input_index; + conns[idx * 3 + 2] = E.output_node; idx++; } @@ -1110,8 +1110,8 @@ void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) cons } names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - String name = E->get(); + for (StringName &E : names) { + String name = E; if (name != "output") { p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); } diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index b8980fd56b..56743007e4 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -252,8 +252,8 @@ void AnimationCache::set_all(float p_time, float p_delta) { List<int> indices; animation->value_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - Variant v = animation->track_get_key_value(i, E->get()); + for (int &E : indices) { + Variant v = animation->track_get_key_value(i, E); set_track_value(i, v); } } @@ -263,9 +263,9 @@ void AnimationCache::set_all(float p_time, float p_delta) { List<int> indices; animation->method_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - Vector<Variant> args = animation->method_track_get_params(i, E->get()); - StringName name = animation->method_track_get_name(i, E->get()); + for (int &E : indices) { + Vector<Variant> args = animation->method_track_get_params(i, E); + StringName name = animation->method_track_get_name(i, E); Callable::CallError err; if (!args.size()) { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 6496331cb0..383d92d37f 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -512,8 +512,8 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c } advance_conditions.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = advance_conditions.front(); E; E = E->next()) { - r_list->push_back(PropertyInfo(Variant::BOOL, E->get())); + for (StringName &E : advance_conditions) { + r_list->push_back(PropertyInfo(Variant::BOOL, E)); } } @@ -679,8 +679,8 @@ void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const { } nodes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - r_nodes->push_back(E->get()); + for (StringName &E : nodes) { + r_nodes->push_back(E); } } @@ -902,8 +902,7 @@ void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) c } names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - String name = E->get(); + for (StringName &name : names) { p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 14ca325c25..0f557519b2 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -176,8 +176,8 @@ void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const { anim_names.sort(); - for (List<PropertyInfo>::Element *E = anim_names.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (PropertyInfo &E : anim_names) { + p_list->push_back(E); } p_list->push_back(PropertyInfo(Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL)); @@ -485,8 +485,8 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float List<int> indices; a->value_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); + for (int &F : indices) { + Variant value = a->track_get_key_value(i, F); switch (pa->special) { case SP_NONE: { bool valid; @@ -544,9 +544,9 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float a->method_track_get_key_indices(i, p_time, p_delta, &indices); - for (List<int>::Element *E = indices.front(); E; E = E->next()) { - StringName method = a->method_track_get_name(i, E->get()); - Vector<Variant> params = a->method_track_get_params(i, E->get()); + for (int &E : indices) { + StringName method = a->method_track_get_name(i, E); + Vector<Variant> params = a->method_track_get_params(i, E); int s = params.size(); @@ -1076,8 +1076,8 @@ void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { anims.sort(); - for (List<String>::Element *E = anims.front(); E; E = E->next()) { - p_animations->push_back(E->get()); + for (String &E : anims) { + p_animations->push_back(E); } } @@ -1118,8 +1118,8 @@ void AnimationPlayer::queue(const StringName &p_name) { Vector<String> AnimationPlayer::get_queue() { Vector<String> ret; - for (List<StringName>::Element *E = queued.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (StringName &E : queued) { + ret.push_back(E); } return ret; @@ -1502,8 +1502,8 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) { List<StringName> al; get_animation_list(&al); - for (List<StringName>::Element *E = al.front(); E; E = E->next()) { - r_options->push_back(quote_style + String(E->get()) + quote_style); + for (StringName &E : al) { + r_options->push_back(quote_style + String(E) + quote_style); } } Node::get_argument_options(p_function, p_idx, r_options); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 72448fc4f7..d277808e1f 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -76,10 +76,10 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) { Dictionary cn = get_script_instance()->call("_get_child_nodes"); List<Variant> keys; cn.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { ChildNode child; - child.name = E->get(); - child.node = cn[E->get()]; + child.name = E; + child.node = cn[E]; r_child_nodes->push_back(child); } } @@ -536,8 +536,8 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List<StringName> sname; player->get_animation_list(&sname); - for (List<StringName>::Element *E = sname.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (StringName &E : sname) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); Animation::TrackType track_type = anim->track_get_type(i); @@ -561,7 +561,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { Node *child = parent->get_node_and_resource(path, resource, leftover_path); if (!child) { - ERR_PRINT("AnimationTree: '" + String(E->get()) + "', couldn't resolve track: '" + String(path) + "'"); + ERR_PRINT("AnimationTree: '" + String(E) + "', couldn't resolve track: '" + String(path) + "'"); continue; } @@ -590,7 +590,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { Node3D *node_3d = Object::cast_to<Node3D>(child); if (!node_3d) { - ERR_PRINT("AnimationTree: '" + String(E->get()) + "', transform track does not point to Node3D: '" + String(path) + "'"); + ERR_PRINT("AnimationTree: '" + String(E) + "', transform track does not point to Node3D: '" + String(path) + "'"); continue; } @@ -816,9 +816,7 @@ void AnimationTree::_process_graph(float p_delta) { { bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); - for (List<AnimationNode::AnimationState>::Element *E = state.animation_states.front(); E; E = E->next()) { - const AnimationNode::AnimationState &as = E->get(); - + for (AnimationNode::AnimationState &as : state.animation_states) { Ref<Animation> a = as.animation; float time = as.time; float delta = as.delta; @@ -962,8 +960,8 @@ void AnimationTree::_process_graph(float p_delta) { List<int> indices; a->value_track_get_key_indices(i, time, delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - Variant value = a->track_get_key_value(i, F->get()); + for (int &F : indices) { + Variant value = a->track_get_key_value(i, F); t->object->set_indexed(t->subpath, value); } } @@ -979,9 +977,9 @@ void AnimationTree::_process_graph(float p_delta) { a->method_track_get_key_indices(i, time, delta, &indices); - for (List<int>::Element *F = indices.front(); F; F = F->next()) { - StringName method = a->method_track_get_name(i, F->get()); - Vector<Variant> params = a->method_track_get_params(i, F->get()); + for (int &F : indices) { + StringName method = a->method_track_get_name(i, F); + Vector<Variant> params = a->method_track_get_params(i, F); int s = params.size(); @@ -1355,9 +1353,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A List<PropertyInfo> plist; node->get_parameter_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - PropertyInfo pinfo = E->get(); - + for (PropertyInfo &pinfo : plist) { StringName key = pinfo.name; if (!property_map.has(p_base_path + key)) { @@ -1373,8 +1369,8 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A List<AnimationNode::ChildNode> children; node->get_child_nodes(&children); - for (List<AnimationNode::ChildNode>::Element *E = children.front(); E; E = E->next()) { - _update_properties_for_node(p_base_path + E->get().name + "/", E->get().node); + for (AnimationNode::ChildNode &E : children) { + _update_properties_for_node(p_base_path + E.name + "/", E.node); } } @@ -1428,17 +1424,17 @@ void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const { const_cast<AnimationTree *>(this)->_update_properties(); } - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + p_list->push_back(E); } } void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) { //rename values first - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().name.begins_with(p_base)) { - String new_name = E->get().name.replace_first(p_base, p_new_base); - property_map[new_name] = property_map[E->get().name]; + for (const PropertyInfo &E : properties) { + if (E.name.begins_with(p_base)) { + String new_name = E.name.replace_first(p_base, p_new_base); + property_map[new_name] = property_map[E.name]; } } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 761046c14a..b31c3d57f9 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -46,8 +46,8 @@ void Tween::start_tweeners() { ERR_FAIL_MSG("Tween without commands, aborting."); } - for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { - E->get()->start(); + for (Ref<Tweener> E : tweeners.write[current_step]) { + E->start(); } } @@ -253,11 +253,11 @@ bool Tween::step(float p_delta) { float step_delta = rem_delta; step_active = false; - for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { + for (Ref<Tweener> E : tweeners.write[current_step]) { // Modified inside Tweener.step(). float temp_delta = rem_delta; // Turns to true if any Tweener returns true (i.e. is still not finished). - step_active = E->get()->step(temp_delta) || step_active; + step_active = E->step(temp_delta) || step_active; step_delta = MIN(temp_delta, rem_delta); } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index fd5637be11..5012aed99a 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -292,9 +292,9 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { // Add base object properties. List<PropertyInfo> pinfo; obj->get_property_list(&pinfo, true); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { - properties.push_back(SceneDebuggerProperty(E->get(), obj->get(E->get().name))); + for (PropertyInfo &E : pinfo) { + if (E.usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { + properties.push_back(SceneDebuggerProperty(E, obj->get(E.name))); } } } @@ -452,8 +452,7 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) { } void SceneDebuggerTree::serialize(Array &p_arr) { - for (List<RemoteNode>::Element *E = nodes.front(); E; E = E->next()) { - RemoteNode &n = E->get(); + for (RemoteNode &n : nodes) { p_arr.push_back(n.child_count); p_arr.push_back(n.name); p_arr.push_back(n.type_name); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index f302f64224..6e3d0e2767 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -2288,14 +2288,14 @@ void CodeEdit::_filter_code_completion_candidates() { TypedArray<Dictionary> completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (List<ScriptCodeCompletionOption>::Element *E = code_completion_option_sources.front(); E; E = E->next()) { + for (ScriptCodeCompletionOption &E : code_completion_option_sources) { Dictionary option; - option["kind"] = E->get().kind; - option["display_text"] = E->get().display; - option["insert_text"] = E->get().insert_text; - option["font_color"] = E->get().font_color; - option["icon"] = E->get().icon; - option["default_value"] = E->get().default_value; + option["kind"] = E.kind; + option["display_text"] = E.display; + option["insert_text"] = E.insert_text; + option["font_color"] = E.font_color; + option["icon"] = E.icon; + option["default_value"] = E.default_value; completion_options_sources[i] = option; i++; } @@ -2406,9 +2406,7 @@ void CodeEdit::_filter_code_completion_candidates() { int max_width = 0; String string_to_complete_lower = string_to_complete.to_lower(); - for (List<ScriptCodeCompletionOption>::Element *E = code_completion_option_sources.front(); E; E = E->next()) { - ScriptCodeCompletionOption &option = E->get(); - + for (ScriptCodeCompletionOption &option : code_completion_option_sources) { if (single_quote && option.display.is_quoted()) { option.display = option.display.unquote().quote("'"); } @@ -2527,8 +2525,7 @@ void CodeEdit::_lines_edited_from(int p_from_line, int p_to_line) { int line_count = (p_to_line - p_from_line); List<int> breakpoints; breakpointed_lines.get_key_list(&breakpoints); - for (const List<int>::Element *E = breakpoints.front(); E; E = E->next()) { - int line = E->get(); + for (const int line : breakpoints) { if (line <= from_line) { continue; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 032533d4a9..ae1f4b2f65 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -343,73 +343,73 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const { { List<StringName> names; theme->get_icon_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.icon_override.has(E->get())) { + if (data.icon_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", usage)); } } { List<StringName> names; theme->get_stylebox_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.style_override.has(E->get())) { + if (data.style_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", usage)); } } { List<StringName> names; theme->get_font_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.font_override.has(E->get())) { + if (data.font_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Font", usage)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E, PROPERTY_HINT_RESOURCE_TYPE, "Font", usage)); } } { List<StringName> names; theme->get_font_size_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.font_size_override.has(E->get())) { + if (data.font_size_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::INT, "custom_font_sizes/" + E->get(), PROPERTY_HINT_NONE, "", usage)); + p_list->push_back(PropertyInfo(Variant::INT, "custom_font_sizes/" + E, PROPERTY_HINT_NONE, "", usage)); } } { List<StringName> names; theme->get_color_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.color_override.has(E->get())) { + if (data.color_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E->get(), PROPERTY_HINT_NONE, "", usage)); + p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E, PROPERTY_HINT_NONE, "", usage)); } } { List<StringName> names; theme->get_constant_list(get_class_name(), &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; - if (data.constant_override.has(E->get())) { + if (data.constant_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; } - p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E->get(), PROPERTY_HINT_RANGE, "-16384,16384", usage)); + p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E, PROPERTY_HINT_RANGE, "-16384,16384", usage)); } } } @@ -428,14 +428,14 @@ void Control::_validate_property(PropertyInfo &property) const { Vector<StringName> unique_names; String hint_string; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - hint_string += String(E->get()) + ","; - unique_names.append(E->get()); + hint_string += String(E) + ","; + unique_names.append(E); } property.hint_string = hint_string; @@ -793,13 +793,13 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E->get())) { - return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E->get()); + for (StringName &E : p_theme_types) { + if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { + return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E); } - if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E->get())) { - return theme_owner_window->theme->get_theme_item(p_data_type, p_name, E->get()); + if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E)) { + return theme_owner_window->theme->get_theme_item(p_data_type, p_name, E); } } @@ -822,17 +822,17 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E->get())) { - return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E->get()); + for (StringName &E : p_theme_types) { + if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { + return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E); } } } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_default()->has_theme_item(p_data_type, p_name, E->get())) { - return Theme::get_default()->get_theme_item(p_data_type, p_name, E->get()); + for (StringName &E : p_theme_types) { + if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { + return Theme::get_default()->get_theme_item(p_data_type, p_name, E); } } // If they don't exist, use any type to return the default/empty value. @@ -848,12 +848,12 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E->get())) { + for (StringName &E : p_theme_types) { + if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return true; } - if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E->get())) { + if (theme_owner_window && theme_owner_window->theme->has_theme_item(p_data_type, p_name, E)) { return true; } } @@ -877,16 +877,16 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E->get())) { + for (StringName &E : p_theme_types) { + if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return true; } } } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (List<StringName>::Element *E = p_theme_types.front(); E; E = E->next()) { - if (Theme::get_default()->has_theme_item(p_data_type, p_name, E->get())) { + for (StringName &E : p_theme_types) { + if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return true; } } @@ -2580,8 +2580,8 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List } sn.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = sn.front(); E; E = E->next()) { - r_options->push_back(quote_style + E->get() + quote_style); + for (StringName &E : sn) { + r_options->push_back(quote_style + E + quote_style); } } } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 9ed3a2244e..67cb6f04a7 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -552,9 +552,9 @@ void FileDialog::update_file_list() { bool match = patterns.is_empty(); String match_str; - for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { - match_str = E->get(); + for (String &E : patterns) { + if (files.front()->get().matchn(E)) { + match_str = E; match = true; break; } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 2281fb19c6..8ad4d04b7f 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -217,8 +217,8 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S } bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { + for (Connection &E : connections) { + if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { return true; } } @@ -227,7 +227,7 @@ bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, con } void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { + for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { connections.erase(E); top_layer->update(); @@ -561,20 +561,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) { //check disconnect - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == gn->get_name() && E->get().from_port == j) { - Node *to = get_node(String(E->get().to)); + for (Connection &E : connections) { + if (E.from == gn->get_name() && E.from_port == j) { + Node *to = get_node(String(E.to)); if (Object::cast_to<GraphNode>(to)) { - connecting_from = E->get().to; - connecting_index = E->get().to_port; + connecting_from = E.to; + connecting_index = E.to_port; connecting_out = false; - connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E->get().to_port); - connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port); + connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E.to_port); + connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E.to_port); connecting_target = false; connecting_to = pos; just_disconnected = true; - emit_signal(SNAME("disconnection_request"), E->get().from, E->get().from_port, E->get().to, E->get().to_port); + emit_signal(SNAME("disconnection_request"), E.from, E.from_port, E.to, E.to_port); to = get_node(String(connecting_from)); //maybe it was erased if (Object::cast_to<GraphNode>(to)) { connecting = true; @@ -603,20 +603,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) { //check disconnect - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().to == gn->get_name() && E->get().to_port == j) { - Node *fr = get_node(String(E->get().from)); + for (Connection &E : connections) { + if (E.to == gn->get_name() && E.to_port == j) { + Node *fr = get_node(String(E.from)); if (Object::cast_to<GraphNode>(fr)) { - connecting_from = E->get().from; - connecting_index = E->get().from_port; + connecting_from = E.from; + connecting_index = E.from_port; connecting_out = true; - connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E->get().from_port); - connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port); + connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E.from_port); + connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E.from_port); connecting_target = false; connecting_to = pos; just_disconnected = true; - emit_signal(SNAME("disconnection_request"), E->get().from, E->get().from_port, E->get().to, E->get().to_port); + emit_signal(SNAME("disconnection_request"), E.from, E.from_port, E.to, E.to_port); fr = get_node(String(connecting_from)); //maybe it was erased if (Object::cast_to<GraphNode>(fr)) { connecting = true; @@ -1001,8 +1001,8 @@ void GraphEdit::_minimap_draw() { // Draw node connections. Color activity_color = get_theme_color(SNAME("activity")); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - NodePath fromnp(E->get().from); + for (Connection &E : connections) { + NodePath fromnp(E.from); Node *from = get_node(fromnp); if (!from) { @@ -1013,7 +1013,7 @@ void GraphEdit::_minimap_draw() { continue; } - NodePath tonp(E->get().to); + NodePath tonp(E.to); Node *to = get_node(tonp); if (!to) { continue; @@ -1023,16 +1023,16 @@ void GraphEdit::_minimap_draw() { continue; } - Vector2 from_slot_position = gfrom->get_position_offset() * zoom + gfrom->get_connection_output_position(E->get().from_port); + Vector2 from_slot_position = gfrom->get_position_offset() * zoom + gfrom->get_connection_output_position(E.from_port); Vector2 from_position = minimap->_convert_from_graph_position(from_slot_position - graph_offset) + minimap_offset; - Color from_color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 to_slot_position = gto->get_position_offset() * zoom + gto->get_connection_input_position(E->get().to_port); + Color from_color = gfrom->get_connection_output_color(E.from_port); + Vector2 to_slot_position = gto->get_position_offset() * zoom + gto->get_connection_input_position(E.to_port); Vector2 to_position = minimap->_convert_from_graph_position(to_slot_position - graph_offset) + minimap_offset; - Color to_color = gto->get_connection_input_color(E->get().to_port); + Color to_color = gto->get_connection_input_color(E.to_port); - if (E->get().activity > 0) { - from_color = from_color.lerp(activity_color, E->get().activity); - to_color = to_color.lerp(activity_color, E->get().activity); + if (E.activity > 0) { + from_color = from_color.lerp(activity_color, E.activity); + to_color = to_color.lerp(activity_color, E.activity); } _draw_cos_line(minimap, from_position, to_position, from_color, to_color, 1.0, 0.5); } @@ -1360,15 +1360,15 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } void GraphEdit::set_connection_activity(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port, float p_activity) { - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) { - if (Math::is_equal_approx(E->get().activity, p_activity)) { + for (Connection &E : connections) { + if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { + if (Math::is_equal_approx(E.activity, p_activity)) { //update only if changed top_layer->update(); minimap->update(); connections_layer->update(); } - E->get().activity = p_activity; + E.activity = p_activity; return; } } @@ -1500,12 +1500,12 @@ Array GraphEdit::_get_connection_list() const { List<Connection> conns; get_connection_list(&conns); Array arr; - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { + for (Connection &E : conns) { Dictionary d; - d["from"] = E->get().from; - d["from_port"] = E->get().from_port; - d["to"] = E->get().to; - d["to_port"] = E->get().to_port; + d["from"] = E.from; + d["from_port"] = E.from_port; + d["to"] = E.to; + d["to_port"] = E.to_port; arr.push_back(d); } return arr; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 14c86c0d27..ae3db4a983 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -397,8 +397,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> m = p_event; if (m.is_valid()) { - for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) { - if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) { + for (Rect2 &E : autohide_areas) { + if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E.has_point(m->get_position())) { _close_pressed(); return; } @@ -751,8 +751,8 @@ void PopupMenu::_notification(int p_what) { Point2 mouse_pos = DisplayServer::get_singleton()->mouse_get_position(); mouse_pos -= get_position(); - for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) { - if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E->get().has_point(mouse_pos)) { + for (Rect2 &E : autohide_areas) { + if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E.has_point(mouse_pos)) { _close_pressed(); return; } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 99395aae30..3925e0c38e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -238,9 +238,9 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> } int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); for (int i = 0; i < frame->lines.size(); i++) { _resize_line(frame, i, p_base_font, p_base_font_size, 1); } @@ -316,9 +316,9 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> Vector2 offset; float row_height = 0.0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; @@ -472,9 +472,9 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> const int available_width = p_width - hseparation * (col_count - 1); int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; for (int i = 0; i < frame->lines.size(); i++) { @@ -556,7 +556,7 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> Vector2 offset; float row_height = 0.0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { + for (const List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. ItemFrame *frame = static_cast<ItemFrame *>(E->get()); @@ -783,8 +783,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o int row_count = table->rows.size(); int idx = 0; - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ItemFrame *frame = static_cast<ItemFrame *>(E); int col = idx % col_count; int row = idx / col_count; @@ -1203,8 +1203,8 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V int col_count = table->columns.size(); int row_count = table->rows.size(); - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ItemFrame *frame = static_cast<ItemFrame *>(E); int col = idx % col_count; int row = idx / col_count; @@ -2080,8 +2080,8 @@ bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) { return true; } - for (List<Item *>::Element *E = from->subitems.front(); E; E = E->next()) { - bool layout = _find_layout_subitem(E->get(), to); + for (Item *E : from->subitems) { + bool layout = _find_layout_subitem(E, to); if (layout) { return true; @@ -3448,8 +3448,8 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { } Vector<ItemFX *> fx_items; - for (List<Item *>::Element *E = main->subitems.front(); E; E = E->next()) { - Item *subitem = static_cast<Item *>(E->get()); + for (Item *E : main->subitems) { + Item *subitem = static_cast<Item *>(E); _fetch_item_fx_stack(subitem, fx_items); if (fx_items.size()) { @@ -3719,9 +3719,9 @@ String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p ItemTable *table = static_cast<ItemTable *>(it); int idx = 0; int col_count = table->columns.size(); - for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) { - ERR_CONTINUE(E->get()->type != ITEM_FRAME); // Children should all be frames. - ItemFrame *frame = static_cast<ItemFrame *>(E->get()); + for (Item *E : table->subitems) { + ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames. + ItemFrame *frame = static_cast<ItemFrame *>(E); int column = idx % col_count; for (int i = 0; i < frame->lines.size(); i++) { diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 5a12480577..0a76351885 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -956,8 +956,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) { } } - for (List<CanvasItem *>::Element *E = p_node->children_items.front(); E; E = E->next()) { - CanvasItem *ci = E->get(); + for (CanvasItem *ci : p_node->children_items) { if (ci->top_level) { continue; } @@ -1334,9 +1333,9 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) { update(); if (p_propagate) { - for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) { - if (!E->get()->top_level && E->get()->texture_filter == TEXTURE_FILTER_PARENT_NODE) { - E->get()->_update_texture_filter_changed(true); + for (CanvasItem *E : children_items) { + if (!E->top_level && E->texture_filter == TEXTURE_FILTER_PARENT_NODE) { + E->_update_texture_filter_changed(true); } } } @@ -1374,9 +1373,9 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); update(); if (p_propagate) { - for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) { - if (!E->get()->top_level && E->get()->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) { - E->get()->_update_texture_repeat_changed(true); + for (CanvasItem *E : children_items) { + if (!E->top_level && E->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) { + E->_update_texture_repeat_changed(true); } } } diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index f649380afa..588d4b67d5 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -220,8 +220,8 @@ bool HTTPRequest::_handle_response(bool *ret_value) { client->get_response_headers(&rheaders); response_headers.resize(0); downloaded.set(0); - for (List<String>::Element *E = rheaders.front(); E; E = E->next()) { - response_headers.push_back(E->get()); + for (String &E : rheaders) { + response_headers.push_back(E); } if (response_code == 301 || response_code == 302) { @@ -235,9 +235,9 @@ bool HTTPRequest::_handle_response(bool *ret_value) { String new_request; - for (List<String>::Element *E = rheaders.front(); E; E = E->next()) { - if (E->get().findn("Location: ") != -1) { - new_request = E->get().substr(9, E->get().length()).strip_edges(); + for (String &E : rheaders) { + if (E.findn("Location: ") != -1) { + new_request = E.substr(9, E.length()).strip_edges(); } } diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index 89dac5f5a8..b7c6723cfc 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -42,9 +42,9 @@ bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value) } bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const { - for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - if (E->get().name == p_name) { - r_ret = E->get().value; + for (const PropSet &E : stored_values) { + if (E.name == p_name) { + r_ret = E.value; return true; } } @@ -52,10 +52,10 @@ bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const { } void InstancePlaceholder::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { + for (const PropSet &E : stored_values) { PropertyInfo pi; - pi.name = E->get().name; - pi.type = E->get().value.get_type(); + pi.name = E.name; + pi.type = E.value.get_type(); pi.usage = PROPERTY_USAGE_STORAGE; p_list->push_back(pi); @@ -95,8 +95,8 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene scene->set_name(get_name()); int pos = get_index(); - for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - scene->set(E->get().name, E->get().value); + for (PropSet &E : stored_values) { + scene->set(E.name, E.value); } if (p_replace) { @@ -114,10 +114,10 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) { Dictionary ret; PackedStringArray order; - for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) { - ret[E->get().name] = E->get().value; + for (PropSet &E : stored_values) { + ret[E.name] = E.value; if (p_with_order) { - order.push_back(E->get().name); + order.push_back(E.name); } }; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0d060240de..4b496d4761 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1597,8 +1597,8 @@ Array Node::_get_groups() const { Array groups; List<GroupInfo> gi; get_groups(&gi); - for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) { - groups.push_back(E->get().name); + for (GroupInfo &E : gi) { + groups.push_back(E.name); } return groups; @@ -1947,18 +1947,18 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const List<PropertyInfo> plist; N->get()->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; + String name = E.name; if (name == script_property_name) { continue; } Variant value = N->get()->get(name).duplicate(true); - if (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) { + if (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) { Resource *res = Object::cast_to<Resource>(value); if (res) { // Duplicate only if it's a resource current_node->set(name, res->duplicate()); @@ -1983,14 +1983,14 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (p_flags & DUPLICATE_GROUPS) { List<GroupInfo> gi; get_groups(&gi); - for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) { + for (GroupInfo &E : gi) { #ifdef TOOLS_ENABLED - if ((p_flags & DUPLICATE_FROM_EDITOR) && !E->get().persistent) { + if ((p_flags & DUPLICATE_FROM_EDITOR) && !E.persistent) { continue; } #endif - node->add_to_group(E->get().name, E->get().persistent); + node->add_to_group(E.name, E.persistent); } } @@ -2014,21 +2014,21 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const } } - for (List<const Node *>::Element *E = hidden_roots.front(); E; E = E->next()) { - Node *parent = node->get_node(get_path_to(E->get()->data.parent)); + for (const Node *&E : hidden_roots) { + Node *parent = node->get_node(get_path_to(E->data.parent)); if (!parent) { memdelete(node); return nullptr; } - Node *dup = E->get()->_duplicate(p_flags, r_duplimap); + Node *dup = E->_duplicate(p_flags, r_duplimap); if (!dup) { memdelete(node); return nullptr; } parent->add_child(dup); - int pos = E->get()->get_index(); + int pos = E->get_index(); if (pos < parent->get_child_count() - 1) { parent->move_child(dup, pos); @@ -2073,17 +2073,17 @@ void Node::remap_node_resources(Node *p_node, const Map<RES, RES> &p_resource_re List<PropertyInfo> props; p_node->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_node->get(E->get().name); + Variant v = p_node->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (p_resource_remap.has(res)) { - p_node->set(E->get().name, p_resource_remap[res]); + p_node->set(E.name, p_resource_remap[res]); remap_nested_resources(res, p_resource_remap); } } @@ -2099,17 +2099,17 @@ void Node::remap_nested_resources(RES p_resource, const Map<RES, RES> &p_resourc List<PropertyInfo> props; p_resource->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_resource->get(E->get().name); + Variant v = p_resource->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (p_resource_remap.has(res)) { - p_resource->set(E->get().name, p_resource_remap[res]); + p_resource->set(E.name, p_resource_remap[res]); remap_nested_resources(res, p_resource_remap); } } @@ -2135,13 +2135,13 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { List<Connection> conns; n->get_all_signal_connections(&conns); - for (List<Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().flags & CONNECT_PERSIST) { + for (Connection &E : conns) { + if (E.flags & CONNECT_PERSIST) { //user connected NodePath p = p_original->get_path_to(n); Node *copy = p_copy->get_node(p); - Node *target = Object::cast_to<Node>(E->get().callable.get_object()); + Node *target = Object::cast_to<Node>(E.callable.get_object()); if (!target) { continue; } @@ -2158,9 +2158,9 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { } if (copy && copytarget) { - const Callable copy_callable = Callable(copytarget, E->get().callable.get_method()); - if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) { - copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags); + const Callable copy_callable = Callable(copytarget, E.callable.get_method()); + if (!copy->is_connected(E.signal.get_name(), copy_callable)) { + copy->connect(E.signal.get_name(), copy_callable, E.binds, E.flags); } } } @@ -2194,8 +2194,8 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) { List<GroupInfo> groups; get_groups(&groups); - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - p_node->add_to_group(E->get().name, E->get().persistent); + for (GroupInfo &E : groups) { + p_node->add_to_group(E.name, E.persistent); } } @@ -2241,9 +2241,7 @@ void Node::_replace_connections_target(Node *p_new_target) { List<Connection> cl; get_signals_connected_to_this(&cl); - for (List<Connection>::Element *E = cl.front(); E; E = E->next()) { - Connection &c = E->get(); - + for (Connection &c : cl) { if (c.flags & CONNECT_PERSIST) { c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method())); bool valid = p_new_target->has_method(c.callable.get_method()) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.callable.get_method()); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 644ce92018..8bca76a794 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -94,8 +94,7 @@ void SceneTreeTimer::release_connections() { List<Connection> connections; get_all_signal_connections(&connections); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Connection const &connection = E->get(); + for (Connection &connection : connections) { disconnect(connection.signal.get_name(), connection.callable); } } @@ -572,8 +571,8 @@ void SceneTree::finalize() { } // cleanup timers - for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E; E = E->next()) { - E->get()->release_connections(); + for (Ref<SceneTreeTimer> E : timers) { + E->release_connections(); } timers.clear(); } @@ -1147,8 +1146,8 @@ Array SceneTree::get_processed_tweens() { ret.resize(tweens.size()); int i = 0; - for (List<Ref<Tween>>::Element *E = tweens.front(); E; E = E->next()) { - ret[i] = E->get(); + for (Ref<Tween> E : tweens) { + ret[i] = E; i++; } @@ -1403,11 +1402,11 @@ SceneTree::SceneTree() { List<String> exts; ResourceLoader::get_recognized_extensions_for_type("Environment", &exts); String ext_hint; - for (List<String>::Element *E = exts.front(); E; E = E->next()) { + for (String &E : exts) { if (ext_hint != String()) { ext_hint += ","; } - ext_hint += "*." + E->get(); + ext_hint += "*." + E; } // Get path. String env_path = GLOBAL_DEF("rendering/environment/defaults/default_environment", ""); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 34a871b993..4231072ed9 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -573,8 +573,7 @@ void Viewport::_process_picking() { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame bool has_mouse_event = false; - for (List<Ref<InputEvent>>::Element *E = physics_picking_events.front(); E; E = E->next()) { - Ref<InputEventMouse> m = E->get(); + for (Ref<InputEvent> m : physics_picking_events) { if (m.is_valid()) { has_mouse_event = true; break; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index bf7512e8eb..4ebfe301ab 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1356,14 +1356,14 @@ void Window::_validate_property(PropertyInfo &property) const { Vector<StringName> unique_names; String hint_string; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (StringName &E : names) { // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - hint_string += String(E->get()) + ","; - unique_names.append(E->get()); + hint_string += String(E) + ","; + unique_names.append(E); } property.hint_string = hint_string; diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 1484007333..920ee2e5ab 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -228,8 +228,8 @@ private: value_track_get_key_indices(p_track, p_time, p_delta, &idxs); Vector<int> idxr; - for (List<int>::Element *E = idxs.front(); E; E = E->next()) { - idxr.push_back(E->get()); + for (int &E : idxs) { + idxr.push_back(E); } return idxr; } @@ -238,8 +238,8 @@ private: method_track_get_key_indices(p_track, p_time, p_delta, &idxs); Vector<int> idxr; - for (List<int>::Element *E = idxs.front(); E; E = E->next()) { - idxr.push_back(E->get()); + for (int &E : idxs) { + idxr.push_back(E); } return idxr; } diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 53979e16df..71b4542970 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -729,8 +729,8 @@ void Curve2D::_bake() const { Vector2 *w = baked_point_cache.ptrw(); int idx = 0; - for (List<Vector2>::Element *E = pointlist.front(); E; E = E->next()) { - w[idx] = E->get(); + for (Vector2 &E : pointlist) { + w[idx] = E; idx++; } } @@ -1239,9 +1239,9 @@ void Curve3D::_bake() const { Vector3 prev_up = Vector3(0, 1, 0); Vector3 prev_forward = Vector3(0, 0, 1); - for (List<Plane>::Element *E = pointlist.front(); E; E = E->next()) { - w[idx] = E->get().normal; - wt[idx] = E->get().d; + for (Plane &E : pointlist) { + w[idx] = E.normal; + wt[idx] = E.d; if (!up_vector_enabled) { idx++; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 7d49533afd..fbeb331f13 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -278,8 +278,8 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id if (shader.is_valid()) { List<PropertyInfo> pl; shader->get_param_list(&pl); - for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) { - r_options->push_back(quote_style + E->get().name.replace_first("shader_param/", "") + quote_style); + for (PropertyInfo &E : pl) { + r_options->push_back(quote_style + E.name.replace_first("shader_param/", "") + quote_style); } } } diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index d2be2bdba1..d679a17c15 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -329,9 +329,7 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); - + for (Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; @@ -366,8 +364,8 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() { { Vector3 *w = varr.ptrw(); int idx = 0; - for (List<Vector3>::Element *E = lines.front(); E; E = E->next()) { - w[idx++] = E->get(); + for (Vector3 &E : lines) { + w[idx++] = E; } } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 9bb2a4ddb8..8018ce3a9b 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -206,8 +206,8 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { node->set(snames[nprops[j].name], props[nprops[j].value], &valid); //restore old state for new script, if exists - for (List<Pair<StringName, Variant>>::Element *E = old_state.front(); E; E = E->next()) { - node->set(E->get().first, E->get().second); + for (Pair<StringName, Variant> &E : old_state) { + node->set(E.first, E.second); } } else { Variant value = props[nprops[j].value]; @@ -477,13 +477,13 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map script->update_exports(); } - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; - Variant value = p_node->get(E->get().name); + String name = E.name; + Variant value = p_node->get(E.name); bool isdefault = false; Variant default_value = ClassDB::class_get_default_property_value(type, name); @@ -497,7 +497,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } // the version above makes more sense, because it does not rely on placeholder or usage flag // in the script, just the default value function. - // if (E->get().usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) { + // if (E.usage & PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE) { // isdefault = true; //is script default value // } @@ -507,7 +507,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map // only save what has been changed // only save changed properties in instance - if ((E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E->get().name == "__meta__") { + if ((E.usage & PROPERTY_USAGE_NO_INSTANCE_STATE) || E.name == "__meta__") { //property has requested that no instance state is saved, sorry //also, meta won't be overridden or saved continue; @@ -520,7 +520,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map //check all levels of pack to see if the property exists somewhere const PackState &ps = F->get(); - original = ps.state->get_property_value(ps.node, E->get().name, exists); + original = ps.state->get_property_value(ps.node, E.name, exists); if (exists) { break; } @@ -565,9 +565,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map List<Node::GroupInfo> groups; p_node->get_groups(&groups); - for (List<Node::GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo &gi = E->get(); - + for (Node::GroupInfo &gi : groups) { if (!gi.persistent) { continue; } @@ -577,9 +575,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map */ bool skip = false; - for (List<PackState>::Element *F = pack_state_stack.front(); F; F = F->next()) { + for (PackState &F : pack_state_stack) { //check all levels of pack to see if the group was added somewhere - const PackState &ps = F->get(); + const PackState &ps = F; if (ps.state->is_node_in_group(ps.node, gi.name)) { skip = true; break; @@ -679,14 +677,14 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName //ERR_FAIL_COND_V( !node_map.has(p_node), ERR_BUG); //NodeData &nd = nodes[node_map[p_node]]; - for (List<MethodInfo>::Element *E = _signals.front(); E; E = E->next()) { + for (MethodInfo &E : _signals) { List<Node::Connection> conns; - p_node->get_signal_connection_list(E->get().name, &conns); + p_node->get_signal_connection_list(E.name, &conns); conns.sort(); - for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) { - const Node::Connection &c = F->get(); + for (Node::Connection &F : conns) { + const Node::Connection &c = F; if (!(c.flags & CONNECT_PERSIST)) { //only persistent connections get saved continue; diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 5cf107e8ea..b0257059f0 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1167,12 +1167,12 @@ Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) int prop_count = 0; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - String name = E->get().name; + String name = E.name; Variant value = packed_scene->get(name); Map<StringName, int> empty_string_map; //unused @@ -1488,8 +1488,8 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, Dictionary d = p_variant; List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - Variant v = d[E->get()]; + for (Variant &E : keys) { + Variant v = d[E]; _find_resources(v); } } break; diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index f19d08dbb1..424a54f344 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -72,13 +72,12 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const { params_cache.clear(); params_cache_dirty = false; - for (List<PropertyInfo>::Element *E = local.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : local) { if (default_textures.has(pi.name)) { //do not show default textures continue; } pi.name = "shader_param/" + pi.name; - params_cache[pi.name] = E->get().name; + params_cache[pi.name] = pi.name; if (p_params) { //small little hack if (pi.type == Variant::RID) { diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp index df80084c5c..5fdabb6f0f 100644 --- a/scene/resources/sprite_frames.cpp +++ b/scene/resources/sprite_frames.cpp @@ -100,8 +100,8 @@ Vector<String> SpriteFrames::_get_animation_list() const { Vector<String> ret; List<StringName> al; get_animation_list(&al); - for (List<StringName>::Element *E = al.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (StringName &E : al) { + ret.push_back(E); } return ret; diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index bf889d7a1c..ac6bffb20b 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -529,8 +529,8 @@ void CodeHighlighter::set_color_regions(const Dictionary &p_color_regions) { List<Variant> keys; p_color_regions.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (Variant &E : keys) { + String key = E; String start_key = key.get_slice(" ", 0); String end_key = key.get_slice_count(" ") > 1 ? key.get_slice(" ", 1) : String(); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 303bbf38f4..5eb35ce3ff 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -447,8 +447,8 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { // Sort and store properties. list.sort(); - for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (PropertyInfo &E : list) { + p_list->push_back(E); } } @@ -1275,15 +1275,15 @@ void Theme::get_type_variation_list(const StringName &p_base_type, List<StringNa return; } - for (const List<StringName>::Element *E = variation_base_map[p_base_type].front(); E; E = E->next()) { + for (const StringName &E : variation_base_map[p_base_type]) { // Prevent infinite loops if variants were set to be cross-dependent (that's still invalid usage, but handling for stability sake). - if (p_list->find(E->get())) { + if (p_list->find(E)) { continue; } - p_list->push_back(E->get()); + p_list->push_back(E); // Continue looking for sub-variations. - get_type_variation_list(E->get(), p_list); + get_type_variation_list(E, p_list); } } diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index f9b5a4cfec..2ab9d4b5a3 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -4357,14 +4357,14 @@ void TileSetPluginAtlasRendering::update_dirty_quadrants(TileMap *p_tile_map, Se RenderingServer *rs = RenderingServer::get_singleton(); // Free the canvas items. - for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - rs->free(E->get()); + for (RID E : q.canvas_items) { + rs->free(E); } q.canvas_items.clear(); // Free the occluders. - for (List<RID>::Element *E = q.occluders.front(); E; E = E->next()) { - rs->free(E->get()); + for (RID E : q.occluders) { + rs->free(E); } q.occluders.clear(); @@ -4473,8 +4473,8 @@ void TileSetPluginAtlasRendering::update_dirty_quadrants(TileMap *p_tile_map, Se // Sort the quadrants for (Map<Vector2i, Vector2i, TileMapQuadrant::CoordsWorldComparator>::Element *E = world_to_map.front(); E; E = E->next()) { TileMapQuadrant &q = quadrant_map[E->value()]; - for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++); + for (RID F : q.canvas_items) { + RS::get_singleton()->canvas_item_set_draw_index(F, index++); } } @@ -4491,14 +4491,14 @@ void TileSetPluginAtlasRendering::create_quadrant(TileMap *p_tile_map, TileMapQu void TileSetPluginAtlasRendering::cleanup_quadrant(TileMap *p_tile_map, TileMapQuadrant *p_quadrant) { // Free the canvas items. - for (List<RID>::Element *E = p_quadrant->canvas_items.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get()); + for (RID E : p_quadrant->canvas_items) { + RenderingServer::get_singleton()->free(E); } p_quadrant->canvas_items.clear(); // Free the occluders. - for (List<RID>::Element *E = p_quadrant->occluders.front(); E; E = E->next()) { - RenderingServer::get_singleton()->free(E->get()); + for (RID E : p_quadrant->occluders) { + RenderingServer::get_singleton()->free(E); } p_quadrant->occluders.clear(); } diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index ef380ab233..752c026aa6 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -628,8 +628,8 @@ bool VisualShader::is_node_connection(Type p_type, int p_from_node, int p_from_p ERR_FAIL_INDEX_V(p_type, TYPE_MAX, false); const Graph *g = &graph[p_type]; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (const Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { return true; } } @@ -642,12 +642,12 @@ bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_nod const VisualShader::Node &node = p_graph->nodes[p_node]; - for (const List<int>::Element *E = node.prev_connected_nodes.front(); E; E = E->next()) { - if (E->get() == p_target) { + for (const int &E : node.prev_connected_nodes) { + if (E == p_target) { return true; } - result = is_nodes_connected_relatively(p_graph, E->get(), p_target); + result = is_nodes_connected_relatively(p_graph, E, p_target); if (result) { break; } @@ -686,8 +686,8 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po return false; } - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (const Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { return false; } } @@ -739,8 +739,8 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port, ERR_FAIL_COND_V_MSG(!is_port_types_compatible(from_port_type, to_port_type), ERR_INVALID_PARAMETER, "Incompatible port types (scalar/vec/bool) with transform."); - for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + for (Connection &E : g->connections) { + if (E.from_node == p_from_node && E.from_port == p_from_port && E.to_node == p_to_node && E.to_port == p_to_port) { ERR_FAIL_V(ERR_ALREADY_EXISTS); } } @@ -763,7 +763,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por ERR_FAIL_INDEX(p_type, TYPE_MAX); Graph *g = &graph[p_type]; - for (List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { + for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { g->connections.erase(E); g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node); @@ -780,12 +780,12 @@ Array VisualShader::_get_node_connections(Type p_type) const { const Graph *g = &graph[p_type]; Array ret; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { + for (const Connection &E : g->connections) { Dictionary d; - d["from_node"] = E->get().from_node; - d["from_port"] = E->get().from_port; - d["to_node"] = E->get().to_node; - d["to_port"] = E->get().to_port; + d["from_node"] = E.from_node; + d["from_port"] = E.from_port; + d["to_node"] = E.to_node; + d["to_port"] = E.to_port; ret.push_back(d); } @@ -796,8 +796,8 @@ void VisualShader::get_node_connections(Type p_type, List<Connection> *r_connect ERR_FAIL_INDEX(p_type, TYPE_MAX); const Graph *g = &graph[p_type]; - for (const List<Connection>::Element *E = g->connections.front(); E; E = E->next()) { - r_connections->push_back(E->get()); + for (const Connection &E : g->connections) { + r_connections->push_back(E); } } @@ -1190,11 +1190,11 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const { String index = name.get_slicec('/', 2); if (index == "connections") { Vector<int> conns; - for (const List<Connection>::Element *E = graph[type].connections.front(); E; E = E->next()) { - conns.push_back(E->get().from_node); - conns.push_back(E->get().from_port); - conns.push_back(E->get().to_node); - conns.push_back(E->get().to_port); + for (const Connection &E : graph[type].connections) { + conns.push_back(E.from_node); + conns.push_back(E.from_port); + conns.push_back(E.to_node); + conns.push_back(E.to_port); } r_ret = conns; @@ -1791,8 +1791,8 @@ void VisualShader::_update_shader() const { ERR_FAIL_COND(err != OK); if (emitters.has(i)) { - for (List<int>::Element *E = emitters[i].front(); E; E = E->next()) { - err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E->get(), processed, false, classes); + for (int &E : emitters[i]) { + err = _write_node(Type(i), global_code, global_code_per_node, global_code_per_func, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes); ERR_FAIL_COND(err != OK); } } @@ -2586,8 +2586,8 @@ void VisualShaderNodeUniformRef::clear_uniforms() { } bool VisualShaderNodeUniformRef::has_uniform(const String &p_name) { - for (List<VisualShaderNodeUniformRef::Uniform>::Element *E = uniforms.front(); E; E = E->next()) { - if (E->get().name == p_name) { + for (VisualShaderNodeUniformRef::Uniform &E : uniforms) { + if (E.name == p_name) { return true; } } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 6f244deb1e..0a01d0c0b0 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -532,13 +532,13 @@ void Body2DSW::integrate_velocities(real_t p_step) { } void Body2DSW::wakeup_neighbours() { - for (List<Pair<Constraint2DSW *, int>>::Element *E = constraint_list.front(); E; E = E->next()) { - const Constraint2DSW *c = E->get().first; + for (Pair<Constraint2DSW *, int> &E : constraint_list) { + const Constraint2DSW *c = E.first; Body2DSW **n = c->get_body_ptr(); int bc = c->get_body_count(); for (int i = 0; i < bc; i++) { - if (i == E->get().second) { + if (i == E.second) { continue; } Body2DSW *b = n[i]; diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index b8cb4cddc5..8b30160cc1 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -46,8 +46,8 @@ void Step2DSW::_populate_island(Body2DSW *p_body, LocalVector<Body2DSW *> &p_bod p_body_island.push_back(p_body); } - for (const List<Pair<Constraint2DSW *, int>>::Element *E = p_body->get_constraint_list().front(); E; E = E->next()) { - Constraint2DSW *constraint = (Constraint2DSW *)E->get().first; + for (const Pair<Constraint2DSW *, int> &E : p_body->get_constraint_list()) { + Constraint2DSW *constraint = (Constraint2DSW *)E.first; if (constraint->get_island_step() == _step) { continue; // Already processed. } @@ -56,7 +56,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, LocalVector<Body2DSW *> &p_bod all_constraints.push_back(constraint); for (int i = 0; i < constraint->get_body_count(); i++) { - if (i == E->get().second) { + if (i == E.second) { continue; } Body2DSW *other_body = constraint->get_body_ptr()[i]; diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 2657fa3ae8..9d898f6275 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -2716,9 +2716,7 @@ void RendererStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_su mesh->surfaces[mesh->surface_count] = s; mesh->surface_count++; - for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) { - //update instances - MeshInstance *mi = E->get(); + for (MeshInstance *mi : mesh->instances) { _mesh_instance_add_surface(mi, mesh, mesh->surface_count - 1); } @@ -3029,8 +3027,7 @@ void RendererStorageRD::mesh_clear(RID p_mesh) { mesh->surface_count = 0; mesh->material_cache.clear(); //clear instance data - for (List<MeshInstance *>::Element *E = mesh->instances.front(); E; E = E->next()) { - MeshInstance *mi = E->get(); + for (MeshInstance *mi : mesh->instances) { _mesh_instance_clear(mi); } mesh->has_bone_weights = false; @@ -8413,10 +8410,10 @@ void RendererStorageRD::global_variables_load_settings(bool p_load_textures) { List<PropertyInfo> settings; ProjectSettings::get_singleton()->get_property_list(&settings); - for (List<PropertyInfo>::Element *E = settings.front(); E; E = E->next()) { - if (E->get().name.begins_with("shader_globals/")) { - StringName name = E->get().name.get_slice("/", 1); - Dictionary d = ProjectSettings::get_singleton()->get(E->get().name); + for (PropertyInfo &E : settings) { + if (E.name.begins_with("shader_globals/")) { + StringName name = E.name.get_slice("/", 1); + Dictionary d = ProjectSettings::get_singleton()->get(E.name); ERR_CONTINUE(!d.has("type")); ERR_CONTINUE(!d.has("value")); @@ -8584,8 +8581,8 @@ void RendererStorageRD::_update_global_variables() { if (global_variables.must_update_buffer_materials) { // only happens in the case of a buffer variable added or removed, // so not often. - for (List<RID>::Element *E = global_variables.materials_using_buffer.front(); E; E = E->next()) { - Material *material = material_owner.getornull(E->get()); + for (RID E : global_variables.materials_using_buffer) { + Material *material = material_owner.getornull(E); ERR_CONTINUE(!material); //wtf _material_queue_update(material, true, false); @@ -8597,8 +8594,8 @@ void RendererStorageRD::_update_global_variables() { if (global_variables.must_update_texture_materials) { // only happens in the case of a buffer variable added or removed, // so not often. - for (List<RID>::Element *E = global_variables.materials_using_texture.front(); E; E = E->next()) { - Material *material = material_owner.getornull(E->get()); + for (RID E : global_variables.materials_using_texture) { + Material *material = material_owner.getornull(E); ERR_CONTINUE(!material); //wtf _material_queue_update(material, false, true); diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp index 1dde92d8ff..8c4070562e 100644 --- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp @@ -760,11 +760,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge if (var_frag_to_light.size() > 0) { String gcode = "\n\nstruct {\n"; - for (List<Pair<StringName, SL::ShaderNode::Varying>>::Element *E = var_frag_to_light.front(); E; E = E->next()) { - gcode += "\t" + _prestr(E->get().second.precision) + _typestr(E->get().second.type) + " " + _mkid(E->get().first); - if (E->get().second.array_size > 0) { + for (Pair<StringName, SL::ShaderNode::Varying> &E : var_frag_to_light) { + gcode += "\t" + _prestr(E.second.precision) + _typestr(E.second.type) + " " + _mkid(E.first); + if (E.second.array_size > 0) { gcode += "["; - gcode += itos(E->get().second.array_size); + gcode += itos(E.second.array_size); gcode += "]"; } gcode += ";\n"; @@ -1394,8 +1394,8 @@ void ShaderCompilerRD::initialize(DefaultIdentifierActions p_actions) { ShaderLanguage::get_builtin_funcs(&func_list); - for (List<String>::Element *E = func_list.front(); E; E = E->next()) { - internal_functions.insert(E->get()); + for (String &E : func_list) { + internal_functions.insert(E); } texture_functions.insert("texture"); texture_functions.insert("textureProj"); diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 3336623f21..2ade8454bb 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2876,8 +2876,8 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c Vector<Instance *> lights_with_shadow; - for (List<Instance *>::Element *E = scenario->directional_lights.front(); E; E = E->next()) { - if (!E->get()->visible) { + for (Instance *E : scenario->directional_lights) { + if (!E->visible) { continue; } @@ -2885,13 +2885,13 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c break; } - InstanceLightData *light = static_cast<InstanceLightData *>(E->get()->base_data); + InstanceLightData *light = static_cast<InstanceLightData *>(E->base_data); //check shadow.. if (light) { - if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->get()->base) && !(RSG::storage->light_get_type(E->get()->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->get()->base))) { - lights_with_shadow.push_back(E->get()); + if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->base) && !(RSG::storage->light_get_type(E->base) == RS::LIGHT_DIRECTIONAL && RSG::storage->light_directional_is_sky_only(E->base))) { + lights_with_shadow.push_back(E); } //add to list directional_lights.push_back(light->instance); @@ -3391,8 +3391,7 @@ void RendererSceneCull::render_probes() { idx++; } - for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) { - Instance *instance = E->get(); + for (Instance *instance : probe->owner->scenario->directional_lights) { InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { continue; @@ -3465,8 +3464,7 @@ void RendererSceneCull::render_probes() { idx++; } - for (List<Instance *>::Element *E = probe->owner->scenario->directional_lights.front(); E; E = E->next()) { - Instance *instance = E->get(); + for (Instance *instance : probe->owner->scenario->directional_lights) { InstanceLightData *instance_light = (InstanceLightData *)instance->base_data; if (!instance->visible) { continue; @@ -3573,26 +3571,26 @@ void RendererSceneCull::render_particle_colliders() { void RendererSceneCull::_update_instance_shader_parameters_from_material(Map<StringName, Instance::InstanceShaderParameter> &isparams, const Map<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) { List<RendererStorage::InstanceShaderParam> plist; RSG::storage->material_get_instance_shader_parameters(p_material, &plist); - for (List<RendererStorage::InstanceShaderParam>::Element *E = plist.front(); E; E = E->next()) { - StringName name = E->get().info.name; + for (RendererStorage::InstanceShaderParam &E : plist) { + StringName name = E.info.name; if (isparams.has(name)) { - if (isparams[name].info.type != E->get().info.type) { - WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different data types. Only the first one (in order) will display correctly."); + if (isparams[name].info.type != E.info.type) { + WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different data types. Only the first one (in order) will display correctly."); } - if (isparams[name].index != E->get().index) { - WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E->get().info.name + "', but they do it with different indices. Only the first one (in order) will display correctly."); + if (isparams[name].index != E.index) { + WARN_PRINT("More than one material in instance export the same instance shader uniform '" + E.info.name + "', but they do it with different indices. Only the first one (in order) will display correctly."); } continue; //first one found always has priority } Instance::InstanceShaderParameter isp; - isp.index = E->get().index; - isp.info = E->get().info; - isp.default_value = E->get().default_value; + isp.index = E.index; + isp.info = E.info; + isp.default_value = E.default_value; if (existing_isparams.has(name)) { isp.value = existing_isparams[name].value; } else { - isp.value = E->get().default_value; + isp.value = E.default_value; } isparams[name] = isp; } diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index 4c31880faf..df1b40974f 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -388,9 +388,9 @@ protected: versions.clear(); List<Variant> keys; p_versions.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - StringName name = E->get(); - Ref<RDShaderBytecode> bc = p_versions[E->get()]; + for (Variant &E : keys) { + StringName name = E; + Ref<RDShaderBytecode> bc = p_versions[E]; ERR_CONTINUE(bc.is_null()); versions[name] = bc; } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 3b9aca200b..2db246c31f 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -4448,12 +4448,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons String member_name = String(ident.ptr()); if (shader->structs.has(st)) { StructNode *n = shader->structs[st].shader_struct; - for (List<MemberNode *>::Element *E = n->members.front(); E; E = E->next()) { - if (String(E->get()->name) == member_name) { - member_type = E->get()->datatype; - array_size = E->get()->array_size; + for (MemberNode *E : n->members) { + if (String(E->name) == member_name) { + member_type = E->datatype; + array_size = E->array_size; if (member_type == TYPE_STRUCT) { - member_struct_name = E->get()->struct_name; + member_struct_name = E->struct_name; } ok = true; break; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index a39d0e89ee..9377075e76 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -53,15 +53,15 @@ Array RenderingServer::_texture_debug_usage_bind() { List<TextureInfo> list; texture_debug_usage(&list); Array arr; - for (const List<TextureInfo>::Element *E = list.front(); E; E = E->next()) { + for (const TextureInfo &E : list) { Dictionary dict; - dict["texture"] = E->get().texture; - dict["width"] = E->get().width; - dict["height"] = E->get().height; - dict["depth"] = E->get().depth; - dict["format"] = E->get().format; - dict["bytes"] = E->get().bytes; - dict["path"] = E->get().path; + dict["texture"] = E.texture; + dict["width"] = E.width; + dict["height"] = E.height; + dict["depth"] = E.depth; + dict["format"] = E.format; + dict["bytes"] = E.bytes; + dict["path"] = E.path; arr.push_back(dict); } return arr; @@ -972,10 +972,10 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa if (index_array_len) { List<Variant> keys; p_lods.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - float distance = E->get(); + for (Variant &E : keys) { + float distance = E; ERR_CONTINUE(distance <= 0.0); - Vector<int> indices = p_lods[E->get()]; + Vector<int> indices = p_lods[E]; ERR_CONTINUE(indices.size() == 0); uint32_t index_count = indices.size(); ERR_CONTINUE(index_count >= (uint32_t)index_array_len); //should be smaller.. diff --git a/tests/test_class_db.h b/tests/test_class_db.h index 29edf5a4a0..e67b2de66a 100644 --- a/tests/test_class_db.h +++ b/tests/test_class_db.h @@ -108,9 +108,9 @@ struct ExposedClass { List<SignalData> signals_; const PropertyData *find_property_by_name(const StringName &p_name) const { - for (const List<PropertyData>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const PropertyData &E : properties) { + if (E.name == p_name) { + return &E; } } @@ -118,9 +118,9 @@ struct ExposedClass { } const MethodData *find_method_by_name(const StringName &p_name) const { - for (const List<MethodData>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name == p_name) { - return &E->get(); + for (const MethodData &E : methods) { + if (E.name == p_name) { + return &E; } } @@ -395,8 +395,8 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons } } - for (const List<ArgumentData>::Element *F = p_method.arguments.front(); F; F = F->next()) { - const ArgumentData &arg = F->get(); + for (const ArgumentData &F : p_method.arguments) { + const ArgumentData &arg = F; const ExposedClass *arg_class = p_context.find_exposed_class(arg.type); if (arg_class) { @@ -427,8 +427,8 @@ void validate_method(const Context &p_context, const ExposedClass &p_class, cons } void validate_signal(const Context &p_context, const ExposedClass &p_class, const SignalData &p_signal) { - for (const List<ArgumentData>::Element *F = p_signal.arguments.front(); F; F = F->next()) { - const ArgumentData &arg = F->get(); + for (const ArgumentData &F : p_signal.arguments) { + const ArgumentData &arg = F; const ExposedClass *arg_class = p_context.find_exposed_class(arg.type); if (arg_class) { @@ -469,16 +469,16 @@ void validate_class(const Context &p_context, const ExposedClass &p_exposed_clas TEST_FAIL_COND((is_derived_type && !p_context.exposed_classes.has(p_exposed_class.base)), "Base type '", p_exposed_class.base.operator String(), "' does not exist, for class '", p_exposed_class.name, "'."); - for (const List<PropertyData>::Element *F = p_exposed_class.properties.front(); F; F = F->next()) { - validate_property(p_context, p_exposed_class, F->get()); + for (const PropertyData &F : p_exposed_class.properties) { + validate_property(p_context, p_exposed_class, F); } - for (const List<MethodData>::Element *F = p_exposed_class.methods.front(); F; F = F->next()) { - validate_method(p_context, p_exposed_class, F->get()); + for (const MethodData &F : p_exposed_class.methods) { + validate_method(p_context, p_exposed_class, F); } - for (const List<SignalData>::Element *F = p_exposed_class.signals_.front(); F; F = F->next()) { - validate_signal(p_context, p_exposed_class, F->get()); + for (const SignalData &F : p_exposed_class.signals_) { + validate_signal(p_context, p_exposed_class, F); } } @@ -526,9 +526,7 @@ void add_exposed_classes(Context &r_context) { Map<StringName, StringName> accessor_methods; - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - const PropertyInfo &property = E->get(); - + for (const PropertyInfo &property : property_list) { if (property.usage & PROPERTY_USAGE_GROUP || property.usage & PROPERTY_USAGE_SUBGROUP || property.usage & PROPERTY_USAGE_CATEGORY) { continue; } @@ -561,8 +559,8 @@ void add_exposed_classes(Context &r_context) { ClassDB::get_method_list(class_name, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - const MethodInfo &method_info = E->get(); + for (MethodInfo &E : method_list) { + const MethodInfo &method_info = E; int argc = method_info.arguments.size(); @@ -667,8 +665,8 @@ void add_exposed_classes(Context &r_context) { // Methods starting with an underscore are ignored unless they're virtual or used as a property setter or getter. if (!method.is_virtual && String(method.name)[0] == '_') { - for (const List<PropertyData>::Element *F = exposed_class.properties.front(); F; F = F->next()) { - const PropertyData &prop = F->get(); + for (const PropertyData &F : exposed_class.properties) { + const PropertyData &prop = F; if (prop.setter == method.name || prop.getter == method.name) { exposed_class.methods.push_back(method); @@ -752,8 +750,8 @@ void add_exposed_classes(Context &r_context) { enum_.name = *k; const List<StringName> &enum_constants = enum_map.get(*k); - for (const List<StringName>::Element *E = enum_constants.front(); E; E = E->next()) { - const StringName &constant_name = E->get(); + for (const StringName &E : enum_constants) { + const StringName &constant_name = E; TEST_FAIL_COND(String(constant_name).find("::") != -1, "Enum constant contains '::', check bindings to remove the scope: '", String(class_name), ".", String(enum_.name), ".", String(constant_name), "'."); @@ -774,12 +772,12 @@ void add_exposed_classes(Context &r_context) { r_context.enum_types.push_back(String(class_name) + "." + String(*k)); } - for (const List<String>::Element *E = constants.front(); E; E = E->next()) { - const String &constant_name = E->get(); + for (const String &E : constants) { + const String &constant_name = E; TEST_FAIL_COND(constant_name.find("::") != -1, "Constant contains '::', check bindings to remove the scope: '", String(class_name), ".", constant_name, "'."); - int *value = class_info->constant_map.getptr(StringName(E->get())); + int *value = class_info->constant_map.getptr(StringName(E)); TEST_FAIL_COND(!value, "Missing constant value: '", String(class_name), ".", String(constant_name), "'."); ConstantData constant; @@ -829,8 +827,8 @@ void add_global_enums(Context &r_context) { } } - for (List<EnumData>::Element *E = r_context.global_enums.front(); E; E = E->next()) { - r_context.enum_types.push_back(E->get().name); + for (EnumData &E : r_context.global_enums) { + r_context.enum_types.push_back(E.name); } } @@ -840,10 +838,10 @@ void add_global_enums(Context &r_context) { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (List<StringName>::Element *E = hardcoded_enums.front(); E; E = E->next()) { + for (StringName &E : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore - r_context.enum_types.push_back(E->get()); + r_context.enum_types.push_back(E); } } diff --git a/tests/test_math.cpp b/tests/test_math.cpp index 67d9a52539..d2960333cc 100644 --- a/tests/test_math.cpp +++ b/tests/test_math.cpp @@ -549,8 +549,8 @@ MainLoop *test() { List<StringName> tl; ClassDB::get_class_list(&tl); - for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - Vector<uint8_t> m5b = E->get().operator String().md5_buffer(); + for (StringName &E : tl) { + Vector<uint8_t> m5b = E.operator String().md5_buffer(); hashes.push_back(hashes.size()); } diff --git a/tests/test_render.cpp b/tests/test_render.cpp index fe223ca258..66fd04dbdd 100644 --- a/tests/test_render.cpp +++ b/tests/test_render.cpp @@ -210,12 +210,12 @@ public: //return quit; - for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) { - Transform3D pre(Basis(E->get().rot_axis, ofs), Vector3()); - vs->instance_set_transform(E->get().instance, pre * E->get().base); + for (InstanceInfo &E : instances) { + Transform3D pre(Basis(E.rot_axis, ofs), Vector3()); + vs->instance_set_transform(E.instance, pre * E.base); /* if( !E->next() ) { - vs->free( E->get().instance ); + vs->free( E.instance ); instances.erase(E ); }*/ } diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index f6a56f1f5d..3e353d7eec 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -353,8 +353,8 @@ public: } // Remove disconnected peers from map. - for (List<String>::Element *E = remove.front(); E; E = E->next()) { - peers.erase(E->get()); + for (String &E : remove) { + peers.erase(E); } return err; // OK, ERR_BUSY, or possibly an error. |