1*9cf65994Sderaadt /* $OpenBSD: main.c,v 1.19 2021/01/27 01:57:37 deraadt Exp $ */
2df930be7Sderaadt /* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */
3df930be7Sderaadt
4df930be7Sderaadt /*
5df930be7Sderaadt * Copyright (c) 1980, 1993
6df930be7Sderaadt * The Regents of the University of California. All rights reserved.
7df930be7Sderaadt *
8df930be7Sderaadt * Redistribution and use in source and binary forms, with or without
9df930be7Sderaadt * modification, are permitted provided that the following conditions
10df930be7Sderaadt * are met:
11df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright
12df930be7Sderaadt * notice, this list of conditions and the following disclaimer.
13df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright
14df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the
15df930be7Sderaadt * documentation and/or other materials provided with the distribution.
167a09557bSmillert * 3. Neither the name of the University nor the names of its contributors
17df930be7Sderaadt * may be used to endorse or promote products derived from this software
18df930be7Sderaadt * without specific prior written permission.
19df930be7Sderaadt *
20df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30df930be7Sderaadt * SUCH DAMAGE.
31df930be7Sderaadt */
32df930be7Sderaadt
3348b4d137Smestre #include <err.h>
34df930be7Sderaadt #include <setjmp.h>
3548b4d137Smestre #include <stdio.h>
361ed0e75dSpjanzen #include <stdlib.h>
371ed0e75dSpjanzen #include <unistd.h>
3848b4d137Smestre
391ed0e75dSpjanzen #include "getpar.h"
4048b4d137Smestre #include "trek.h"
41df930be7Sderaadt
42*9cf65994Sderaadt struct quad Quad[NQUADS][NQUADS];
43*9cf65994Sderaadt char Sect[NSECTS][NSECTS];
44*9cf65994Sderaadt struct event Event[MAXEVENTS];
45*9cf65994Sderaadt struct Ship Ship;
46*9cf65994Sderaadt struct Game Game;
47*9cf65994Sderaadt struct Move Move;
48*9cf65994Sderaadt struct Param Param;
49*9cf65994Sderaadt struct Now Now;
50*9cf65994Sderaadt struct Etc Etc;
51*9cf65994Sderaadt
52df930be7Sderaadt /*
53df930be7Sderaadt ** #### ##### # #### ##### #### ##### # #
54df930be7Sderaadt ** # # # # # # # # # # # #
55df930be7Sderaadt ** ### # ##### #### # #### ### ###
56df930be7Sderaadt ** # # # # # # # # # # # #
57df930be7Sderaadt ** #### # # # # # # # # ##### # #
58df930be7Sderaadt **
59df930be7Sderaadt ** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help
60df930be7Sderaadt ** from Jeff Poskanzer and Pete Rubinstein.
61df930be7Sderaadt **
62df930be7Sderaadt ** I also want to thank everyone here at Berkeley who
63df930be7Sderaadt ** where crazy enough to play the undebugged game. I want to
64df930be7Sderaadt ** particularly thank Nick Whyte, who made considerable
65df930be7Sderaadt ** suggestions regarding the content of the game. Why, I'll
66df930be7Sderaadt ** never forget the time he suggested the name for the
67df930be7Sderaadt ** "capture" command.
68df930be7Sderaadt **
69df930be7Sderaadt ** Please send comments, questions, and suggestions about this
70df930be7Sderaadt ** game to:
71df930be7Sderaadt ** Eric P. Allman
72df930be7Sderaadt ** Project INGRES
73df930be7Sderaadt ** Electronics Research Laboratory
74df930be7Sderaadt ** Cory Hall
75df930be7Sderaadt ** University of California
76df930be7Sderaadt ** Berkeley, California 94720
77df930be7Sderaadt **
78df930be7Sderaadt ** If you make ANY changes in the game, I sure would like to
79df930be7Sderaadt ** know about them. It is sort of an ongoing project for me,
80df930be7Sderaadt ** and I very much want to put in any bug fixes and improvements
81df930be7Sderaadt ** that you might come up with.
82df930be7Sderaadt **
83df930be7Sderaadt ** FORTRASH version by Kay R. Fisher (DEC) "and countless others".
84df930be7Sderaadt ** That was adapted from the "original BASIC program" (ha!) by
85df930be7Sderaadt ** Mike Mayfield (Centerline Engineering).
86df930be7Sderaadt **
87df930be7Sderaadt ** Additional inspiration taken from FORTRAN version by
88df930be7Sderaadt ** David Matuszek and Paul Reynolds which runs on the CDC
89df930be7Sderaadt ** 7600 at Lawrence Berkeley Lab, maintained there by
90df930be7Sderaadt ** Andy Davidson. This version is also available at LLL
91df930be7Sderaadt ** and at LMSC. In all fairness, this version was the
92df930be7Sderaadt ** major inspiration for this version of the game (trans-
93df930be7Sderaadt ** lation: I ripped off a whole lot of code).
94df930be7Sderaadt **
95df930be7Sderaadt ** Minor other input from the "Battelle Version 7A" by Joe Miller
96df930be7Sderaadt ** (Graphics Systems Group, Battelle-Columbus Labs) and
97df930be7Sderaadt ** Ross Pavlac (Systems Programmer, Battelle Memorial
98df930be7Sderaadt ** Institute). That version was written in December '74
99df930be7Sderaadt ** and extensively modified June '75. It was adapted
100df930be7Sderaadt ** from the FTN version by Ron Williams of CDC Sunnyvale,
101df930be7Sderaadt ** which was adapted from the Basic version distributed
102df930be7Sderaadt ** by DEC. It also had "neat stuff swiped" from T. T.
103df930be7Sderaadt ** Terry and Jim Korp (University of Texas), Hicks (Penn
104df930be7Sderaadt ** U.), and Rick Maus (Georgia Tech). Unfortunately, it
105df930be7Sderaadt ** was not as readable as it could have been and so the
106df930be7Sderaadt ** translation effort was severely hampered. None the
107df930be7Sderaadt ** less, I got the idea of inhabited starsystems from this
108df930be7Sderaadt ** version.
109df930be7Sderaadt **
110df930be7Sderaadt ** Permission is given for use, copying, and modification of
111df930be7Sderaadt ** all or part of this program and related documentation,
112df930be7Sderaadt ** provided that all reference to the authors are maintained.
113df930be7Sderaadt **
114df930be7Sderaadt **
115df930be7Sderaadt **********************************************************************
116df930be7Sderaadt **
117df930be7Sderaadt ** NOTES TO THE MAINTAINER:
118df930be7Sderaadt **
119df930be7Sderaadt ** There is a compilation option xTRACE which must be set for any
1205c4c4ba9Spjanzen ** trace information to be generated (the -t option must also be
1215c4c4ba9Spjanzen ** set on the command line). It is no longer defined by default.
122df930be7Sderaadt **
123df930be7Sderaadt ***********************************************************************
124df930be7Sderaadt */
125df930be7Sderaadt
126df930be7Sderaadt jmp_buf env;
127df930be7Sderaadt
1281b37764bSpjanzen int
main(int argc,char ** argv)12911da2480Smestre main(int argc, char **argv)
130df930be7Sderaadt {
13197419aa0Spjanzen int ac;
13297419aa0Spjanzen char **av;
133df930be7Sderaadt
134e6afc4b5Smestre if (pledge("stdio", NULL) == -1)
135f01d2bc3Stb err(1, "pledge");
136f01d2bc3Stb
137df930be7Sderaadt av = argv;
138df930be7Sderaadt ac = argc;
139df930be7Sderaadt av++;
140df930be7Sderaadt
1415c4c4ba9Spjanzen #ifdef xTRACE
1425c4c4ba9Spjanzen Trace = 0;
143df930be7Sderaadt while (ac > 1 && av[0][0] == '-')
144df930be7Sderaadt {
145df930be7Sderaadt switch (av[0][1])
146df930be7Sderaadt {
147df930be7Sderaadt case 't': /* trace */
148df930be7Sderaadt Trace++;
149df930be7Sderaadt break;
150df930be7Sderaadt
151df930be7Sderaadt default:
152df930be7Sderaadt printf("Invalid option: %s\n", av[0]);
153df930be7Sderaadt
154df930be7Sderaadt }
155df930be7Sderaadt ac--;
156df930be7Sderaadt av++;
157df930be7Sderaadt }
1585c4c4ba9Spjanzen #endif
159df930be7Sderaadt
160df930be7Sderaadt printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n");
161df930be7Sderaadt
162df930be7Sderaadt if (setjmp(env))
163df930be7Sderaadt {
164df930be7Sderaadt if ( !getynpar("Another game") )
16517641e31Stb return 0;
166df930be7Sderaadt }
167df930be7Sderaadt do
168df930be7Sderaadt {
169df930be7Sderaadt setup();
170df930be7Sderaadt play();
171df930be7Sderaadt } while (getynpar("Another game"));
172df930be7Sderaadt
173df930be7Sderaadt fflush(stdout);
1741ed0e75dSpjanzen return 0;
175df930be7Sderaadt }
176