made the server validate player input

This commit is contained in:
oy 2012-08-03 18:46:17 +02:00
parent 280fdb34a4
commit 9164c1d879

View file

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