copy in from cvs; cvs2svn fucked up big time

git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
2003-12-19 19:12:08 +00:00
parent 351c8ca204
commit 51eabc017b
310 changed files with 7852 additions and 5005 deletions

View File

@@ -1,21 +1,25 @@
# $NetBSD: Makefile,v 1.18 1998/09/12 19:05:48 wrstuden Exp $
# $NetBSD: Makefile,v 1.22 2002/03/05 21:30:41 thorpej Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
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
HIDEGAME=hidegame
CLEANFILES+=initdeck cards.pck
.if ${MKSHARE} != "no"
FILES=cards.pck
FILESDIR=/usr/share/games
.endif
monop: cards.pck
realall: ${FILES}
initdeck: initdeck.c
${HOST_LINK.c} -o initdeck ${.CURDIR}/initdeck.c
cards.pck: initdeck
${.OBJDIR}/initdeck ${.CURDIR}/cards.inp
./initdeck ${.CURDIR}/cards.inp
.include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for monop
#
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
# 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. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
monop_CLEANFILES := cards.pck
monop_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(MONOP_CARDSFILE))

View File

@@ -1,4 +1,4 @@
/* $NetBSD: cards.c,v 1.5 1998/08/30 09:19:39 veego Exp $ */
/* $NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,24 +38,26 @@
#if 0
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: cards.c,v 1.5 1998/08/30 09:19:39 veego Exp $");
__RCSID("$NetBSD: cards.c,v 1.12 2002/08/12 02:38:13 itojun Exp $");
#endif
#endif /* not lint */
# include "monop.ext"
# include "pathnames.h"
#include <sys/types.h>
#include <sys/endian.h>
#include "monop.ext"
#include "pathnames.h"
/*
* These routine deal with the card decks
*/
# define GOJF 'F' /* char for get-out-of-jail-free cards */
#define GOJF 'F' /* char for get-out-of-jail-free cards */
# ifndef DEV
static char *cardfile = _PATH_CARDS;
# else
static char *cardfile = "cards.pck";
# endif
#ifndef DEV
static const char *cardfile = _PATH_CARDS;
#else
static const char *cardfile = "cards.pck";
#endif
static FILE *deckf;
@@ -69,36 +71,51 @@ static void printmes __P((void));
void
init_decks()
{
int32_t nc;
if ((deckf=fopen(cardfile, "r")) == NULL) {
file_err:
perror(cardfile);
exit(1);
}
if (fread(deck, sizeof (DECK), 2, deckf) != 2)
/* read number of community chest cards... */
if (fread(&nc, sizeof(nc), 1, deckf) != 1)
goto file_err;
CC_D.num_cards = be32toh(nc);
/* ... and number of community chest cards. */
if (fread(&nc, sizeof(nc), 1, deckf) != 1)
goto file_err;
CH_D.num_cards = be32toh(nc);
set_up(&CC_D);
set_up(&CH_D);
}
/*
* This routine sets up the offset pointers for the given deck.
*/
static void
set_up(dp)
DECK *dp; {
DECK *dp;
{
int r1, r2;
int i;
int r1, r2;
int i;
dp->offsets = (long *) calloc(sizeof (long), dp->num_cards);
if (fread(dp->offsets, sizeof(long), dp->num_cards, deckf) != (size_t)dp->num_cards) {
dp->offsets = (u_int64_t *) calloc(dp->num_cards, sizeof (u_int64_t));
if (dp->offsets == NULL)
err(1, NULL);
if (fread(dp->offsets, sizeof(u_int64_t), dp->num_cards, deckf) !=
(size_t)dp->num_cards) {
perror(cardfile);
exit(1);
}
/* convert offsets from big-endian byte order */
for (i = 0; i < dp->num_cards; i++)
BE64TOH(dp->offsets[i]);
dp->last_card = 0;
dp->gojf_used = FALSE;
for (i = 0; i < dp->num_cards; i++) {
long temp;
u_int64_t temp;
r1 = roll(1, dp->num_cards) - 1;
r2 = roll(1, dp->num_cards) - 1;
@@ -107,26 +124,26 @@ DECK *dp; {
dp->offsets[r1] = temp;
}
}
/*
* This routine draws a card from the given deck
*/
void
get_card(dp)
DECK *dp;
DECK *dp;
{
char type_maj, type_min;
int num;
int i, per_h, per_H, num_h, num_H;
OWN *op;
char type_maj, type_min;
int num;
int i, per_h, per_H, num_h, num_H;
OWN *op;
do {
fseek(deckf, dp->offsets[dp->last_card], 0);
fseek(deckf, dp->offsets[dp->last_card], SEEK_SET);
dp->last_card = ++(dp->last_card) % dp->num_cards;
type_maj = getc(deckf);
} while (dp->gojf_used && type_maj == GOJF);
type_min = getc(deckf);
num = getw(deckf);
num = ntohl(getw(deckf));
printmes();
switch (type_maj) {
case '+': /* get money */
@@ -195,7 +212,9 @@ DECK *dp;
num_h += op->sqr->desc->houses;
}
num = per_h * num_h + per_H * num_H;
printf("You had %d Houses and %d Hotels, so that cost you $%d\n", num_h, num_H, num);
printf(
"You had %d Houses and %d Hotels, so that cost you $%d\n",
num_h, num_H, num);
if (num == 0)
lucky("");
else
@@ -213,9 +232,9 @@ DECK *dp;
* This routine prints out the message on the card
*/
static void
printmes() {
char c;
printmes()
{
char c;
printline();
fflush(stdout);

View File

@@ -93,7 +93,7 @@ Take a Walk on the Board Walk.
(Advance To Board Walk)
%%
MF24
Advance to Illinos Ave.
Advance to Illinois Ave.
%%
MF0
Advance to Go

View File

@@ -1,4 +1,4 @@
/* $NetBSD: deck.h,v 1.3 1995/03/23 08:34:36 cgd Exp $ */
/* $NetBSD: deck.h,v 1.5 1999/08/21 10:40:03 simonb Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -35,16 +35,18 @@
* @(#)deck.h 8.1 (Berkeley) 5/31/93
*/
# define bool char
#include <sys/types.h>
# define CC_D deck[0]
# define CH_D deck[1]
#define bool char
#define CC_D deck[0]
#define CH_D deck[1]
struct dk_st { /* deck description structure */
int num_cards; /* number of cards in deck */
int last_card; /* number of last card picked */
bool gojf_used; /* set if gojf card out of deck */
long *offsets; /* offests for start of cards */
u_int64_t *offsets; /* offsets for start of cards */
};
typedef struct dk_st DECK;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $ */
/* $NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $");
__RCSID("$NetBSD: execute.c,v 1.8 2001/08/29 18:23:44 jsm Exp $");
#endif
#endif /* not lint */
@@ -49,8 +49,9 @@ __RCSID("$NetBSD: execute.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $");
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
# define SEGSIZE 8192
#define SEGSIZE 8192
typedef struct stat STAT;
typedef struct tm TIME;
@@ -66,9 +67,8 @@ static void show_move __P((void));
*/
void
execute(com_num)
int com_num;
int com_num;
{
new_play = FALSE; /* new_play is true if fixing */
(*func[com_num])();
notify();
@@ -78,15 +78,15 @@ int com_num;
else if (num_doub)
printf("%s rolled doubles. Goes again\n", cur_p->name);
}
/*
* This routine moves a piece around.
*/
void
do_move()
{
int r1, r2;
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));
@@ -111,15 +111,15 @@ do_move()
ret:
return;
}
/*
* This routine moves a normal move
*/
void
move(rl)
int rl;
int rl;
{
int old_loc;
int old_loc;
old_loc = cur_p->loc;
cur_p->loc = (cur_p->loc + rl) % N_SQRS;
@@ -129,14 +129,14 @@ int rl;
}
show_move();
}
/*
* This routine shows the results of a move
*/
static void
show_move()
{
SQUARE *sqp;
SQUARE *sqp;
sqp = &board[cur_p->loc];
printf("That puts you on %s\n", sqp->name);
@@ -172,18 +172,18 @@ show_move()
rent(sqp);
}
}
/*
* This routine saves the current game for use at a later date
*/
void
save()
{
char *sp;
int outf, num;
time_t t;
struct stat sb;
char *start, *end;
char *sp;
int outf, num;
time_t t;
struct stat sb;
char *start, *end;
printf("Which file do you wish to save it in? ");
sp = buf;
@@ -219,14 +219,14 @@ save()
close(outf);
printf("[%s]\n", buf);
}
/*
* This routine restores an old game from a file
*/
void
restore()
{
char *sp;
char *sp;
printf("Which file do you wish to restore from? ");
for (sp = buf; (*sp=getchar()) != '\n'; sp++)
@@ -234,20 +234,20 @@ restore()
*sp = '\0';
rest_f(buf);
}
/*
* This does the actual restoring. It returns TRUE if the
* backup was successful, else false.
*/
int
rest_f(file)
char *file;
const char *file;
{
char *sp;
int inf, num;
char buf[80];
char *start, *end;
STAT sbuf;
char *sp;
int inf, num;
char buf[80];
char *start, *end;
STAT sbuf;
if ((inf=open(file, O_RDONLY)) < 0) {
perror(file);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $ */
/* $NetBSD: getinp.c,v 1.10 2003/01/06 13:04:55 wiz Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getinp.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $");
__RCSID("$NetBSD: getinp.c,v 1.10 2003/01/06 13:04:55 wiz Exp $");
#endif
#endif /* not lint */
@@ -47,27 +47,26 @@ __RCSID("$NetBSD: getinp.c,v 1.6 1997/10/12 17:45:10 christos Exp $");
#include <ctype.h>
#include "monop.ext"
# define LINE 70
#define LINE 70
static char buf[257];
static int comp __P((char *));
static int comp __P((const char *));
int
getinp(prompt, list)
char *prompt, *list[];
const char *prompt, *const list[];
{
int i, n_match, match = 0;
char *sp;
int c;
int i, n_match, match = 0;
char *sp;
int c;
for (;;) {
inter:
printf(prompt);
printf("%s", prompt);
for (sp = buf; (c=getchar()) != '\n'; ) {
*sp = c;
if (c == -1) /* check for interupted system call */
if (c == -1) /* check for interrupted system call */
goto inter;
else if (sp != buf || *sp != ' ')
sp++;
@@ -85,7 +84,7 @@ inter:
printf("<RETURN>");
}
else
printf(list[i]);
printf("%s", list[i]);
if (list[i+1])
printf(", ");
else
@@ -106,16 +105,17 @@ inter:
if (n_match == 1)
return match;
else if (buf[0] != '\0')
printf("Illegal response: \"%s\". Use '?' to get list of valid answers\n", buf);
printf("Illegal response: \"%s\". "
"Use '?' to get list of valid answers\n", buf);
}
}
static int
comp(s1)
char *s1;
const char *s1;
{
char *sp, *tsp, c;
const char *sp, *tsp;
char c;
if (buf[0] != '\0')
for (sp = buf, tsp = s1; *sp; ) {

View File

@@ -1,4 +1,4 @@
/* $NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $ */
/* $NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,14 +38,14 @@
#if 0
static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: houses.c,v 1.4 1997/10/12 17:45:11 christos Exp $");
__RCSID("$NetBSD: houses.c,v 1.6 1999/09/08 21:17:51 jsm Exp $");
#endif
#endif /* not lint */
#include "monop.ext"
static char *names[N_MON+2],
cur_prop[80];
static const char *names[N_MON+2];
static char cur_prop[80];
static MON *monops[N_MON];
@@ -58,12 +58,11 @@ static void list_cur __P((MON *));
void
buy_houses()
{
int num_mon;
MON *mp;
OWN *op;
bool good,got_morg;
int i,p;
MON *mp;
OWN *op;
bool good,got_morg;
int i,p;
over:
num_mon = 0;
@@ -103,7 +102,9 @@ over:
else {
names[num_mon++] = "done";
names[num_mon--] = 0;
if ((p=getinp("Which property do you wish to buy houses for? ", names)) == num_mon)
if ((p = getinp(
"Which property do you wish to buy houses for? ",
names)) == num_mon)
return;
buy_h(monops[p]);
goto over;
@@ -112,15 +113,14 @@ over:
static void
buy_h(mnp)
MON *mnp;
MON *mnp;
{
int i;
MON *mp;
int price;
short input[3],temp[3];
int tot;
PROP *pp;
int i;
MON *mp;
int price;
short input[3],temp[3];
int tot;
PROP *pp;
mp = mnp;
price = mp->h_cost * 50;
@@ -172,12 +172,11 @@ err: printf("That makes the spread too wide. Try again\n");
void
sell_houses()
{
int num_mon;
MON *mp;
OWN *op;
bool good;
int p;
int num_mon;
MON *mp;
OWN *op;
bool good;
int p;
over:
num_mon = 0;
@@ -205,7 +204,9 @@ over:
else {
names[num_mon++] = "done";
names[num_mon--] = 0;
if ((p=getinp("Which property do you wish to sell houses from? ", names)) == num_mon)
if ((p = getinp(
"Which property do you wish to sell houses from? ",
names)) == num_mon)
return;
sell_h(monops[p]);
notify();
@@ -215,15 +216,14 @@ over:
static void
sell_h(mnp)
MON *mnp;
MON *mnp;
{
int i;
MON *mp;
int price;
short input[3],temp[3];
int tot;
PROP *pp;
int i;
MON *mp;
int price;
short input[3],temp[3];
int tot;
PROP *pp;
mp = mnp;
price = mp->h_cost * 25;
@@ -247,7 +247,9 @@ over:
input[i] = get_int(cur_prop);
temp[i] = pp->houses - input[i];
if (temp[i] < 0) {
printf("That's too many. The most you can sell is %d\n", pp->houses);
printf(
"That's too many. The most you can sell is %d\n",
pp->houses);
goto over;
}
}
@@ -272,11 +274,10 @@ err: printf("That makes the spread too wide. Try again\n");
static void
list_cur(mp)
MON *mp;
MON *mp;
{
int i;
SQUARE *sqp;
int i;
SQUARE *sqp;
for (i = 0; i < mp->num_in; i++) {
sqp = mp->sq[i];

View File

@@ -1,4 +1,4 @@
/* $NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $ */
/* $NetBSD: initdeck.c,v 1.14 2001/07/22 13:34:01 wiz Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,6 +33,7 @@
* SUCH DAMAGE.
*/
#ifdef __NetBSD__
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
@@ -43,48 +44,78 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)initdeck.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: initdeck.c,v 1.5 1997/10/12 17:45:12 christos Exp $");
__RCSID("$NetBSD: initdeck.c,v 1.14 2001/07/22 13:34:01 wiz Exp $");
#endif
#endif /* not lint */
#endif /* __NetBSD__ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "deck.h"
#ifndef u_int32_t
#define u_int32_t unsigned int
#endif
static u_int32_t
h2nl(u_int32_t h)
{
unsigned char c[4];
u_int32_t rv;
c[0] = (h >> 24) & 0xff;
c[1] = (h >> 16) & 0xff;
c[2] = (h >> 8) & 0xff;
c[3] = (h >> 0) & 0xff;
memcpy(&rv, c, sizeof rv);
return (rv);
}
/*
* This program initializes the card files for monopoly.
* It reads in a data file with Com. Chest cards, followed by
* the Chance card. The two are seperated by a line of "%-".
* All other cards are seperated by lines of "%%". In the front
* the Chance card. The two are separated by a line of "%-".
* All other cards are separated by lines of "%%". In the front
* of the file is the data for the decks in the same order.
* This includes the seek pointer for the start of each card.
* All cards start with their execution code, followed by the
* string to print, terminated with a null byte.
*/
# define TRUE 1
# define FALSE 0
#define TRUE 1
#define FALSE 0
# define bool char
# define reg register
#define bool char
char *infile = "cards.inp", /* input file */
*outfile = "cards.pck"; /* "packed" file */
const char *infile = "cards.inp", /* input file */
*outfile = "cards.pck"; /* "packed" file */
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(int, char *[]);
static void getargs(int, char *[]);
static void fwrite_be_offt(off_t, FILE *);
static void count(void);
static void putem(void);
int
main(ac, av)
int ac;
char *av[]; {
int ac;
char *av[];
{
int i, nc;
/* sanity test */
if (sizeof(int) != 4) {
fprintf(stderr, "sizeof(int) != 4\n");
exit(1);
}
getargs(ac, av);
if ((inf = fopen(infile, "r")) == NULL) {
@@ -95,35 +126,64 @@ char *av[]; {
/*
* allocate space for pointers.
*/
CC_D.offsets = (long *)calloc(CC_D.num_cards + 1, sizeof (long));
CH_D.offsets = (long *)calloc(CH_D.num_cards + 1, sizeof (long));
fseek(inf, 0L, 0);
CC_D.offsets = calloc(CC_D.num_cards + 1, /* sizeof (off_t) */ 8);
CH_D.offsets = calloc(CH_D.num_cards + 1, /* sizeof (off_t) */ 8);
if (CC_D.offsets == NULL || CH_D.offsets == NULL) {
fprintf(stderr, "out of memory\n");
exit(1);
}
fseek(inf, 0L, SEEK_SET);
if ((outf = fopen(outfile, "w")) == NULL) {
perror(outfile);
exit(0);
exit(1);
}
fwrite(deck, sizeof (DECK), 2, outf);
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
/*
* these fields will be overwritten after the offsets are calculated,
* so byte-order doesn't matter yet.
*/
fwrite(&nc, sizeof(nc), 1, outf);
fwrite(&nc, sizeof(nc), 1, outf);
fwrite(CC_D.offsets, /* sizeof (off_t) */ 8, CC_D.num_cards, outf);
fwrite(CH_D.offsets, /* sizeof (off_t) */ 8, CH_D.num_cards, outf);
/*
* write out the cards themselves (calculating the offsets).
*/
putem();
fclose(inf);
fseek(outf, 0, 0L);
fwrite(deck, sizeof (DECK), 2, outf);
fwrite(CC_D.offsets, sizeof (long), CC_D.num_cards, outf);
fwrite(CH_D.offsets, sizeof (long), CH_D.num_cards, outf);
fseek(outf, 0, SEEK_SET);
/* number of community chest cards first... */
nc = h2nl(CC_D.num_cards);
fwrite(&nc, sizeof(nc), 1, outf);
/* ... then number of chance cards. */
nc = h2nl(CH_D.num_cards);
fwrite(&nc, sizeof(nc), 1, outf);
/* dump offsets in big-endian byte order */
for (i = 0; i < CC_D.num_cards; i++)
fwrite_be_offt(CC_D.offsets[i], outf);
for (i = 0; i < CH_D.num_cards; i++)
fwrite_be_offt(CH_D.offsets[i], outf);
fflush(outf);
if (ferror(outf)) {
perror(outfile);
exit(1);
}
fclose(outf);
printf("There were %d com. chest and %d chance cards\n", CC_D.num_cards, CH_D.num_cards);
printf("There were %d com. chest and %d chance cards\n",
CC_D.num_cards, CH_D.num_cards);
exit(0);
}
static void
getargs(ac, av)
int ac;
char *av[];
int ac;
char *av[];
{
if (ac > 1)
infile = av[1];
if (ac > 2)
@@ -136,10 +196,9 @@ char *av[];
static void
count()
{
reg bool newline;
reg DECK *in_deck;
reg int c;
bool newline;
DECK *in_deck;
int c;
newline = TRUE;
in_deck = &CC_D;
@@ -154,17 +213,17 @@ count()
newline = (c == '\n');
in_deck->num_cards++;
}
/*
* put strings in the file
*/
static void
putem()
{
reg bool newline;
reg DECK *in_deck;
reg int c;
reg int num;
bool newline;
DECK *in_deck;
int c;
int num;
in_deck = &CC_D;
CC_D.num_cards = 1;
@@ -174,7 +233,7 @@ putem()
putc(getc(inf), outf);
for (num = 0; (c=getc(inf)) != '\n'; )
num = num * 10 + (c - '0');
putw(num, outf);
putw(h2nl(num), outf);
newline = FALSE;
while ((c=getc(inf)) != EOF)
if (newline && c == '%') {
@@ -191,7 +250,7 @@ putem()
putc(c = getc(inf), outf);
for (num = 0; (c=getc(inf)) != EOF && c != '\n'; )
num = num * 10 + (c - '0');
putw(num, outf);
putw(h2nl(num), outf);
}
else {
putc(c, outf);
@@ -199,3 +258,23 @@ putem()
}
putc('\0', outf);
}
/*
* fwrite_be_offt:
* Write out the off paramater as a 64 bit big endian number
*/
static void
fwrite_be_offt(off, f)
off_t off;
FILE *f;
{
int i;
unsigned char c[8];
for (i = 7; i >= 0; i--) {
c[i] = off & 0xff;
off >>= 8;
}
fwrite(c, sizeof(c), 1, f);
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $ */
/* $NetBSD: jail.c,v 1.5 1999/08/21 10:40:03 simonb Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)jail.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $");
__RCSID("$NetBSD: jail.c,v 1.5 1999/08/21 10:40:03 simonb Exp $");
#endif
#endif /* not lint */
@@ -51,7 +51,6 @@ __RCSID("$NetBSD: jail.c,v 1.4 1997/10/12 17:45:14 christos Exp $");
void
card()
{
if (cur_p->loc != JAIL) {
printf("But you're not IN Jail\n");
return;
@@ -64,28 +63,28 @@ card()
cur_p->loc = 10; /* just visiting */
cur_p->in_jail = 0;
}
/*
* This routine returns the players get-out-of-jail-free card
* to a deck.
*/
void
ret_card(plr)
PLAY *plr;
PLAY *plr;
{
plr->num_gojf--;
if (CC_D.gojf_used)
CC_D.gojf_used = FALSE;
else
CH_D.gojf_used = FALSE;
}
/*
* This routine deals with paying your way out of jail.
*/
void
pay()
{
if (cur_p->loc != JAIL) {
printf("But you're not IN Jail\n");
return;
@@ -95,18 +94,19 @@ pay()
cur_p->in_jail = 0;
printf("That cost you $50\n");
}
/*
* This routine deals with a move in jail
*/
int
move_jail(r1, r2)
int r1, r2;
int r1, r2;
{
if (r1 != r2) {
printf("Sorry, that doesn't get you out\n");
if (++(cur_p->in_jail) == 3) {
printf("It's your third turn and you didn't roll doubles. You have to pay $50\n");
printf("It's your third turn and you didn't roll "
"doubles. You have to pay $50\n");
cur_p->money -= 50;
moveit:
cur_p->loc = 10;
@@ -126,7 +126,6 @@ moveit:
void
printturn()
{
if (cur_p->loc != JAIL)
return;
printf("(This is your ");

View File

@@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $ */
/* $NetBSD: misc.c,v 1.10 2001/01/16 02:41:17 cgd Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,13 +38,13 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $");
__RCSID("$NetBSD: misc.c,v 1.10 2001/01/16 02:41:17 cgd Exp $");
#endif
#endif /* not lint */
# include "monop.ext"
# include <ctype.h>
# include <signal.h>
#include "monop.ext"
#include <ctype.h>
#include <signal.h>
/*
* This routine executes a truncated set of commands until a
@@ -52,10 +52,9 @@ __RCSID("$NetBSD: misc.c,v 1.6 1997/10/12 17:45:15 christos Exp $");
*/
int
getyn(prompt)
char *prompt;
const char *prompt;
{
int com;
int com;
for (;;)
if ((com=getinp(prompt, yn)) < 2)
@@ -63,13 +62,13 @@ char *prompt;
else
(*func[com-2])();
}
/*
* This routine tells the player if he's out of money.
*/
void
notify()
{
if (cur_p->money < 0)
printf("That leaves you $%d in debt\n", -cur_p->money);
else if (cur_p->money == 0)
@@ -79,30 +78,30 @@ notify()
told_em = TRUE;
}
}
/*
* This routine switches to the next player
*/
void
next_play()
{
player = ++player % num_play;
player = (player + 1) % num_play;
cur_p = &play[player];
num_doub = 0;
}
/*
* This routine gets an integer from the keyboard after the
* given prompt.
*/
int
get_int(prompt)
char *prompt;
const char *prompt;
{
int num;
char *sp;
int c;
char buf[257];
int num;
char *sp;
int c;
char buf[257];
for (;;) {
inter:
@@ -124,18 +123,18 @@ inter:
printf("I can't understand that\n");
}
}
/*
* This routine sets the monopoly flag from the list given.
*/
void
set_ownlist(pl)
int pl;
int pl;
{
int num; /* general counter */
MON *orig; /* remember starting monop ptr */
OWN *op; /* current owned prop */
OWN *orig_op; /* origianl prop before loop */
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;
#ifdef DEBUG
@@ -150,7 +149,8 @@ int pl;
#ifdef DEBUG
printf(" case UTIL:\n");
#endif
for (num = 0; op && op->sqr->type == UTIL; op = op->next)
for (num = 0; op && op->sqr->type == UTIL;
op = op->next)
num++;
play[pl].num_util = num;
#ifdef DEBUG
@@ -161,10 +161,13 @@ int pl;
#ifdef DEBUG
printf(" case RR:\n");
#endif
for (num = 0; op && op->sqr->type == RR; op = op->next) {
for (num = 0; op && op->sqr->type == RR;
op = op->next) {
#ifdef DEBUG
printf("iter: %d\n", num);
printf("op = %d, op->sqr = %d, op->sqr->type = %d\n", op, op->sqr, op->sqr->type);
printf("op = %d, op->sqr = %d, "
"op->sqr->type = %d\n", op, op->sqr,
op->sqr->type);
#endif
num++;
}
@@ -197,15 +200,19 @@ int pl;
printf("num = %d\n");
#endif
if (orig == 0) {
printf("panic: bad monopoly descriptor: orig = %p\n", orig);
printf("panic: bad monopoly descriptor: "
"orig = %p\n", orig);
printf("player # %d\n", pl+1);
printhold(pl);
printf("orig_op = %p\n", orig_op);
printf("orig_op->sqr->type = %d (PRPTY)\n", op->sqr->type);
printf("orig_op->sqr->type = %d (PRPTY)\n",
op->sqr->type);
printf("orig_op->next = %p\n", op->next);
printf("orig_op->sqr->desc = %p\n", op->sqr->desc);
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->sqr->type = %d (PRPTY)\n",
op->sqr->type);
printf("op->next = %p\n", op->next);
printf("op->sqr->desc = %p\n", op->sqr->desc);
printf("num = %d\n", num);
@@ -221,16 +228,16 @@ int pl;
}
}
}
/*
* This routine sets things up as if it is a new monopoly
*/
void
is_monop(mp, pl)
MON *mp;
int pl;
MON *mp;
int pl;
{
int i;
int i;
mp->owner = pl;
mp->num_own = mp->num_in;
@@ -238,49 +245,50 @@ int pl;
mp->sq[i]->desc->monop = TRUE;
mp->name = mp->mon_n;
}
/*
* This routine sets things up as if it is no longer a monopoly
*/
void
is_not_monop(mp)
MON *mp;
MON *mp;
{
int i;
int i;
mp->owner = -1;
for (i = 0; i < mp->num_in; i++)
mp->sq[i]->desc->monop = FALSE;
mp->name = mp->not_m;
}
/*
* This routine gives a list of the current player's routine
*/
void
list()
list()
{
printhold(player);
}
/*
* This routine gives a list of a given players holdings
*/
void
list_all()
list_all()
{
int pl;
int pl;
while ((pl=getinp("Whose holdings do you want to see? ", name_list)) < num_play)
while ((pl = getinp("Whose holdings do you want to see? ", name_list))
< num_play)
printhold(pl);
}
/*
* This routine gives the players a chance before it exits.
*/
void
quit()
{
putchar('\n');
if (getyn("Do you all really want to quit? ") == 0)
exit(0);

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: monop.6,v 1.8 1995/03/23 08:34:50 cgd Exp $
.\" $NetBSD: monop.6,v 1.13 2002/09/26 18:32:03 wiz Exp $
.\"
.\" Copyright (c) 1980 The Regents of the University of California.
.\" All rights reserved.
@@ -40,10 +40,10 @@
.Nm monop
.Nd Monopoly game
.Sh SYNOPSIS
.Nm @gamesdir@/monop
.Nm
.Op Ar file
.Sh DESCRIPTION
.Nm Monop
.Nm
is reminiscent of the Parker Brother's game Monopoly, and
monitors a game between 1 to 9 users.
It is assumed that the rules of Monopoly are known.
@@ -53,8 +53,7 @@ no auction is held and the property remains unowned.
.Nm
The game, in effect, lends the player money,
so it is possible to buy something which you cannot afford.
However, as soon as a person goes into debt,
he must
However, as soon as a person goes into debt, he must
.Dq fix the problem ,
.Em i.e. ,
make himself solvent, before play can continue.
@@ -65,7 +64,7 @@ which puts the property back on the board, unowned.
.Pp
Any time that the response to a question is a
.Em string ,
e.g., a name, place or person, you can type
e.g., a name, place or person, you can type
.Sq Ic ?
to get a list of valid answers.
It is not possible to input a negative number, nor is it ever necessary.
@@ -73,7 +72,8 @@ It is not possible to input a negative number, nor is it ever necessary.
.Em A Summary of Commands :
.Bl -tag -width item
.It Ic quit
quit game: This allows you to quit the game. It asks you if you're sure.
quit game: This allows you to quit the game.
It asks you if you're sure.
.It Ic print
print board: This prints out the current board.
The columns have the following meanings (column headings are the same for the
@@ -87,13 +87,13 @@ commands):
.It Name
The first ten characters of the name of the square
.It Own
The
The
.Em number
of the owner of the property.
.It Price
The cost of the property (if any)
.It Mg
This field has a
This field has a
.Sq *
in it if the property is mortgaged
.It \&#
@@ -101,11 +101,14 @@ If the property is a Utility or Railroad, this is the number
of such owned by the owner.
If the property is land, this is the number of houses on it.
.It Rent
Current rent on the property. If it is not owned, there is no rent.
Current rent on the property.
If it is not owned, there is no rent.
.El
.It Ic where
where players are: Tells you where all the players are.
A `*' indicates the current player.
A
.Sq *
indicates the current player.
.It Ic own holdings
List your own holdings,
.Em i.e. ,
@@ -113,7 +116,7 @@ money, get-out-of-jail-free cards, and property.
.It Ic holdings
holdings list: Look at anyone's holdings.
It will ask you whose holdings you wish to look at.
When you are finished, type
When you are finished, type
.Sq Ic done .
.It Ic mortgage
mortgage property:
@@ -134,7 +137,7 @@ it asks you to re-input things.
sell houses:
Sets up a list of monopolies from which you can sell houses.
It operates in an analogous manner to
.Ic buy.
.Ic buy .
.It Ic card
card for jail:
Use a get-out-of-jail-free card to get out of jail.
@@ -158,7 +161,7 @@ save game:
Save the current game in a file for later play.
You can continue play after saving,
either by adding the file in which you saved the game after the
.Nm monop
.Nm
command, or by using the
.Ic restore
command (see below).
@@ -169,13 +172,14 @@ restore game:
Read in a previously saved game from a file.
It leaves the file intact.
.It Ic roll
Roll the dice and move forward to your new location.
If you simply hit the <RETURN> key instead of a command,
it is the same as typing
Roll the dice and move forward to your new location.
If you simply hit the
.Aq RETURN
key instead of a command, it is the same as typing
.Ic roll .
.El
.Sh AUTHOR
Ken Arnold
.An Ken Arnold
.Sh FILES
.Bl -tag -width @monop_cardsfile@ -compact
.It Pa @monop_cardsfile@

View File

@@ -1,4 +1,4 @@
/* $NetBSD: monop.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $ */
/* $NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: monop.c,v 1.5 1998/09/11 13:54:08 hubertf Exp $");
__RCSID("$NetBSD: monop.c,v 1.12 2001/09/18 18:15:49 wiz Exp $");
#endif
#endif /* not lint */
@@ -64,9 +64,9 @@ static void do_quit __P((int));
*/
int
main(ac, av)
int ac;
char *av[]; {
int ac;
char *av[];
{
/* Revoke setgid privileges */
setregid(getgid(), getgid());
@@ -95,20 +95,20 @@ char *av[]; {
/*ARGSUSED*/
static void
do_quit(n)
int n __attribute__((unused));
int n __attribute__((__unused__));
{
quit();
}
/*
* This routine gets the names of the players
*/
static void
getplayers()
{
char *sp;
int i, j;
char buf[257];
char *sp;
int i, j;
char buf[257];
blew_it:
for (;;) {
@@ -119,6 +119,8 @@ blew_it:
break;
}
cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY));
if (play == NULL)
err(1, NULL);
for (i = 0; i < num_play; i++) {
over:
printf("Player %d's name: ", i + 1);
@@ -127,7 +129,10 @@ over:
if (sp == buf)
goto over;
*sp++ = '\0';
strcpy(name_list[i]=play[i].name=(char *)calloc(1,sp-buf),buf);
name_list[i] = play[i].name = (char *)calloc(1, sp - buf);
if (name_list[i] == NULL)
err(1, NULL);
strcpy(play[i].name, buf);
play[i].money = 1500;
}
name_list[i++] = "done";
@@ -136,25 +141,28 @@ over:
for (j = i + 1; j < num_play; j++)
if (strcasecmp(name_list[i], name_list[j]) == 0) {
if (i != num_play - 1)
printf("Hey!!! Some of those are IDENTICAL!! Let's try that again....\n");
printf("Hey!!! Some of those are "
"IDENTICAL!! Let's try that "
"again....\n");
else
printf("\"done\" is a reserved word. Please try again\n");
printf("\"done\" is a reserved word. "
"Please try again\n");
for (i = 0; i < num_play; i++)
free(play[i].name);
free(play);
goto blew_it;
}
}
/*
* This routine figures out who goes first
*/
static void
init_players()
{
int i, rl, cur_max;
bool over = 0;
int max_pl = 0;
int i, rl, cur_max;
bool over = 0;
int max_pl = 0;
again:
putchar('\n');
@@ -177,15 +185,15 @@ again:
cur_p = &play[max_pl];
printf("%s (%d) goes first\n", cur_p->name, max_pl + 1);
}
/*
* This routine initalizes the monopoly structures.
* This routine initializes the monopoly structures.
*/
static void
init_monops()
{
MON *mp;
int i;
MON *mp;
int i;
for (mp = mon; mp < &mon[N_MON]; mp++) {
mp->name = mp->not_m;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: monop.def,v 1.4 1997/10/12 17:45:18 christos Exp $ */
/* $NetBSD: monop.def,v 1.6 1999/09/08 21:17:52 jsm Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -35,16 +35,16 @@
* @(#)monop.def 5.5 (Berkeley) 5/31/93
*/
# include "deck.h"
# include "monop.h"
#include "deck.h"
#include "monop.h"
bool fixing, /* set if fixing up debt */
trading, /* set if in process of trading */
told_em, /* set if told user he's out of debt */
spec; /* set if moving by card to RR or UTIL */
char *name_list[MAX_PL+2], /* list of players' names */
*comlist[] = { /* list of normal commands */
const char *name_list[MAX_PL+2], /* list of players' names */
*const comlist[] = { /* list of normal commands */
"quit", /* 0 */ "print", /* 1 */
"where", /* 2 */ "own holdings", /* 3 */
"holdings", /* 4 */ "mortgage", /* 5 */
@@ -56,14 +56,14 @@ char *name_list[MAX_PL+2], /* list of players' names */
"", /* 16 */
0
},
*yn[] = { /* list of commands for yes/no answers */
*const yn[] = { /* list of commands for yes/no answers */
"yes", /* 0 */ "no", /* 1 */
"quit", /* 2 */ "print", /* 3 */
"where", /* 4 */ "own holdings", /* 5 */
"holdings", /* 6 */
0
},
*lucky_mes[] = { /* "got lucky" messages */
*const lucky_mes[] = { /* "got lucky" messages */
"You lucky stiff", "You got lucky",
"What a lucky person!", "You must have a 4-leaf clover",
"My, my! Aren't we lucky!", "Luck smiles upon you",
@@ -80,7 +80,7 @@ int player, /* current player number */
num_luck = sizeof lucky_mes / sizeof (char *);
/* list of command functions */
void (*func[]) __P((void)) = { /* array of function calls for commands */
void (*const func[]) __P((void)) = { /* array of function calls for commands */
quit, /* quit game |* 0 *| */
printboard, /* print board |* 1 *| */
where, /* where players are |* 2 *| */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: monop.ext,v 1.3 1997/10/12 17:45:19 christos Exp $ */
/* $NetBSD: monop.ext,v 1.4 1999/09/08 21:17:52 jsm Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -40,11 +40,11 @@
extern bool trading, spec, fixing, told_em;
extern char *yn[], *comlist[], *name_list[], *lucky_mes[];
extern const char *const yn[], *const comlist[], *name_list[], *const lucky_mes[];
extern int num_play, player, num_doub, num_luck;
extern void (*func[]) __P((void));
extern void (*const func[]) __P((void));
extern DECK deck[2];

View File

@@ -1,4 +1,4 @@
/* $NetBSD: monop.h,v 1.6 1997/10/12 17:45:20 christos Exp $ */
/* $NetBSD: monop.h,v 1.10 1999/09/30 18:01:32 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -35,48 +35,49 @@
* @(#)monop.h 8.1 (Berkeley) 5/31/93
*/
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
# define bool char
#define bool char
# define TRUE (1)
# define FALSE (0)
#define TRUE (1)
#define FALSE (0)
# define N_MON 8 /* number of monopolies */
# define N_PROP 22 /* number of normal property squares */
# define N_RR 4 /* number of railroads */
# define N_UTIL 2 /* number of utilities */
# define N_SQRS 40 /* number of squares on board */
# define MAX_PL 9 /* maximum number of players */
# define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */
#define N_MON 8 /* number of monopolies */
#define N_PROP 22 /* number of normal property squares */
#define N_RR 4 /* number of railroads */
#define N_UTIL 2 /* number of utilities */
#define N_SQRS 40 /* number of squares on board */
#define MAX_PL 9 /* maximum number of players */
#define MAX_PRP (N_PROP+N_RR+N_UTIL) /* max # ownable property */
/* square type numbers */
# define PRPTY 0 /* normal property */
# define RR 1 /* railroad */
# define UTIL 2 /* water works - electric co */
# define SAFE 3 /* safe spot */
# define CC 4 /* community chest */
# define CHANCE 5 /* chance (surprise!!!) */
# define INC_TAX 6 /* Income tax */
# define GOTO_J 7 /* Go To Jail! */
# define LUX_TAX 8 /* Luxury tax */
# define IN_JAIL 9 /* In jail */
#define PRPTY 0 /* normal property */
#define RR 1 /* railroad */
#define UTIL 2 /* water works - electric co */
#define SAFE 3 /* safe spot */
#define CC 4 /* community chest */
#define CHANCE 5 /* chance (surprise!!!) */
#define INC_TAX 6 /* Income tax */
#define GOTO_J 7 /* Go To Jail! */
#define LUX_TAX 8 /* Luxury tax */
#define IN_JAIL 9 /* In jail */
# define JAIL 40 /* JAIL square number */
#define JAIL 40 /* JAIL square number */
# define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1])
# define printline() printf("------------------------------\n")
# define sqnum(sqp) (sqp - board)
# define swap(A1,A2) if ((A1) != (A2)) { \
#define lucky(str) printf("%s%s\n",str,lucky_mes[roll(1,num_luck)-1])
#define printline() printf("------------------------------\n")
#define sqnum(sqp) (sqp - board)
#define swap(A1,A2) if ((A1) != (A2)) { \
(A1) ^= (A2); \
(A2) ^= (A1); \
(A1) ^= (A2); \
}
struct sqr_st { /* structure for square */
char *name; /* place name */
const char *name; /* place name */
short owner; /* owner number */
short type; /* place type */
struct prp_st *desc; /* description struct */
@@ -86,13 +87,13 @@ struct sqr_st { /* structure for square */
typedef struct sqr_st SQUARE;
struct mon_st { /* monopoly description structure */
char *name; /* monop. name (color) */
const char *name; /* monop. name (color) */
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 */
const char *not_m; /* name if not monopoly */
const char *mon_n; /* name if a monopoly */
unsigned char sqnums[3]; /* Square numbers (used to init)*/
SQUARE *sq[3]; /* list of squares in monop */
};
@@ -146,10 +147,10 @@ void do_move __P((void));
void move __P((int));
void save __P((void));
void restore __P((void));
int rest_f __P((char *));
int rest_f __P((const char *));
/* getinp.c */
int getinp __P((char *, char *[]));
int getinp __P((const char *, const char *const []));
/* houses.c */
void buy_houses __P((void));
@@ -163,10 +164,10 @@ int move_jail __P((int, int ));
void printturn __P((void));
/* misc.c */
int getyn __P((char *));
int getyn __P((const char *));
void notify __P((void));
void next_play __P((void));
int get_int __P((char *));
int get_int __P((const char *));
void set_ownlist __P((int));
void is_monop __P((MON *, int));
void is_not_monop __P((MON *));

View File

@@ -1,4 +1,4 @@
/* $NetBSD: morg.c,v 1.6 1998/08/30 09:19:39 veego Exp $ */
/* $NetBSD: morg.c,v 1.8 1999/09/08 21:17:52 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,18 +38,18 @@
#if 0
static char sccsid[] = "@(#)morg.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: morg.c,v 1.6 1998/08/30 09:19:39 veego Exp $");
__RCSID("$NetBSD: morg.c,v 1.8 1999/09/08 21:17:52 jsm Exp $");
#endif
#endif /* not lint */
# include "monop.ext"
#include "monop.ext"
/*
* These routines deal with mortgaging.
*/
static char *names[MAX_PRP+2],
*morg_coms[] = {
static const char *names[MAX_PRP+2],
*const morg_coms[] = {
"quit", /* 0 */
"print", /* 1 */
"where", /* 2 */
@@ -87,19 +87,21 @@ static void fix_ex __P((int));
void
mortgage()
{
int prop;
int prop;
for (;;) {
if (set_mlist() == 0) {
if (got_houses)
printf("You can't mortgage property with houses on it.\n");
printf("You can't mortgage property with "
"houses on it.\n");
else
printf("You don't have any un-mortgaged property.\n");
printf("You don't have any un-mortgaged "
"property.\n");
return;
}
if (num_good == 1) {
printf("Your only mortageable property is %s\n",names[0]);
printf("Your only mortageable property is %s\n",
names[0]);
if (getyn("Do you want to mortgage it? ") == 0)
m(square[0]);
return;
@@ -111,14 +113,14 @@ mortgage()
notify();
}
}
/*
* This routine sets up the list of mortgageable property
*/
static int
set_mlist()
{
OWN *op;
OWN *op;
num_good = 0;
for (op = cur_p->own_list; op; op = op->next)
@@ -134,21 +136,22 @@ set_mlist()
names[num_good--] = 0;
return num_good;
}
/*
* This routine actually mortgages the property.
*/
static void
m(prop)
int prop;
int prop;
{
int price;
int price;
price = board[prop].cost/2;
board[prop].desc->morg = TRUE;
printf("That got you $%d\n",price);
cur_p->money += price;
}
/*
* This routine is the command level repsponse to the unmortgage
* command. It gets the list of mortgaged property and asks which are
@@ -157,8 +160,7 @@ int prop;
void
unmortgage()
{
int prop;
int prop;
for (;;) {
if (set_umlist() == 0) {
@@ -171,20 +173,21 @@ unmortgage()
unm(square[0]);
return;
}
prop = getinp("Which property do you want to unmortgage? ",names);
prop = getinp("Which property do you want to unmortgage? ",
names);
if (prop == num_good)
return;
unm(square[prop]);
}
}
/*
* This routine sets up the list of mortgaged property
*/
static int
set_umlist()
{
OWN *op;
OWN *op;
num_good = 0;
for (op = cur_p->own_list; op; op = op->next)
@@ -196,15 +199,15 @@ set_umlist()
names[num_good--] = 0;
return num_good;
}
/*
* This routine actually unmortgages the property
*/
static void
unm(prop)
int prop;
int prop;
{
int price;
int price;
price = board[prop].cost/2;
board[prop].desc->morg = FALSE;
@@ -213,6 +216,7 @@ int prop;
cur_p->money -= price;
set_umlist();
}
/*
* This routine forces the indebted player to fix his
* financial woes.
@@ -220,20 +224,19 @@ int prop;
void
force_morg()
{
told_em = fixing = TRUE;
while (cur_p->money <= 0)
fix_ex(getinp("How are you going to fix it up? ",morg_coms));
fixing = FALSE;
}
/*
* This routine is a special execute for the force_morg routine
*/
static void
fix_ex(com_num)
int com_num;
int com_num;
{
told_em = FALSE;
(*func[com_num])();
notify();

View File

@@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $ */
/* $NetBSD: print.c,v 1.6 1999/09/08 21:17:52 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,15 +38,15 @@
#if 0
static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: print.c,v 1.4 1997/10/12 17:45:22 christos Exp $");
__RCSID("$NetBSD: print.c,v 1.6 1999/09/08 21:17:52 jsm Exp $");
#endif
#endif /* not lint */
# include "monop.ext"
#include "monop.ext"
static char *header = "Name Own Price Mg # Rent";
static const char *header = "Name Own Price Mg # Rent";
static void printmorg __P((SQUARE *));
static void printmorg __P((const SQUARE *));
/*
* This routine prints out the current board
@@ -54,8 +54,7 @@ static void printmorg __P((SQUARE *));
void
printboard()
{
int i;
int i;
printf("%s\t%s\n", header, header);
for (i = 0; i < N_SQRS/2; i++) {
@@ -64,14 +63,14 @@ printboard()
printsq(i+N_SQRS/2, TRUE);
}
}
/*
* This routine lists where each player is.
*/
void
where()
{
int i;
int i;
printf("%s Player\n", header);
for (i = 0; i < num_play; i++) {
@@ -82,18 +81,18 @@ where()
putchar('\n');
}
}
/*
* This routine prints out an individual square
*/
void
printsq(sqn, eoln)
int sqn;
bool eoln;
int sqn;
bool eoln;
{
int rnt;
PROP *pp;
SQUARE *sqp;
int rnt;
PROP *pp;
SQUARE *sqp;
sqp = &board[sqn];
printf("%-10.10s", sqp->name);
@@ -156,39 +155,40 @@ bool eoln;
printmorg(sqp);
rnt = 25;
rnt <<= play[sqp->owner].num_rr - 1;
printf("%d %4d", play[sqp->owner].num_rr, 25 << (play[sqp->owner].num_rr - 1));
printf("%d %4d", play[sqp->owner].num_rr,
25 << (play[sqp->owner].num_rr - 1));
break;
}
if (eoln)
putchar('\n');
}
/*
* This routine prints out the mortgage flag.
*/
static void
printmorg(sqp)
SQUARE *sqp;
const SQUARE *sqp;
{
if (sqp->desc->morg)
printf(" * ");
else
printf(" ");
}
/*
* This routine lists the holdings of the player given
*/
void
printhold(pl)
int pl;
int pl;
{
OWN *op;
PLAY *pp;
OWN *op;
PLAY *pp;
pp = &play[pl];
printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl], pl+1,
pp->money + prop_worth(pp));
printf("%s's (%d) holdings (Total worth: $%d):\n", name_list[pl],
pl + 1, pp->money + prop_worth(pp));
printf("\t$%d", pp->money);
if (pp->num_gojf) {
printf(", %d get-out-of-jail-free card", pp->num_gojf);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $ */
/* $NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)prop.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: prop.c,v 1.4 1997/10/12 17:45:23 christos Exp $");
__RCSID("$NetBSD: prop.c,v 1.7 2001/01/16 02:41:17 cgd Exp $");
#endif
#endif /* not lint */
@@ -53,29 +53,30 @@ static int value __P((SQUARE *));
*/
void
buy(player, sqrp)
int player;
SQUARE *sqrp;
int player;
SQUARE *sqrp;
{
trading = FALSE;
sqrp->owner = player;
add_list(player, &(play[player].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;
int plr;
OWN **head;
int op_sqr;
{
int val;
OWN *tp, *last_tp;
OWN *op;
int val;
OWN *tp, *last_tp;
OWN *op;
op = (OWN *)calloc(1, sizeof (OWN));
if (op == NULL)
errx(1, "out of memory");
op->sqr = &board[op_sqr];
val = value(op->sqr);
last_tp = NULL;
@@ -94,17 +95,17 @@ int op_sqr;
if (!trading)
set_ownlist(plr);
}
/*
* This routine deletes property from the list.
*/
void
del_list(plr, head, op_sqr)
int plr;
OWN **head;
short op_sqr;
int plr;
OWN **head;
short op_sqr;
{
OWN *op, *last_op;
OWN *op, *last_op;
switch (board[op_sqr].type) {
case PRPTY:
@@ -130,16 +131,16 @@ short op_sqr;
free(op);
}
}
/*
* This routine calculates the value for sorting of the
* given square.
*/
static int
value(sqp)
SQUARE *sqp;
SQUARE *sqp;
{
int sqr;
int sqr;
sqr = sqnum(sqp);
switch (sqp->type) {
@@ -158,6 +159,7 @@ SQUARE *sqp;
return 8 + (sqp->desc) - prop;
}
}
/*
* This routine accepts bids for the current peice
* of property.
@@ -165,11 +167,10 @@ SQUARE *sqp;
void
bid()
{
static bool in[MAX_PL];
int i, num_in, cur_max;
char buf[80];
int cur_bid;
static bool in[MAX_PL];
int i, num_in, cur_max;
char buf[80];
int cur_bid;
printf("\nSo it goes up for auction. Type your bid after your name\n");
for (i = 0; i < num_play; i++)
@@ -178,7 +179,7 @@ bid()
cur_max = 0;
num_in = num_play;
while (num_in > 1 || (cur_max == 0 && num_in > 0)) {
i = ++i % num_play;
i = (i + 1) % num_play;
if (in[i]) {
do {
(void)sprintf(buf, "%s: ", name_list[i]);
@@ -189,7 +190,8 @@ bid()
break;
}
else if (cur_bid <= cur_max) {
printf("You must bid higher than %d to stay in\n", cur_max);
printf("You must bid higher than %d "
"to stay in\n", cur_max);
printf("(bid of 0 drops you out)\n");
}
} while (cur_bid != 0 && cur_bid <= cur_max);
@@ -198,25 +200,26 @@ bid()
}
if (cur_max != 0) {
while (!in[i])
i = ++i % num_play;
i = (i + 1) % num_play;
printf("It goes to %s (%d) for $%d\n",play[i].name,i+1,cur_max);
buy(i, &board[cur_p->loc]);
play[i].money -= cur_max;
}
else
printf("Nobody seems to want it, so we'll leave it for later\n");
printf("Nobody seems to want it, so we'll leave it for "
"later\n");
}
/*
* This routine calculates the value of the property
* of given player.
*/
int
prop_worth(plp)
PLAY *plp;
PLAY *plp;
{
OWN *op;
int worth;
OWN *op;
int worth;
worth = 0;
for (op = plp->own_list; op; op = op->next) {

View File

@@ -1,4 +1,4 @@
/* $NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $ */
/* $NetBSD: rent.c,v 1.5 1999/08/21 10:40:04 simonb Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,23 +38,22 @@
#if 0
static char sccsid[] = "@(#)rent.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: rent.c,v 1.4 1997/10/12 17:45:24 christos Exp $");
__RCSID("$NetBSD: rent.c,v 1.5 1999/08/21 10:40:04 simonb Exp $");
#endif
#endif /* not lint */
#include "monop.ext"
#include "monop.ext"
/*
* This routine has the player pay rent
*/
void
rent(sqp)
SQUARE *sqp;
SQUARE *sqp;
{
int rnt = 0;
PROP *pp;
PLAY *plp;
int rnt = 0;
PROP *pp;
PLAY *plp;
plp = &play[sqp->owner];
printf("Owned by %s\n", plp->name);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $ */
/* $NetBSD: roll.c,v 1.8 2002/06/02 22:17:37 wiz Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $");
__RCSID("$NetBSD: roll.c,v 1.8 2002/06/02 22:17:37 wiz Exp $");
#endif
#endif /* not lint */
@@ -49,18 +49,15 @@ __RCSID("$NetBSD: roll.c,v 1.6 1997/10/12 17:45:25 christos Exp $");
* This routine rolls ndie nside-sided dice.
*/
# define reg register
# if defined(pdp11)
# define MAXRAND 32767L
#if defined(pdp11)
#define MAXRAND 32767L
int
roll(ndie, nsides)
int ndie, nsides;
int ndie, nsides;
{
long tot;
unsigned n, r;
long tot;
unsigned n, r;
tot = 0;
n = ndie;
@@ -69,14 +66,14 @@ int ndie, nsides;
return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
}
# else
#else
int
roll(ndie, nsides)
int ndie, nsides; {
int tot, r;
double num_sides;
int ndie, nsides;
{
int tot, r;
double num_sides;
num_sides = nsides;
tot = 0;
@@ -84,4 +81,4 @@ int ndie, nsides; {
tot += (r = rand()) * (num_sides / RAND_MAX) + 1;
return tot;
}
# endif
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $ */
/* $NetBSD: spec.c,v 1.6 1999/09/08 21:17:52 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,23 +38,23 @@
#if 0
static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: spec.c,v 1.4 1997/10/12 17:45:26 christos Exp $");
__RCSID("$NetBSD: spec.c,v 1.6 1999/09/08 21:17:52 jsm Exp $");
#endif
#endif /* not lint */
# include "monop.ext"
#include "monop.ext"
static char *perc[] = {
static const char *const perc[] = {
"10%", "ten percent", "%", "$200", "200", 0
};
void
inc_tax()
{ /* collect income tax */
int worth, com_num;
int worth, com_num;
com_num = getinp("Do you wish to lose 10%% of your total worth or $200? ", perc);
com_num = getinp("Do you wish to lose 10%% of your total worth or "
"$200? ", perc);
worth = cur_p->money + prop_worth(cur_p);
printf("You were worth $%d", worth);
worth /= 10;
@@ -80,14 +80,12 @@ inc_tax()
void
goto_jail()
{ /* move player to jail */
cur_p->loc = JAIL;
}
void
lux_tax()
{ /* landing on luxury tax */
printf("You lose $75\n");
cur_p->money -= 75;
}
@@ -95,13 +93,11 @@ lux_tax()
void
cc()
{ /* draw community chest card */
get_card(&CC_D);
}
void
chance()
{ /* draw chance card */
get_card(&CH_D);
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: trade.c,v 1.4 1997/10/12 17:45:27 christos Exp $ */
/* $NetBSD: trade.c,v 1.7 1999/09/30 18:01:32 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#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.7 1999/09/30 18:01:32 jsm Exp $");
#endif
#endif /* not lint */
@@ -53,7 +53,7 @@ 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];
@@ -68,8 +68,7 @@ static void move_em __P((TRADE *, TRADE *));
void
trade()
{
int tradee, i;
int tradee, i;
trading = TRUE;
for (i = 0; i < 2; i++) {
@@ -101,20 +100,20 @@ 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;
int struct_no, play_no;
{
int sn, pn;
PLAY *pp;
int numin, prop, num_prp;
OWN *op;
TRADE *tp;
int sn, pn;
PLAY *pp;
int numin, prop, num_prp;
OWN *op;
TRADE *tp;
for (numin = 0; numin < MAX_PRP; numin++)
used[numin] = FALSE;
@@ -155,16 +154,16 @@ once_more:
}
}
}
/*
* This routine sets up the list of tradable property.
*/
static int
set_list(the_list)
OWN *the_list;
OWN *the_list;
{
int i;
OWN *op;
int i;
OWN *op;
i = 0;
for (op = the_list; op; op = op->next)
@@ -174,17 +173,17 @@ OWN *the_list;
plist[i--] = 0;
return i;
}
/*
* This routine summates the trade.
*/
static void
summate()
{
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 +204,26 @@ summate()
printf("\t-- Nothing --\n");
}
}
/*
* This routine actually executes the trade.
*/
static void
do_trade()
{
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;
TRADE *from, *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 +239,16 @@ TRADE *from, *to;
}
set_ownlist(to->trader);
}
/*
* This routine lets a player resign
*/
void
resign()
{
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) {