Skip to content

Commit

Permalink
Fix finding strings
Browse files Browse the repository at this point in the history
  • Loading branch information
accelerator74 committed May 7, 2024
1 parent d1809a7 commit 59a9ed0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@ unordered_set<string> 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);
}
Expand Down
2 changes: 1 addition & 1 deletion extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

// for string manipulation
#include <algorithm>
#include <string>
#include <cstring>
#include <iostream>
#include <cctype>
#include <unordered_set>
Expand Down

0 comments on commit 59a9ed0

Please sign in to comment.