summaryrefslogtreecommitdiff
path: root/games/mille/move.c
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1998-09-22 04:08:26 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1998-09-22 04:08:26 +0000
commit63ce38ea6d817d922d71550704c9284994be18e0 (patch)
tree82962a4ae4f208abc8eefc440aa0d12ee4a75749 /games/mille/move.c
parent6636e97531a7dda416334308b7ce853ee42de781 (diff)
NetBSD changes and further fixes (reformatted man page, better handling of
user input).
Diffstat (limited to 'games/mille/move.c')
-rw-r--r--games/mille/move.c78
1 files changed, 47 insertions, 31 deletions
diff --git a/games/mille/move.c b/games/mille/move.c
index d05befb82b8..0f4aa63a146 100644
--- a/games/mille/move.c
+++ b/games/mille/move.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $ */
/* $NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $ */
/*
@@ -37,12 +38,15 @@
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $";
+static char rcsid[] = "$OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $";
#endif
#endif /* not lint */
-#include <termios.h>
+#ifdef DEBUG
+#include <sys/param.h>
+#endif
+#include <termios.h>
#include "mille.h"
# ifdef attron
@@ -61,11 +65,12 @@ char *Movenames[] = {
"M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER"
};
+void
domove()
{
- register PLAY *pp;
- register int i, j;
- register bool goodplay;
+ PLAY *pp;
+ int i, j;
+ bool goodplay;
pp = &Player[Play];
if (Play == PLAYER)
@@ -77,12 +82,12 @@ domove()
switch (Movetype) {
case M_DISCARD:
if (haspicked(pp)) {
- if (pp->hand[Card_no] == C_INIT)
+ if (pp->hand[Card_no] == C_INIT) {
if (Card_no == 6)
Finished = TRUE;
else
error("no card there");
- else {
+ } else {
if (issafety(pp->hand[Card_no])) {
error("discard a safety?");
goodplay = FALSE;
@@ -164,11 +169,12 @@ acc:
* Check and see if either side can go. If they cannot,
* the game is over
*/
-check_go() {
-
- register CARD card;
- register PLAY *pp, *op;
- register 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]);
@@ -194,11 +200,12 @@ check_go() {
Finished = TRUE;
}
+int
playcard(pp)
-register PLAY *pp;
+ PLAY *pp;
{
- register int v;
- register CARD card;
+ int v;
+ CARD card;
/*
* check and see if player has picked
@@ -343,9 +350,13 @@ protected:
return TRUE;
}
+void
getmove()
{
- register char c, *sp;
+ char c;
+#ifdef DEBUG
+ char *sp;
+#endif
#ifdef EXTRAP
static bool last_ex = FALSE; /* set if last command was E */
@@ -391,7 +402,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);
@@ -431,12 +442,13 @@ getmove()
case 'Z': /* Debug code */
if (!Debug && outf == NULL) {
char buf[MAXPATHLEN];
-
+over:
prompt(FILEPROMPT);
leaveok(Board, FALSE);
refresh();
sp = buf;
- while ((*sp = readch()) != '\n') {
+ while ((*sp = readch()) != '\n' && *sp != '\r'
+ && (sp - buf < sizeof(buf))) {
if (*sp == killchar())
goto over;
else if (*sp == erasechar()) {
@@ -456,7 +468,7 @@ getmove()
*sp = '\0';
leaveok(Board, TRUE);
if ((outf = fopen(buf, "w")) == NULL)
- perror(buf);
+ warn("%s", buf);
setbuf(outf, (char *)NULL);
}
Debug = !Debug;
@@ -470,13 +482,15 @@ getmove()
ret:
leaveok(Board, TRUE);
}
+
/*
* return whether or not the player has picked
*/
+int
haspicked(pp)
-register PLAY *pp; {
-
- register int card;
+ PLAY *pp;
+{
+ int card;
if (Topcard <= Deck)
return TRUE;
@@ -492,10 +506,11 @@ register PLAY *pp; {
return (pp->hand[card] != C_INIT);
}
+void
account(card)
-register CARD card; {
-
- register CARD oppos;
+ CARD card;
+{
+ CARD oppos;
if (card == C_INIT)
return;
@@ -517,8 +532,9 @@ register CARD card; {
}
}
+void
prompt(promptno)
-int promptno;
+ int promptno;
{
static char *names[] = {
">>:Move:",
@@ -548,11 +564,12 @@ int promptno;
clrtoeol();
}
+void
sort(hand)
-register CARD *hand;
+ CARD *hand;
{
- register CARD *cp, *tp;
- register CARD temp;
+ CARD *cp, *tp;
+ CARD temp;
cp = hand;
hand += HAND_SZ;
@@ -564,4 +581,3 @@ register CARD *hand;
*tp = temp;
}
}
-