diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/array.cpp | 4 | ||||
-rw-r--r-- | core/array.h | 2 | ||||
-rw-r--r-- | core/dictionary.cpp | 4 | ||||
-rw-r--r-- | core/dictionary.h | 2 | ||||
-rw-r--r-- | core/error_macros.h | 6 | ||||
-rw-r--r-- | core/image.cpp | 12 | ||||
-rw-r--r-- | core/io/compression.cpp | 6 | ||||
-rw-r--r-- | core/io/multiplayer_api.cpp | 13 | ||||
-rw-r--r-- | core/io/resource_importer.cpp | 11 | ||||
-rw-r--r-- | core/io/resource_importer.h | 5 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 24 | ||||
-rw-r--r-- | core/io/resource_loader.h | 2 | ||||
-rw-r--r-- | core/list.h | 4 | ||||
-rw-r--r-- | core/math/transform_2d.cpp | 2 | ||||
-rw-r--r-- | core/math/transform_2d.h | 2 | ||||
-rw-r--r-- | core/math/vector2.h | 1 | ||||
-rw-r--r-- | core/object.cpp | 5 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/ordered_hash_map.h | 4 | ||||
-rw-r--r-- | core/reference.h | 13 | ||||
-rw-r--r-- | core/string_builder.h | 4 | ||||
-rw-r--r-- | core/variant.cpp | 27 | ||||
-rw-r--r-- | core/variant.h | 1 |
23 files changed, 136 insertions, 19 deletions
diff --git a/core/array.cpp b/core/array.cpp index 649e610a69..65934d6ec9 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -401,6 +401,10 @@ Variant Array::max() const { return maxval; } +const void *Array::id() const { + return _p->array.ptr(); +} + Array::Array(const Array &p_from) { _p = NULL; diff --git a/core/array.h b/core/array.h index 6158db4065..d4e937a486 100644 --- a/core/array.h +++ b/core/array.h @@ -94,6 +94,8 @@ public: Variant min() const; Variant max() const; + const void *id() const; + Array(const Array &p_from); Array(); ~Array(); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index bea0997cc9..5e4dfb9a5a 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -270,6 +270,10 @@ void Dictionary::operator=(const Dictionary &p_dictionary) { _ref(p_dictionary); } +const void *Dictionary::id() const { + return _p->variant_map.id(); +} + Dictionary::Dictionary(const Dictionary &p_from) { _p = NULL; _ref(p_from); diff --git a/core/dictionary.h b/core/dictionary.h index eab7354cef..b68d3f5737 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -82,6 +82,8 @@ public: Dictionary duplicate(bool p_deep = false) const; + const void *id() const; + Dictionary(const Dictionary &p_from); Dictionary(); ~Dictionary(); diff --git a/core/error_macros.h b/core/error_macros.h index ca5ccd24cf..78e29551d4 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -86,7 +86,7 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li #define _FNL __FILE__ ":" -/** An index has failed if m_index<0 or m_index >=m_size, the function exists */ +/** An index has failed if m_index<0 or m_index >=m_size, the function exits */ extern bool _err_error_exists; @@ -140,7 +140,7 @@ extern bool _err_error_exists; _err_error_exists = false; \ } while (0); // (*) -/** An index has failed if m_index<0 or m_index >=m_size, the function exists. +/** An index has failed if m_index<0 or m_index >=m_size, the function exits. * This function returns an error value, if returning Error, please select the most * appropriate error condition from error_macros.h */ @@ -154,7 +154,7 @@ extern bool _err_error_exists; _err_error_exists = false; \ } while (0); // (*) -/** An index has failed if m_index >=m_size, the function exists. +/** An index has failed if m_index >=m_size, the function exits. * This function returns an error value, if returning Error, please select the most * appropriate error condition from error_macros.h */ diff --git a/core/image.cpp b/core/image.cpp index 90afd9f35a..99d5eab864 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1876,7 +1876,7 @@ Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const P Rect2 Image::get_used_rect() const { - if (format != FORMAT_LA8 && format != FORMAT_RGBA8) + if (format != FORMAT_LA8 && format != FORMAT_RGBA8 && format != FORMAT_RGBAF && format != FORMAT_RGBAH && format != FORMAT_RGBA4444 && format != FORMAT_RGBA5551) return Rect2(Point2(), Size2(width, height)); int len = data.size(); @@ -1884,17 +1884,13 @@ Rect2 Image::get_used_rect() const { if (len == 0) return Rect2(); - //int data_size = len; - PoolVector<uint8_t>::Read r = data.read(); - const unsigned char *rptr = r.ptr(); - - int ps = format == FORMAT_LA8 ? 2 : 4; + const_cast<Image *>(this)->lock(); int minx = 0xFFFFFF, miny = 0xFFFFFFF; int maxx = -1, maxy = -1; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { - bool opaque = rptr[(j * width + i) * ps + (ps - 1)] > 2; + bool opaque = get_pixel(i, j).a > 0.99; if (!opaque) continue; if (i > maxx) @@ -1908,6 +1904,8 @@ Rect2 Image::get_used_rect() const { } } + const_cast<Image *>(this)->unlock(); + if (maxx == -1) return Rect2(); else diff --git a/core/io/compression.cpp b/core/io/compression.cpp index a113f3b61b..b51e50150e 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -175,7 +175,9 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p } break; case MODE_ZSTD: { ZSTD_DCtx *dctx = ZSTD_createDCtx(); - if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, (size_t)1 << zstd_window_log_size); + if (zstd_long_distance_matching) { + ZSTD_DCtx_setParameter(dctx, ZSTD_d_windowLogMax, zstd_window_log_size); + } int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size); ZSTD_freeDCtx(dctx); return ret; @@ -189,4 +191,4 @@ int Compression::zlib_level = Z_DEFAULT_COMPRESSION; int Compression::gzip_level = Z_DEFAULT_COMPRESSION; int Compression::zstd_level = 3; bool Compression::zstd_long_distance_matching = false; -int Compression::zstd_window_log_size = 27; +int Compression::zstd_window_log_size = 27; // ZSTD_WINDOWLOG_LIMIT_DEFAULT diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 86382939f1..2e76ce68ed 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -659,8 +659,11 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const } if (call_local_native) { + int temp_id = rpc_sender_id; + rpc_sender_id = get_network_unique_id(); Variant::CallError ce; p_node->call(p_method, p_arg, p_argcount, ce); + rpc_sender_id = temp_id; if (ce.error != Variant::CallError::CALL_OK) { String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce); error = "rpc() aborted in local call: - " + error; @@ -670,9 +673,12 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const } if (call_local_script) { + int temp_id = rpc_sender_id; + rpc_sender_id = get_network_unique_id(); Variant::CallError ce; ce.error = Variant::CallError::CALL_OK; p_node->get_script_instance()->call(p_method, p_arg, p_argcount, ce); + rpc_sender_id = temp_id; if (ce.error != Variant::CallError::CALL_OK) { String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce); error = "rpc() aborted in script local call: - " + error; @@ -708,7 +714,11 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const if (set_local) { bool valid; + int temp_id = rpc_sender_id; + + rpc_sender_id = get_network_unique_id(); p_node->set(p_property, p_value, &valid); + rpc_sender_id = temp_id; if (!valid) { String error = "rset() aborted in local set, property not found: - " + String(p_property); @@ -722,8 +732,11 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const set_local = _should_call_local(rpc_mode, is_master, skip_rset); if (set_local) { + int temp_id = rpc_sender_id; + rpc_sender_id = get_network_unique_id(); bool valid = p_node->get_script_instance()->set(p_property, p_value); + rpc_sender_id = temp_id; if (!valid) { String error = "rset() aborted in local script set, property not found: - " + String(p_property); diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index b5fa412576..038a34ed51 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -94,6 +94,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy r_path_and_type.type = value; } else if (assign == "importer") { r_path_and_type.importer = value; + } else if (assign == "group_file") { + r_path_and_type.group_file = value; } else if (assign == "metadata") { r_path_and_type.metadata = value; } else if (assign == "valid") { @@ -294,6 +296,15 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat memdelete(f); } +String ResourceFormatImporter::get_import_group_file(const String &p_path) const { + + bool valid = true; + PathAndType pat; + _get_path_and_type(p_path, pat, &valid); + return valid?pat.group_file:String(); + +} + bool ResourceFormatImporter::is_import_valid(const String &p_path) const { bool valid = true; diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 1c146c33d7..bdbdde6df6 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -43,6 +43,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { String path; String type; String importer; + String group_file; Variant metadata; }; @@ -69,6 +70,7 @@ public: virtual bool is_import_valid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual bool is_imported(const String &p_path) const { return recognize_path(p_path); } + virtual String get_import_group_file(const String &p_path) const; virtual bool exists(const String &p_path) const; virtual bool can_be_imported(const String &p_path) const; @@ -120,8 +122,11 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const = 0; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const = 0; + virtual String get_option_group_file() const { return String(); } virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL) = 0; + + virtual Error import_group_file(const String& p_group_file,const Map<String,Map<StringName, Variant> >&p_source_file_options, const Map<String,String>& p_base_paths) { return ERR_UNAVAILABLE; } virtual bool are_import_settings_valid(const String &p_path) const { return true; } virtual String get_import_settings_string() const { return String(); } }; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index e4b694b64f..56d3b8b133 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -608,6 +608,30 @@ int ResourceLoader::get_import_order(const String &p_path) { return 0; } +String ResourceLoader::get_import_group_file(const String &p_path) { + String path = _path_remap(p_path); + + String local_path; + if (path.is_rel_path()) + local_path = "res://" + path; + else + local_path = ProjectSettings::get_singleton()->localize_path(path); + + for (int i = 0; i < loader_count; i++) { + + if (!loader[i]->recognize_path(local_path)) + continue; + /* + if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + continue; + */ + + return loader[i]->get_import_group_file(p_path); + } + + return String(); //not found +} + bool ResourceLoader::is_import_valid(const String &p_path) { String path = _path_remap(p_path); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index ca7610a0d2..9e7020be7c 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -81,6 +81,7 @@ public: virtual bool is_import_valid(const String &p_path) const { return true; } virtual bool is_imported(const String &p_path) const { return false; } virtual int get_import_order(const String &p_path) const { return 0; } + virtual String get_import_group_file(const String &p_path) const { return ""; } //no group virtual ~ResourceFormatLoader() {} }; @@ -155,6 +156,7 @@ public: static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); static bool is_import_valid(const String &p_path); + static String get_import_group_file(const String &p_path); static bool is_imported(const String &p_path); static int get_import_order(const String &p_path); diff --git a/core/list.h b/core/list.h index c26aad6463..c21c20ba34 100644 --- a/core/list.h +++ b/core/list.h @@ -691,6 +691,10 @@ public: memdelete_arr(aux_buffer); } + const void *id() const { + return (void *)_data; + } + /** * copy constructor for the list */ diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 7d00158f3d..1d0387bd45 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -106,7 +106,7 @@ Size2 Transform2D::get_scale() const { return Size2(elements[0].length(), det_sign * elements[1].length()); } -void Transform2D::set_scale(Size2 &p_scale) { +void Transform2D::set_scale(const Size2 &p_scale) { elements[0].normalize(); elements[1].normalize(); elements[0] *= p_scale.x; diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h index b9e7a36fb3..c44678674a 100644 --- a/core/math/transform_2d.h +++ b/core/math/transform_2d.h @@ -81,7 +81,7 @@ struct Transform2D { real_t basis_determinant() const; Size2 get_scale() const; - void set_scale(Size2 &p_scale); + void set_scale(const Size2 &p_scale); _FORCE_INLINE_ const Vector2 &get_origin() const { return elements[2]; } _FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { elements[2] = p_origin; } diff --git a/core/math/vector2.h b/core/math/vector2.h index ae2d1ec660..9a214ef9b5 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -99,6 +99,7 @@ struct Vector2 { Vector2 operator/(const real_t &rvalue) const; void operator/=(const real_t &rvalue); + void operator/=(const Vector2 &rvalue) { *this = *this / rvalue; } Vector2 operator-() const; diff --git a/core/object.cpp b/core/object.cpp index 03a11b8ca3..039f556c87 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1366,7 +1366,10 @@ Array Object::_get_incoming_connections() const { void Object::get_signal_list(List<MethodInfo> *p_signals) const { if (!script.is_null()) { - Ref<Script>(script)->get_script_signal_list(p_signals); + Ref<Script> scr = script; + if (scr.is_valid()) { + scr->get_script_signal_list(p_signals); + } } ClassDB::get_signal_list(get_class_name(), p_signals); diff --git a/core/object.h b/core/object.h index e8a6178052..3730af1ad4 100644 --- a/core/object.h +++ b/core/object.h @@ -88,6 +88,7 @@ enum PropertyHint { PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send PROPERTY_HINT_NODE_PATH_VALID_TYPES, + PROPERTY_HINT_SAVE_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,". This opens a save dialog PROPERTY_HINT_MAX, // When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit }; diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h index 09d43d6797..2c18de92be 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -274,6 +274,10 @@ public: inline bool empty() const { return list.empty(); } inline int size() const { return list.size(); } + const void *id() const { + return list.id(); + } + void clear() { map.clear(); list.clear(); diff --git a/core/reference.h b/core/reference.h index f3fcc922c7..9105dbbd58 100644 --- a/core/reference.h +++ b/core/reference.h @@ -197,6 +197,19 @@ public: r.reference = NULL; } + template <class T_Other> + void reference_ptr(T_Other *p_ptr) { + if (reference == p_ptr) { + return; + } + unref(); + + T *r = Object::cast_to<T>(p_ptr); + if (r) { + ref_pointer(r); + } + } + Ref(const Ref &p_from) { reference = NULL; diff --git a/core/string_builder.h b/core/string_builder.h index 40d70e8f45..0c4985d230 100644 --- a/core/string_builder.h +++ b/core/string_builder.h @@ -70,6 +70,10 @@ public: return appended_strings.size(); } + _FORCE_INLINE_ uint32_t get_string_length() const { + return string_length; + } + String as_string() const; _FORCE_INLINE_ operator String() const { diff --git a/core/variant.cpp b/core/variant.cpp index 6c54faf233..1bc3cff505 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1415,7 +1415,12 @@ struct _VariantStrPair { }; Variant::operator String() const { + List<const void *> stack; + return stringify(stack); +} + +String Variant::stringify(List<const void *> &stack) const { switch (type) { case NIL: return "Null"; @@ -1467,6 +1472,12 @@ Variant::operator String() const { case DICTIONARY: { const Dictionary &d = *reinterpret_cast<const Dictionary *>(_data._mem); + if (stack.find(d.id())) { + return "{...}"; + } + + stack.push_back(d.id()); + //const String *K=NULL; String str("{"); List<Variant> keys; @@ -1477,8 +1488,9 @@ Variant::operator String() const { for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { _VariantStrPair sp; - sp.key = String(E->get()); - sp.value = d[E->get()]; + sp.key = E->get().stringify(stack); + sp.value = d[E->get()].stringify(stack); + pairs.push_back(sp); } @@ -1561,12 +1573,19 @@ Variant::operator String() const { case ARRAY: { Array arr = operator Array(); + if (stack.find(arr.id())) { + return "[...]"; + } + stack.push_back(arr.id()); + String str("["); for (int i = 0; i < arr.size(); i++) { if (i) str += ", "; - str += String(arr[i]); - }; + + str += arr[i].stringify(stack); + } + str += "]"; return str; diff --git a/core/variant.h b/core/variant.h index 9215d15bf0..5151262f27 100644 --- a/core/variant.h +++ b/core/variant.h @@ -401,6 +401,7 @@ public: bool hash_compare(const Variant &p_variant) const; bool booleanize() const; + String stringify(List<const void *> &stack) const; void static_assign(const Variant &p_variant); static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list); |