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

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