Skip to content

Commit

Permalink
make sure StartReplayFromFile uses delay and fix hud time for customf…
Browse files Browse the repository at this point in the history
…rames
  • Loading branch information
rtldg committed Aug 11, 2021
1 parent 6bcb16b commit fc8b78a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions addons/sourcemod/scripting/include/shavit.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/shavit-hud.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
8 changes: 6 additions & 2 deletions addons/sourcemod/scripting/shavit-replay.sp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ enum struct bot_info_t
bool bCustomFrames;
bool bIgnoreLimit;
bool b2x;
float fDelay;
frame_cache_t aCache;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fc8b78a

Please sign in to comment.