behaviour-tree-test/core
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
..
config Merge pull request #103944 from KoBeWi/more_red_info 2025-05-08 07:19:33 -05:00
crypto CryptoCore: Use size_t for buffer sizes to fix encoding/sums of 2.0+ GiB files. 2025-04-03 11:29:59 +02:00
debugger Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
error Remove pointless use of atomics in error macros 2025-05-12 17:06:19 +02:00
extension Typed array equality operator logic updated 2025-05-13 14:41:16 -05:00
input Merge pull request #106021 from Alex2782/fix_xbox_controller_on_android 2025-05-16 07:43:09 -05:00
io Overhaul Variant::duplicate() for resources 2025-05-26 10:06:40 +02:00
math Core: Convert Pair/KeyValue to constexpr 2025-05-15 10:37:41 -05:00
object Merge pull request #96611 from Dynamic-Pistol/master 2025-05-13 16:22:25 -05:00
os Core: Convert Pair/KeyValue to constexpr 2025-05-15 10:37:41 -05:00
string Merge pull request #106295 from timothyqiu/legacy-l10n 2025-05-13 01:05:31 +02:00
templates Core: Convert Pair/KeyValue to constexpr 2025-05-15 10:37:41 -05:00
variant Overhaul Variant::duplicate() for resources 2025-05-26 10:06:40 +02:00
core_bind.compat.inc Style: Convert namespaces to PascalCase 2025-03-23 19:10:24 -05:00
core_bind.cpp Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
core_bind.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
core_builders.py SCons: Begin decoupling generation & build code 2025-04-25 08:23:01 -05:00
core_constants.cpp Add PROPERTY_HINT_INPUT_NAME 2025-04-23 22:23:44 +02:00
core_constants.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
core_globals.h Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
core_string_names.h Always use String as StringName backing internally. 2025-04-23 14:57:03 +02:00
doc_data.cpp Add String::replace_char(s) methods for performance and convenience 2025-04-10 13:08:45 +02:00
doc_data.h Do not iterate Dictionary with get_key_at_index. 2025-04-07 21:54:13 +08:00
register_core_types.cpp Remove registration of deprecated classes 2025-05-05 20:16:50 +02:00
register_core_types.h Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
SCsub SCons: Begin decoupling generation & build code 2025-04-25 08:23:01 -05:00
typedefs.h Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00
version.h Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00