diff --git a/addons/sourcemod/scripting/include/shavit.inc b/addons/sourcemod/scripting/include/shavit.inc index fc55b8fc..80447461 100644 --- a/addons/sourcemod/scripting/include/shavit.inc +++ b/addons/sourcemod/scripting/include/shavit.inc @@ -23,7 +23,7 @@ #endif #define _shavit_included -#define SHAVIT_VERSION "2.3.2" +#define SHAVIT_VERSION "2.3.3" #define STYLE_LIMIT 256 #define MAX_ZONES 64 #define MAX_NAME_LENGTH_SQL 32 @@ -545,6 +545,22 @@ forward void Shavit_OnWorstRecord(int client, int style, float time, int jumps, */ forward void Shavit_OnTierAssigned(const char[] map, int tier); +/** + * Called when replay playback starts. + * + * @param client Client index for the bot. + * @noreturn + */ +forward void Shavit_OnReplayStart(int client); + +/** + * Called when replay playback ends. + * + * @param client Client index for the bot. + * @noreturn + */ +forward void Shavit_OnReplayEnd(int client); + /** * Returns the game type the server is running. * diff --git a/addons/sourcemod/scripting/shavit-hud.sp b/addons/sourcemod/scripting/shavit-hud.sp index 9499f01d..cbaa3bcc 100644 --- a/addons/sourcemod/scripting/shavit-hud.sp +++ b/addons/sourcemod/scripting/shavit-hud.sp @@ -756,7 +756,7 @@ void UpdateHUD(int client) else if(fPB > 0.0) { - Format(sHintText, 512, "%s%T: %s (#%d)", sHintText, "HudBestText", client, sPB, (Shavit_GetRankForTime(style, fPB, track) - 1)); + Format(sHintText, 512, "%s%T: %s (#%d)", sHintText, "HudBestText", client, sPB, Shavit_GetRankForTime(style, fPB, track)); } if(status >= Timer_Running) @@ -1081,7 +1081,7 @@ void UpdateTopLeftHUD(int client, bool wait) if(fPBTime != 0.0) { - FormatEx(sTopLeft, 128, "WR: %s (%s)\n%T: %s (#%d)", sWRTime, sWRName, "HudBestText", client, sPBTime, (Shavit_GetRankForTime(style, fPBTime, track) - 1)); + FormatEx(sTopLeft, 128, "WR: %s (%s)\n%T: %s (#%d)", sWRTime, sWRName, "HudBestText", client, sPBTime, Shavit_GetRankForTime(style, fPBTime, track)); } else diff --git a/addons/sourcemod/scripting/shavit-rankings.sp b/addons/sourcemod/scripting/shavit-rankings.sp index c58ee20c..5bcb82a4 100644 --- a/addons/sourcemod/scripting/shavit-rankings.sp +++ b/addons/sourcemod/scripting/shavit-rankings.sp @@ -304,6 +304,7 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha RunLongFastQuery(bSuccess, "CREATE GetWeightedPoints", "CREATE FUNCTION GetWeightedPoints(authid CHAR(32)) " ... "RETURNS FLOAT " ... + "READS SQL DATA " ... "BEGIN " ... "DECLARE p FLOAT; " ... "DECLARE total FLOAT DEFAULT 0.0; " ... @@ -327,6 +328,7 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha RunLongFastQuery(bSuccess, "CREATE GetRecordPoints", "CREATE FUNCTION GetRecordPoints(rstyle INT, rtrack INT, rtime FLOAT, rmap CHAR(128), pointspertier FLOAT, stylemultiplier FLOAT) " ... "RETURNS FLOAT " ... + "READS SQL DATA " ... "BEGIN " ... "DECLARE pwr, ppoints FLOAT DEFAULT 0.0; " ... "DECLARE ptier INT DEFAULT 1; " ... diff --git a/addons/sourcemod/scripting/shavit-replay.sp b/addons/sourcemod/scripting/shavit-replay.sp index a58ba7fa..fb273bd3 100644 --- a/addons/sourcemod/scripting/shavit-replay.sp +++ b/addons/sourcemod/scripting/shavit-replay.sp @@ -89,6 +89,10 @@ int gI_Track[MAXPLAYERS+1]; bool gB_Late = false; +// forwards +Handle gH_OnReplayStart = null; +Handle gH_OnReplayEnd = null; + // server specific float gF_Tickrate = 0.0; char gS_Map[160]; @@ -196,6 +200,10 @@ public void OnPluginStart() LoadTranslations("shavit-common.phrases"); LoadTranslations("shavit-replay.phrases"); + // forwards + gH_OnReplayStart = CreateGlobalForward("Shavit_OnReplayStart", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); + gH_OnReplayEnd = CreateGlobalForward("Shavit_OnReplayEnd", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); + // game specific gEV_Type = GetEngineVersion(); gF_Tickrate = (1.0 / GetTickInterval()); @@ -1737,6 +1745,10 @@ public Action Timer_EndReplay(Handle Timer, any data) gI_ReplayTick[data] = 0; + Call_StartForward(gH_OnReplayEnd); + Call_PushCell(gI_ReplayBotClient[data]); + Call_Finish(); + if(gI_ReplayBotClient[data] != gA_CentralCache[iCentralClient]) { gRS_ReplayStatus[data] = Replay_Start; @@ -1760,6 +1772,10 @@ public Action Timer_StartReplay(Handle Timer, any data) return Plugin_Stop; } + Call_StartForward(gH_OnReplayStart); + Call_PushCell(gI_ReplayBotClient[data]); + Call_Finish(); + gRS_ReplayStatus[data] = gA_CentralCache[iCentralReplayStatus] = Replay_Running; return Plugin_Stop; diff --git a/addons/sourcemod/scripting/shavit-sounds.sp b/addons/sourcemod/scripting/shavit-sounds.sp index 1ea617ad..34e1ee24 100644 --- a/addons/sourcemod/scripting/shavit-sounds.sp +++ b/addons/sourcemod/scripting/shavit-sounds.sp @@ -29,8 +29,6 @@ bool gB_HUD; -EngineVersion gEV_Type = Engine_Unknown; - ArrayList gA_FirstSounds = null; ArrayList gA_PersonalSounds = null; ArrayList gA_WorldSounds = null; @@ -70,9 +68,6 @@ public void OnAllPluginsLoaded() public void OnPluginStart() { - // game specific - gEV_Type = GetEngineVersion(); - // cache gA_FirstSounds = new ArrayList(PLATFORM_MAX_PATH); gA_PersonalSounds = new ArrayList(PLATFORM_MAX_PATH); @@ -182,7 +177,7 @@ public void OnMapStart() gSM_RankSounds.SetString(sRank, sExploded[1]); } - if(PrecacheSoundAny(sExploded[1])) + if(PrecacheSound(sExploded[1], true)) { FormatEx(sDownloadString, PLATFORM_MAX_PATH, "sound/%s", sExploded[1]); AddFileToDownloadsTable(sDownloadString); @@ -198,28 +193,6 @@ public void OnMapStart() delete fFile; } -bool PrecacheSoundAny(const char[] path) -{ - if(gEV_Type == Engine_CSGO) - { - char sCSGOPath[PLATFORM_MAX_PATH]; - FormatEx(sCSGOPath, PLATFORM_MAX_PATH, "*%s", path); - - static int table = INVALID_STRING_TABLE; - - if(table == INVALID_STRING_TABLE) - { - table = FindStringTable("soundprecache"); - } - - AddToStringTable(table, sCSGOPath); - - return true; - } - - return PrecacheSound(path, true); -} - public void Shavit_OnFinish_Post(int client, int style, float time, int jumps, int strafes, float sync, int rank, int overwrite, int track) { float fOldTime = 0.0; @@ -303,11 +276,6 @@ void PlayEventSound(int client, bool everyone, char[] sound) if(count > 0) { - if(gEV_Type == Engine_CSGO) - { - Format(sound, PLATFORM_MAX_PATH, "*%s", sound); - } - EmitSound(clients, count, sound); } } diff --git a/addons/sourcemod/scripting/shavit-wr.sp b/addons/sourcemod/scripting/shavit-wr.sp index 0d4ac6aa..f7391dfb 100644 --- a/addons/sourcemod/scripting/shavit-wr.sp +++ b/addons/sourcemod/scripting/shavit-wr.sp @@ -127,9 +127,9 @@ public void OnPluginStart() LoadTranslations("shavit-common.phrases"); LoadTranslations("shavit-wr.phrases"); - // debug because I was making this all by myself and no one wanted to help me *sniff* #if defined DEBUG RegConsoleCmd("sm_junk", Command_Junk); + RegConsoleCmd("sm_printleaderboards", Command_PrintLeaderboards); #endif // forwards @@ -652,6 +652,21 @@ public Action Command_Junk(int client, int args) return Plugin_Handled; } + +public Action Command_PrintLeaderboards(int client, int args) +{ + ReplyToCommand(client, "Track: Main - Style: 0"); + ReplyToCommand(client, "Current PB: %f", gF_PlayerRecord[client][0][0]); + ReplyToCommand(client, "Count: %d", gI_RecordAmount[0][0]); + ReplyToCommand(client, "Rank: %d", Shavit_GetRankForTime(0, gF_PlayerRecord[client][0][0], 0)); + + for(int i = 0; i < gI_RecordAmount[0][0]; i++) + { + ReplyToCommand(client, "#%d: %f", i, gA_Leaderboard[0][0].Get(i)); + } + + return Plugin_Handled; +} #endif int GetTrackRecordCount(int track) @@ -2348,7 +2363,7 @@ int GetRankForTime(int style, float time, int track) { for(int i = 0; i < gI_RecordAmount[style][track]; i++) { - if(time < gA_Leaderboard[style][track].Get(i)) + if(time <= gA_Leaderboard[style][track].Get(i)) { return ++i; }