X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/a77b3f8edc13dc6efdbcf80e336689cfa1de08ab..571fdd8c925268b4be1b866ff8f96c140bfe0ef9:/monop/trade.c diff --git a/monop/trade.c b/monop/trade.c index 1a0b8fbc..63d2e8a9 100644 --- a/monop/trade.c +++ b/monop/trade.c @@ -1,4 +1,4 @@ -/* $NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $ */ +/* $NetBSD: trade.c,v 1.16 2012/06/19 05:35:32 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -12,11 +12,7 @@ * 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 + * 3. 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. * @@ -38,11 +34,11 @@ #if 0 static char sccsid[] = "@(#)trade.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $"); +__RCSID("$NetBSD: trade.c,v 1.16 2012/06/19 05:35:32 dholland Exp $"); #endif #endif /* not lint */ -#include "monop.ext" +#include "monop.h" struct trd_st { /* how much to give to other player */ int trader; /* trader number */ @@ -53,23 +49,22 @@ struct trd_st { /* how much to give to other player */ typedef struct trd_st TRADE; -static char *plist[MAX_PRP+2]; +static const char *plist[MAX_PRP+2]; static int used[MAX_PRP]; static TRADE trades[2]; -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 *)); +static void get_list(int, int ); +static int set_list(OWN *); +static void summate(void); +static void do_trade(void); +static void move_em(TRADE *, TRADE *); void -trade() +trade(void) { - - int tradee, i; + int tradee, i; trading = TRUE; for (i = 0; i < 2; i++) { @@ -101,20 +96,19 @@ over: if (getyn("Is the trade ok? ") == 0) do_trade(); } + /* * 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; +get_list(int struct_no, int play_no) { - - int sn, pn; - PLAY *pp; - int numin, prop, num_prp; - OWN *op; - TRADE *tp; + int sn, pn; + PLAY *pp; + int numin, propnum, num_prp; + OWN *op; + TRADE *tp; for (numin = 0; numin < MAX_PRP; numin++) used[numin] = FALSE; @@ -126,16 +120,16 @@ int struct_no, play_no; if (pp->own_list) { numin = set_list(pp->own_list); for (num_prp = numin; num_prp; ) { - prop = getinp("Which property do you wish to trade? ", + propnum=getinp("Which property do you wish to trade? ", plist); - if (prop == numin) + if (propnum == numin) break; - else if (used[prop]) + else if (used[propnum]) printf("You've already allocated that.\n"); else { num_prp--; - used[prop] = TRUE; - for (op = pp->own_list; prop--; op = op->next) + used[propnum] = TRUE; + for (op = pp->own_list; propnum--; op = op->next) continue; add_list(pn, &(tp->prop_list), sqnum(op->sqr)); } @@ -155,16 +149,15 @@ once_more: } } } + /* * This routine sets up the list of tradable property. */ static int -set_list(the_list) -OWN *the_list; +set_list(OWN *the_list) { - - int i; - OWN *op; + int i; + OWN *op; i = 0; for (op = the_list; op; op = op->next) @@ -174,17 +167,17 @@ OWN *the_list; plist[i--] = 0; return i; } + /* * This routine summates the trade. */ static void -summate() +summate(void) { - - bool some; - int i; - TRADE *tp; - OWN *op; + bool some; + int i; + TRADE *tp; + OWN *op; for (i = 0; i < 2; i++) { tp = &trades[i]; @@ -205,26 +198,25 @@ summate() printf("\t-- Nothing --\n"); } } + /* * This routine actually executes the trade. */ static void -do_trade() +do_trade(void) { - move_em(&trades[0], &trades[1]); move_em(&trades[1], &trades[0]); } + /* * This routine does a switch from one player to another */ static void -move_em(from, to) -TRADE *from, *to; +move_em(TRADE *from, TRADE *to) { - - PLAY *pl_fr, *pl_to; - OWN *op; + PLAY *pl_fr, *pl_to; + OWN *op; pl_fr = &play[from->trader]; pl_to = &play[to->trader]; @@ -240,16 +232,16 @@ TRADE *from, *to; } set_ownlist(to->trader); } + /* * This routine lets a player resign */ void -resign() +resign(void) { - - int i, new_own; - OWN *op; - SQUARE *sqp; + int i, new_own; + OWN *op; + SQUARE *sqp; if (cur_p->money <= 0) { switch (board[cur_p->loc].type) { @@ -257,6 +249,9 @@ resign() case RR: case PRPTY: new_own = board[cur_p->loc].owner; + /* If you ran out of money by buying current location */ + if (new_own == player) + new_own = num_play; break; default: /* Chance, taxes, etc */ new_own = num_play; @@ -305,23 +300,24 @@ resign() sqp->owner = -1; sqp->desc->morg = FALSE; if (sqp->type == PRPTY) { - isnot_monop(sqp->desc->mon_desc); + is_not_monop(sqp->desc->mon_desc); sqp->desc->houses = 0; } } if (cur_p->num_gojf) ret_card(cur_p); } + free(play[player].name); for (i = player; i < num_play; i++) { name_list[i] = name_list[i+1]; if (i + 1 < num_play) - play[i] = play[i+1]; + play[i] = play[i+1]; } - name_list[num_play--] = 0; + name_list[num_play--] = NULL; for (i = 0; i < N_SQRS; i++) if (board[i].owner > player) --board[i].owner; - player = --player < 0 ? num_play - 1 : player; + player = player == 0 ? num_play - 1 : player - 1; next_play(); if (num_play < 2) { printf("\nThen %s WINS!!!!!\n", play[0].name);