summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2021-07-10 21:17:41 +0200
committerkobewi <kobewi4e@gmail.com>2021-11-04 12:45:58 +0100
commite393c2a7348d96587e15af17c72ebeff719d4be3 (patch)
treea31a5913139f9e56d3324452dc908ab96a4f7967 /core
parent78931aa040bb0d0586345f95cc982605c0720ba1 (diff)
Add is_built_in() method to Resource
Diffstat (limited to 'core')
-rw-r--r--core/io/resource.h1
-rw-r--r--core/io/resource_format_binary.cpp8
-rw-r--r--core/object/object.cpp2
3 files changed, 6 insertions, 5 deletions
diff --git a/core/io/resource.h b/core/io/resource.h
index 9ccc247887..109c0f6611 100644
--- a/core/io/resource.h
+++ b/core/io/resource.h
@@ -103,6 +103,7 @@ public:
virtual void set_path(const String &p_path, bool p_take_over = false);
String get_path() const;
+ _FORCE_INLINE_ bool is_built_in() const { return path_cache.is_empty() || path_cache.find("::") != -1 || path_cache.begins_with("local://"); }
static String generate_scene_unique_id();
void set_scene_unique_id(const String &p_id);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index cbb033f6c6..a5a195f859 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1572,7 +1572,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia
return; // don't save it
}
- if (res->get_path().length() && res->get_path().find("::") == -1) {
+ if (!res->is_built_in()) {
f->store_32(OBJECT_EXTERNAL_RESOURCE_INDEX);
f->store_32(external_resources[res]);
} else {
@@ -1743,7 +1743,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
return;
}
- if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) {
+ if (!p_main && (!bundle_resources) && !res->is_built_in()) {
if (res->get_path() == path) {
ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded.");
return;
@@ -1978,7 +1978,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Set<String> used_unique_ids;
for (RES &r : saved_resources) {
- if (r->get_path() == "" || r->get_path().find("::") != -1) {
+ if (r->is_built_in()) {
if (r->get_scene_unique_id() != "") {
if (used_unique_ids.has(r->get_scene_unique_id())) {
r->set_scene_unique_id("");
@@ -1992,7 +1992,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Map<RES, int> resource_map;
int res_index = 0;
for (RES &r : saved_resources) {
- if (r->get_path() == "" || r->get_path().find("::") != -1) {
+ if (r->is_built_in()) {
if (r->get_scene_unique_id() == "") {
String new_id;
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 476fdec1f7..498f116997 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -1475,7 +1475,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
return;
}
- if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1) {
+ if (!r->is_built_in()) {
return; //not an internal resource
}