diff --git a/addons/sourcemod/scripting/include/shavit.inc b/addons/sourcemod/scripting/include/shavit.inc index dcf1db33..318e6549 100644 --- a/addons/sourcemod/scripting/include/shavit.inc +++ b/addons/sourcemod/scripting/include/shavit.inc @@ -585,9 +585,10 @@ forward void Shavit_OnWorldRecord(int client, int style, float time, int jumps, * @param style Style the record was done on. * @param id Record ID. -1 if mass deletion. * @param track Timer track. + * @param steamid The steamid of wr holder * @noreturn */ -forward void Shavit_OnWRDeleted(int style, int id, int track); +forward void Shavit_OnWRDeleted(int style, int id, int track, int steamid); /** * Called when a player's timer paused. @@ -1132,6 +1133,17 @@ native void Shavit_GetPlayerPB(int client, int style, float &time, int track); */ native float Shavit_GetClientPB(int client, int style, int track); +/** + * can someone make a description of this? thanks + * + * @param client Client index. + * @param style Style to get the PB for. + * @param track Timer track. + * @param time Time to set + * @noreturn + */ +native void Shavit_SetClientPB(int client, int style, int track, float time); + /** * Retrieves the completions of a player. * @@ -1269,7 +1281,7 @@ native float Shavit_GetDistanceOffset(int client, int zonetype); * @param track Timer track. * @return true if replay existed, false otherwise. */ -native bool Shavit_DeleteReplay(const char[] map, int style, int track); +native bool Shavit_DeleteReplay(const char[] map, int style, int track, int steamid = 0); /** * Retrieves the engine time of the replay bot's first frame. diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index f44727fe..253b764a 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -942,6 +942,23 @@ public void Trans_OnRecordCompare(Database db, any data, int numQueries, DBResul hPack.Reset(); int iSteamID = hPack.ReadCell(); + int client = 0; + char szSteamid[32]; + for(int index = 1; index < MaxClients+1; index++) + { + if(IsValidClient(index) && !IsFakeClient(index)) + { + GetClientAuthId(index, AuthId_Steam3, szSteamid, 32); + ReplaceString(szSteamid, 32, "[U:1:", ""); + ReplaceString(szSteamid, 32, "]", ""); + if(iSteamID == StringToInt(szSteamid)) + { + client = index; + break; + } + } + } + for(int i = 0; i < numQueries; i++) { DataPack hQueryPack = view_as(queryData[i]); @@ -954,13 +971,18 @@ public void Trans_OnRecordCompare(Database db, any data, int numQueries, DBResul int iTrack = hQueryPack.ReadCell(); delete hQueryPack; + if(client > 0) + { + Shavit_SetClientPB(client, iStyle, iTrack, 0.0); + } + if(results[i] != null && results[i].FetchRow()) { int iWR = results[i].FetchInt(0); if(iWR == iRecordID) { - Shavit_DeleteReplay(sMap, iStyle, iTrack); + Shavit_DeleteReplay(sMap, iStyle, iTrack, iSteamID); } } } diff --git a/addons/sourcemod/scripting/shavit-hud.sp b/addons/sourcemod/scripting/shavit-hud.sp index c04a09d0..15b7a45b 100644 --- a/addons/sourcemod/scripting/shavit-hud.sp +++ b/addons/sourcemod/scripting/shavit-hud.sp @@ -1704,12 +1704,12 @@ void UpdateTopLeftHUD(int client, bool wait) { if(fTargetPB != 0.0) { - Format(sTopLeft, 128, "%s\n%s (%N)", sTopLeft, sTargetPB, target); + Format(sTopLeft, 128, "%s\n (#%d) %s (%N)", sTopLeft, Shavit_GetRankForTime(style, fTargetPB, track), sTargetPB, target); } if(fSelfPB != 0.0) { - Format(sTopLeft, 128, "%s\n%s (%N)", sTopLeft, sSelfPB, client); + Format(sTopLeft, 128, "%s\n%s (#%d) (%N)", sTopLeft, Shavit_GetRankForTime(style, fSelfPB, track), sSelfPB, client); } } @@ -1759,7 +1759,7 @@ void UpdateKeyHint(int client) { Format(sMessage, 256, "%s%s%T: %.01f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", "HudSync", client, Shavit_GetSync(target)); - if(!gA_StyleSettings[style].bAutobhop && (gI_HUD2Settings[client] & HUD2_PERFS) == 0) + if(!gA_StyleSettings[style].bAutobhop && (gI_HUDSettings[client] & HUD2_PERFS) > 0) { Format(sMessage, 256, "%s\n%T: %.1f", sMessage, "HudPerfs", client, Shavit_GetPerfectJumps(target)); } diff --git a/addons/sourcemod/scripting/shavit-replay.sp b/addons/sourcemod/scripting/shavit-replay.sp index f2c219ca..1b38b447 100644 --- a/addons/sourcemod/scripting/shavit-replay.sp +++ b/addons/sourcemod/scripting/shavit-replay.sp @@ -465,6 +465,7 @@ public int Native_DeleteReplay(Handle handler, int numParams) int iStyle = GetNativeCell(2); int iTrack = GetNativeCell(3); + int iSteamID = GetNativeCell(4); char sTrack[4]; FormatEx(sTrack, 4, "_%d", iTrack); @@ -472,16 +473,11 @@ public int Native_DeleteReplay(Handle handler, int numParams) char sPath[PLATFORM_MAX_PATH]; FormatEx(sPath, PLATFORM_MAX_PATH, "%s/%d/%s%s.replay", gS_ReplayFolder, iStyle, gS_Map, (iTrack > 0)? sTrack:""); - if(!FileExists(sPath) || !DeleteFile(sPath)) + if(!DeleteReplay(iStyle, iTrack, StrEqual(sMap, gS_Map), iSteamID)) { return false; } - if(StrEqual(sMap, gS_Map)) - { - UnloadReplay(iStyle, iTrack); - } - return true; } @@ -1348,7 +1344,7 @@ bool SaveReplay(int style, int track, float time, int steamid, char[] name, int return true; } -bool DeleteReplay(int style, int track) +bool DeleteReplay(int style, int track, bool unload_replay = false, int steamid = 0) { char sTrack[4]; FormatEx(sTrack, 4, "_%d", track); @@ -1356,12 +1352,61 @@ bool DeleteReplay(int style, int track) char sPath[PLATFORM_MAX_PATH]; FormatEx(sPath, PLATFORM_MAX_PATH, "%s/%d/%s%s.replay", gS_ReplayFolder, style, gS_Map, (track > 0)? sTrack:""); - if(!FileExists(sPath) || !DeleteFile(sPath)) + if(!FileExists(sPath)) { return false; } - UnloadReplay(style, track); + if(steamid != 0) + { + File file = OpenFile(sPath, "wb"); + + char szTemp[160]; + file.ReadString(szTemp, 160); + + int iTemp = 0; + file.ReadUint8(iTemp); + file.ReadUint8(iTemp); + file.ReadInt32(iTemp); + file.ReadInt32(iTemp); + int iSteamID = 0; + + if(gA_FrameCache[style][track].iReplayVersion >= 0x04) + { + file.ReadInt32(iSteamID); + } + + else + { + char sAuthID[32]; + file.ReadString(sAuthID, 32); + ReplaceString(sAuthID, 32, "[U:1:", ""); + ReplaceString(sAuthID, 32, "]", ""); + iSteamID = StringToInt(sAuthID); + } + + if(steamid == iSteamID) + { + if(!DeleteFile(sPath)) + { + delete file; + return false; + } + } + delete file; + } + else + { + if(!DeleteFile(sPath)) + { + return false; + } + } + + if(unload_replay) + { + UnloadReplay(style, track); + } return true; } @@ -2242,13 +2287,13 @@ void ClearFrames(int client) gI_PlayerTimerStartFrames[client] = 0; } -public void Shavit_OnWRDeleted(int style, int id, int track) +public void Shavit_OnWRDeleted(int style, int id, int track, int steamid) { float time = Shavit_GetWorldRecord(style, track); if(gA_FrameCache[style][track].iFrameCount > 0 && GetReplayLength(style, track) - gF_Tickrate <= time) // -0.1 to fix rounding issues { - DeleteReplay(style, track); + DeleteReplay(style, track, true, steamid); } } @@ -2884,4 +2929,4 @@ bool File_Copy(const char[] source, const char[] destination) delete file_destination; return true; -} +} \ No newline at end of file diff --git a/addons/sourcemod/scripting/shavit-wr.sp b/addons/sourcemod/scripting/shavit-wr.sp index 6a3b50e7..5f3fc775 100644 --- a/addons/sourcemod/scripting/shavit-wr.sp +++ b/addons/sourcemod/scripting/shavit-wr.sp @@ -102,6 +102,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max { // natives CreateNative("Shavit_GetClientPB", Native_GetClientPB); + CreateNative("Shavit_SetClientPB", Native_SetClientPB); CreateNative("Shavit_GetPlayerPB", Native_GetPlayerPB); CreateNative("Shavit_GetClientCompletions", Native_GetClientCompletions); CreateNative("Shavit_GetRankForTime", Native_GetRankForTime); @@ -135,7 +136,7 @@ public void OnPluginStart() // forwards gH_OnWorldRecord = CreateGlobalForward("Shavit_OnWorldRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_OnFinish_Post = CreateGlobalForward("Shavit_OnFinish_Post", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); - gH_OnWRDeleted = CreateGlobalForward("Shavit_OnWRDeleted", ET_Event, Param_Cell, Param_Cell, Param_Cell); + gH_OnWRDeleted = CreateGlobalForward("Shavit_OnWRDeleted", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_OnWorstRecord = CreateGlobalForward("Shavit_OnWorstRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_OnFinishMessage = CreateGlobalForward("Shavit_OnFinishMessage", ET_Event, Param_Cell, Param_CellByRef, Param_Array, Param_Cell, Param_Cell, Param_String, Param_Cell); @@ -578,6 +579,17 @@ public int Native_GetClientPB(Handle handler, int numParams) return view_as(gF_PlayerRecord[GetNativeCell(1)][GetNativeCell(2)][GetNativeCell(3)]); } +public int Native_SetClientPB(Handle handler, int numParams) +{ + int client = GetNativeCell(1); + int style = GetNativeCell(2); + int track = GetNativeCell(3); + float time = GetNativeCell(4); + + gF_PlayerRecord[client][style][track] = time; + +} + public int Native_GetPlayerPB(Handle handler, int numParams) { SetNativeCellRef(3, gF_PlayerRecord[GetNativeCell(1)][GetNativeCell(2)][GetNativeCell(4)]); @@ -1236,6 +1248,7 @@ public void DeleteConfirm_Callback(Database db, DBResultSet results, const char[ Call_PushCell(iStyle); Call_PushCell(iRecordID); Call_PushCell(iTrack); + Call_PushCell(iSteamID); Call_Finish(); }