mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-16 03:07:18 +00:00
60 lines
2.0 KiB
SourcePawn
60 lines
2.0 KiB
SourcePawn
|
|
// History of REPLAY_FORMAT_SUBVERSION:
|
|
// 0x01: standard origin[3], angles[2], and buttons
|
|
// 0x02: flags added movetype added
|
|
// 0x03: integrity stuff: style, track, and map added to header. preframe count added (unimplemented until later though)
|
|
// 0x04: steamid/accountid written as a 32-bit int instead of a string
|
|
// 0x05: postframes & fTickrate added
|
|
// 0x06: mousexy and vel added
|
|
// 0x07: fixed iFrameCount because postframes were included in the value when they shouldn't be
|
|
// 0x08: added zone-offsets to header
|
|
|
|
#define REPLAY_FORMAT_V2 "{SHAVITREPLAYFORMAT}{V2}"
|
|
#define REPLAY_FORMAT_FINAL "{SHAVITREPLAYFORMAT}{FINAL}"
|
|
#define REPLAY_FORMAT_SUBVERSION 0x08
|
|
|
|
stock bool Shavit_ReplayEnabledStyle(int style)
|
|
{
|
|
return !Shavit_GetStyleSettingBool(style, "unranked") && !Shavit_GetStyleSettingBool(style, "noreplay");
|
|
}
|
|
|
|
stock void Shavit_Replay_CreateDirectories(const char[] sReplayFolder, int styles)
|
|
{
|
|
if (!DirExists(sReplayFolder) && !CreateDirectory(sReplayFolder, 511))
|
|
{
|
|
SetFailState("Failed to create replay folder (%s). Make sure you have file permissions", sReplayFolder);
|
|
}
|
|
|
|
char sPath[PLATFORM_MAX_PATH];
|
|
FormatEx(sPath, PLATFORM_MAX_PATH, "%s/copy", sReplayFolder);
|
|
|
|
if (!DirExists(sPath) && !CreateDirectory(sPath, 511))
|
|
{
|
|
SetFailState("Failed to create replay copy folder (%s). Make sure you have file permissions", sPath);
|
|
}
|
|
|
|
for(int i = 0; i < styles; i++)
|
|
{
|
|
if (!Shavit_ReplayEnabledStyle(i))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
FormatEx(sPath, PLATFORM_MAX_PATH, "%s/%d", sReplayFolder, i);
|
|
|
|
if (!DirExists(sPath) && !CreateDirectory(sPath, 511))
|
|
{
|
|
SetFailState("Failed to create replay style folder (%s). Make sure you have file permissions", sPath);
|
|
}
|
|
}
|
|
|
|
// Test to see if replay file creation even works...
|
|
FormatEx(sPath, sizeof(sPath), "%s/0/faketestfile_69.replay", sReplayFolder);
|
|
File fTest = OpenFile(sPath, "wb+");
|
|
CloseHandle(fTest);
|
|
|
|
if (fTest == null)
|
|
{
|
|
SetFailState("Failed to write to replay folder (%s). Make sure you have file permissions.", sReplayFolder);
|
|
}
|
|
} |