TPT: fix crash, spark reset set type without checking if it was a valid number

This commit is contained in:
Simon Robertshaw 2012-06-12 19:45:19 +01:00
parent b8f2a2dcd5
commit 3b020b3151

View File

@ -1127,9 +1127,14 @@ int luatpt_reset_spark(lua_State* l)
for (i=0; i<NPART; i++)
{
if (luacon_sim->parts[i].type==PT_SPRK)
{
if (luacon_sim->parts[i].ctype >= 0 && luacon_sim->parts[i].ctype < PT_NUM)
{
luacon_sim->parts[i].type = luacon_sim->parts[i].ctype;
luacon_sim->parts[i].life = 4;
luacon_sim->parts[i].life = 0;
}
else
luacon_sim->kill_part(i);
}
}
return 0;