mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-09 11:28:26 +00:00
Wr suggestions (#972)
* make !wr say map not found when map not found... * use translation string for 'map was not found' * stockify GuessBestMapName() and also use in sm_tier * fix formatting Co-authored-by: KiD Fearless <kidfearless1@gmail.com>
This commit is contained in:
parent
e1e7d3bf2e
commit
c40ab49fac
@ -425,6 +425,32 @@ stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool preci
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock bool GuessBestMapName(ArrayList maps, const char[] input, char[] output, int size)
|
||||||
|
{
|
||||||
|
if(maps.FindString(input) != -1)
|
||||||
|
{
|
||||||
|
strcopy(output, size, input);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sCache[128];
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.Length; i++)
|
||||||
|
{
|
||||||
|
maps.GetString(i, sCache, 128);
|
||||||
|
|
||||||
|
if(StrContains(sCache, input) != -1)
|
||||||
|
{
|
||||||
|
strcopy(output, size, sCache);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before shavit-core processes the client's usercmd.
|
* Called before shavit-core processes the client's usercmd.
|
||||||
* Before this is called, safety checks (fake/dead clients) happen.
|
* Before this is called, safety checks (fake/dead clients) happen.
|
||||||
|
|||||||
@ -67,7 +67,6 @@ int gI_Tier = 1; // No floating numbers for tiers, sorry.
|
|||||||
|
|
||||||
char gS_Map[160];
|
char gS_Map[160];
|
||||||
|
|
||||||
int gI_ValidMaps = 0;
|
|
||||||
ArrayList gA_ValidMaps = null;
|
ArrayList gA_ValidMaps = null;
|
||||||
StringMap gA_MapTiers = null;
|
StringMap gA_MapTiers = null;
|
||||||
|
|
||||||
@ -434,34 +433,9 @@ public void SQL_FillTierCache_Callback(Database db, DBResultSet results, const c
|
|||||||
Call_Finish();
|
Call_Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
gI_ValidMaps = gA_ValidMaps.Length;
|
|
||||||
SortADTArray(gA_ValidMaps, Sort_Ascending, Sort_String);
|
SortADTArray(gA_ValidMaps, Sort_Ascending, Sort_String);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuessBestMapName(const char[] input, char[] output, int size)
|
|
||||||
{
|
|
||||||
if(gA_ValidMaps.FindString(input) != -1)
|
|
||||||
{
|
|
||||||
strcopy(output, size, input);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sCache[128];
|
|
||||||
|
|
||||||
for(int i = 0; i < gI_ValidMaps; i++)
|
|
||||||
{
|
|
||||||
gA_ValidMaps.GetString(i, sCache, 128);
|
|
||||||
|
|
||||||
if(StrContains(sCache, input) != -1)
|
|
||||||
{
|
|
||||||
strcopy(output, size, sCache);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnMapEnd()
|
public void OnMapEnd()
|
||||||
{
|
{
|
||||||
RecalculateAll(gS_Map);
|
RecalculateAll(gS_Map);
|
||||||
@ -473,16 +447,19 @@ public Action Command_Tier(int client, int args)
|
|||||||
int tier = gI_Tier;
|
int tier = gI_Tier;
|
||||||
|
|
||||||
char sMap[128];
|
char sMap[128];
|
||||||
strcopy(sMap, 128, gS_Map);
|
|
||||||
|
|
||||||
if(args > 0)
|
if(args == 0)
|
||||||
|
{
|
||||||
|
strcopy(sMap, 128, gS_Map);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GetCmdArgString(sMap, 128);
|
GetCmdArgString(sMap, 128);
|
||||||
GuessBestMapName(sMap, sMap, 128);
|
if(!GuessBestMapName(gA_ValidMaps, sMap, sMap, 128) || !gA_MapTiers.GetValue(sMap, tier))
|
||||||
|
|
||||||
if(!gA_MapTiers.GetValue(sMap, tier))
|
|
||||||
{
|
{
|
||||||
strcopy(sMap, 128, gS_Map);
|
Shavit_PrintToChat(client, "%t", "Map was not found", sMap);
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,6 @@ wrcache_t gA_WRCache[MAXPLAYERS+1];
|
|||||||
|
|
||||||
char gS_Map[160]; // blame workshop paths being so fucking long
|
char gS_Map[160]; // blame workshop paths being so fucking long
|
||||||
ArrayList gA_ValidMaps = null;
|
ArrayList gA_ValidMaps = null;
|
||||||
int gI_ValidMaps = 1;
|
|
||||||
|
|
||||||
// current wr stats
|
// current wr stats
|
||||||
float gF_WRTime[STYLE_LIMIT][TRACKS_SIZE];
|
float gF_WRTime[STYLE_LIMIT][TRACKS_SIZE];
|
||||||
@ -124,6 +123,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
|
LoadTranslations("common.phrases");
|
||||||
LoadTranslations("shavit-common.phrases");
|
LoadTranslations("shavit-common.phrases");
|
||||||
LoadTranslations("shavit-wr.phrases");
|
LoadTranslations("shavit-wr.phrases");
|
||||||
|
|
||||||
@ -143,9 +143,9 @@ public void OnPluginStart()
|
|||||||
RegConsoleCmd("sm_wr", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_wr [map]");
|
RegConsoleCmd("sm_wr", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_wr [map]");
|
||||||
RegConsoleCmd("sm_worldrecord", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_worldrecord [map]");
|
RegConsoleCmd("sm_worldrecord", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_worldrecord [map]");
|
||||||
|
|
||||||
RegConsoleCmd("sm_bwr", Command_WorldRecord_Bonus, "View the leaderboard of a map. Usage: sm_bwr [map]");
|
RegConsoleCmd("sm_bwr", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_bwr [map]");
|
||||||
RegConsoleCmd("sm_bworldrecord", Command_WorldRecord_Bonus, "View the leaderboard of a map. Usage: sm_bworldrecord [map]");
|
RegConsoleCmd("sm_bworldrecord", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_bworldrecord [map]");
|
||||||
RegConsoleCmd("sm_bonusworldrecord", Command_WorldRecord_Bonus, "View the leaderboard of a map. Usage: sm_bonusworldrecord [map]");
|
RegConsoleCmd("sm_bonusworldrecord", Command_WorldRecord, "View the leaderboard of a map. Usage: sm_bonusworldrecord [map]");
|
||||||
|
|
||||||
RegConsoleCmd("sm_recent", Command_RecentRecords, "View the recent #1 times set.");
|
RegConsoleCmd("sm_recent", Command_RecentRecords, "View the recent #1 times set.");
|
||||||
RegConsoleCmd("sm_recentrecords", Command_RecentRecords, "View the recent #1 times set.");
|
RegConsoleCmd("sm_recentrecords", Command_RecentRecords, "View the recent #1 times set.");
|
||||||
@ -317,7 +317,6 @@ public void OnMapStart()
|
|||||||
|
|
||||||
gA_ValidMaps.Clear();
|
gA_ValidMaps.Clear();
|
||||||
gA_ValidMaps.PushString(sLowerCase);
|
gA_ValidMaps.PushString(sLowerCase);
|
||||||
gI_ValidMaps = 1;
|
|
||||||
|
|
||||||
char sQuery[128];
|
char sQuery[128];
|
||||||
FormatEx(sQuery, 128, "SELECT map FROM %smapzones GROUP BY map;", gS_MySQLPrefix);
|
FormatEx(sQuery, 128, "SELECT map FROM %smapzones GROUP BY map;", gS_MySQLPrefix);
|
||||||
@ -358,7 +357,6 @@ public void SQL_UpdateMaps_Callback(Database db, DBResultSet results, const char
|
|||||||
if(gA_ValidMaps.FindString(sLowerCase) == -1)
|
if(gA_ValidMaps.FindString(sLowerCase) == -1)
|
||||||
{
|
{
|
||||||
gA_ValidMaps.PushString(sLowerCase);
|
gA_ValidMaps.PushString(sLowerCase);
|
||||||
gI_ValidMaps++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,31 +1311,24 @@ public Action Command_WorldRecord(int client, int args)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetCmdArgString(gA_WRCache[client].sClientMap, 128);
|
GetCmdArgString(gA_WRCache[client].sClientMap, 128);
|
||||||
GuessBestMapName(gA_WRCache[client].sClientMap, gA_WRCache[client].sClientMap, 128);
|
if (!GuessBestMapName(gA_ValidMaps, gA_WRCache[client].sClientMap, gA_WRCache[client].sClientMap, 128))
|
||||||
|
{
|
||||||
|
Shavit_PrintToChat(client, "%t", "Map was not found", gA_WRCache[client].sClientMap);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShowWRStyleMenu(client, Track_Main);
|
char sCommand[16];
|
||||||
}
|
GetCmdArg(0, sCommand, 16);
|
||||||
|
|
||||||
public Action Command_WorldRecord_Bonus(int client, int args)
|
int track = Track_Main;
|
||||||
{
|
|
||||||
if(!IsValidClient(client))
|
if(StrContains(sCommand, "sm_b", false) == 0)
|
||||||
{
|
{
|
||||||
return Plugin_Handled;
|
track = Track_Bonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args == 0)
|
return ShowWRStyleMenu(client, track);
|
||||||
{
|
|
||||||
strcopy(gA_WRCache[client].sClientMap, 128, gS_Map);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetCmdArgString(gA_WRCache[client].sClientMap, 128);
|
|
||||||
GuessBestMapName(gA_WRCache[client].sClientMap, gA_WRCache[client].sClientMap, 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ShowWRStyleMenu(client, Track_Bonus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Action ShowWRStyleMenu(int client, int track)
|
Action ShowWRStyleMenu(int client, int track)
|
||||||
@ -2263,30 +2254,6 @@ int GetRankForTime(int style, float time, int track)
|
|||||||
return (iRecords + 1);
|
return (iRecords + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuessBestMapName(const char[] input, char[] output, int size)
|
|
||||||
{
|
|
||||||
if(gA_ValidMaps.FindString(input) != -1)
|
|
||||||
{
|
|
||||||
strcopy(output, size, input);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sCache[128];
|
|
||||||
|
|
||||||
for(int i = 0; i < gI_ValidMaps; i++)
|
|
||||||
{
|
|
||||||
gA_ValidMaps.GetString(i, sCache, 128);
|
|
||||||
|
|
||||||
if(StrContains(sCache, input) != -1)
|
|
||||||
{
|
|
||||||
strcopy(output, size, sCache);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetTrackName(int client, int track, char[] output, int size)
|
void GetTrackName(int client, int track, char[] output, int size)
|
||||||
{
|
{
|
||||||
if(track < 0 || track >= TRACKS_SIZE)
|
if(track < 0 || track >= TRACKS_SIZE)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user