summaryrefslogtreecommitdiffstats
path: root/games/mille
diff options
context:
space:
mode:
Diffstat (limited to 'games/mille')
-rw-r--r--games/mille/comp.c7
-rw-r--r--games/mille/end.c8
-rw-r--r--games/mille/init.c4
-rw-r--r--games/mille/mille.c6
-rw-r--r--games/mille/mille.h37
-rw-r--r--games/mille/misc.c13
-rw-r--r--games/mille/move.c23
-rw-r--r--games/mille/print.c7
-rw-r--r--games/mille/roll.c1
-rw-r--r--games/mille/save.c13
-rw-r--r--games/mille/table.c68
-rw-r--r--games/mille/types.c3
-rw-r--r--games/mille/varpush.c3
13 files changed, 104 insertions, 89 deletions
diff --git a/games/mille/comp.c b/games/mille/comp.c
index 6c50457..ce42c2e 100644
--- a/games/mille/comp.c
+++ b/games/mille/comp.c
@@ -47,6 +47,7 @@ static const char rcsid[] =
# define V_VALUABLE 40
+void
calcmove()
{
CARD card;
@@ -76,7 +77,7 @@ calcmove()
switch (card) {
case C_STOP: case C_CRASH:
case C_FLAT: case C_EMPTY:
- if (playit[i] = canplay(pp, op, card))
+ if ((playit[i] = canplay(pp, op, card)) != NULL)
canstop = TRUE;
goto norm;
case C_LIMIT:
@@ -402,6 +403,7 @@ play_it:
/*
* Return true if the given player could conceivably win with his next card.
*/
+bool
onecard(pp)
PLAY *pp;
{
@@ -412,7 +414,7 @@ PLAY *pp;
card = -1;
if (pp->can_go || ((isrepair(bat) || bat == C_STOP || spd == C_LIMIT) &&
Numseen[S_RIGHT_WAY] != 0) ||
- bat >= 0 && Numseen[safety(bat)] != 0)
+ (bat >= 0 && Numseen[safety(bat)] != 0))
switch (End - pp->mileage) {
case 200:
if (pp->nummiles[C_200] == 2)
@@ -434,6 +436,7 @@ PLAY *pp;
return FALSE;
}
+bool
canplay(pp, op, card)
PLAY *pp, *op;
CARD card;
diff --git a/games/mille/end.c b/games/mille/end.c
index 9c80521..c8d736c 100644
--- a/games/mille/end.c
+++ b/games/mille/end.c
@@ -45,10 +45,16 @@ static const char rcsid[] =
* @(#)end.c 1.1 (Berkeley) 4/1/82
*/
+#ifndef EXTRAP
+void extrapolate __P((PLAY *));
+void undoex __P((void));
+#endif
+
/*
* print out the score as if it was final, and add the totals for
* the end-of-games points to the user who deserves it (if any).
*/
+void
finalscore(pp)
PLAY *pp; {
@@ -93,6 +99,7 @@ static int Last_tot[2]; /* last tot used for extrapolate */
* print out the score as if it was final, and add the totals for
* the end-of-games points to the user who deserves it (if any).
*/
+void
extrapolate(pp)
PLAY *pp; {
@@ -137,6 +144,7 @@ extrapolate(pp)
Last_tot[num] = tot;
}
+void
undoex() {
reg PLAY *pp;
diff --git a/games/mille/init.c b/games/mille/init.c
index 3a89a69..f29ed22 100644
--- a/games/mille/init.c
+++ b/games/mille/init.c
@@ -45,6 +45,7 @@ static const char rcsid[] =
* @(#)init.c 1.1 (Berkeley) 4/1/82
*/
+void
init() {
PLAY *pp;
@@ -88,6 +89,7 @@ init() {
End = 700;
}
+void
shuffle() {
int i, r;
@@ -106,6 +108,7 @@ shuffle() {
Topcard = &Deck[DECK_SZ];
}
+void
newboard() {
int i;
@@ -164,6 +167,7 @@ newboard() {
newscore();
}
+void
newscore() {
int i, new;
diff --git a/games/mille/mille.c b/games/mille/mille.c
index eb6f6ff..0495d11 100644
--- a/games/mille/mille.c
+++ b/games/mille/mille.c
@@ -58,9 +58,6 @@ static const char rcsid[] =
* @(#)mille.c 1.3 (Berkeley) 5/10/83
*/
-void check_more __P((void));
-void die __P((int));
-void rub();
static void usage __P((void));
int
@@ -153,7 +150,8 @@ usage()
* quit.
*/
void
-rub() {
+rub(sig)
+int sig; {
(void)signal(SIGINT, SIG_IGN);
if (getyn(REALLYPROMPT))
diff --git a/games/mille/mille.h b/games/mille/mille.h
index 8269fdb..2f94e41 100644
--- a/games/mille/mille.h
+++ b/games/mille/mille.h
@@ -36,10 +36,12 @@
*/
# include <sys/types.h>
+# include <sys/uio.h>
# include <ctype.h>
# include <curses.h>
# include <string.h>
# include <stdlib.h>
+# include <unistd.h>
/*
* @(#)mille.h 1.1 (Berkeley) 4/1/82
@@ -230,4 +232,37 @@ extern WINDOW *Board, *Miles, *Score;
* functions
*/
-CARD getcard();
+void account __P((CARD));
+void calcmove __P((void));
+bool canplay __P((PLAY *, PLAY *, CARD));
+bool check_ext __P((bool));
+void check_more __P((void));
+void die __P((int));
+void domove __P((void));
+bool error __P((char *, ...));
+#ifdef EXTRAP
+void extrapolate __P((PLAY *));
+#endif
+void finalscore __P((PLAY *));
+CARD getcard __P((void));
+bool getyn __P((int));
+void init __P((void));
+int isrepair __P((CARD));
+void newboard __P((void));
+void newscore __P((void));
+bool onecard __P((PLAY *));
+void prboard __P((void));
+void prompt __P((int));
+void prscore __P((bool));
+char readch __P((void));
+bool rest_f __P((char *));
+int roll __P((int, int));
+void rub __P((int));
+CARD safety __P((CARD));
+bool save __P((void));
+void shuffle __P((void));
+void sort __P((CARD *));
+void varpush __P((int, int (*)()));
+#ifdef EXTRAP
+void undoex __P((void));
+#endif
diff --git a/games/mille/misc.c b/games/mille/misc.c
index ebedd22..ee428bc 100644
--- a/games/mille/misc.c
+++ b/games/mille/misc.c
@@ -40,10 +40,10 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/file.h>
+#include <stdarg.h>
#include <termios.h>
#include "mille.h"
-#include <unctrl.h>
# ifdef attron
@@ -58,11 +58,15 @@ static const char rcsid[] =
#define NUMSAFE 4
/* VARARGS1 */
-error(str, arg)
-char *str;
+bool
+error(char *str, ...)
{
+ va_list arg;
+
+ va_start(arg, str);
stdscr = Score;
mvprintw(ERR_Y, ERR_X, str, arg);
+ va_end(arg);
clrtoeol();
putchar('\07');
refresh();
@@ -119,6 +123,7 @@ cont: ;
}
}
+bool
check_ext(forcomp)
bool forcomp; {
@@ -173,6 +178,7 @@ done:
* Get a yes or no answer to the given question. Saves are
* also allowed. Return TRUE if the answer was yes, FALSE if no.
*/
+bool
getyn(promptno)
int promptno; {
@@ -245,6 +251,7 @@ check_more()
die(0);
}
+char
readch()
{
int cnt;
diff --git a/games/mille/move.c b/games/mille/move.c
index 117e7a6..b67acfd 100644
--- a/games/mille/move.c
+++ b/games/mille/move.c
@@ -56,10 +56,16 @@ static const char rcsid[] =
#undef CTRL
#define CTRL(c) (c - 'A' + 1)
-char *Movenames[] = {
+const char *Movenames[] = {
"M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER"
};
+static void check_go __P((void));
+static void getmove __P((void));
+static int haspicked __P((PLAY *));
+static bool playcard __P((PLAY *));
+
+void
domove()
{
PLAY *pp;
@@ -163,6 +169,7 @@ acc:
* Check and see if either side can go. If they cannot,
* the game is over
*/
+static void
check_go() {
CARD card;
@@ -193,6 +200,7 @@ check_go() {
Finished = TRUE;
}
+static bool
playcard(pp)
PLAY *pp;
{
@@ -342,9 +350,13 @@ protected:
return TRUE;
}
+static void
getmove()
{
- char c, *sp;
+ char c;
+#ifdef DEBUG
+ char *sp;
+#endif
#ifdef EXTRAP
static bool last_ex = FALSE; /* set if last command was E */
@@ -390,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);
@@ -472,6 +484,7 @@ ret:
/*
* return whether or not the player has picked
*/
+static int
haspicked(pp)
PLAY *pp; {
@@ -491,6 +504,7 @@ PLAY *pp; {
return (pp->hand[card] != C_INIT);
}
+void
account(card)
CARD card; {
@@ -516,6 +530,7 @@ CARD card; {
}
}
+void
prompt(promptno)
int promptno;
{
@@ -547,6 +562,7 @@ int promptno;
clrtoeol();
}
+void
sort(hand)
CARD *hand;
{
@@ -563,4 +579,3 @@ CARD *hand;
*tp = temp;
}
}
-
diff --git a/games/mille/print.c b/games/mille/print.c
index 8cc271a..a373168 100644
--- a/games/mille/print.c
+++ b/games/mille/print.c
@@ -48,6 +48,10 @@ static const char rcsid[] =
# define COMP_STRT 20
# define CARD_STRT 2
+static void show_card __P((int, int, CARD, CARD *));
+static void show_score __P((int, int, int, int *));
+
+void
prboard() {
PLAY *pp;
@@ -102,6 +106,7 @@ prboard() {
* show_card:
* Show the given card if it is different from the last one shown
*/
+static void
show_card(y, x, c, lc)
int y, x;
CARD c, *lc;
@@ -115,6 +120,7 @@ CARD c, *lc;
static char Score_fmt[] = "%4d";
+void
prscore(for_real)
bool for_real; {
@@ -161,6 +167,7 @@ bool for_real; {
* Show a score value if it is different from the last time we
* showed it.
*/
+static void
show_score(y, x, s, ls)
int y, x;
int s, *ls;
diff --git a/games/mille/roll.c b/games/mille/roll.c
index 6a99fb9..714b51f 100644
--- a/games/mille/roll.c
+++ b/games/mille/roll.c
@@ -48,6 +48,7 @@ static const char rcsid[] =
*
*/
+int
roll(ndie, nsides)
int ndie, nsides; {
diff --git a/games/mille/save.c b/games/mille/save.c
index 3bd1887..c9c2951 100644
--- a/games/mille/save.c
+++ b/games/mille/save.c
@@ -41,8 +41,11 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/uio.h>
+#include <fcntl.h>
#include <string.h>
#include <termios.h>
+#include <unistd.h>
#include "mille.h"
#include <unctrl.h>
@@ -58,14 +61,11 @@ static const char rcsid[] =
typedef struct stat STAT;
-char *ctime();
-
-int read(), write();
-
/*
* This routine saves the current game for use at a later date
*/
+bool
save() {
extern int errno;
@@ -76,6 +76,7 @@ save() {
time_t tme;
STAT junk;
+ sp = NULL;
tp = &tme;
if (Fromfile && getyn(SAMEFILEPROMPT))
strcpy(buf, Fromfile);
@@ -128,7 +129,8 @@ over:
wrefresh(Score);
time(tp); /* get current time */
strcpy(buf, ctime(tp));
- for (sp = buf; *sp != '\n'; sp++)
+ sp = buf;
+ for (; *sp != '\n'; sp++)
continue;
*sp = '\0';
varpush(outf, write);
@@ -144,6 +146,7 @@ over:
* backup was made on exiting, in which case certain things must
* be cleaned up before the game starts.
*/
+bool
rest_f(file)
char *file; {
diff --git a/games/mille/table.c b/games/mille/table.c
deleted file mode 100644
index 75240b9..0000000
--- a/games/mille/table.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1982, 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1982, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-# define DEBUG
-
-/*
- * @(#)table.c 1.1 (Berkeley) 4/1/82
- */
-
-# include "mille.h"
-
-main() {
-
- int i, j, count;
-
- printf(" %16s -> %5s %5s %4s %s\n", "Card", "cards", "count", "need", "opposite");
- for (i = 0; i < NUM_CARDS - 1; i++) {
- for (j = 0, count = 0; j < DECK_SZ; j++)
- if (Deck[j] == i)
- count++;
- printf("%2d %16s -> %5d %5d %4d %s\n", i, C_name[i], Numcards[i], count, Numneed[i], C_name[opposite(i)]);
- }
-}
-
diff --git a/games/mille/types.c b/games/mille/types.c
index ec51694..d54f46f 100644
--- a/games/mille/types.c
+++ b/games/mille/types.c
@@ -45,12 +45,14 @@ static const char rcsid[] =
* @(#)types.c 1.1 (Berkeley) 4/1/82
*/
+int
isrepair(card)
CARD card; {
return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT;
}
+CARD
safety(card)
CARD card; {
@@ -75,5 +77,6 @@ CARD card; {
return C_RIGHT_WAY;
}
/* NOTREACHED */
+ exit(EXIT_FAILURE);
}
diff --git a/games/mille/varpush.c b/games/mille/varpush.c
index 70bf17a..853f005 100644
--- a/games/mille/varpush.c
+++ b/games/mille/varpush.c
@@ -46,12 +46,11 @@ static const char rcsid[] =
* @(#)varpush.c 1.1 (Berkeley) 4/1/82
*/
-int read(), write();
-
/*
* push variables around via the routine func() on the file
* channel file. func() is either read or write.
*/
+void
varpush(file, func)
int file;
int (*func)(); {
OpenPOWER on IntegriCloud