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