mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Server: fix incorrect calculation of player timebase on bot instances
- Member CPlayer::m_lastUCmdSimulationRemainderTime is set and checked as an int in compiled code, change type from float to int. - Simulation time was calculated incorrectly; brough expression 'CPlayer::m_lastUCmdSimulationRemainderTime * TICK_INTERVAL' into parentheses. - Call to CPlayer::SetTotalExtraClientCmdTimeAttempted() took incorrect parameter value if flSimulationTime < 0.0f, it was supposed to be clamped to 0.0f, but instead, took the value of 'TIME_TO_TICKS( flTimeBase )'.
This commit is contained in:
parent
661874025f
commit
06e995f17b
@ -60,37 +60,29 @@ QAngle* CPlayer::EyeAngles(QAngle* pAngles)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
inline void CPlayer::SetTimeBase(float flTimeBase)
|
inline void CPlayer::SetTimeBase(float flTimeBase)
|
||||||
{
|
{
|
||||||
float flTime = float(TIME_TO_TICKS(flTimeBase));
|
const int nRemainderTime = Max(TIME_TO_TICKS(flTimeBase), 0);
|
||||||
|
SetLastUCmdSimulationRemainderTime(nRemainderTime);
|
||||||
|
|
||||||
if (flTime < 0.0f)
|
const float flAttemptedTime = Max(flTimeBase - (m_lastUCmdSimulationRemainderTime * TICK_INTERVAL), 0.0f);
|
||||||
flTime = 0.0f;
|
SetTotalExtraClientCmdTimeAttempted(flAttemptedTime);
|
||||||
|
|
||||||
SetLastUCmdSimulationRemainderTime(flTime);
|
|
||||||
|
|
||||||
float flSimulationTime = flTimeBase - m_lastUCmdSimulationRemainderTime * TICK_INTERVAL;
|
|
||||||
if (flSimulationTime >= 0.0f)
|
|
||||||
{
|
|
||||||
flTime = flSimulationTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetTotalExtraClientCmdTimeAttempted(flTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Purpose: sets the last user cmd simulation remainder time
|
// Purpose: sets the last user cmd simulation remainder time
|
||||||
// Input : flRemainderTime -
|
// Input : nRemainderTime -
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void CPlayer::SetLastUCmdSimulationRemainderTime(float flRemainderTime)
|
void CPlayer::SetLastUCmdSimulationRemainderTime(int nRemainderTime)
|
||||||
{
|
{
|
||||||
if (m_lastUCmdSimulationRemainderTime != flRemainderTime)
|
if (m_lastUCmdSimulationRemainderTime != nRemainderTime)
|
||||||
{
|
{
|
||||||
edict_t nEdict = NetworkProp()->GetEdict();
|
const edict_t nEdict = NetworkProp()->GetEdict();
|
||||||
|
|
||||||
if (nEdict != FL_EDICT_INVALID)
|
if (nEdict != FL_EDICT_INVALID)
|
||||||
{
|
{
|
||||||
_InterlockedOr16((SHORT*)(*g_pGlobals)->m_pEdicts + nEdict + 32, 0x200u);
|
_InterlockedOr16((SHORT*)(*g_pGlobals)->m_pEdicts + nEdict + 32, 0x200u);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastUCmdSimulationRemainderTime = flRemainderTime;
|
m_lastUCmdSimulationRemainderTime = nRemainderTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +94,8 @@ void CPlayer::SetTotalExtraClientCmdTimeAttempted(float flAttemptedTime)
|
|||||||
{
|
{
|
||||||
if (m_totalExtraClientCmdTimeAttempted != flAttemptedTime)
|
if (m_totalExtraClientCmdTimeAttempted != flAttemptedTime)
|
||||||
{
|
{
|
||||||
edict_t nEdict = NetworkProp()->GetEdict();
|
const edict_t nEdict = NetworkProp()->GetEdict();
|
||||||
|
|
||||||
if (nEdict != FL_EDICT_INVALID)
|
if (nEdict != FL_EDICT_INVALID)
|
||||||
{
|
{
|
||||||
_InterlockedOr16((SHORT*)(*g_pGlobals)->m_pEdicts + nEdict + 32, 0x200u);
|
_InterlockedOr16((SHORT*)(*g_pGlobals)->m_pEdicts + nEdict + 32, 0x200u);
|
||||||
|
@ -247,14 +247,12 @@ public:
|
|||||||
QAngle* EyeAngles(QAngle* pAngles);
|
QAngle* EyeAngles(QAngle* pAngles);
|
||||||
|
|
||||||
void SetTimeBase(float flTimeBase);
|
void SetTimeBase(float flTimeBase);
|
||||||
void SetLastUCmdSimulationRemainderTime(float flRemainderTime);
|
void SetLastUCmdSimulationRemainderTime(int nRemainderTime);
|
||||||
void SetTotalExtraClientCmdTimeAttempted(float flAttemptedTime);
|
void SetTotalExtraClientCmdTimeAttempted(float flAttemptedTime);
|
||||||
|
|
||||||
void ProcessUserCmds(CUserCmd* cmds, int numCmds, int totalCmds,
|
void ProcessUserCmds(CUserCmd* cmds, int numCmds, int totalCmds,
|
||||||
int droppedPackets, bool paused);
|
int droppedPackets, bool paused);
|
||||||
|
|
||||||
void ClampUnlag(CUserCmd* cmd);
|
|
||||||
|
|
||||||
void PlayerRunCommand(CUserCmd* pUserCmd, IMoveHelper* pMover);
|
void PlayerRunCommand(CUserCmd* pUserCmd, IMoveHelper* pMover);
|
||||||
void SetLastUserCommand(CUserCmd* pUserCmd);
|
void SetLastUserCommand(CUserCmd* pUserCmd);
|
||||||
|
|
||||||
@ -576,7 +574,7 @@ private:
|
|||||||
float m_totalFrameTime;
|
float m_totalFrameTime;
|
||||||
float m_joinFrameTime;
|
float m_joinFrameTime;
|
||||||
int m_lastUCmdSimulationTicks;
|
int m_lastUCmdSimulationTicks;
|
||||||
float m_lastUCmdSimulationRemainderTime;
|
int m_lastUCmdSimulationRemainderTime; // Originally float???
|
||||||
float m_totalExtraClientCmdTimeAttempted;
|
float m_totalExtraClientCmdTimeAttempted;
|
||||||
int m_hPlayerViewEntity;
|
int m_hPlayerViewEntity;
|
||||||
bool m_atLeastOneCommandRunThisServerFrame;
|
bool m_atLeastOneCommandRunThisServerFrame;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user