mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 02:18:26 +00:00
Fixed issues with replay playback (#521)
This commit is contained in:
parent
dd5090d286
commit
6f42a78416
@ -27,6 +27,7 @@
|
|||||||
#include <shavit>
|
#include <shavit>
|
||||||
|
|
||||||
#define REPLAY_FORMAT_V2 "{SHAVITREPLAYFORMAT}{V2}"
|
#define REPLAY_FORMAT_V2 "{SHAVITREPLAYFORMAT}{V2}"
|
||||||
|
// #define DEBUG
|
||||||
|
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
@ -760,7 +761,8 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEntProp(client, Prop_Data, "m_CollisionGroup", 2);
|
SetEntProp(client, Prop_Data, "m_CollisionGroup", 1);
|
||||||
|
SetEntityMoveType(client, MOVETYPE_NOCLIP);
|
||||||
|
|
||||||
bool central = (gA_CentralCache[iCentralClient] == client);
|
bool central = (gA_CentralCache[iCentralClient] == client);
|
||||||
bool idle = (central && gA_CentralCache[iCentralReplayStatus] == Replay_Idle);
|
bool idle = (central && gA_CentralCache[iCentralReplayStatus] == Replay_Idle);
|
||||||
@ -981,6 +983,10 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
{
|
{
|
||||||
buttons = 0;
|
buttons = 0;
|
||||||
|
|
||||||
|
vel[0] = 0.0;
|
||||||
|
vel[1] = 0.0;
|
||||||
|
// vel[2] = 0.0; // i doubt this is needed
|
||||||
|
|
||||||
if(gA_Frames[style][track] == null || gI_FrameCount[style][track] <= 0) // if no replay is loaded
|
if(gA_Frames[style][track] == null || gI_FrameCount[style][track] <= 0) // if no replay is loaded
|
||||||
{
|
{
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
@ -1027,8 +1033,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
|
|
||||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_EndReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer((gF_ReplayDelay / 2.0), Timer_EndReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
|
|
||||||
SetEntityMoveType(client, MOVETYPE_NOCLIP);
|
|
||||||
|
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,8 +1041,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
gF_StartTick[style] = GetEngineTime();
|
gF_StartTick[style] = GetEngineTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEntityMoveType(client, ((GetEntityFlags(client) & FL_ONGROUND) > 0)? MOVETYPE_WALK:MOVETYPE_NOCLIP);
|
|
||||||
|
|
||||||
vecPosition[0] = gA_Frames[style][track].Get(gI_ReplayTick[style], 0);
|
vecPosition[0] = gA_Frames[style][track].Get(gI_ReplayTick[style], 0);
|
||||||
vecPosition[1] = gA_Frames[style][track].Get(gI_ReplayTick[style], 1);
|
vecPosition[1] = gA_Frames[style][track].Get(gI_ReplayTick[style], 1);
|
||||||
vecPosition[2] = gA_Frames[style][track].Get(gI_ReplayTick[style], 2);
|
vecPosition[2] = gA_Frames[style][track].Get(gI_ReplayTick[style], 2);
|
||||||
@ -1052,17 +1054,28 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
MakeVectorFromPoints(vecCurrentPosition, vecPosition, vecVelocity);
|
MakeVectorFromPoints(vecCurrentPosition, vecPosition, vecVelocity);
|
||||||
ScaleVector(vecVelocity, gF_Tickrate);
|
ScaleVector(vecVelocity, gF_Tickrate);
|
||||||
|
|
||||||
float fDistance = GetVectorDistance(vecCurrentPosition, vecPosition);
|
if((gI_ReplayTick[style] % RoundToFloor(gF_Tickrate * 1.5)) == 0)
|
||||||
|
|
||||||
if((gI_ReplayTick[style] % RoundToFloor(gF_Tickrate * 1.5)) == 0 && GetVectorLength(vecVelocity) < 2.0 * fDistance)
|
|
||||||
{
|
{
|
||||||
TeleportEntity(client, vecPosition, vecAngles, vecVelocity);
|
float vecLastPosition[3];
|
||||||
|
vecLastPosition[0] = gA_Frames[style][track].Get(gI_ReplayTick[style] - 1, 0);
|
||||||
|
vecLastPosition[1] = gA_Frames[style][track].Get(gI_ReplayTick[style] - 1, 1);
|
||||||
|
vecLastPosition[2] = gA_Frames[style][track].Get(gI_ReplayTick[style] - 1, 2);
|
||||||
|
|
||||||
|
#if defined DEBUG
|
||||||
|
PrintToChatAll("vecVelocity: %.02f | dist %.02f", GetVectorLength(vecVelocity), GetVectorDistance(vecLastPosition, vecPosition) * gF_Tickrate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(GetVectorLength(vecVelocity) / (GetVectorDistance(vecLastPosition, vecPosition) * gF_Tickrate) > 2.0)
|
||||||
|
{
|
||||||
|
MakeVectorFromPoints(vecLastPosition, vecPosition, vecVelocity);
|
||||||
|
ScaleVector(vecVelocity, gF_Tickrate);
|
||||||
|
TeleportEntity(client, vecLastPosition, vecAngles, vecVelocity);
|
||||||
|
|
||||||
|
return Plugin_Changed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TeleportEntity(client, NULL_VECTOR, vecAngles, vecVelocity);
|
TeleportEntity(client, NULL_VECTOR, vecAngles, vecVelocity);
|
||||||
}
|
|
||||||
|
|
||||||
return Plugin_Changed;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user