fix crash, spark reset set type without checking if it was a valid number. Also disable another way to create invalid elements
This commit is contained in:
parent
4368ded197
commit
f49f4ea241
@ -1088,9 +1088,14 @@ int luatpt_reset_spark(lua_State* l)
|
|||||||
for (i=0; i<NPART; i++)
|
for (i=0; i<NPART; i++)
|
||||||
{
|
{
|
||||||
if (parts[i].type==PT_SPRK)
|
if (parts[i].type==PT_SPRK)
|
||||||
|
{
|
||||||
|
if (parts[i].ctype >= 0 && parts[i].ctype < PT_NUM)
|
||||||
{
|
{
|
||||||
parts[i].type = parts[i].ctype;
|
parts[i].type = parts[i].ctype;
|
||||||
parts[i].life = 4;
|
parts[i].life = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
kill_part(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1284,7 +1289,7 @@ int luatpt_set_property(lua_State* l)
|
|||||||
} else {
|
} else {
|
||||||
t = luaL_optint(l, 2, 0);
|
t = luaL_optint(l, 2, 0);
|
||||||
}
|
}
|
||||||
if (format == 3 && (t<0 || t>=PT_NUM))
|
if (format == 3 && (t<0 || t>=PT_NUM || !ptypes[t].enabled))
|
||||||
return luaL_error(l, "Unrecognised element number '%d'", t);
|
return luaL_error(l, "Unrecognised element number '%d'", t);
|
||||||
} else {
|
} else {
|
||||||
name = luaL_optstring(l, 2, "dust");
|
name = luaL_optstring(l, 2, "dust");
|
||||||
|
@ -1525,10 +1525,15 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
for (i=0; i<NPART; i++)
|
for (i=0; i<NPART; i++)
|
||||||
if (parts[i].type==PT_SPRK)
|
if (parts[i].type==PT_SPRK)
|
||||||
|
{
|
||||||
|
if (parts[i].ctype >= 0 && parts[i].ctype < PT_NUM)
|
||||||
{
|
{
|
||||||
parts[i].type = parts[i].ctype;
|
parts[i].type = parts[i].ctype;
|
||||||
parts[i].life = 0;
|
parts[i].life = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
kill_part(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user