mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
made the server validate player input
This commit is contained in:
parent
280fdb34a4
commit
9164c1d879
|
@ -533,13 +533,35 @@ void CGameContext::OnTick()
|
|||
// Server hooks
|
||||
void CGameContext::OnClientDirectInput(int ClientID, void *pInput)
|
||||
{
|
||||
m_apPlayers[ClientID]->OnDirectInput((CNetObj_PlayerInput *)pInput);
|
||||
int NumCorrections = m_NetObjHandler.NumObjCorrections();
|
||||
if(m_NetObjHandler.ValidateObj(NETOBJTYPE_PLAYERINPUT, pInput, sizeof(CNetObj_PlayerInput)) == 0)
|
||||
{
|
||||
if(g_Config.m_Debug && NumCorrections != m_NetObjHandler.NumObjCorrections())
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "NETOBJTYPE_PLAYERINPUT corrected on '%s'", m_NetObjHandler.CorrectedObjOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
}
|
||||
m_apPlayers[ClientID]->OnDirectInput((CNetObj_PlayerInput *)pInput);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::OnClientPredictedInput(int ClientID, void *pInput)
|
||||
{
|
||||
if(!m_World.m_Paused)
|
||||
m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput);
|
||||
{
|
||||
int NumCorrections = m_NetObjHandler.NumObjCorrections();
|
||||
if(m_NetObjHandler.ValidateObj(NETOBJTYPE_PLAYERINPUT, pInput, sizeof(CNetObj_PlayerInput)) == 0)
|
||||
{
|
||||
if(g_Config.m_Debug && NumCorrections != m_NetObjHandler.NumObjCorrections())
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "NETOBJTYPE_PLAYERINPUT corrected on '%s'", m_NetObjHandler.CorrectedObjOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
}
|
||||
m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameContext::OnClientEnter(int ClientID)
|
||||
|
|
Loading…
Reference in a new issue