diff options
author | 1998-09-22 04:08:21 +0000 | |
---|---|---|
committer | 1998-09-22 04:08:21 +0000 | |
commit | a0b17b52444273d9aaeaf93b94a9f9bfe8ea8736 (patch) | |
tree | ed9f2bef03876e618b4bccc80a4d9abbf22e2502 | |
parent | Remove additional kernels during cleanup, otherwise it can (diff) | |
download | wireguard-openbsd-a0b17b52444273d9aaeaf93b94a9f9bfe8ea8736.tar.xz wireguard-openbsd-a0b17b52444273d9aaeaf93b94a9f9bfe8ea8736.zip |
NetBSD changes and further fixes (reformatted man page, better handling of
user input).
-rw-r--r-- | games/mille/comp.c | 36 | ||||
-rw-r--r-- | games/mille/end.c | 33 | ||||
-rw-r--r-- | games/mille/extern.c | 3 | ||||
-rw-r--r-- | games/mille/init.c | 45 | ||||
-rw-r--r-- | games/mille/mille.6 | 307 | ||||
-rw-r--r-- | games/mille/mille.c | 24 | ||||
-rw-r--r-- | games/mille/mille.h | 52 | ||||
-rw-r--r-- | games/mille/misc.c | 76 | ||||
-rw-r--r-- | games/mille/move.c | 78 | ||||
-rw-r--r-- | games/mille/print.c | 35 | ||||
-rw-r--r-- | games/mille/roll.c | 11 | ||||
-rw-r--r-- | games/mille/save.c | 95 | ||||
-rw-r--r-- | games/mille/table.c | 70 | ||||
-rw-r--r-- | games/mille/types.c | 17 | ||||
-rw-r--r-- | games/mille/varpush.c | 63 |
15 files changed, 486 insertions, 459 deletions
diff --git a/games/mille/comp.c b/games/mille/comp.c index 58538e3b3c8..8763e0c92e3 100644 --- a/games/mille/comp.c +++ b/games/mille/comp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: comp.c,v 1.2 1998/09/22 04:08:21 pjanzen Exp $ */ /* $NetBSD: comp.c,v 1.4 1995/03/24 05:01:11 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)comp.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: comp.c,v 1.4 1995/03/24 05:01:11 cgd Exp $"; +static char rcsid[] = "$OpenBSD: comp.c,v 1.2 1998/09/22 04:08:21 pjanzen Exp $"; #endif #endif /* not lint */ @@ -49,17 +50,18 @@ static char rcsid[] = "$NetBSD: comp.c,v 1.4 1995/03/24 05:01:11 cgd Exp $"; # define V_VALUABLE 40 +void calcmove() { - register CARD card; - register int *value; - register PLAY *pp, *op; - register bool foundend, cango, canstop, foundlow; - register unsgn int i, count200, badcount, nummin, nummax, diff; - register int curmin, curmax; - register CARD safe, oppos; - int valbuf[HAND_SZ], count[NUM_CARDS]; - bool playit[HAND_SZ]; + CARD card; + int *value; + PLAY *pp, *op; + bool foundend, cango, canstop, foundlow; + unsgn int i, count200, badcount, nummin, nummax, diff; + int curmin, curmax; + CARD safe, oppos; + int valbuf[HAND_SZ], count[NUM_CARDS]; + bool playit[HAND_SZ]; wmove(Score, ERR_Y, ERR_X); /* get rid of error messages */ wclrtoeol(Score); @@ -78,7 +80,7 @@ calcmove() switch (card) { case C_STOP: case C_CRASH: case C_FLAT: case C_EMPTY: - if (playit[i] = canplay(pp, op, card)) + if ((playit[i] = canplay(pp, op, card))) canstop = TRUE; goto norm; case C_LIMIT: @@ -404,17 +406,18 @@ play_it: /* * Return true if the given player could conceivably win with his next card. */ +int onecard(pp) -register PLAY *pp; + PLAY *pp; { - register CARD bat, spd, card; + CARD bat, spd, card; bat = pp->battle; spd = pp->speed; card = -1; if (pp->can_go || ((isrepair(bat) || bat == C_STOP || spd == C_LIMIT) && Numseen[S_RIGHT_WAY] != 0) || - bat >= 0 && Numseen[safety(bat)] != 0) + (bat >= 0 && Numseen[safety(bat)] != 0)) switch (End - pp->mileage) { case 200: if (pp->nummiles[C_200] == 2) @@ -436,9 +439,10 @@ register PLAY *pp; return FALSE; } +int canplay(pp, op, card) -register PLAY *pp, *op; -register CARD card; + PLAY *pp, *op; + CARD card; { switch (card) { case C_200: diff --git a/games/mille/end.c b/games/mille/end.c index 5b391b564a2..86d619ea617 100644 --- a/games/mille/end.c +++ b/games/mille/end.c @@ -1,3 +1,4 @@ +/* $OpenBSD: end.c,v 1.3 1998/09/22 04:08:22 pjanzen Exp $ */ /* $NetBSD: end.c,v 1.4 1995/03/24 05:01:30 cgd Exp $ */ /* @@ -37,11 +38,11 @@ #if 0 static char sccsid[] = "@(#)end.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: end.c,v 1.4 1995/03/24 05:01:30 cgd Exp $"; +static char rcsid[] = "$OpenBSD: end.c,v 1.3 1998/09/22 04:08:22 pjanzen Exp $"; #endif #endif /* not lint */ -# include "mille.h" +#include "mille.h" /* * @(#)end.c 1.1 (Berkeley) 4/1/82 @@ -51,10 +52,11 @@ static char rcsid[] = "$NetBSD: end.c,v 1.4 1995/03/24 05:01:30 cgd Exp $"; * print out the score as if it was final, and add the totals for * the end-of-games points to the user who deserves it (if any). */ +void finalscore(pp) -register PLAY *pp; { - - register int temp, tot, num; + PLAY *pp; +{ + int temp, tot, num; if (pp->was_finished == Finished) return; @@ -95,13 +97,14 @@ static int Last_tot[2]; /* last tot used for extrapolate */ * print out the score as if it was final, and add the totals for * the end-of-games points to the user who deserves it (if any). */ +void extrapolate(pp) -register PLAY *pp; { - - register int x, num, tot, count; + PLAY *pp; +{ + int x, num, tot, count; num = pp - Player; - tot += SC_TRIP + SC_DELAY + SC_EXT; + tot += SC_TRIP + SC_DELAY + SC_EXTENSION; x = num * 6 + 21 + 3; for (tot = 5; tot <= 9; tot++) mvaddch(tot, x, '0'); @@ -139,10 +142,11 @@ register PLAY *pp; { Last_tot[num] = tot; } -undoex() { - - register PLAY *pp; - register int i; +void +undoex() +{ + PLAY *pp; + int i; i = 0; for (pp = Player; pp < &Player[2]; pp++) { @@ -150,5 +154,4 @@ undoex() { pp->hand_tot -= Last_tot[i++]; } } -# endif - +#endif diff --git a/games/mille/extern.c b/games/mille/extern.c index 927b7f23461..2c99d07f2d9 100644 --- a/games/mille/extern.c +++ b/games/mille/extern.c @@ -1,3 +1,4 @@ +/* $OpenBSD: extern.c,v 1.2 1998/09/22 04:08:22 pjanzen Exp $ */ /* $NetBSD: extern.c,v 1.4 1995/03/24 05:01:36 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: extern.c,v 1.4 1995/03/24 05:01:36 cgd Exp $"; +static char rcsid[] = "$OpenBSD: extern.c,v 1.2 1998/09/22 04:08:22 pjanzen Exp $"; #endif #endif /* not lint */ diff --git a/games/mille/init.c b/games/mille/init.c index 4dce19f2cd6..3fa7190a859 100644 --- a/games/mille/init.c +++ b/games/mille/init.c @@ -1,3 +1,4 @@ +/* $OpenBSD: init.c,v 1.3 1998/09/22 04:08:22 pjanzen Exp $ */ /* $NetBSD: init.c,v 1.5 1995/03/24 05:01:40 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: init.c,v 1.5 1995/03/24 05:01:40 cgd Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.3 1998/09/22 04:08:22 pjanzen Exp $"; #endif #endif /* not lint */ @@ -47,13 +48,14 @@ static char rcsid[] = "$NetBSD: init.c,v 1.5 1995/03/24 05:01:40 cgd Exp $"; * @(#)init.c 1.1 (Berkeley) 4/1/82 */ -init() { +void +init() +{ + PLAY *pp; + int i, j; + CARD card; - register PLAY *pp; - register int i, j; - register CARD card; - - bzero(Numseen, sizeof Numseen); + memset(Numseen, 0, sizeof Numseen); Numgos = 0; for (i = 0; i < 2; i++) { @@ -90,15 +92,16 @@ init() { End = 700; } -shuffle() { - - register int i, r; - register CARD temp; +void +shuffle() +{ + int i, r; + CARD temp; for (i = 0; i < DECK_SZ; i++) { r = roll(1, DECK_SZ) - 1; if (r < 0 || r > DECK_SZ - 1) { - fprintf(stderr, "shuffle: card no. error: %d\n", r); + warnx("shuffle: card no. error: %d", r); die(1); } temp = Deck[r]; @@ -108,10 +111,11 @@ shuffle() { Topcard = &Deck[DECK_SZ]; } -newboard() { - - register int i; - register PLAY *pp; +void +newboard() +{ + int i; + PLAY *pp; static int first = TRUE; if (first) { @@ -166,10 +170,11 @@ newboard() { newscore(); } -newscore() { - - register int i, new; - register PLAY *pp; +void +newscore() +{ + int i, new; + PLAY *pp; static int was_full = -1; static int last_win = -1; diff --git a/games/mille/mille.6 b/games/mille/mille.6 index 02ce56c4517..bb6156521a3 100644 --- a/games/mille/mille.6 +++ b/games/mille/mille.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: mille.6,v 1.4 1995/03/24 05:01:45 cgd Exp $ +.\" $OpenBSD: mille.6,v 1.2 1998/09/22 04:08:23 pjanzen Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. @@ -31,47 +31,51 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)mille.6 8.2 (Berkeley) 12/30/93 +.\" @(#)mille.6 8.3 (Berkeley) 6/1/94 .\" -.TH MILLE 6 "December 30, 1993" -.UC 4 -.SH NAME -mille \- play Mille Bornes -.SH SYNOPSIS -.B /usr/games/mille -[ file ] -.SH DESCRIPTION -.I Mille +.Dd June 1, 1994 +.Dt MILLE 6 +.Os +.Sh NAME +.Nm mille +.Nd play Mille Bornes +.Sh SYNOPSIS +.Nm +.Op Ar file +.Sh DESCRIPTION +.Nm plays a two-handed game reminiscent of the Parker Brother's game of Mille Bornes with you. The rules are described below. If a file name is given on the command line, the game saved in that file is started. -.PP +.Pp When a game is started up, the bottom of the score window will contain a list of commands. They are: -.IP P +.Bl -tag -width indent +.It P Pick a card from the deck. This card is placed in the `P' slot in your hand. -.IP D +.It D Discard a card from your hand. To indicate which card, type the number of the card in the hand -(or \*(lqP\*(rq for the just-picked card) followed by a <RETURN> or <SPACE>. +(or +.Dq P +for the just-picked card) followed by a <RETURN> or <SPACE>. The <RETURN or <SPACE> is required to allow recovery from typos which can be very expensive, like discarding safeties. -.IP U +.It U Use a card. The card is again indicated by its number, followed by a <RETURN> or <SPACE>. -.IP O +.It O Toggle ordering the hand. By default off, if turned on it will sort the cards in your hand appropriately. This is not recommended for the impatient on slow terminals. -.IP Q +.It Q Quit the game. -This will ask for confirmation, just to be sure. -Hitting <DELETE> (or <RUBOUT>) is equivalent. -.IP S +This will ask for confirmation. +.It S Save the game in a file. If the game was started from a file, you will be given an opportunity to save it on the same file. @@ -79,10 +83,10 @@ If you don't wish to, or you did not start from a file, you will be asked for the file name. If you type a <RETURN> without a name, the save will be terminated and the game resumed. -.IP R +.It R Redraw the screen from scratch. The command ^L (control `L') will also work. -.IP W +.It W Toggle window type. This switches the score window between the startup window (with all the command names) and the end-of-game window. @@ -90,29 +94,26 @@ Using the end-of-game window saves time by eliminating the switch at the end of the game to show the final score. Recommended for hackers and other miscreants. -.PP +.El +.Pp If you make a mistake, an error message will be printed on the last line of the score window, and a bell will beep. -.PP +.Pp At the end of each hand or game, you will be asked if you wish to play another. If not, it will ask you if you want to save the game. If you do, and the save is unsuccessful, play will be resumed as if you had said you wanted to play another hand/game. This allows you to use the -.RB \*(lq S \*(rq +.Dq S command to reattempt the save. -.SH AUTHOR +.Sh AUTHOR Ken Arnold -.br +.Pp (The game itself is a product of Parker Brothers, Inc.) -.SH "SEE ALSO" -curses(3X), -.I "Screen Updating and Cursor Movement Optimization:" -.IR "A Library Package" , -Ken Arnold -.SH CARDS -.PP +.Sh SEE ALSO +.Xr curses 3X +.Sh CARDS Here is some useful information. The number in parentheses after the card name is the number of that card in the deck: @@ -133,198 +134,186 @@ Speed Limit (3) End of Limit (6) .sp .fi .DT -.SH RULES -.PP -.BR Object : +.Sh RULES +.Ss Object : The point of this game is to get a total of 5000 points in several hands. Each hand is a race to put down exactly 700 miles before your opponent does. Beyond the points gained by putting down milestones, there are several other ways of making points. -.PP -.BR Overview : +.Ss Overview : The game is played with a deck of 101 cards. -.I Distance +.Em Distance cards represent a number of miles traveled. They come in denominations of 25, 50, 75, 100, and 200. When one is played, it adds that many miles to the player's trip so far this hand. -.I Hazard +.Em Hazard cards are used to prevent your opponent from putting down Distance cards. They can only be played if your opponent has a -.I Go +.Em Go card on top of the Battle pile. The cards are -.IR "Out of Gas" , -.IR "Accident" , -.IR "Flat Tire" , -.IR "Speed Limit" , +.Em Out of Gas , +.Em Accident , +.Em Flat Tire , +.Em Speed Limit , and -.IR "Stop" . -.I Remedy +.Em Stop . +.Em Remedy cards fix problems caused by Hazard cards played on you by your opponent. The cards are -.IR "Gasoline" , -.IR "Repairs" , -.IR "Spare Tire" , -.IR "End of Limit" , +.Em Gasoline , +.Em Repairs , +.Em Spare Tire , +.Em End of Limit , and -.IR "Go" . -.I Safety +.Em Go . +.Em Safety cards prevent your opponent from putting specific Hazard cards on you in the first place. They are -.IR "Extra Tank" , -.IR "Driving Ace" , -.IR "Puncture Proof" , +.Em Extra Tank , +.Em Driving Ace , +.Em Puncture Proof , and -.IR "Right of Way" , -and there are only one of each in the deck. -.PP -.BR "Board Layout" : +.Em Right of Way , +and there is only one of each in the deck. +.Ss Board Layout : The board is split into several areas. From top to bottom, they are: -.B "SAFETY AREA" +.Bl -hang -offset indent -compact +.It Sy SAFETY AREA : (unlabeled): This is where the safeties will be placed as they are played. -.BR HAND : +.It Sy HAND : These are the cards in your hand. -.BR BATTLE : +.It Sy BATTLE : This is the Battle pile. All the Hazard and Remedy Cards are played here, except the -.I "Speed Limit" +.Em Speed Limit and -.I "End of Limit" +.Em End of Limit cards. Only the top card is displayed, as it is the only effective one. -.BR SPEED : +.It Sy SPEED The Speed pile. The -.I "Speed Limit" +.Em Speed Limit and -.I "End of Limit" +.Em End of Limit cards are played here to control the speed at which the player is allowed to put down miles. -.BR MILEAGE : +.It Sy MILEAGE : Miles are placed here. The total of the numbers shown here is the distance traveled so far. -.PP -.BR Play : +.El +.Ss Play : The first pick alternates between the two players. Each turn usually starts with a pick from the deck. The player then plays a card, or if this is not possible or desirable, discards one. Normally, a play or discard of a single card constitutes a turn. If the card played is a safety, however, the same player takes another turn immediately. -.PP -This repeats until one of the players reaches 700 points or the deck runs out. +.Pp +This repeats until one of the players reaches 700 miles or the deck runs out. If someone reaches 700, they have the option of going for an -.IR Extension , +.Sy Extension , which means that the play continues until someone reaches 1000 miles. -.PP -.BR "Hazard and Remedy Cards" : +.Ss Hazard and Remedy Cards : Hazard Cards are played on your opponent's Battle and Speed piles. Remedy Cards are used for undoing the effects of your opponent's nastiness. -.PP -.RB "\ \ \ \ " Go +.Bl -hang -offset indent -compact +.It Sy Go (Green Light) must be the top card on your Battle pile for you to play any mileage, unless you have played the -.I "Right of Way" +.Em Right of Way card (see below). -.br -.RB "\ \ \ \ " Stop +.It Sy Stop is played on your opponent's -.I Go +.Em Go card to prevent them from playing mileage until they play a -.I Go +.Em Go card. -.br -.RB "\ \ \ \ " "Speed Limit" +.It Sy Speed Limit is played on your opponent's Speed pile. Until they play an -.I "End of Limit" +.Em End of Limit they can only play 25 or 50 mile cards, presuming their -.I Go +.Em Go card allows them to do even that. -.br -.RB "\ \ \ \ " "End of Limit" +.It Sy End of Limit is played on your Speed pile to nullify a -.I "Speed Limit" +.Em Speed Limit played by your opponent. -.br -.RB "\ \ \ \ " "Out of Gas" +.It Sy Out of Gas is played on your opponent's -.I Go +.Em Go card. They must then play a -.I Gasoline +.Em Gasoline card, and then a -.I Go +.Em Go card before they can play any more mileage. -.br -.RB "\ \ \ \ " "Flat Tire" +.It Sy Flat Tire is played on your opponent's -.I Go +.Em Go card. They must then play a -.I "Spare Tire" +.Em Spare Tire card, and then a -.I Go +.Em Go card before they can play any more mileage. -.br -.RB "\ \ \ \ " "Accident" +.It Sy Accident is played on your opponent's -.I Go +.Em Go card. They must then play a -.I Repairs +.Em Repairs card, and then a -.I Go +.Em Go card before they can play any more mileage. -.br -.PP -.BR "Safety Cards" : +.El +.Ss Safety Cards : Safety cards prevent your opponent from playing the corresponding Hazard cards on you for the rest of the hand. It cancels an attack in progress, and -.IR "always entitles the player to an extra turn" . -.br -.RB "\ \ \ \ " "Right of Way" +.Em always entitles the player to an extra turn . +.Bl -hang -offset indent -compact +.It Sy Right of Way prevents your opponent from playing both -.I Stop +.Em Stop and -.I "Speed Limit" +.Em Speed Limit cards on you. It also acts as a permanent -.I Go +.Em Go card for the rest of the hand, so you can play mileage as long as there is not a Hazard card on top of your Battle pile. In this case only, your opponent can play Hazard cards directly on a Remedy card other than a Go card. -.br -.RB "\ \ \ \ " "Extra Tank" +.It Sy Extra Tank When played, your opponent cannot play an -.I "Out of Gas" +.Em Out of Gas on your Battle Pile. -.br -.RB "\ \ \ \ " "Puncture Proof" +.It Sy Puncture Proof When played, your opponent cannot play a -.I "Flat Tire" +.Em Flat Tire on your Battle Pile. -.br -.RB "\ \ \ \ " "Driving Ace" +.It Sy Driving Ace When played, your opponent cannot play an -.I Accident +.Em Accident on your Battle Pile. -.PP -.BR "Distance Cards" : +.El +.Ss Distance Cards : Distance cards are played when you have a -.I Go +.Em Go card on your Battle pile, -or a Right of Way in your Safety area and are not stopped by a Hazard Card. +or a +.Em Right of Way +in your Safety area and are not stopped by a Hazard Card. They can be played in any combination that totals exactly 700 miles, except that .IR "you cannot play more than two 200 mile cards in one hand" . A hand ends whenever one player gets exactly 700 miles or the deck runs out. -In that case, play continues until neither someone reaches 700, -or neither player can use any cards in their hand. +In that case, play continues until either someone reaches 700, +or neither player can use any cards in his hand. If the trip is completed after the deck runs out, this is called -.IR "Delayed Action" . -.PP -.BR "Coup Fourr\o'\(aae'" : +.Em Delayed Action . +.Ss Coup Fourre : This is a French fencing term for a counter-thrust move as part of a parry to an opponent's attack. In current French colloquial language it means a sneaky, underhanded blow. @@ -332,50 +321,42 @@ In Mille Bornes, it is used as follows: If an opponent plays a Hazard card, and you have the corresponding Safety in your hand, you play it immediately, even -.I before +.Em before you draw. This immediately removes the Hazard card from your Battle pile, and protects you from that card for the rest of the game. This -gives you more points (see \*(lqScoring\*(rq below). -.PP -.BR Scoring : +gives you more points (see Scoring below). +.Ss Scoring : Scores are totaled at the end of each hand, whether or not anyone completed the trip. The terms used in the Score window have the following meanings: -.br -.RB "\ \ \ \ " "Milestones Played" : +.Bl -hang -offset indent -compact +.It Sy Milestones Played : Each player scores as many miles as they played before the trip ended. -.br -.RB "\ \ \ \ " "Each Safety" : +.It Sy Each Safety : 100 points for each safety in the Safety area. -.br -.RB "\ \ \ \ " "All 4 Safeties" : +.It Sy All 4 Safeties : 300 points if all four safeties are played. -.br -.RB "\ \ \ \ " "Each Coup Fourr\o'\(aae'" : -300 points for each Coup Fourr\o'\(aae' accomplished. -.PP -The following bonus scores can apply only to the winning player. -.br -.RB "\ \ \ \ " "Trip Completed" : +.It Sy Each Coup Fourre : +300 points for each Coup Fourre accomplished. +.El +The following bonus scores can apply only to the winning player: +.Bl -hang -offset indent -compact +.It Sy Trip Completed : 400 points bonus for completing the trip to 700 or 1000. -.br -.RB "\ \ \ \ " "Safe Trip" : +.It Sy Safe Trip : 300 points bonus for completing the trip without using any 200 mile cards. -.br -.RB "\ \ \ \ " "Delayed Action" : +.It Sy Delayed Action : 300 points bonus for finishing after the deck was exhausted. -.br -.RB "\ \ \ \ " "Extension" : +.It Sy Extension : 200 points bonus for completing a 1000 mile trip. -.br -.RB "\ \ \ \ " "Shut-Out" : +.It Sy Shut-Out : 500 points bonus for completing the trip before your opponent played any mileage cards. -.PP +.El Running totals are also kept for the current score for each player for the hand -.RB ( "Hand Total" ), +.Sy ( Hand Total ) , the game -.RB ( "Overall Total" ), +.Sy ( Overall Total ) , and number of games won -.RB ( Games ). +.Sy ( Games ) . diff --git a/games/mille/mille.c b/games/mille/mille.c index a72197a5cd9..62a73f38c99 100644 --- a/games/mille/mille.c +++ b/games/mille/mille.c @@ -1,3 +1,4 @@ +/* $OpenBSD: mille.c,v 1.6 1998/09/22 04:08:23 pjanzen Exp $ */ /* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */ /* @@ -43,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $"; +static char rcsid[] = "$OpenBSD: mille.c,v 1.6 1998/09/22 04:08:23 pjanzen Exp $"; #endif #endif /* not lint */ @@ -57,13 +58,12 @@ static char rcsid[] = "$NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $"; * @(#)mille.c 1.3 (Berkeley) 5/10/83 */ -void rub(); - +int main(ac, av) -register int ac; -register char *av[]; { - - register bool restore; + int ac; + char *av[]; +{ + bool restore; /* revoke */ setegid(getgid()); @@ -152,8 +152,9 @@ register char *av[]; { * quit. */ void -rub() { - +rub(dummy) + int dummy; +{ (void)signal(SIGINT, SIG_IGN); if (getyn(REALLYPROMPT)) die(0); @@ -163,9 +164,10 @@ rub() { /* * Time to go beddy-by */ +void die(code) -int code; { - + int code; +{ (void)signal(SIGINT, SIG_IGN); if (outf) fflush(outf); diff --git a/games/mille/mille.h b/games/mille/mille.h index 6c9d9712b50..697634b3041 100644 --- a/games/mille/mille.h +++ b/games/mille/mille.h @@ -1,3 +1,4 @@ +/* $OpenBSD: mille.h,v 1.3 1998/09/22 04:08:23 pjanzen Exp $ */ /* $NetBSD: mille.h,v 1.5 1995/03/24 05:01:51 cgd Exp $ */ /* @@ -36,10 +37,17 @@ */ # include <sys/types.h> +# include <sys/uio.h> +# include <sys/stat.h> # include <ctype.h> +# include <err.h> +# include <errno.h> # include <curses.h> -# include <termios.h> +# include <fcntl.h> +# include <stdlib.h> # include <string.h> +# include <termios.h> +# include <unistd.h> /* * @(#)mille.h 1.1 (Berkeley) 4/1/82 @@ -158,7 +166,7 @@ # define erasechar() _tty.c_cc[VERASE] # define killchar() _tty.c_cc[VKILL] # endif -# endif SYSV +# endif /* SYSV */ typedef struct { bool coups[NUM_SAFE]; @@ -223,4 +231,42 @@ extern WINDOW *Board, *Miles, *Score; * functions */ -CARD getcard(); +void account __P((CARD)); +void calcmove __P((void)); +int canplay __P((PLAY *, PLAY *, CARD)); +int check_ext __P((bool)); +void check_go __P((void)); +void check_more __P((void)); +void die __P((int)); +void domove __P((void)); +bool error __P((char *, ...)); +void finalscore __P((PLAY *)); +CARD getcard __P((void)); +void getmove __P((void)); +int getyn __P((int)); +int haspicked __P((PLAY *)); +void init __P((void)); +int isrepair __P((CARD)); +int main __P((int, char **)); +void newboard __P((void)); +void newscore __P((void)); +int onecard __P((PLAY *)); +int playcard __P((PLAY *)); +void prboard __P((void)); +void prompt __P((int)); +void prscore __P((int)); +int readch __P((void)); +bool rest_f __P((char *)); +int roll __P((int, int)); +void rub __P((int)); +int safety __P((CARD)); +bool save __P((void)); +void show_card __P((int, int, CARD, CARD *)); +void show_score __P((int, int, int, int *)); +void shuffle __P((void)); +void sort __P((CARD *)); +bool varpush __P((int, ssize_t __P((int, const struct iovec *, int)))); +#ifdef EXTRAP +void extrapolate __P((PLAY *)); +void undoex __P((void)); +#endif diff --git a/games/mille/misc.c b/games/mille/misc.c index 35c94b23044..08f71780677 100644 --- a/games/mille/misc.c +++ b/games/mille/misc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: misc.c,v 1.3 1998/09/22 04:08:23 pjanzen Exp $ */ /* $NetBSD: misc.c,v 1.4 1995/03/24 05:01:54 cgd Exp $ */ /* @@ -37,13 +38,19 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: misc.c,v 1.4 1995/03/24 05:01:54 cgd Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1998/09/22 04:08:23 pjanzen Exp $"; #endif #endif /* not lint */ #include <sys/file.h> #include <termios.h> +#if __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif + #include "mille.h" # ifdef attron @@ -57,23 +64,35 @@ static char rcsid[] = "$NetBSD: misc.c,v 1.4 1995/03/24 05:01:54 cgd Exp $"; #define NUMSAFE 4 -/* VARARGS1 */ +bool +#if __STDC__ +error(char *str, ...) +#else error(str, arg) -char *str; + char *str; + va_dcl +#endif { - stdscr = Score; - mvprintw(ERR_Y, ERR_X, str, arg); + va_list ap; + +#if __STDC__ + va_start(ap, str); +#else + va_start(ap); +#endif + wmove(Score, ERR_Y, ERR_X); + vwprintw(Score, str, ap); clrtoeol(); putchar('\07'); refresh(); - stdscr = Board; + va_end(ap); return FALSE; } CARD getcard() { - register int c, c1; + int c, c1; for (;;) { while ((c = readch()) == '\n' || c == '\r' || c == ' ') @@ -102,7 +121,7 @@ getcard() } refresh(); if (c >= 0) { - while ((c1=readch()) != '\r' && c1 != '\n' && c1 != ' ') + while ((c1 = readch()) != '\r' && c1 != '\n' && c1 != ' ') if (c1 == killchar()) return -1; else if (c1 == erasechar()) { @@ -119,28 +138,26 @@ cont: ; } } +int check_ext(forcomp) -register bool forcomp; { - - - if (End == 700) + bool forcomp; +{ + if (End == 700) { if (Play == PLAYER) { if (getyn(EXTENSIONPROMPT)) { extend: if (!forcomp) End = 1000; return TRUE; - } - else { + } else { done: if (!forcomp) Finished = TRUE; return FALSE; } - } - else { - register PLAY *pp, *op; - register int i, safe, miles; + } else { + PLAY *pp, *op; + int i, safe, miles; pp = &Player[COMP]; op = &Player[PLAYER]; @@ -165,7 +182,7 @@ done: goto extend; goto done; } - else + } else goto done; } @@ -173,10 +190,11 @@ done: * Get a yes or no answer to the given question. Saves are * also allowed. Return TRUE if the answer was yes, FALSE if no. */ +int getyn(promptno) -register int promptno; { - - register char c; + int promptno; +{ + char c; Saved = FALSE; for (;;) { @@ -217,10 +235,11 @@ register int promptno; { * came from a saved file, make sure that they don't want to restore * it. Exit appropriately. */ -check_more() { - +void +check_more() +{ On_exit = TRUE; - if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000) + if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000) { if (getyn(ANOTHERGAMEPROMPT)) return; else { @@ -234,7 +253,7 @@ check_more() { Player[COMP].total = 0; Player[PLAYER].total = 0; } - else + } else if (getyn(ANOTHERHANDPROMPT)) return; if (!Saved && getyn(SAVEGAMEPROMPT)) @@ -243,12 +262,13 @@ check_more() { die(0); } +int readch() { - register int cnt; + int cnt; static char c; - for (cnt = 0; read(0, &c, 1) <= 0; cnt++) + for (cnt = 0; read(STDIN_FILENO, &c, 1) <= 0; cnt++) if (cnt > 100) exit(1); return c; diff --git a/games/mille/move.c b/games/mille/move.c index d05befb82b8..0f4aa63a146 100644 --- a/games/mille/move.c +++ b/games/mille/move.c @@ -1,3 +1,4 @@ +/* $OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $ */ /* $NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $ */ /* @@ -37,12 +38,15 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $"; +static char rcsid[] = "$OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $"; #endif #endif /* not lint */ -#include <termios.h> +#ifdef DEBUG +#include <sys/param.h> +#endif +#include <termios.h> #include "mille.h" # ifdef attron @@ -61,11 +65,12 @@ char *Movenames[] = { "M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER" }; +void domove() { - register PLAY *pp; - register int i, j; - register bool goodplay; + PLAY *pp; + int i, j; + bool goodplay; pp = &Player[Play]; if (Play == PLAYER) @@ -77,12 +82,12 @@ domove() switch (Movetype) { case M_DISCARD: if (haspicked(pp)) { - if (pp->hand[Card_no] == C_INIT) + if (pp->hand[Card_no] == C_INIT) { if (Card_no == 6) Finished = TRUE; else error("no card there"); - else { + } else { if (issafety(pp->hand[Card_no])) { error("discard a safety?"); goodplay = FALSE; @@ -164,11 +169,12 @@ acc: * Check and see if either side can go. If they cannot, * the game is over */ -check_go() { - - register CARD card; - register PLAY *pp, *op; - register int i; +void +check_go() +{ + CARD card; + PLAY *pp, *op; + int i; for (pp = Player; pp < &Player[2]; pp++) { op = (pp == &Player[COMP] ? &Player[PLAYER] : &Player[COMP]); @@ -194,11 +200,12 @@ check_go() { Finished = TRUE; } +int playcard(pp) -register PLAY *pp; + PLAY *pp; { - register int v; - register CARD card; + int v; + CARD card; /* * check and see if player has picked @@ -343,9 +350,13 @@ protected: return TRUE; } +void getmove() { - register char c, *sp; + char c; +#ifdef DEBUG + char *sp; +#endif #ifdef EXTRAP static bool last_ex = FALSE; /* set if last command was E */ @@ -391,7 +402,7 @@ getmove() Movetype = M_ORDER; goto ret; case 'Q': /* Quit */ - rub(); /* Same as a rubout */ + rub(0); /* Same as a rubout */ break; case 'W': /* Window toggle */ Window = nextwin(Window); @@ -431,12 +442,13 @@ getmove() case 'Z': /* Debug code */ if (!Debug && outf == NULL) { char buf[MAXPATHLEN]; - +over: prompt(FILEPROMPT); leaveok(Board, FALSE); refresh(); sp = buf; - while ((*sp = readch()) != '\n') { + while ((*sp = readch()) != '\n' && *sp != '\r' + && (sp - buf < sizeof(buf))) { if (*sp == killchar()) goto over; else if (*sp == erasechar()) { @@ -456,7 +468,7 @@ getmove() *sp = '\0'; leaveok(Board, TRUE); if ((outf = fopen(buf, "w")) == NULL) - perror(buf); + warn("%s", buf); setbuf(outf, (char *)NULL); } Debug = !Debug; @@ -470,13 +482,15 @@ getmove() ret: leaveok(Board, TRUE); } + /* * return whether or not the player has picked */ +int haspicked(pp) -register PLAY *pp; { - - register int card; + PLAY *pp; +{ + int card; if (Topcard <= Deck) return TRUE; @@ -492,10 +506,11 @@ register PLAY *pp; { return (pp->hand[card] != C_INIT); } +void account(card) -register CARD card; { - - register CARD oppos; + CARD card; +{ + CARD oppos; if (card == C_INIT) return; @@ -517,8 +532,9 @@ register CARD card; { } } +void prompt(promptno) -int promptno; + int promptno; { static char *names[] = { ">>:Move:", @@ -548,11 +564,12 @@ int promptno; clrtoeol(); } +void sort(hand) -register CARD *hand; + CARD *hand; { - register CARD *cp, *tp; - register CARD temp; + CARD *cp, *tp; + CARD temp; cp = hand; hand += HAND_SZ; @@ -564,4 +581,3 @@ register CARD *hand; *tp = temp; } } - diff --git a/games/mille/print.c b/games/mille/print.c index 1c4f9442f08..2fb09670da0 100644 --- a/games/mille/print.c +++ b/games/mille/print.c @@ -1,3 +1,4 @@ +/* $OpenBSD: print.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $ */ /* $NetBSD: print.c,v 1.4 1995/03/24 05:02:02 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: print.c,v 1.4 1995/03/24 05:02:02 cgd Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $"; #endif #endif /* not lint */ @@ -50,10 +51,11 @@ static char rcsid[] = "$NetBSD: print.c,v 1.4 1995/03/24 05:02:02 cgd Exp $"; # define COMP_STRT 20 # define CARD_STRT 2 -prboard() { - - register PLAY *pp; - register int i, j, k, temp; +void +prboard() +{ + PLAY *pp; + int i, j, k, temp; for (k = 0; k < 2; k++) { pp = &Player[k]; @@ -68,8 +70,8 @@ prboard() { show_card(14, temp, pp->battle, &pp->sh_battle); show_card(16, temp, pp->speed, &pp->sh_speed); for (i = C_25; i <= C_200; i++) { - register char *name; - register int end; + char *name; + int end; if (pp->nummiles[i] == pp->sh_nummiles[i]) continue; @@ -104,9 +106,10 @@ prboard() { * show_card: * Show the given card if it is different from the last one shown */ +void show_card(y, x, c, lc) -int y, x; -register CARD c, *lc; + int y, x; + CARD c, *lc; { if (c == *lc) return; @@ -117,11 +120,12 @@ register CARD c, *lc; static char Score_fmt[] = "%4d"; +void prscore(for_real) -register bool for_real; { - - register PLAY *pp; - register int x; + bool for_real; +{ + PLAY *pp; + int x; stdscr = Score; for (pp = Player; pp < &Player[2]; pp++) { @@ -163,9 +167,10 @@ register bool for_real; { * Show a score value if it is different from the last time we * showed it. */ +void show_score(y, x, s, ls) -int y, x; -register int s, *ls; + int y, x; + int s, *ls; { if (s == *ls) return; diff --git a/games/mille/roll.c b/games/mille/roll.c index 73fd29f99e9..956a5812cf6 100644 --- a/games/mille/roll.c +++ b/games/mille/roll.c @@ -1,3 +1,4 @@ +/* $OpenBSD: roll.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $ */ /* $NetBSD: roll.c,v 1.4 1995/03/24 05:02:07 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: roll.c,v 1.4 1995/03/24 05:02:07 cgd Exp $"; +static char rcsid[] = "$OpenBSD: roll.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $"; #endif #endif /* not lint */ @@ -50,11 +51,11 @@ static char rcsid[] = "$NetBSD: roll.c,v 1.4 1995/03/24 05:02:07 cgd Exp $"; * */ +int roll(ndie, nsides) -register int ndie, nsides; { - - register int tot; - extern unsigned int random(); + int ndie, nsides; +{ + int tot; tot = 0; while (ndie--) diff --git a/games/mille/save.c b/games/mille/save.c index c339fedd231..5ad1ff7708e 100644 --- a/games/mille/save.c +++ b/games/mille/save.c @@ -1,3 +1,4 @@ +/* $OpenBSD: save.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $ */ /* $NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $ */ /* @@ -37,14 +38,10 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $"; +static char rcsid[] = "$OpenBSD: save.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $"; #endif #endif /* not lint */ -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> -#include <termios.h> #include "mille.h" # ifdef attron @@ -58,34 +55,34 @@ static char rcsid[] = "$NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $"; typedef struct stat STAT; -char *ctime(); - -int read(), write(); - /* - * This routine saves the current game for use at a later date + * This routine saves the current game for use at a later date. + * Returns FALSE if it couldn't be done. */ - -save() { - - extern int errno; - register char *sp; - register int outf; - register time_t *tp; - char buf[80]; - time_t tme; - STAT junk; - +bool +save() +{ + char *sp; + int outf; + time_t *tp; + char buf[256]; + time_t tme; + STAT junk; + bool rv; + + sp = NULL; tp = &tme; - if (Fromfile && getyn(SAMEFILEPROMPT)) - strcpy(buf, Fromfile); - else { + if (Fromfile && getyn(SAMEFILEPROMPT)) { + strncpy(buf, Fromfile, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + } else { over: prompt(FILEPROMPT); leaveok(Board, FALSE); refresh(); sp = buf; - while ((*sp = readch()) != '\n') { + while ((*sp = readch()) != '\n' && *sp != '\r' && + (sp - buf < sizeof(buf))) { if (*sp == killchar()) goto over; else if (*sp == erasechar()) { @@ -127,16 +124,20 @@ over: mvwaddstr(Score, ERR_Y, ERR_X, buf); wrefresh(Score); time(tp); /* get current time */ - strcpy(buf, ctime(tp)); - for (sp = buf; *sp != '\n'; sp++) - continue; - *sp = '\0'; - varpush(outf, write); + rv = varpush(outf, writev); close(outf); - wprintw(Score, " [%s]", buf); + if (!rv) + unlink(buf); + else { + strcpy(buf, ctime(tp)); + for (sp = buf; *sp != '\n'; sp++) + continue; + *sp = '\0'; + wprintw(Score, " [%s]", buf); + } wclrtoeol(Score); wrefresh(Score); - return TRUE; + return rv; } /* @@ -144,23 +145,20 @@ over: * backup was made on exiting, in which case certain things must * be cleaned up before the game starts. */ +bool rest_f(file) -register char *file; { - - register char *sp; - register int inf; - char buf[80]; - STAT sbuf; - - if ((inf = open(file, 0)) < 0) { - perror(file); - exit(1); - } - if (fstat(inf, &sbuf) < 0) { /* get file stats */ - perror(file); - exit(1); - } - varpush(inf, read); + char *file; +{ + char *sp; + int inf; + char buf[80]; + STAT sbuf; + + if ((inf = open(file, O_RDONLY)) < 0) + err(1, "%s", file); + if (fstat(inf, &sbuf) < 0) /* get file stats */ + err(1, "%s", file); + varpush(inf, readv); close(inf); strcpy(buf, ctime(&sbuf.st_mtime)); for (sp = buf; *sp != '\n'; sp++) @@ -173,4 +171,3 @@ register char *file; { Fromfile = file; return !On_exit; } - diff --git a/games/mille/table.c b/games/mille/table.c deleted file mode 100644 index 9b7235c7af1..00000000000 --- a/games/mille/table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: table.c,v 1.4 1995/03/24 05:02:18 cgd Exp $ */ - -/* - * Copyright (c) 1982, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1982, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; -#else -static char rcsid[] = "$NetBSD: table.c,v 1.4 1995/03/24 05:02:18 cgd Exp $"; -#endif -#endif /* not lint */ - -# define DEBUG - -/* - * @(#)table.c 1.1 (Berkeley) 4/1/82 - */ - -# include "mille.h" - -main() { - - register int i, j, count; - - printf(" %16s -> %5s %5s %4s %s\n", "Card", "cards", "count", "need", "opposite"); - for (i = 0; i < NUM_CARDS - 1; i++) { - for (j = 0, count = 0; j < DECK_SZ; j++) - if (Deck[j] == i) - count++; - printf("%2d %16s -> %5d %5d %4d %s\n", i, C_name[i], Numcards[i], count, Numneed[i], C_name[opposite(i)]); - } -} - diff --git a/games/mille/types.c b/games/mille/types.c index 08124737d6f..fe296659ac5 100644 --- a/games/mille/types.c +++ b/games/mille/types.c @@ -1,3 +1,4 @@ +/* $OpenBSD: types.c,v 1.3 1998/09/22 04:08:25 pjanzen Exp $ */ /* $NetBSD: types.c,v 1.4 1995/03/24 05:02:22 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)types.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: types.c,v 1.4 1995/03/24 05:02:22 cgd Exp $"; +static char rcsid[] = "$OpenBSD: types.c,v 1.3 1998/09/22 04:08:25 pjanzen Exp $"; #endif #endif /* not lint */ @@ -47,15 +48,18 @@ static char rcsid[] = "$NetBSD: types.c,v 1.4 1995/03/24 05:02:22 cgd Exp $"; * @(#)types.c 1.1 (Berkeley) 4/1/82 */ +int isrepair(card) -register CARD card; { - - return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT; + CARD card; +{ + return card == C_GAS || card == C_SPARE || + card == C_REPAIRS || card == C_INIT; } +int safety(card) -register CARD card; { - + CARD card; +{ switch (card) { case C_EMPTY: case C_GAS: @@ -78,4 +82,3 @@ register CARD card; { } /* NOTREACHED */ } - diff --git a/games/mille/varpush.c b/games/mille/varpush.c index 5a39b7facd9..2dbcd759e8f 100644 --- a/games/mille/varpush.c +++ b/games/mille/varpush.c @@ -1,3 +1,4 @@ +/* $OpenBSD: varpush.c,v 1.3 1998/09/22 04:08:25 pjanzen Exp $ */ /* $NetBSD: varpush.c,v 1.4 1995/03/24 05:02:35 cgd Exp $ */ /* @@ -48,51 +49,63 @@ static char rcsid[] = "$NetBSD: varpush.c,v 1.4 1995/03/24 05:02:35 cgd Exp $"; * @(#)varpush.c 1.1 (Berkeley) 4/1/82 */ -int read(), write(); - /* * push variables around via the routine func() on the file * channel file. func() is either read or write. */ +bool varpush(file, func) -register int file; -register int (*func)(); { - + int file; + ssize_t (*func) __P((int, const struct iovec *, int)); +{ int temp; + const struct iovec vec[] = { + { (void *) &Debug, sizeof Debug }, + { (void *) &Finished, sizeof Finished }, + { (void *) &Order, sizeof Order }, + { (void *) &End, sizeof End }, + { (void *) &On_exit, sizeof On_exit }, + { (void *) &Handstart, sizeof Handstart }, + { (void *) &Numgos, sizeof Numgos }, + { (void *) Numseen, sizeof Numseen }, + { (void *) &Play, sizeof Play }, + { (void *) &Window, sizeof Window }, + { (void *) Deck, sizeof Deck }, + { (void *) &Discard, sizeof Discard }, + { (void *) Player, sizeof Player } + }; + + if (((func)(file, vec, sizeof(vec) / sizeof(vec[0]))) < 0) { + error(strerror(errno)); + return FALSE; + } - (*func)(file, (char *) &Debug, sizeof Debug); - (*func)(file, (char *) &Finished, sizeof Finished); - (*func)(file, (char *) &Order, sizeof Order); - (*func)(file, (char *) &End, sizeof End); - (*func)(file, (char *) &On_exit, sizeof On_exit); - (*func)(file, (char *) &Handstart, sizeof Handstart); - (*func)(file, (char *) &Numgos, sizeof Numgos); - (*func)(file, (char *) Numseen, sizeof Numseen); - (*func)(file, (char *) &Play, sizeof Play); - (*func)(file, (char *) &Window, sizeof Window); - (*func)(file, (char *) Deck, sizeof Deck); - (*func)(file, (char *) &Discard, sizeof Discard); - (*func)(file, (char *) Player, sizeof Player); - if (func == read) { - read(file, (char *) &temp, sizeof temp); + if (func == readv) { + if ((read(file, (void *) &temp, sizeof temp)) < 0) { + error(strerror(errno)); + return FALSE; + } Topcard = &Deck[temp]; #ifdef DEBUG if (Debug) { char buf[80]; over: printf("Debug file:"); - gets(buf); + fgets(buf, sizeof(buf), stdin); if ((outf = fopen(buf, "w")) == NULL) { - perror(buf); + warn("%s", buf); goto over; } if (strcmp(buf, _PATH_DEVNULL) != 0) setbuf(outf, (char *)NULL); } #endif - } - else { + } else { temp = Topcard - Deck; - write(file, (char *) &temp, sizeof temp); + if ((write(file, (void *) &temp, sizeof temp)) < 0) { + error(strerror(errno)); + return FALSE; + } } + return TRUE; } |