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,14 +533,36 @@ void CGameContext::OnTick()
// Server hooks // Server hooks
void CGameContext::OnClientDirectInput(int ClientID, void *pInput) void CGameContext::OnClientDirectInput(int ClientID, void *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); m_apPlayers[ClientID]->OnDirectInput((CNetObj_PlayerInput *)pInput);
} }
}
void CGameContext::OnClientPredictedInput(int ClientID, void *pInput) void CGameContext::OnClientPredictedInput(int ClientID, void *pInput)
{ {
if(!m_World.m_Paused) if(!m_World.m_Paused)
{
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); m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput);
} }
}
}
void CGameContext::OnClientEnter(int ClientID) void CGameContext::OnClientEnter(int ClientID)
{ {