behaviour-tree-test/core/io
Pedro J. Estébanez 342266cfd9 Overhaul Variant::duplicate() for resources
This in the scope of a duplication triggered via any type in the `Variant` realm. that is, the following: `Variant` itself, `Array` and `Dictionary`. That includes invoking `duplicate()` from scripts.

A `duplicate_deep(deep_subresources_mode)` method is added to `Variant`, `Array` and `Dictionary` (for compatibility reasons, simply adding an extra parameter was not possible). The default value for it is `RESOURCE_DEEP_DUPLICATE_NONE`, which is like calling `duplicate(true)`.

Remarks:
- The results of copying resources via those `Variant` types are exactly the same as if the copy were initiated from the `Resource` type at C++.
- In order to keep some separation between `Variant` and the higher-level animal which is `Resource`, `Variant` still contains the original code for that, so it's self-sufficient unless there's a `Resource` involved. Once the deep copy finds a `Resource` that has to be copied according to the duplication parameters, the algorithm invokes the `Resource` duplication machinery. When the stack is unwind back to a nesting level `Variant` can handle, `Variant` duplication logic keeps functioning.

While that is good from a responsibility separation standpoint, that would have a caveat: `Variant` would not be aware of the mapping between original and duplicate subresources and so wouldn't be able to keep preventing multiple duplicates.

To avoid that, this commit also introduces a wormwhole, a sharing mechanism by which `Variant` and `Resource` can collaborate in managing the lifetime of the original-to-duplicates map. The user-visible benefit is that the overduplicate prevention works as broadly as the whole `Variant` entity being copied, including all nesting levels, regardless how disconnected the data members containing resources may be across al the nesting levels. In other words, despite the aforementioned division of duties between `Variant` and `Resource` duplication logic, the duplicates map is shared among them. It's created when first finding a `Resource` and, however how deep the copy was working at that point, the map kept alive unitl the stack is unwind to the root user call, until the first step of the recursion.

Thanks to that common map of duplicates, this commit is able to fix the issue that `Resource::duplicate_for_local_scene()` used to ignore overridden duplicate logic.
2025-05-26 10:06:40 +02:00
..
compression.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
compression.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
config_file.cpp Improve ConfigFile get_sections and get_section_keys by returning Vector<String> 2025-04-24 20:10:31 -04:00
config_file.h Improve ConfigFile get_sections and get_section_keys by returning Vector<String> 2025-04-24 20:10:31 -04:00
dir_access.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
dir_access.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
dtls_server.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
dtls_server.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access.compat.inc [FileAccess] Return error codes from store_* methods. 2024-11-29 23:22:31 +02:00
file_access.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access_compressed.cpp Fix FileAccessCompressed claiming one byte more than it actually has. 2025-04-08 15:19:58 +02:00
file_access_compressed.h add GDSOFTCLASS to FileAccess and DirAccess derived classes 2025-04-09 11:52:50 -07:00
file_access_encrypted.cpp Merge pull request #103415 from bruvzg/iv_pools 2025-03-19 12:26:38 +01:00
file_access_encrypted.h add GDSOFTCLASS to FileAccess and DirAccess derived classes 2025-04-09 11:52:50 -07:00
file_access_memory.cpp Merge pull request #100564 from YYF233333/iwyu 2024-12-19 19:59:55 -06:00
file_access_memory.h add GDSOFTCLASS to FileAccess and DirAccess derived classes 2025-04-09 11:52:50 -07:00
file_access_pack.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access_pack.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access_zip.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
file_access_zip.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
http_client.cpp Do not use Dictionary::keys() for Dictionary iteration. 2025-04-05 18:42:13 +08:00
http_client.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
http_client_tcp.cpp Replace append_utfx with direct String::utfx 2025-03-30 19:56:38 +02:00
http_client_tcp.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
image.cpp Overhaul Resource::duplicate() 2025-05-26 10:05:25 +02:00
image.h Overhaul Resource::duplicate() 2025-05-26 10:05:25 +02:00
image_loader.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
image_loader.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
ip.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
ip.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
ip_address.cpp Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00
ip_address.h Core: Add [[nodiscard]] to string-like classes 2025-05-06 12:23:41 -05:00
json.cpp Improve JSON::stringify performance 2025-05-06 18:27:32 -04:00
json.h Improve JSON::stringify performance 2025-05-06 18:27:32 -04:00
logger.cpp Fix empty lines being added for errors with no script backtrace 2025-05-05 13:27:21 +02:00
logger.h Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00
marshalls.cpp Fix for debugging typed dictionaries 2025-05-08 21:11:23 +10:00
marshalls.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
missing_resource.cpp Fix missing resource properties being dropped on save 2024-11-05 11:53:29 -06:00
missing_resource.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
net_socket.cpp One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
net_socket.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
packed_data_container.cpp Add ConstIterator to Dictionary. 2025-03-13 01:28:46 +08:00
packed_data_container.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
packet_peer.cpp Style: Add WARNING: as new comment admonition 2024-09-25 09:44:42 -05:00
packet_peer.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
packet_peer_dtls.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
packet_peer_dtls.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
packet_peer_udp.cpp Core: Integrate warning suppression macro helpers 2025-04-03 10:13:46 -05:00
packet_peer_udp.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
pck_packer.cpp Use resize_zeroed instead of resize then fill(0) in several places. 2025-03-14 12:09:39 +01:00
pck_packer.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
plist.cpp Core: Replace C math headers with C++ equivalents 2025-04-16 15:49:02 -05:00
plist.h Add and require GDSOFTCLASS for Object subclasses that want to cast but do not use GDCLASS. 2025-03-31 20:49:50 +02:00
remote_filesystem_client.cpp Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers 2024-12-23 11:14:58 -06:00
remote_filesystem_client.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
resource.cpp Overhaul Variant::duplicate() for resources 2025-05-26 10:06:40 +02:00
resource.h Overhaul Variant::duplicate() for resources 2025-05-26 10:06:40 +02:00
resource_format_binary.cpp Core: Add [[nodiscard]] to string-like classes 2025-05-06 12:23:41 -05:00
resource_format_binary.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
resource_importer.cpp Continue checking for a texture decompression path even if end of import file is not reached 2025-05-05 00:19:32 -07:00
resource_importer.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
resource_loader.cpp Remove old path remaps system 2025-04-23 15:48:33 +02:00
resource_loader.h Remove old path remaps system 2025-04-23 15:48:33 +02:00
resource_saver.cpp [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
resource_saver.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
resource_uid.cpp mbedTLS: Fix concurrency issues with TLS 2025-05-08 11:45:00 +02:00
resource_uid.h Add create_id_for_path() to ResourceUID 2025-04-11 00:53:34 +02:00
SCsub SCons: Add unobtrusive type hints in SCons files 2024-09-25 09:34:35 -05:00
stream_peer.cpp Remove misleading and incorrect notes about endianness. Fix FileAccess and StreamPeer not doing what name suggests. 2025-04-09 11:01:25 +03:00
stream_peer.h Remove misleading and incorrect notes about endianness. Fix FileAccess and StreamPeer not doing what name suggests. 2025-04-09 11:01:25 +03:00
stream_peer_gzip.cpp Fix StreamPeerGZIP::finish() internal buffer size usage 2025-03-19 09:56:32 +01:00
stream_peer_gzip.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
stream_peer_tcp.cpp [Core,Drivers] Improve use of Ref.is_null/valid 2024-11-01 16:50:11 +01:00
stream_peer_tcp.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
stream_peer_tls.cpp Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
stream_peer_tls.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
tcp_server.cpp Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers 2024-12-23 11:14:58 -06:00
tcp_server.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
translation_loader_po.cpp Use append_ instead of parse_ for String methods. 2025-03-27 17:51:02 +01:00
translation_loader_po.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
udp_server.cpp [Core,Drivers] Improve use of Ref.is_null/valid 2024-11-01 16:50:11 +01:00
udp_server.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
xml_parser.cpp Use append_ instead of parse_ for String methods. 2025-03-27 17:51:02 +01:00
xml_parser.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
zip_io.cpp Replace append_utfx with direct String::utfx 2025-03-30 19:56:38 +02:00
zip_io.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00