use lowercase strings when sending to GuessBestMapName

This commit is contained in:
rtldg 2021-08-17 23:50:51 +00:00
parent 2733faf57d
commit 077cbe9a01
3 changed files with 10 additions and 9 deletions

View File

@ -485,25 +485,23 @@ stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool preci
}
}
stock bool GuessBestMapName(ArrayList maps, const char[] input, char[] output, int size)
stock bool GuessBestMapName(ArrayList maps, const char input[PLATFORM_MAX_PATH], char output[PLATFORM_MAX_PATH])
{
if(maps.FindString(input) != -1)
{
strcopy(output, size, input);
output = input;
return true;
}
char sCache[128];
char sCache[PLATFORM_MAX_PATH];
for(int i = 0; i < maps.Length; i++)
{
maps.GetString(i, sCache, 128);
maps.GetString(i, sCache, PLATFORM_MAX_PATH);
if(StrContains(sCache, input) != -1)
{
strcopy(output, size, sCache);
output = sCache;
return true;
}
}

View File

@ -441,6 +441,7 @@ public void SQL_FillTierCache_Callback(Database db, DBResultSet results, const c
{
char sMap[PLATFORM_MAX_PATH];
results.FetchString(0, sMap, sizeof(sMap));
LowercaseString(sMap);
int tier = results.FetchInt(1);
@ -564,8 +565,9 @@ public Action Command_Tier(int client, int args)
else
{
GetCmdArgString(sMap, sizeof(sMap));
LowercaseString(sMap);
if(!GuessBestMapName(gA_ValidMaps, sMap, sMap, sizeof(sMap)) || !gA_MapTiers.GetValue(sMap, tier))
if(!GuessBestMapName(gA_ValidMaps, sMap, sMap) || !gA_MapTiers.GetValue(sMap, tier))
{
Shavit_PrintToChat(client, "%t", "Map was not found", sMap);
return Plugin_Handled;

View File

@ -1503,8 +1503,9 @@ public Action Command_WorldRecord(int client, int args)
else
{
GetCmdArg(1, gA_WRCache[client].sClientMap, sizeof(wrcache_t::sClientMap));
LowercaseString(gA_WRCache[client].sClientMap);
if (!GuessBestMapName(gA_ValidMaps, gA_WRCache[client].sClientMap, gA_WRCache[client].sClientMap, sizeof(wrcache_t::sClientMap)))
if (!GuessBestMapName(gA_ValidMaps, gA_WRCache[client].sClientMap, gA_WRCache[client].sClientMap))
{
Shavit_PrintToChat(client, "%t", "Map was not found", gA_WRCache[client].sClientMap);
return Plugin_Handled;