mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Record entity flags and movetypes in replays. (#579)
This commit is contained in:
parent
56d37bb871
commit
314406c203
@ -31,8 +31,8 @@
|
||||
|
||||
#define REPLAY_FORMAT_V2 "{SHAVITREPLAYFORMAT}{V2}"
|
||||
#define REPLAY_FORMAT_FINAL "{SHAVITREPLAYFORMAT}{FINAL}"
|
||||
#define REPLAY_FORMAT_SUBVERSION 0x01 // for compatibility, if i ever update this code again
|
||||
#define CELLS_PER_FRAME 6 // origin[3], angles[2], buttons
|
||||
#define REPLAY_FORMAT_SUBVERSION 0x02
|
||||
#define CELLS_PER_FRAME 8 // origin[3], angles[2], buttons, flags, movetype
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
@ -71,7 +71,7 @@ int gI_ReplayBotClient[STYLE_LIMIT];
|
||||
ArrayList gA_Frames[STYLE_LIMIT][TRACKS_SIZE];
|
||||
float gF_StartTick[STYLE_LIMIT];
|
||||
ReplayStatus gRS_ReplayStatus[STYLE_LIMIT];
|
||||
any gA_FrameCache[STYLE_LIMIT][TRACKS_SIZE][3]; // int frame_count, float time, bool new_format
|
||||
any gA_FrameCache[STYLE_LIMIT][TRACKS_SIZE][4]; // int frame_count, float time, bool new_format, int replay_version
|
||||
char gS_ReplayNames[STYLE_LIMIT][TRACKS_SIZE][MAX_NAME_LENGTH];
|
||||
bool gB_ForciblyStopped = false;
|
||||
|
||||
@ -818,8 +818,7 @@ bool LoadReplay(int style, int track, const char[] path)
|
||||
|
||||
if(StrEqual(sExplodedHeader[1], REPLAY_FORMAT_FINAL)) // hopefully, the last of them
|
||||
{
|
||||
// uncomment if ever needed
|
||||
// int iSubVersion = StringToInt(sExplodedHeader[0]);
|
||||
gA_FrameCache[style][track][3] = StringToInt(sExplodedHeader[0]);
|
||||
|
||||
int iTemp = 0;
|
||||
fFile.ReadInt32(iTemp);
|
||||
@ -850,11 +849,19 @@ bool LoadReplay(int style, int track, const char[] path)
|
||||
gH_SQL.Query(SQL_GetUserName_Callback, sQuery, pack, DBPrio_High);
|
||||
}
|
||||
|
||||
any[] aReplayData = new any[CELLS_PER_FRAME];
|
||||
int cells = 8;
|
||||
|
||||
// backwards compatibility
|
||||
if(gA_FrameCache[style][track][3] == 0x01)
|
||||
{
|
||||
cells = 6;
|
||||
}
|
||||
|
||||
any[] aReplayData = new any[cells];
|
||||
|
||||
for(int i = 0; i < gA_FrameCache[style][track][0]; i++)
|
||||
{
|
||||
if(fFile.Read(aReplayData, CELLS_PER_FRAME, 4) >= 0)
|
||||
if(fFile.Read(aReplayData, cells, 4) >= 0)
|
||||
{
|
||||
gA_Frames[style][track].Set(i, view_as<float>(aReplayData[0]), 0);
|
||||
gA_Frames[style][track].Set(i, view_as<float>(aReplayData[1]), 1);
|
||||
@ -862,6 +869,12 @@ bool LoadReplay(int style, int track, const char[] path)
|
||||
gA_Frames[style][track].Set(i, view_as<float>(aReplayData[3]), 3);
|
||||
gA_Frames[style][track].Set(i, view_as<float>(aReplayData[4]), 4);
|
||||
gA_Frames[style][track].Set(i, view_as<int>(aReplayData[5]), 5);
|
||||
|
||||
if(gA_FrameCache[style][track][3] >= 0x02)
|
||||
{
|
||||
gA_Frames[style][track].Set(i, view_as<int>(aReplayData[6]), 6);
|
||||
gA_Frames[style][track].Set(i, view_as<int>(aReplayData[7]), 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1452,6 +1465,23 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
|
||||
buttons = gA_Frames[style][track].Get(gI_ReplayTick[style], 5);
|
||||
|
||||
if(gA_FrameCache[style][track][3] >= 0x02)
|
||||
{
|
||||
SetEntityFlags(client, gA_Frames[style][track].Get(gI_ReplayTick[style], 6));
|
||||
|
||||
MoveType mt = gA_Frames[style][track].Get(gI_ReplayTick[style], 7);
|
||||
|
||||
if(mt == MOVETYPE_WALK || mt == MOVETYPE_LADDER)
|
||||
{
|
||||
SetEntityMoveType(client, mt);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetEntityMoveType(client, MOVETYPE_NOCLIP);
|
||||
}
|
||||
}
|
||||
|
||||
float vecVelocity[3];
|
||||
MakeVectorFromPoints(vecCurrentPosition, vecPosition, vecVelocity);
|
||||
ScaleVector(vecVelocity, gF_Tickrate);
|
||||
@ -1495,6 +1525,8 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
gA_PlayerFrames[client].Set(gI_PlayerFrames[client], angles[1], 4);
|
||||
|
||||
gA_PlayerFrames[client].Set(gI_PlayerFrames[client], buttons, 5);
|
||||
gA_PlayerFrames[client].Set(gI_PlayerFrames[client], GetEntityFlags(client), 6);
|
||||
gA_PlayerFrames[client].Set(gI_PlayerFrames[client], GetEntityMoveType(client), 7);
|
||||
|
||||
gI_PlayerFrames[client]++;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user