From a1a241af826d2531b4bfd593c5b9367fd3aaf2af Mon Sep 17 00:00:00 2001 From: praydog Date: Tue, 26 Mar 2024 16:57:25 -0700 Subject: [PATCH] REMethodDefinition: Fix infinite log spam caused by 0 encoded_offset --- shared/sdk/RETypeDB.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shared/sdk/RETypeDB.cpp b/shared/sdk/RETypeDB.cpp index ea697e03c..7292e1bcd 100644 --- a/shared/sdk/RETypeDB.cpp +++ b/shared/sdk/RETypeDB.cpp @@ -392,6 +392,9 @@ const char* REMethodDefinition::get_name() const { return tdb->get_string(name_offset); } +std::unordered_set logged_encoded_0_methods{}; +std::shared_mutex logged_encoded_0_methods_mtx{}; + void* REMethodDefinition::get_function() const { #if TDB_VER >= 71 if (this->encoded_offset == 0) { @@ -416,6 +419,17 @@ void* REMethodDefinition::get_function() const { } }*/ + { + std::shared_lock _{ logged_encoded_0_methods_mtx }; + + if (logged_encoded_0_methods.contains(const_cast(this))) { + return nullptr; + } + } + + std::unique_lock _{ logged_encoded_0_methods_mtx }; + logged_encoded_0_methods.insert(const_cast(this)); + auto decl_type = this->get_declaring_type(); auto name = decl_type != nullptr ? decl_type->get_full_name() : std::string{"null"}; spdlog::error("[REMethodDefinition::get_function] Encoded offset is 0 (vindex {}) (method: {}.{})", this->get_virtual_index(), name, this->get_name());