Remove OnPredictedEarlyInput and OnClientPredictedEarlyInput

This commit is contained in:
Tater 2024-06-02 03:12:49 -05:00
parent 7de808ae99
commit 0d84dcbaef
3 changed files with 7 additions and 58 deletions

View file

@ -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++;

View file

@ -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)
{

View file

@ -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);