Added Shavit_ReloadLeaderboards.

This commit is contained in:
shavit 2019-02-24 15:53:51 +02:00
parent 6fba2bca9c
commit 78bba83fd0
2 changed files with 16 additions and 1 deletions

View File

@ -762,6 +762,13 @@ native void Shavit_GetWRTime(int style, float &time, int track);
*/
native float Shavit_GetWorldRecord(int style, int track);
/**
* Reloads WR leaderboards cache for the current map.
*
* @noreturn
*/
native void Shavit_ReloadLeaderboards();
/**
* Saves the WR's record ID for the current map on a variable.
* Unused in base plugins, as of pre-1.4b.
@ -1330,6 +1337,7 @@ public void __pl_shavit_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetWRName");
MarkNativeAsOptional("Shavit_GetWRRecordID");
MarkNativeAsOptional("Shavit_GetWRTime");
MarkNativeAsOptional("Shavit_ReloadLeaderboards");
MarkNativeAsOptional("Shavit_HasStyleAccess");
MarkNativeAsOptional("Shavit_HijackAngles");
MarkNativeAsOptional("Shavit_InsideZone");

View File

@ -107,6 +107,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetWRName", Native_GetWRName);
CreateNative("Shavit_GetWRRecordID", Native_GetWRRecordID);
CreateNative("Shavit_GetWRTime", Native_GetWRTime);
CreateNative("Shavit_ReloadLeaderboards", Native_ReloadLeaderboards);
CreateNative("Shavit_WR_DeleteMap", Native_WR_DeleteMap);
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
@ -556,6 +557,12 @@ public int Native_GetWRTime(Handle handler, int numParams)
SetNativeCellRef(2, gF_WRTime[GetNativeCell(1)][GetNativeCell(3)]);
}
public int Native_ReloadLeaderboards(Handle handler, int numParams)
{
UpdateLeaderboards();
UpdateWRCache();
}
public int Native_GetWRRecordID(Handle handler, int numParams)
{
SetNativeCellRef(2, gI_WRRecordID[GetNativeCell(1)][GetNativeCell(3)]);
@ -2309,7 +2316,7 @@ public void SQL_OnFinish_Callback(Database db, DBResultSet results, const char[]
void UpdateLeaderboards()
{
char sQuery[192];
FormatEx(sQuery, 192, "SELECT style, time, track FROM %splayertimes WHERE map = '%s' ORDER BY time ASC, date ASC;", gS_MySQLPrefix, gS_Map);
FormatEx(sQuery, 192, "SELECT style, time, track FROM %splayertimes WHERE map = '%s' ORDER BY time ASC, date ASC LIMIT 1000;", gS_MySQLPrefix, gS_Map);
gH_SQL.Query(SQL_UpdateLeaderboards_Callback, sQuery, 0);
}