ref: 3f23bc4d26422ae2a77ffd10b4e9941edaa24fc7
parent: b8433f9421cc3b1140a21da7b82b7ba07abea59c
author: mkf <mkf@cloud9p.org>
date: Tue May 14 07:23:14 EDT 2024
srv: use strtodir
--- a/srv.c
+++ b/srv.c
@@ -265,25 +265,14 @@
Point p;
p = findglenda();
-
- if(strcmp(s, "NE") == 0)
- d = NE;
- else if(strcmp(s, "E") == 0)
- d = E;
- else if(strcmp(s, "SE") == 0)
- d = SE;
- else if(strcmp(s, "W") == 0)
- d = W;
- else if(strcmp(s, "SW") == 0)
- d = SW;
- else if(strcmp(s, "NW") == 0)
- d = NW;
- else
+ d = strtodir(s);
+
+ if(d == Err)
{
-
fprint(playersock, "ERR invalidinput proc_move(): %s\n", s);
return;
}
+
if(domove(d) == Wall)
{
fprint(playersock, "WALL %s %d %d\n", s, p.x, p.y);
--- a/util.c
+++ b/util.c
@@ -40,7 +40,7 @@
else if(strcmp(s, "NW") == 0)
d = NW;
else
- sysfatal("parsemove(): invalid direction");
+ return Err;
return d;
}
--- a/util.h
+++ b/util.h
@@ -1,5 +1,5 @@
int isnum(char *s, unsigned int n);
-int parsemove(char *s);
+int strtodir(char *s);
char* dirtostr(int dir);
Point parseput(char *x, char *y);
int dprint(char *fmt, ...);