mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Rename a couple confusing input functions, add comments
This commit is contained in:
parent
64fec2cd37
commit
4b6a10624c
|
@ -2901,7 +2901,7 @@ 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)
|
||||
|
|
|
@ -1293,6 +1293,8 @@ static int PlayerFlags_SevenToSix(int Flags)
|
|||
}
|
||||
|
||||
// Server hooks
|
||||
|
||||
// Called on all incoming NETMSG_INPUT, reformats player flags for sixup compatibility
|
||||
void CGameContext::OnClientPrepareInput(int ClientId, void *pInput)
|
||||
{
|
||||
auto *pPlayerInput = (CNetObj_PlayerInput *)pInput;
|
||||
|
@ -1300,10 +1302,11 @@ void CGameContext::OnClientPrepareInput(int ClientId, void *pInput)
|
|||
pPlayerInput->m_PlayerFlags = PlayerFlags_SevenToSix(pPlayerInput->m_PlayerFlags);
|
||||
}
|
||||
|
||||
// Called on all incoming NETMSG_INPUT, only sets player flags and tracks afk status. Does not perform a DirectInput
|
||||
void CGameContext::OnClientDirectInput(int ClientId, void *pInput)
|
||||
{
|
||||
if(!m_World.m_Paused)
|
||||
m_apPlayers[ClientId]->OnDirectInput((CNetObj_PlayerInput *)pInput);
|
||||
m_apPlayers[ClientId]->OnPlayerFreshInput((CNetObj_PlayerInput *)pInput);
|
||||
|
||||
int Flags = ((CNetObj_PlayerInput *)pInput)->m_PlayerFlags;
|
||||
if((Flags & 256) || (Flags & 512))
|
||||
|
@ -1312,9 +1315,10 @@ void CGameContext::OnClientDirectInput(int ClientId, void *pInput)
|
|||
}
|
||||
}
|
||||
|
||||
// Called once per input that happens on this tick after OnClientPredictedEarlyInput is called. 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 at all has been sent by a player
|
||||
// early return if no input has ever been sent by the player
|
||||
if(pInput == nullptr && !m_aPlayerHasInput[ClientId])
|
||||
return;
|
||||
|
||||
|
@ -1326,12 +1330,13 @@ void CGameContext::OnClientPredictedInput(int ClientId, void *pInput)
|
|||
}
|
||||
|
||||
if(!m_World.m_Paused)
|
||||
m_apPlayers[ClientId]->OnPredictedInput(pApplyInput);
|
||||
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 at all has been sent by a player
|
||||
// early return if no input has ever been sent by the player
|
||||
if(pInput == nullptr && !m_aPlayerHasInput[ClientId])
|
||||
return;
|
||||
|
||||
|
|
|
@ -499,7 +499,8 @@ void CPlayer::OnDisconnect()
|
|||
m_Moderating = false;
|
||||
}
|
||||
|
||||
void CPlayer::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
|
||||
// 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)
|
||||
{
|
||||
// skip the input if chat is active
|
||||
if((m_PlayerFlags & PLAYERFLAG_CHATTING) && (pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING))
|
||||
|
@ -519,7 +520,8 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
|
|||
GameServer()->SendBroadcast("This server uses an experimental translation from Teeworlds 0.7 to 0.6. Please report bugs on ddnet.org/discord", m_ClientId);
|
||||
}
|
||||
|
||||
void CPlayer::OnDirectInput(CNetObj_PlayerInput *pNewInput)
|
||||
// Afk player tracking
|
||||
void CPlayer::OnPlayerFreshInput(CNetObj_PlayerInput *pNewInput)
|
||||
{
|
||||
Server()->SetClientFlags(m_ClientId, pNewInput->m_PlayerFlags);
|
||||
|
||||
|
@ -540,6 +542,7 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *pNewInput)
|
|||
}
|
||||
}
|
||||
|
||||
// Executes a DirectInput for the players character
|
||||
void CPlayer::OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput)
|
||||
{
|
||||
m_PlayerFlags = pNewInput->m_PlayerFlags;
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
void Snap(int SnappingClient);
|
||||
void FakeSnap();
|
||||
|
||||
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
|
||||
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
|
||||
void OnPlayerFreshInput(CNetObj_PlayerInput *pNewInput);
|
||||
void OnPlayerInput(CNetObj_PlayerInput *pNewInput);
|
||||
void OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput);
|
||||
void OnDisconnect();
|
||||
|
||||
|
|
Loading…
Reference in a new issue