diff options
author | rune-scape <spartacrafter@gmail.com> | 2024-09-04 20:11:06 -0700 |
---|---|---|
committer | rune-scape <spartacrafter@gmail.com> | 2024-09-09 13:30:02 -0700 |
commit | 0dde931bc95e6781190af0ba31fc2ab3af22c3bc (patch) | |
tree | ed1a48ed800a9903c30d300cef8f7bb95712b777 /core/string | |
parent | 27552a2f26adcdba579cd804197de3942e8cb0ec (diff) | |
download | redot-engine-0dde931bc95e6781190af0ba31fc2ab3af22c3bc.tar.gz |
StringName: Fix empty hash
+Fixed compat hashes
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/string_name.cpp | 5 | ||||
-rw-r--r-- | core/string/string_name.h | 3 | ||||
-rw-r--r-- | core/string/translation.compat.inc | 41 | ||||
-rw-r--r-- | core/string/translation.cpp | 1 | ||||
-rw-r--r-- | core/string/translation.h | 4 | ||||
-rw-r--r-- | core/string/translation_server.compat.inc | 38 | ||||
-rw-r--r-- | core/string/translation_server.cpp | 1 | ||||
-rw-r--r-- | core/string/translation_server.h | 4 |
8 files changed, 7 insertions, 90 deletions
diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp index 0294dbfbbc..dff19b3a41 100644 --- a/core/string/string_name.cpp +++ b/core/string/string_name.cpp @@ -162,6 +162,11 @@ void StringName::unref() { _data = nullptr; } +uint32_t StringName::get_empty_hash() { + static uint32_t empty_hash = String::hash(""); + return empty_hash; +} + bool StringName::operator==(const String &p_name) const { if (_data) { return _data->operator==(p_name); diff --git a/core/string/string_name.h b/core/string/string_name.h index 288e2c7520..d4b70d311d 100644 --- a/core/string/string_name.h +++ b/core/string/string_name.h @@ -83,6 +83,7 @@ class StringName { static inline Mutex mutex; static void setup(); static void cleanup(); + static uint32_t get_empty_hash(); static inline bool configured = false; #ifdef DEBUG_ENABLED struct DebugSortReferences { @@ -139,7 +140,7 @@ public: if (_data) { return _data->hash; } else { - return 0; + return get_empty_hash(); } } _FORCE_INLINE_ const void *data_unique_pointer() const { diff --git a/core/string/translation.compat.inc b/core/string/translation.compat.inc deleted file mode 100644 index 68bd1831e4..0000000000 --- a/core/string/translation.compat.inc +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************/ -/* translation.compat.inc */ -/**************************************************************************/ -/* 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. */ -/**************************************************************************/ - -#ifndef DISABLE_DEPRECATED - -void Translation::_bind_compatibility_methods() { - ClassDB::bind_compatibility_method(D_METHOD("add_message", "src_message", "xlated_message", "context"), &Translation::add_message, DEFVAL("")); - ClassDB::bind_compatibility_method(D_METHOD("add_plural_message", "src_message", "xlated_messages", "context"), &Translation::add_plural_message, DEFVAL("")); - ClassDB::bind_compatibility_method(D_METHOD("get_message", "src_message", "context"), &Translation::get_message, DEFVAL("")); - ClassDB::bind_compatibility_method(D_METHOD("get_plural_message", "src_message", "src_plural_message", "n", "context"), &Translation::get_plural_message, DEFVAL("")); - ClassDB::bind_compatibility_method(D_METHOD("erase_message", "src_message", "context"), &Translation::erase_message, DEFVAL("")); -} - -#endif diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 33d4a1bcde..020949371f 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -29,7 +29,6 @@ /**************************************************************************/ #include "translation.h" -#include "translation.compat.inc" #include "core/os/os.h" #include "core/os/thread.h" diff --git a/core/string/translation.h b/core/string/translation.h index 2c5baae8b7..4e8cffc90c 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -51,10 +51,6 @@ class Translation : public Resource { protected: static void _bind_methods(); -#ifndef DISABLE_DEPRECATED - static void _bind_compatibility_methods(); -#endif - GDVIRTUAL2RC(StringName, _get_message, StringName, StringName); GDVIRTUAL4RC(StringName, _get_plural_message, StringName, StringName, int, StringName); diff --git a/core/string/translation_server.compat.inc b/core/string/translation_server.compat.inc deleted file mode 100644 index 9d1ee8b9df..0000000000 --- a/core/string/translation_server.compat.inc +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************/ -/* translation_server.compat.inc */ -/**************************************************************************/ -/* 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. */ -/**************************************************************************/ - -#ifndef DISABLE_DEPRECATED - -void TranslationServer::_bind_compatibility_methods() { - ClassDB::bind_compatibility_method(D_METHOD("translate", "message", "context"), &TranslationServer::translate, DEFVAL("")); - ClassDB::bind_compatibility_method(D_METHOD("translate_plural", "message", "plural_message", "n", "context"), &TranslationServer::translate_plural, DEFVAL("")); -} - -#endif diff --git a/core/string/translation_server.cpp b/core/string/translation_server.cpp index 4ac79ad10a..d4aa152340 100644 --- a/core/string/translation_server.cpp +++ b/core/string/translation_server.cpp @@ -29,7 +29,6 @@ /**************************************************************************/ #include "translation_server.h" -#include "translation_server.compat.inc" #include "core/config/project_settings.h" #include "core/io/resource_loader.h" diff --git a/core/string/translation_server.h b/core/string/translation_server.h index ebe81d9712..bb285ab19c 100644 --- a/core/string/translation_server.h +++ b/core/string/translation_server.h @@ -74,10 +74,6 @@ class TranslationServer : public Object { static void _bind_methods(); -#ifndef DISABLE_DEPRECATED - static void _bind_compatibility_methods(); -#endif - struct LocaleScriptInfo { String name; String script; |