summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2019-10-05 23:34:14 +0000
committermrg <mrg@NetBSD.org>2019-10-05 23:34:14 +0000
commitee35c5e8f222ee16db93ebbc9ce428c3defe8a95 (patch)
tree5283ed4ece3fb132e81dab3fa120eab788517a6f /battlestar
parent7175df1928b975fdbf6d5177ee2708542d4c3a27 (diff)
downloadbsdgames-darwin-ee35c5e8f222ee16db93ebbc9ce428c3defe8a95.tar.gz
bsdgames-darwin-ee35c5e8f222ee16db93ebbc9ce428c3defe8a95.tar.zst
bsdgames-darwin-ee35c5e8f222ee16db93ebbc9ce428c3defe8a95.zip
expand the internal consistency checks in truedirec() to avoid
fallthrough cases. now if direction turns up wrong (it should not, but this code can't tell that, and convert it to an enum that would also fix this, is more effort than this is worth.
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/room.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/battlestar/room.c b/battlestar/room.c
index 61defbbb..16d129b5 100644
--- a/battlestar/room.c
+++ b/battlestar/room.c
@@ -1,4 +1,4 @@
-/* $NetBSD: room.c,v 1.13 2011/05/23 22:44:18 joerg Exp $ */
+/* $NetBSD: room.c,v 1.14 2019/10/05 23:34:14 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: room.c,v 1.13 2011/05/23 22:44:18 joerg Exp $");
+__RCSID("$NetBSD: room.c,v 1.14 2019/10/05 23:34:14 mrg Exp $");
#endif
#endif /* not lint */
@@ -129,6 +129,7 @@ truedirec(int way, int option)
case WEST:
return ("right");
}
+ break;
case SOUTH:
switch (direction) {
@@ -142,6 +143,7 @@ truedirec(int way, int option)
case WEST:
return ("left");
}
+ break;
case EAST:
switch (direction) {
@@ -155,6 +157,7 @@ truedirec(int way, int option)
return (option == '+' ? "behind you" :
"back");
}
+ break;
case WEST:
switch (direction) {
@@ -168,12 +171,12 @@ truedirec(int way, int option)
case WEST:
return ("ahead");
}
-
- default:
- printf("Error: room %d. More than four directions wanted.",
- position);
- return ("!!");
+ break;
}
+
+ printf("Error: room %d. More than four directions wanted.",
+ position);
+ return ("!!");
}
void