summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1998-09-21 07:36:18 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1998-09-21 07:36:18 +0000
commitb035152d559c05bd0c273db0c645e9a76ab61122 (patch)
treed379cb7e6e1226ead0bc17a5b80aa99b7b3b0094 /games
parent8745530dedffa86a4a34dffb91fd3cf2e7e244df (diff)
Cleanup, partially from NetBSD and jsm28@cam.ac.uk. No longer segfaults if
scorefile can't be opened. New -q quiet option. Partial man page reformat.
Diffstat (limited to 'games')
-rw-r--r--games/atc/Makefile4
-rw-r--r--games/atc/atc.6589
-rw-r--r--games/atc/def.h1
-rw-r--r--games/atc/extern.c7
-rw-r--r--games/atc/extern.h84
-rw-r--r--games/atc/games/ATC_scores5
-rw-r--r--games/atc/grammar.y18
-rw-r--r--games/atc/graphics.c53
-rw-r--r--games/atc/include.h40
-rw-r--r--games/atc/input.c131
-rw-r--r--games/atc/lex.l4
-rw-r--r--games/atc/list.c5
-rw-r--r--games/atc/log.c36
-rw-r--r--games/atc/main.c59
-rw-r--r--games/atc/pathnames.h1
-rw-r--r--games/atc/struct.h1
-rw-r--r--games/atc/tunable.c3
-rw-r--r--games/atc/tunable.h50
-rw-r--r--games/atc/update.c35
19 files changed, 581 insertions, 545 deletions
diff --git a/games/atc/Makefile b/games/atc/Makefile
index 9145556f0d0..ed3898f5b2f 100644
--- a/games/atc/Makefile
+++ b/games/atc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 1998/07/24 00:10:15 millert Exp $
+# $OpenBSD: Makefile,v 1.9 1998/09/21 07:36:04 pjanzen Exp $
PROG= atc
CFLAGS+=-DBSD -I${.CURDIR} -I.
@@ -7,7 +7,7 @@ SRCS= extern.c grammar.c graphics.c input.c lex.c list.c log.c \
MAN= atc.6
LDADD= -ll -lm -lcurses
DPADD= ${LIBL} ${LIBM} ${LIBCURSES}
-GAMES= ATC_scores Game_List Killer crossover default easy game_2 \
+GAMES= Game_List Killer crossover default easy game_2 \
Atlantis OHare Tic-Tac-Toe airports box crosshatch game_3 \
game_4 novice two-corners
CLEANFILES=grammar.c y.tab.h lex.c
diff --git a/games/atc/atc.6 b/games/atc/atc.6
index f2fcdfdfc44..1911a50c88f 100644
--- a/games/atc/atc.6
+++ b/games/atc/atc.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: atc.6,v 1.2 1998/07/26 06:37:33 pjanzen Exp $
+.\" $OpenBSD: atc.6,v 1.3 1998/09/21 07:36:04 pjanzen Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -36,492 +36,401 @@
.\"
.\" @(#)atc.6 8.1 (Berkeley) 5/31/93
.\"
-. \" XP - exdented paragraph
-.de XP
-.RT
-.if \\n(1T .sp \\n(PDu
-.ne 1.1
-.if !\\n(IP .nr IP +1
-.in +\\n(I\\n(IRu
-.ti -\\n(I\\n(IRu
-..
-.\" Copyright (c) 1986 Ed James. All rights reserved.
+.\" Copyright (c) 1986 Ed James. All rights reserved.
.\"
-.TH ATC 6 "May 31, 1993"
-.UC
-.SH NAME
-atc \- air traffic controller game
-.SH SYNOPSIS
-.B atc
--[u?lstp] [-[gf] game_name] [-r random seed]
-.SH DESCRIPTION
-.LP
-.I Atc
-lets you try your hand at the nerve wracking duties of the air traffic
+.Dd May 31, 1993
+.Dt ATC 6
+.Os
+.Sh NAME
+.Nm atc
+.Nd air traffic controller game
+.Sh SYNOPSIS
+.Nm
+.Op Fl u?lstpq
+.Op Fl gf Ar game_name
+.Op Fl r Ar random seed
+.Sh DESCRIPTION
+.Nm
+lets you try your hand at the nerve-wracking duties of an air traffic
controller without endangering the lives of millions of
travelers each year.
Your responsibilities require you to direct the flight of jets
and prop planes into and out of the flight arena and airports.
The speed (update time) and frequency of the planes depend on the
difficulty of the chosen arena.
-.SH OPTIONS
-.LP
-.TP 8
-.B \-u
+.Sh OPTIONS
+.Bl -tag -width "-g game"
+.It Fl u
Print the usage line and exit.
-.TP
-.B \-?
+.It Fl ?
Same as
-.B \-u.
-.TP
-.B \-l
+.Fl u .
+.It Fl l
Print a list of available games and exit.
The first game name printed is the default game.
-.TP
-.B \-s
+.It Fl s
Print the score list (formerly the Top Ten list).
-.TP
-.B \-t
+.It Fl t
Same as
-.B \-s.
-.TP
-.B \-p
-Print the path to the special directory where
-.I atc
+.Fl s .
+.It Fl p
+Print the path to the special directory where
+.Nm
expects to find its private files. This is used during the
installation of the program.
-.TP
-.B "\-g game"
+.It Fl q
+Play quietly (no bells).
+.It Fl g Ar game
Play the named game. If the game listed is not one of the
-ones printed from the
-.B \-l
+ones printed from the
+.Fl l
option, the default game is played.
-.TP
-.B "\-f game"
+.It Fl f Ar game
Same as
-.B \-g.
-.TP
-.B "\-r seed"
+.Fl g .
+.It Fl r Ar seed
Set the random seed. The purpose of this flag is questionable.
-.SH GOALS
-.LP
-Your goal in
-.I atc
-is to keep the game going as long as possible.
+.El
+.Sh GOALS
+Your goal in
+.Nm
+is to keep the game going as long as possible.
There is no winning state, except to beat the times of other players.
You will need to: launch planes at airports (by instructing them to
increase their altitude); land planes at airports (by instructing them to
go to altitude zero when exactly over the airport); and maneuver planes
-out of exit points.
-.LP
+out of exit points.
+.Pp
Several things will cause the end of the game.
-Each plane has a destination (see information area), and
+Each plane has a destination (see information area), and
sending a plane to the wrong destination is an error.
Planes can run out of fuel, or can collide. Collision is defined as
adjacency in any of the three dimensions. A plane leaving the arena
in any other way than through its destination exit is an error as well.
-.LP
+.Pp
Scores are sorted in order of the number of planes safe. The other
-statistics are provided merely for fun. There is no penalty for
+statistics are provided merely for fun. There is no penalty for
taking longer than another player (except in the case of ties).
-.LP
+.Pp
Suspending a game is not permitted. If you get a talk message, tough.
When was the last time an Air Traffic Controller got called away to
-the phone?
-.SH "THE DISPLAY"
-.LP
-Depending on the terminal you run
-.I atc
-on, the screen will be divided into 4 areas.
+the phone?
+.Sh THE DISPLAY
+Depending on the terminal you run
+.Nm
+on, the screen will be divided into 4 areas.
It should be stressed that the terminal driver portion of the
game was designed to be reconfigurable, so the display format can vary
-depending the version you are playing. The descriptions here are based
-on the ascii version
-of the game. The game rules and input format, however,
+depending the version you are playing. The descriptions here are based
+on the ASCII version of the game. The game rules and input format, however,
should remain consistent.
Control-L redraws the screen, should it become muddled.
-.SS RADAR
-.IP
+.Ss RADAR
The first screen area is the radar display, showing the relative locations
of the planes, airports, standard entry/exit points, radar
beacons, and "lines" which simply serve to aid you in guiding
-the planes.
-.IP
+the planes.
+.Pp
Planes are shown as a single letter with an altitude. If
the numerical altitude is a single digit, then it represents
thousands of feet.
Some distinction is made between the prop
planes and the jets. On ascii terminals, prop planes are
represented by a upper case letter, jets by a lower case letter.
-.IP
+.Pp
Airports are shown as a number and some indication of the direction
-planes must be going to land at the airport.
+planes must be going to land at the airport.
On ascii terminals, this is one of '^', '>', '<', and 'v', to indicate
north (0 degrees), east (90), west (270) and south (180), respectively.
The planes will also
take off in this direction.
-.IP
+.Pp
Beacons are represented as circles or asterisks and a number.
Their purpose is to offer a place of easy reference to the plane pilots.
See 'the delay command' under the input section of this manual.
-.IP
-Entry/exit points are displayed as numbers along the border of the
+.Pp
+Entry/exit points are displayed as numbers along the border of the
radar screen. Planes will enter the arena from these points without
-warning. These points have a direction associated with them, and
+warning. These points have a direction associated with them, and
planes will always enter the arena from this direction. On the
ascii version of
-.I atc,
+.Nm atc ,
this direction is not displayed. It will become apparent
what this direction is as the game progresses.
-.IP
+.Pp
Incoming planes will always enter at the same altitude: 7000 feet.
-For a plane to successfully depart through an entry/exit point,
+For a plane to successfully depart through an entry/exit point,
it must be flying at 9000 feet.
It is not necessary for the planes to be flying in any particular
direction when they leave the arena (yet).
-.SS "INFORMATION AREA"
-.IP
+.Ss INFORMATION AREA
The second area of the display is the information area, which lists
the time (number of updates since start), and the number of planes you
have directed safely out of the arena.
-Below this is a list of planes currently in the air, followed by a
+Below this is a list of planes currently in the air, followed by a
blank line, and then a list of planes on the ground (at airports).
-Each line lists the plane name and its current altitude,
+Each line lists the plane name and its current altitude,
an optional asterisk indicating low fuel, the plane's destination,
and the plane's current command. Changing altitude is not considered
-to be a command and is therefore not displayed. The following are
+to be a command and is therefore not displayed. The following are
some possible information lines:
-.IP
- B4*A0: Circle @ b1
-.br
- g7 E4: 225
-.IP
+.Pp
+.Dl B4*A0: Circle @ b1
+.Pp
+.Dl g7 E4: 225
+.Pp
The first example shows a prop plane named 'B' that is flying at 4000
-feet. It is low on fuel (note the '*'). It's destination is
+feet. It is low on fuel (note the '*'). Its destination is
Airport #0.
The next command it expects
to do is circle when it reaches Beacon #1.
-The second example shows a jet named 'g' at 7000 feet, destined for
+The second example shows a jet named 'g' at 7000 feet, destined for
Exit #4. It is just now executing a turn to 225 degrees (South-West).
-.SS "INPUT AREA"
-.IP
-The third area of the display is the input area. It is here that
+.Ss INPUT AREA
+The third area of the display is the input area. It is here that
your input is reflected. See the INPUT heading of this manual
for more details.
-.SS "AUTHOR AREA"
-.IP
+.Ss AUTHOR AREA
This area is used simply to give credit where credit is due. :-)
-.SH INPUT
-.LP
+.Sh INPUT
A command completion interface is built into
the game. At any time, typing '?' will list possible input characters.
Typing a backspace (your erase character) backs up, erasing the last part
-of the command. When a command is complete, a return enters it, and
+of the command. When a command is complete, a return enters it, and
any semantic checking is done at that time. If no errors are detected,
the command is sent to the appropriate plane. If an error is discovered
during the check, the offending statement will be underscored and a
(hopefully) descriptive message will be printed under it.
-.LP
+.Pp
The command syntax is broken into two parts:
-.I "Immediate Only"
-and
-.I Delayable
+.Em Immediate Only
+and
+.Em Delayable
commands.
-.I "Immediate Only"
+.Em Immediate Only
commands happen on the next
-update.
-.I Delayable
+update.
+.Em Delayable
commands also happen on the next update unless they
-are followed by an optional predicate called the
-.I Delay
+are followed by an optional predicate called the
+.Em Delay
command.
-.LP
-In the following tables, the syntax
-.B [0\-9]
-means any single digit, and
-.B <dir>
-refers to the keys around the 's' key, namely ``wedcxzaq''.
-In absolute references, 'q' refers to North-West or 315 degrees, and 'w'
-refers to North, or 0 degrees.
-In relative references, 'q' refers to -45 degrees or 45 degrees left, and 'w'
+.Pp
+In the following tables, the syntax
+.Em [0\-9]
+means any single digit, and
+.Em <dir>
+refers to the keys around the 's' key, namely
+.Dq wedcxzaq .
+In absolute references,
+.Dq q
+refers to North-West or 315 degrees, and
+.Dq w
+refers to North, or 0 degrees.
+In relative references,
+.Dq q
+refers to -45 degrees or 45 degrees left, and
+.Dq w
refers to 0 degrees, or no change in direction.
-.LP
+.Pp
All commands start with a plane letter. This indicates the recipient
of the command. Case is ignored.
-.SS "IMMEDIATE ONLY COMMANDS"
-.RS
-.B "\- a Altitude:"
-.RS
+.Ss IMMEDIATE ONLY COMMANDS
+.Bd -ragged -offset indent
+.Bl -tag -width indent -compact
+.It Sy a Altitude
Affect a plane's altitude (and take off).
-.RE
-.RS
-.B "\- [0\-9] Number:"
-.RS
+.Bl -tag -width indent -compact
+.It Sy [0\-9] Number
Go to the given altitude (thousands of feet).
-.RE
-.B "\- c/+ Climb:"
-.RS
+.It Sy c/+ [0\-9] Climb (thousands of feet)
Relative altitude change.
-.RE
-.RS
-.B "\- [0\-9] Number:"
-.RS
-Difference in thousands of feet.
-.RE
-.RE
-.B "\- d/\- Descend:"
-.RS
+.It Sy d/\- [0\-9] Descend (thousands of feet)
Relative altitude change.
-.RE
-.RS
-.B "\- [0\-9] Number:"
-.RS
-Difference in thousands of feet.
-.RE
-.RE
-.RE
-.B "\- m Mark:"
-.RS
+.El
+.It Sy m Mark
Display in highlighted mode. Command is displayed normally.
-.RE
-.B "\- i Ignore:"
-.RS
+.It Sy i Ignore
Do not display highlighted. Command is displayed as a
line of dashes if there is no command.
-.RE
-.B "\- u Unmark:"
-.RS
-Same as ignore, but if a delayed command is processed,
+.It Sy u Unmark
+Same as ignore, but if a delayed command is processed,
the plane will become marked. This is useful if you want
to forget about a plane during part, but not all, of its
journey.
-.RE
-.RE
-.SS "DELAYABLE COMMANDS"
-.RS
-.B "\- c Circle:"
-.RS
+.El
+.Ed
+.Ss DELAYABLE COMMANDS
+.Bd -ragged -offset indent
+.Bl -tag -width indent -compact
+.It Sy c Circle
Have the plane circle.
-.RE
-.B "\- t Turn:"
-.RS
+.It Sy t Turn
Change direction.
-.RE
-.RS
-.B "\- l Left:"
-.RS
+.Bl -tag -width indent -compact
+.It Sy l Left
Turn counterclockwise (45 degrees by default).
-.RE
-.RS
-.B "\- <dir> Direction:"
-.RS
+.Bl -tag -width indent -compact
+.It Sy <dir> Direction
Turn ccw the given number of degrees.
Zero degrees is no turn. A ccw turn
of -45 degrees is 45 cw.
-.RE
-.RE
-.B "\- r Right:"
-.RS
+.El
+.It Sy r Right
Turn clockwise (45 degrees by default).
-.RE
-.RS
-.B "\- <dir> Direction:"
-.RS
+.Bl -tag -width indent -compact
+.It Sy <dir> Direction
Same as turn left <dir>.
-.RE
-.RE
-.B "\- L Left 90:"
-.RS
+.El
+.It Sy L Left 90
Turn counterclockwise 90 degrees.
-.RE
-.B "\- R Right 90:"
-.RS
+.It Sy R Right 90
Turn clockwise 90 degrees.
-.RE
-.B "\- <dir> Direction:"
-.RS
+.It Sy <dir> Direction
Turn to the absolute compass heading given.
The shortest turn will be taken.
-.RE
-.B "\- t Towards:"
-.RS
+.It Sy t Towards
Turn towards a beacon, airport or exit. The turn is
just an estimate.
-.RE
-.RS
-.B "\- b/* Beacon:"
-.RS
+.Bl -tag -width indent -compact
+.It Sy b/* [0\-9] Beacon Number
Turn towards the beacon.
-.RE
-.RS
-.B "\- [0-9] Number:"
-.RS
-The beacon number.
-.RE
-.RE
-.B "\- e Exit:"
-.RS
+.It Sy e [0\-9] Exit Number
Turn towards the exit.
-.RE
-.RS
-.B "\- [0-9] Number:"
-.RS
-The exit number.
-.RE
-.RE
-.B "\- a Airport:"
-.RS
+.It Sy a [0\-9] Airport Number
Turn towards the airport.
-.RE
-.RS
-.B "\- [0-9] Number:"
-.RS
-The airport number.
-.RE
-.RE
-.RE
-.RE
-.RE
-.SS THE DELAY COMMAND
-.LP
-The
-.B Delay
+.El
+.El
+.El
+.Ed
+.Ss THE DELAY COMMAND
+The
+.Em Delay
(a/@)
-command may be appended to any
-.B Delayable
+command may be appended to any
+.Em Delayable
command. It allows the controller to instruct a plane to do an action
when the plane reaches a particular beacon (or other objects in future
versions).
-.sp
-.RS
-.B "\- a/@ At:"
-.RS
+.Pp
+.Bd -ragged -offset indent
+.Bl -tag -width indent -compact
+.It Sy a/@ At
Do the given delayable command when the plane reaches the given beacon.
-.RE
-.RS
-.B "\- b/* Beacon:"
-.RS
-This is redundant to allow for expansion.
-.RE
-.RS
-.B "\- [0-9] Number:"
-.RS
-The beacon number.
-.RE
-.RE
-.RE
-.RE
-.SS "MARKING, UNMARKING AND IGNORING"
-.LP
-Planes are
-.B marked
+.Bl -tag -width indent -compact
+.It Sy ( b/* ) [0\-9] ( Beacon ) Number
+The letter is redundant to allow for expansion.
+.El
+.El
+.Ed
+.Ss MARKING, UNMARKING AND IGNORING
+.Pp
+Planes are
+.Em marked
when they enter the arena. This means they are displayed in highlighted
-mode on the radar display. A plane may also be either
-.B unmarked
+mode on the radar display. A plane may also be either
+.Em unmarked
or
-.B ignored.
+.Em ignored.
An
-.B unmarked
+.Em unmarked
plane is drawn in unhighlighted mode, and a line of dashes is displayed in
the command field of the information area. The plane will remain this
way until a mark command has been issued. Any other command will be issued,
but the command line will return to a line of dashes when the command
-is completed.
-.LP
+is completed.
+.Pp
An
-.B ignored
+.Em ignored
plane is treated the same as an unmarked plane, except that it will
-automatically switch to
-.B marked
+automatically switch to
+.Em marked
status when a delayed command has been processed. This is useful if
you want to forget about a plane for a while, but its flight path has
not yet been completely set.
-.LP
-As with all of the commands, marking, unmarking and ignoring will take effect
+.Pp
+As with all of the commands, marking, unmarking and ignoring will take effect
at the beginning of the next update. Do not be surprised if the plane does
not immediately switch to unhighlighted mode.
-.SS EXAMPLES
-.RS
-.TP 16
-atlab1
+.Ss EXAMPLES
+.Bd -ragged -offset indent
+.Bl -tag -width "gtte4ab2"
+.It atlab1
a: turn left at beacon #1
-.TP 16
-cc
+.It cc
C: circle
-.TP 16
-gtte4ab2
+.It gtte4ab2
g: turn towards exit #4 at beacon #2
-.TP 16
-ma+2
+.It ma+2
m: altitude: climb 2000 feet
-.TP 16
-stq
+.It stq
S: turn to 315
-.TP 16
-xi
+.It xi
x: ignore
-.RE
-.SH "OTHER INFORMATION"
-.LP
+.El
+.Ed
+.Sh OTHER INFORMATION
Jets move every update; prop planes move every other update.
-.LP
+.Pp
All planes turn a most 90 degrees per movement.
-.LP
+.Pp
Planes enter at 7000 feet and leave at 9000 feet.
-.LP
+.Pp
Planes flying at an altitude of 0 crash if they are not over an airport.
-.LP
+.Pp
Planes waiting at airports can only be told to take off (climb in altitude).
-.SH "NEW GAMES"
-.LP
-The
-.B Game_List
+.Sh "NEW GAMES"
+The
+.Em Game_List
file lists the currently available play fields. New field description
file names must be placed in this file to be 'playable'. If a player
specifies a game not in this file, his score will not be logged.
-.LP
+.Pp
The game field description files are broken into two parts. The first
part is the definition section. Here, the four tunable game parameters
must be set. These variables are set with the syntax:
-.IP
-variable = number;
-.LP
-Variable may be one of:
-.B update,
+.Pp
+.Dl variable = number;
+.Pp
+Variable may be one of:
+.Em update,
indicating the number of seconds between forced updates;
-.B newplane,
+.Em newplane,
indicating (about) the number of updates between new plane entries;
-.B width,
+.Em width,
indicating the width of the play field; and
-.B height,
+.Em height,
indicating the height of the play field.
-.LP
+.Pp
The second part of the field description files describes the locations
of the exits, the beacons, the airports and the lines.
The syntax is as follows:
-.IP
-beacon: (x y) ... ;
-.br
-airport: (x y direction) ... ;
-.br
-exit: (x y direction) ... ;
-.br
-line: [ (x1 y1) (x2 y2) ] ... ;
-.LP
+.Pp
+.Bd -ragged -offset indent
+.Bl -tag -width "airport:" -compact
+.It beacon:
+(x y) ... ;
+.It airport:
+(x y direction) ... ;
+.It exit:
+(x y direction) ... ;
+.It line:
+[ (x1 y1) (x2 y2) ] ... ;
+.El
+.Ed
For beacons, a simple x, y coordinate pair is used (enclosed in parenthesis).
Airports and exits require a third value, a direction, which is one
-of
-.B wedcxzaq.
+of
+.Dq wedcxzaq .
For airports, this is the direction that planes must be going to take
off and land, and for exits, this is the direction that planes will going
-when they
-.B enter
+when they enter
the arena. This may not seem intuitive, but as there is no restriction on
direction of exit, this is appropriate.
Lines are slightly different, since they need two coordinate pairs to
-specify the line endpoints. These endpoints must be enclosed in
+specify the line endpoints. These endpoints must be enclosed in
square brackets.
-.LP
+.Pp
All statements are semi-colon (;) terminated. Multiple item statements
accumulate. Each definition must occur exactly once, before any
item statements. Comments begin with a hash (#) symbol
@@ -529,15 +438,11 @@ and terminate with a newline.
The coordinates are between zero and width-1 and height-1
inclusive. All of the exit coordinates must lie on the borders, and
all of the beacons and airports must lie inside of the borders.
-Line endpoints may be anywhere within the field, so long as
-the lines are horizontal, vertical or
-.B "exactly diagonal."
-.SS "FIELD FILE EXAMPLE"
-.RS
-.sp
-.nf
-.TA 1i 1i
-.ta 1i 1i
+Line endpoints may be anywhere within the field, so long as
+the lines are horizontal, vertical or
+.Dq exactly diagonal .
+.Ss FIELD FILE EXAMPLE
+.Bd -literal -offset indent
# This is the default game.
update = 5;
@@ -561,30 +466,20 @@ line: [ ( 1 1 ) ( 6 6 ) ]
[ ( 11 18 ) ( 10 19 ) ]
[ ( 13 17 ) ( 28 17 ) ]
[ ( 1 7 ) ( 11 7 ) ] ;
-.fi
-.RE
-.SH FILES
-.LP
-Files are kept in a special directory. See the OPTIONS for a way to
+.Ed
+.Sh FILES
+Files are kept in a special directory. See the OPTIONS for a way to
print this path out.
-.TP 16
-.B ATC_score
-Where the scores are kept.
-.TP 16
-.B Game_List
+.Pp
+.Bl -tag -width "/var/games/ATC_score" -compact
+.It Pa /var/games/ATC_score
+Score file
+.It Pa /usr/share/games/atc/Game_List
The list of playable games.
-.SH AUTHOR
-.LP
+.Sh AUTHOR
Ed James, UC Berkeley: edjames@ucbvax.berkeley.edu, ucbvax!edjames
-.LP
+.Pp
This game is based on someone's description of the overall flavor
of a game written for some unknown PC many years ago, maybe.
-.SH BUGS
-.LP
+.Sh BUGS
The screen sometimes refreshes after you have quit.
-.LP
-Yet Another Curses Bug was discovered during the development of this game.
-If your curses library clrtobot.o is version 5.1 or earlier,
-you will have erase problems with the backspace operator in the input
-window.
-
diff --git a/games/atc/def.h b/games/atc/def.h
index 1290a30ea8d..b3a52d201f7 100644
--- a/games/atc/def.h
+++ b/games/atc/def.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: def.h,v 1.2 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: def.h,v 1.3 1995/03/21 15:03:47 cgd Exp $ */
/*-
diff --git a/games/atc/extern.c b/games/atc/extern.c
index 1f3d89802eb..5f5adb4e5b9 100644
--- a/games/atc/extern.c
+++ b/games/atc/extern.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: extern.c,v 1.2 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $ */
/*-
@@ -49,7 +50,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/04/27 21:22:19 mycroft Exp $";
+static char rcsid[] = "$OpenBSD: extern.c,v 1.2 1998/09/21 07:36:05 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -57,9 +58,9 @@ static char rcsid[] = "$NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $
char GAMES[] = "Game_List";
-int clck, safe_planes, start_time, test_mode;
+int clck, safe_planes, start_time, test_mode, makenoise;
-char *file;
+const char *file;
FILE *filein, *fileout;
diff --git a/games/atc/extern.h b/games/atc/extern.h
index ec5c3a7a25d..3d055a6c672 100644
--- a/games/atc/extern.h
+++ b/games/atc/extern.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: extern.h,v 1.2 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: extern.h,v 1.4 1995/04/27 21:22:22 mycroft Exp $ */
/*-
@@ -47,9 +48,10 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
-extern char GAMES[], *file;
+extern char GAMES[];
+extern const char *file;
-extern int clck, safe_planes, start_time, test_mode;
+extern int clck, safe_planes, start_time, test_mode, makenoise;
extern FILE *filein, *fileout;
@@ -61,4 +63,80 @@ extern struct termios tty_start, tty_new;
extern DISPLACEMENT displacement[MAXDIR];
-extern PLANE *findplane(), *newplane();
+extern int NUM_SCORES;
+
+int addplane __P((void));
+void append __P((LIST *, PLANE *));
+void check_adir __P((int, int, int));
+void check_edge __P((int, int));
+void check_edir __P((int, int, int));
+void check_line __P((int, int, int, int));
+void check_linepoint __P((int, int));
+void check_point __P((int, int));
+int checkdefs __P((void));
+int compar __P((const void *, const void *));
+void delete __P((LIST *, PLANE *));
+int dir_deg __P((int));
+int dir_no __P((char));
+void done_screen __P((void));
+void draw_all __P((void));
+void draw_line __P((WINDOW *, int, int, int, int, const char *));
+void erase_all __P((void));
+int getAChar __P((void));
+int getcommand __P((void));
+int gettoken __P((void));
+void init_gr __P((void));
+void ioaddstr __P((int, const char *));
+void ioclrtobot __P((void));
+void ioclrtoeol __P((int));
+void ioerror __P((int, int, const char *));
+void iomove __P((int));
+int list_games __P((void));
+int log_score __P((int));
+void log_score_quit __P((int));
+void loser __P((const PLANE *, const char *));
+char name __P((const PLANE *));
+int next_plane __P((void));
+void noise __P((void));
+int number __P((char));
+int open_score_file __P((void));
+void planewin __P((void));
+int pop __P((void));
+void push __P((int, int));
+void quit __P((int));
+int read_file __P((const char *));
+void redraw __P((void));
+void rezero __P((void));
+void setup_screen __P((const C_SCREEN *));
+int too_close __P((const PLANE *p1, const PLANE *p2, int));
+void update __P((int));
+int yyerror __P((const char *));
+int yylex __P((void));
+int yyparse __P((void));
+const char *Left __P((char));
+const char *Right __P((char));
+const char *airport __P((char));
+const char *beacon __P((char));
+const char *benum __P((char));
+const char *circle __P((char));
+const char *climb __P((char));
+const char *command __P((PLANE *));
+const char *default_game __P((void));
+const char *delayb __P((char));
+const char *descend __P((char));
+const char *ex_it __P((char));
+PLANE *findplane __P((int));
+const char *ignore __P((char));
+const char *left __P((char));
+const char *mark __P((char));
+PLANE *newplane __P((void));
+const char *okay_game __P((const char *));
+const char *rel_dir __P((char));
+const char *right __P((char));
+const char *setalt __P((char));
+const char *setplane __P((char));
+const char *setrelalt __P((char));
+const char *timestr __P((int));
+const char *to_dir __P((char));
+const char *turn __P((char));
+const char *unmark __P((char));
diff --git a/games/atc/games/ATC_scores b/games/atc/games/ATC_scores
deleted file mode 100644
index bbffeb25933..00000000000
--- a/games/atc/games/ATC_scores
+++ /dev/null
@@ -1,5 +0,0 @@
-schumann puff game_2 171 1414 195
-schumann puff default 18 220 59
-schumann puff easy 13 182 146
-schumann puff crossover 11 74 448
-schumann puff Killer 0 38 27
diff --git a/games/atc/grammar.y b/games/atc/grammar.y
index a409b490eb8..97f337ced2f 100644
--- a/games/atc/grammar.y
+++ b/games/atc/grammar.y
@@ -1,3 +1,4 @@
+/* $OpenBSD: grammar.y,v 1.2 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: grammar.y,v 1.3 1995/03/21 15:03:59 cgd Exp $ */
/*-
@@ -67,7 +68,7 @@
#if 0
static char sccsid[] = "@(#)grammar.y 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: grammar.y,v 1.3 1995/03/21 15:03:59 cgd Exp $";
+static char rcsid[] = "$OpenBSD: grammar.y,v 1.2 1998/09/21 07:36:05 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -288,14 +289,18 @@ Lline:
;
%%
+void
check_edge(x, y)
+ int x, y;
{
if (!(x == 0) && !(x == sp->width - 1) &&
!(y == 0) && !(y == sp->height - 1))
yyerror("edge value not on edge.");
}
+void
check_point(x, y)
+ int x, y;
{
if (x < 1 || x >= sp->width - 1)
yyerror("X value out of range.");
@@ -303,7 +308,9 @@ check_point(x, y)
yyerror("Y value out of range.");
}
+void
check_linepoint(x, y)
+ int x, y;
{
if (x < 0 || x >= sp->width)
yyerror("X value out of range.");
@@ -311,7 +318,9 @@ check_linepoint(x, y)
yyerror("Y value out of range.");
}
+void
check_line(x1, y1, x2, y2)
+ int x1, y1, x2, y2;
{
int d1, d2;
@@ -325,7 +334,9 @@ check_line(x1, y1, x2, y2)
yyerror("Bad line endpoints.");
}
+int
yyerror(s)
+ const char *s;
{
fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s);
errors++;
@@ -333,7 +344,9 @@ yyerror(s)
return (errors);
}
+void
check_edir(x, y, dir)
+ int x, y, dir;
{
int bad = 0;
@@ -364,10 +377,13 @@ check_edir(x, y, dir)
yyerror("Bad direction for entrance at exit.");
}
+void
check_adir(x, y, dir)
+ int x, y, dir;
{
}
+int
checkdefs()
{
int err = 0;
diff --git a/games/atc/graphics.c b/games/atc/graphics.c
index 75df3925725..c15bde8e9c7 100644
--- a/games/atc/graphics.c
+++ b/games/atc/graphics.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: graphics.c,v 1.2 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $ */
/*-
@@ -49,14 +50,12 @@
#if 0
static char sccsid[] = "@(#)graphics.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $";
+static char rcsid[] = "$OpenBSD: graphics.c,v 1.2 1998/09/21 07:36:05 pjanzen Exp $";
#endif
#endif /* not lint */
+#include <err.h>
#include "include.h"
-#ifdef SYSV
-#include <errno.h>
-#endif
#define C_TOPBOTTOM '-'
#define C_LEFTRIGHT '|'
@@ -68,6 +67,7 @@ static char rcsid[] = "$NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $";
WINDOW *radar, *cleanradar, *credit, *input, *planes;
+int
getAChar()
{
#ifdef BSD
@@ -81,6 +81,7 @@ getAChar()
#endif
}
+void
erase_all()
{
PLANE *pp;
@@ -95,6 +96,7 @@ erase_all()
}
}
+void
draw_all()
{
PLANE *pp;
@@ -114,11 +116,16 @@ draw_all()
fflush(stdout);
}
+void
init_gr()
{
static char buffer[BUFSIZ];
initscr();
+ if (LINES < 24 || COLS < 80) {
+ endwin();
+ errx(1, "screen too small.");
+ }
setbuf(stdout, buffer);
input = newwin(INPUT_LINES, COLS - PLANE_COLS, LINES - INPUT_LINES, 0);
credit = newwin(INPUT_LINES, PLANE_COLS, LINES - INPUT_LINES,
@@ -126,11 +133,13 @@ init_gr()
planes = newwin(LINES - INPUT_LINES, PLANE_COLS, 0, COLS - PLANE_COLS);
}
+void
setup_screen(scp)
- C_SCREEN *scp;
+ const C_SCREEN *scp;
{
register int i, j;
- char str[3], *airstr;
+ char str[3];
+ const char *airstr;
str[2] = '\0';
@@ -217,9 +226,11 @@ setup_screen(scp)
fflush(stdout);
}
+void
draw_line(w, x, y, lx, ly, s)
WINDOW *w;
- char *s;
+ int x, y, lx, ly;
+ const char *s;
{
int dx, dy;
@@ -235,7 +246,9 @@ draw_line(w, x, y, lx, ly, s)
}
}
+void
ioclrtoeol(pos)
+ int pos;
{
wmove(input, 0, pos);
wclrtoeol(input);
@@ -243,15 +256,19 @@ ioclrtoeol(pos)
fflush(stdout);
}
+void
iomove(pos)
+ int pos;
{
wmove(input, 0, pos);
wrefresh(input);
fflush(stdout);
}
+void
ioaddstr(pos, str)
- char *str;
+ int pos;
+ const char *str;
{
wmove(input, 0, pos);
waddstr(input, str);
@@ -259,6 +276,7 @@ ioaddstr(pos, str)
fflush(stdout);
}
+void
ioclrtobot()
{
wclrtobot(input);
@@ -266,8 +284,10 @@ ioclrtobot()
fflush(stdout);
}
+void
ioerror(pos, len, str)
- char *str;
+ int pos, len;
+ const char *str;
{
int i;
@@ -280,7 +300,9 @@ ioerror(pos, len, str)
fflush(stdout);
}
-quit()
+void
+quit(dummy)
+ int dummy;
{
int c, y, x;
#ifdef BSD
@@ -317,13 +339,12 @@ quit()
wmove(input, y, x);
wrefresh(input);
fflush(stdout);
- return;
}
+void
planewin()
{
PLANE *pp;
- char *command();
int warning = 0;
#ifdef BSD
@@ -363,9 +384,10 @@ planewin()
fflush(stdout);
}
+void
loser(p, s)
- PLANE *p;
- char *s;
+ const PLANE *p;
+ const char *s;
{
int c;
#ifdef BSD
@@ -397,6 +419,7 @@ loser(p, s)
exit(0);
}
+void
redraw()
{
clear();
@@ -415,7 +438,7 @@ redraw()
fflush(stdout);
}
-
+void
done_screen()
{
clear();
diff --git a/games/atc/include.h b/games/atc/include.h
index 98e5e3004e1..9b32a15f7a2 100644
--- a/games/atc/include.h
+++ b/games/atc/include.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: include.h,v 1.4 1998/09/21 07:36:05 pjanzen Exp $ */
/* $NetBSD: include.h,v 1.5 1995/04/27 21:22:23 mycroft Exp $ */
/*-
@@ -47,36 +48,27 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
#include <sys/types.h>
-#include <pwd.h>
-#include <termios.h>
-
-#ifdef BSD
-#include <sys/time.h>
#include <sys/file.h>
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/utsname.h>
+#include <sys/wait.h>
-#include <signal.h>
-#include <math.h>
-
+#include <ctype.h>
#include <curses.h>
-
-#ifdef SYSV
-#define bcopy(a,b,c) memcpy((b), (a), (c))
-#define bzero(a,b) memset((a), '\0', (b))
-#define srandom srand
-#define random rand
-#endif
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <math.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
#include "def.h"
#include "struct.h"
#include "extern.h"
-#include "tunable.h"
diff --git a/games/atc/input.c b/games/atc/input.c
index db9cb05cb21..68c53d4e894 100644
--- a/games/atc/input.c
+++ b/games/atc/input.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: input.c,v 1.5 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $ */
/*-
@@ -49,7 +50,7 @@
#if 0
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $";
+static char rcsid[] = "$OpenBSD: input.c,v 1.5 1998/09/21 07:36:06 pjanzen Exp $";
#endif
#endif not lint
@@ -66,10 +67,10 @@ static char rcsid[] = "$NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $"
#define NUMTOKEN 257
typedef struct {
- int token;
- int to_state;
- char *str;
- char *(*func)();
+ int token;
+ int to_state;
+ const char *str;
+ const char *(*func) __P((char));
} RULE;
typedef struct {
@@ -95,11 +96,6 @@ typedef struct {
#define NUMSTATES NUMELS(st)
-char *setplane(), *circle(), *left(), *right(), *Left(), *Right(),
- *beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(),
- *benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(),
- *airport(), *turn(), *ignore();
-
RULE state0[] = { { ALPHATOKEN, 1, "%c:", setplane},
{ RETTOKEN, -1, "", NULL },
{ HELPTOKEN, 12, " [a-z]<ret>", NULL }},
@@ -180,6 +176,7 @@ int level;
int tval;
int dest_type, dest_no, dir;
+int
pop()
{
if (level == 0)
@@ -194,6 +191,7 @@ pop()
return (0);
}
+void
rezero()
{
iomove(0);
@@ -206,7 +204,9 @@ rezero()
strcpy(T_STR, "");
}
+void
push(ruleno, ch)
+ int ruleno, ch;
{
int newstate, newpos;
@@ -227,10 +227,11 @@ push(ruleno, ch)
strcpy(T_STR, "");
}
+int
getcommand()
{
int c, i, done;
- char *s, *(*func)();
+ const char *s, *(*func) __P((char));
PLANE *pp;
rezero();
@@ -285,12 +286,15 @@ getcommand()
return (0);
}
+void
noise()
{
- putchar('\07');
+ if (makenoise)
+ putchar('\07');
fflush(stdout);
}
+int
gettoken()
{
while ((tval = getAChar()) == REDRAWTOKEN)
@@ -306,29 +310,32 @@ gettoken()
return (tval);
}
-char *
+const char *
setplane(c)
+ char c;
{
PLANE *pp;
pp = findplane(number(c));
if (pp == NULL)
return ("Unknown Plane");
- bcopy(pp, &p, sizeof (p));
+ memcpy(&p, pp, sizeof (p));
p.delayd = 0;
return (NULL);
}
-char *
+const char *
turn(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes at airports may not change direction");
return (NULL);
}
-char *
+const char *
circle(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes cannot circle on the ground");
@@ -336,8 +343,9 @@ circle(c)
return (NULL);
}
-char *
+const char *
left(c)
+ char c;
{
dir = D_LEFT;
p.new_dir = p.dir - 1;
@@ -346,18 +354,20 @@ left(c)
return (NULL);
}
-char *
+const char *
right(c)
+ char c;
{
dir = D_RIGHT;
p.new_dir = p.dir + 1;
- if (p.new_dir > MAXDIR)
+ if (p.new_dir >= MAXDIR)
p.new_dir -= MAXDIR;
return (NULL);
}
-char *
+const char *
Left(c)
+ char c;
{
p.new_dir = p.dir - 2;
if (p.new_dir < 0)
@@ -365,17 +375,19 @@ Left(c)
return (NULL);
}
-char *
+const char *
Right(c)
+ char c;
{
p.new_dir = p.dir + 2;
- if (p.new_dir > MAXDIR)
+ if (p.new_dir >= MAXDIR)
p.new_dir -= MAXDIR;
return (NULL);
}
-char *
+const char *
delayb(c)
+ char c;
{
int xdiff, ydiff;
@@ -383,28 +395,32 @@ delayb(c)
if (c >= sp->num_beacons)
return ("Unknown beacon");
- xdiff = sp->beacon[c].x - p.xpos;
+ xdiff = sp->beacon[(int)c].x - p.xpos;
xdiff = SGN(xdiff);
- ydiff = sp->beacon[c].y - p.ypos;
+ ydiff = sp->beacon[(int)c].y - p.ypos;
ydiff = SGN(ydiff);
if (xdiff != displacement[p.dir].dx || ydiff != displacement[p.dir].dy)
return ("Beacon is not in flight path");
+ if (xdiff != 0 && ydiff !=0)
+ if (abs(sp->beacon[(int)c].x - p.xpos) !=
+ abs(sp->beacon[(int)c].y - p.ypos))
+ return ("Beacon is not in flight path");
p.delayd = 1;
p.delayd_no = c;
if (dest_type != T_NODEST) {
switch (dest_type) {
case T_BEACON:
- xdiff = sp->beacon[dest_no].x - sp->beacon[c].x;
- ydiff = sp->beacon[dest_no].y - sp->beacon[c].y;
+ xdiff = sp->beacon[dest_no].x - sp->beacon[(int)c].x;
+ ydiff = sp->beacon[dest_no].y - sp->beacon[(int)c].y;
break;
case T_EXIT:
- xdiff = sp->exit[dest_no].x - sp->beacon[c].x;
- ydiff = sp->exit[dest_no].y - sp->beacon[c].y;
+ xdiff = sp->exit[dest_no].x - sp->beacon[(int)c].x;
+ ydiff = sp->exit[dest_no].y - sp->beacon[(int)c].y;
break;
case T_AIRPORT:
- xdiff = sp->airport[dest_no].x - sp->beacon[c].x;
- ydiff = sp->airport[dest_no].y - sp->beacon[c].y;
+ xdiff = sp->airport[dest_no].x - sp->beacon[(int)c].x;
+ ydiff = sp->airport[dest_no].y - sp->beacon[(int)c].y;
break;
default:
return ("Bad case in delayb! Get help!");
@@ -419,43 +435,49 @@ delayb(c)
return (NULL);
}
-char *
+const char *
beacon(c)
+ char c;
{
dest_type = T_BEACON;
return (NULL);
}
-char *
+const char *
ex_it(c)
+ char c;
{
dest_type = T_EXIT;
return (NULL);
}
-char *
+const char *
airport(c)
+ char c;
{
dest_type = T_AIRPORT;
return (NULL);
}
-char *
+const char *
climb(c)
+ char c;
{
dir = D_UP;
return (NULL);
}
-char *
+const char *
descend(c)
+ char c;
{
dir = D_DOWN;
return (NULL);
}
-char *
+const char *
setalt(c)
+ char c;
{
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
return ("Already at that altitude");
@@ -463,8 +485,9 @@ setalt(c)
return (NULL);
}
-char *
+const char *
setrelalt(c)
+ char c;
{
if (c == 0)
return ("altitude not changed");
@@ -487,8 +510,9 @@ setrelalt(c)
return (NULL);
}
-char *
+const char *
benum(c)
+ char c;
{
dest_no = c -= '0';
@@ -496,20 +520,20 @@ benum(c)
case T_BEACON:
if (c >= sp->num_beacons)
return ("Unknown beacon");
- p.new_dir = DIR_FROM_DXDY(sp->beacon[c].x - p.xpos,
- sp->beacon[c].y - p.ypos);
+ p.new_dir = DIR_FROM_DXDY(sp->beacon[(int)c].x - p.xpos,
+ sp->beacon[(int)c].y - p.ypos);
break;
case T_EXIT:
if (c >= sp->num_exits)
return ("Unknown exit");
- p.new_dir = DIR_FROM_DXDY(sp->exit[c].x - p.xpos,
- sp->exit[c].y - p.ypos);
+ p.new_dir = DIR_FROM_DXDY(sp->exit[(int)c].x - p.xpos,
+ sp->exit[(int)c].y - p.ypos);
break;
case T_AIRPORT:
if (c >= sp->num_airports)
return ("Unknown airport");
- p.new_dir = DIR_FROM_DXDY(sp->airport[c].x - p.xpos,
- sp->airport[c].y - p.ypos);
+ p.new_dir = DIR_FROM_DXDY(sp->airport[(int)c].x - p.xpos,
+ sp->airport[(int)c].y - p.ypos);
break;
default:
return ("Unknown case in benum! Get help!");
@@ -518,15 +542,17 @@ benum(c)
return (NULL);
}
-char *
+const char *
to_dir(c)
+ char c;
{
p.new_dir = dir_no(c);
return (NULL);
}
-char *
+const char *
rel_dir(c)
+ char c;
{
int angle;
@@ -549,8 +575,9 @@ rel_dir(c)
return (NULL);
}
-char *
+const char *
mark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot mark planes on the ground");
@@ -560,8 +587,9 @@ mark(c)
return (NULL);
}
-char *
+const char *
unmark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot unmark planes on the ground");
@@ -571,8 +599,9 @@ unmark(c)
return (NULL);
}
-char *
+const char *
ignore(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot ignore planes on the ground");
@@ -582,6 +611,7 @@ ignore(c)
return (NULL);
}
+int
dir_no(ch)
char ch;
{
@@ -597,6 +627,7 @@ dir_no(ch)
case 'a': dir = 6; break;
case 'q': dir = 7; break;
default:
+ dir = -1;
fprintf(stderr, "bad character in dir_no\n");
break;
}
diff --git a/games/atc/lex.l b/games/atc/lex.l
index 54f84c463fe..a7693b9cf63 100644
--- a/games/atc/lex.l
+++ b/games/atc/lex.l
@@ -1,4 +1,5 @@
%{
+/* $OpenBSD: lex.l,v 1.2 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: lex.l,v 1.3 1995/03/21 15:04:15 cgd Exp $ */
/*-
@@ -50,11 +51,12 @@
#if 0
static char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: lex.l,v 1.3 1995/03/21 15:04:15 cgd Exp $";
+static char rcsid[] = "$OpenBSD: lex.l,v 1.2 1998/09/21 07:36:06 pjanzen Exp $";
#endif
#endif /* not lint */
#include "y.tab.h"
+
extern int line;
%}
diff --git a/games/atc/list.c b/games/atc/list.c
index 62132cb9ef7..2de6251968a 100644
--- a/games/atc/list.c
+++ b/games/atc/list.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: list.c,v 1.2 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: list.c,v 1.3 1995/03/21 15:04:18 cgd Exp $ */
/*-
@@ -49,7 +50,7 @@
#if 0
static char sccsid[] = "@(#)list.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: list.c,v 1.3 1995/03/21 15:04:18 cgd Exp $";
+static char rcsid[] = "$OpenBSD: list.c,v 1.2 1998/09/21 07:36:06 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -61,6 +62,7 @@ newplane()
return ((PLANE *) calloc(1, sizeof (PLANE)));
}
+void
append(l, p)
LIST *l;
PLANE *p;
@@ -99,6 +101,7 @@ append(l, p)
}
}
+void
delete(l, p)
LIST *l;
PLANE *p;
diff --git a/games/atc/log.c b/games/atc/log.c
index a9680218ac1..f06018990c1 100644
--- a/games/atc/log.c
+++ b/games/atc/log.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: log.c,v 1.5 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $ */
/*-
@@ -49,7 +50,7 @@
#if 0
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $";
+static char rcsid[] = "$OpenBSD: log.c,v 1.5 1998/09/21 07:36:06 pjanzen Exp $";
#endif
#endif not lint
@@ -58,9 +59,14 @@ static char rcsid[] = "$NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $";
static FILE *score_fp;
-compar(a, b)
- SCORE *a, *b;
+int
+compar(va, vb)
+ const void *va, *vb;
{
+ const SCORE *a, *b;
+
+ a = (SCORE *)va;
+ b = (SCORE *)vb;
if (b->planes == a->planes)
return (b->time - a->time);
else
@@ -77,8 +83,9 @@ compar(a, b)
#define MIN(t) (((t) % SECAHOUR) / SECAMIN)
#define SEC(t) ((t) % SECAMIN)
-char *
+const char *
timestr(t)
+ int t;
{
static char s[80];
@@ -96,6 +103,7 @@ timestr(t)
return (s);
}
+int
open_score_file()
{
mode_t old_mode;
@@ -117,8 +125,10 @@ open_score_file()
return (-1);
}
umask(old_mode);
+ return (0);
}
+int
log_score(list_em)
{
int i, num_scores = 0, good, changed = 0, found = 0;
@@ -127,6 +137,8 @@ log_score(list_em)
SCORE score[100], thisscore;
struct utsname name;
+ if (score_fp == NULL)
+ return (-1);
#ifdef BSD
if (flock(fileno(score_fp), LOCK_EX) < 0)
#endif
@@ -191,10 +203,10 @@ log_score(list_em)
if (thisscore.time > score[i].time) {
if (num_scores < NUM_SCORES)
num_scores++;
- bcopy(&score[i],
- &score[num_scores - 1],
+ memcpy(&score[num_scores - 1],
+ &score[i],
sizeof (score[i]));
- bcopy(&thisscore, &score[i],
+ memcpy(&score[i], &thisscore,
sizeof (score[i]));
changed++;
break;
@@ -202,7 +214,7 @@ log_score(list_em)
}
}
if (!found && !changed && num_scores < NUM_SCORES) {
- bcopy(&thisscore, &score[num_scores],
+ memcpy(&score[num_scores], &thisscore,
sizeof (score[num_scores]));
num_scores++;
changed++;
@@ -256,3 +268,11 @@ log_score(list_em)
putchar('\n');
return (0);
}
+
+void
+log_score_quit(dummy)
+ int dummy;
+{
+ (void)log_score(0);
+ exit(0);
+}
diff --git a/games/atc/main.c b/games/atc/main.c
index 078b4bbd589..e69664d5663 100644
--- a/games/atc/main.c
+++ b/games/atc/main.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: main.c,v 1.7 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
@@ -55,27 +56,27 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.7 1998/09/21 07:36:06 pjanzen Exp $";
#endif
#endif /* not lint */
#include "include.h"
#include "pathnames.h"
+int
main(ac, av)
+ int ac;
char *av[];
{
int seed;
int f_usage = 0, f_list = 0, f_showscore = 0;
int f_printpath = 0;
- char *file = NULL;
+ const char *file = NULL;
char *name, *ptr;
struct sigaction sa;
#ifdef BSD
struct itimerval itv;
#endif
- extern char *default_game(), *okay_game();
- extern void log_score(), quit(), update();
open_score_file();
@@ -84,12 +85,13 @@ main(ac, av)
setgid(getgid());
start_time = seed = time(0);
+ makenoise = 1;
name = *av++;
while (*av) {
#ifndef SAVEDASH
if (**av == '-')
- *++*av;
+ ++*av;
else
break;
#endif
@@ -110,6 +112,9 @@ main(ac, av)
case 'p':
f_printpath++;
break;
+ case 'q':
+ makenoise = 0;
+ break;
case 'r':
seed = atoi(*av);
av++;
@@ -120,8 +125,7 @@ main(ac, av)
av++;
break;
default:
- fprintf(stderr, "Unknown option '%c'\n", *ptr,
- name);
+ warnx("unknown option '%c'", *ptr);
f_usage++;
break;
}
@@ -132,14 +136,14 @@ main(ac, av)
if (f_usage)
fprintf(stderr,
- "Usage: %s -[u?lstp] [-[gf] game_name] [-r random seed]\n",
+ "Usage: %s -[u?lstpq] [-[gf] game_name] [-r random seed]\n",
name);
if (f_showscore)
log_score(1);
if (f_list)
list_games();
if (f_printpath) {
- char buf[100];
+ char buf[256];
strcpy(buf, _PATH_GAMES);
buf[strlen(buf) - 1] = '\0';
@@ -168,8 +172,8 @@ main(ac, av)
signal(SIGTSTP, SIG_IGN);
signal(SIGSTOP, SIG_IGN);
#endif
- signal(SIGHUP, log_score);
- signal(SIGTERM, log_score);
+ signal(SIGHUP, log_score_quit);
+ signal(SIGTERM, log_score_quit);
tcgetattr(fileno(stdin), &tty_start);
tty_new = tty_start;
@@ -211,7 +215,7 @@ main(ac, av)
alarm(0);
#endif
- update();
+ update(0);
#ifdef BSD
itv.it_value.tv_sec = sp->update_secs;
@@ -227,8 +231,9 @@ main(ac, av)
}
}
+int
read_file(s)
- char *s;
+ const char *s;
{
extern FILE *yyin;
int retval;
@@ -236,7 +241,7 @@ read_file(s)
file = s;
yyin = fopen(s, "r");
if (yyin == NULL) {
- perror(s);
+ warn("fopen %s", s);
return (-1);
}
retval = yyparse();
@@ -248,7 +253,7 @@ read_file(s)
return (0);
}
-char *
+const char *
default_game()
{
FILE *fp;
@@ -259,38 +264,47 @@ default_game()
strcat(games, GAMES);
if ((fp = fopen(games, "r")) == NULL) {
- perror(games);
+ warn("fopen %s", games);
return (NULL);
}
if (fgets(line, sizeof(line), fp) == NULL) {
- fprintf(stderr, "%s: no default game available\n", games);
+ warnx("%s: no default game available", games);
return (NULL);
}
fclose(fp);
line[strlen(line) - 1] = '\0';
+ if (strlen(line) + strlen(_PATH_GAMES) >= sizeof(file)) {
+ warnx("default game name too long");
+ return (NULL);
+ }
strcpy(file, _PATH_GAMES);
strcat(file, line);
return (file);
}
-char *
+const char *
okay_game(s)
- char *s;
+ const char *s;
{
FILE *fp;
static char file[256];
- char *ret = NULL, line[256], games[256];
+ const char *ret = NULL;
+ char line[256], games[256];
strcpy(games, _PATH_GAMES);
strcat(games, GAMES);
if ((fp = fopen(games, "r")) == NULL) {
- perror(games);
+ warn("fopen %s", games);
return (NULL);
}
while (fgets(line, sizeof(line), fp) != NULL) {
line[strlen(line) - 1] = '\0';
if (strcmp(s, line) == 0) {
+ if (strlen(line) + strlen(_PATH_GAMES) >= sizeof(file)) {
+ warnx("game name too long");
+ return (NULL);
+ }
strcpy(file, _PATH_GAMES);
strcat(file, line);
ret = file;
@@ -308,6 +322,7 @@ okay_game(s)
return (ret);
}
+int
list_games()
{
FILE *fp;
@@ -318,7 +333,7 @@ list_games()
strcat(games, GAMES);
if ((fp = fopen(games, "r")) == NULL) {
- perror(games);
+ warn("fopen %s", games);
return (-1);
}
puts("available games:");
diff --git a/games/atc/pathnames.h b/games/atc/pathnames.h
index c6f65339750..4490ed1aa42 100644
--- a/games/atc/pathnames.h
+++ b/games/atc/pathnames.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pathnames.h,v 1.2 1998/09/21 07:36:06 pjanzen Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1995/03/21 15:04:28 cgd Exp $ */
/*-
diff --git a/games/atc/struct.h b/games/atc/struct.h
index 016f1d6c0e3..b99e385f9ae 100644
--- a/games/atc/struct.h
+++ b/games/atc/struct.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: struct.h,v 1.2 1998/09/21 07:36:07 pjanzen Exp $ */
/* $NetBSD: struct.h,v 1.3 1995/03/21 15:04:31 cgd Exp $ */
/*-
diff --git a/games/atc/tunable.c b/games/atc/tunable.c
index b864e70d499..739807d4c81 100644
--- a/games/atc/tunable.c
+++ b/games/atc/tunable.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: tunable.c,v 1.2 1998/09/21 07:36:07 pjanzen Exp $ */
/* $NetBSD: tunable.c,v 1.3 1995/03/21 15:04:33 cgd Exp $ */
/*-
@@ -49,7 +50,7 @@
#if 0
static char sccsid[] = "@(#)tunable.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: tunable.c,v 1.3 1995/03/21 15:04:33 cgd Exp $";
+static char rcsid[] = "$OpenBSD: tunable.c,v 1.2 1998/09/21 07:36:07 pjanzen Exp $";
#endif
#endif /* not lint */
diff --git a/games/atc/tunable.h b/games/atc/tunable.h
deleted file mode 100644
index a295a477fae..00000000000
--- a/games/atc/tunable.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: tunable.h,v 1.3 1995/03/21 15:04:35 cgd Exp $ */
-
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Ed James.
- *
- * 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.
- *
- * @(#)tunable.h 8.1 (Berkeley) 5/31/93
- */
-
-/*
- * Copyright (c) 1987 by Ed James, UC Berkeley. All rights reserved.
- *
- * Copy permission is hereby granted provided that this notice is
- * retained on all partial or complete copies.
- *
- * For more info on this and all of my stuff, mail edjames@berkeley.edu.
- */
-
-extern int NUM_SCORES;
diff --git a/games/atc/update.c b/games/atc/update.c
index cff7dcd6946..e34b7c768cb 100644
--- a/games/atc/update.c
+++ b/games/atc/update.c
@@ -1,4 +1,4 @@
-/* $NetBSD: update.c,v 1.4 1995/04/27 21:22:26 mycroft Exp $ */
+/* $OpenBSD: update.c,v 1.3 1998/09/21 07:36:07 pjanzen Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -49,16 +49,18 @@
#if 0
static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: update.c,v 1.4 1995/04/27 21:22:26 mycroft Exp $";
+static char rcsid[] = "$OpenBSD: update.c,v 1.3 1998/09/21 07:36:07 pjanzen Exp $";
#endif
#endif not lint
#include "include.h"
-update()
+void
+update(dummy)
+ int dummy;
{
- int i, dir_diff, mask, unclean;
- PLANE *pp, *p1, *p2, *p;
+ int i, dir_diff, unclean;
+ PLANE *pp, *p1, *p2;
#ifdef SYSV
alarm(0);
@@ -211,7 +213,7 @@ update()
* Otherwise, prop jobs show up *on* entrance. Remember that
* we don't update props on odd updates.
*/
- if ((rand() % sp->newplane_time) == 0)
+ if ((random() % sp->newplane_time) == 0)
addplane();
#ifdef SYSV
@@ -219,7 +221,7 @@ update()
#endif
}
-char *
+const char *
command(pp)
PLANE *pp;
{
@@ -250,9 +252,9 @@ command(pp)
return (buf);
}
-/* char */
+char
name(p)
- PLANE *p;
+ const PLANE *p;
{
if (p->plane_type == 0)
return ('A' + p->plane_no);
@@ -260,7 +262,9 @@ name(p)
return ('a' + p->plane_no);
}
+int
number(l)
+ char l;
{
if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
return (-1);
@@ -270,6 +274,7 @@ number(l)
return (l - 'A');
}
+int
next_plane()
{
static int last_plane = -1;
@@ -298,12 +303,13 @@ next_plane()
return (last_plane);
}
+int
addplane()
{
PLANE p, *pp, *p1;
int i, num_starts, close, rnd, rnd2, pnum;
- bzero(&p, sizeof (p));
+ memset(&p, 0, sizeof (p));
p.status = S_MARKED;
p.plane_type = random() % 2;
@@ -358,7 +364,7 @@ addplane()
p.plane_no = pnum;
pp = newplane();
- bcopy(&p, pp, sizeof (p));
+ memcpy(pp, &p, sizeof (p));
if (pp->orig_type == T_AIRPORT)
append(&ground, pp);
@@ -370,6 +376,7 @@ addplane()
PLANE *
findplane(n)
+ int n;
{
PLANE *pp;
@@ -382,8 +389,10 @@ findplane(n)
return (NULL);
}
+int
too_close(p1, p2, dist)
- PLANE *p1, *p2;
+ const PLANE *p1, *p2;
+ int dist;
{
if (ABS(p1->altitude - p2->altitude) <= dist &&
ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)
@@ -392,7 +401,9 @@ too_close(p1, p2, dist)
return (0);
}
+int
dir_deg(d)
+ int d;
{
switch (d) {
case 0: return (0);