diff --git a/src/console.c b/src/console.c index 26a072300..3fbcfb6c4 100644 --- a/src/console.c +++ b/src/console.c @@ -13,7 +13,7 @@ int console_parse_type(char *txt, int *element, char *err) int i = -1; if (strcasecmp(txt,"WIND")==0) { - strcpy(err, "Particle type not recognised"); + if (err) strcpy(err, "Particle type not recognised"); return 0; } // alternative names for some elements @@ -23,18 +23,18 @@ int console_parse_type(char *txt, int *element, char *err) if (i>=0) { *element = i; - strcpy(err,""); + if (err) strcpy(err,""); return 1; } for (i=1; i=XRES || ny<0 || ny>=YRES) { - strcpy(err,"Invalid coordinates"); + if (err) strcpy(err,"Invalid coordinates"); return 0; } *x = nx; @@ -54,7 +54,7 @@ int console_parse_coords(char *txt, int *x, int *y, char *err) int console_parse_partref(char *txt, int *which, char *err) { int i = -1, nx, ny; - strcpy(err,""); + if (err) strcpy(err,""); if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; @@ -75,10 +75,10 @@ int console_parse_partref(char *txt, int *which, char *err) if (i>=0 && i2){ if(!lua_isnumber(l, acount) && lua_isstring(l, acount)){ name = luaL_optstring(l, acount, "none"); - if (!console_parse_type(name, &partsel, console_error)) + if (!console_parse_type(name, &partsel, NULL)) return luaL_error(l, "Unrecognised element '%s'", name); } } @@ -409,7 +409,7 @@ int luatpt_set_property(lua_State* l) return luaL_error(l, "Unrecognised element number '%d'", t); } else { name = luaL_optstring(l, 2, "dust"); - if (!console_parse_type(name, &t, console_error)) + if (!console_parse_type(name, &t, NULL)) return luaL_error(l, "Unrecognised element '%s'", name); } if(i == -1 || (w != -1 && h != -1)){