diff --git a/src/game/client/prediction/entities/character.cpp b/src/game/client/prediction/entities/character.cpp index 6ad4c4555..81150feb2 100644 --- a/src/game/client/prediction/entities/character.cpp +++ b/src/game/client/prediction/entities/character.cpp @@ -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(); diff --git a/src/game/client/prediction/entities/character.h b/src/game/client/prediction/entities/character.h index ac1155b5a..a5d13ac24 100644 --- a/src/game/client/prediction/entities/character.h +++ b/src/game/client/prediction/entities/character.h @@ -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);