| File: | src/games/trek/main.c |
| Warning: | line 138, column 2 Value stored to 'ac' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* $OpenBSD: main.c,v 1.19 2021/01/27 01:57:37 deraadt 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 | struct quad Quad[NQUADS8][NQUADS8]; |
| 43 | char Sect[NSECTS10][NSECTS10]; |
| 44 | struct event Event[MAXEVENTS25]; |
| 45 | struct Ship Ship; |
| 46 | struct Game Game; |
| 47 | struct Move Move; |
| 48 | struct Param Param; |
| 49 | struct Now Now; |
| 50 | struct Etc Etc; |
| 51 | |
| 52 | /* |
| 53 | ** #### ##### # #### ##### #### ##### # # |
| 54 | ** # # # # # # # # # # # # |
| 55 | ** ### # ##### #### # #### ### ### |
| 56 | ** # # # # # # # # # # # # |
| 57 | ** #### # # # # # # # # ##### # # |
| 58 | ** |
| 59 | ** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help |
| 60 | ** from Jeff Poskanzer and Pete Rubinstein. |
| 61 | ** |
| 62 | ** I also want to thank everyone here at Berkeley who |
| 63 | ** where crazy enough to play the undebugged game. I want to |
| 64 | ** particularly thank Nick Whyte, who made considerable |
| 65 | ** suggestions regarding the content of the game. Why, I'll |
| 66 | ** never forget the time he suggested the name for the |
| 67 | ** "capture" command. |
| 68 | ** |
| 69 | ** Please send comments, questions, and suggestions about this |
| 70 | ** game to: |
| 71 | ** Eric P. Allman |
| 72 | ** Project INGRES |
| 73 | ** Electronics Research Laboratory |
| 74 | ** Cory Hall |
| 75 | ** University of California |
| 76 | ** Berkeley, California 94720 |
| 77 | ** |
| 78 | ** If you make ANY changes in the game, I sure would like to |
| 79 | ** know about them. It is sort of an ongoing project for me, |
| 80 | ** and I very much want to put in any bug fixes and improvements |
| 81 | ** that you might come up with. |
| 82 | ** |
| 83 | ** FORTRASH version by Kay R. Fisher (DEC) "and countless others". |
| 84 | ** That was adapted from the "original BASIC program" (ha!) by |
| 85 | ** Mike Mayfield (Centerline Engineering). |
| 86 | ** |
| 87 | ** Additional inspiration taken from FORTRAN version by |
| 88 | ** David Matuszek and Paul Reynolds which runs on the CDC |
| 89 | ** 7600 at Lawrence Berkeley Lab, maintained there by |
| 90 | ** Andy Davidson. This version is also available at LLL |
| 91 | ** and at LMSC. In all fairness, this version was the |
| 92 | ** major inspiration for this version of the game (trans- |
| 93 | ** lation: I ripped off a whole lot of code). |
| 94 | ** |
| 95 | ** Minor other input from the "Battelle Version 7A" by Joe Miller |
| 96 | ** (Graphics Systems Group, Battelle-Columbus Labs) and |
| 97 | ** Ross Pavlac (Systems Programmer, Battelle Memorial |
| 98 | ** Institute). That version was written in December '74 |
| 99 | ** and extensively modified June '75. It was adapted |
| 100 | ** from the FTN version by Ron Williams of CDC Sunnyvale, |
| 101 | ** which was adapted from the Basic version distributed |
| 102 | ** by DEC. It also had "neat stuff swiped" from T. T. |
| 103 | ** Terry and Jim Korp (University of Texas), Hicks (Penn |
| 104 | ** U.), and Rick Maus (Georgia Tech). Unfortunately, it |
| 105 | ** was not as readable as it could have been and so the |
| 106 | ** translation effort was severely hampered. None the |
| 107 | ** less, I got the idea of inhabited starsystems from this |
| 108 | ** version. |
| 109 | ** |
| 110 | ** Permission is given for use, copying, and modification of |
| 111 | ** all or part of this program and related documentation, |
| 112 | ** provided that all reference to the authors are maintained. |
| 113 | ** |
| 114 | ** |
| 115 | ********************************************************************** |
| 116 | ** |
| 117 | ** NOTES TO THE MAINTAINER: |
| 118 | ** |
| 119 | ** There is a compilation option xTRACE which must be set for any |
| 120 | ** trace information to be generated (the -t option must also be |
| 121 | ** set on the command line). It is no longer defined by default. |
| 122 | ** |
| 123 | *********************************************************************** |
| 124 | */ |
| 125 | |
| 126 | jmp_buf env; |
| 127 | |
| 128 | int |
| 129 | main(int argc, char **argv) |
| 130 | { |
| 131 | int ac; |
| 132 | char **av; |
| 133 | |
| 134 | if (pledge("stdio", NULL((void *)0)) == -1) |
| 135 | err(1, "pledge"); |
| 136 | |
| 137 | av = argv; |
| 138 | ac = argc; |
Value stored to 'ac' is never read | |
| 139 | av++; |
| 140 | |
| 141 | #ifdef xTRACE |
| 142 | Trace = 0; |
| 143 | while (ac > 1 && av[0][0] == '-') |
| 144 | { |
| 145 | switch (av[0][1]) |
| 146 | { |
| 147 | case 't': /* trace */ |
| 148 | Trace++; |
| 149 | break; |
| 150 | |
| 151 | default: |
| 152 | printf("Invalid option: %s\n", av[0]); |
| 153 | |
| 154 | } |
| 155 | ac--; |
| 156 | av++; |
| 157 | } |
| 158 | #endif |
| 159 | |
| 160 | printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n"); |
| 161 | |
| 162 | if (setjmp(env)) |
| 163 | { |
| 164 | if ( !getynpar("Another game") ) |
| 165 | return 0; |
| 166 | } |
| 167 | do |
| 168 | { |
| 169 | setup(); |
| 170 | play(); |
| 171 | } while (getynpar("Another game")); |
| 172 | |
| 173 | fflush(stdout(&__sF[1])); |
| 174 | return 0; |
| 175 | } |