mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Remove OnPredictedEarlyInput and OnClientPredictedEarlyInput
This commit is contained in:
parent
7de808ae99
commit
0d84dcbaef
|
@ -2909,23 +2909,6 @@ int CServer::Run()
|
||||||
#ifdef CONF_DEBUG
|
#ifdef CONF_DEBUG
|
||||||
UpdateDebugDummies(false);
|
UpdateDebugDummies(false);
|
||||||
#endif
|
#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++;
|
m_CurrentGameTick++;
|
||||||
NewTicks++;
|
NewTicks++;
|
||||||
|
|
|
@ -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.
|
// pInput is nullptr if the client did not send any fresh input this tick.
|
||||||
void CGameContext::OnClientPredictedInput(int ClientId, void *pInput)
|
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
|
// early return if no input has ever been sent by the player
|
||||||
if(pInput == nullptr && !m_aPlayerHasInput[ClientId])
|
if(pInput == nullptr && !m_aPlayerHasInput[ClientId])
|
||||||
|
@ -1350,16 +1331,12 @@ void CGameContext::OnClientPredictedEarlyInput(int ClientId, void *pInput)
|
||||||
}
|
}
|
||||||
else
|
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]));
|
mem_copy(&m_aLastPlayerInput[ClientId], pApplyInput, sizeof(m_aLastPlayerInput[ClientId]));
|
||||||
m_aPlayerHasInput[ClientId] = true;
|
m_aPlayerHasInput[ClientId] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!m_World.m_Paused)
|
if(!m_World.m_Paused)
|
||||||
m_apPlayers[ClientId]->OnPredictedEarlyInput(pApplyInput);
|
m_apPlayers[ClientId]->OnPlayerInput(pApplyInput);
|
||||||
|
|
||||||
if(m_TeeHistorianActive)
|
if(m_TeeHistorianActive)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
// 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)
|
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
|
// skip the input if chat is active
|
||||||
if((m_PlayerFlags & PLAYERFLAG_CHATTING) && (pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING))
|
if((m_PlayerFlags & PLAYERFLAG_CHATTING) && (pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING))
|
||||||
return;
|
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
|
int CPlayer::GetClientVersion() const
|
||||||
{
|
{
|
||||||
return m_pGameServer->GetClientVersion(m_ClientId);
|
return m_pGameServer->GetClientVersion(m_ClientId);
|
||||||
|
|
Loading…
Reference in a new issue