/**************************************************************************/ /* snapshot_data.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "snapshot_data.h" #include "core/core_bind.h" #include "core/io/compression.h" #include "core/object/script_language.h" #include "scene/debugger/scene_debugger.h" #if defined(MODULE_GDSCRIPT_ENABLED) && defined(DEBUG_ENABLED) #include "modules/gdscript/gdscript.h" #endif SnapshotDataObject::SnapshotDataObject(SceneDebuggerObject &p_obj, GameStateSnapshot *p_snapshot, ResourceCache &resource_cache) : snapshot(p_snapshot) { remote_object_id = p_obj.id; type_name = p_obj.class_name; for (const SceneDebuggerObject::SceneDebuggerProperty &prop : p_obj.properties) { PropertyInfo pinfo = prop.first; Variant pvalue = prop.second; if (pinfo.type == Variant::OBJECT && pvalue.is_string()) { String path = pvalue; // If a resource is followed by a ::, it is a nested resource (like a sub_resource in a .tscn file). // To get a reference to it, first we load the parent resource (the .tscn, for example), then, // we load the child resource. The parent resource (dependency) should not be destroyed before the child // resource (pvalue) is loaded. if (path.is_resource_file()) { // Built-in resource. String base_path = path.get_slice("::", 0); if (!resource_cache.cache.has(base_path)) { resource_cache.cache[base_path] = ResourceLoader::load(base_path); resource_cache.misses++; } else { resource_cache.hits++; } } if (!resource_cache.cache.has(path)) { resource_cache.cache[path] = ResourceLoader::load(path); resource_cache.misses++; } else { resource_cache.hits++; } pvalue = resource_cache.cache[path]; if (pinfo.hint_string == "Script") { if (get_script() != pvalue) { set_script(Ref()); Ref