Fix prediction when chat is enabled

This commit is contained in:
trml 2020-07-15 03:15:35 +02:00
parent d57c8ef463
commit b354e034fc
2 changed files with 26 additions and 0 deletions

View file

@ -497,6 +497,10 @@ void CCharacter::GiveNinja()
void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
{
// skip the input if chat is active
if(pNewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)
return;
// copy new input
mem_copy(&m_Input, pNewInput, sizeof(m_Input));
//m_NumInputs++;
@ -510,6 +514,15 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
{
// skip the input if chat is active
if(pNewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)
{
// reset input
ResetInput();
return;
}
m_NumInputs++;
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
@ -527,6 +540,18 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
}
void CCharacter::ResetInput()
{
m_Input.m_Direction = 0;
//m_Input.m_Hook = 0;
// simulate releasing the fire button
if((m_Input.m_Fire&1) != 0)
m_Input.m_Fire++;
m_Input.m_Fire &= INPUT_STATE_MASK;
m_Input.m_Jump = 0;
m_LatestPrevInput = m_LatestInput = m_Input;
}
void CCharacter::Tick()
{
DDRaceTick();

View file

@ -51,6 +51,7 @@ public:
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
void ResetInput();
void FireWeapon();
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);