mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix prediction when chat is enabled
This commit is contained in:
parent
d57c8ef463
commit
b354e034fc
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue