From 1ca1c020e95b9a129fe36902f79ff5305f7d8328 Mon Sep 17 00:00:00 2001 From: mariokeks <82907647+mariokeks@users.noreply.github.com> Date: Sun, 21 Jun 2026 20:59:58 +0200 Subject: [PATCH 1/3] Fix always reading from index 0 in the paths ArrayList --- .../scripting/include/offstyledb_shavit.inc | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_shavit.inc b/addons/sourcemod/scripting/include/offstyledb_shavit.inc index 42a2b8c..86cce16 100644 --- a/addons/sourcemod/scripting/include/offstyledb_shavit.inc +++ b/addons/sourcemod/scripting/include/offstyledb_shavit.inc @@ -242,20 +242,37 @@ public void Shavit_AddAdditionalReplayPathsHere(int client, int style, float tim public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name) { - char replayPath[PLATFORM_MAX_PATH]; - if (replaypaths != null && replaypaths.Length > 0) - { - replaypaths.GetString(0, replayPath, sizeof(replayPath)); - } - - // A non-canonical save (isbestreplay=false) is ours only if the path lives in - // our temp dir - other plugins may register their own extra replay paths too. - bool isOurCopy = !isbestreplay && replayPath[0] != '\0' && IsTempReplayPath(replayPath); + if(istoolong) + { + return; + } - if (!isbestreplay && !isOurCopy) - { - return; - } + char replayPath[PLATFORM_MAX_PATH]; + // A non-canonical save (isbestreplay=false) is ours only if the path lives in + // our temp dir - other plugins may register their own extra replay paths too. + bool isOurCopy = false; + + if(isbestreplay) + { + replaypaths.GetString(0, replayPath, sizeof(replayPath)); + } + else + { + for(int i = 0; i < replaypaths.Length; i++) + { + replaypaths.GetString(i, replayPath, sizeof(replayPath)); + if(IsTempReplayPath(replayPath)) + { + isOurCopy = true; + break; + } + } + + if(!isOurCopy) + { + return; + } + } Records_HandleReplaySaved(client, isbestreplay, replayPath, isOurCopy); } From 9a766c0fd40670d61d15091b2dc5338399caafba Mon Sep 17 00:00:00 2001 From: tommy Date: Thu, 27 Aug 2026 10:32:56 -0400 Subject: [PATCH 2/3] Whitespace styling --- .../sourcemod/scripting/include/offstyledb_shavit.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_shavit.inc b/addons/sourcemod/scripting/include/offstyledb_shavit.inc index 86cce16..bf43e1c 100644 --- a/addons/sourcemod/scripting/include/offstyledb_shavit.inc +++ b/addons/sourcemod/scripting/include/offstyledb_shavit.inc @@ -242,7 +242,7 @@ public void Shavit_AddAdditionalReplayPathsHere(int client, int style, float tim public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name) { - if(istoolong) + if (istoolong) { return; } @@ -252,23 +252,23 @@ public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, i // our temp dir - other plugins may register their own extra replay paths too. bool isOurCopy = false; - if(isbestreplay) + if (isbestreplay) { replaypaths.GetString(0, replayPath, sizeof(replayPath)); } else { - for(int i = 0; i < replaypaths.Length; i++) + for (int i = 0; i < replaypaths.Length; i++) { replaypaths.GetString(i, replayPath, sizeof(replayPath)); - if(IsTempReplayPath(replayPath)) + if (IsTempReplayPath(replayPath)) { isOurCopy = true; break; } } - if(!isOurCopy) + if (!isOurCopy) { return; } From 63ee668139bdf265184aebfa1a1249326d920a2d Mon Sep 17 00:00:00 2001 From: tommy Date: Thu, 27 Aug 2026 10:32:56 -0400 Subject: [PATCH 3/3] Guard against empty replaypaths before reading index 0 --- addons/sourcemod/scripting/include/offstyledb_shavit.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_shavit.inc b/addons/sourcemod/scripting/include/offstyledb_shavit.inc index bf43e1c..2e25ad5 100644 --- a/addons/sourcemod/scripting/include/offstyledb_shavit.inc +++ b/addons/sourcemod/scripting/include/offstyledb_shavit.inc @@ -242,7 +242,7 @@ public void Shavit_AddAdditionalReplayPathsHere(int client, int style, float tim public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name) { - if (istoolong) + if (istoolong || replaypaths == null || replaypaths.Length == 0) { return; }