]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - monop/prop.c
add a 'down' key to tetris, defaulting to 'n'. it move the block down
[bsdgames-darwin.git] / monop / prop.c
index c1a016f5f8495b546efb7f5487af2e97814213c2..0b6bef81dd0eb2efa1606e4281503882c380e460 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $     */
+/*     $NetBSD: prop.c,v 1.20 2012/06/19 05:35:32 dholland Exp $       */
 
 /*
  * Copyright (c) 1980, 1993
  * 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.
  *
 #if 0
 static char sccsid[] = "@(#)prop.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $");
+__RCSID("$NetBSD: prop.c,v 1.20 2012/06/19 05:35:32 dholland Exp $");
 #endif
 #endif /* not lint */
 
 #include <stdlib.h>
-#include "monop.ext"
 
-static int value __P((SQUARE *));
+#include "monop.h"
+
+static int value(SQUARE *);
 
 /*
  *     This routine deals with buying property, setting all the
  * appropriate flags.
  */
 void
-buy(player, sqrp)
-       int player;
-       SQUARE *sqrp;
+buy(int playernum, SQUARE *sqrp)
 {
        trading = FALSE;
-       sqrp->owner = player;
-       add_list(player, &(play[player].own_list), cur_p->loc);
+       sqrp->owner = playernum;
+       add_list(playernum, &(play[playernum].own_list), cur_p->loc);
 }
 
 /*
  *     This routine adds an item to the list.
  */
 void
-add_list(plr, head, op_sqr)
-       int plr;
-       OWN **head;
-       int op_sqr; 
+add_list(int plr, OWN **head, int op_sqr)
 {
        int val;
        OWN *tp, *last_tp;
        OWN *op;
 
-       op = (OWN *)calloc(1, sizeof (OWN));
+       op = calloc(1, sizeof (OWN));
        if (op == NULL)
                errx(1, "out of memory");
        op->sqr = &board[op_sqr];
@@ -100,10 +92,7 @@ add_list(plr, head, op_sqr)
  *     This routine deletes property from the list.
  */
 void
-del_list(plr, head, op_sqr)
-       int plr;
-       OWN **head;
-       short op_sqr;
+del_list(int plr, OWN **head, short op_sqr)
 {
        OWN *op, *last_op;
 
@@ -124,6 +113,8 @@ del_list(plr, head, op_sqr)
                        break;
                else
                        last_op = op;
+       if (op == NULL)
+               return;
        if (last_op == NULL)
                *head = op->next;
        else {
@@ -137,8 +128,7 @@ del_list(plr, head, op_sqr)
  * given square.
  */
 static int
-value(sqp)
-       SQUARE *sqp;
+value(SQUARE *sqp)
 {
        int sqr;
 
@@ -161,15 +151,14 @@ value(sqp)
 }
 
 /*
- *     This routine accepts bids for the current peice
- * of property.
+ * This routine accepts bids for the current piece of property.
  */
 void
-bid()
+bid(void)
 {
        static bool in[MAX_PL];
        int i, num_in, cur_max;
-       char buf[80];
+       char buf[257];
        int cur_bid;
 
        printf("\nSo it goes up for auction.  Type your bid after your name\n");
@@ -182,17 +171,21 @@ bid()
                i = (i + 1) % num_play;
                if (in[i]) {
                        do {
-                               (void)sprintf(buf, "%s: ", name_list[i]);
+                               (void)snprintf(buf, sizeof(buf), "%s: ",
+                                   name_list[i]);
                                cur_bid = get_int(buf);
                                if (cur_bid == 0) {
                                        in[i] = FALSE;
                                        if (--num_in == 0)
                                                break;
-                               }
-                               else if (cur_bid <= cur_max) {
+                               } else if (cur_bid <= cur_max) {
                                        printf("You must bid higher than %d "
                                            "to stay in\n", cur_max);
                                        printf("(bid of 0 drops you out)\n");
+                               } else if (cur_bid > play[i].money) {
+                                       printf("You can't bid more than your cash ($%d)\n",
+                                           play[i].money);
+                                       cur_bid = -1;
                                }
                        } while (cur_bid != 0 && cur_bid <= cur_max);
                        cur_max = (cur_bid ? cur_bid : cur_max);
@@ -215,8 +208,7 @@ bid()
  * of given player.
  */
 int
-prop_worth(plp)
-       PLAY *plp;
+prop_worth(PLAY *plp)
 {
        OWN *op;
        int worth;