]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - mille/move.c
Remove unnecessary casts, and add necessary ones for printf arguments.
[bsdgames-darwin.git] / mille / move.c
index c29baca23b68546d3acc3fa659640a62691fcd2a..d3f3a164c86e60f8a5ffda977beb38652c34fd38 100644 (file)
@@ -1,6 +1,8 @@
+/*     $NetBSD: move.c,v 1.12 1999/10/01 17:06:01 jsm Exp $    */
+
 /*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
 #ifndef lint
-static char sccsid[] = "@(#)move.c     5.4 (Berkeley) 6/1/90";
+#if 0
+static char sccsid[] = "@(#)move.c     8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: move.c,v 1.12 1999/10/01 17:06:01 jsm Exp $");
+#endif
 #endif /* not lint */
 
+#include <termios.h>
+
 #include       "mille.h"
 #ifndef        unctrl
 #include       "unctrl.h"
 #endif
 
-# ifdef        attron
-#      include <term.h>
-#      define  _tty    cur_term->Nttyb
-# endif        attron
-
 /*
  * @(#)move.c  1.2 (Berkeley) 3/28/83
  */
@@ -52,15 +56,12 @@ static char sccsid[] = "@(#)move.c  5.4 (Berkeley) 6/1/90";
 #undef CTRL
 #define        CTRL(c)         (c - 'A' + 1)
 
-char   *Movenames[] = {
-               "M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER"
-       };
-
+void
 domove()
 {
-       reg PLAY        *pp;
-       reg int         i, j;
-       reg bool        goodplay;
+       PLAY    *pp;
+       int     i, j;
+       bool    goodplay;
 
        pp = &Player[Play];
        if (Play == PLAYER)
@@ -78,7 +79,7 @@ domove()
                                else
                                        error("no card there");
                        else {
-                               if (issafety(pp->hand[Card_no])) {
+                               if (is_safety(pp->hand[Card_no])) {
                                        error("discard a safety?");
                                        goodplay = FALSE;
                                        break;
@@ -111,7 +112,7 @@ domove()
 acc:
                        if (Play == COMP) {
                                account(*Topcard);
-                               if (issafety(*Topcard))
+                               if (is_safety(*Topcard))
                                        pp->safety[*Topcard-S_CONV] = S_IN_HAND;
                        }
                        if (pp->hand[1] == C_INIT && Topcard > Deck) {
@@ -159,21 +160,22 @@ acc:
  *     Check and see if either side can go.  If they cannot,
  * the game is over
  */
-check_go() {
-
-       reg CARD        card;
-       reg PLAY        *pp, *op;
-       reg int         i;
+void
+check_go()
+{
+       CARD    card;
+       PLAY    *pp, *op;
+       int     i;
 
        for (pp = Player; pp < &Player[2]; pp++) {
                op = (pp == &Player[COMP] ? &Player[PLAYER] : &Player[COMP]);
                for (i = 0; i < HAND_SZ; i++) {
                        card = pp->hand[i];
-                       if (issafety(card) || canplay(pp, op, card)) {
+                       if (is_safety(card) || canplay(pp, op, card)) {
 #ifdef DEBUG
                                if (Debug) {
                                        fprintf(outf, "CHECK_GO: can play %s (%d), ", C_name[card], card);
-                                       fprintf(outf, "issafety(card) = %d, ", issafety(card));
+                                       fprintf(outf, "is_safety(card) = %d, ", is_safety(card));
                                        fprintf(outf, "canplay(pp, op, card) = %d\n", canplay(pp, op, card));
                                }
 #endif
@@ -189,11 +191,12 @@ check_go() {
        Finished = TRUE;
 }
 
+int
 playcard(pp)
-reg PLAY       *pp;
+       PLAY    *pp;
 {
-       reg int         v;
-       reg CARD        card;
+       int     v;
+       CARD    card;
 
        /*
         * check and see if player has picked
@@ -245,7 +248,7 @@ mustpick:
 
          case C_GO:
                if (pp->battle != C_INIT && pp->battle != C_STOP
-                   && !isrepair(pp->battle))
+                   && !is_repair(pp->battle))
                        return error("cannot play \"Go\" on a \"%s\"",
                            C_name[pp->battle]);
                pp->battle = C_GO;
@@ -287,7 +290,7 @@ protected:
          case C_DRIVE_SAFE:    case C_RIGHT_WAY:
                if (pp->battle == opposite(card)
                    || (card == C_RIGHT_WAY && pp->speed == C_LIMIT)) {
-                       if (!(card == C_RIGHT_WAY && !isrepair(pp->battle))) {
+                       if (!(card == C_RIGHT_WAY && !is_repair(pp->battle))) {
                                pp->battle = C_GO;
                                pp->can_go = TRUE;
                        }
@@ -320,7 +323,7 @@ protected:
                                pp->can_go = TRUE;
                                pp->battle = C_INIT;
                        }
-                       if (!pp->can_go && isrepair(pp->battle))
+                       if (!pp->can_go && is_repair(pp->battle))
                                pp->can_go = TRUE;
                }
                Next = -1;
@@ -334,13 +337,14 @@ protected:
        if (pp == &Player[PLAYER])
                account(card);
        pp->hand[Card_no] = C_INIT;
-       Next = (Next == -1 ? FALSE : TRUE);
+       Next = (Next == (bool)-1 ? FALSE : TRUE);
        return TRUE;
 }
 
+void
 getmove()
 {
-       reg char        c, *sp;
+       char    c;
 #ifdef EXTRAP
        static bool     last_ex = FALSE;        /* set if last command was E */
 
@@ -386,7 +390,7 @@ getmove()
                        Movetype = M_ORDER;
                        goto ret;
                  case 'Q':             /* Quit */
-                       rub();          /* Same as a rubout */
+                       rub(0);         /* Same as a rubout */
                        break;
                  case 'W':             /* Window toggle */
                        Window = nextwin(Window);
@@ -451,7 +455,7 @@ getmove()
                                *sp = '\0';
                                leaveok(Board, TRUE);
                                if ((outf = fopen(buf, "w")) == NULL)
-                                       perror(buf);
+                                       warn("%s", buf);
                                setbuf(outf, (char *)NULL);
                        }
                        Debug = !Debug;
@@ -465,13 +469,15 @@ getmove()
 ret:
        leaveok(Board, TRUE);
 }
+
 /*
  * return whether or not the player has picked
  */
+int
 haspicked(pp)
-reg PLAY       *pp; {
-
-       reg int card;
+       const PLAY      *pp;
+{
+       int     card;
 
        if (Topcard <= Deck)
                return TRUE;
@@ -487,10 +493,11 @@ reg PLAY  *pp; {
        return (pp->hand[card] != C_INIT);
 }
 
+void
 account(card)
-reg CARD       card; {
-
-       reg CARD        oppos;
+       CARD    card; 
+{
+       CARD    oppos;
 
        if (card == C_INIT)
                return;
@@ -512,10 +519,11 @@ reg CARD  card; {
                }
 }
 
+void
 prompt(promptno)
-int    promptno;
+       int     promptno;
 {
-       static char     *names[] = {
+       static const char       *const names[] = {
                                ">>:Move:",
                                "Really?",
                                "Another hand?",
@@ -543,11 +551,12 @@ int       promptno;
        clrtoeol();
 }
 
+void
 sort(hand)
-reg CARD       *hand;
+       CARD    *hand;
 {
-       reg CARD        *cp, *tp;
-       reg CARD        temp;
+       CARD    *cp, *tp;
+       CARD    temp;
 
        cp = hand;
        hand += HAND_SZ;
@@ -559,4 +568,3 @@ reg CARD    *hand;
                                *tp = temp;
                        }
 }
-