AutoRecorder: make demo maxlength configurable

This commit is contained in:
BotoX 2018-08-09 16:07:22 +02:00
parent c439aa9086
commit f436ed3652

View File

@ -9,12 +9,12 @@ ConVar g_hTimeStart;
ConVar g_hTimeStop;
ConVar g_hFinishMap;
ConVar g_hDemoPath;
ConVar g_hMaxLength;
bool g_bRestartRecording = false;
bool g_bIsRecording = false;
bool g_bIsManual = false;
int g_iRestartRecording;
int g_iStartedRecording;
// Default: o=rx,g=rx,u=rwx | 755
#define DIRECTORY_PERMISSIONS (FPERM_O_READ|FPERM_O_EXEC | FPERM_G_READ|FPERM_G_EXEC | FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC)
@ -37,6 +37,7 @@ public void OnPluginStart()
g_hTimeStop = CreateConVar("sm_autorecord_timestop", "-1", "Hour in the day to stop recording (0-23, -1 disables)");
g_hFinishMap = CreateConVar("sm_autorecord_finishmap", "1", "If 1, continue recording until the map ends", _, true, 0.0, true, 1.0);
g_hDemoPath = CreateConVar("sm_autorecord_path", "demos/", "Path to store recorded demos");
g_hMaxLength = CreateConVar("sm_autorecord_maxlength", "0", "Maximum length of demos in seconds, 0 to disable", _, true, 0.0);
AutoExecConfig(true, "autorecorder");
@ -67,7 +68,8 @@ public void OnPluginStart()
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if(g_bRestartRecording && g_iRestartRecording <= GetTime())
int maxLength = GetConVarInt(g_hMaxLength);
if(g_bIsRecording && maxLength > 0 && GetTime() >= g_iStartedRecording + maxLength)
{
StopRecord();
CheckStatus();
@ -91,9 +93,6 @@ public void OnMapEnd()
{
StopRecord();
g_bIsManual = false;
g_bRestartRecording = false;
g_iRestartRecording = -1;
}
}
@ -206,11 +205,9 @@ void StartRecord()
ServerCommand("tv_record \"%s/auto-%s-%s\"", sPath, sTime, sMap);
g_bIsRecording = true;
g_iStartedRecording = GetTime();
LogMessage("Recording to auto-%s-%s.dem", sTime, sMap);
g_bRestartRecording = true;
g_iRestartRecording = GetTime() + 1800;
}
}
@ -220,8 +217,5 @@ void StopRecord()
{
ServerCommand("tv_stoprecord");
g_bIsRecording = false;
g_bRestartRecording = false;
g_iRestartRecording = -1;
}
}