engine: client: prevent memory corruption on old protocol when server didn't sent local player info in delta at spawn

This commit is contained in:
Alibek Omarov 2023-12-31 06:17:36 +03:00
parent f031c31b77
commit 4cf87c2c23

View File

@ -824,6 +824,27 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
cd = &from->client; cd = &from->client;
pmove->player_index = ps->number - 1; pmove->player_index = ps->number - 1;
// a1ba: workaround bug on old protocol where the server refuse to send
// our local player in delta. cl.playernum, in theory, must be equal
// to our local player index anyway
// this might not be a real solution, since everything else will be bogus
// but we need to properly run prediction and avoid potential memory
// corruption
// either debug this, or remove when old protocol will be dropped!!!
if( cls.legacymode )
{
if( pmove->player_index < 0 )
{
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
}
else
{
// if this happens, record a demo and send it to a1ba
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
}
}
pmove->multiplayer = (cl.maxclients > 1); pmove->multiplayer = (cl.maxclients > 1);
pmove->runfuncs = runfuncs; pmove->runfuncs = runfuncs;
pmove->time = time * 1000.0f; pmove->time = time * 1000.0f;