From fc8b78ae43f76d89157be3a9f799e5f487d049f8 Mon Sep 17 00:00:00 2001 From: rtldg <55846624+rtldg@users.noreply.github.com> Date: Wed, 11 Aug 2021 13:20:42 +0000 Subject: [PATCH] make sure StartReplayFromFile uses delay and fix hud time for customframes --- addons/sourcemod/scripting/include/shavit.inc | 8 ++++---- addons/sourcemod/scripting/shavit-hud.sp | 2 +- addons/sourcemod/scripting/shavit-replay.sp | 8 ++++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/sourcemod/scripting/include/shavit.inc b/addons/sourcemod/scripting/include/shavit.inc index 03540ab6..6b3da5a9 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 "3.0.4" +#define SHAVIT_VERSION "3.0.5" #define STYLE_LIMIT 256 #define MAX_ZONES 64 #define MAX_STAGES 51 // 😐 kind of arbitrary but also some space between this and MAX_ZONES @@ -2035,7 +2035,7 @@ native bool Shavit_IsReplayEntity(int ent); * @param ignorelimit Ignore cvar limit for dynamic bots. * @return Replay entity. 0 is returned if couldn't be created. */ -native int Shavit_StartReplay(int style, int track, float delay, int client, int bot, int type, bool ignorelimit = false); +native int Shavit_StartReplay(int style, int track, float delay, int client, int bot, int type, bool ignorelimit); /** * Starts a replay with a given set of frames. @@ -2052,7 +2052,7 @@ native int Shavit_StartReplay(int style, int track, float delay, int client, int * @param size sizeof(frame_cache_t). Used to throw errors at you if you don't recompile plugins. * @return Replay entity. 0 is returned if couldn't be created. */ -native int Shavit_StartReplayFromFrameCache(int style, int track, float delay, int client, int bot, int type, bool ignorelimit = false, any[] cache, int size = sizeof(frame_cache_t)); +native int Shavit_StartReplayFromFrameCache(int style, int track, float delay, int client, int bot, int type, bool ignorelimit, any[] cache, int size = sizeof(frame_cache_t)); /** * Starts a replay from a replay file. @@ -2068,7 +2068,7 @@ native int Shavit_StartReplayFromFrameCache(int style, int track, float delay, i * @param path File path to replay * @return Replay entity. 0 is returned if couldn't be created. */ -native int Shavit_StartReplayFromFile(int style, int track, float delay, int client, int bot, int type, bool ignorelimit = false, const char[] path); +native int Shavit_StartReplayFromFile(int style, int track, float delay, int client, int bot, int type, bool ignorelimit, const char[] path); /** * Reloads a specific replay into the replay bot cache. diff --git a/addons/sourcemod/scripting/shavit-hud.sp b/addons/sourcemod/scripting/shavit-hud.sp index 7660e495..f05e5dd8 100644 --- a/addons/sourcemod/scripting/shavit-hud.sp +++ b/addons/sourcemod/scripting/shavit-hud.sp @@ -1493,7 +1493,7 @@ void UpdateMainHUD(int client) if(iReplayStyle != -1) { fReplayTime = Shavit_GetReplayTime(target); - fReplayLength = Shavit_GetReplayLength(iReplayStyle, iReplayTrack); + fReplayLength = Shavit_GetReplayCacheLength(target); fSpeedHUD /= Shavit_GetStyleSettingFloat(iReplayStyle, "speed") * Shavit_GetStyleSettingFloat(iReplayStyle, "timescale"); } diff --git a/addons/sourcemod/scripting/shavit-replay.sp b/addons/sourcemod/scripting/shavit-replay.sp index 278833a8..442f0806 100644 --- a/addons/sourcemod/scripting/shavit-replay.sp +++ b/addons/sourcemod/scripting/shavit-replay.sp @@ -110,6 +110,7 @@ enum struct bot_info_t bool bCustomFrames; bool bIgnoreLimit; bool b2x; + float fDelay; frame_cache_t aCache; } @@ -884,6 +885,7 @@ void StartReplay(bot_info_t info, int track, int style, int starter, float delay info.iStarterSerial = (starter > 0) ? GetClientSerial(starter) : 0; info.iTick = 0; //info.iLoopingConfig + info.fDelay = delay; info.hTimer = CreateTimer((delay / 2.0), Timer_StartReplay, info.iEnt, TIMER_FLAG_NO_MAPCHANGE); if (!info.bCustomFrames) @@ -971,6 +973,7 @@ int CreateReplayEntity(int track, int style, float delay, int client, int bot, i info.iStarterSerial = (client > 0) ? GetClientSerial(client) : 0; info.bIgnoreLimit = ignorelimit; info.iLoopingConfig = loopingConfig; + info.fDelay = delay; SetupIfCustomFrames(info, cache); bot = CreateReplayBot(info); @@ -1762,7 +1765,7 @@ int CreateReplayBot(bot_info_t info) } else { - StartReplay(gA_BotInfo[bot], gA_BotInfo[bot].iTrack, gA_BotInfo[bot].iStyle, GetClientFromSerial(info.iStarterSerial), gCV_ReplayDelay.FloatValue); + StartReplay(gA_BotInfo[bot], gA_BotInfo[bot].iTrack, gA_BotInfo[bot].iStyle, GetClientFromSerial(info.iStarterSerial), info.fDelay); } gA_BotInfo[GetClientFromSerial(info.iStarterSerial)].iEnt = bot; @@ -2860,7 +2863,7 @@ Action ReplayOnPlayerRunCmd(bot_info_t info, int &buttons, int &impulse, float v if(info.iTick >= (info.aCache.iFrameCount + info.aCache.iPostFrames + info.aCache.iPreFrames)) { info.iStatus = Replay_End; - info.hTimer = CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_EndReplay, info.iEnt, TIMER_FLAG_NO_MAPCHANGE); + info.hTimer = CreateTimer((info.fDelay / 2.0), Timer_EndReplay, info.iEnt, TIMER_FLAG_NO_MAPCHANGE); return Plugin_Changed; } @@ -3884,6 +3887,7 @@ void ClearBotInfo(bot_info_t info) info.bCustomFrames = false; //info.bIgnoreLimit info.b2x = false; + info.fDelay = 0.0; ClearFrameCache(info.aCache); }