Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/battlestar expand the internal consistency checks in t...



details:   https://anonhg.NetBSD.org/src/rev/ea65442888a5
branches:  trunk
changeset: 965919:ea65442888a5
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Oct 05 23:34:14 2019 +0000

description:
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:

 games/battlestar/room.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r 3e7b8c44700b -r ea65442888a5 games/battlestar/room.c
--- a/games/battlestar/room.c   Sat Oct 05 23:32:20 2019 +0000
+++ b/games/battlestar/room.c   Sat Oct 05 23:34:14 2019 +0000
@@ -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 @@
                case WEST:
                        return ("right");
                }
+               break;
 
        case SOUTH:
                switch (direction) {
@@ -142,6 +143,7 @@
                case WEST:
                        return ("left");
                }
+               break;
 
        case EAST:
                switch (direction) {
@@ -155,6 +157,7 @@
                        return (option == '+' ? "behind you" :
                            "back");
                }
+               break;
 
        case WEST:
                switch (direction) {
@@ -168,12 +171,12 @@
                case WEST:
                        return ("ahead");
                }
+               break;
+       }
 
-       default:
-               printf("Error: room %d.  More than four directions wanted.", 
-                   position);
-               return ("!!");
-       }
+       printf("Error: room %d.  More than four directions wanted.", 
+           position);
+       return ("!!");
 }
 
 void



Home | Main Index | Thread Index | Old Index