CON palfrom: sanity-check current player and maybe print error message.

git-svn-id: https://svn.eduke32.com/eduke32@2615 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-04-28 21:56:38 +00:00
parent 5dd8d20e7a
commit b2b8ab7890

View file

@ -3316,11 +3316,19 @@ nullquote:
case CON_PALFROM: case CON_PALFROM:
insptr++; insptr++;
if ((unsigned)vm.g_p >= (unsigned)playerswhenstarted)
{ {
int32_t j = 2; OSD_Printf(CON_ERROR "invalid player ID %d\n",g_errorLineNum,keyw[g_tw],vm.g_p);
g_player[vm.g_p].ps->pals.f = *insptr++; insptr += 4;
for (; j>=0; j--) }
*((char *)(&g_player[vm.g_p].ps->pals.r)+2-j) = *insptr++; else
{
palette_t *const pals = &g_player[vm.g_p].ps->pals;
pals->f = *insptr++;
pals->r = *insptr++;
pals->g = *insptr++;
pals->b = *insptr++;
} }
continue; continue;