mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-27 06:07:56 +03:00
Added Matcher_ContainsWildcard and fixed an issue with lazy wildcards
This commit is contained in:
parent
033fd9662b
commit
714c89cc49
@ -36,6 +36,9 @@ bool Matcher_NamesMatch_Classic( const char *pszQuery, const char *szValue );
|
||||
// szValue = The value tested against the query. This value can use wildcards as well.
|
||||
bool Matcher_NamesMatch_MutualWildcard( const char *pszQuery, const char *szValue );
|
||||
|
||||
// Returns true if the specified string contains a wildcard character.
|
||||
bool Matcher_ContainsWildcard( const char *pszQuery );
|
||||
|
||||
// Taken from the Response System.
|
||||
// Checks if the specified string appears to be a number of some sort.
|
||||
static bool AppearsToBeANumber( char const *token )
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "minmax.h"
|
||||
|
||||
ConVar mapbase_wildcards_enabled("mapbase_wildcards_enabled", "1", FCVAR_NONE, "Toggles Mapbase's '?' wildcard and true '*' features. Useful for maps that have '?' in their targetnames.");
|
||||
ConVar mapbase_wildcards_lazy_hack("mapbase_wildcards_lazy_hack", "1", FCVAR_NONE, "Toggles a hack which prevents Mapbase's lazy '?' wildcards from picking up \"???\", the default instance parameter.");
|
||||
ConVar mapbase_regex_enabled("mapbase_regex_enabled", "1", FCVAR_NONE, "Toggles Mapbase's regex matching handover.");
|
||||
|
||||
//=============================================================================
|
||||
@ -121,6 +122,14 @@ bool Matcher_NamesMatch(const char *pszQuery, const char *szValue)
|
||||
return Matcher_Regex( pszQuery+2, szValue );
|
||||
}
|
||||
}
|
||||
else if (pszQuery[0] == '?' && pszQuery[1] == '?' && pszQuery[2] == '?' && mapbase_wildcards_lazy_hack.GetBool())
|
||||
{
|
||||
// HACKHACK: There's a nasty issue where instances with blank parameters use "???", but Mapbase's lazy wildcard code
|
||||
// recognizes this as essentially meaning "any name with 3 characters". This is a serious problem when the instance
|
||||
// specifically expects the game to interpret "???" as a blank space, such as with damage filters, which crash when targeting
|
||||
// a non-filter entity.
|
||||
return false;
|
||||
}
|
||||
|
||||
return Matcher_RunCharCompare( pszQuery, szValue );
|
||||
}
|
||||
@ -200,6 +209,23 @@ bool Matcher_NamesMatch_MutualWildcard(const char *pszQuery, const char *szValue
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if a string contains a wildcard.
|
||||
bool Matcher_ContainsWildcard(const char *pszQuery)
|
||||
{
|
||||
if ( pszQuery == NULL )
|
||||
return false;
|
||||
|
||||
while ( *pszQuery )
|
||||
{
|
||||
unsigned char cQuery = *pszQuery;
|
||||
if (cQuery == '*' || cQuery == '?')
|
||||
return true;
|
||||
++pszQuery;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Matcher_Compare is a deprecated alias originally used when Matcher_Match didn't support wildcards.
|
||||
/*
|
||||
bool Matcher_Compare(const char *pszQuery, const char *szValue)
|
||||
|
Loading…
x
Reference in New Issue
Block a user