From 59a9ed08d90efdc71d0900f55417e37561d3689c Mon Sep 17 00:00:00 2001 From: Accelerator Date: Tue, 7 May 2024 18:41:08 +0300 Subject: [PATCH] Fix finding strings --- extension.cpp | 14 +++++++++++--- extension.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/extension.cpp b/extension.cpp index 6129e3b..6e4d321 100644 --- a/extension.cpp +++ b/extension.cpp @@ -15,16 +15,24 @@ unordered_set szStrings; #if SOURCE_ENGINE >= SE_LEFT4DEAD2 DETOUR_DECL_MEMBER4(Detour_LogDirect, LoggingResponse_t, LoggingChannelID_t, channelID, LoggingSeverity_t, severity, Color, color, const tchar *, pMessage) { - if (szStrings.find(pMessage) != szStrings.end()) - return LR_CONTINUE; + for (const auto& str : szStrings) { + const char* str_cstr = str.c_str(); + if (strstr(pMessage, str_cstr) != nullptr) { + return LR_CONTINUE; + } + } return DETOUR_MEMBER_CALL(Detour_LogDirect)(channelID, severity, color, pMessage); } #else DETOUR_DECL_STATIC2(Detour_DefSpew, SpewRetval_t, SpewType_t, channel, char *, text) { - if (szStrings.find(text) != szStrings.end()) + for (const auto& str : szStrings) { + const char* str_cstr = str.c_str(); + if (strstr(text, str_cstr) != nullptr) { return SPEW_CONTINUE; + } + } return DETOUR_STATIC_CALL(Detour_DefSpew)(channel, text); } diff --git a/extension.h b/extension.h index 972c4cd..f3b57ef 100644 --- a/extension.h +++ b/extension.h @@ -44,7 +44,7 @@ // for string manipulation #include -#include +#include #include #include #include