Add support for auto-converting '_' to ':' with Steam3 Id targetting

This commit is contained in:
Nicholas Hastings 2014-09-05 14:02:52 -07:00
parent 215bbb8324
commit 29d428adc2

View File

@ -1556,28 +1556,34 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
if (steamIdType > 0)
{
const char *search_pattern;
char tmp_pattern[256];
char new_pattern[256];
if (steamIdType == 2)
{
size_t p, len;
strcpy(tmp_pattern, "STEAM_");
strcpy(new_pattern, "STEAM_");
len = strlen(&info->pattern[7]);
for (p = 0; p < len; p++)
{
tmp_pattern[6 + p] = info->pattern[7 + p];
if (tmp_pattern[6 + p] == '_')
new_pattern[6 + p] = info->pattern[7 + p];
if (new_pattern[6 + p] == '_')
{
tmp_pattern[6 + p] = ':';
new_pattern[6 + p] = ':';
}
}
tmp_pattern[6 + p] = '\0';
search_pattern = tmp_pattern;
new_pattern[6 + p] = '\0';
}
else
{
search_pattern = &info->pattern[1];
size_t p = 0;
char c;
while ((c = info->pattern[p + 1]) != '\0')
{
new_pattern[p] = (c == '_') ? ':' : c;
++p;
}
new_pattern[p] = '\0';
}
for (int i = 1; i <= max_clients; i++)
@ -1593,7 +1599,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
// We want to make it easy for people to be kicked/banned, so don't require validation for command targets.
const char *steamId = steamIdType == 2 ? pTarget->GetSteam2Id(false) : pTarget->GetSteam3Id(false);
if (steamId && strcmp(steamId, search_pattern) == 0)
if (steamId && strcmp(steamId, new_pattern) == 0)
{
if ((info->reason = FilterCommandTarget(pAdmin, pTarget, info->flags))
== COMMAND_TARGET_VALID)