mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-08 02:48:26 +00:00
fix the replay recording after splitting up the files
This commit is contained in:
parent
2e579b82ef
commit
1140769b62
@ -1,4 +1,18 @@
|
|||||||
|
|
||||||
|
// 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)
|
stock bool Shavit_ReplayEnabledStyle(int style)
|
||||||
{
|
{
|
||||||
return !Shavit_GetStyleSettingBool(style, "unranked") && !Shavit_GetStyleSettingBool(style, "noreplay");
|
return !Shavit_GetStyleSettingBool(style, "unranked") && !Shavit_GetStyleSettingBool(style, "noreplay");
|
||||||
|
|||||||
@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
|
#include <sdktools>
|
||||||
|
#include <convar_class>
|
||||||
|
|
||||||
#include <shavit>
|
#include <shavit>
|
||||||
|
|
||||||
@ -33,9 +35,30 @@ public Plugin myinfo =
|
|||||||
url = "https://github.com/shavitush/bhoptimer"
|
url = "https://github.com/shavitush/bhoptimer"
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gB_Late = false;
|
#define FRAMES_PER_WRITE 100 // amounts of frames to write per read/write call
|
||||||
EngineVersion gEV_Type = Engine_Unknown;
|
|
||||||
|
|
||||||
|
enum struct finished_run_info
|
||||||
|
{
|
||||||
|
int iSteamID;
|
||||||
|
int style;
|
||||||
|
float time;
|
||||||
|
int jumps;
|
||||||
|
int strafes;
|
||||||
|
float sync;
|
||||||
|
int track;
|
||||||
|
float oldtime;
|
||||||
|
float perfs;
|
||||||
|
float avgvel;
|
||||||
|
float maxvel;
|
||||||
|
int timestamp;
|
||||||
|
float fZoneOffset[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gB_Late = false;
|
||||||
|
char gS_Map[PLATFORM_MAX_PATH];
|
||||||
|
float gF_Tickrate = 0.0;
|
||||||
|
|
||||||
|
int gI_Styles = 0;
|
||||||
char gS_ReplayFolder[PLATFORM_MAX_PATH];
|
char gS_ReplayFolder[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
Convar gCV_Enabled = null;
|
Convar gCV_Enabled = null;
|
||||||
@ -62,6 +85,8 @@ float gF_NextFrameTime[MAXPLAYERS+1];
|
|||||||
int gI_HijackFrames[MAXPLAYERS+1];
|
int gI_HijackFrames[MAXPLAYERS+1];
|
||||||
float gF_HijackedAngles[MAXPLAYERS+1][2];
|
float gF_HijackedAngles[MAXPLAYERS+1][2];
|
||||||
|
|
||||||
|
//#include <TickRateControl>
|
||||||
|
forward void TickRate_OnTickRateChanged(float fOld, float fNew);
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
{
|
{
|
||||||
@ -72,7 +97,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
CreateNative("Shavit_SetReplayData", Native_SetReplayData);
|
CreateNative("Shavit_SetReplayData", Native_SetReplayData);
|
||||||
CreateNative("Shavit_SetPlayerPreFrames", Native_SetPlayerPreFrames);
|
CreateNative("Shavit_SetPlayerPreFrames", Native_SetPlayerPreFrames);
|
||||||
|
|
||||||
RegPluginLibrary("shavit-replay-humans");
|
RegPluginLibrary("shavit-replay-recorder");
|
||||||
|
|
||||||
gB_Late = late;
|
gB_Late = late;
|
||||||
|
|
||||||
@ -89,6 +114,19 @@ public void OnPluginStart()
|
|||||||
gCV_PreRunAlways = new Convar("shavit_replay_prerun_always", "1", "Record prerun frames outside the start zone?", 0, true, 0.0, true, 1.0);
|
gCV_PreRunAlways = new Convar("shavit_replay_prerun_always", "1", "Record prerun frames outside the start zone?", 0, true, 0.0, true, 1.0);
|
||||||
gCV_PlaybackPreRunTime = new Convar("shavit_replay_preruntime", "1.5", "Time (in seconds) to record before a player leaves start zone.", 0, true, 0.0, true, 2.0);
|
gCV_PlaybackPreRunTime = new Convar("shavit_replay_preruntime", "1.5", "Time (in seconds) to record before a player leaves start zone.", 0, true, 0.0, true, 2.0);
|
||||||
gCV_TimeLimit = new Convar("shavit_replay_timelimit", "7200.0", "Maximum amount of time (in seconds) to allow saving to disk.\nDefault is 7200 (2 hours)\n0 - Disabled");
|
gCV_TimeLimit = new Convar("shavit_replay_timelimit", "7200.0", "Maximum amount of time (in seconds) to allow saving to disk.\nDefault is 7200 (2 hours)\n0 - Disabled");
|
||||||
|
|
||||||
|
gF_Tickrate = (1.0 / GetTickInterval());
|
||||||
|
|
||||||
|
if (gB_Late)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if (IsValidClient(i) && !IsFakeClient(i))
|
||||||
|
{
|
||||||
|
OnClientPutInServer(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadReplayConfig()
|
bool LoadReplayConfig()
|
||||||
@ -152,6 +190,11 @@ public void OnClientDisconnect_Post(int client)
|
|||||||
delete gA_PlayerFrames[client];
|
delete gA_PlayerFrames[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TickRate_OnTickRateChanged(float fOld, float fNew)
|
||||||
|
{
|
||||||
|
gF_Tickrate = fNew;
|
||||||
|
}
|
||||||
|
|
||||||
void ClearFrames(int client)
|
void ClearFrames(int client)
|
||||||
{
|
{
|
||||||
delete gA_PlayerFrames[client];
|
delete gA_PlayerFrames[client];
|
||||||
@ -250,7 +293,7 @@ void DoReplaySaverCallbacks(int iSteamID, int client, int style, float time, int
|
|||||||
|
|
||||||
bool isTooLong = (gCV_TimeLimit.FloatValue > 0.0 && time > gCV_TimeLimit.FloatValue);
|
bool isTooLong = (gCV_TimeLimit.FloatValue > 0.0 && time > gCV_TimeLimit.FloatValue);
|
||||||
|
|
||||||
float length = GetReplayLength(style, track, gA_FrameCache[style][track]);
|
float length = Shavit_GetReplayLength(style, track);
|
||||||
bool isBestReplay = (length == 0.0 || time < length);
|
bool isBestReplay = (length == 0.0 || time < length);
|
||||||
|
|
||||||
Action action = Plugin_Continue;
|
Action action = Plugin_Continue;
|
||||||
@ -306,7 +349,7 @@ void DoReplaySaverCallbacks(int iSteamID, int client, int style, float time, int
|
|||||||
Call_PushCell(makeCopy);
|
Call_PushCell(makeCopy);
|
||||||
Call_PushString(sPath);
|
Call_PushString(sPath);
|
||||||
Call_PushCell(gA_PlayerFrames[client]);
|
Call_PushCell(gA_PlayerFrames[client]);
|
||||||
Call_PushCell(preframes);
|
Call_PushCell(gI_PlayerPrerunFrames[client]);
|
||||||
Call_PushCell(postframes);
|
Call_PushCell(postframes);
|
||||||
Call_PushString(sName);
|
Call_PushString(sName);
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
@ -445,15 +488,14 @@ void WriteReplayHeader(File fFile, int style, int track, float time, int steamid
|
|||||||
fFile.WriteInt32(view_as<int>(fZoneOffset[1]));
|
fFile.WriteInt32(view_as<int>(fZoneOffset[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
stock int LimitMoveVelFloat(float vel)
|
|
||||||
{
|
|
||||||
int x = RoundToCeil(vel);
|
|
||||||
return ((x < -666) ? -666 : ((x > 666) ? 666 : x)) & 0xFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, int mouse[2])
|
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, int mouse[2])
|
||||||
{
|
{
|
||||||
if (!gB_GrabbingPostFrames[client] || !(Shavit_ReplayEnabledStyle(style) && status == Timer_Running))
|
if (!gA_PlayerFrames[client])
|
||||||
|
{
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gB_GrabbingPostFrames[client] && !(Shavit_ReplayEnabledStyle(style) && status == Timer_Running))
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@ -472,7 +514,11 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
|||||||
|
|
||||||
if (gF_NextFrameTime[client] > 0.0)
|
if (gF_NextFrameTime[client] > 0.0)
|
||||||
{
|
{
|
||||||
gF_NextFrameTime[client] -= fTimescale;
|
if (fTimescale != -1.0)
|
||||||
|
{
|
||||||
|
gF_NextFrameTime[client] -= fTimescale;
|
||||||
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,7 +554,10 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
|||||||
|
|
||||||
gA_PlayerFrames[client].SetArray(gI_PlayerFrames[client]++, aFrame, sizeof(frame_t));
|
gA_PlayerFrames[client].SetArray(gI_PlayerFrames[client]++, aFrame, sizeof(frame_t));
|
||||||
|
|
||||||
gF_NextFrameTime[client] += (1.0 - fTimescale);
|
if (fTimescale != -1.0)
|
||||||
|
{
|
||||||
|
gF_NextFrameTime[client] += (1.0 - fTimescale);
|
||||||
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@ -40,21 +40,6 @@
|
|||||||
//#include <TickRateControl>
|
//#include <TickRateControl>
|
||||||
forward void TickRate_OnTickRateChanged(float fOld, float fNew);
|
forward void TickRate_OnTickRateChanged(float fOld, float fNew);
|
||||||
|
|
||||||
// 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
|
|
||||||
#define REPLAY_FORMAT_CURRENT_USED_CELLS 8
|
|
||||||
#define FRAMES_PER_WRITE 100 // amounts of frames to write per read/write call
|
|
||||||
#define MAX_LOOPING_BOT_CONFIGS 24
|
#define MAX_LOOPING_BOT_CONFIGS 24
|
||||||
#define HACKY_CLIENT_IDX_PROP "m_iTeamNum" // I store the client owner idx in this for Replay_Prop. My brain is too powerful.
|
#define HACKY_CLIENT_IDX_PROP "m_iTeamNum" // I store the client owner idx in this for Replay_Prop. My brain is too powerful.
|
||||||
|
|
||||||
@ -116,23 +101,6 @@ enum struct bot_info_t
|
|||||||
frame_cache_t aCache;
|
frame_cache_t aCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum struct finished_run_info
|
|
||||||
{
|
|
||||||
int iSteamID;
|
|
||||||
int style;
|
|
||||||
float time;
|
|
||||||
int jumps;
|
|
||||||
int strafes;
|
|
||||||
float sync;
|
|
||||||
int track;
|
|
||||||
float oldtime;
|
|
||||||
float perfs;
|
|
||||||
float avgvel;
|
|
||||||
float maxvel;
|
|
||||||
int timestamp;
|
|
||||||
float fZoneOffset[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
iBotShooting_Attack1 = (1 << 0),
|
iBotShooting_Attack1 = (1 << 0),
|
||||||
@ -1574,7 +1542,7 @@ void CreateAllNavFiles()
|
|||||||
|
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
if(!LoadStyling())
|
if (!LoadStyling())
|
||||||
{
|
{
|
||||||
SetFailState("Could not load the replay bots' configuration file. Make sure it exists (addons/sourcemod/configs/shavit-replay.cfg) and follows the proper syntax!");
|
SetFailState("Could not load the replay bots' configuration file. Make sure it exists (addons/sourcemod/configs/shavit-replay.cfg) and follows the proper syntax!");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user