From 1fcb7993fe3de7af0bc16da495cfd07bb7709c04 Mon Sep 17 00:00:00 2001 From: shavit Date: Tue, 16 Jan 2018 10:15:41 +0200 Subject: [PATCH] Added `oldtime` parameter to Shavit_OnFinish --- addons/sourcemod/scripting/include/shavit.inc | 3 ++- addons/sourcemod/scripting/shavit-core.sp | 20 +++++++++++++++---- addons/sourcemod/scripting/shavit-rankings.sp | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/addons/sourcemod/scripting/include/shavit.inc b/addons/sourcemod/scripting/include/shavit.inc index c21d22b2..12153ac2 100644 --- a/addons/sourcemod/scripting/include/shavit.inc +++ b/addons/sourcemod/scripting/include/shavit.inc @@ -360,9 +360,10 @@ forward Action Shavit_OnFinishPre(int client, any snapshot[TIMERSNAPSHOT_SIZE]); * @param strafes Amount of strafes. * @param sync Sync percentage (0.0 to 100.0) or -1.0 when not measured. * @param track Timer track. + * @param oldtime The player's best time on the map before this finish. * @noreturn */ -forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track); +forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime); /** * Like Shavit_OnFinish, but after the insertion query was called. diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index e06280fc..69ef1e32 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -193,7 +193,7 @@ public void OnPluginStart() gH_Forwards_Start = CreateGlobalForward("Shavit_OnStart", ET_Event, Param_Cell, Param_Cell); gH_Forwards_Stop = CreateGlobalForward("Shavit_OnStop", ET_Event, Param_Cell, Param_Cell); gH_Forwards_FinishPre = CreateGlobalForward("Shavit_OnFinishPre", ET_Event, Param_Cell, Param_Array); - gH_Forwards_Finish = CreateGlobalForward("Shavit_OnFinish", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); + gH_Forwards_Finish = CreateGlobalForward("Shavit_OnFinish", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_Forwards_OnRestart = CreateGlobalForward("Shavit_OnRestart", ET_Event, Param_Cell, Param_Cell); gH_Forwards_OnEnd = CreateGlobalForward("Shavit_OnEnd", ET_Event, Param_Cell, Param_Cell); gH_Forwards_OnPause = CreateGlobalForward("Shavit_OnPause", ET_Event, Param_Cell, Param_Cell); @@ -1035,25 +1035,37 @@ public int Native_FinishMap(Handle handler, int numParams) Call_StartForward(gH_Forwards_Finish); Call_PushCell(client); + int style = 0; + int track = Track_Main; + if(result == Plugin_Continue) { - Call_PushCell(gBS_Style[client]); + Call_PushCell(style = gBS_Style[client]); Call_PushCell(CalculateTime(client)); Call_PushCell(gI_Jumps[client]); Call_PushCell(gI_Strafes[client]); Call_PushCell((gA_StyleSettings[gBS_Style[client]][bSync])? (gI_GoodGains[client] == 0)? 0.0:(gI_GoodGains[client] / float(gI_TotalMeasures[client]) * 100.0):-1.0); + Call_PushCell(track = gI_Track[client]); } else { - Call_PushCell(snapshot[bsStyle]); + Call_PushCell(style = snapshot[bsStyle]); Call_PushCell(snapshot[fCurrentTime]); Call_PushCell(snapshot[iJumps]); Call_PushCell(snapshot[iStrafes]); Call_PushCell((gA_StyleSettings[snapshot[bsStyle]][bSync])? (snapshot[iGoodGains] == 0)? 0.0:(snapshot[iGoodGains] / float(snapshot[iTotalMeasures]) * 100.0):-1.0); + Call_PushCell(track = snapshot[iTimerTrack]); } - Call_PushCell(gI_Track[client]); + float oldtime = 0.0; + + if(gB_WR) + { + Shavit_GetPlayerPB(client, style, oldtime, track); + } + + Call_PushCell(oldtime); Call_Finish(); StopTimer(client); diff --git a/addons/sourcemod/scripting/shavit-rankings.sp b/addons/sourcemod/scripting/shavit-rankings.sp index 53ab3078..19f1e744 100644 --- a/addons/sourcemod/scripting/shavit-rankings.sp +++ b/addons/sourcemod/scripting/shavit-rankings.sp @@ -755,8 +755,8 @@ public void SQL_Recalculate_Callback(Database db, DBResultSet results, const cha int serial = data.ReadCell(); int size = data.ReadCell(); - char[] sMap = new char[size + 1]; - ReadPackString(data, sMap, size + 1); + char[] sMap = new char[size+1]; + data.ReadString(sMap, size+1); int track = data.ReadCell(); int style = data.ReadCell();