From 3b020b315148e5b065071b5bb8a4caf1321c730c Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 12 Jun 2012 19:45:19 +0100 Subject: TPT: fix crash, spark reset set type without checking if it was a valid number diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index c7dc15d..48e7908 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1128,8 +1128,13 @@ int luatpt_reset_spark(lua_State* l) { if (luacon_sim->parts[i].type==PT_SPRK) { - luacon_sim->parts[i].type = luacon_sim->parts[i].ctype; - luacon_sim->parts[i].life = 4; + 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 = 0; + } + else + luacon_sim->kill_part(i); } } return 0; -- cgit v0.9.2-21-gd62e