projects
/
wumpus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c933090
)
fix: superhack input path reading
1/head
author
Frank Uhlig
<uhlig.frank@gmail.com>
Mon, 25 Mar 2019 20:54:49 +0000
(20:54 +0000)
committer
Frank Uhlig
<uhlig.frank@gmail.com>
Mon, 25 Mar 2019 20:54:49 +0000
(20:54 +0000)
superhack.c
patch
|
blob
|
history
diff --git
a/superhack.c
b/superhack.c
index c5461a1ff7f3fae5ff1c84a46be6073c55fc1c46..eff24c2fb4725f604a7137aac28d97397ff93053 100644
(file)
--- a/
superhack.c
+++ b/
superhack.c
@@
-22,6
+22,7
@@
static int path[5];
static int j, k, scratchloc, pies;
static char inp[BUFSIZ]; /* common input buffer */
static int j, k, scratchloc, pies;
static char inp[BUFSIZ]; /* common input buffer */
+#define NUMBERS "0123456789"
#define YOU 0
#define RMS 1
#define STARLET1 2
#define YOU 0
#define RMS 1
#define STARLET1 2
@@
-226,8
+227,9
@@
void throw()
extern void check_shot(), move_superhack();
int j9;
extern void check_shot(), move_superhack();
int j9;
- j9 = sscanf(inp +
isalpha(inp[0]
), "%d %d %d %d %d",
+ j9 = sscanf(inp +
strcspn(inp, NUMBERS
), "%d %d %d %d %d",
&path[0], &path[1], &path[2], &path[3], &path[4]);
&path[0], &path[1], &path[2], &path[3], &path[4]);
+
if (j9 < 1)
{
PM("Sorry, I didn't see any room numbers after your throw command.");
if (j9 < 1)
{
PM("Sorry, I didn't see any room numbers after your throw command.");
@@
-312,7
+314,7
@@
void move_superhack()
void move()
{
void move()
{
- if (sscanf(inp +
isalpha(inp[0]
), "%d", &scratchloc) < 1)
+ if (sscanf(inp +
strcspn(inp, NUMBERS
), "%d", &scratchloc) < 1)
{
PM("Sorry, I didn't see a room number after your `m' command.");
return;
{
PM("Sorry, I didn't see a room number after your `m' command.");
return;