From 0d84dcbaef6beeac8ad00df8369a97e1615d5879 Mon Sep 17 00:00:00 2001 From: Tater Date: Sun, 2 Jun 2024 03:12:49 -0500 Subject: [PATCH] Remove OnPredictedEarlyInput and OnClientPredictedEarlyInput --- src/engine/server/server.cpp | 17 ----------------- src/game/server/gamecontext.cpp | 27 ++------------------------- src/game/server/player.cpp | 21 +++++---------------- 3 files changed, 7 insertions(+), 58 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index aa678ffda..885dc631e 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2909,23 +2909,6 @@ int CServer::Run() #ifdef CONF_DEBUG UpdateDebugDummies(false); #endif - // Use DirectInput to apply any (and all) fires intended for the current tick to the gameworld - for(int c = 0; c < MAX_CLIENTS; c++) - { - if(m_aClients[c].m_State != CClient::STATE_INGAME) - continue; - bool ClientHadInput = false; - for(auto &Input : m_aClients[c].m_aInputs) - { - if(Input.m_GameTick == Tick() + 1) - { - GameServer()->OnClientPredictedEarlyInput(c, Input.m_aData); - ClientHadInput = true; - } - } - if(!ClientHadInput) - GameServer()->OnClientPredictedEarlyInput(c, nullptr); - } m_CurrentGameTick++; NewTicks++; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 0a3efab06..02c6dc277 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1315,28 +1315,9 @@ void CGameContext::OnClientFreshInput(int ClientId, void *pInput) } } -// Called once per input that happens on this tick after OnClientPredictedEarlyInput is called. +// Called once per input that happens on this tick. // pInput is nullptr if the client did not send any fresh input this tick. void CGameContext::OnClientPredictedInput(int ClientId, void *pInput) -{ - // early return if no input has ever been sent by the player - if(pInput == nullptr && !m_aPlayerHasInput[ClientId]) - return; - - // set to last sent input when no new input has been sent - CNetObj_PlayerInput *pApplyInput = (CNetObj_PlayerInput *)pInput; - if(pApplyInput == nullptr) - { - pApplyInput = &m_aLastPlayerInput[ClientId]; - } - - if(!m_World.m_Paused) - m_apPlayers[ClientId]->OnPlayerInput(pApplyInput); -} - -// Called once per tick BEFORE OnClientPredictedInput. -// pInput is nullptr if the client did not send any fresh input this tick. -void CGameContext::OnClientPredictedEarlyInput(int ClientId, void *pInput) { // early return if no input has ever been sent by the player if(pInput == nullptr && !m_aPlayerHasInput[ClientId]) @@ -1350,16 +1331,12 @@ void CGameContext::OnClientPredictedEarlyInput(int ClientId, void *pInput) } else { - // Store input in this function and not in `OnClientPredictedInput`, - // because this function is called on all inputs, while - // `OnClientPredictedInput` is only called on the first input of each - // tick. mem_copy(&m_aLastPlayerInput[ClientId], pApplyInput, sizeof(m_aLastPlayerInput[ClientId])); m_aPlayerHasInput[ClientId] = true; } if(!m_World.m_Paused) - m_apPlayers[ClientId]->OnPredictedEarlyInput(pApplyInput); + m_apPlayers[ClientId]->OnPlayerInput(pApplyInput); if(m_TeeHistorianActive) { diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 0a1b9379b..3bba3c285 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -502,6 +502,11 @@ void CPlayer::OnDisconnect() // 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; + + if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (pNewInput->m_Fire & 1)) + m_Spawning = true; + // skip the input if chat is active if((m_PlayerFlags & PLAYERFLAG_CHATTING) && (pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)) return; @@ -542,22 +547,6 @@ void CPlayer::OnPlayerFreshInput(CNetObj_PlayerInput *pNewInput) } } -// Executes a DirectInput for the players character -void CPlayer::OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput) -{ - m_PlayerFlags = pNewInput->m_PlayerFlags; - - if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (pNewInput->m_Fire & 1)) - m_Spawning = true; - - // skip the input if chat is active - if(m_PlayerFlags & PLAYERFLAG_CHATTING) - return; - - //if(m_pCharacter && !m_Paused) - //m_pCharacter->OnDirectInput(pNewInput); -} - int CPlayer::GetClientVersion() const { return m_pGameServer->GetClientVersion(m_ClientId);