Fix method hashes with default arguments

This commit is contained in:
David Snopek
2023-09-10 12:36:44 -05:00
parent fc99492d30
commit 0d13727c97
7 changed files with 937 additions and 8 deletions

View File

@ -32,6 +32,7 @@
#include "core/config/engine.h"
#include "core/extension/gdextension.h"
#include "core/extension/gdextension_compat_hashes.h"
#include "core/io/file_access.h"
#include "core/io/xml_parser.h"
#include "core/object/class_db.h"
@ -1144,6 +1145,17 @@ static GDExtensionMethodBindPtr gdextension_classdb_get_method_bind(GDExtensionC
const StringName methodname = *reinterpret_cast<const StringName *>(p_methodname);
bool exists = false;
MethodBind *mb = ClassDB::get_method_with_compatibility(classname, methodname, p_hash, &exists);
#ifndef DISABLE_DEPRECATED
// If lookup failed, see if this is one of the broken hashes from issue #81386.
if (!mb && exists) {
uint32_t mapped_hash;
if (GDExtensionCompatHashes::lookup_current_hash(classname, methodname, p_hash, &mapped_hash)) {
mb = ClassDB::get_method_with_compatibility(classname, methodname, mapped_hash, &exists);
}
}
#endif
if (!mb && exists) {
ERR_PRINT("Method '" + classname + "." + methodname + "' has changed and no compatibility fallback has been provided. Please open an issue.");
return nullptr;