summaryrefslogtreecommitdiff
path: root/src/console.c
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-06-05 20:38:00 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-06-08 11:48:44 (GMT)
commitb5856bfa47020448961a60689dc2a44d09baf2ec (patch)
treefb28d2ef8317dab27ae4d3336bafb6929d6f9b4a /src/console.c
parentb3e0085606c87052fddf2f0e25ba8a596a384a74 (diff)
downloadpowder-b5856bfa47020448961a60689dc2a44d09baf2ec.zip
powder-b5856bfa47020448961a60689dc2a44d09baf2ec.tar.gz
console_error now optional for console_parse_type
Prevents lua step functions from clearing console_error in calls to console_parse_type, hence preventing luacon_eval errors from being shown
Diffstat (limited to 'src/console.c')
-rw-r--r--src/console.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/console.c b/src/console.c
index 26a0723..3fbcfb6 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<PT_NUM; i++) {
if (strcasecmp(txt,ptypes[i].name)==0)
{
*element = i;
- strcpy(err,"");
+ if (err) strcpy(err,"");
return 1;
}
}
- strcpy(err, "Particle type not recognised");
+ if (err) strcpy(err, "Particle type not recognised");
return 0;
}
//takes a string of coords "x,y" and puts the values into x and y.
@@ -43,7 +43,7 @@ int console_parse_coords(char *txt, int *x, int *y, char *err)
int nx = -1, ny = -1;
if (sscanf(txt,"%d,%d",&nx,&ny)!=2 || nx<0 || nx>=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 && i<NPART && parts[i].type)
{
*which = i;
- strcpy(err,"");
+ if (err) strcpy(err,"");
return 1;
}
- if (strcmp(err,"")==0) strcpy(err,"Particle does not exist");
+ if (err && strcmp(err,"")==0) strcpy(err,"Particle does not exist");
return 0;
}