diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 6 | ||||
-rw-r--r-- | core/core_bind.cpp | 5 | ||||
-rw-r--r-- | core/core_bind.h | 3 | ||||
-rw-r--r-- | core/core_constants.cpp | 3 | ||||
-rw-r--r-- | core/error/error_macros.h | 22 | ||||
-rw-r--r-- | core/io/resource_saver.h | 3 | ||||
-rw-r--r-- | core/math/vector2.h | 3 | ||||
-rw-r--r-- | core/math/vector2i.h | 3 | ||||
-rw-r--r-- | core/math/vector3.h | 2 | ||||
-rw-r--r-- | core/math/vector3i.h | 3 | ||||
-rw-r--r-- | core/templates/paged_allocator.h | 2 |
11 files changed, 45 insertions, 10 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index c9b615fb0a..9db43afba1 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -614,11 +614,7 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo bool ProjectSettings::has_setting(String p_var) const { _THREAD_SAFE_METHOD_ - StringName name = p_var; - if (!disable_feature_overrides && feature_overrides.has(name)) { - name = feature_overrides[name]; - } - return props.has(name); + return props.has(p_var); } Error ProjectSettings::_load_settings_binary(const String &p_path) { diff --git a/core/core_bind.cpp b/core/core_bind.cpp index bb4b49d9cd..590d1c12c6 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -137,7 +137,7 @@ void ResourceLoader::_bind_methods() { ////// ResourceSaver ////// -Error ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) { +Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'."); return ::ResourceSaver::save(p_path, p_resource, p_flags); } @@ -156,9 +156,10 @@ Vector<String> ResourceSaver::get_recognized_extensions(const RES &p_resource) { ResourceSaver *ResourceSaver::singleton = nullptr; void ResourceSaver::_bind_methods() { - ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &ResourceSaver::save, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &ResourceSaver::save, DEFVAL((uint32_t)FLAG_NONE)); ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &ResourceSaver::get_recognized_extensions); + BIND_ENUM_CONSTANT(FLAG_NONE); BIND_ENUM_CONSTANT(FLAG_RELATIVE_PATHS); BIND_ENUM_CONSTANT(FLAG_BUNDLE_RESOURCES); BIND_ENUM_CONSTANT(FLAG_CHANGE_PATH); diff --git a/core/core_bind.h b/core/core_bind.h index 1ed243206b..4a7eb718f1 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -94,6 +94,7 @@ protected: public: enum SaverFlags { + FLAG_NONE = 0, FLAG_RELATIVE_PATHS = 1, FLAG_BUNDLE_RESOURCES = 2, FLAG_CHANGE_PATH = 4, @@ -105,7 +106,7 @@ public: static ResourceSaver *get_singleton() { return singleton; } - Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags); + Error save(const String &p_path, const RES &p_resource, uint32_t p_flags); Vector<String> get_recognized_extensions(const RES &p_resource); ResourceSaver() { singleton = this; } diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 63e7323f7a..89926ee81b 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -168,6 +168,7 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_IMAGE_MASK); BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_TEXT_MASK); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NONE); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SPECIAL); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ESCAPE); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TAB); @@ -422,6 +423,7 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(KeyModifierMask, KEY_MASK, KPAD); BIND_CORE_ENUM_CLASS_CONSTANT(KeyModifierMask, KEY_MASK, GROUP_SWITCH); + BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, NONE); BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, LEFT); BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, RIGHT); BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, MIDDLE); @@ -472,6 +474,7 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(JoyAxis, JOY_AXIS, SDL_MAX); BIND_CORE_ENUM_CLASS_CONSTANT(JoyAxis, JOY_AXIS, MAX); + BIND_CORE_ENUM_CLASS_CONSTANT(MIDIMessage, MIDI_MESSAGE, NONE); BIND_CORE_ENUM_CLASS_CONSTANT(MIDIMessage, MIDI_MESSAGE, NOTE_OFF); BIND_CORE_ENUM_CLASS_CONSTANT(MIDIMessage, MIDI_MESSAGE, NOTE_ON); BIND_CORE_ENUM_CLASS_CONSTANT(MIDIMessage, MIDI_MESSAGE, AFTERTOUCH); diff --git a/core/error/error_macros.h b/core/error/error_macros.h index 7b032fb4cd..01e22e84b7 100644 --- a/core/error/error_macros.h +++ b/core/error/error_macros.h @@ -194,6 +194,7 @@ void _err_flush_stdout(); #define CRASH_BAD_INDEX(m_index, m_size) \ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -208,6 +209,7 @@ void _err_flush_stdout(); #define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -296,6 +298,7 @@ void _err_flush_stdout(); #define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \ if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -310,6 +313,7 @@ void _err_flush_stdout(); #define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -559,6 +563,7 @@ void _err_flush_stdout(); #define CRASH_COND(m_cond) \ if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -573,6 +578,7 @@ void _err_flush_stdout(); #define CRASH_COND_MSG(m_cond, m_msg) \ if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", m_msg); \ + _err_flush_stdout(); \ GENERATE_TRAP(); \ } else \ ((void)0) @@ -808,4 +814,20 @@ void _err_flush_stdout(); } else \ ((void)0) +/** + * This should be a 'free' assert for program flow and should not be needed in any releases, + * only used in dev builds. + */ +#ifdef DEV_ENABLED +#define DEV_ASSERT(m_cond) \ + if (unlikely(!(m_cond))) { \ + _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: DEV_ASSERT failed \"" _STR(m_cond) "\" is false."); \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ + ((void)0) +#else +#define DEV_ASSERT(m_cond) +#endif + #endif // ERROR_MACROS_H diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 2919a4cec0..ebc3be91a1 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -71,6 +71,7 @@ class ResourceSaver { public: enum SaverFlags { + FLAG_NONE = 0, FLAG_RELATIVE_PATHS = 1, FLAG_BUNDLE_RESOURCES = 2, FLAG_CHANGE_PATH = 4, @@ -80,7 +81,7 @@ public: FLAG_REPLACE_SUBRESOURCE_PATHS = 64, }; - static Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); + static Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = (uint32_t)FLAG_NONE); static void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions); static void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front = false); static void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver); diff --git a/core/math/vector2.h b/core/math/vector2.h index a2680b84fc..bd67299f33 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -31,6 +31,7 @@ #ifndef VECTOR2_H #define VECTOR2_H +#include "core/error/error_macros.h" #include "core/math/math_funcs.h" class String; @@ -60,9 +61,11 @@ struct _NO_DISCARD_ Vector2 { }; _FORCE_INLINE_ real_t &operator[](int p_idx) { + DEV_ASSERT((unsigned int)p_idx < 2); return coord[p_idx]; } _FORCE_INLINE_ const real_t &operator[](int p_idx) const { + DEV_ASSERT((unsigned int)p_idx < 2); return coord[p_idx]; } diff --git a/core/math/vector2i.h b/core/math/vector2i.h index 3f5f12d4dd..13b70031bd 100644 --- a/core/math/vector2i.h +++ b/core/math/vector2i.h @@ -31,6 +31,7 @@ #ifndef VECTOR2I_H #define VECTOR2I_H +#include "core/error/error_macros.h" #include "core/math/math_funcs.h" class String; @@ -58,9 +59,11 @@ struct _NO_DISCARD_ Vector2i { }; _FORCE_INLINE_ int32_t &operator[](int p_idx) { + DEV_ASSERT((unsigned int)p_idx < 2); return coord[p_idx]; } _FORCE_INLINE_ const int32_t &operator[](int p_idx) const { + DEV_ASSERT((unsigned int)p_idx < 2); return coord[p_idx]; } diff --git a/core/math/vector3.h b/core/math/vector3.h index 89b0095741..b22ebeaf0a 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -59,10 +59,12 @@ struct _NO_DISCARD_ Vector3 { }; _FORCE_INLINE_ const real_t &operator[](const int p_axis) const { + DEV_ASSERT((unsigned int)p_axis < 3); return coord[p_axis]; } _FORCE_INLINE_ real_t &operator[](const int p_axis) { + DEV_ASSERT((unsigned int)p_axis < 3); return coord[p_axis]; } diff --git a/core/math/vector3i.h b/core/math/vector3i.h index 2a4c7e2e97..b49c1142ed 100644 --- a/core/math/vector3i.h +++ b/core/math/vector3i.h @@ -31,6 +31,7 @@ #ifndef VECTOR3I_H #define VECTOR3I_H +#include "core/error/error_macros.h" #include "core/math/math_funcs.h" class String; @@ -54,10 +55,12 @@ struct _NO_DISCARD_ Vector3i { }; _FORCE_INLINE_ const int32_t &operator[](const int p_axis) const { + DEV_ASSERT((unsigned int)p_axis < 3); return coord[p_axis]; } _FORCE_INLINE_ int32_t &operator[](const int p_axis) { + DEV_ASSERT((unsigned int)p_axis < 3); return coord[p_axis]; } diff --git a/core/templates/paged_allocator.h b/core/templates/paged_allocator.h index 5bc723787f..b9067e2edd 100644 --- a/core/templates/paged_allocator.h +++ b/core/templates/paged_allocator.h @@ -86,10 +86,10 @@ public: } p_mem->~T(); available_pool[allocs_available >> page_shift][allocs_available & page_mask] = p_mem; + allocs_available++; if (thread_safe) { spin_lock.unlock(); } - allocs_available++; } void reset(bool p_allow_unfreed = false) { |