Simulation::create_part sanity check

This commit is contained in:
QuanTech0 2020-04-26 20:39:56 -04:00 committed by jacob1
parent 323a850e16
commit 4efe5875ab

View File

@ -3112,9 +3112,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
{
int i, oldType = PT_NONE;
if (x<0 || y<0 || x>=XRES || y>=YRES)
return -1;
if (t>=0 && t<PT_NUM && !elements[t].Enabled)
if (x<0 || y<0 || x>=XRES || y>=YRES || t<=0 || t>=PT_NUM || !elements[t].Enabled)
return -1;
if (t == PT_SPRK && !(p == -2 && elements[TYP(pmap[y][x])].CtypeDraw))