summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob1 <jfu614@gmail.com>2012-05-24 16:42:19 (GMT)
committer Jacob1 <jfu614@gmail.com>2012-05-24 16:42:19 (GMT)
commitf49f4ea2413464ebdfac6ee0be32c1b282839c63 (patch)
tree137bea08f733a03f4a12f57137ab93e99b452166 /src
parent4368ded19707c4272a31210503da7c123db24b63 (diff)
downloadpowder-f49f4ea2413464ebdfac6ee0be32c1b282839c63.zip
powder-f49f4ea2413464ebdfac6ee0be32c1b282839c63.tar.gz
fix crash, spark reset set type without checking if it was a valid number. Also disable another way to create invalid elements
Diffstat (limited to 'src')
-rw-r--r--src/luaconsole.c11
-rw-r--r--src/main.c9
2 files changed, 15 insertions, 5 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c
index 6d54529..e0aab5f 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -1089,8 +1089,13 @@ int luatpt_reset_spark(lua_State* l)
{
if (parts[i].type==PT_SPRK)
{
- parts[i].type = parts[i].ctype;
- parts[i].life = 4;
+ if (parts[i].ctype >= 0 && parts[i].ctype < PT_NUM)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 0;
+ }
+ else
+ kill_part(i);
}
}
return 0;
@@ -1284,7 +1289,7 @@ int luatpt_set_property(lua_State* l)
} else {
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);
} else {
name = luaL_optstring(l, 2, "dust");
diff --git a/src/main.c b/src/main.c
index 87778bb..3a9776e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1526,8 +1526,13 @@ int main(int argc, char *argv[])
for (i=0; i<NPART; i++)
if (parts[i].type==PT_SPRK)
{
- parts[i].type = parts[i].ctype;
- parts[i].life = 0;
+ if (parts[i].ctype >= 0 && parts[i].ctype < PT_NUM)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 0;
+ }
+ else
+ kill_part(i);
}
}
else