]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - mille/move.c
cgram: provide usage on incorrect invocation
[bsdgames-darwin.git] / mille / move.c
index 1cfa7a0e60cab8966f3fb6dfba14e579bebf5f52..1528aa38173be1a2217071f8c45ca14bde31c0c4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: move.c,v 1.13 2003/08/07 09:37:25 agc Exp $    */
+/*     $NetBSD: move.c,v 1.19 2019/02/03 03:19:25 mrg Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
 #if 0
 static char sccsid[] = "@(#)move.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: move.c,v 1.13 2003/08/07 09:37:25 agc Exp $");
+__RCSID("$NetBSD: move.c,v 1.19 2019/02/03 03:19:25 mrg Exp $");
 #endif
 #endif /* not lint */
 
 #include <termios.h>
 
+#ifdef DEBUG
+#include <sys/param.h>
+#endif
+
 #include       "mille.h"
 #ifndef        unctrl
 #include       "unctrl.h"
@@ -52,14 +56,26 @@ __RCSID("$NetBSD: move.c,v 1.13 2003/08/07 09:37:25 agc Exp $");
 #undef CTRL
 #define        CTRL(c)         (c - 'A' + 1)
 
+static void check_go(void);
+static int playcard(PLAY *);
+static void getmove(void);
+static int haspicked(const PLAY *);
+
 void
-domove()
+domove(void)
 {
        PLAY    *pp;
        int     i, j;
        bool    goodplay;
 
        pp = &Player[Play];
+       for (i = 0, j = 0; i < HAND_SZ; i++)
+               if (pp->hand[i] != -1)
+                       j++;
+       if (!j) {
+               nextplay();
+               return;
+       }
        if (Play == PLAYER)
                getmove();
        else
@@ -156,8 +172,8 @@ acc:
  *     Check and see if either side can go.  If they cannot,
  * the game is over
  */
-void
-check_go()
+static void
+check_go(void)
 {
        CARD    card;
        PLAY    *pp, *op;
@@ -187,9 +203,8 @@ check_go()
        Finished = TRUE;
 }
 
-int
-playcard(pp)
-       PLAY    *pp;
+static int
+playcard(PLAY *pp)
 {
        int     v;
        CARD    card;
@@ -217,12 +232,15 @@ mustpick:
          case C_200:
                if (pp->nummiles[C_200] == 2)
                        return error("only two 200's per hand");
+               /* FALLTHROUGH */
          case C_100:   case C_75:
                if (pp->speed == C_LIMIT)
                        return error("limit of 50");
+               /* FALLTHROUGH */
          case C_50:
                if (pp->mileage + Value[card] > End)
                        return error("puts you over %d", End);
+               /* FALLTHROUGH */
          case C_25:
                if (!pp->can_go)
                        return error("cannot move now");
@@ -337,8 +355,8 @@ protected:
        return TRUE;
 }
 
-void
-getmove()
+static void
+getmove(void)
 {
        char    c;
 #ifdef EXTRAP
@@ -356,9 +374,9 @@ getmove()
                refresh();
                while ((c = readch()) == killchar() || c == erasechar())
                        continue;
-               if (islower(c))
-                       c = toupper(c);
-               if (isprint(c) && !isspace(c)) {
+               if (islower((unsigned char)c))
+                       c = toupper((unsigned char)c);
+               if (isprint((unsigned char)c) && !isspace((unsigned char)c)) {
                        addch(c);
                        refresh();
                }
@@ -426,10 +444,12 @@ getmove()
                  case 'Z':             /* Debug code */
                        if (!Debug && outf == NULL) {
                                char    buf[MAXPATHLEN];
+                               char    *sp;
 
                                prompt(FILEPROMPT);
                                leaveok(Board, FALSE);
                                refresh();
+over:
                                sp = buf;
                                while ((*sp = readch()) != '\n') {
                                        if (*sp == killchar())
@@ -452,7 +472,7 @@ getmove()
                                leaveok(Board, TRUE);
                                if ((outf = fopen(buf, "w")) == NULL)
                                        warn("%s", buf);
-                               setbuf(outf, (char *)NULL);
+                               setbuf(outf, NULL);
                        }
                        Debug = !Debug;
                        break;
@@ -469,9 +489,8 @@ ret:
 /*
  * return whether or not the player has picked
  */
-int
-haspicked(pp)
-       const PLAY      *pp;
+static int
+haspicked(const PLAY *pp)
 {
        int     card;
 
@@ -490,8 +509,7 @@ haspicked(pp)
 }
 
 void
-account(card)
-       CARD    card; 
+account(CARD card)
 {
        CARD    oppos;
 
@@ -516,8 +534,7 @@ account(card)
 }
 
 void
-prompt(promptno)
-       int     promptno;
+prompt(int promptno)
 {
        static const char       *const names[] = {
                                ">>:Move:",
@@ -548,8 +565,7 @@ prompt(promptno)
 }
 
 void
-sort(hand)
-       CARD    *hand;
+sort(CARD *hand)
 {
        CARD    *cp, *tp;
        CARD    temp;