From e4dfa69bcf58e4d50acdde32c590364e43fce3ab Mon Sep 17 00:00:00 2001 From: Lightning_A Date: Mon, 9 Aug 2021 09:03:45 -0600 Subject: Fix non-const iterators in const methods --- editor/animation_track_editor.cpp | 11 ++++------- scene/animation/animation_blend_tree.cpp | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 324237ff82..76e71a1030 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -702,8 +702,7 @@ public: for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { if (from != key_ofs) { key++; continue; @@ -728,8 +727,7 @@ public: bool change_notify_deserved = false; for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +984,7 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,7 +1134,7 @@ public: same_key_type = false; } - for (float &F : E->value()) { + for (const float &F : E->value()) { int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index af186072ac..c5f36bb98d 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -978,7 +978,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node for (Map::Element *E = nodes.front(); E; E = E->next()) { for (int i = 0; i < E->get().connections.size(); i++) { - StringName output = E->get().connections[i]; + const StringName output = E->get().connections[i]; if (output == p_output_node) { return CONNECTION_ERROR_CONNECTION_EXISTS; } @@ -990,7 +990,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node void AnimationNodeBlendTree::get_node_connections(List *r_connections) const { for (Map::Element *E = nodes.front(); E; E = E->next()) { for (int i = 0; i < E->get().connections.size(); i++) { - StringName output = E->get().connections[i]; + const StringName output = E->get().connections[i]; if (output != StringName()) { NodeConnection nc; nc.input_node = E->key(); -- cgit v1.2.3 From c63b18507d21b8a213c073bced9057b571cdcd7a Mon Sep 17 00:00:00 2001 From: Lightning_A Date: Mon, 9 Aug 2021 14:13:42 -0600 Subject: Use range iterators for `Map` --- core/config/project_settings.cpp | 36 ++-- core/core_bind.cpp | 8 +- core/debugger/engine_debugger.cpp | 10 +- core/debugger/local_debugger.cpp | 8 +- core/debugger/remote_debugger.cpp | 4 +- core/extension/extension_api_dump.cpp | 6 +- core/extension/native_extension_manager.cpp | 12 +- core/input/input.cpp | 14 +- core/io/file_access_pack.cpp | 8 +- core/io/ip.cpp | 8 +- core/io/resource.cpp | 4 +- core/io/resource_format_binary.cpp | 4 +- core/io/resource_loader.cpp | 4 +- core/math/quick_hull.cpp | 24 +-- core/math/triangle_mesh.cpp | 4 +- core/object/message_queue.cpp | 12 +- core/object/script_language.cpp | 4 +- core/string/optimized_translation.cpp | 10 +- core/string/translation.cpp | 12 +- core/variant/variant_call.cpp | 8 +- drivers/unix/net_socket_posix.cpp | 4 +- drivers/vulkan/rendering_device_vulkan.cpp | 6 +- drivers/vulkan/vulkan_context.cpp | 16 +- editor/animation_bezier_editor.cpp | 18 +- editor/animation_track_editor.cpp | 36 ++-- editor/audio_stream_preview.cpp | 16 +- .../debug_adapter/debug_adapter_parser.cpp | 4 +- editor/debugger/editor_debugger_inspector.cpp | 6 +- editor/debugger/editor_debugger_node.cpp | 10 +- editor/debugger/editor_network_profiler.cpp | 12 +- editor/debugger/editor_profiler.cpp | 16 +- editor/dependency_editor.cpp | 20 +-- editor/doc_tools.cpp | 14 +- editor/editor_autoload_settings.cpp | 4 +- editor/editor_data.cpp | 14 +- editor/editor_export.cpp | 6 +- editor/editor_feature_profile.cpp | 6 +- editor/editor_file_system.cpp | 10 +- editor/editor_help.cpp | 18 +- editor/editor_inspector.cpp | 24 +-- editor/editor_log.cpp | 16 +- editor/editor_node.cpp | 14 +- editor/editor_run_native.cpp | 6 +- editor/editor_settings.cpp | 18 +- editor/filesystem_dock.cpp | 8 +- editor/find_in_files.cpp | 4 +- editor/import/collada.cpp | 20 +-- editor/import/editor_import_collada.cpp | 20 +-- editor/import/editor_importer_bake_reset.cpp | 8 +- editor/import/resource_importer_texture.cpp | 16 +- editor/import/scene_import_settings.cpp | 58 +++---- editor/import/scene_importer_mesh.cpp | 4 +- editor/import_defaults_editor.cpp | 6 +- .../plugins/animation_blend_tree_editor_plugin.cpp | 10 +- editor/plugins/asset_library_editor_plugin.cpp | 14 +- editor/plugins/canvas_item_editor_plugin.cpp | 36 ++-- editor/plugins/node_3d_editor_gizmos.cpp | 8 +- editor/plugins/node_3d_editor_plugin.cpp | 54 +++--- editor/plugins/shader_editor_plugin.cpp | 6 +- editor/plugins/theme_editor_plugin.cpp | 10 +- editor/plugins/tiles/tile_atlas_view.cpp | 8 +- editor/plugins/tiles/tile_data_editors.cpp | 94 +++++------ editor/plugins/tiles/tile_map_editor.cpp | 186 ++++++++++----------- .../plugins/tiles/tile_set_atlas_source_editor.cpp | 10 +- editor/plugins/visual_shader_editor_plugin.cpp | 14 +- editor/progress_dialog.cpp | 6 +- editor/scene_tree_dock.cpp | 8 +- editor/script_create_dialog.cpp | 4 +- editor/settings_config_dialog.cpp | 4 +- modules/bullet/bullet_physics_server.cpp | 4 +- modules/bullet/shape_bullet.cpp | 4 +- modules/csg/csg.cpp | 8 +- modules/fbx/data/fbx_skeleton.cpp | 6 +- modules/fbx/editor_scene_importer_fbx.cpp | 34 ++-- modules/fbx/tools/validation_tools.h | 6 +- .../gdnative/gdnative_library_editor_plugin.cpp | 18 +- modules/gdnative/nativescript/api_generator.cpp | 4 +- modules/gdnative/nativescript/nativescript.cpp | 124 +++++++------- modules/gdscript/gdscript.cpp | 148 ++++++++-------- modules/gdscript/gdscript_analyzer.cpp | 6 +- modules/gdscript/gdscript_byte_codegen.cpp | 56 +++---- modules/gdscript/gdscript_byte_codegen.h | 6 +- modules/gdscript/gdscript_compiler.cpp | 8 +- modules/gdscript/gdscript_editor.cpp | 38 ++--- modules/gdscript/gdscript_function.cpp | 8 +- modules/gdscript/gdscript_parser.cpp | 6 +- modules/gdscript/gdscript_utility_functions.cpp | 12 +- modules/gdscript/gdscript_vm.cpp | 4 +- .../language_server/gdscript_language_protocol.cpp | 8 +- .../language_server/gdscript_text_document.cpp | 4 +- .../language_server/gdscript_workspace.cpp | 32 ++-- modules/gdscript/language_server/lsp.hpp | 10 +- modules/gdscript/tests/test_gdscript.cpp | 4 +- modules/gltf/gltf_document.cpp | 64 +++---- modules/gridmap/grid_map.cpp | 104 ++++++------ modules/navigation/nav_map.cpp | 12 +- modules/text_server_adv/text_server_adv.cpp | 166 +++++++++--------- modules/text_server_fb/text_server_fb.cpp | 178 ++++++++++---------- modules/visual_script/visual_script.cpp | 32 ++-- modules/visual_script/visual_script_editor.cpp | 24 +-- modules/webrtc/webrtc_multiplayer_peer.cpp | 36 ++-- modules/websocket/websocket_multiplayer_peer.cpp | 20 +-- modules/websocket/wsl_server.cpp | 12 +- platform/javascript/export/export_plugin.cpp | 4 +- platform/linuxbsd/display_server_x11.cpp | 98 +++++------ platform/windows/display_server_windows.cpp | 32 ++-- scene/2d/area_2d.cpp | 28 ++-- scene/2d/collision_object_2d.cpp | 24 +-- scene/2d/physics_body_2d.cpp | 26 +-- scene/2d/tile_map.cpp | 140 ++++++++-------- scene/3d/area_3d.cpp | 28 ++-- scene/3d/collision_object_3d.cpp | 40 ++--- scene/3d/mesh_instance_3d.cpp | 4 +- scene/3d/physics_body_3d.cpp | 26 +-- scene/animation/animation_blend_tree.cpp | 54 +++--- scene/animation/animation_node_state_machine.cpp | 18 +- scene/animation/animation_player.cpp | 44 ++--- scene/debugger/scene_debugger.cpp | 16 +- scene/gui/code_edit.cpp | 16 +- scene/gui/graph_node.cpp | 12 +- scene/gui/grid_container.cpp | 20 +-- scene/main/node.cpp | 26 +-- scene/main/resource_preloader.cpp | 8 +- scene/resources/curve.cpp | 8 +- scene/resources/mesh.cpp | 4 +- scene/resources/mesh_library.cpp | 14 +- scene/resources/navigation_mesh.cpp | 8 +- scene/resources/packed_scene.cpp | 22 +-- scene/resources/resource_format_text.cpp | 32 ++-- scene/resources/shader.cpp | 4 +- scene/resources/sprite_frames.cpp | 20 +-- scene/resources/tile_set.cpp | 164 +++++++++--------- scene/resources/visual_shader.cpp | 52 +++--- servers/physics_2d/shape_2d_sw.cpp | 10 +- servers/physics_3d/body_3d_sw.cpp | 6 +- servers/physics_3d/shape_3d_sw.cpp | 4 +- servers/physics_3d/step_3d_sw.cpp | 6 +- .../scene_shader_forward_clustered.cpp | 28 ++-- .../forward_mobile/scene_shader_forward_mobile.cpp | 28 ++-- .../renderer_rd/renderer_canvas_render_rd.cpp | 28 ++-- .../renderer_rd/renderer_scene_render_rd.cpp | 8 +- .../renderer_rd/renderer_scene_sky_rd.cpp | 28 ++-- .../rendering/renderer_rd/renderer_storage_rd.cpp | 70 ++++---- .../rendering/renderer_rd/shader_compiler_rd.cpp | 14 +- servers/rendering/renderer_rd/shader_rd.cpp | 16 +- servers/rendering/renderer_scene_cull.cpp | 10 +- servers/rendering/renderer_storage.cpp | 20 +-- servers/rendering/renderer_viewport.cpp | 42 ++--- servers/rendering/rendering_device_binds.cpp | 6 +- servers/rendering/rendering_device_binds.h | 10 +- servers/rendering/shader_language.cpp | 92 +++++----- servers/rendering/shader_warnings.cpp | 8 +- tests/test_math.cpp | 4 +- tests/test_shader_lang.cpp | 28 ++-- 154 files changed, 1897 insertions(+), 1897 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 09f9f84728..85e83ff7f2 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -252,15 +252,15 @@ void ProjectSettings::_get_property_list(List *p_list) const { Set<_VCSort> vclist; - for (Map::Element *E = props.front(); E; E = E->next()) { - const VariantContainer *v = &E->get(); + for (const KeyValue &E : props) { + const VariantContainer *v = &E.value; if (v->hide_from_editor) { continue; } _VCSort vc; - vc.name = E->key(); + vc.name = E.key; vc.order = v->order; vc.type = v->variant.get_type(); if (vc.name.begins_with("input/") || vc.name.begins_with("import/") || vc.name.begins_with("export/") || vc.name.begins_with("/remap") || vc.name.begins_with("/locale") || vc.name.begins_with("/autoload")) { @@ -318,14 +318,14 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_f void ProjectSettings::_convert_to_last_version(int p_from_version) { if (p_from_version <= 3) { // Converts the actions from array to dictionary (array of events to dictionary with deadzone + events) - for (Map::Element *E = props.front(); E; E = E->next()) { - Variant value = E->get().variant; - if (String(E->key()).begins_with("input/") && value.get_type() == Variant::ARRAY) { + for (KeyValue &E : props) { + Variant value = E.value.variant; + if (String(E.key).begins_with("input/") && value.get_type() == Variant::ARRAY) { Array array = value; Dictionary action; action["deadzone"] = Variant(0.5f); action["events"] = array; - E->get().variant = action; + E.value.variant = action; } } } @@ -695,8 +695,8 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map>::Element *E = props.front(); E; E = E->next()) { - count += E->get().size(); + for (const KeyValue> &E : props) { + count += E.value.size(); } if (p_custom_features != String()) { @@ -788,7 +788,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_string("\n"); - for (Map>::Element *E = props.front(); E; E = E->next()) { + for (const Map>::Element *E = props.front(); E; E = E->next()) { if (E != props.front()) { file->store_string("\n"); } @@ -831,19 +831,19 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust Set<_VCSort> vclist; if (p_merge_with_current) { - for (Map::Element *G = props.front(); G; G = G->next()) { - const VariantContainer *v = &G->get(); + for (const KeyValue &G : props) { + const VariantContainer *v = &G.value; if (v->hide_from_editor) { continue; } - if (p_custom.has(G->key())) { + if (p_custom.has(G.key)) { continue; } _VCSort vc; - vc.name = G->key(); //*k; + vc.name = G.key; //*k; vc.order = v->order; vc.type = v->variant.get_type(); vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE; @@ -855,14 +855,14 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } } - for (const Map::Element *E = p_custom.front(); E; E = E->next()) { + for (const KeyValue &E : p_custom) { // Lookup global prop to store in the same order - Map::Element *global_prop = props.find(E->key()); + Map::Element *global_prop = props.find(E.key); _VCSort vc; - vc.name = E->key(); + vc.name = E.key; vc.order = global_prop ? global_prop->get().order : 0xFFFFFFF; - vc.type = E->get().get_type(); + vc.type = E.value.get_type(); vc.flags = PROPERTY_USAGE_STORAGE; vclist.insert(vc); } diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 1f028702f6..0b9816932c 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2411,12 +2411,12 @@ Error EngineDebugger::call_capture(void *p_user, const String &p_cmd, const Arra } EngineDebugger::~EngineDebugger() { - for (Map::Element *E = captures.front(); E; E = E->next()) { - ::EngineDebugger::unregister_message_capture(E->key()); + for (const KeyValue &E : captures) { + ::EngineDebugger::unregister_message_capture(E.key); } captures.clear(); - for (Map::Element *E = profilers.front(); E; E = E->next()) { - ::EngineDebugger::unregister_profiler(E->key()); + for (const KeyValue &E : profilers) { + ::EngineDebugger::unregister_profiler(E.key); } profilers.clear(); } diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index a522b1310f..059025aa8f 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -123,8 +123,8 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_process_ticks, physics_time = USEC_TO_SEC(p_physics_ticks); physics_frame_time = p_physics_frame_time; // Notify tick to running profilers - for (Map::Element *E = profilers.front(); E; E = E->next()) { - Profiler &p = E->get(); + for (KeyValue &E : profilers) { + Profiler &p = E.value; if (!p.active || !p.tick) { continue; } @@ -179,9 +179,9 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, Ve void EngineDebugger::deinitialize() { if (singleton) { // Stop all profilers - for (Map::Element *E = profilers.front(); E; E = E->next()) { - if (E->get().active) { - singleton->profiler_enable(E->key(), false); + for (const KeyValue &E : profilers) { + if (E.value.active) { + singleton->profiler_enable(E.key, false); } } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index b0b3f11424..f7e56351b0 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -166,8 +166,8 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } else if (line.begins_with("set")) { if (line.get_slice_count(" ") == 1) { - for (Map::Element *E = options.front(); E; E = E->next()) { - print_line("\t" + E->key() + "=" + E->value()); + for (const KeyValue &E : options) { + print_line("\t" + E.key + "=" + E.value); } } else { @@ -249,8 +249,8 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } print_line("Breakpoint(s): " + itos(breakpoints.size())); - for (Map>::Element *E = breakpoints.front(); E; E = E->next()) { - print_line("\t" + String(E->value().front()->get()) + ":" + itos(E->key())); + for (const KeyValue> &E : breakpoints) { + print_line("\t" + String(E.value.front()->get()) + ":" + itos(E.key)); } } else { diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index f865dfe102..032c7d55c0 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -179,8 +179,8 @@ public: if (pt - last_profile_time > 100) { last_profile_time = pt; DebuggerMarshalls::NetworkProfilerFrame frame; - for (Map::Element *E = multiplayer_node_data.front(); E; E = E->next()) { - frame.infos.push_back(E->get()); + for (const KeyValue &E : multiplayer_node_data) { + frame.infos.push_back(E.value); } multiplayer_node_data.clear(); EngineDebugger::get_singleton()->send_message("network:profile_frame", frame.serialize()); diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index a8547a0090..3856229eac 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -353,11 +353,11 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { api_dump["global_constants"] = constants; Array enums; - for (Map>>::Element *E = enum_list.front(); E; E = E->next()) { + for (const KeyValue>> &E : enum_list) { Dictionary d1; - d1["name"] = E->key(); + d1["name"] = E.key; Array values; - for (const Pair &F : E->get()) { + for (const Pair &F : E.value) { Dictionary d2; d2["name"] = F.first; d2["value"] = F.second; diff --git a/core/extension/native_extension_manager.cpp b/core/extension/native_extension_manager.cpp index 8b7a9df4f1..4eac5249c9 100644 --- a/core/extension/native_extension_manager.cpp +++ b/core/extension/native_extension_manager.cpp @@ -84,8 +84,8 @@ bool NativeExtensionManager::is_extension_loaded(const String &p_path) const { Vector NativeExtensionManager::get_loaded_extensions() const { Vector ret; - for (const Map>::Element *E = native_extension_map.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue> &E : native_extension_map) { + ret.push_back(E.key); } return ret; } @@ -97,16 +97,16 @@ Ref NativeExtensionManager::get_extension(const String &p_path) void NativeExtensionManager::initialize_extensions(NativeExtension::InitializationLevel p_level) { ERR_FAIL_COND(int32_t(p_level) - 1 != level); - for (Map>::Element *E = native_extension_map.front(); E; E = E->next()) { - E->get()->initialize_library(p_level); + for (KeyValue> &E : native_extension_map) { + E.value->initialize_library(p_level); } level = p_level; } void NativeExtensionManager::deinitialize_extensions(NativeExtension::InitializationLevel p_level) { ERR_FAIL_COND(int32_t(p_level) != level); - for (Map>::Element *E = native_extension_map.front(); E; E = E->next()) { - E->get()->deinitialize_library(p_level); + for (KeyValue> &E : native_extension_map) { + E.value->deinitialize_library(p_level); } level = int32_t(p_level) - 1; } diff --git a/core/input/input.cpp b/core/input/input.cpp index 9195f7d8b5..05b02408a1 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -863,9 +863,9 @@ void Input::release_pressed_events() { joy_buttons_pressed.clear(); _joy_axis.clear(); - for (Map::Element *E = action_state.front(); E; E = E->next()) { - if (E->get().pressed) { - action_release(E->key()); + for (const KeyValue &E : action_state) { + if (E.value.pressed) { + action_release(E.key); } } } @@ -1322,8 +1322,8 @@ void Input::add_joy_mapping(String p_mapping, bool p_update_existing) { if (p_update_existing) { Vector entry = p_mapping.split(","); String uid = entry[0]; - for (Map::Element *E = joy_names.front(); E; E = E->next()) { - Joypad &joy = E->get(); + for (KeyValue &E : joy_names) { + Joypad &joy = E.value; if (joy.uid == uid) { joy.mapping = map_db.size() - 1; } @@ -1337,8 +1337,8 @@ void Input::remove_joy_mapping(String p_guid) { map_db.remove(i); } } - for (Map::Element *E = joy_names.front(); E; E = E->next()) { - Joypad &joy = E->get(); + for (KeyValue &E : joy_names) { + Joypad &joy = E.value; if (joy.uid == p_guid) { joy.mapping = -1; } diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 7b43daf9c0..b2832b2a75 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -110,8 +110,8 @@ PackedData::PackedData() { } void PackedData::_free_packed_dirs(PackedDir *p_dir) { - for (Map::Element *E = p_dir->subdirs.front(); E; E = E->next()) { - _free_packed_dirs(E->get()); + for (const KeyValue &E : p_dir->subdirs) { + _free_packed_dirs(E.value); } memdelete(p_dir); } @@ -395,8 +395,8 @@ Error DirAccessPack::list_dir_begin() { list_dirs.clear(); list_files.clear(); - for (Map::Element *E = current->subdirs.front(); E; E = E->next()) { - list_dirs.push_back(E->key()); + for (const KeyValue &E : current->subdirs) { + list_dirs.push_back(E.key); } for (Set::Element *E = current->files.front(); E; E = E->next()) { diff --git a/core/io/ip.cpp b/core/io/ip.cpp index e3102508a3..68b4e4b354 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -288,8 +288,8 @@ Array IP::_get_local_interfaces() const { Array results; Map interfaces; get_local_interfaces(&interfaces); - for (Map::Element *E = interfaces.front(); E; E = E->next()) { - Interface_Info &c = E->get(); + for (KeyValue &E : interfaces) { + Interface_Info &c = E.value; Dictionary rc; rc["name"] = c.name; rc["friendly"] = c.name_friendly; @@ -310,8 +310,8 @@ Array IP::_get_local_interfaces() const { void IP::get_local_addresses(List *r_addresses) const { Map interfaces; get_local_interfaces(&interfaces); - for (Map::Element *E = interfaces.front(); E; E = E->next()) { - for (const IPAddress &F : E->get().ip_addresses) { + for (const KeyValue &E : interfaces) { + for (const IPAddress &F : E.value.ip_addresses) { r_addresses->push_front(F); } } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 87b4d7195d..1cefa52d69 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -540,9 +540,9 @@ void ResourceCache::dump(const char *p_file, bool p_short) { } } - for (Map::Element *E = type_count.front(); E; E = E->next()) { + for (const KeyValue &E : type_count) { if (f) { - f->store_line(E->key() + " count: " + itos(E->get())); + f->store_line(E.key + " count: " + itos(E.value)); } } if (f) { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 84fd6496a7..cbb033f6c6 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1960,8 +1960,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector save_order; save_order.resize(external_resources.size()); - for (Map::Element *E = external_resources.front(); E; E = E->next()) { - save_order.write[E->get()] = E->key(); + for (const KeyValue &E : external_resources) { + save_order.write[E.value] = E.key; } for (int i = 0; i < save_order.size(); i++) { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3026236f07..2198761c2a 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -156,8 +156,8 @@ void ResourceFormatLoader::get_dependencies(const String &p_path, List * Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Map &p_map) { Dictionary deps_dict; - for (Map::Element *E = p_map.front(); E; E = E->next()) { - deps_dict[E->key()] = E->value(); + for (KeyValue E : p_map) { + deps_dict[E.key] = E.value; } int64_t err; diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 0960fe19a6..d438a9a377 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -265,8 +265,8 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ //create new faces from horizon edges List::Element *> new_faces; //new faces - for (Map::Element *E = lit_edges.front(); E; E = E->next()) { - FaceConnect &fc = E->get(); + for (KeyValue &E : lit_edges) { + FaceConnect &fc = E.value; if (fc.left && fc.right) { continue; //edge is uninteresting, not on horizon } @@ -275,8 +275,8 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ Face face; face.vertices[0] = f.points_over[next]; - face.vertices[1] = E->key().vertices[0]; - face.vertices[2] = E->key().vertices[1]; + face.vertices[1] = E.key.vertices[0]; + face.vertices[2] = E.key.vertices[1]; Plane p(p_points[face.vertices[0]], p_points[face.vertices[1]], p_points[face.vertices[2]]); @@ -418,13 +418,13 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ } // remove all edge connections to this face - for (Map::Element *G = ret_edges.front(); G; G = G->next()) { - if (G->get().left == O) { - G->get().left = nullptr; + for (KeyValue &G : ret_edges) { + if (G.value.left == O) { + G.value.left = nullptr; } - if (G->get().right == O) { - G->get().right = nullptr; + if (G.value.right == O) { + G.value.right = nullptr; } } @@ -444,10 +444,10 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ } r_mesh.edges.resize(ret_edges.size()); idx = 0; - for (Map::Element *E = ret_edges.front(); E; E = E->next()) { + for (const KeyValue &E : ret_edges) { Geometry3D::MeshData::Edge e; - e.a = E->key().vertices[0]; - e.b = E->key().vertices[1]; + e.a = E.key.vertices[0]; + e.b = E.key.vertices[1]; r_mesh.edges.write[idx++] = e; } diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 16d9652ef2..2f3da0b6a8 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -157,8 +157,8 @@ void TriangleMesh::create(const Vector &p_faces) { vertices.resize(db.size()); Vector3 *vw = vertices.ptrw(); - for (Map::Element *E = db.front(); E; E = E->next()) { - vw[E->get()] = E->key(); + for (const KeyValue &E : db) { + vw[E.value] = E.key; } } diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index 4751c69f1e..736e940846 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -227,16 +227,16 @@ void MessageQueue::statistics() { print_line("TOTAL BYTES: " + itos(buffer_end)); print_line("NULL count: " + itos(null_count)); - for (Map::Element *E = set_count.front(); E; E = E->next()) { - print_line("SET " + E->key() + ": " + itos(E->get())); + for (const KeyValue &E : set_count) { + print_line("SET " + E.key + ": " + itos(E.value)); } - for (Map::Element *E = call_count.front(); E; E = E->next()) { - print_line("CALL " + E->key() + ": " + itos(E->get())); + for (const KeyValue &E : call_count) { + print_line("CALL " + E.key + ": " + itos(E.value)); } - for (Map::Element *E = notify_count.front(); E; E = E->next()) { - print_line("NOTIFY " + itos(E->key()) + ": " + itos(E->get())); + for (const KeyValue &E : notify_count) { + print_line("NOTIFY " + itos(E.key) + ": " + itos(E.value)); } } diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 0fb8c7350c..b0ce46ca2b 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -93,8 +93,8 @@ Dictionary Script::_get_script_constant_map() { Dictionary ret; Map map; get_constants(&map); - for (Map::Element *E = map.front(); E; E = E->next()) { - ret[E->key()] = E->value(); + for (const KeyValue &E : map) { + ret[E.key] = E.value; } return ret; } diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index 5863bd1c46..839b7a9c01 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -162,11 +162,11 @@ void OptimizedTranslation::generate(const Ref &p_from) { btw[btindex++] = t.size(); btw[btindex++] = hfunc_table[i]; - for (Map::Element *E = t.front(); E; E = E->next()) { - btw[btindex++] = E->key(); - btw[btindex++] = compressed[E->get()].offset; - btw[btindex++] = compressed[E->get()].compressed.size(); - btw[btindex++] = compressed[E->get()].orig_len; + for (const KeyValue &E : t) { + btw[btindex++] = E.key; + btw[btindex++] = compressed[E.value].offset; + btw[btindex++] = compressed[E.value].compressed.size(); + btw[btindex++] = compressed[E.value].orig_len; } } diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 5c0eb388f5..5e3b8297aa 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -820,8 +820,8 @@ static const char *locale_renames[][2] = { Dictionary Translation::_get_messages() const { Dictionary d; - for (const Map::Element *E = translation_map.front(); E; E = E->next()) { - d[E->key()] = E->value(); + for (const KeyValue &E : translation_map) { + d[E.key] = E.value; } return d; } @@ -830,8 +830,8 @@ Vector Translation::_get_message_list() const { Vector msgs; msgs.resize(translation_map.size()); int idx = 0; - for (const Map::Element *E = translation_map.front(); E; E = E->next()) { - msgs.set(idx, E->key()); + for (const KeyValue &E : translation_map) { + msgs.set(idx, E.key); idx += 1; } @@ -911,8 +911,8 @@ void Translation::erase_message(const StringName &p_src_text, const StringName & } void Translation::get_message_list(List *r_messages) const { - for (const Map::Element *E = translation_map.front(); E; E = E->next()) { - r_messages->push_back(E->key()); + for (const KeyValue &E : translation_map) { + r_messages->push_back(E.key); } } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 32d6778a2b..5682a7c7b5 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1241,8 +1241,8 @@ void Variant::get_constants_for_type(Variant::Type p_type, List *p_c for (List::Element *E = cd.value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else - for (Map::Element *E = cd.value.front(); E; E = E->next()) { - p_constants->push_back(E->key()); + for (const KeyValue &E : cd.value) { + p_constants->push_back(E.key); #endif } @@ -1250,8 +1250,8 @@ void Variant::get_constants_for_type(Variant::Type p_type, List *p_c for (List::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) { p_constants->push_back(E->get()); #else - for (Map::Element *E = cd.variant_value.front(); E; E = E->next()) { - p_constants->push_back(E->key()); + for (const KeyValue &E : cd.variant_value) { + p_constants->push_back(E.key); #endif } } diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index e01c6a0e0f..768b819650 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -258,8 +258,8 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str uint32_t if_v6id = 0; Map if_info; IP::get_singleton()->get_local_interfaces(&if_info); - for (Map::Element *E = if_info.front(); E; E = E->next()) { - IP::Interface_Info &c = E->get(); + for (KeyValue &E : if_info) { + IP::Interface_Info &c = E.value; if (c.name != p_if_name) { continue; } diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 086d3b4284..8743135f89 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8688,10 +8688,10 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { while (frames[p_frame].framebuffers_to_dispose_of.front()) { Framebuffer *framebuffer = &frames[p_frame].framebuffers_to_dispose_of.front()->get(); - for (Map::Element *E = framebuffer->framebuffers.front(); E; E = E->next()) { + for (const KeyValue &E : framebuffer->framebuffers) { //first framebuffer, then render pass because it depends on it - vkDestroyFramebuffer(device, E->get().framebuffer, nullptr); - vkDestroyRenderPass(device, E->get().render_pass, nullptr); + vkDestroyFramebuffer(device, E.value.framebuffer, nullptr); + vkDestroyRenderPass(device, E.value.render_pass, nullptr); } frames[p_frame].framebuffers_to_dispose_of.pop_front(); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 1c7e83af21..152efc7807 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -1755,8 +1755,8 @@ Error VulkanContext::prepare_buffers() { vkWaitForFences(device, 1, &fences[frame_index], VK_TRUE, UINT64_MAX); vkResetFences(device, 1, &fences[frame_index]); - for (Map::Element *E = windows.front(); E; E = E->next()) { - Window *w = &E->get(); + for (KeyValue &E : windows) { + Window *w = &E.value; w->semaphore_acquired = false; @@ -1837,8 +1837,8 @@ Error VulkanContext::swap_buffers() { VkSemaphore *semaphores_to_acquire = (VkSemaphore *)alloca(windows.size() * sizeof(VkSemaphore)); uint32_t semaphores_to_acquire_count = 0; - for (Map::Element *E = windows.front(); E; E = E->next()) { - Window *w = &E->get(); + for (KeyValue &E : windows) { + Window *w = &E.value; if (w->semaphore_acquired) { semaphores_to_acquire[semaphores_to_acquire_count++] = w->image_acquired_semaphores[frame_index]; @@ -1876,8 +1876,8 @@ Error VulkanContext::swap_buffers() { VkCommandBuffer *cmdbufptr = (VkCommandBuffer *)alloca(sizeof(VkCommandBuffer *) * windows.size()); submit_info.pCommandBuffers = cmdbufptr; - for (Map::Element *E = windows.front(); E; E = E->next()) { - Window *w = &E->get(); + for (KeyValue &E : windows) { + Window *w = &E.value; if (w->swapchain == VK_NULL_HANDLE) { continue; @@ -1911,8 +1911,8 @@ Error VulkanContext::swap_buffers() { present.pSwapchains = pSwapchains; present.pImageIndices = pImageIndices; - for (Map::Element *E = windows.front(); E; E = E->next()) { - Window *w = &E->get(); + for (KeyValue &E : windows) { + Window *w = &E.value; if (w->swapchain == VK_NULL_HANDLE) { continue; diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 28642f1bb4..02b4a12b92 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -398,17 +398,17 @@ void AnimationBezierTrackEdit::_notification(int p_what) { float scale = timeline->get_zoom_scale(); Ref point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); - for (Map::Element *E = subtrack_colors.front(); E; E = E->next()) { - _draw_track(E->key(), E->get()); + for (const KeyValue &E : subtrack_colors) { + _draw_track(E.key, E.value); - for (int i = 0; i < animation->track_get_key_count(E->key()); i++) { - float offset = animation->track_get_key_time(E->key(), i); - float value = animation->bezier_track_get_key_value(E->key(), i); + for (int i = 0; i < animation->track_get_key_count(E.key); i++) { + float offset = animation->track_get_key_time(E.key, i); + float value = animation->bezier_track_get_key_value(E.key, i); Vector2 pos((offset - timeline->get_value()) * scale + limit, _bezier_h_to_pixel(value)); if (pos.x >= limit && pos.x <= right_limit) { - draw_texture(point, pos - point->get_size() / 2, E->get()); + draw_texture(point, pos - point->get_size() / 2, E.value); } } } @@ -680,9 +680,9 @@ void AnimationBezierTrackEdit::gui_input(const Ref &p_event) { emit_signal(SNAME("close_request")); return; } - for (Map::Element *E = subtracks.front(); E; E = E->next()) { - if (E->get().has_point(mb->get_position())) { - set_animation_and_track(animation, E->key()); + for (const KeyValue &E : subtracks) { + if (E.value.has_point(mb->get_position())) { + set_animation_and_track(animation, E.key); _clear_selection(); return; } diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 76e71a1030..d5afd5020c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -700,15 +700,15 @@ public: return; } - for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { + for (const KeyValue> &E : key_ofs_map) { int key = 0; - for (const float &key_ofs : E->value()) { + for (const float &key_ofs : E.value) { if (from != key_ofs) { key++; continue; } - int track = E->key(); + int track = E.key; key_ofs_map[track][key] = to; if (setting) { @@ -725,9 +725,9 @@ public: bool _set(const StringName &p_name, const Variant &p_value) { bool update_obj = false; bool change_notify_deserved = false; - for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int track = E->key(); - for (const float &key_ofs : E->value()) { + for (const KeyValue> &E : key_ofs_map) { + int track = E.key; + for (const float &key_ofs : E.value) { int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -982,9 +982,9 @@ public: } bool _get(const StringName &p_name, Variant &r_ret) const { - for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int track = E->key(); - for (const float &key_ofs : E->value()) { + for (const KeyValue> &E : key_ofs_map) { + int track = E.key; + for (const float &key_ofs : E.value) { int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1116,15 +1116,15 @@ public: bool show_time = true; bool same_track_type = true; bool same_key_type = true; - for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int track = E->key(); + for (const KeyValue> &E : key_ofs_map) { + int track = E.key; ERR_FAIL_INDEX(track, animation->get_track_count()); if (first_track < 0) { first_track = track; } - if (show_time && E->value().size() > 1) { + if (show_time && E.value.size() > 1) { show_time = false; } @@ -1134,7 +1134,7 @@ public: same_key_type = false; } - for (const float &F : E->value()) { + for (const float &F : E.value) { int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { @@ -4828,8 +4828,8 @@ void AnimationTrackEditor::_update_key_edit() { Map> key_ofs_map; Map base_map; int first_track = -1; - for (Map::Element *E = selection.front(); E; E = E->next()) { - int track = E->key().track; + for (const KeyValue &E : selection) { + int track = E.key.track; if (first_track < 0) { first_track = track; } @@ -4839,7 +4839,7 @@ void AnimationTrackEditor::_update_key_edit() { base_map[track] = NodePath(); } - key_ofs_map[track].push_back(animation->track_get_key_time(track, E->key().key)); + key_ofs_map[track].push_back(animation->track_get_key_time(track, E.key.key)); } multi_key_edit->key_ofs_map = key_ofs_map; multi_key_edit->base_map = base_map; @@ -5383,8 +5383,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { float len = -1e20; float pivot = 0; - for (Map::Element *E = selection.front(); E; E = E->next()) { - float t = animation->track_get_key_time(E->key().track, E->key().key); + for (const KeyValue &E : selection) { + float t = animation->track_get_key_time(E.key.track, E.key.key); if (t < from_t) { from_t = t; } diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index f7f4988873..2efcdcda31 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -216,15 +216,15 @@ AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = nullptr; void AudioStreamPreviewGenerator::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { List to_erase; - for (Map::Element *E = previews.front(); E; E = E->next()) { - if (!E->get().generating.is_set()) { - if (E->get().thread) { - E->get().thread->wait_to_finish(); - memdelete(E->get().thread); - E->get().thread = nullptr; + for (KeyValue &E : previews) { + if (!E.value.generating.is_set()) { + if (E.value.thread) { + E.value.thread->wait_to_finish(); + memdelete(E.value.thread); + E.value.thread = nullptr; } - if (!ObjectDB::get_instance(E->key())) { //no longer in use, get rid of preview - to_erase.push_back(E->key()); + if (!ObjectDB::get_instance(E.key)) { //no longer in use, get rid of preview + to_erase.push_back(E.key); } } } diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index fbd3aaa409..485d58f4a3 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -306,8 +306,8 @@ Dictionary DebugAdapterParser::req_stackTrace(const Dictionary &p_params) const Array arr; DebugAdapterProtocol *dap = DebugAdapterProtocol::get_singleton(); - for (Map>::Element *E = dap->stackframe_list.front(); E; E = E->next()) { - DAP::StackFrame sf = E->key(); + for (const KeyValue> &E : dap->stackframe_list) { + DAP::StackFrame sf = E.key; if (!lines_at_one) { sf.line--; } diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index a1eb71235c..e53f66e72e 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -200,12 +200,12 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { } void EditorDebuggerInspector::clear_cache() { - for (Map::Element *E = remote_objects.front(); E; E = E->next()) { + for (const KeyValue &E : remote_objects) { EditorNode *editor = EditorNode::get_singleton(); - if (editor->get_editor_history()->get_current() == E->value()->get_instance_id()) { + if (editor->get_editor_history()->get_current() == E.value->get_instance_id()) { editor->push_item(nullptr); } - memdelete(E->value()); + memdelete(E.value); } remote_objects.clear(); remote_dependencies.clear(); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index be84e8dec5..188f5708aa 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -328,9 +328,9 @@ void EditorDebuggerNode::_notification(int p_what) { debugger->set_editor_remote_tree(remote_scene_tree); debugger->start(server->take_connection()); // Send breakpoints. - for (Map::Element *E = breakpoints.front(); E; E = E->next()) { - const Breakpoint &bp = E->key(); - debugger->set_breakpoint(bp.source, bp.line, E->get()); + for (const KeyValue &E : breakpoints) { + const Breakpoint &bp = E.key; + debugger->set_breakpoint(bp.source, bp.line, E.value); } // Will arrive too late, how does the regular run work? debugger->update_live_edit_root(); @@ -497,8 +497,8 @@ void EditorDebuggerNode::set_breakpoints(const String &p_path, Array p_lines) { set_breakpoint(p_path, p_lines[i], true); } - for (Map::Element *E = breakpoints.front(); E; E = E->next()) { - Breakpoint b = E->key(); + for (const KeyValue &E : breakpoints) { + Breakpoint b = E.key; if (b.source == p_path && !p_lines.has(b.line)) { set_breakpoint(p_path, b.line, false); } diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index 9479fbd5d4..d4385630be 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -56,18 +56,18 @@ void EditorNetworkProfiler::_update_frame() { TreeItem *root = counters_display->create_item(); - for (Map::Element *E = nodes_data.front(); E; E = E->next()) { + for (const KeyValue &E : nodes_data) { TreeItem *node = counters_display->create_item(root); for (int j = 0; j < counters_display->get_columns(); ++j) { node->set_text_align(j, j > 0 ? TreeItem::ALIGN_RIGHT : TreeItem::ALIGN_LEFT); } - node->set_text(0, E->get().node_path); - node->set_text(1, E->get().incoming_rpc == 0 ? "-" : itos(E->get().incoming_rpc)); - node->set_text(2, E->get().incoming_rset == 0 ? "-" : itos(E->get().incoming_rset)); - node->set_text(3, E->get().outgoing_rpc == 0 ? "-" : itos(E->get().outgoing_rpc)); - node->set_text(4, E->get().outgoing_rset == 0 ? "-" : itos(E->get().outgoing_rset)); + node->set_text(0, E.value.node_path); + node->set_text(1, E.value.incoming_rpc == 0 ? "-" : itos(E.value.incoming_rpc)); + node->set_text(2, E.value.incoming_rset == 0 ? "-" : itos(E.value.incoming_rset)); + node->set_text(3, E.value.outgoing_rpc == 0 ? "-" : itos(E.value.outgoing_rpc)); + node->set_text(4, E.value.outgoing_rset == 0 ? "-" : itos(E.value.outgoing_rset)); } } diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index fa9c9f61f5..2fe7cd7886 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -515,11 +515,11 @@ Vector> EditorProfiler::get_data_as_csv() const { if (!m.valid) { continue; } - for (Map::Element *E = m.category_ptrs.front(); E; E = E->next()) { - possible_signatures.insert(E->key()); + for (const KeyValue &E : m.category_ptrs) { + possible_signatures.insert(E.key); } - for (Map::Element *E = m.item_ptrs.front(); E; E = E->next()) { - possible_signatures.insert(E->key()); + for (const KeyValue &E : m.item_ptrs) { + possible_signatures.insert(E.key); } } @@ -557,11 +557,11 @@ Vector> EditorProfiler::get_data_as_csv() const { values.clear(); values.resize(possible_signatures.size()); - for (Map::Element *E = m.category_ptrs.front(); E; E = E->next()) { - values.write[sig_map[E->key()]] = String::num_real(E->value()->total_time); + for (const KeyValue &E : m.category_ptrs) { + values.write[sig_map[E.key]] = String::num_real(E.value->total_time); } - for (Map::Element *E = m.item_ptrs.front(); E; E = E->next()) { - values.write[sig_map[E->key()]] = String::num_real(E->value()->total); + for (const KeyValue &E : m.item_ptrs) { + values.write[sig_map[E.key]] = String::num_real(E.value->total); } res.push_back(values); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index a9d8cb219c..d07d77c112 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -74,16 +74,16 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Mapget_file_path(i); - for (Map::Element *E = candidates[file].front(); E; E = E->next()) { - if (E->get() == String()) { - E->get() = path; + for (KeyValue &E : candidates[file]) { + if (E.value == String()) { + E.value = path; continue; } //must match the best, using subdirs - String existing = E->get().replace_first("res://", ""); + String existing = E.value.replace_first("res://", ""); String current = path.replace_first("res://", ""); - String lost = E->key().replace_first("res://", ""); + String lost = E.key.replace_first("res://", ""); Vector existingv = existing.split("/"); existingv.reverse(); @@ -107,7 +107,7 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map existing_score) { //if it was the same, could track distance to new path but.. - E->get() = path; //replace by more accurate + E.value = path; //replace by more accurate } } } @@ -133,10 +133,10 @@ void DependencyEditor::_fix_all() { Map remaps; - for (Map>::Element *E = candidates.front(); E; E = E->next()) { - for (Map::Element *F = E->get().front(); F; F = F->next()) { - if (F->get() != String()) { - remaps[F->key()] = F->get(); + for (KeyValue> &E : candidates) { + for (const KeyValue &F : E.value) { + if (F.value != String()) { + remaps[F.key] = F.value; } } } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index ec162231e9..beead74c53 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -44,8 +44,8 @@ #include "modules/modules_enabled.gen.h" void DocTools::merge_from(const DocTools &p_data) { - for (Map::Element *E = class_list.front(); E; E = E->next()) { - DocData::ClassDoc &c = E->get(); + for (KeyValue &E : class_list) { + DocData::ClassDoc &c = E.value; if (!p_data.class_list.has(c.name)) { continue; @@ -185,9 +185,9 @@ void DocTools::merge_from(const DocTools &p_data) { } void DocTools::remove_from(const DocTools &p_data) { - for (Map::Element *E = p_data.class_list.front(); E; E = E->next()) { - if (class_list.has(E->key())) { - class_list.erase(E->key()); + for (const KeyValue &E : p_data.class_list) { + if (class_list.has(E.key)) { + class_list.erase(E.key); } } } @@ -1227,8 +1227,8 @@ static void _write_method_doc(FileAccess *f, const String &p_name, Vector &p_class_path) { - for (Map::Element *E = class_list.front(); E; E = E->next()) { - DocData::ClassDoc &c = E->get(); + for (KeyValue &E : class_list) { + DocData::ClassDoc &c = E.value; String save_path; if (p_class_path.has(c.name)) { diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index fcf79a80a7..0840c3b6a8 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -473,8 +473,8 @@ void EditorAutoloadSettings::update_autoload() { } // Remove deleted/changed autoloads - for (Map::Element *E = to_remove.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (KeyValue &E : to_remove) { + AutoLoadInfo &info = E.value; if (info.is_singleton) { for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptServer::get_language(i)->remove_named_global_constant(info.name); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 225526da5b..aee9c21007 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -1105,8 +1105,8 @@ Array EditorSelection::_get_transformable_selected_nodes() { TypedArray EditorSelection::get_selected_nodes() { TypedArray ret; - for (Map::Element *E = selection.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue &E : selection) { + ret.push_back(E.key); } return ret; @@ -1133,8 +1133,8 @@ void EditorSelection::_update_nl() { selected_node_list.clear(); - for (Map::Element *E = selection.front(); E; E = E->next()) { - Node *parent = E->key(); + for (const KeyValue &E : selection) { + Node *parent = E.key; parent = parent->get_parent(); bool skip = false; while (parent) { @@ -1148,7 +1148,7 @@ void EditorSelection::_update_nl() { if (skip) { continue; } - selected_node_list.push_back(E->key()); + selected_node_list.push_back(E.key); } nl_changed = true; @@ -1183,8 +1183,8 @@ List &EditorSelection::get_selected_node_list() { List EditorSelection::get_full_selected_node_list() { List node_list; - for (Map::Element *E = selection.front(); E; E = E->next()) { - node_list.push_back(E->key()); + for (const KeyValue &E : selection) { + node_list.push_back(E.key); } return node_list; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 8b289e3d94..a88adf3634 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1817,9 +1817,9 @@ bool EditorExportPlatformPC::can_export(const Ref &p_preset, List EditorExportPlatformPC::get_binary_extensions(const Ref &p_preset) const { List list; - for (Map::Element *E = extensions.front(); E; E = E->next()) { - if (p_preset->get(E->key())) { - list.push_back(extensions[E->key()]); + for (const KeyValue &E : extensions) { + if (p_preset->get(E.key)) { + list.push_back(extensions[E.key]); return list; } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 84a9237a96..2222a5e5d3 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -179,9 +179,9 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { Array dis_props; - for (Map>::Element *E = disabled_properties.front(); E; E = E->next()) { - for (Set::Element *F = E->get().front(); F; F = F->next()) { - dis_props.push_back(String(E->key()) + ":" + String(F->get())); + for (KeyValue> &E : disabled_properties) { + for (Set::Element *F = E.value.front(); F; F = F->next()) { + dis_props.push_back(String(E.key) + ":" + String(F->get())); } } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index e62ad956a9..0882b525d7 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1663,8 +1663,8 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector Error err = importer->import_group_file(p_group_file, source_file_options, base_paths); //all went well, overwrite config files with proper remaps and md5s - for (Map>::Element *E = source_file_options.front(); E; E = E->next()) { - const String &file = E->key(); + for (const KeyValue> &E : source_file_options) { + const String &file = E.key; String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file); FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE); ERR_FAIL_COND_V_MSG(!f, ERR_FILE_CANT_OPEN, "Cannot open import file '" + file + ".import'."); @@ -2133,10 +2133,10 @@ void EditorFileSystem::reimport_files(const Vector &p_files) { if (groups_to_reimport.size()) { Map> group_files; _find_group_files(filesystem, group_files, groups_to_reimport); - for (Map>::Element *E = group_files.front(); E; E = E->next()) { - Error err = _reimport_group(E->key(), E->get()); + for (const KeyValue> &E : group_files) { + Error err = _reimport_group(E.key, E.value); if (err == OK) { - _reimport_file(E->key()); + _reimport_file(E.key); } } } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index fff9e5e908..b17f105507 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -394,8 +394,8 @@ void EditorHelp::_update_doc() { bool prev = false; class_desc->push_font(doc_font); - for (Map::Element *E = doc->class_list.front(); E; E = E->next()) { - if (E->get().inherits == cd.name) { + for (const KeyValue &E : doc->class_list) { + if (E.value.inherits == cd.name) { if (!found) { class_desc->push_color(title_color); class_desc->add_text(TTR("Inherited by:") + " "); @@ -406,7 +406,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(" , "); } - _add_type(E->get().name); + _add_type(E.value.name); prev = true; } } @@ -876,14 +876,14 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); - for (Map>::Element *E = enums.front(); E; E = E->next()) { - enum_line[E->key()] = class_desc->get_line_count() - 2; + for (KeyValue> &E : enums) { + enum_line[E.key] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); class_desc->push_color(title_color); class_desc->add_text("enum "); class_desc->pop(); - String e = E->key(); + String e = E.key; if ((e.get_slice_count(".") > 1) && (e.get_slice(".", 0) == edited_class)) { e = e.get_slice(".", 1); } @@ -913,10 +913,10 @@ void EditorHelp::_update_doc() { } class_desc->push_indent(1); - Vector enum_list = E->get(); + Vector enum_list = E.value; Map enumValuesContainer; - int enumStartingLine = enum_line[E->key()]; + int enumStartingLine = enum_line[E.key]; for (int i = 0; i < enum_list.size(); i++) { if (cd.name == "@GlobalScope") { @@ -955,7 +955,7 @@ void EditorHelp::_update_doc() { } if (cd.name == "@GlobalScope") { - enum_values_line[E->key()] = enumValuesContainer; + enum_values_line[E.key] = enumValuesContainer; } class_desc->pop(); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 4832cd6994..4d0f27c5d4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -842,10 +842,10 @@ void EditorProperty::set_bottom_editor(Control *p_control) { bool EditorProperty::is_cache_valid() const { if (object) { - for (Map::Element *E = cache.front(); E; E = E->next()) { + for (const KeyValue &E : cache) { bool valid; - Variant value = object->get(E->key(), &valid); - if (!valid || value != E->get()) { + Variant value = object->get(E.key, &valid); + if (!valid || value != E.value) { return false; } } @@ -3029,8 +3029,8 @@ void EditorInspector::collapse_all_folding() { E->fold(); } - for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (EditorProperty *E : F->get()) { + for (const KeyValue> &F : editor_property_map) { + for (EditorProperty *E : F.value) { E->collapse_all_folding(); } } @@ -3040,8 +3040,8 @@ void EditorInspector::expand_all_folding() { for (EditorInspectorSection *E : sections) { E->unfold(); } - for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (EditorProperty *E : F->get()) { + for (const KeyValue> &F : editor_property_map) { + for (EditorProperty *E : F.value) { E->expand_all_folding(); } } @@ -3306,11 +3306,11 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) property_selected = p_path; property_focusable = p_focusable; //deselect the others - for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - if (F->key() == property_selected) { + for (const KeyValue> &F : editor_property_map) { + if (F.key == property_selected) { continue; } - for (EditorProperty *E : F->get()) { + for (EditorProperty *E : F.value) { if (E->is_selected()) { E->deselect(); } @@ -3368,8 +3368,8 @@ void EditorInspector::_notification(int p_what) { if (refresh_countdown > 0) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { - for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (EditorProperty *E : F->get()) { + for (const KeyValue> &F : editor_property_map) { + for (EditorProperty *E : F.value) { if (!E->is_cache_valid()) { E->update_property(); E->update_reload_status(); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index f91cb7f607..346b93a87c 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -116,8 +116,8 @@ void EditorLog::_save_state() { config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); const String section = "editor_log"; - for (Map::Element *E = type_filter_map.front(); E; E = E->next()) { - config->set_value(section, "log_filter_" + itos(E->key()), E->get()->is_active()); + for (const KeyValue &E : type_filter_map) { + config->set_value(section, "log_filter_" + itos(E.key), E.value->is_active()); } config->set_value(section, "collapse", collapse); @@ -135,8 +135,8 @@ void EditorLog::_load_state() { // Run the below code even if config->load returns an error, since we want the defaults to be set even if the file does not exist yet. const String section = "editor_log"; - for (Map::Element *E = type_filter_map.front(); E; E = E->next()) { - E->get()->set_active(config->get_value(section, "log_filter_" + itos(E->key()), true)); + for (const KeyValue &E : type_filter_map) { + E.value->set_active(config->get_value(section, "log_filter_" + itos(E.key), true)); } collapse = config->get_value(section, "collapse", false); @@ -306,8 +306,8 @@ void EditorLog::_search_changed(const String &p_text) { } void EditorLog::_reset_message_counts() { - for (Map::Element *E = type_filter_map.front(); E; E = E->next()) { - E->value()->set_message_count(0); + for (const KeyValue &E : type_filter_map) { + E.value->set_message_count(0); } } @@ -441,7 +441,7 @@ void EditorLog::deinit() { } EditorLog::~EditorLog() { - for (Map::Element *E = type_filter_map.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue &E : type_filter_map) { + memdelete(E.value); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 9dcf0c8c07..44825d2536 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3202,8 +3202,8 @@ void EditorNode::_update_addon_config() { Vector enabled_addons; - for (Map::Element *E = plugin_addons.front(); E; E = E->next()) { - enabled_addons.push_back(E->key()); + for (const KeyValue &E : plugin_addons) { + enabled_addons.push_back(E.key); } if (enabled_addons.size() == 0) { @@ -3585,9 +3585,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b dependency_errors.erase(lpath); //at least not self path - for (Map>::Element *E = dependency_errors.front(); E; E = E->next()) { - String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E->key()) + "\n"; - for (Set::Element *F = E->get().front(); F; F = F->next()) { + for (KeyValue> &E : dependency_errors) { + String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E.key) + "\n"; + for (Set::Element *F = E.value.front(); F; F = F->next()) { txt += "\t" + F->get() + "\n"; } add_io_error(txt); @@ -4050,8 +4050,8 @@ Ref EditorNode::get_class_icon(const String &p_class, const String &p } const Map> &p_map = EditorNode::get_editor_data().get_custom_types(); - for (const Map>::Element *E = p_map.front(); E; E = E->next()) { - const Vector &ct = E->value(); + for (const KeyValue> &E : p_map) { + const Vector &ct = E.value; for (int i = 0; i < ct.size(); ++i) { if (ct[i].name == p_class) { if (ct[i].icon.is_valid()) { diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 5828549bdc..74ebffc404 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -66,9 +66,9 @@ void EditorRunNative::_notification(int p_what) { bool changed = EditorExport::get_singleton()->poll_export_platforms() || first; if (changed) { - for (Map::Element *E = menus.front(); E; E = E->next()) { - Ref eep = EditorExport::get_singleton()->get_export_platform(E->key()); - MenuButton *mb = E->get(); + for (KeyValue &E : menus) { + Ref eep = EditorExport::get_singleton()->get_export_platform(E.key); + MenuButton *mb = E.value; int dc = eep->get_options_count(); if (dc == 0) { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b4e2e8cc00..25406055f2 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -139,10 +139,10 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { if (p_name == "shortcuts") { Array arr; - for (const Map>::Element *E = shortcuts.front(); E; E = E->next()) { - Ref sc = E->get(); + for (const KeyValue> &E : shortcuts) { + Ref sc = E.value; - if (builtin_action_overrides.has(E->key())) { + if (builtin_action_overrides.has(E.key)) { // This shortcut was auto-generated from built in actions: don't save. continue; } @@ -158,19 +158,19 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { } } - arr.push_back(E->key()); + arr.push_back(E.key); arr.push_back(sc->get_event()); } r_ret = arr; return true; } else if (p_name == "builtin_action_overrides") { Array actions_arr; - for (Map>>::Element *E = builtin_action_overrides.front(); E; E = E->next()) { - List> events = E->get(); + for (const KeyValue>> &E : builtin_action_overrides) { + List> events = E.value; // TODO: skip actions which are the same as the builtin. Dictionary action_dict; - action_dict["name"] = E->key(); + action_dict["name"] = E.key; Array events_arr; for (List>::Element *I = events.front(); I; I = I->next()) { @@ -1429,8 +1429,8 @@ Ref EditorSettings::get_shortcut(const String &p_name) const { } void EditorSettings::get_shortcut_list(List *r_shortcuts) { - for (const Map>::Element *E = shortcuts.front(); E; E = E->next()) { - r_shortcuts->push_back(E->key()); + for (const KeyValue> &E : shortcuts) { + r_shortcuts->push_back(E.key); } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 4bf8d07b47..1d1976d7e5 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1301,11 +1301,11 @@ void FileSystemDock::_update_dependencies_after_move(const Map & void FileSystemDock::_update_project_settings_after_move(const Map &p_renames) const { // Find all project settings of type FILE and replace them if needed. const Map prop_info = ProjectSettings::get_singleton()->get_custom_property_info(); - for (const Map::Element *E = prop_info.front(); E; E = E->next()) { - if (E->get().hint == PROPERTY_HINT_FILE) { - String old_path = GLOBAL_GET(E->key()); + for (const KeyValue &E : prop_info) { + if (E.value.hint == PROPERTY_HINT_FILE) { + String old_path = GLOBAL_GET(E.key); if (p_renames.has(old_path)) { - ProjectSettings::get_singleton()->set_setting(E->key(), p_renames[old_path]); + ProjectSettings::get_singleton()->set_setting(E.key, p_renames[old_path]); } }; } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 9444706fd2..380b269675 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -840,8 +840,8 @@ void FindInFilesPanel::_on_replace_all_clicked() { PackedStringArray modified_files; - for (Map::Element *E = _file_items.front(); E; E = E->next()) { - TreeItem *file_item = E->value(); + for (KeyValue &E : _file_items) { + TreeItem *file_item = E.value; String fpath = file_item->get_metadata(0); Vector locations; diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index b6d0927ce6..4cd9066350 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -2095,19 +2095,19 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { } void Collada::_merge_skeletons2(VisualScene *p_vscene) { - for (Map::Element *E = state.skin_controller_data_map.front(); E; E = E->next()) { - SkinControllerData &cd = E->get(); + for (KeyValue &E : state.skin_controller_data_map) { + SkinControllerData &cd = E.value; NodeSkeleton *skeleton = nullptr; - for (Map::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { + for (const KeyValue &F : cd.bone_rest_map) { String name; - if (!state.sid_to_node_map.has(F->key())) { + if (!state.sid_to_node_map.has(F.key)) { continue; } - name = state.sid_to_node_map[F->key()]; + name = state.sid_to_node_map[F.key]; ERR_CONTINUE(!state.scene_map.has(name)); @@ -2248,9 +2248,9 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it //make rests relative to the skeleton (they seem to be always relative to world) - for (Map::Element *E = skin.bone_rest_map.front(); E; E = E->next()) { - E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton - state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative + for (KeyValue &E : skin.bone_rest_map) { + E.value = skel_inv * E.value; //make the bone rest local to the skeleton + state.bone_rest_map[E.key] = E.value; // make it remember where the bone is globally, now that it's relative } //but most exporters seem to work only if i do this.. @@ -2302,8 +2302,8 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) { } void Collada::_optimize() { - for (Map::Element *E = state.visual_scene_map.front(); E; E = E->next()) { - VisualScene &vs = E->get(); + for (KeyValue &E : state.visual_scene_map) { + VisualScene &vs = E.value; for (int i = 0; i < vs.root_nodes.size(); i++) { _create_skeletons(&vs.root_nodes.write[i]); } diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 7ab80ac3b4..3de7426302 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1314,8 +1314,8 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t } void ColladaImport::_fix_param_animation_tracks() { - for (Map::Element *E = collada.state.scene_map.front(); E; E = E->next()) { - Collada::Node *n = E->get(); + for (KeyValue &E : collada.state.scene_map) { + Collada::Node *n = E.value; switch (n->type) { case Collada::Node::TYPE_NODE: { // ? do nothing @@ -1363,7 +1363,7 @@ void ColladaImport::_fix_param_animation_tracks() { for (int rti = 0; rti < rt.size(); rti++) { Collada::AnimationTrack *at = &collada.state.animation_tracks.write[rt[rti]]; - at->target = E->key(); + at->target = E.key; at->param = "morph/" + collada.state.mesh_name_map[mesh_name]; at->property = true; //at->param @@ -1431,11 +1431,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->set_name(collada.state.animation_clips[p_clip].name); } - for (Map::Element *E = node_map.front(); E; E = E->next()) { - if (E->get().bone < 0) { + for (const KeyValue &E : node_map) { + if (E.value.bone < 0) { continue; } - bones_with_animation[E->key()] = false; + bones_with_animation[E.key] = false; } //store and validate tracks @@ -1626,19 +1626,19 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (p_make_tracks_in_all_bones) { //some bones may lack animation, but since we don't store pose as a property, we must add keyframes! - for (Map::Element *E = bones_with_animation.front(); E; E = E->next()) { - if (E->get()) { + for (const KeyValue &E : bones_with_animation) { + if (E.value) { continue; } - NodeMap &nm = node_map[E->key()]; + NodeMap &nm = node_map[E.key]; String path = scene->get_path_to(nm.node); ERR_CONTINUE(nm.bone < 0); Skeleton3D *sk = static_cast(nm.node); String name = sk->get_bone_name(nm.bone); path = path + ":" + name; - Collada::Node *cn = collada.state.scene_map[E->key()]; + Collada::Node *cn = collada.state.scene_map[E.key]; if (cn->ignore_anim) { WARN_PRINT("Collada: Ignoring animation on node: " + path); continue; diff --git a/editor/import/editor_importer_bake_reset.cpp b/editor/import/editor_importer_bake_reset.cpp index 00dce6850e..fb5de941ae 100644 --- a/editor/import/editor_importer_bake_reset.cpp +++ b/editor/import/editor_importer_bake_reset.cpp @@ -122,14 +122,14 @@ void BakeReset::_align_animations(AnimationPlayer *p_ap, const Map::Element *anim_i = anim_names.front(); anim_i; anim_i = anim_i->next()) { Ref a = p_ap->get_animation(anim_i->get()); ERR_CONTINUE(a.is_null()); - for (Map::Element *rest_bone_i = r_rest_bones.front(); rest_bone_i; rest_bone_i = rest_bone_i->next()) { - int track = a->find_track(NodePath(rest_bone_i->key())); + for (const KeyValue &rest_bone_i : r_rest_bones) { + int track = a->find_track(NodePath(rest_bone_i.key)); if (track == -1) { continue; } int new_track = a->add_track(Animation::TYPE_TRANSFORM3D); - NodePath new_path = NodePath(rest_bone_i->key()); - BakeResetRestBone rest_bone = rest_bone_i->get(); + NodePath new_path = NodePath(rest_bone_i.key); + const BakeResetRestBone rest_bone = rest_bone_i.value; a->track_set_path(new_track, new_path); for (int key_i = 0; key_i < a->track_get_key_count(track); key_i++) { Vector3 loc; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 61745cb6ee..96a53b3257 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -86,28 +86,28 @@ void ResourceImporterTexture::update_imports() { return; } - for (Map::Element *E = make_flags.front(); E; E = E->next()) { + for (const KeyValue &E : make_flags) { Ref cf; cf.instantiate(); - String src_path = String(E->key()) + ".import"; + String src_path = String(E.key) + ".import"; Error err = cf->load(src_path); ERR_CONTINUE(err != OK); bool changed = false; - if (E->get().flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { + if (E.value.flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { cf->set_value("params", "compress/normal_map", 1); changed = true; } - if (E->get().flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) { - cf->set_value("params", "roughness/mode", E->get().channel_for_roughness + 2); - cf->set_value("params", "roughness/src_normal", E->get().normal_path_for_roughness); + if (E.value.flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) { + cf->set_value("params", "roughness/mode", E.value.channel_for_roughness + 2); + cf->set_value("params", "roughness/src_normal", E.value.normal_path_for_roughness); changed = true; } - if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d/compress_to"))) { + if (E.value.flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d/compress_to"))) { int compress_to = cf->get_value("params", "detect_3d/compress_to"); cf->set_value("params", "detect_3d/compress_to", 0); if (compress_to == 1) { @@ -121,7 +121,7 @@ void ResourceImporterTexture::update_imports() { if (changed) { cf->save(src_path); - to_reimport.push_back(E->key()); + to_reimport.push_back(E.key); } } diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index f99ab9888a..7ab5308a47 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -771,52 +771,52 @@ void SceneImportSettings::_re_import() { Dictionary subresources; - for (Map::Element *E = node_map.front(); E; E = E->next()) { - if (E->get().settings.size()) { + for (KeyValue &E : node_map) { + if (E.value.settings.size()) { Dictionary d; - for (Map::Element *F = E->get().settings.front(); F; F = F->next()) { - d[String(F->key())] = F->get(); + for (const KeyValue &F : E.value.settings) { + d[String(F.key)] = F.value; } - nodes[E->key()] = d; + nodes[E.key] = d; } } if (nodes.size()) { subresources["nodes"] = nodes; } - for (Map::Element *E = material_map.front(); E; E = E->next()) { - if (E->get().settings.size()) { + for (KeyValue &E : material_map) { + if (E.value.settings.size()) { Dictionary d; - for (Map::Element *F = E->get().settings.front(); F; F = F->next()) { - d[String(F->key())] = F->get(); + for (const KeyValue &F : E.value.settings) { + d[String(F.key)] = F.value; } - materials[E->key()] = d; + materials[E.key] = d; } } if (materials.size()) { subresources["materials"] = materials; } - for (Map::Element *E = mesh_map.front(); E; E = E->next()) { - if (E->get().settings.size()) { + for (KeyValue &E : mesh_map) { + if (E.value.settings.size()) { Dictionary d; - for (Map::Element *F = E->get().settings.front(); F; F = F->next()) { - d[String(F->key())] = F->get(); + for (const KeyValue &F : E.value.settings) { + d[String(F.key)] = F.value; } - meshes[E->key()] = d; + meshes[E.key] = d; } } if (meshes.size()) { subresources["meshes"] = meshes; } - for (Map::Element *E = animation_map.front(); E; E = E->next()) { - if (E->get().settings.size()) { + for (KeyValue &E : animation_map) { + if (E.value.settings.size()) { Dictionary d; - for (Map::Element *F = E->get().settings.front(); F; F = F->next()) { - d[String(F->key())] = F->get(); + for (const KeyValue &F : E.value.settings) { + d[String(F.key)] = F.value; } - animations[E->key()] = d; + animations[E.key] = d; } } if (animations.size()) { @@ -889,8 +889,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { switch (current_action) { case ACTION_EXTRACT_MATERIALS: { - for (Map::Element *E = material_map.front(); E; E = E->next()) { - MaterialData &md = material_map[E->key()]; + for (const KeyValue &E : material_map) { + MaterialData &md = material_map[E.key]; TreeItem *item = external_path_tree->create_item(root); @@ -905,7 +905,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(2, "Already External"); item->set_tooltip(2, TTR("This material already references an external file, no action will be taken.\nDisable the external property for it to be extracted again.")); } else { - item->set_metadata(0, E->key()); + item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); String path = p_path.plus_file(name); @@ -942,8 +942,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { external_paths->get_ok_button()->set_text(TTR("Extract")); } break; case ACTION_CHOOSE_MESH_SAVE_PATHS: { - for (Map::Element *E = mesh_map.front(); E; E = E->next()) { - MeshData &md = mesh_map[E->key()]; + for (const KeyValue &E : mesh_map) { + MeshData &md = mesh_map[E.key]; TreeItem *item = external_path_tree->create_item(root); @@ -958,7 +958,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(2, "Already Saving"); item->set_tooltip(2, TTR("This mesh already saves to an external resource, no action will be taken.")); } else { - item->set_metadata(0, E->key()); + item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); String path = p_path.plus_file(name); @@ -995,8 +995,8 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { external_paths->get_ok_button()->set_text(TTR("Set Paths")); } break; case ACTION_CHOOSE_ANIMATION_SAVE_PATHS: { - for (Map::Element *E = animation_map.front(); E; E = E->next()) { - AnimationData &ad = animation_map[E->key()]; + for (const KeyValue &E : animation_map) { + AnimationData &ad = animation_map[E.key]; TreeItem *item = external_path_tree->create_item(root); @@ -1010,7 +1010,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { item->set_text(2, "Already Saving"); item->set_tooltip(2, TTR("This animation already saves to an external resource, no action will be taken.")); } else { - item->set_metadata(0, E->key()); + item->set_metadata(0, E.key); item->set_editable(0, true); item->set_checked(0, true); String path = p_path.plus_file(name); diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index f83a7d046a..370394b475 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -966,8 +966,8 @@ Ref EditorSceneImporterMesh::create_navigation_mesh() { Vector vertices; vertices.resize(unique_vertices.size()); - for (Map::Element *E = unique_vertices.front(); E; E = E->next()) { - vertices.write[E->get()] = E->key(); + for (const KeyValue &E : unique_vertices) { + vertices.write[E.value] = E.key; } Ref nm; diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 25bca1d4f4..8300dcf555 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -86,9 +86,9 @@ void ImportDefaultsEditor::_save() { if (settings->importer.is_valid()) { Dictionary modified; - for (Map::Element *E = settings->values.front(); E; E = E->next()) { - if (E->get() != settings->default_values[E->key()]) { - modified[E->key()] = E->get(); + for (const KeyValue &E : settings->values) { + if (E.value != settings->default_values[E.key]) { + modified[E.key] = E.value; } } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 24cb660f7a..55ffbf9477 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -776,16 +776,16 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { } if (player) { - for (Map::Element *E = animations.front(); E; E = E->next()) { - Ref an = blend_tree->get_node(E->key()); + for (const KeyValue &E : animations) { + Ref an = blend_tree->get_node(E.key); if (an.is_valid()) { if (player->has_animation(an->get_animation())) { Ref anim = player->get_animation(an->get_animation()); if (anim.is_valid()) { - E->get()->set_max(anim->get_length()); + E.value->set_max(anim->get_length()); //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)); + StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time"; + E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); } } } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 664b2f521e..aacfc3e305 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -830,9 +830,9 @@ void EditorAssetLibrary::_update_image_queue() { int current_images = 0; List to_delete; - for (Map::Element *E = image_queue.front(); E; E = E->next()) { - if (!E->get().active && current_images < max_images) { - String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + E->get().image_url.md5_text()); + for (KeyValue &E : image_queue) { + if (!E.value.active && current_images < max_images) { + String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + E.value.image_url.md5_text()); Vector headers; if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) { @@ -844,14 +844,14 @@ void EditorAssetLibrary::_update_image_queue() { } } - Error err = E->get().request->request(E->get().image_url, headers); + Error err = E.value.request->request(E.value.image_url, headers); if (err != OK) { - to_delete.push_back(E->key()); + to_delete.push_back(E.key); } else { - E->get().active = true; + E.value.active = true; } current_images++; - } else if (E->get().active) { + } else if (E.value.active) { current_images++; } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index a42bdfea34..a49dd916f3 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -748,8 +748,8 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po List CanvasItemEditor::_get_edited_canvas_items(bool retreive_locked, bool remove_canvas_item_if_parent_in_selection) { List selection; - for (Map::Element *E = editor_selection->get_selection().front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to(E->key()); + for (const KeyValue &E : editor_selection->get_selection()) { + CanvasItem *canvas_item = Object::cast_to(E.key); if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retreive_locked || !_is_node_locked(canvas_item))) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data(canvas_item); if (se) { @@ -3782,8 +3782,8 @@ void CanvasItemEditor::_notification(int p_what) { } // Update the viewport if bones changes - for (Map::Element *E = bone_list.front(); E; E = E->next()) { - Object *b = ObjectDB::get_instance(E->key().from); + for (KeyValue &E : bone_list) { + Object *b = ObjectDB::get_instance(E.key.from); if (!b) { viewport->update(); break; @@ -3796,14 +3796,14 @@ void CanvasItemEditor::_notification(int p_what) { Transform2D global_xform = b2->get_global_transform(); - if (global_xform != E->get().xform) { - E->get().xform = global_xform; + if (global_xform != E.value.xform) { + E.value.xform = global_xform; viewport->update(); } Bone2D *bone = Object::cast_to(b); - if (bone && bone->get_length() != E->get().length) { - E->get().length = bone->get_length(); + if (bone && bone->get_length() != E.value.length) { + E.value.length = bone->get_length(); viewport->update(); } } @@ -4263,8 +4263,8 @@ void CanvasItemEditor::_button_tool_select(int p_index) { void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) { Map &selection = editor_selection->get_selection(); - for (Map::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + CanvasItem *canvas_item = Object::cast_to(E.key); if (!canvas_item || !canvas_item->is_visible_in_tree()) { continue; } @@ -4695,8 +4695,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { Map &selection = editor_selection->get_selection(); - for (Map::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + CanvasItem *canvas_item = Object::cast_to(E.key); if (!canvas_item || !canvas_item->is_visible_in_tree()) { continue; } @@ -4741,8 +4741,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { case ANIM_CLEAR_POSE: { Map &selection = editor_selection->get_selection(); - for (Map::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + CanvasItem *canvas_item = Object::cast_to(E.key); if (!canvas_item || !canvas_item->is_visible_in_tree()) { continue; } @@ -4816,8 +4816,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { Node *editor_root = EditorNode::get_singleton()->get_edited_scene()->get_tree()->get_edited_scene_root(); undo_redo->create_action(TTR("Create Custom Bone2D(s) from Node(s)")); - for (Map::Element *E = selection.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + Node2D *n2d = Object::cast_to(E.key); Bone2D *new_bone = memnew(Bone2D); String new_bone_name = n2d->get_name(); @@ -4861,8 +4861,8 @@ void CanvasItemEditor::_focus_selection(int p_op) { int count = 0; Map &selection = editor_selection->get_selection(); - for (Map::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + CanvasItem *canvas_item = Object::cast_to(E.key); if (!canvas_item) { continue; } diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index eb771f2bc4..ac7bfd267b 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -4773,10 +4773,10 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } Vector lines; - for (Map<_EdgeKey, bool>::Element *E = edge_map.front(); E; E = E->next()) { - if (E->get()) { - lines.push_back(E->key().from); - lines.push_back(E->key().to); + for (const KeyValue<_EdgeKey, bool> &E : edge_map) { + if (E.value) { + lines.push_back(E.key.from); + lines.push_back(E.key.to); } } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 857190bc92..dae3b6aaec 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -357,8 +357,8 @@ int Node3DEditorViewport::get_selected_count() const { int count = 0; - for (Map::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + Node3D *sp = Object::cast_to(E.key); if (!sp) { continue; } @@ -864,8 +864,8 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data(selected) : nullptr; if (se && se->gizmo.is_valid()) { - for (Map::Element *E = se->subgizmos.front(); E; E = E->next()) { - int subgizmo_id = E->key(); + for (const KeyValue &E : se->subgizmos) { + int subgizmo_id = E.key; se->subgizmos[subgizmo_id] = se->gizmo->get_subgizmo_transform(subgizmo_id); } se->original_local = selected->get_transform(); @@ -1374,9 +1374,9 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { Vector ids; Vector restore; - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - ids.push_back(GE->key()); - restore.push_back(GE->value()); + for (const KeyValue &GE : se->subgizmos) { + ids.push_back(GE.key); + restore.push_back(GE.value); } se->gizmo->commit_subgizmos(ids, restore, true); @@ -1612,9 +1612,9 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { Vector ids; Vector restore; - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - ids.push_back(GE->key()); - restore.push_back(GE->value()); + for (const KeyValue &GE : se->subgizmos) { + ids.push_back(GE.key); + restore.push_back(GE.value); } se->gizmo->commit_subgizmos(ids, restore, false); @@ -1845,13 +1845,13 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { } if (se->gizmo.is_valid()) { - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - Transform3D xform = GE->get(); + for (KeyValue &GE : se->subgizmos) { + Transform3D xform = GE.value; Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords); if (!local_coords) { new_xform = se->original.affine_inverse() * new_xform; } - se->gizmo->set_subgizmo_transform(GE->key(), new_xform); + se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords); @@ -1944,11 +1944,11 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { } if (se->gizmo.is_valid()) { - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - Transform3D xform = GE->get(); + for (KeyValue &GE : se->subgizmos) { + Transform3D xform = GE.value; Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords); new_xform = se->original.affine_inverse() * new_xform; - se->gizmo->set_subgizmo_transform(GE->key(), new_xform); + se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords); @@ -2030,14 +2030,14 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { Vector3 compute_axis = local_coords ? axis : plane.normal; if (se->gizmo.is_valid()) { - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - Transform3D xform = GE->get(); + for (KeyValue &GE : se->subgizmos) { + Transform3D xform = GE.value; Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords); if (!local_coords) { new_xform = se->original.affine_inverse() * new_xform; } - se->gizmo->set_subgizmo_transform(GE->key(), new_xform); + se->gizmo->set_subgizmo_transform(GE.key, new_xform); } } else { Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords); @@ -2666,8 +2666,8 @@ void Node3DEditorViewport::_notification(int p_what) { bool changed = false; bool exist = false; - for (Map::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to(E->key()); + for (const KeyValue &E : selection) { + Node3D *sp = Object::cast_to(E.key); if (!sp) { continue; } @@ -3809,8 +3809,8 @@ void Node3DEditorViewport::focus_selection() { } if (se->gizmo.is_valid()) { - for (Map::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { - center += se->gizmo->get_subgizmo_transform(GE->key()).origin; + for (const KeyValue &GE : se->subgizmos) { + center += se->gizmo->get_subgizmo_transform(GE.key).origin; count++; } } @@ -4750,8 +4750,8 @@ void Node3DEditor::update_transform_gizmo() { Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data(selected) : nullptr; if (se && se->gizmo.is_valid()) { - for (Map::Element *E = se->subgizmos.front(); E; E = E->next()) { - Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E->key()); + for (const KeyValue &E : se->subgizmos) { + Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E.key); gizmo_center += xf.origin; if (count == 0 && local_gizmo_coords) { gizmo_basis = xf.basis; @@ -6677,8 +6677,8 @@ Vector Node3DEditor::get_subgizmo_selection() { Vector ret; if (se) { - for (Map::Element *E = se->subgizmos.front(); E; E = E->next()) { - ret.push_back(E->key()); + for (const KeyValue &E : se->subgizmos) { + ret.push_back(E.key); } } return ret; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 22ca5592bd..a88e24c0d0 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -131,9 +131,9 @@ void ShaderTextEditor::_load_theme_settings() { List built_ins; if (shader.is_valid()) { - for (const Map::Element *E = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { - for (const Map::Element *F = E->get().built_ins.front(); F; F = F->next()) { - built_ins.push_back(F->key()); + for (const KeyValue &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()))) { + for (const KeyValue &F : E.value.built_ins) { + built_ins.push_back(F.key); } } diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 165a381407..a1591ce9d8 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -437,8 +437,8 @@ void ThemeItemImportTree::_update_total_selected(Theme::DataType p_data_type) { } int count = 0; - for (Map::Element *E = selected_items.front(); E; E = E->next()) { - ThemeItem ti = E->key(); + for (const KeyValue &E : selected_items) { + ThemeItem ti = E.key; if (ti.data_type == p_data_type) { count++; } @@ -759,7 +759,7 @@ void ThemeItemImportTree::_import_selected() { ProgressDialog::get_singleton()->add_task("import_theme_items", TTR("Importing Theme Items"), selected_items.size() + 2); int idx = 0; - for (Map::Element *E = selected_items.front(); E; E = E->next()) { + for (KeyValue &E : selected_items) { // Arbitrary number of items to skip from reporting. // Reduces the number of UI updates that this causes when copying large themes. if (idx % 10 == 0) { @@ -769,8 +769,8 @@ void ThemeItemImportTree::_import_selected() { ProgressDialog::get_singleton()->task_step("import_theme_items", TTR("Importing items {n}/{n}").format(arr, "{n}"), idx); } - ItemCheckedState cs = E->get(); - ThemeItem ti = E->key(); + ItemCheckedState cs = E.value; + ThemeItem ti = E.key; if (cs == SELECT_IMPORT_DEFINITION || cs == SELECT_IMPORT_FULL) { Variant item_value = Variant(); diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index e98bd74b62..f21d5098d3 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -522,10 +522,10 @@ void TileAtlasView::_update_alternative_tiles_rect_cache() { } Vector3i TileAtlasView::get_alternative_tile_at_pos(const Vector2 p_pos) const { - for (Map>::Element *E_coords = alternative_tiles_rect_cache.front(); E_coords; E_coords = E_coords->next()) { - for (Map::Element *E_alternative = E_coords->value().front(); E_alternative; E_alternative = E_alternative->next()) { - if (E_alternative->value().has_point(p_pos)) { - return Vector3i(E_coords->key().x, E_coords->key().y, E_alternative->key()); + for (const KeyValue> &E_coords : alternative_tiles_rect_cache) { + for (const KeyValue &E_alternative : E_coords.value) { + if (E_alternative.value.has_point(p_pos)) { + return Vector3i(E_coords.key.x, E_coords.key.y, E_alternative.key); } } } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 5f72cfe313..1a69d19d3c 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -756,10 +756,10 @@ Variant TileDataDefaultEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas_s } void TileDataDefaultEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { - for (Map::Element *E = p_previous_values.front(); E; E = E->next()) { - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E->key().alternative_tile, property), E->get()); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E->key().alternative_tile, property), p_new_value); + for (const KeyValue &E : p_previous_values) { + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E.key.alternative_tile, property), E.value); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/%s", coords.x, coords.y, E.key.alternative_tile, property), p_new_value); } } @@ -1191,10 +1191,10 @@ Variant TileDataOcclusionShapeEditor::_get_value(TileSetAtlasSource *p_tile_set_ } void TileDataOcclusionShapeEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { - for (Map::Element *E = p_previous_values.front(); E; E = E->next()) { - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, occlusion_layer), E->get()); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, occlusion_layer), p_new_value); + for (const KeyValue &E : p_previous_values) { + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, occlusion_layer), E.value); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/occlusion_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, occlusion_layer), p_new_value); } } @@ -1312,8 +1312,8 @@ void TileDataCollisionEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_ dummy_object->set(vformat("polygon_%d_one_way", i), tile_data->is_collision_polygon_one_way(physics_layer, i)); dummy_object->set(vformat("polygon_%d_one_way_margin", i), tile_data->get_collision_polygon_one_way_margin(physics_layer, i)); } - for (Map::Element *E = property_editors.front(); E; E = E->next()) { - E->get()->update_property(); + for (const KeyValue &E : property_editors) { + E.value->update_property(); } polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); @@ -1359,24 +1359,24 @@ Variant TileDataCollisionEditor::_get_value(TileSetAtlasSource *p_tile_set_atlas void TileDataCollisionEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { Array new_array = p_new_value; - for (Map::Element *E = p_previous_values.front(); E; E = E->next()) { - Array old_array = E->get(); + for (KeyValue &E : p_previous_values) { + Array old_array = E.value; - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E->key().alternative_tile, physics_layer), old_array.size()); + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E.key.alternative_tile, physics_layer), old_array.size()); for (int i = 0; i < old_array.size(); i++) { Dictionary dict = old_array[i]; - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["points"]); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way"]); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way_margin"]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["points"]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["one_way"]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["one_way_margin"]); } - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E->key().alternative_tile, physics_layer), new_array.size()); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygons_count", coords.x, coords.y, E.key.alternative_tile, physics_layer), new_array.size()); for (int i = 0; i < new_array.size(); i++) { Dictionary dict = new_array[i]; - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["points"]); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way"]); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E->key().alternative_tile, physics_layer, i), dict["one_way_margin"]); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/points", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["points"]); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["one_way"]); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/physics_layer_%d/polygon_%d/one_way_margin", coords.x, coords.y, E.key.alternative_tile, physics_layer, i), dict["one_way_margin"]); } } } @@ -2021,16 +2021,16 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t drag_type = DRAG_TYPE_NONE; } else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) { undo_redo->create_action(TTR("Painting Terrain Set")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - Dictionary dict = E->get(); - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), drag_painted_value); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), dict["terrain_set"]); + for (KeyValue &E : drag_modified) { + Dictionary dict = E.value; + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.key.alternative_tile), drag_painted_value); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.key.alternative_tile), dict["terrain_set"]); Array array = dict["terrain_peering_bits"]; for (int i = 0; i < array.size(); i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) { - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), array[i]); } } } @@ -2041,17 +2041,17 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(TileAtlasView *p_t int terrain_set = int(painted["terrain_set"]); int terrain = int(painted["terrain"]); undo_redo->create_action(TTR("Painting Terrain")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - Dictionary dict = E->get(); - Vector2i coords = E->key().get_atlas_coords(); + for (KeyValue &E : drag_modified) { + Dictionary dict = E.value; + Vector2i coords = E.key.get_atlas_coords(); Array array = dict["terrain_peering_bits"]; for (int i = 0; i < array.size(); i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) { - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), terrain); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), terrain); } if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) { - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), array[i]); } } } @@ -2304,14 +2304,14 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(TileAtlasVi } else { if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) { undo_redo->create_action(TTR("Painting Tiles Property")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - Dictionary dict = E->get(); - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), dict["terrain_set"]); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E->key().alternative_tile), drag_painted_value); + for (KeyValue &E : drag_modified) { + Dictionary dict = E.value; + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.key.alternative_tile), dict["terrain_set"]); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain_set", coords.x, coords.y, E.key.alternative_tile), drag_painted_value); Array array = dict["terrain_peering_bits"]; for (int i = 0; i < array.size(); i++) { - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), array[i]); } } undo_redo->commit_action(false); @@ -2321,17 +2321,17 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(TileAtlasVi int terrain_set = int(painted["terrain_set"]); int terrain = int(painted["terrain"]); undo_redo->create_action(TTR("Painting Terrain")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - Dictionary dict = E->get(); - Vector2i coords = E->key().get_atlas_coords(); + for (KeyValue &E : drag_modified) { + Dictionary dict = E.value; + Vector2i coords = E.key.get_atlas_coords(); Array array = dict["terrain_peering_bits"]; for (int i = 0; i < array.size(); i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(terrain_set, bit)) { - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), terrain); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), terrain); } if (tile_set->is_valid_peering_bit_terrain(dict["terrain_set"], bit)) { - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E->key().alternative_tile), array[i]); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.key.alternative_tile), array[i]); } } } @@ -2443,10 +2443,10 @@ Variant TileDataNavigationEditor::_get_value(TileSetAtlasSource *p_tile_set_atla } void TileDataNavigationEditor::_setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map p_previous_values, Variant p_new_value) { - for (Map::Element *E = p_previous_values.front(); E; E = E->next()) { - Vector2i coords = E->key().get_atlas_coords(); - undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, navigation_layer), E->get()); - undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E->key().alternative_tile, navigation_layer), p_new_value); + for (const KeyValue &E : p_previous_values) { + Vector2i coords = E.key.get_atlas_coords(); + undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, navigation_layer), E.value); + undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/navigation_layer_%d/polygon", coords.x, coords.y, E.key.alternative_tile, navigation_layer), p_new_value); } } diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index a248f23517..cc5ff90541 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -455,15 +455,15 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref &p switch (drag_type) { case DRAG_TYPE_PAINT: { Map to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - Vector2i coords = E->key(); + Vector2i coords = E.key; if (!drag_modified.has(coords)) { drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); } - tile_map->set_cell(tile_map_layer, coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } break; case DRAG_TYPE_BUCKET: { @@ -471,15 +471,15 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref &p for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { Map to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - Vector2i coords = E->key(); + Vector2i coords = E.key; if (!drag_modified.has(coords)) { drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); } - tile_map->set_cell(tile_map_layer, coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } } @@ -531,15 +531,15 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref &p drag_start_mouse_pos = mpos; drag_modified.clear(); Map to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - Vector2i coords = E->key(); + Vector2i coords = E.key; if (!drag_modified.has(coords)) { drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); } - tile_map->set_cell(tile_map_layer, coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } else if (tool_buttons_group->get_pressed_button() == line_tool_button) { drag_type = DRAG_TYPE_LINE; @@ -557,15 +557,15 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref &p for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { Map to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - Vector2i coords = E->key(); + Vector2i coords = E.key; if (!drag_modified.has(coords)) { drag_modified.insert(coords, tile_map->get_cell(tile_map_layer, coords)); } - tile_map->set_cell(tile_map_layer, coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + tile_map->set_cell(tile_map_layer, coords, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } } @@ -710,8 +710,8 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over // Expand the grid if needed if (expand_grid && !preview.is_empty()) { drawn_grid_rect = Rect2i(preview.front()->key(), Vector2i(1, 1)); - for (Map::Element *E = preview.front(); E; E = E->next()) { - drawn_grid_rect.expand_to(E->key()); + for (const KeyValue &E : preview) { + drawn_grid_rect.expand_to(E.key); } } } @@ -748,23 +748,23 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over } // Draw the preview. - for (Map::Element *E = preview.front(); E; E = E->next()) { + for (const KeyValue &E : preview) { Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(E->key())); + tile_xform.set_origin(tile_map->map_to_world(E.key)); tile_xform.set_scale(tile_set->get_tile_size()); if (!erase_button->is_pressed() && random_tile_checkbox->is_pressed()) { tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(1.0, 1.0, 1.0, 0.5), true); } else { - if (tile_set->has_source(E->get().source_id)) { - TileSetSource *source = *tile_set->get_source(E->get().source_id); + if (tile_set->has_source(E.value.source_id)) { + TileSetSource *source = *tile_set->get_source(E.value.source_id); TileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get tile data. - TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(E->get().get_atlas_coords(), E->get().alternative_tile)); + TileData *tile_data = Object::cast_to(atlas_source->get_tile_data(E.value.get_atlas_coords(), E.value.alternative_tile)); // Compute the offset - Rect2i source_rect = atlas_source->get_tile_texture_region(E->get().get_atlas_coords()); - Vector2i tile_offset = atlas_source->get_tile_effective_texture_offset(E->get().get_atlas_coords(), E->get().alternative_tile); + Rect2i source_rect = atlas_source->get_tile_texture_region(E.value.get_atlas_coords()); + Vector2i tile_offset = atlas_source->get_tile_effective_texture_offset(E.value.get_atlas_coords(), E.value.alternative_tile); // Compute the destination rectangle in the CanvasItem. Rect2 dest_rect; @@ -772,9 +772,9 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over bool transpose = tile_data->get_transpose(); if (transpose) { - dest_rect.position = (tile_map->map_to_world(E->key()) - Vector2(dest_rect.size.y, dest_rect.size.x) / 2 - tile_offset); + dest_rect.position = (tile_map->map_to_world(E.key) - Vector2(dest_rect.size.y, dest_rect.size.x) / 2 - tile_offset); } else { - dest_rect.position = (tile_map->map_to_world(E->key()) - dest_rect.size / 2 - tile_offset); + dest_rect.position = (tile_map->map_to_world(E.key) - dest_rect.size / 2 - tile_offset); } dest_rect = xform.xform(dest_rect); @@ -1165,11 +1165,11 @@ void TileMapEditorTilesPlugin::_stop_dragging() { } undo_redo->create_action(TTR("Move tiles")); // Move the tiles. - for (Map::Element *E = cells_do.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : cells_do) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } - for (Map::Element *E = cells_undo.front(); E; E = E->next()) { - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : cells_undo) { + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } // Update the selection. @@ -1205,41 +1205,41 @@ void TileMapEditorTilesPlugin::_stop_dragging() { } break; case DRAG_TYPE_PAINT: { undo_redo->create_action(TTR("Paint tiles")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), tile_map->get_cell_source_id(tile_map_layer, E->key()), tile_map->get_cell_atlas_coords(tile_map_layer, E->key()), tile_map->get_cell_alternative_tile(tile_map_layer, E->key())); - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : drag_modified) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } undo_redo->commit_action(false); } break; case DRAG_TYPE_LINE: { Map to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos); undo_redo->create_action(TTR("Paint tiles")); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), tile_map->get_cell_source_id(tile_map_layer, E->key()), tile_map->get_cell_atlas_coords(tile_map_layer, E->key()), tile_map->get_cell_alternative_tile(tile_map_layer, E->key())); + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); } undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { Map to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos)); undo_redo->create_action(TTR("Paint tiles")); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { + for (const KeyValue &E : to_draw) { + if (!erase_button->is_pressed() && E.value.source_id == TileSet::INVALID_SOURCE) { continue; } - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), tile_map->get_cell_source_id(tile_map_layer, E->key()), tile_map->get_cell_atlas_coords(tile_map_layer, E->key()), tile_map->get_cell_alternative_tile(tile_map_layer, E->key())); + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); } undo_redo->commit_action(); } break; case DRAG_TYPE_BUCKET: { undo_redo->create_action(TTR("Paint tiles")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), tile_map->get_cell_source_id(tile_map_layer, E->key()), tile_map->get_cell_atlas_coords(tile_map_layer, E->key()), tile_map->get_cell_alternative_tile(tile_map_layer, E->key())); - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : drag_modified) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } undo_redo->commit_action(false); } break; @@ -1364,17 +1364,17 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_selection( } int vertical_offset = 0; - for (Map>::Element *E_source = per_source.front(); E_source; E_source = E_source->next()) { + for (const KeyValue> &E_source : per_source) { // Per source. List unorganized; Rect2i encompassing_rect_coords; Map organized_pattern; - TileSetSource *source = *tile_set->get_source(E_source->key()); + TileSetSource *source = *tile_set->get_source(E_source.key); TileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Organize using coordinates. - for (const TileMapCell *current : E_source->get()) { + for (const TileMapCell *current : E_source.value) { if (current->alternative_tile == 0) { organized_pattern[current->get_atlas_coords()] = current; } else { @@ -1393,14 +1393,14 @@ void TileMapEditorTilesPlugin::_update_selection_pattern_from_tileset_selection( } } else { // Add everything unorganized. - for (const TileMapCell *cell : E_source->get()) { + for (const TileMapCell *cell : E_source.value) { unorganized.push_back(cell); } } // Now add everything to the output pattern. - for (Map::Element *E_cell = organized_pattern.front(); E_cell; E_cell = E_cell->next()) { - selection_pattern->set_cell(E_cell->key() - encompassing_rect_coords.position + Vector2i(0, vertical_offset), E_cell->get()->source_id, E_cell->get()->get_atlas_coords(), E_cell->get()->alternative_tile); + for (const KeyValue &E_cell : organized_pattern) { + selection_pattern->set_cell(E_cell.key - encompassing_rect_coords.position + Vector2i(0, vertical_offset), E_cell.value->source_id, E_cell.value->get_atlas_coords(), E_cell.value->alternative_tile); } Vector2i organized_size = selection_pattern->get_size(); int unorganized_index = 0; @@ -2308,14 +2308,14 @@ Set TileMapEditorTerrainsPlugi // Returns all tiles compatible with the given constraints. Set compatible_terrain_tile_patterns; - for (Map>::Element *E = per_terrain_terrains_tile_patterns_tiles[p_terrain_set].front(); E; E = E->next()) { + for (const KeyValue> &E : per_terrain_terrains_tile_patterns_tiles[p_terrain_set]) { int valid = true; int in_pattern_count = 0; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); if (tile_set->is_valid_peering_bit_terrain(p_terrain_set, bit)) { // Check if the bit is compatible with the constraints. - Constraint terrain_bit_constraint = Constraint(tile_map, p_position, bit, E->key()[in_pattern_count]); + Constraint terrain_bit_constraint = Constraint(tile_map, p_position, bit, E.key[in_pattern_count]); Set::Element *in_set_constraint_element = p_constraints.find(terrain_bit_constraint); if (in_set_constraint_element && in_set_constraint_element->get().get_terrain() != terrain_bit_constraint.get_terrain()) { @@ -2327,7 +2327,7 @@ Set TileMapEditorTerrainsPlugi } if (valid) { - compatible_terrain_tile_patterns.insert(E->key()); + compatible_terrain_tile_patterns.insert(E.key); } } @@ -2368,15 +2368,15 @@ Set TileMapEditorTerrainsPlugin::_get_c // Count the number of occurrences per terrain. Map overlapping_terrain_bits = c.get_overlapping_coords_and_peering_bits(); - for (Map::Element *E_overlapping = overlapping_terrain_bits.front(); E_overlapping; E_overlapping = E_overlapping->next()) { - if (!p_to_replace.has(E_overlapping->key())) { - TileMapCell neighbor_cell = tile_map->get_cell(tile_map_layer, E_overlapping->key()); + for (const KeyValue &E_overlapping : overlapping_terrain_bits) { + if (!p_to_replace.has(E_overlapping.key)) { + TileMapCell neighbor_cell = tile_map->get_cell(tile_map_layer, E_overlapping.key); TileData *neighbor_tile_data = nullptr; if (terrain_tiles.has(neighbor_cell) && terrain_tiles[neighbor_cell]->get_terrain_set() == p_terrain_set) { neighbor_tile_data = terrain_tiles[neighbor_cell]; } - int terrain = neighbor_tile_data ? neighbor_tile_data->get_peering_bit_terrain(TileSet::CellNeighbor(E_overlapping->get())) : -1; + int terrain = neighbor_tile_data ? neighbor_tile_data->get_peering_bit_terrain(TileSet::CellNeighbor(E_overlapping.value)) : -1; if (terrain_count.has(terrain)) { terrain_count[terrain] = 0; } @@ -2387,10 +2387,10 @@ Set TileMapEditorTerrainsPlugin::_get_c // Get the terrain with the max number of occurrences. int max = 0; int max_terrain = -1; - for (Map::Element *E_terrain_count = terrain_count.front(); E_terrain_count; E_terrain_count = E_terrain_count->next()) { - if (E_terrain_count->get() > max) { - max = E_terrain_count->get(); - max_terrain = E_terrain_count->key(); + for (const KeyValue &E_terrain_count : terrain_count) { + if (E_terrain_count.value > max) { + max = E_terrain_count.value; + max_terrain = E_terrain_count.key; } } @@ -2458,15 +2458,15 @@ Map TileMapEditorTer while (!to_replace.is_empty()) { // Compute the minimum number of tile possibilities for each cell. int min_nb_possibilities = 100000000; - for (Map>::Element *E = per_cell_acceptable_tiles.front(); E; E = E->next()) { - min_nb_possibilities = MIN(min_nb_possibilities, E->get().size()); + for (const KeyValue> &E : per_cell_acceptable_tiles) { + min_nb_possibilities = MIN(min_nb_possibilities, E.value.size()); } // Get the set of possible cells to fill. LocalVector to_choose_from; - for (Map>::Element *E = per_cell_acceptable_tiles.front(); E; E = E->next()) { - if (E->get().size() == min_nb_possibilities) { - to_choose_from.push_back(E->key()); + for (const KeyValue> &E : per_cell_acceptable_tiles) { + if (E.value.size() == min_nb_possibilities) { + to_choose_from.push_back(E.key); } } @@ -2584,9 +2584,9 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map // Add the constraints from the added tiles. Set added_tiles_constraints_set; - for (Map::Element *E_to_paint = p_to_paint.front(); E_to_paint; E_to_paint = E_to_paint->next()) { - Vector2i coords = E_to_paint->key(); - TerrainsTilePattern terrains_tile_pattern = E_to_paint->get(); + for (const KeyValue &E_to_paint : p_to_paint) { + Vector2i coords = E_to_paint.key; + TerrainsTilePattern terrains_tile_pattern = E_to_paint.value; Set cell_constraints = _get_constraints_from_added_tile(coords, p_terrain_set, terrains_tile_pattern); for (Set::Element *E = cell_constraints.front(); E; E = E->next()) { @@ -2596,8 +2596,8 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map // Build the list of potential tiles to replace. Set potential_to_replace; - for (Map::Element *E_to_paint = p_to_paint.front(); E_to_paint; E_to_paint = E_to_paint->next()) { - Vector2i coords = E_to_paint->key(); + for (const KeyValue &E_to_paint : p_to_paint) { + Vector2i coords = E_to_paint.key; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { if (tile_map->is_existing_neighbor(TileSet::CellNeighbor(i))) { Vector2i neighbor = tile_map->get_neighbor_cell(coords, TileSet::CellNeighbor(i)); @@ -2612,8 +2612,8 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map Set to_replace; // Add the central tiles to the one to replace. TODO: maybe change that. - for (Map::Element *E_to_paint = p_to_paint.front(); E_to_paint; E_to_paint = E_to_paint->next()) { - to_replace.insert(E_to_paint->key()); + for (const KeyValue &E_to_paint : p_to_paint) { + to_replace.insert(E_to_paint.key); } // Add the constraints from the surroundings of the modified areas. @@ -2627,9 +2627,9 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map Map> source_tiles_of_constraint; for (Set::Element *E = removed_cells_constraints_set.front(); E; E = E->next()) { Map sources_of_constraint = E->get().get_overlapping_coords_and_peering_bits(); - for (Map::Element *E_source_tile_of_constraint = sources_of_constraint.front(); E_source_tile_of_constraint; E_source_tile_of_constraint = E_source_tile_of_constraint->next()) { - if (potential_to_replace.has(E_source_tile_of_constraint->key())) { - source_tiles_of_constraint[E->get()].insert(E_source_tile_of_constraint->key()); + for (const KeyValue &E_source_tile_of_constraint : sources_of_constraint) { + if (potential_to_replace.has(E_source_tile_of_constraint.key)) { + source_tiles_of_constraint[E->get()].insert(E_source_tile_of_constraint.key); } } } @@ -2646,8 +2646,8 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map potential_to_replace.erase(to_add_to_remove); to_replace.insert(to_add_to_remove); to_replace_modified = true; - for (Map>::Element *E_source_tiles_of_constraint = source_tiles_of_constraint.front(); E_source_tiles_of_constraint; E_source_tiles_of_constraint = E_source_tiles_of_constraint->next()) { - E_source_tiles_of_constraint->get().erase(to_add_to_remove); + for (KeyValue> &E_source_tiles_of_constraint : source_tiles_of_constraint) { + E_source_tiles_of_constraint.value.erase(to_add_to_remove); } break; } @@ -2665,13 +2665,13 @@ Map TileMapEditorTerrainsPlugin::_draw_terrains(const Map Map wfc_output = _wave_function_collapse(to_replace, p_terrain_set, constraints); // Use the WFC run for the output. - for (Map::Element *E = wfc_output.front(); E; E = E->next()) { - output[E->key()] = _get_random_tile_from_pattern(p_terrain_set, E->get()); + for (const KeyValue &E : wfc_output) { + output[E.key] = _get_random_tile_from_pattern(p_terrain_set, E.value); } // Override the WFC results to make sure at least the painted tiles are actually painted. - for (Map::Element *E_to_paint = p_to_paint.front(); E_to_paint; E_to_paint = E_to_paint->next()) { - output[E_to_paint->key()] = _get_random_tile_from_pattern(p_terrain_set, E_to_paint->get()); + for (const KeyValue &E_to_paint : p_to_paint) { + output[E_to_paint.key] = _get_random_tile_from_pattern(p_terrain_set, E_to_paint.value); } return output; @@ -2749,9 +2749,9 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { } break; case DRAG_TYPE_PAINT: { undo_redo->create_action(TTR("Paint terrain")); - for (Map::Element *E = drag_modified.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E->key(), tile_map->get_cell_source_id(tile_map_layer, E->key()), tile_map->get_cell_atlas_coords(tile_map_layer, E->key()), tile_map->get_cell_alternative_tile(tile_map_layer, E->key())); - undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : drag_modified) { + undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, E.key, tile_map->get_cell_source_id(tile_map_layer, E.key), tile_map->get_cell_atlas_coords(tile_map_layer, E.key), tile_map->get_cell_alternative_tile(tile_map_layer, E.key)); + undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } undo_redo->commit_action(false); } break; @@ -2825,11 +2825,11 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref to_draw[line[i]] = selected_terrains_tile_pattern; } Map modified = _draw_terrains(to_draw, selected_terrain_set); - for (Map::Element *E = modified.front(); E; E = E->next()) { - if (!drag_modified.has(E->key())) { - drag_modified[E->key()] = tile_map->get_cell(tile_map_layer, E->key()); + for (const KeyValue &E : modified) { + if (!drag_modified.has(E.key)) { + drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); } - tile_map->set_cell(tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + tile_map->set_cell(tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } } break; @@ -2864,9 +2864,9 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref terrains_to_draw[tile_map->world_to_map(mpos)] = selected_terrains_tile_pattern; Map to_draw = _draw_terrains(terrains_to_draw, selected_terrain_set); - for (Map::Element *E = to_draw.front(); E; E = E->next()) { - drag_modified[E->key()] = tile_map->get_cell(tile_map_layer, E->key()); - tile_map->set_cell(tile_map_layer, E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); + for (const KeyValue &E : to_draw) { + drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); + tile_map->set_cell(tile_map_layer, E.key, E.value.source_id, E.value.get_atlas_coords(), E.value.alternative_tile); } } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 1f1408016b..bc026146ef 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -674,9 +674,9 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { #undef ADD_TILE_DATA_EDITOR // Add tile data editors as children. - for (Map::Element *E = tile_data_editors.front(); E; E = E->next()) { + for (KeyValue &E : tile_data_editors) { // Tile Data Editor. - TileDataEditor *tile_data_editor = E->get(); + TileDataEditor *tile_data_editor = E.value; if (!tile_data_editor->is_inside_tree()) { tile_data_painting_editor_container->add_child(tile_data_editor); } @@ -716,9 +716,9 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() { } // Hide all editors but the current one. - for (Map::Element *E = tile_data_editors.front(); E; E = E->next()) { - E->get()->hide(); - E->get()->get_toolbar()->hide(); + for (const KeyValue &E : tile_data_editors) { + E.value->hide(); + E.value->get_toolbar()->hide(); } if (tile_data_editors.has(property)) { current_tile_data_editor = tile_data_editors[property]; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 27f30479cf..b1b64564bb 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -123,9 +123,9 @@ void VisualShaderGraphPlugin::set_connections(List &p_ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id) { if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].output_ports.has(p_port_id)) { - for (Map::Element *E = links[p_node_id].output_ports.front(); E; E = E->next()) { - if (E->value().preview_button != nullptr) { - E->value().preview_button->set_pressed(false); + for (const KeyValue &E : links[p_node_id].output_ports) { + if (E.value.preview_button != nullptr) { + E.value.preview_button->set_pressed(false); } } @@ -264,11 +264,11 @@ void VisualShaderGraphPlugin::register_curve_editor(int p_node_id, int p_index, } void VisualShaderGraphPlugin::update_uniform_refs() { - for (Map::Element *E = links.front(); E; E = E->next()) { - VisualShaderNodeUniformRef *ref = Object::cast_to(E->get().visual_node); + for (KeyValue &E : links) { + VisualShaderNodeUniformRef *ref = Object::cast_to(E.value.visual_node); if (ref) { - remove_node(E->get().type, E->key()); - add_node(E->get().type, E->key()); + remove_node(E.value.type, E.key); + add_node(E.value.type, E.key); } } } diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 3441060fad..95a5646013 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -63,9 +63,9 @@ void BackgroundProgress::_add_task(const String &p_task, const String &p_label, void BackgroundProgress::_update() { _THREAD_SAFE_METHOD_ - for (Map::Element *E = updates.front(); E; E = E->next()) { - if (tasks.has(E->key())) { - _task_step(E->key(), E->get()); + for (const KeyValue &E : updates) { + if (tasks.has(E.key)) { + _task_step(E.key, E.value); } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index d2e8880bf9..a100e9fc55 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -517,8 +517,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(paste_parent, "add_child", dup); - for (Map::Element *E2 = duplimap.front(); E2; E2 = E2->next()) { - Node *d = E2->value(); + for (KeyValue &E2 : duplimap) { + Node *d = E2.value; editor_data->get_undo_redo().add_do_method(d, "set_owner", owner); } @@ -848,8 +848,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } Ref mne = memnew(MultiNodeEdit); - for (const Map::Element *E = editor_selection->get_selection().front(); E; E = E->next()) { - mne->add_node(root->get_path_to(E->key())); + for (const KeyValue &E : editor_selection->get_selection()) { + mne->add_node(root->get_path_to(E.key)); } EditorNode::get_singleton()->push_item(mne.ptr()); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 4cbc859e0c..1e19d9bd47 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -425,8 +425,8 @@ void ScriptCreateDialog::_lang_changed(int l) { templates[i].id = new_id; } // Disable overridden - for (Map>::Element *E = template_overrides.front(); E; E = E->next()) { - const Vector &overrides = E->get(); + for (const KeyValue> &E : template_overrides) { + const Vector &overrides = E.value; if (overrides.size() == 1) { continue; // doesn't override anything diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index f024589ef1..9c579f3e9f 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -382,8 +382,8 @@ void EditorSettingsDialog::_update_shortcuts() { } // remove sections with no shortcuts - for (Map::Element *E = sections.front(); E; E = E->next()) { - TreeItem *section = E->get(); + for (KeyValue &E : sections) { + TreeItem *section = E.value; if (section->get_first_child() == nullptr) { root->remove_child(section); } diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 3054debaec..6b2b0c4ad0 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -1404,8 +1404,8 @@ void BulletPhysicsServer3D::free(RID p_rid) { ShapeBullet *shape = shape_owner.get_or_null(p_rid); // Notify the shape is configured - for (Map::Element *element = shape->get_owners().front(); element; element = element->next()) { - static_cast(element->key())->remove_shape_full(shape); + for (const KeyValue &element : shape->get_owners()) { + static_cast(element.key)->remove_shape_full(shape); } shape_owner.free(p_rid); diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index 88ffb9ec67..ec039ba842 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -63,8 +63,8 @@ btCollisionShape *ShapeBullet::prepare(btCollisionShape *p_btShape) const { } void ShapeBullet::notifyShapeChanged() { - for (Map::Element *E = owners.front(); E; E = E->next()) { - ShapeOwnerBullet *owner = static_cast(E->key()); + for (const KeyValue &E : owners) { + ShapeOwnerBullet *owner = static_cast(E.key); owner->shape_changed(owner->find_shape(this)); } } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 229e1e2724..53694035dc 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -258,8 +258,8 @@ void CSGBrush::build_from_faces(const Vector &p_vertices, const Vector< } materials.resize(material_map.size()); - for (Map, int>::Element *E = material_map.front(); E; E = E->next()) { - materials.write[E->get()] = E->key(); + for (const KeyValue, int> &E : material_map) { + materials.write[E.value] = E.key; } _regen_face_aabbs(); @@ -457,8 +457,8 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b // Update the list of materials. r_merged_brush.materials.resize(mesh_merge.materials.size()); - for (const Map, int>::Element *E = mesh_merge.materials.front(); E; E = E->next()) { - r_merged_brush.materials.write[E->get()] = E->key(); + for (const KeyValue, int> &E : mesh_merge.materials) { + r_merged_brush.materials.write[E.value] = E.key; } } diff --git a/modules/fbx/data/fbx_skeleton.cpp b/modules/fbx/data/fbx_skeleton.cpp index 1ac4922acf..3dc163964c 100644 --- a/modules/fbx/data/fbx_skeleton.cpp +++ b/modules/fbx/data/fbx_skeleton.cpp @@ -98,9 +98,9 @@ void FBXSkeleton::init_skeleton(const ImportState &state) { ERR_FAIL_COND_MSG(skeleton->get_bone_count() != bone_count, "Not all bones got added, is the file corrupted?"); - for (Map>::Element *bone_element = bone_map.front(); bone_element; bone_element = bone_element->next()) { - const Ref bone = bone_element->value(); - int bone_index = bone_element->key(); + for (const KeyValue> &bone_element : bone_map) { + const Ref bone = bone_element.value; + int bone_index = bone_element.key; print_verbose("working on bone: " + itos(bone_index) + " bone name:" + bone->bone_name); skeleton->set_bone_rest(bone->godot_bone_id, get_unscaled_transform(bone->node->pivot_transform->LocalTransform, state.scale)); diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index e3f36ef3e3..e0663ab49d 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -567,8 +567,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // this means that the nodes from maya kLocators will be preserved as bones // in the same rig without having to match this across skeletons and merge by detection // we can just merge and undo any parent transforms - for (Map>::Element *bone_element = state.fbx_bone_map.front(); bone_element; bone_element = bone_element->next()) { - Ref bone = bone_element->value(); + for (KeyValue> &bone_element : state.fbx_bone_map) { + Ref bone = bone_element.value; Ref fbx_skeleton_inst; uint64_t armature_id = bone->armature_id; @@ -609,8 +609,8 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // setup skeleton instances if required :) - for (Map>::Element *skeleton_node = state.skeleton_map.front(); skeleton_node; skeleton_node = skeleton_node->next()) { - Ref &skeleton = skeleton_node->value(); + for (KeyValue> &skeleton_node : state.skeleton_map) { + Ref &skeleton = skeleton_node.value; skeleton->init_skeleton(state); ERR_CONTINUE_MSG(skeleton->fbx_node.is_null(), "invalid fbx target map, missing skeleton"); @@ -699,9 +699,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } } - for (Map>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - const uint64_t mesh_id = mesh_data->key(); - Ref mesh = mesh_data->value(); + for (KeyValue> &mesh_data : state.renderer_mesh_data) { + const uint64_t mesh_id = mesh_data.key; + Ref mesh = mesh_data.value; const FBXDocParser::MeshGeometry *mesh_geometry = p_document->GetObject(mesh_id)->Get(); @@ -765,9 +765,9 @@ Node3D *EditorSceneImporterFBX::_generate_scene( } // mesh data iteration for populating skeleton mapping - for (Map>::Element *mesh_data = state.renderer_mesh_data.front(); mesh_data; mesh_data = mesh_data->next()) { - Ref mesh = mesh_data->value(); - const uint64_t mesh_id = mesh_data->key(); + for (KeyValue> &mesh_data : state.renderer_mesh_data) { + Ref mesh = mesh_data.value; + const uint64_t mesh_id = mesh_data.key; EditorSceneImporterMeshNode3D *mesh_instance = mesh->godot_mesh_instance; const int mesh_weights = mesh->max_weight_count; Ref skeleton; @@ -1004,13 +1004,13 @@ Node3D *EditorSceneImporterFBX::_generate_scene( // target id, [ track name, [time index, vector] ] //std::map > AnimCurveNodes; - for (Map>::Element *track = AnimCurveNodes.front(); track; track = track->next()) { + for (KeyValue> &track : AnimCurveNodes) { // 5 tracks // current track index // track count is 5 // track count is 5. // next track id is 5. - const uint64_t target_id = track->key(); + const uint64_t target_id = track.key; int track_idx = animation->add_track(Animation::TYPE_TRANSFORM3D); // animation->track_set_path(track_idx, node_path); @@ -1072,7 +1072,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene( const FBXDocParser::Model *model = target_node->fbx_model; const FBXDocParser::PropertyTable *props = dynamic_cast(model); - Map &track_data = track->value(); + Map &track_data = track.value; FBXTrack &translation_keys = track_data[StringName("T")]; FBXTrack &rotation_keys = track_data[StringName("R")]; FBXTrack &scale_keys = track_data[StringName("S")]; @@ -1259,15 +1259,15 @@ Node3D *EditorSceneImporterFBX::_generate_scene( state.fbx_target_map.clear(); state.fbx_node_list.clear(); - for (Map>::Element *element = state.fbx_bone_map.front(); element; element = element->next()) { - Ref bone = element->value(); + for (KeyValue> &element : state.fbx_bone_map) { + Ref bone = element.value; bone->parent_bone.unref(); bone->node.unref(); bone->fbx_skeleton.unref(); } - for (Map>::Element *element = state.skeleton_map.front(); element; element = element->next()) { - Ref skel = element->value(); + for (KeyValue> &element : state.skeleton_map) { + Ref skel = element.value; skel->fbx_node.unref(); skel->skeleton_bones.clear(); } diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 906a721045..12d644ee94 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -53,9 +53,9 @@ protected: String csv_header = "file_path, error message, extra data\n"; massive_log_file += csv_header; - for (Map>::Element *element = validation_entries.front(); element; element = element->next()) { - for (unsigned int x = 0; x < element->value().size(); x++) { - const String &line_entry = element->key() + ", " + element->value()[x].c_escape() + "\n"; + for (const KeyValue> &element : validation_entries) { + for (unsigned int x = 0; x < element.value.size(); x++) { + const String &line_entry = element.key + ", " + element.value[x].c_escape() + "\n"; massive_log_file += line_entry; } } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index f965bcd014..9dad13a615 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -38,9 +38,9 @@ void GDNativeLibraryEditor::edit(Ref p_library) { library = p_library; Ref config = p_library->get_config_file(); - for (Map::Element *E = platforms.front(); E; E = E->next()) { - for (List::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + for (KeyValue &E : platforms) { + for (List::Element *it = E.value.entries.front(); it; it = it->next()) { + String target = E.key + "." + it->get(); TargetConfig ecfg; ecfg.library = config->get_value("entry", target, ""); ecfg.dependencies = config->get_value("dependencies", target, Array()); @@ -245,9 +245,9 @@ void GDNativeLibraryEditor::_translate_to_config_file() { config->erase_section("entry"); config->erase_section("dependencies"); - for (Map::Element *E = platforms.front(); E; E = E->next()) { - for (List::Element *it = E->value().entries.front(); it; it = it->next()) { - String target = E->key() + "." + it->get(); + for (KeyValue &E : platforms) { + for (List::Element *it = E.value.entries.front(); it; it = it->next()) { + String target = E.key + "." + it->get(); if (entry_configs[target].library.is_empty() && entry_configs[target].dependencies.is_empty()) { continue; } @@ -341,9 +341,9 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { filter_list->set_hide_on_checkable_item_selection(false); int idx = 0; - for (Map::Element *E = platforms.front(); E; E = E->next()) { - filter_list->add_check_item(E->get().name, idx); - filter_list->set_item_metadata(idx, E->key()); + for (const KeyValue &E : platforms) { + filter_list->add_check_item(E.value.name, idx); + filter_list->set_item_metadata(idx, E.key); filter_list->set_item_checked(idx, true); idx += 1; } diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 2d9b45cb07..598f7c7ad0 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -223,8 +223,8 @@ List generate_c_api_classes() { enum_api_map[enum_name] = enum_api; } } - for (const Map::Element *E = enum_api_map.front(); E; E = E->next()) { - global_constants_api.enums.push_back(E->get()); + for (const KeyValue &E : enum_api_map) { + global_constants_api.enums.push_back(E.value); } global_constants_api.constants.sort_custom(); api.push_back(global_constants_api); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 92ba9bd452..fb46bafb3c 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -360,8 +360,8 @@ void NativeScript::get_script_signal_list(List *r_signals) const { Set signals_; while (script_data) { - for (Map::Element *S = script_data->signals_.front(); S; S = S->next()) { - signals_.insert(S->get().signal); + for (const KeyValue &S : script_data->signals_) { + signals_.insert(S.value.signal); } script_data = script_data->base_data; @@ -401,8 +401,8 @@ void NativeScript::get_script_method_list(List *p_list) const { Set methods; while (script_data) { - for (Map::Element *E = script_data->methods.front(); E; E = E->next()) { - methods.insert(E->get().info); + for (const KeyValue &E : script_data->methods) { + methods.insert(E.value.info); } script_data = script_data->base_data; @@ -857,9 +857,9 @@ NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { Map> erase_and_unload; - for (Map>::Element *L = library_classes.front(); L; L = L->next()) { - String lib_path = L->key(); - Map classes = L->get(); + for (KeyValue> &L : library_classes) { + String lib_path = L.key; + Map classes = L.value; if (p_reload) { Map>::Element *E = library_gdnatives.find(lib_path); @@ -890,9 +890,9 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { gdn = E->get(); } - for (Map::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue &C : classes) { // free property stuff first - for (OrderedHashMap::Element P = C->get().properties.front(); P; P = P.next()) { + for (OrderedHashMap::Element P = C.value.properties.front(); P; P = P.next()) { if (P.get().getter.free_func) { P.get().getter.free_func(P.get().getter.method_data); } @@ -903,28 +903,28 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) { } // free method stuff - for (Map::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + for (const KeyValue &M : C.value.methods) { + if (M.value.method.free_func) { + M.value.method.free_func(M.value.method.method_data); } } // free constructor/destructor - if (C->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); + if (C.value.destroy_func.free_func) { + C.value.destroy_func.free_func(C.value.destroy_func.method_data); } } erase_and_unload.insert(lib_path, gdn); } - for (Map>::Element *E = erase_and_unload.front(); E; E = E->next()) { - String lib_path = E->key(); - Ref gdn = E->get(); + for (KeyValue> &E : erase_and_unload) { + String lib_path = E.key; + Ref gdn = E.value; library_classes.erase(lib_path); @@ -957,8 +957,8 @@ NativeScriptLanguage::NativeScriptLanguage() { } NativeScriptLanguage::~NativeScriptLanguage() { - for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref lib = L->get(); + for (KeyValue> &L : NSL->library_gdnatives) { + Ref lib = L.value; // only shut down valid libs, duh! if (lib.is_valid()) { // If it's a singleton-library then the gdnative module @@ -1157,15 +1157,15 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a int current = 0; - for (Map::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue &d : profile_data) { if (current >= p_info_max) { break; } - p_info_arr[current].call_count = d->get().call_count; - p_info_arr[current].self_time = d->get().self_time; - p_info_arr[current].total_time = d->get().total_time; - p_info_arr[current].signature = d->get().signature; + p_info_arr[current].call_count = d.value.call_count; + p_info_arr[current].self_time = d.value.self_time; + p_info_arr[current].total_time = d.value.total_time; + p_info_arr[current].signature = d.value.signature; current++; } @@ -1181,16 +1181,16 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in int current = 0; - for (Map::Element *d = profile_data.front(); d; d = d->next()) { + for (const KeyValue &d : profile_data) { if (current >= p_info_max) { break; } - if (d->get().last_frame_call_count) { - p_info_arr[current].call_count = d->get().last_frame_call_count; - p_info_arr[current].self_time = d->get().last_frame_self_time; - p_info_arr[current].total_time = d->get().last_frame_total_time; - p_info_arr[current].signature = d->get().signature; + if (d.value.last_frame_call_count) { + p_info_arr[current].call_count = d.value.last_frame_call_count; + p_info_arr[current].self_time = d.value.last_frame_self_time; + p_info_arr[current].total_time = d.value.last_frame_total_time; + p_info_arr[current].signature = d.value.signature; current++; } } @@ -1503,9 +1503,9 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { if (L) { Map classes = L->get(); - for (Map::Element *C = classes.front(); C; C = C->next()) { + for (KeyValue &C : classes) { // free property stuff first - for (OrderedHashMap::Element P = C->get().properties.front(); P; P = P.next()) { + for (OrderedHashMap::Element P = C.value.properties.front(); P; P = P.next()) { if (P.get().getter.free_func) { P.get().getter.free_func(P.get().getter.method_data); } @@ -1516,19 +1516,19 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { } // free method stuff - for (Map::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + for (const KeyValue &M : C.value.methods) { + if (M.value.method.free_func) { + M.value.method.free_func(M.value.method.method_data); } } // free constructor/destructor - if (C->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C.value.create_func.free_func) { + C.value.create_func.free_func(C.value.create_func.method_data); } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); + if (C.value.destroy_func.free_func) { + C.value.destroy_func.free_func(C.value.destroy_func.method_data); } } @@ -1548,14 +1548,14 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here - for (Map>::Element *L = library_gdnatives.front(); L; L = L->next()) { - if (L->get().is_null()) { + for (KeyValue> &L : library_gdnatives) { + if (L.value.is_null()) { continue; } - if (L->get()->is_initialized()) { + if (L.value->is_initialized()) { void *proc_ptr; - Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr); + Error err = L.value->get_symbol(L.value->get_library()->get_symbol_prefix() + name, proc_ptr); if (!err) { ((void (*)())proc_ptr)(); @@ -1584,13 +1584,13 @@ void NativeScriptLanguage::frame() { { MutexLock lock(mutex); - for (Map::Element *d = profile_data.front(); d; d = d->next()) { - d->get().last_frame_call_count = d->get().frame_call_count; - d->get().last_frame_self_time = d->get().frame_self_time; - d->get().last_frame_total_time = d->get().frame_total_time; - d->get().frame_call_count = 0; - d->get().frame_self_time = 0; - d->get().frame_total_time = 0; + for (KeyValue &d : profile_data) { + d.value.last_frame_call_count = d.value.frame_call_count; + d.value.last_frame_self_time = d.value.frame_self_time; + d.value.last_frame_total_time = d.value.frame_total_time; + d.value.frame_call_count = 0; + d.value.frame_self_time = 0; + d.value.frame_total_time = 0; } } #endif @@ -1651,8 +1651,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); NSL->_unload_stuff(true); - for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref gdn = L->get(); + for (KeyValue> &L : NSL->library_gdnatives) { + Ref gdn = L.value; if (gdn.is_null()) { continue; @@ -1685,8 +1685,8 @@ void NativeReloadNode::_notification(int p_what) { MutexLock lock(NSL->mutex); Set libs_to_remove; - for (Map>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { - Ref gdn = L->get(); + for (KeyValue> &L : NSL->library_gdnatives) { + Ref gdn = L.value; if (gdn.is_null()) { continue; @@ -1703,24 +1703,24 @@ void NativeReloadNode::_notification(int p_what) { } if (!gdn->initialize()) { - libs_to_remove.insert(L->key()); + libs_to_remove.insert(L.key); continue; } - NSL->library_classes.insert(L->key(), Map()); + NSL->library_classes.insert(L.key, Map()); // here the library registers all the classes and stuff. void *proc_ptr; Error err = gdn->get_symbol(gdn->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr); if (err != OK) { - ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data()); + ERR_PRINT(String("No godot_nativescript_init in \"" + L.key + "\" found").utf8().get_data()); } else { - ((void (*)(void *))proc_ptr)((void *)&L->key()); + ((void (*)(void *))proc_ptr)((void *)&L.key); } - for (Map>::Element *U = NSL->library_script_users.front(); U; U = U->next()) { - for (Set::Element *S = U->get().front(); S; S = S->next()) { + for (KeyValue> &U : NSL->library_script_users) { + for (Set::Element *S = U.value.front(); S; S = S->next()) { NativeScript *script = S->get(); if (script->placeholders.size() == 0) { diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index bc8801b8b9..2bae838543 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -122,8 +122,8 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco instance->owner_id = p_owner->get_instance_id(); #ifdef DEBUG_ENABLED //needed for hot reloading - for (Map::Element *E = member_indices.front(); E; E = E->next()) { - instance->member_indices_cache[E->key()] = E->get().index; + for (const KeyValue &E : member_indices) { + instance->member_indices_cache[E.key] = E.value.index; } #endif instance->owner->set_script_instance(instance); @@ -253,10 +253,10 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { void GDScript::_get_script_method_list(List *r_list, bool p_include_base) const { const GDScript *current = this; while (current) { - for (const Map::Element *E = current->member_functions.front(); E; E = E->next()) { - GDScriptFunction *func = E->get(); + for (const KeyValue &E : current->member_functions) { + GDScriptFunction *func = E.value; MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; for (int i = 0; i < func->get_argument_count(); i++) { PropertyInfo arginfo = func->get_argument_type(i); #ifdef TOOLS_ENABLED @@ -286,11 +286,11 @@ void GDScript::_get_script_property_list(List *r_list, bool p_incl while (sptr) { Vector<_GDScriptMemberSort> msort; - for (Map::Element *E = sptr->member_info.front(); E; E = E->next()) { + for (const KeyValue &E : sptr->member_info) { _GDScriptMemberSort ms; - ERR_CONTINUE(!sptr->member_indices.has(E->key())); - ms.index = sptr->member_indices[E->key()].index; - ms.name = E->key(); + ERR_CONTINUE(!sptr->member_indices.has(E.key)); + ms.index = sptr->member_indices[E.key].index; + ms.name = E.key; msort.push_back(ms); } @@ -412,8 +412,8 @@ void GDScript::_update_exports_values(Map &values, List_update_exports_values(values, propnames); } - for (Map::Element *E = member_default_values_cache.front(); E; E = E->next()) { - values[E->key()] = E->get(); + for (const KeyValue &E : member_default_values_cache) { + values[E.key] = E.value; } for (const PropertyInfo &E : members_cache) { @@ -471,9 +471,9 @@ void GDScript::_update_doc() { doc.description = doc_description; doc.tutorials = doc_tutorials; - for (Map::Element *E = doc_enums.front(); E; E = E->next()) { - if (E->value().description != "") { - doc.enums[E->key()] = E->value().description; + for (const KeyValue &E : doc_enums) { + if (E.value.description != "") { + doc.enums[E.key] = E.value.description; } } @@ -552,29 +552,29 @@ void GDScript::_update_doc() { doc.signals.push_back(signal_doc); } - for (Map::Element *E = constants.front(); E; E = E->next()) { - if (subclasses.has(E->key())) { + for (const KeyValue &E : constants) { + if (subclasses.has(E.key)) { continue; } // Enums. bool is_enum = false; - if (E->value().get_type() == Variant::DICTIONARY) { - if (doc_enums.has(E->key())) { + if (E.value.get_type() == Variant::DICTIONARY) { + if (doc_enums.has(E.key)) { is_enum = true; - for (int i = 0; i < doc_enums[E->key()].values.size(); i++) { - doc_enums[E->key()].values.write[i].enumeration = E->key(); - doc.constants.push_back(doc_enums[E->key()].values[i]); + for (int i = 0; i < doc_enums[E.key].values.size(); i++) { + doc_enums[E.key].values.write[i].enumeration = E.key; + doc.constants.push_back(doc_enums[E.key].values[i]); } } } if (!is_enum && doc_enums.has("@unnamed_enums")) { for (int i = 0; i < doc_enums["@unnamed_enums"].values.size(); i++) { - if (E->key() == doc_enums["@unnamed_enums"].values[i].name) { + if (E.key == doc_enums["@unnamed_enums"].values[i].name) { is_enum = true; DocData::ConstantDoc constant_doc; constant_doc.enumeration = "@unnamed_enums"; - DocData::constant_doc_from_variant(constant_doc, E->key(), E->value(), doc_enums["@unnamed_enums"].values[i].description); + DocData::constant_doc_from_variant(constant_doc, E.key, E.value, doc_enums["@unnamed_enums"].values[i].description); doc.constants.push_back(constant_doc); break; } @@ -583,16 +583,16 @@ void GDScript::_update_doc() { if (!is_enum) { DocData::ConstantDoc constant_doc; String doc_description; - if (doc_constants.has(E->key())) { - doc_description = doc_constants[E->key()]; + if (doc_constants.has(E.key)) { + doc_description = doc_constants[E.key]; } - DocData::constant_doc_from_variant(constant_doc, E->key(), E->value(), doc_description); + DocData::constant_doc_from_variant(constant_doc, E.key, E.value, doc_description); doc.constants.push_back(constant_doc); } } - for (Map>::Element *E = subclasses.front(); E; E = E->next()) { - E->get()->_update_doc(); + for (KeyValue> &E : subclasses) { + E.value->_update_doc(); } _add_doc(doc); @@ -784,8 +784,8 @@ void GDScript::update_exports() { void GDScript::_set_subclass_path(Ref &p_sc, const String &p_path) { p_sc->path = p_path; - for (Map>::Element *E = p_sc->subclasses.front(); E; E = E->next()) { - _set_subclass_path(E->get(), p_path); + for (KeyValue> &E : p_sc->subclasses) { + _set_subclass_path(E.value, p_path); } } @@ -886,8 +886,8 @@ Error GDScript::reload(bool p_keep_state) { valid = true; - for (Map>::Element *E = subclasses.front(); E; E = E->next()) { - _set_subclass_path(E->get(), path); + for (KeyValue> &E : subclasses) { + _set_subclass_path(E.value, path); } _init_rpc_methods_properties(); @@ -901,8 +901,8 @@ ScriptLanguage *GDScript::get_language() const { void GDScript::get_constants(Map *p_constants) { if (p_constants) { - for (Map::Element *E = constants.front(); E; E = E->next()) { - (*p_constants)[E->key()] = E->value(); + for (const KeyValue &E : constants) { + (*p_constants)[E.key] = E.value; } } } @@ -1032,9 +1032,9 @@ const Map &GDScript::debug_get_member_functions( } StringName GDScript::debug_get_member_by_index(int p_idx) const { - for (const Map::Element *E = member_indices.front(); E; E = E->next()) { - if (E->get().index == p_idx) { - return E->key(); + for (const KeyValue &E : member_indices) { + if (E.value.index == p_idx) { + return E.key; } } @@ -1079,12 +1079,12 @@ bool GDScript::has_script_signal(const StringName &p_signal) const { } void GDScript::_get_script_signal_list(List *r_list, bool p_include_base) const { - for (const Map>::Element *E = _signals.front(); E; E = E->next()) { + for (const KeyValue> &E : _signals) { MethodInfo mi; - mi.name = E->key(); - for (int i = 0; i < E->get().size(); i++) { + mi.name = E.key; + for (int i = 0; i < E.value.size(); i++) { PropertyInfo arg; - arg.name = E->get()[i]; + arg.name = E.value[i]; mi.arguments.push_back(arg); } r_list->push_back(mi); @@ -1142,11 +1142,11 @@ void GDScript::_save_orphaned_subclasses() { }; Vector weak_subclasses; // collect subclasses ObjectID and name - for (Map>::Element *E = subclasses.front(); E; E = E->next()) { - E->get()->_owner = nullptr; //bye, you are no longer owned cause I died + for (KeyValue> &E : subclasses) { + E.value->_owner = nullptr; //bye, you are no longer owned cause I died ClassRefWithName subclass; - subclass.id = E->get()->get_instance_id(); - subclass.fully_qualified_name = E->get()->fully_qualified_name; + subclass.id = E.value->get_instance_id(); + subclass.fully_qualified_name = E.value->fully_qualified_name; weak_subclasses.push_back(subclass); } @@ -1178,10 +1178,10 @@ void GDScript::_init_rpc_methods_properties() { Map>::Element *sub_E = subclasses.front(); while (cscript) { // RPC Methods - for (Map::Element *E = cscript->member_functions.front(); E; E = E->next()) { - Multiplayer::RPCConfig config = E->get()->get_rpc_config(); + for (KeyValue &E : cscript->member_functions) { + Multiplayer::RPCConfig config = E.value->get_rpc_config(); if (config.rpc_mode != Multiplayer::RPC_MODE_DISABLED) { - config.name = E->get()->get_name(); + config.name = E.value->get_name(); if (rpc_functions.find(config) == -1) { rpc_functions.push_back(config); } @@ -1215,8 +1215,8 @@ GDScript::~GDScript() { } } - for (Map::Element *E = member_functions.front(); E; E = E->next()) { - memdelete(E->get()); + for (const KeyValue &E : member_functions) { + memdelete(E.value); } if (GDScriptCache::singleton) { // Cache may have been already destroyed at engine shutdown. @@ -1442,11 +1442,11 @@ void GDScriptInstance::get_property_list(List *p_properties) const //instance a fake script for editing the values Vector<_GDScriptMemberSort> msort; - for (Map::Element *F = sptr->member_info.front(); F; F = F->next()) { + for (const KeyValue &F : sptr->member_info) { _GDScriptMemberSort ms; - ERR_CONTINUE(!sptr->member_indices.has(F->key())); - ms.index = sptr->member_indices[F->key()].index; - ms.name = F->key(); + ERR_CONTINUE(!sptr->member_indices.has(F.key)); + ms.index = sptr->member_indices[F.key].index; + ms.name = F.key; msort.push_back(ms); } @@ -1467,11 +1467,11 @@ void GDScriptInstance::get_property_list(List *p_properties) const void GDScriptInstance::get_method_list(List *p_list) const { const GDScript *sptr = script.ptr(); while (sptr) { - for (Map::Element *E = sptr->member_functions.front(); E; E = E->next()) { + for (const KeyValue &E : sptr->member_functions) { MethodInfo mi; - mi.name = E->key(); + mi.name = E.key; mi.flags |= METHOD_FLAG_FROM_SCRIPT; - for (int i = 0; i < E->get()->get_argument_count(); i++) { + for (int i = 0; i < E.value->get_argument_count(); i++) { mi.arguments.push_back(PropertyInfo(Variant::NIL, "arg" + itos(i))); } p_list->push_back(mi); @@ -1569,10 +1569,10 @@ void GDScriptInstance::reload_members() { new_members.resize(script->member_indices.size()); //pass the values to the new indices - for (Map::Element *E = script->member_indices.front(); E; E = E->next()) { - if (member_indices_cache.has(E->key())) { - Variant value = members[member_indices_cache[E->key()]]; - new_members.write[E->get().index] = value; + for (KeyValue &E : script->member_indices) { + if (member_indices_cache.has(E.key)) { + Variant value = members[member_indices_cache[E.key]]; + new_members.write[E.value.index] = value; } } @@ -1581,8 +1581,8 @@ void GDScriptInstance::reload_members() { //pass the values to the new indices member_indices_cache.clear(); - for (Map::Element *E = script->member_indices.front(); E; E = E->next()) { - member_indices_cache[E->key()] = E->get().index; + for (const KeyValue &E : script->member_indices) { + member_indices_cache[E.key] = E.value.index; } #endif @@ -1890,21 +1890,21 @@ void GDScriptLanguage::reload_tool_script(const Ref