From a77b3f8edc13dc6efdbcf80e336689cfa1de08ab Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 12 Oct 1997 17:45:06 +0000 Subject: WARNSify --- monop/Makefile | 8 +--- monop/cards.c | 29 ++++++++++----- monop/execute.c | 87 +++++++++++++++++++++++-------------------- monop/getinp.c | 31 +++++++++------- monop/houses.c | 66 ++++++++++++++++++++------------- monop/initdeck.c | 37 ++++++++++++------- monop/jail.c | 28 ++++++++++---- monop/misc.c | 93 +++++++++++++++++++++++++--------------------- monop/monop.c | 67 ++++++++++++++++++++++----------- monop/monop.def | 15 +++----- monop/monop.ext | 10 +++-- monop/monop.h | 111 +++++++++++++++++++++++++++++++++++++++++++------------ monop/morg.c | 60 +++++++++++++++++++++--------- monop/print.c | 48 ++++++++++++++---------- monop/prop.c | 56 +++++++++++++++++----------- monop/rent.c | 15 +++++--- monop/roll.c | 21 +++++++---- monop/spec.c | 31 ++++++++++++---- monop/trade.c | 79 ++++++++++++++++++++++++--------------- 19 files changed, 564 insertions(+), 328 deletions(-) (limited to 'monop') diff --git a/monop/Makefile b/monop/Makefile index c374447d..52f3fbda 100644 --- a/monop/Makefile +++ b/monop/Makefile @@ -1,13 +1,10 @@ -# $NetBSD: Makefile,v 1.16 1997/10/12 14:21:48 lukem Exp $ +# $NetBSD: Makefile,v 1.17 1997/10/12 17:45:06 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -WARNS= 0 PROG= monop SRCS= monop.c cards.c execute.c getinp.c houses.c jail.c misc.c morg.c \ print.c prop.c rent.c roll.c spec.c trade.c MAN= monop.6 -DPADD+= ${LIBCOMPAT} -LDADD+= -lcompat HIDEGAME=hidegame CLEANFILES+=initdeck cards.pck FILES=cards.pck @@ -18,7 +15,4 @@ monop: cards.pck cards.pck: initdeck ${.OBJDIR}/initdeck ${.CURDIR}/cards.inp -initdeck: initdeck.c - ${HOST_CC} ${HOST_CFLAGS} ${HOST_LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${.CURDIR}/initdeck.c - .include diff --git a/monop/cards.c b/monop/cards.c index b65f0f26..29c9d887 100644 --- a/monop/cards.c +++ b/monop/cards.c @@ -1,4 +1,4 @@ -/* $NetBSD: cards.c,v 1.3 1995/03/23 08:34:35 cgd Exp $ */ +/* $NetBSD: cards.c,v 1.4 1997/10/12 17:45:07 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: cards.c,v 1.3 1995/03/23 08:34:35 cgd Exp $"; +__RCSID("$NetBSD: cards.c,v 1.4 1997/10/12 17:45:07 christos Exp $"); #endif #endif /* not lint */ @@ -58,11 +59,16 @@ static char *cardfile = "cards.pck"; static FILE *deckf; +static void set_up __P((DECK *)); +static void printmes __P((void)); + /* * This routine initializes the decks from the data file, * which it opens. */ -init_decks() { +void +init_decks() +{ if ((deckf=fopen(cardfile, "r")) == NULL) { file_err: @@ -77,10 +83,11 @@ file_err: /* * This routine sets up the offset pointers for the given deck. */ +static void set_up(dp) DECK *dp; { - reg int r1, r2; + int r1, r2; int i; dp->offsets = (long *) calloc(sizeof (long), dp->num_cards); @@ -91,7 +98,7 @@ DECK *dp; { dp->last_card = 0; dp->gojf_used = FALSE; for (i = 0; i < dp->num_cards; i++) { - reg long temp; + long temp; r1 = roll(1, dp->num_cards) - 1; r2 = roll(1, dp->num_cards) - 1; @@ -103,11 +110,13 @@ DECK *dp; { /* * This routine draws a card from the given deck */ +void get_card(dp) -DECK *dp; { +DECK *dp; +{ - reg char type_maj, type_min; - reg int num; + char type_maj, type_min; + int num; int i, per_h, per_H, num_h, num_H; OWN *op; @@ -198,12 +207,14 @@ DECK *dp; { } spec = FALSE; } + /* * This routine prints out the message on the card */ +static void printmes() { - reg char c; + char c; printline(); fflush(stdout); diff --git a/monop/execute.c b/monop/execute.c index f4f49ab4..40f2b776 100644 --- a/monop/execute.c +++ b/monop/execute.c @@ -1,4 +1,4 @@ -/* $NetBSD: execute.c,v 1.3 1995/03/23 08:34:38 cgd Exp $ */ +/* $NetBSD: execute.c,v 1.4 1997/10/12 17:45:09 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,37 +33,41 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: execute.c,v 1.3 1995/03/23 08:34:38 cgd Exp $"; +__RCSID("$NetBSD: execute.c,v 1.4 1997/10/12 17:45:09 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" -# include -# include -# include +#include "monop.ext" +#include +#include +#include +#include +#include +#include # define SEGSIZE 8192 typedef struct stat STAT; typedef struct tm TIME; -extern char etext[], /* end of text space */ - rub(); - -static char buf[257], - *yn_only[] = { "yes", "no"}; +static char buf[257]; static bool new_play; /* set if move on to new player */ +static void show_move __P((void)); + /* * This routine executes the given command by index number */ +void execute(com_num) -reg int com_num; { +int com_num; +{ new_play = FALSE; /* new_play is true if fixing */ (*func[com_num])(); @@ -77,10 +81,12 @@ reg int com_num; { /* * This routine moves a piece around. */ -do_move() { +void +do_move() +{ - reg int r1, r2; - reg bool was_jail; + int r1, r2; + bool was_jail; new_play = was_jail = FALSE; printf("roll is %d, %d\n", r1=roll(1, 6), r2=roll(1, 6)); @@ -108,10 +114,12 @@ ret: /* * This routine moves a normal move */ +void move(rl) -reg int rl; { +int rl; +{ - reg int old_loc; + int old_loc; old_loc = cur_p->loc; cur_p->loc = (cur_p->loc + rl) % N_SQRS; @@ -124,9 +132,11 @@ reg int rl; { /* * This routine shows the results of a move */ -show_move() { +static void +show_move() +{ - reg SQUARE *sqp; + SQUARE *sqp; sqp = &board[cur_p->loc]; printf("That puts you on %s\n", sqp->name); @@ -154,7 +164,7 @@ show_move() { cur_p->money -= sqp->cost; } else if (num_play > 2) - bid(sqp); + bid(); } else if (sqp->owner == player) printf("You own it.\n"); @@ -165,14 +175,15 @@ show_move() { /* * This routine saves the current game for use at a later date */ -save() { +void +save() +{ - reg char *sp; - reg int outf, num; + char *sp; + int outf, num; time_t t; - int *dat_end; struct stat sb; - unsgn start, end; + char *start, *end; printf("Which file do you wish to save it in? "); sp = buf; @@ -185,7 +196,7 @@ save() { */ if (stat(buf, &sb) > -1 - && getyn("File exists. Do you wish to overwrite? ", yn_only) > 0) + && getyn("File exists. Do you wish to overwrite? ") > 0) return; if ((outf=creat(buf, 0644)) < 0) { @@ -198,11 +209,7 @@ save() { for (sp = buf; *sp != '\n'; sp++) continue; *sp = '\0'; -# if 0 - start = (((int) etext + (SEGSIZE-1)) / SEGSIZE ) * SEGSIZE; -# else start = 0; -# endif end = sbrk(0); while (start < end) { /* write out entire data space */ num = start + 16 * 1024 > end ? end - start : 16 * 1024; @@ -215,9 +222,11 @@ save() { /* * This routine restores an old game from a file */ -restore() { +void +restore() +{ - reg char *sp; + char *sp; printf("Which file do you wish to restore from? "); for (sp = buf; (*sp=getchar()) != '\n'; sp++) @@ -229,13 +238,15 @@ restore() { * This does the actual restoring. It returns TRUE if the * backup was successful, else false. */ +int rest_f(file) -reg char *file; { +char *file; +{ - reg char *sp; - reg int inf, num; + char *sp; + int inf, num; char buf[80]; - unsgn start, end; + char *start, *end; STAT sbuf; if ((inf=open(file, 0)) < 0) { @@ -247,11 +258,7 @@ reg char *file; { perror(file); exit(1); } -# if 0 - start = (((int) etext + (SEGSIZE-1)) / SEGSIZE ) * SEGSIZE; -# else start = 0; -# endif brk(end = start + sbuf.st_size); while (start < end) { /* write out entire data space */ num = start + 16 * 1024 > end ? end - start : 16 * 1024; diff --git a/monop/getinp.c b/monop/getinp.c index 5de77f8d..cbb8dc42 100644 --- a/monop/getinp.c +++ b/monop/getinp.c @@ -1,4 +1,4 @@ -/* $NetBSD: getinp.c,v 1.5 1997/03/29 20:42:22 thorpej Exp $ */ +/* $NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,32 +33,34 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: getinp.c,v 1.5 1997/03/29 20:42:22 thorpej Exp $"; +__RCSID("$NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $"); #endif #endif /* not lint */ -# include -# include -# include - -# define reg register +#include +#include +#include +#include "monop.ext" # define LINE 70 static char buf[257]; +static int comp __P((char *)); + +int getinp(prompt, list) -char *prompt, *list[]; { +char *prompt, *list[]; +{ - reg int i, n_match, match; + int i, n_match, match = 0; char *sp; int c; - int plen; - static int comp(); for (;;) { inter: @@ -108,11 +110,12 @@ inter: } } -static +static int comp(s1) -char *s1; { +char *s1; +{ - reg char *sp, *tsp, c; + char *sp, *tsp, c; if (buf[0] != '\0') for (sp = buf, tsp = s1; *sp; ) { diff --git a/monop/houses.c b/monop/houses.c index 1cb4b0a3..bda0ad7b 100644 --- a/monop/houses.c +++ b/monop/houses.c @@ -1,4 +1,4 @@ -/* $NetBSD: houses.c,v 1.3 1995/03/23 08:34:40 cgd Exp $ */ +/* $NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,29 +33,35 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: houses.c,v 1.3 1995/03/23 08:34:40 cgd Exp $"; +__RCSID("$NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" static char *names[N_MON+2], cur_prop[80]; static MON *monops[N_MON]; +static void buy_h __P((MON *)); +static void sell_h __P((MON *)); +static void list_cur __P((MON *)); /* * These routines deal with buying and selling houses */ -buy_houses() { +void +buy_houses() +{ - reg int num_mon; - reg MON *mp; - reg OWN *op; + int num_mon; + MON *mp; + OWN *op; bool good,got_morg; int i,p; @@ -104,13 +110,15 @@ over: } } +static void buy_h(mnp) -MON *mnp; { +MON *mnp; +{ - reg int i; - reg MON *mp; - reg int price; - shrt input[3],temp[3]; + int i; + MON *mp; + int price; + short input[3],temp[3]; int tot; PROP *pp; @@ -150,7 +158,7 @@ err: printf("That makes the spread too wide. Try again\n"); tot += input[i]; if (tot) { printf("You asked for %d houses for $%d\n", tot, tot * price); - if (getyn("Is that ok? ", yn) == 0) { + if (getyn("Is that ok? ") == 0) { cur_p->money -= tot * price; for (tot = i = 0; i < mp->num_in; i++) mp->sq[i]->desc->houses = temp[i]; @@ -161,11 +169,13 @@ err: printf("That makes the spread too wide. Try again\n"); /* * This routine sells houses. */ -sell_houses() { +void +sell_houses() +{ - reg int num_mon; - reg MON *mp; - reg OWN *op; + int num_mon; + MON *mp; + OWN *op; bool good; int p; @@ -203,13 +213,15 @@ over: } } +static void sell_h(mnp) -MON *mnp; { +MON *mnp; +{ - reg int i; - reg MON *mp; - reg int price; - shrt input[3],temp[3]; + int i; + MON *mp; + int price; + short input[3],temp[3]; int tot; PROP *pp; @@ -250,7 +262,7 @@ err: printf("That makes the spread too wide. Try again\n"); tot += input[i]; if (tot) { printf("You asked to sell %d houses for $%d\n",tot,tot * price); - if (getyn("Is that ok? ", yn) == 0) { + if (getyn("Is that ok? ") == 0) { cur_p->money += tot * price; for (tot = i = 0; i < mp->num_in; i++) mp->sq[i]->desc->houses = temp[i]; @@ -258,11 +270,13 @@ err: printf("That makes the spread too wide. Try again\n"); } } +static void list_cur(mp) -reg MON *mp; { +MON *mp; +{ - reg int i; - reg SQUARE *sqp; + int i; + SQUARE *sqp; for (i = 0; i < mp->num_in; i++) { sqp = mp->sq[i]; diff --git a/monop/initdeck.c b/monop/initdeck.c index 7d79c31c..f1e36c4c 100644 --- a/monop/initdeck.c +++ b/monop/initdeck.c @@ -1,4 +1,4 @@ -/* $NetBSD: initdeck.c,v 1.4 1997/03/29 20:42:23 thorpej Exp $ */ +/* $NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,22 +33,23 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: initdeck.c,v 1.4 1997/03/29 20:42:23 thorpej Exp $"; +__RCSID("$NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $"); #endif #endif /* not lint */ -# include -# include "deck.h" +#include +#include +#include "deck.h" /* * This program initializes the card files for monopoly. @@ -70,13 +71,17 @@ static char rcsid[] = "$NetBSD: initdeck.c,v 1.4 1997/03/29 20:42:23 thorpej Exp char *infile = "cards.inp", /* input file */ *outfile = "cards.pck"; /* "packed" file */ -extern long ftell(); -extern char *calloc(); - DECK deck[2]; FILE *inf, *outf; +/* initdeck.c */ +int main __P((int, char *[])); +static void getargs __P((int, char *[])); +static void count __P((void)); +static void putem __P((void)); + +int main(ac, av) int ac; char *av[]; { @@ -113,9 +118,11 @@ char *av[]; { exit(0); } +static void getargs(ac, av) int ac; -char *av[]; { +char *av[]; +{ if (ac > 1) infile = av[1]; @@ -126,7 +133,9 @@ char *av[]; { /* * count the cards */ -count() { +static void +count() +{ reg bool newline; reg DECK *in_deck; @@ -148,7 +157,9 @@ count() { /* * put strings in the file */ -putem() { +static void +putem() +{ reg bool newline; reg DECK *in_deck; diff --git a/monop/jail.c b/monop/jail.c index 06055315..8c03e9bf 100644 --- a/monop/jail.c +++ b/monop/jail.c @@ -1,4 +1,4 @@ -/* $NetBSD: jail.c,v 1.3 1995/03/23 08:34:44 cgd Exp $ */ +/* $NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,21 +33,24 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: jail.c,v 1.3 1995/03/23 08:34:44 cgd Exp $"; +__RCSID("$NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" /* * This routine uses a get-out-of-jail-free card to get the * player out of jail. */ -card() { +void +card() +{ if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); @@ -65,8 +68,10 @@ card() { * This routine returns the players get-out-of-jail-free card * to a deck. */ +void ret_card(plr) -reg PLAY *plr; { +PLAY *plr; +{ plr->num_gojf--; if (CC_D.gojf_used) @@ -77,7 +82,9 @@ reg PLAY *plr; { /* * This routine deals with paying your way out of jail. */ -pay() { +void +pay() +{ if (cur_p->loc != JAIL) { printf("But you're not IN Jail\n"); @@ -91,8 +98,10 @@ pay() { /* * This routine deals with a move in jail */ +int move_jail(r1, r2) -reg int r1, r2; { +int r1, r2; +{ if (r1 != r2) { printf("Sorry, that doesn't get you out\n"); @@ -113,7 +122,10 @@ moveit: goto moveit; } } -printturn() { + +void +printturn() +{ if (cur_p->loc != JAIL) return; diff --git a/monop/misc.c b/monop/misc.c index 00d301e2..20d5c367 100644 --- a/monop/misc.c +++ b/monop/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.5 1997/03/29 20:42:24 thorpej Exp $ */ +/* $NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: misc.c,v 1.5 1997/03/29 20:42:24 thorpej Exp $"; +__RCSID("$NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $"); #endif #endif /* not lint */ @@ -49,10 +50,12 @@ static char rcsid[] = "$NetBSD: misc.c,v 1.5 1997/03/29 20:42:24 thorpej Exp $"; * This routine executes a truncated set of commands until a * "yes or "no" answer is gotten. */ +int getyn(prompt) -reg char *prompt; { +char *prompt; +{ - reg int com; + int com; for (;;) if ((com=getinp(prompt, yn)) < 2) @@ -63,7 +66,9 @@ reg char *prompt; { /* * This routine tells the player if he's out of money. */ -notify() { +void +notify() +{ if (cur_p->money < 0) printf("That leaves you $%d in debt\n", -cur_p->money); @@ -77,7 +82,9 @@ notify() { /* * This routine switches to the next player */ -next_play() { +void +next_play() +{ player = ++player % num_play; cur_p = &play[player]; @@ -87,11 +94,13 @@ next_play() { * This routine gets an integer from the keyboard after the * given prompt. */ +int get_int(prompt) -reg char *prompt; { +char *prompt; +{ - reg int num; - reg char *sp; + int num; + char *sp; int c; char buf[257]; @@ -118,12 +127,14 @@ inter: /* * This routine sets the monopoly flag from the list given. */ +void set_ownlist(pl) -int pl; { +int pl; +{ - reg int num; /* general counter */ - reg MON *orig; /* remember starting monop ptr */ - reg OWN *op; /* current owned prop */ + int num; /* general counter */ + MON *orig; /* remember starting monop ptr */ + OWN *op; /* current owned prop */ OWN *orig_op; /* origianl prop before loop */ op = play[pl].own_list; @@ -186,17 +197,17 @@ int pl; { printf("num = %d\n"); #endif if (orig == 0) { - printf("panic: bad monopoly descriptor: orig = %d\n", orig); + printf("panic: bad monopoly descriptor: orig = %p\n", orig); printf("player # %d\n", pl+1); printhold(pl); - printf("orig_op = %d\n", orig_op); + printf("orig_op = %p\n", orig_op); printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type); - printf("orig_op->next = %d\n", op->next); - printf("orig_op->sqr->desc = %d\n", op->sqr->desc); - printf("op = %d\n", op); + printf("orig_op->next = %p\n", op->next); + printf("orig_op->sqr->desc = %p\n", op->sqr->desc); + printf("op = %p\n", op); printf("op->sqr->type = %d (PRPTY)\n", op->sqr->type); - printf("op->next = %d\n", op->next); - printf("op->sqr->desc = %d\n", op->sqr->desc); + printf("op->next = %p\n", op->next); + printf("op->sqr->desc = %p\n", op->sqr->desc); printf("num = %d\n", num); } #ifdef DEBUG @@ -213,12 +224,13 @@ int pl; { /* * This routine sets things up as if it is a new monopoly */ +void is_monop(mp, pl) -reg MON *mp; -int pl; { +MON *mp; +int pl; +{ - reg char *sp; - reg int i; + int i; mp->owner = pl; mp->num_own = mp->num_in; @@ -229,11 +241,12 @@ int pl; { /* * This routine sets things up as if it is no longer a monopoly */ +void isnot_monop(mp) -reg MON *mp; { +MON *mp; +{ - reg char *sp; - reg int i; + int i; mp->owner = -1; for (i = 0; i < mp->num_in; i++) @@ -243,16 +256,20 @@ reg MON *mp; { /* * This routine gives a list of the current player's routine */ -list() { +void +list() +{ printhold(player); } /* * This routine gives a list of a given players holdings */ -list_all() { +void +list_all() +{ - reg int pl; + int pl; while ((pl=getinp("Whose holdings do you want to see? ", name_list)) < num_play) printhold(pl); @@ -261,20 +278,10 @@ list_all() { * This routine gives the players a chance before it exits. */ void -quit() { +quit() +{ putchar('\n'); - if (getyn("Do you all really want to quit? ", yn) == 0) + if (getyn("Do you all really want to quit? ") == 0) exit(0); - signal(SIGINT, quit); -} -/* - * This routine copies one structure to another - */ -cpy_st(s1, s2, size) -reg int *s1, *s2, size; { - - size /= 2; - while (size--) - *s1++ = *s2++; } diff --git a/monop/monop.c b/monop/monop.c index 8e335226..4e77db29 100644 --- a/monop/monop.c +++ b/monop/monop.c @@ -1,4 +1,4 @@ -/* $NetBSD: monop.c,v 1.3 1995/03/23 08:34:52 cgd Exp $ */ +/* $NetBSD: monop.c,v 1.4 1997/10/12 17:45:16 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,28 +33,39 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: monop.c,v 1.3 1995/03/23 08:34:52 cgd Exp $"; +__RCSID("$NetBSD: monop.c,v 1.4 1997/10/12 17:45:16 christos Exp $"); #endif #endif /* not lint */ -# include "monop.def" +#include +#include +#include +#include +#include "monop.def" + +int main __P((int, char *[])); +static void getplayers __P((void)); +static void init_players __P((void)); +static void init_monops __P((void)); +static void do_quit __P((int)); /* * This program implements a monopoly game */ +int main(ac, av) -reg int ac; -reg char *av[]; { +int ac; +char *av[]; { srand(getpid()); @@ -69,7 +80,7 @@ reg char *av[]; { } num_luck = sizeof lucky_mes / sizeof (char *); init_decks(); - signal(2, quit); + signal(2, do_quit); for (;;) { printf("\n%s (%d) (cash $%d) on %s\n", cur_p->name, player + 1, cur_p->money, board[cur_p->loc].name); @@ -78,13 +89,23 @@ reg char *av[]; { execute(getinp("-- Command: ", comlist)); } } + +/*ARGSUSED*/ +static void +do_quit(n) + int n; +{ + quit(); +} /* * This routine gets the names of the players */ -getplayers() { +static void +getplayers() +{ - reg char *sp; - reg int i, j; + char *sp; + int i, j; char buf[257]; blew_it: @@ -117,19 +138,21 @@ over: else printf("\"done\" is a reserved word. Please try again\n"); for (i = 0; i < num_play; i++) - cfree(play[i].name); - cfree(play); + free(play[i].name); + free(play); goto blew_it; } } /* * This routine figures out who goes first */ -init_players() { +static void +init_players() +{ - reg int i, rl, cur_max; - bool over; - int max_pl; + int i, rl, cur_max; + bool over = 0; + int max_pl = 0; again: putchar('\n'); @@ -155,10 +178,12 @@ again: /* * This routine initalizes the monopoly structures. */ -init_monops() { +static void +init_monops() +{ - reg MON *mp; - reg int i; + MON *mp; + int i; for (mp = mon; mp < &mon[N_MON]; mp++) { mp->name = mp->not_m; diff --git a/monop/monop.def b/monop/monop.def index 344c4f49..54ecd6c9 100644 --- a/monop/monop.def +++ b/monop/monop.def @@ -1,4 +1,4 @@ -/* $NetBSD: monop.def,v 1.3 1995/03/23 08:34:54 cgd Exp $ */ +/* $NetBSD: monop.def,v 1.4 1997/10/12 17:45:18 christos Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -35,8 +35,8 @@ * @(#)monop.def 5.5 (Berkeley) 5/31/93 */ -# include "monop.h" # include "deck.h" +# include "monop.h" bool fixing, /* set if fixing up debt */ trading, /* set if in process of trading */ @@ -77,13 +77,10 @@ int player, /* current player number */ num_play, /* current number of players */ num_doub, /* # of doubles current player rolled */ /* # of "got lucky" messages */ - num_luck = sizeof lucky_mes / sizeof (char *), - /* list of command functions */ - buy_houses(), card(), do_move(), do_move(), list(), list_all(), - mortgage(), pay(), printboard(), quit(), resign(), restore(), - rub(), save(), sell_houses(), trade(), - unmortgage(), where(), - (*func[])() = { /* array of function calls for commands */ + num_luck = sizeof lucky_mes / sizeof (char *); + +/* list of command functions */ +void (*func[]) __P((void)) = { /* array of function calls for commands */ quit, /* quit game |* 0 *| */ printboard, /* print board |* 1 *| */ where, /* where players are |* 2 *| */ diff --git a/monop/monop.ext b/monop/monop.ext index ea955a88..a83fee42 100644 --- a/monop/monop.ext +++ b/monop/monop.ext @@ -1,4 +1,4 @@ -/* $NetBSD: monop.ext,v 1.2 1995/03/23 08:34:58 cgd Exp $ */ +/* $NetBSD: monop.ext,v 1.3 1997/10/12 17:45:19 christos Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -35,14 +35,16 @@ * @(#)monop.ext 5.4 (Berkeley) 5/31/93 */ -# include "monop.h" -# include "deck.h" +#include "deck.h" +#include "monop.h" extern bool trading, spec, fixing, told_em; extern char *yn[], *comlist[], *name_list[], *lucky_mes[]; -extern int num_play, player, num_doub, num_luck, (*func[])(); +extern int num_play, player, num_doub, num_luck; + +extern void (*func[]) __P((void)); extern DECK deck[2]; diff --git a/monop/monop.h b/monop/monop.h index 1c7b161d..adb8703d 100644 --- a/monop/monop.h +++ b/monop/monop.h @@ -1,4 +1,4 @@ -/* $NetBSD: monop.h,v 1.5 1997/03/29 20:42:25 thorpej Exp $ */ +/* $NetBSD: monop.h,v 1.6 1997/10/12 17:45:20 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,14 +39,7 @@ # include # include -# define reg register -#ifdef __CHAR_UNSIGNED__ -# define shrt short -#else -# define shrt char -#endif # define bool char -# define unsgn unsigned # define TRUE (1) # define FALSE (0) @@ -84,8 +77,8 @@ struct sqr_st { /* structure for square */ char *name; /* place name */ - shrt owner; /* owner number */ - shrt type; /* place type */ + short owner; /* owner number */ + short type; /* place type */ struct prp_st *desc; /* description struct */ int cost; /* cost */ }; @@ -94,13 +87,13 @@ typedef struct sqr_st SQUARE; struct mon_st { /* monopoly description structure */ char *name; /* monop. name (color) */ - shrt owner; /* owner of monopoly */ - shrt num_in; /* # in monopoly */ - shrt num_own; /* # owned (-1: not poss. monop)*/ - shrt h_cost; /* price of houses */ + short owner; /* owner of monopoly */ + short num_in; /* # in monopoly */ + short num_own; /* # owned (-1: not poss. monop)*/ + short h_cost; /* price of houses */ char *not_m; /* name if not monopoly */ char *mon_n; /* name if a monopoly */ - char sqnums[3]; /* Square numbers (used to init)*/ + unsigned char sqnums[3]; /* Square numbers (used to init)*/ SQUARE *sq[3]; /* list of squares in monop */ }; @@ -113,8 +106,8 @@ typedef struct mon_st MON; struct prp_st { /* property description structure */ bool morg; /* set if mortgaged */ bool monop; /* set if monopoly */ - shrt square; /* square description */ - shrt houses; /* number of houses */ + short square; /* square description */ + short houses; /* number of houses */ MON *mon_desc; /* name of color */ int rent[6]; /* rents */ }; @@ -128,11 +121,11 @@ typedef struct own_st OWN; struct plr_st { /* player description structure */ char *name; /* owner name */ - shrt num_gojf; /* # of get-out-of-jail-free's */ - shrt num_rr; /* # of railroads owned */ - shrt num_util; /* # of water works/elec. co. */ - shrt loc; /* location on board */ - shrt in_jail; /* count of turns in jail */ + short num_gojf; /* # of get-out-of-jail-free's */ + short num_rr; /* # of railroads owned */ + short num_util; /* # of water works/elec. co. */ + short loc; /* location on board */ + short in_jail; /* count of turns in jail */ int money; /* amount of money */ OWN *own_list; /* start of propery list */ }; @@ -142,4 +135,76 @@ typedef struct prp_st PROP; typedef struct prp_st RR_S; typedef struct prp_st UTIL_S; -int cc(), chance(), lux_tax(), goto_jail(), inc_tax(); + +/* cards.c */ +void init_decks __P((void)); +void get_card __P((DECK *)); + +/* execute.c */ +void execute __P((int)); +void do_move __P((void)); +void move __P((int)); +void save __P((void)); +void restore __P((void)); +int rest_f __P((char *)); + +/* getinp.c */ +int getinp __P((char *, char *[])); + +/* houses.c */ +void buy_houses __P((void)); +void sell_houses __P((void)); + +/* jail.c */ +void card __P((void)); +void ret_card __P((PLAY *)); +void pay __P((void)); +int move_jail __P((int, int )); +void printturn __P((void)); + +/* misc.c */ +int getyn __P((char *)); +void notify __P((void)); +void next_play __P((void)); +int get_int __P((char *)); +void set_ownlist __P((int)); +void is_monop __P((MON *, int)); +void isnot_monop __P((MON *)); +void list __P((void)); +void list_all __P((void)); +void quit __P((void)); + +/* morg.c */ +void mortgage __P((void)); +void unmortgage __P((void)); +void force_morg __P((void)); + +/* print.c */ +void printboard __P((void)); +void where __P((void)); +void printsq __P((int, bool)); +void printhold __P((int)); + +/* prop.c */ +void buy __P((int, SQUARE *)); +void add_list __P((int, OWN **, int)); +void del_list __P((int, OWN **, short)); +void bid __P((void)); +int prop_worth __P((PLAY *)); + +/* rent.c */ +void rent __P((SQUARE *)); + +/* roll.c */ +int roll __P((int, int)); + +/* spec.c */ +void inc_tax __P((void)); +void goto_jail __P((void)); +void lux_tax __P((void)); +void cc __P((void)); +void chance __P((void)); + +/* trade.c */ +void trade __P((void)); +void resign __P((void)); diff --git a/monop/morg.c b/monop/morg.c index 95708564..04690a37 100644 --- a/monop/morg.c +++ b/monop/morg.c @@ -1,4 +1,4 @@ -/* $NetBSD: morg.c,v 1.4 1995/03/23 08:35:02 cgd Exp $ */ +/* $NetBSD: morg.c,v 1.5 1997/10/12 17:45:21 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)morg.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: morg.c,v 1.4 1995/03/23 08:35:02 cgd Exp $"; +__RCSID("$NetBSD: morg.c,v 1.5 1997/10/12 17:45:21 christos Exp $"); #endif #endif /* not lint */ @@ -67,18 +68,27 @@ static char *names[MAX_PRP+2], 0 }; -static shrt square[MAX_PRP+2]; +static short square[MAX_PRP+2]; static int num_good,got_houses; + +static int set_mlist __P((void)); +static void m __P((int)); +static int set_umlist __P((void)); +static void unm __P((int)); +static void fix_ex __P((int)); + /* * This routine is the command level response the mortgage command. * it gets the list of mortgageable property and asks which are to * be mortgaged. */ -mortgage() { +void +mortgage() +{ - reg int prop; + int prop; for (;;) { if (set_mlist() == 0) { @@ -98,15 +108,17 @@ mortgage() { if (prop == num_good) return; m(square[prop]); - notify(cur_p); + notify(); } } /* * This routine sets up the list of mortgageable property */ -set_mlist() { +static int +set_mlist() +{ - reg OWN *op; + OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) @@ -124,10 +136,12 @@ set_mlist() { /* * This routine actually mortgages the property. */ +static void m(prop) -reg int prop; { +int prop; +{ - reg int price; + int price; price = board[prop].cost/2; board[prop].desc->morg = TRUE; @@ -139,9 +153,11 @@ reg int prop; { * command. It gets the list of mortgaged property and asks which are * to be unmortgaged. */ -unmortgage() { +void +unmortgage() +{ - reg int prop; + int prop; for (;;) { if (set_umlist() == 0) { @@ -163,9 +179,11 @@ unmortgage() { /* * This routine sets up the list of mortgaged property */ -set_umlist() { +static int +set_umlist() +{ - reg OWN *op; + OWN *op; num_good = 0; for (op = cur_p->own_list; op; op = op->next) @@ -180,10 +198,12 @@ set_umlist() { /* * This routine actually unmortgages the property */ +static void unm(prop) -reg int prop; { +int prop; +{ - reg int price; + int price; price = board[prop].cost/2; board[prop].desc->morg = FALSE; @@ -196,7 +216,9 @@ reg int prop; { * This routine forces the indebted player to fix his * financial woes. */ -force_morg() { +void +force_morg() +{ told_em = fixing = TRUE; while (cur_p->money <= 0) @@ -206,8 +228,10 @@ force_morg() { /* * This routine is a special execute for the force_morg routine */ +static void fix_ex(com_num) -reg int com_num; { +int com_num; +{ told_em = FALSE; (*func[com_num])(); diff --git a/monop/print.c b/monop/print.c index eb49d1fc..0b921d77 100644 --- a/monop/print.c +++ b/monop/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.3 1995/03/23 08:35:05 cgd Exp $ */ +/* $NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,25 +33,29 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: print.c,v 1.3 1995/03/23 08:35:05 cgd Exp $"; +__RCSID("$NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $"); #endif #endif /* not lint */ # include "monop.ext" -static char buf[80], /* output buffer */ - *header = "Name Own Price Mg # Rent"; +static char *header = "Name Own Price Mg # Rent"; + +static void printmorg __P((SQUARE *)); /* * This routine prints out the current board */ -printboard() { +void +printboard() +{ - reg int i; + int i; printf("%s\t%s\n", header, header); for (i = 0; i < N_SQRS/2; i++) { @@ -63,10 +67,11 @@ printboard() { /* * This routine lists where each player is. */ -where() { +void +where() +{ - reg int i; - char *bsp; + int i; printf("%s Player\n", header); for (i = 0; i < num_play; i++) { @@ -80,14 +85,15 @@ where() { /* * This routine prints out an individual square */ +void printsq(sqn, eoln) int sqn; -reg bool eoln; { +bool eoln; +{ - reg int rnt; - reg PROP *pp; - reg SQUARE *sqp; - int i; + int rnt; + PROP *pp; + SQUARE *sqp; sqp = &board[sqn]; printf("%-10.10s", sqp->name); @@ -99,7 +105,6 @@ reg bool eoln; { case GOTO_J: case LUX_TAX: case IN_JAIL: -spec: if (!eoln) printf(" "); break; @@ -160,8 +165,10 @@ spec: /* * This routine prints out the mortgage flag. */ +static void printmorg(sqp) -reg SQUARE *sqp; { +SQUARE *sqp; +{ if (sqp->desc->morg) printf(" * "); @@ -171,12 +178,13 @@ reg SQUARE *sqp; { /* * This routine lists the holdings of the player given */ +void printhold(pl) -reg int pl; { +int pl; +{ - reg OWN *op; - reg PLAY *pp; - char *bsp; + OWN *op; + PLAY *pp; pp = &play[pl]; printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1, diff --git a/monop/prop.c b/monop/prop.c index 77b1f6f1..cf853189 100644 --- a/monop/prop.c +++ b/monop/prop.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop.c,v 1.3 1995/03/23 08:35:06 cgd Exp $ */ +/* $NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,25 +33,29 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)prop.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: prop.c,v 1.3 1995/03/23 08:35:06 cgd Exp $"; +__RCSID("$NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include +#include "monop.ext" -extern char *calloc(); +static int value __P((SQUARE *)); /* * This routine deals with buying property, setting all the * appropriate flags. */ +void buy(player, sqrp) -reg int player; -reg SQUARE *sqrp; { +int player; +SQUARE *sqrp; +{ trading = FALSE; sqrp->owner = player; @@ -60,14 +64,15 @@ reg SQUARE *sqrp; { /* * This routine adds an item to the list. */ +void add_list(plr, head, op_sqr) int plr; OWN **head; -int op_sqr; { +int op_sqr; +{ - reg int val; - reg OWN *tp, *last_tp; - MON *mp; + int val; + OWN *tp, *last_tp; OWN *op; op = (OWN *)calloc(1, sizeof (OWN)); @@ -76,7 +81,7 @@ int op_sqr; { last_tp = NULL; for (tp = *head; tp && value(tp->sqr) < val; tp = tp->next) if (val == value(tp->sqr)) { - cfree(op); + free(op); return; } else @@ -92,13 +97,14 @@ int op_sqr; { /* * This routine deletes property from the list. */ +void del_list(plr, head, op_sqr) int plr; OWN **head; -shrt op_sqr; { +short op_sqr; +{ - reg int i; - reg OWN *op, *last_op; + OWN *op, *last_op; switch (board[op_sqr].type) { case PRPTY: @@ -121,17 +127,19 @@ shrt op_sqr; { *head = op->next; else { last_op->next = op->next; - cfree(op); + free(op); } } /* * This routine calculates the value for sorting of the * given square. */ +static int value(sqp) -reg SQUARE *sqp; { +SQUARE *sqp; +{ - reg int sqr; + int sqr; sqr = sqnum(sqp); switch (sqp->type) { @@ -154,10 +162,12 @@ reg SQUARE *sqp; { * This routine accepts bids for the current peice * of property. */ -bid() { +void +bid() +{ static bool in[MAX_PL]; - reg int i, num_in, cur_max; + int i, num_in, cur_max; char buf[80]; int cur_bid; @@ -200,11 +210,13 @@ bid() { * This routine calculates the value of the property * of given player. */ +int prop_worth(plp) -reg PLAY *plp; { +PLAY *plp; +{ - reg OWN *op; - reg int worth; + OWN *op; + int worth; worth = 0; for (op = plp->own_list; op; op = op->next) { diff --git a/monop/rent.c b/monop/rent.c index ef915bb8..0269d170 100644 --- a/monop/rent.c +++ b/monop/rent.c @@ -1,4 +1,4 @@ -/* $NetBSD: rent.c,v 1.3 1995/03/23 08:35:11 cgd Exp $ */ +/* $NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,24 +33,27 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)rent.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: rent.c,v 1.3 1995/03/23 08:35:11 cgd Exp $"; +__RCSID("$NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" /* * This routine has the player pay rent */ +void rent(sqp) -reg SQUARE *sqp; { +SQUARE *sqp; +{ - reg int rnt; - reg PROP *pp; + int rnt = 0; + PROP *pp; PLAY *plp; plp = &play[sqp->owner]; diff --git a/monop/roll.c b/monop/roll.c index ddf38a2e..a0e9e1c8 100644 --- a/monop/roll.c +++ b/monop/roll.c @@ -1,4 +1,4 @@ -/* $NetBSD: roll.c,v 1.5 1995/03/23 08:35:13 cgd Exp $ */ +/* $NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,14 +33,16 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: roll.c,v 1.5 1995/03/23 08:35:13 cgd Exp $"; +__RCSID("$NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $"); #endif #endif /* not lint */ +#include "monop.ext" #include /* @@ -52,11 +54,13 @@ static char rcsid[] = "$NetBSD: roll.c,v 1.5 1995/03/23 08:35:13 cgd Exp $"; # if defined(pdp11) # define MAXRAND 32767L +int roll(ndie, nsides) -int ndie, nsides; { +int ndie, nsides; +{ - reg long tot; - reg unsigned n, r; + long tot; + unsigned n, r; tot = 0; n = ndie; @@ -67,11 +71,12 @@ int ndie, nsides; { # else +int roll(ndie, nsides) -reg int ndie, nsides; { +int ndie, nsides; { - reg int tot, r; - reg double num_sides; + int tot, r; + double num_sides; num_sides = nsides; tot = 0; diff --git a/monop/spec.c b/monop/spec.c index 5b8f32e1..b5f68395 100644 --- a/monop/spec.c +++ b/monop/spec.c @@ -1,4 +1,4 @@ -/* $NetBSD: spec.c,v 1.3 1995/03/23 08:35:16 cgd Exp $ */ +/* $NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,11 +33,12 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: spec.c,v 1.3 1995/03/23 08:35:16 cgd Exp $"; +__RCSID("$NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $"); #endif #endif /* not lint */ @@ -47,9 +48,11 @@ static char *perc[] = { "10%", "ten percent", "%", "$200", "200", 0 }; -inc_tax() { /* collect income tax */ +void +inc_tax() +{ /* collect income tax */ - reg int worth, com_num; + int worth, com_num; com_num = getinp("Do you wish to lose 10%% of your total worth or $200? ", perc); worth = cur_p->money + prop_worth(cur_p); @@ -73,20 +76,32 @@ inc_tax() { /* collect income tax */ if (worth == 200) lucky("\nIt makes no difference! "); } -goto_jail() { /* move player to jail */ + +void +goto_jail() +{ /* move player to jail */ cur_p->loc = JAIL; } -lux_tax() { /* landing on luxury tax */ + +void +lux_tax() +{ /* landing on luxury tax */ printf("You lose $75\n"); cur_p->money -= 75; } -cc() { /* draw community chest card */ + +void +cc() +{ /* draw community chest card */ get_card(&CC_D); } -chance() { /* draw chance card */ + +void +chance() +{ /* draw chance card */ get_card(&CH_D); } diff --git a/monop/trade.c b/monop/trade.c index e8207f99..1a0b8fbc 100644 --- a/monop/trade.c +++ b/monop/trade.c @@ -1,4 +1,4 @@ -/* $NetBSD: trade.c,v 1.3 1995/03/23 08:35:19 cgd Exp $ */ +/* $NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,15 +33,16 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)trade.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: trade.c,v 1.3 1995/03/23 08:35:19 cgd Exp $"; +__RCSID("$NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $"); #endif #endif /* not lint */ -# include "monop.ext" +#include "monop.ext" struct trd_st { /* how much to give to other player */ int trader; /* trader number */ @@ -52,15 +53,23 @@ struct trd_st { /* how much to give to other player */ typedef struct trd_st TRADE; -static char *list[MAX_PRP+2]; +static char *plist[MAX_PRP+2]; static int used[MAX_PRP]; static TRADE trades[2]; -trade() { +static void get_list __P((int, int )); +static int set_list __P((OWN *)); +static void summate __P((void)); +static void do_trade __P((void)); +static void move_em __P((TRADE *, TRADE *)); - reg int tradee, i; +void +trade() +{ + + int tradee, i; trading = TRUE; for (i = 0; i < 2; i++) { @@ -96,11 +105,13 @@ over: * This routine gets the list of things to be trader for the * player, and puts in the structure given. */ +static void get_list(struct_no, play_no) -int struct_no, play_no; { +int struct_no, play_no; +{ - reg int sn, pn; - reg PLAY *pp; + int sn, pn; + PLAY *pp; int numin, prop, num_prp; OWN *op; TRADE *tp; @@ -116,7 +127,7 @@ int struct_no, play_no; { numin = set_list(pp->own_list); for (num_prp = numin; num_prp; ) { prop = getinp("Which property do you wish to trade? ", - list); + plist); if (prop == numin) break; else if (used[prop]) @@ -147,28 +158,32 @@ once_more: /* * This routine sets up the list of tradable property. */ +static int set_list(the_list) -reg OWN *the_list; { +OWN *the_list; +{ - reg int i; - reg OWN *op; + int i; + OWN *op; i = 0; for (op = the_list; op; op = op->next) if (!used[i]) - list[i++] = op->sqr->name; - list[i++] = "done"; - list[i--] = 0; + plist[i++] = op->sqr->name; + plist[i++] = "done"; + plist[i--] = 0; return i; } /* * This routine summates the trade. */ -summate() { +static void +summate() +{ - reg bool some; - reg int i; - reg TRADE *tp; + bool some; + int i; + TRADE *tp; OWN *op; for (i = 0; i < 2; i++) { @@ -193,7 +208,9 @@ summate() { /* * This routine actually executes the trade. */ -do_trade() { +static void +do_trade() +{ move_em(&trades[0], &trades[1]); move_em(&trades[1], &trades[0]); @@ -201,11 +218,13 @@ do_trade() { /* * This routine does a switch from one player to another */ +static void move_em(from, to) -TRADE *from, *to; { +TRADE *from, *to; +{ - reg PLAY *pl_fr, *pl_to; - reg OWN *op; + PLAY *pl_fr, *pl_to; + OWN *op; pl_fr = &play[from->trader]; pl_to = &play[to->trader]; @@ -224,10 +243,12 @@ TRADE *from, *to; { /* * This routine lets a player resign */ -resign() { +void +resign() +{ - reg int i, new_own; - reg OWN *op; + int i, new_own; + OWN *op; SQUARE *sqp; if (cur_p->money <= 0) { @@ -260,7 +281,7 @@ resign() { } while (new_own == player); name_list[num_play] = "done"; } - if (getyn("Do you really want to resign? ", yn) != 0) + if (getyn("Do you really want to resign? ") != 0) return; if (num_play == 1) { printf("Then NOBODY wins (not even YOU!)\n"); @@ -294,7 +315,7 @@ resign() { for (i = player; i < num_play; i++) { name_list[i] = name_list[i+1]; if (i + 1 < num_play) - cpy_st(&play[i], &play[i+1], sizeof (PLAY)); + play[i] = play[i+1]; } name_list[num_play--] = 0; for (i = 0; i < N_SQRS; i++) -- cgit v1.2.3-56-ge451