Skip to content

Commit

Permalink
Move OnDirectInput functionality into WeaponTick
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Jun 2, 2024
1 parent 0d84dcb commit 6797b06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
41 changes: 18 additions & 23 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/game/server/entities/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class CCharacter : public CEntity
void HandleJetpack();

void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
void OnDirectInput(CNetObj_PlayerInput *pNewInput);

void ReleaseHook();
void ResetHook();
Expand Down
1 change: 0 additions & 1 deletion src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6797b06

Please sign in to comment.