From 3b3f16b43c758b7bc6c205269abdb1fa8dc17998 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sun, 3 Nov 2019 17:18:43 +0100 Subject: [PATCH] LagCompensation: fix error in last commit --- LagCompensation/scripting/LagCompensation.sp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/LagCompensation/scripting/LagCompensation.sp b/LagCompensation/scripting/LagCompensation.sp index 2f94839..41f804e 100644 --- a/LagCompensation/scripting/LagCompensation.sp +++ b/LagCompensation/scripting/LagCompensation.sp @@ -494,13 +494,14 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 if(g_aEntityLagData[i].iNotMoving >= MAX_RECORDS) continue; - if(iDelta >= g_aEntityLagData[i].iNumRecords) - iDelta = g_aEntityLagData[i].iNumRecords - 1; - // +1 because the newest record in the list is one tick old // this is because we simulate players first // hence no new entity record was inserted on the current tick - int iRecordIndex = g_aEntityLagData[i].iRecordIndex - iDelta + 1; + iDelta += 1; + if(iDelta >= g_aEntityLagData[i].iNumRecords) + iDelta = g_aEntityLagData[i].iNumRecords - 1; + + int iRecordIndex = g_aEntityLagData[i].iRecordIndex - iDelta; if(iRecordIndex < 0) iRecordIndex += MAX_RECORDS;