Duke3d: add a few missing VM_ASSERT checks

This commit is contained in:
Richard C. Gobeille 2020-05-06 04:40:05 -07:00 committed by Christoph Oelckers
parent 1a1112b4c1
commit 8cf064b90c

View file

@ -2384,6 +2384,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++) : 0; int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++) : 0;
VM_ASSERT((unsigned)playerNum < MAXPLAYERS, "invalid player %d\n", playerNum);
VM_SetPlayer(playerNum, labelNum, lParm2, Gv_GetVar(*insptr++)); VM_SetPlayer(playerNum, labelNum, lParm2, Gv_GetVar(*insptr++));
dispatch(); dispatch();
} }
@ -2395,6 +2397,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++) : 0; int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++) : 0;
VM_ASSERT((unsigned)playerNum < MAXPLAYERS, "invalid player %d\n", playerNum);
Gv_SetVar(*insptr++, VM_GetPlayer(playerNum, labelNum, lParm2)); Gv_SetVar(*insptr++, VM_GetPlayer(playerNum, labelNum, lParm2));
dispatch(); dispatch();
} }
@ -2408,6 +2412,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const newValue = Gv_GetVar(*insptr++); int const newValue = Gv_GetVar(*insptr++);
auto const &wallLabel = WallLabels[labelNum]; auto const &wallLabel = WallLabels[labelNum];
VM_ASSERT((unsigned)wallNum < MAXWALLS, "invalid wall %d\n", wallNum);
if (wallLabel.offset == -1 || wallLabel.flags & LABEL_WRITEFUNC) if (wallLabel.offset == -1 || wallLabel.flags & LABEL_WRITEFUNC)
{ {
VM_SetWall(wallNum, labelNum, newValue); VM_SetWall(wallNum, labelNum, newValue);
@ -2428,6 +2434,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
auto const &wallLabel = WallLabels[labelNum]; auto const &wallLabel = WallLabels[labelNum];
VM_ASSERT((unsigned)wallNum < MAXWALLS, "invalid wall %d\n", wallNum);
Gv_SetVar(*insptr++, Gv_SetVar(*insptr++,
(wallLabel.offset != -1 && (wallLabel.flags & LABEL_READFUNC) != LABEL_READFUNC) (wallLabel.offset != -1 && (wallLabel.flags & LABEL_READFUNC) != LABEL_READFUNC)
? VM_GetStruct(wallLabel.flags, (intptr_t *)((char *)&wall[wallNum] + wallLabel.offset)) ? VM_GetStruct(wallLabel.flags, (intptr_t *)((char *)&wall[wallNum] + wallLabel.offset))
@ -2594,6 +2602,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
auto const &tsprLabel = TsprLabels[labelNum]; auto const &tsprLabel = TsprLabels[labelNum];
VM_ASSERT((unsigned)spriteNum < MAXSPRITES, "invalid sprite %d\n", spriteNum);
VM_SetStruct(tsprLabel.flags, (intptr_t *)((char *)spriteext[spriteNum].tspr + tsprLabel.offset), Gv_GetVar(*insptr++)); VM_SetStruct(tsprLabel.flags, (intptr_t *)((char *)spriteext[spriteNum].tspr + tsprLabel.offset), Gv_GetVar(*insptr++));
dispatch(); dispatch();
} }
@ -2605,6 +2615,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
auto const &tsprLabel = TsprLabels[labelNum]; auto const &tsprLabel = TsprLabels[labelNum];
VM_ASSERT((unsigned)spriteNum < MAXSPRITES, "invalid sprite %d\n", spriteNum);
Gv_SetVar(*insptr++, VM_GetStruct(tsprLabel.flags, (intptr_t *)((char *)spriteext[spriteNum].tspr + tsprLabel.offset))); Gv_SetVar(*insptr++, VM_GetStruct(tsprLabel.flags, (intptr_t *)((char *)spriteext[spriteNum].tspr + tsprLabel.offset)));
dispatch(); dispatch();
} }
@ -2617,6 +2629,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
auto const &sectLabel = SectorLabels[labelNum]; auto const &sectLabel = SectorLabels[labelNum];
int const newValue = Gv_GetVar(*insptr++); int const newValue = Gv_GetVar(*insptr++);
VM_ASSERT((unsigned)sectNum < MAXSECTORS, "invalid sector %d\n", sectNum);
if (sectLabel.offset == -1 || sectLabel.flags & LABEL_WRITEFUNC) if (sectLabel.offset == -1 || sectLabel.flags & LABEL_WRITEFUNC)
{ {
VM_SetSector(sectNum, labelNum, newValue); VM_SetSector(sectNum, labelNum, newValue);
@ -2634,6 +2648,8 @@ GAMEEXEC_STATIC void VM_Execute(int const loop /*= false*/)
int const labelNum = *insptr++; int const labelNum = *insptr++;
auto const &sectLabel = SectorLabels[labelNum]; auto const &sectLabel = SectorLabels[labelNum];
VM_ASSERT((unsigned)sectNum < MAXSECTORS, "invalid sector %d\n", sectNum);
Gv_SetVar(*insptr++, Gv_SetVar(*insptr++,
(sectLabel.offset != -1 && (sectLabel.flags & LABEL_READFUNC) != LABEL_READFUNC) (sectLabel.offset != -1 && (sectLabel.flags & LABEL_READFUNC) != LABEL_READFUNC)
? VM_GetStruct(sectLabel.flags, (intptr_t *)((char *)&sector[sectNum] + sectLabel.offset)) ? VM_GetStruct(sectLabel.flags, (intptr_t *)((char *)&sector[sectNum] + sectLabel.offset))