From 6797b060e667bab810721c61caa82c3de3d20384 Mon Sep 17 00:00:00 2001 From: Tater Date: Sun, 2 Jun 2024 03:19:44 -0500 Subject: [PATCH] Move OnDirectInput functionality into WeaponTick --- src/game/server/entities/character.cpp | 41 +++++++++++--------------- src/game/server/entities/character.h | 1 - src/game/server/player.cpp | 1 - 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index dc3214c8033..f067331444e 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -694,28 +694,6 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) mem_copy(&m_SavedInput, &m_Input, sizeof(m_SavedInput)); } -void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) -{ - mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); - mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput)); - m_NumInputs++; - - // it is not allowed to aim in the center - if(m_LatestInput.m_TargetX == 0 && m_LatestInput.m_TargetY == 0) - m_LatestInput.m_TargetY = -1; - - Antibot()->OnDirectInput(m_pPlayer->GetCid()); - - if(m_NumInputs > 1 && m_pPlayer->GetTeam() != TEAM_SPECTATORS) - { - HandleWeaponSwitch(); - FireWeapon(true); - } - - mem_copy(&m_LatestPrevPrevInput, &m_LatestPrevInput, sizeof(m_LatestInput)); - mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); -} - void CCharacter::ReleaseHook() { m_Core.SetHookedPlayer(-1); @@ -742,7 +720,24 @@ void CCharacter::ResetInput() void CCharacter::WeaponTick() { - OnDirectInput(&m_Input); + mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); + mem_copy(&m_LatestInput, &m_Input, sizeof(m_LatestInput)); + m_NumInputs++; + + // it is not allowed to aim in the center + if(m_LatestInput.m_TargetX == 0 && m_LatestInput.m_TargetY == 0) + m_LatestInput.m_TargetY = -1; + + Antibot()->OnDirectInput(m_pPlayer->GetCid()); + + if(m_NumInputs > 1 && m_pPlayer->GetTeam() != TEAM_SPECTATORS) + { + HandleWeaponSwitch(); + FireWeapon(true); + } + + mem_copy(&m_LatestPrevPrevInput, &m_LatestPrevInput, sizeof(m_LatestInput)); + mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); } void CCharacter::PreTick() diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 2476678b77b..39594629fba 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -61,7 +61,6 @@ class CCharacter : public CEntity void HandleJetpack(); void OnPredictedInput(CNetObj_PlayerInput *pNewInput); - void OnDirectInput(CNetObj_PlayerInput *pNewInput); void ReleaseHook(); void ResetHook(); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 3bba3c28532..515152aa482 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -499,7 +499,6 @@ void CPlayer::OnDisconnect() m_Moderating = false; } -// Copy a input into the charecters active input to be used during the main phase of the game tick void CPlayer::OnPlayerInput(CNetObj_PlayerInput *pNewInput) { m_PlayerFlags = pNewInput->m_PlayerFlags;