diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/engine.cpp | 7 | ||||
-rw-r--r-- | core/config/project_settings.cpp | 4 | ||||
-rw-r--r-- | core/core_bind.cpp | 4 | ||||
-rw-r--r-- | core/debugger/engine_debugger.h | 2 | ||||
-rw-r--r-- | core/io/dir_access.h | 4 | ||||
-rw-r--r-- | core/io/file_access.h | 4 | ||||
-rw-r--r-- | core/io/ip.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.h | 2 | ||||
-rw-r--r-- | core/math/basis.h | 2 | ||||
-rw-r--r-- | core/math/geometry_2d.cpp | 2 | ||||
-rw-r--r-- | core/math/plane.h | 2 | ||||
-rw-r--r-- | core/object/method_bind.h | 2 | ||||
-rw-r--r-- | core/object/object.h | 24 | ||||
-rw-r--r-- | core/object/script_language.h | 4 | ||||
-rw-r--r-- | core/os/os.h | 8 | ||||
-rw-r--r-- | core/string/translation_domain.cpp | 2 | ||||
-rw-r--r-- | core/string/ustring.cpp | 13 | ||||
-rw-r--r-- | core/string/ustring.h | 4 | ||||
-rw-r--r-- | core/templates/cowdata.h | 2 | ||||
-rw-r--r-- | core/templates/lru.h | 52 | ||||
-rw-r--r-- | core/templates/rb_set.h | 2 | ||||
-rw-r--r-- | core/typedefs.h | 2 |
22 files changed, 107 insertions, 43 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 124b5990a5..2735a1aa67 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -39,7 +39,7 @@ #include "core/redot_authors.gen.h" #include "core/variant/typed_array.h" #include "core/version.h" -#include "core/version_generated.gen.h" +#include "servers/rendering/rendering_device.h" void Engine::set_physics_ticks_per_second(int p_ips) { ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0."); @@ -72,6 +72,11 @@ double Engine::get_physics_jitter_fix() const { void Engine::set_max_fps(int p_fps) { _max_fps = p_fps > 0 ? p_fps : 0; + + RenderingDevice *rd = RenderingDevice::get_singleton(); + if (rd) { + rd->_set_max_fps(_max_fps); + } } int Engine::get_max_fps() const { diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 6ac61ecbee..5ac7f05a76 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1505,6 +1505,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("display/window/subwindows/embed_subwindows", true); // Keep the enum values in sync with the `DisplayServer::VSyncMode` enum. custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::INT, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox"); + + GLOBAL_DEF("display/window/frame_pacing/android/enable_frame_pacing", true); + GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/frame_pacing/android/swappy_mode", PROPERTY_HINT_ENUM, "pipeline_forced_on,auto_fps_pipeline_forced_on,auto_fps_auto_pipeline"), 2); + custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); GLOBAL_DEF("physics/2d/run_on_separate_thread", false); GLOBAL_DEF("physics/3d/run_on_separate_thread", false); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 818185f131..16467c9615 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -470,11 +470,11 @@ Error OS::set_thread_name(const String &p_name) { ::Thread::ID OS::get_thread_caller_id() const { return ::Thread::get_caller_id(); -}; +} ::Thread::ID OS::get_main_thread_id() const { return ::Thread::get_main_id(); -}; +} bool OS::has_feature(const String &p_feature) const { const bool *value_ptr = feature_cache.getptr(p_feature); diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index f0295dfe75..93f67b0bee 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -108,7 +108,7 @@ public: _FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; } _FORCE_INLINE_ static bool is_active() { return singleton != nullptr && script_debugger != nullptr; } - _FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; }; + _FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; } static void initialize(const String &p_uri, bool p_skip_breakpoints, const Vector<String> &p_breakpoints, void (*p_allow_focus_steal_fn)()); static void deinitialize(); diff --git a/core/io/dir_access.h b/core/io/dir_access.h index e358ce11a5..2567764e55 100644 --- a/core/io/dir_access.h +++ b/core/io/dir_access.h @@ -98,8 +98,8 @@ public: virtual bool file_exists(String p_file) = 0; virtual bool dir_exists(String p_dir) = 0; - virtual bool is_readable(String p_dir) { return true; }; - virtual bool is_writable(String p_dir) { return true; }; + virtual bool is_readable(String p_dir) { return true; } + virtual bool is_writable(String p_dir) { return true; } static bool exists(const String &p_dir); virtual uint64_t get_space_left() = 0; diff --git a/core/io/file_access.h b/core/io/file_access.h index 5304198fe5..61970b2d1a 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -217,8 +217,8 @@ public: static bool get_read_only_attribute(const String &p_file); static Error set_read_only_attribute(const String &p_file, bool p_ro); - static void set_backup_save(bool p_enable) { backup_save = p_enable; }; - static bool is_backup_save_enabled() { return backup_save; }; + static void set_backup_save(bool p_enable) { backup_save = p_enable; } + static bool is_backup_save_enabled() { return backup_save; } static String get_md5(const String &p_file); static String get_sha256(const String &p_file); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 72c1ad4389..cf152cb41a 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -53,7 +53,7 @@ struct _IP_ResolverPrivate { response.clear(); type = IP::TYPE_NONE; hostname = ""; - }; + } QueueItem() { clear(); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 35aff65856..21b688db9c 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -224,7 +224,7 @@ public: static ThreadLoadStatus load_threaded_get_status(const String &p_path, float *r_progress = nullptr); static Ref<Resource> load_threaded_get(const String &p_path, Error *r_error = nullptr); - static bool is_within_load() { return load_nesting > 0; }; + static bool is_within_load() { return load_nesting > 0; } static void resource_changed_connect(Resource *p_source, const Callable &p_callable, uint32_t p_flags); static void resource_changed_disconnect(Resource *p_source, const Callable &p_callable); diff --git a/core/math/basis.h b/core/math/basis.h index 857e851e1d..814ae255b2 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -225,7 +225,7 @@ struct [[nodiscard]] Basis { static Basis looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false); - Basis(const Quaternion &p_quaternion) { set_quaternion(p_quaternion); }; + Basis(const Quaternion &p_quaternion) { set_quaternion(p_quaternion); } Basis(const Quaternion &p_quaternion, const Vector3 &p_scale) { set_quaternion_scale(p_quaternion, p_scale); } Basis(const Vector3 &p_axis, real_t p_angle) { set_axis_angle(p_axis, p_angle); } diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index 8fcde893cd..c1b08d8cfd 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -78,7 +78,7 @@ struct _AtlasWorkRect { Size2i s; Point2i p; int idx = 0; - _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; }; + _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; } }; struct _AtlasWorkRectResult { diff --git a/core/math/plane.h b/core/math/plane.h index 39baf25022..7ea55499b8 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -42,7 +42,7 @@ struct [[nodiscard]] Plane { real_t d = 0; void set_normal(const Vector3 &p_normal); - _FORCE_INLINE_ Vector3 get_normal() const { return normal; }; + _FORCE_INLINE_ Vector3 get_normal() const { return normal; } void normalize(); Plane normalized() const; diff --git a/core/object/method_bind.h b/core/object/method_bind.h index f7d7330986..875877be6a 100644 --- a/core/object/method_bind.h +++ b/core/object/method_bind.h @@ -111,7 +111,7 @@ public: _FORCE_INLINE_ StringName get_instance_class() const { return instance_class; } _FORCE_INLINE_ void set_instance_class(const StringName &p_class) { instance_class = p_class; } - _FORCE_INLINE_ int get_argument_count() const { return argument_count; }; + _FORCE_INLINE_ int get_argument_count() const { return argument_count; } #ifdef TOOLS_ENABLED virtual bool is_valid() const { return true; } diff --git a/core/object/object.h b/core/object/object.h index 55eb3526bc..308fdc2ab9 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -687,22 +687,22 @@ protected: _ALWAYS_INLINE_ const ObjectGDExtension *_get_extension() const { return _extension; } _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; } virtual void _initialize_classv() { initialize_class(); } - virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; }; - virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; }; - virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {}; - virtual void _validate_propertyv(PropertyInfo &p_property) const {}; - virtual bool _property_can_revertv(const StringName &p_name) const { return false; }; - virtual bool _property_get_revertv(const StringName &p_name, Variant &r_property) const { return false; }; + virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; } + virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; } + virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {} + virtual void _validate_propertyv(PropertyInfo &p_property) const {} + virtual bool _property_can_revertv(const StringName &p_name) const { return false; } + virtual bool _property_get_revertv(const StringName &p_name, Variant &r_property) const { return false; } virtual void _notificationv(int p_notification, bool p_reversed) {} static void _bind_methods(); static void _bind_compatibility_methods() {} - bool _set(const StringName &p_name, const Variant &p_property) { return false; }; - bool _get(const StringName &p_name, Variant &r_property) const { return false; }; - void _get_property_list(List<PropertyInfo> *p_list) const {}; - void _validate_property(PropertyInfo &p_property) const {}; - bool _property_can_revert(const StringName &p_name) const { return false; }; - bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; }; + bool _set(const StringName &p_name, const Variant &p_property) { return false; } + bool _get(const StringName &p_name, Variant &r_property) const { return false; } + void _get_property_list(List<PropertyInfo> *p_list) const {} + void _validate_property(PropertyInfo &p_property) const {} + bool _property_can_revert(const StringName &p_name) const { return false; } + bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; } void _notification(int p_notification) {} _FORCE_INLINE_ static void (*_get_bind_methods())() { diff --git a/core/object/script_language.h b/core/object/script_language.h index 4d56b50bcc..d36dcb393a 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -448,8 +448,8 @@ public: virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override; virtual void validate_property(PropertyInfo &p_property) const override {} - virtual bool property_can_revert(const StringName &p_name) const override { return false; }; - virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; }; + virtual bool property_can_revert(const StringName &p_name) const override { return false; } + virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; } virtual void get_method_list(List<MethodInfo> *p_list) const override; virtual bool has_method(const StringName &p_method) const override; diff --git a/core/os/os.h b/core/os/os.h index 9a9bba4325..ddd4255d11 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -178,14 +178,14 @@ public: void set_delta_smoothing(bool p_enabled); bool is_delta_smoothing_enabled() const; - virtual Vector<String> get_system_fonts() const { return Vector<String>(); }; - virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return String(); }; - virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return Vector<String>(); }; + virtual Vector<String> get_system_fonts() const { return Vector<String>(); } + virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return String(); } + virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return Vector<String>(); } virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) = 0; virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking = true) { return Dictionary(); } virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) = 0; - virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) { return create_process(get_executable_path(), p_arguments, r_child_id); }; + virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) { return create_process(get_executable_path(), p_arguments, r_child_id); } virtual Error kill(const ProcessID &p_pid) = 0; virtual int get_process_id() const; virtual bool is_process_running(const ProcessID &p_pid) const = 0; diff --git a/core/string/translation_domain.cpp b/core/string/translation_domain.cpp index dfbc664783..1fdf5b7e75 100644 --- a/core/string/translation_domain.cpp +++ b/core/string/translation_domain.cpp @@ -125,7 +125,7 @@ String TranslationDomain::_double_vowels(const String &p_message) const { } } return res; -}; +} String TranslationDomain::_replace_with_accented_string(const String &p_message) const { String res; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 73ffe14e50..38f610eaca 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -35,6 +35,7 @@ #include "core/crypto/crypto_core.h" #include "core/math/color.h" #include "core/math/math_funcs.h" +#include "core/object/object.h" #include "core/os/memory.h" #include "core/string/print_string.h" #include "core/string/string_name.h" @@ -4066,8 +4067,18 @@ String String::format(const Variant &values, const String &placeholder) const { for (const Variant &key : keys) { new_string = new_string.replace(placeholder.replace("_", key), d[key]); } + } else if (values.get_type() == Variant::OBJECT) { + Object *obj = values.get_validated_object(); + ERR_FAIL_NULL_V(obj, new_string); + + List<PropertyInfo> props; + obj->get_property_list(&props); + + for (const PropertyInfo &E : props) { + new_string = new_string.replace(placeholder.replace("_", E.name), obj->get(E.name)); + } } else { - ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); + ERR_PRINT(String("Invalid type: use Array, Dictionary or Object.").ascii().get_data()); } return new_string; diff --git a/core/string/ustring.h b/core/string/ustring.h index 491f82e109..d6c0907ecc 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -120,7 +120,7 @@ public: Char16String &operator+=(char16_t p_char); int length() const { return size() ? size() - 1 : 0; } const char16_t *get_data() const; - operator const char16_t *() const { return get_data(); }; + operator const char16_t *() const { return get_data(); } protected: void copy_from(const char16_t *p_cstr); @@ -162,7 +162,7 @@ public: CharString &operator+=(char p_char); int length() const { return size() ? size() - 1 : 0; } const char *get_data() const; - operator const char *() const { return get_data(); }; + operator const char *() const { return get_data(); } protected: void copy_from(const char *p_cstr); diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index ac83810ba6..8ac19d6e17 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -243,7 +243,7 @@ public: _FORCE_INLINE_ CowData() {} _FORCE_INLINE_ ~CowData(); - _FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); }; + _FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); } }; template <typename T> diff --git a/core/templates/lru.h b/core/templates/lru.h index b02f75e58a..60f1a49293 100644 --- a/core/templates/lru.h +++ b/core/templates/lru.h @@ -37,9 +37,21 @@ #include "hash_map.h" #include "list.h" -template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>> +#if defined(__GNUC__) && !defined(__clang__) +#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Waddress\""); + +#define ADDRESS_DIAGNOSTIC_POP \ + _Pragma("GCC diagnostic pop"); +#else +#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE +#define ADDRESS_DIAGNOSTIC_POP +#endif + +template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>, void (*BeforeEvict)(TKey &, TData &) = nullptr> class LRUCache { -private: +public: struct Pair { TKey key; TData data; @@ -53,16 +65,22 @@ private: typedef typename List<Pair>::Element *Element; +private: List<Pair> _list; HashMap<TKey, Element, Hasher, Comparator> _map; size_t capacity; public: - const TData *insert(const TKey &p_key, const TData &p_value) { + const Pair *insert(const TKey &p_key, const TData &p_value) { Element *e = _map.getptr(p_key); Element n = _list.push_front(Pair(p_key, p_value)); if (e) { + ADDRESS_DIAGNOSTIC_WARNING_DISABLE; + if constexpr (BeforeEvict != nullptr) { + BeforeEvict((*e)->get().key, (*e)->get().data); + } + ADDRESS_DIAGNOSTIC_POP; _list.erase(*e); _map.erase(p_key); } @@ -70,11 +88,16 @@ public: while (_map.size() > capacity) { Element d = _list.back(); + ADDRESS_DIAGNOSTIC_WARNING_DISABLE + if constexpr (BeforeEvict != nullptr) { + BeforeEvict(d->get().key, d->get().data); + } + ADDRESS_DIAGNOSTIC_POP _map.erase(d->get().key); _list.pop_back(); } - return &n->get().data; + return &n->get(); } void clear() { @@ -86,12 +109,23 @@ public: return _map.getptr(p_key); } + bool erase(const TKey &p_key) { + Element *e = _map.getptr(p_key); + if (!e) { + return false; + } + _list.move_to_front(*e); + _map.erase(p_key); + _list.pop_front(); + return true; + } + const TData &get(const TKey &p_key) { Element *e = _map.getptr(p_key); CRASH_COND(!e); _list.move_to_front(*e); return (*e)->get().data; - }; + } const TData *getptr(const TKey &p_key) { Element *e = _map.getptr(p_key); @@ -111,6 +145,11 @@ public: capacity = p_capacity; while (_map.size() > capacity) { Element d = _list.back(); + ADDRESS_DIAGNOSTIC_WARNING_DISABLE; + if constexpr (BeforeEvict != nullptr) { + BeforeEvict(d->get().key, d->get().data); + } + ADDRESS_DIAGNOSTIC_POP; _map.erase(d->get().key); _list.pop_back(); } @@ -126,4 +165,7 @@ public: } }; +#undef ADDRESS_DIAGNOSTIC_WARNING_DISABLE +#undef ADDRESS_DIAGNOSTIC_POP + #endif // LRU_H diff --git a/core/templates/rb_set.h b/core/templates/rb_set.h index 3f87f770f5..b4312781a9 100644 --- a/core/templates/rb_set.h +++ b/core/templates/rb_set.h @@ -78,7 +78,7 @@ public: } const T &get() const { return value; - }; + } Element() {} }; diff --git a/core/typedefs.h b/core/typedefs.h index 78ba0f5792..6ba03e1a11 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -317,4 +317,6 @@ struct BuildIndexSequence<0, Is...> : IndexSequence<Is...> {}; #define ___gd_is_defined(val) ____gd_is_defined(__GDARG_PLACEHOLDER_##val) #define GD_IS_DEFINED(x) ___gd_is_defined(x) +#define FORCE_SEMICOLON ; + #endif // TYPEDEFS_H |