Sun May 24 20:39:43 2009 UTC ()
KNF: fix formatting of preprocessor directives


(dholland)
diff -r1.8 -r1.9 src/games/trek/capture.c
diff -r1.8 -r1.9 src/games/trek/events.c
diff -r1.8 -r1.9 src/games/trek/externs.c
diff -r1.8 -r1.9 src/games/trek/schedule.c
diff -r1.6 -r1.7 src/games/trek/damaged.c
diff -r1.6 -r1.7 src/games/trek/klmove.c
diff -r1.12 -r1.13 src/games/trek/dumpgame.c
diff -r1.12 -r1.13 src/games/trek/trek.h
diff -r1.14 -r1.15 src/games/trek/main.c
diff -r1.7 -r1.8 src/games/trek/move.c
diff -r1.7 -r1.8 src/games/trek/systemname.c
diff -r1.11 -r1.12 src/games/trek/phaser.c

cvs diff -r1.8 -r1.9 src/games/trek/capture.c (expand / switch to unified diff)

--- src/games/trek/capture.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/capture.c 2009/05/24 20:39:43 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: capture.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: capture.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include "trek.h" 42#include "trek.h"
43 43
44/* 44/*
45** Ask a Klingon To Surrender 45** Ask a Klingon To Surrender
46** 46**
47** (Fat chance) 47** (Fat chance)
48** 48**
49** The Subspace Radio is needed to ask a Klingon if he will kindly 49** The Subspace Radio is needed to ask a Klingon if he will kindly
50** surrender. A random Klingon from the ones in the quadrant is 50** surrender. A random Klingon from the ones in the quadrant is
@@ -82,30 +82,30 @@ capture(int v __unused) @@ -82,30 +82,30 @@ capture(int v __unused)
82 82
83 /* if there is more than one Klingon, find out which one */ 83 /* if there is more than one Klingon, find out which one */
84 k = selectklingon(); 84 k = selectklingon();
85 Move.free = 0; 85 Move.free = 0;
86 Move.time = 0.05; 86 Move.time = 0.05;
87 87
88 /* check out that Klingon */ 88 /* check out that Klingon */
89 k->srndreq++; 89 k->srndreq++;
90 x = Param.klingpwr; 90 x = Param.klingpwr;
91 x *= Ship.energy; 91 x *= Ship.energy;
92 x /= k->power * Etc.nkling; 92 x /= k->power * Etc.nkling;
93 x *= Param.srndrprob; 93 x *= Param.srndrprob;
94 i = x; 94 i = x;
95# ifdef xTRACE 95#ifdef xTRACE
96 if (Trace) 96 if (Trace)
97 printf("Prob = %d (%.4f)\n", i, x); 97 printf("Prob = %d (%.4f)\n", i, x);
98# endif 98#endif
99 if (i > ranf(100)) 99 if (i > ranf(100))
100 { 100 {
101 /* guess what, he surrendered!!! */ 101 /* guess what, he surrendered!!! */
102 printf("Klingon at %d,%d surrenders\n", k->x, k->y); 102 printf("Klingon at %d,%d surrenders\n", k->x, k->y);
103 i = ranf(Param.klingcrew); 103 i = ranf(Param.klingcrew);
104 if ( i > 0 ) 104 if ( i > 0 )
105 printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i); 105 printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i);
106 if (i > Ship.brigfree) 106 if (i > Ship.brigfree)
107 i = Ship.brigfree; 107 i = Ship.brigfree;
108 Ship.brigfree -= i; 108 Ship.brigfree -= i;
109 printf("%d captives taken\n", i); 109 printf("%d captives taken\n", i);
110 killk(k->x, k->y); 110 killk(k->x, k->y);
111 return; 111 return;

cvs diff -r1.8 -r1.9 src/games/trek/events.c (expand / switch to unified diff)

--- src/games/trek/events.c 2008/01/28 01:15:55 1.8
+++ src/games/trek/events.c 2009/05/24 20:39:43 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: events.c,v 1.8 2008/01/28 01:15:55 dholland Exp $ */ 1/* $NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: events.c,v 1.8 2008/01/28 01:15:55 dholland Exp $"); 37__RCSID("$NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <string.h> 42#include <string.h>
43#include <math.h> 43#include <math.h>
44#include "getpar.h" 44#include "getpar.h"
45#include "trek.h" 45#include "trek.h"
46 46
47/* 47/*
48** CAUSE TIME TO ELAPSE 48** CAUSE TIME TO ELAPSE
49** 49**
50** This routine does a hell of a lot. It elapses time, eats up 50** This routine does a hell of a lot. It elapses time, eats up
@@ -115,31 +115,31 @@ events(int timewarp) @@ -115,31 +115,31 @@ events(int timewarp)
115 rtime = xdate - Now.date; 115 rtime = xdate - Now.date;
116 116
117 /* decrement the magic "Federation Resources" pseudo-variable */ 117 /* decrement the magic "Federation Resources" pseudo-variable */
118 Now.resource -= Now.klings * rtime; 118 Now.resource -= Now.klings * rtime;
119 /* and recompute the time left */ 119 /* and recompute the time left */
120 Now.time = Now.resource / Now.klings; 120 Now.time = Now.resource / Now.klings;
121 121
122 /* move us up to the next date */ 122 /* move us up to the next date */
123 Now.date = xdate; 123 Now.date = xdate;
124 124
125 /* check for out of time */ 125 /* check for out of time */
126 if (Now.time <= 0.0) 126 if (Now.time <= 0.0)
127 lose(L_NOTIME); 127 lose(L_NOTIME);
128# ifdef xTRACE 128#ifdef xTRACE
129 if (evnum >= 0 && Trace) 129 if (evnum >= 0 && Trace)
130 printf("xdate = %.2f, evcode %d params %d %d %d\n", 130 printf("xdate = %.2f, evcode %d params %d %d %d\n",
131 xdate, e->evcode, e->x, e->y, e->systemname); 131 xdate, e->evcode, e->x, e->y, e->systemname);
132# endif 132#endif
133 133
134 /* if evnum < 0, no events occurred */ 134 /* if evnum < 0, no events occurred */
135 if (evnum < 0) 135 if (evnum < 0)
136 break; 136 break;
137 137
138 /* otherwise one did. Find out what it is */ 138 /* otherwise one did. Find out what it is */
139 switch (e->evcode & E_EVENT) 139 switch (e->evcode & E_EVENT)
140 { 140 {
141 141
142 case E_SNOVA: /* supernova */ 142 case E_SNOVA: /* supernova */
143 /* cause the supernova to happen */ 143 /* cause the supernova to happen */
144 snova(-1, 0); 144 snova(-1, 0);
145 /* and schedule the next one */ 145 /* and schedule the next one */

cvs diff -r1.8 -r1.9 src/games/trek/externs.c (expand / switch to unified diff)

--- src/games/trek/externs.c 2003/08/07 09:37:51 1.8
+++ src/games/trek/externs.c 2009/05/24 20:39:43 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: externs.c,v 1.8 2003/08/07 09:37:51 agc Exp $ */ 1/* $NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,31 +24,31 @@ @@ -24,31 +24,31 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: externs.c,v 1.8 2003/08/07 09:37:51 agc Exp $"); 37__RCSID("$NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41# include "trek.h" 41#include "trek.h"
42 42
43/* 43/*
44** global variable definitions 44** global variable definitions
45*/ 45*/
46 46
47const struct device Device[NDEV] = 47const struct device Device[NDEV] =
48{ 48{
49 { "warp drive", "Scotty" }, 49 { "warp drive", "Scotty" },
50 { "S.R. scanners", "Scotty" }, 50 { "S.R. scanners", "Scotty" },
51 { "L.R. scanners", "Scotty" }, 51 { "L.R. scanners", "Scotty" },
52 { "phasers", "Sulu" }, 52 { "phasers", "Sulu" },
53 { "photon tubes", "Sulu" }, 53 { "photon tubes", "Sulu" },
54 { "impulse engines", "Scotty" }, 54 { "impulse engines", "Scotty" },

cvs diff -r1.8 -r1.9 src/games/trek/schedule.c (expand / switch to unified diff)

--- src/games/trek/schedule.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/schedule.c 2009/05/24 20:39:43 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: schedule.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: schedule.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <math.h> 42#include <math.h>
43#include <err.h> 43#include <err.h>
44#include <limits.h> 44#include <limits.h>
45#include "trek.h" 45#include "trek.h"
46 46
47/* 47/*
48** SCHEDULE AN EVENT 48** SCHEDULE AN EVENT
49** 49**
50** An event of type 'type' is scheduled for time NOW + 'offset' 50** An event of type 'type' is scheduled for time NOW + 'offset'
@@ -58,31 +58,31 @@ struct event * @@ -58,31 +58,31 @@ struct event *
58schedule(int type, double offset, int x, int y, int z) 58schedule(int type, double offset, int x, int y, int z)
59{ 59{
60 struct event *e; 60 struct event *e;
61 int i; 61 int i;
62 double date; 62 double date;
63 63
64 date = Now.date + offset; 64 date = Now.date + offset;
65 for (i = 0; i < MAXEVENTS; i++) 65 for (i = 0; i < MAXEVENTS; i++)
66 { 66 {
67 e = &Event[i]; 67 e = &Event[i];
68 if (e->evcode) 68 if (e->evcode)
69 continue; 69 continue;
70 /* got a slot */ 70 /* got a slot */
71# ifdef xTRACE 71#ifdef xTRACE
72 if (Trace) 72 if (Trace)
73 printf("schedule: type %d @ %.2f slot %d parm %d %d %d\n", 73 printf("schedule: type %d @ %.2f slot %d parm %d %d %d\n",
74 type, date, i, x, y, z); 74 type, date, i, x, y, z);
75# endif 75#endif
76 e->evcode = type; 76 e->evcode = type;
77 e->date = date; 77 e->date = date;
78 e->x = x; 78 e->x = x;
79 e->y = y; 79 e->y = y;
80 e->systemname = z; 80 e->systemname = z;
81 Now.eventptr[type & ~E_GHOST] = e; 81 Now.eventptr[type & ~E_GHOST] = e;
82 return (e); 82 return (e);
83 } 83 }
84 errx(1, "Cannot schedule event %d parm %d %d %d", type, x, y, z); 84 errx(1, "Cannot schedule event %d parm %d %d %d", type, x, y, z);
85} 85}
86 86
87 87
88/* 88/*
@@ -92,53 +92,53 @@ schedule(int type, double offset, int x, @@ -92,53 +92,53 @@ schedule(int type, double offset, int x,
92** time plus 'offset'. 92** time plus 'offset'.
93*/ 93*/
94 94
95void 95void
96reschedule(struct event *e1, double offset) 96reschedule(struct event *e1, double offset)
97{ 97{
98 double date; 98 double date;
99 struct event *e; 99 struct event *e;
100 100
101 e = e1; 101 e = e1;
102 102
103 date = Now.date + offset; 103 date = Now.date + offset;
104 e->date = date; 104 e->date = date;
105# ifdef xTRACE 105#ifdef xTRACE
106 if (Trace) 106 if (Trace)
107 printf("reschedule: type %d parm %d %d %d @ %.2f\n", 107 printf("reschedule: type %d parm %d %d %d @ %.2f\n",
108 e->evcode, e->x, e->y, e->systemname, date); 108 e->evcode, e->x, e->y, e->systemname, date);
109# endif 109#endif
110 return; 110 return;
111} 111}
112 112
113 113
114/* 114/*
115** UNSCHEDULE AN EVENT 115** UNSCHEDULE AN EVENT
116** 116**
117** The event at slot 'e' is deleted. 117** The event at slot 'e' is deleted.
118*/ 118*/
119 119
120void 120void
121unschedule(struct event *e1) 121unschedule(struct event *e1)
122{ 122{
123 struct event *e; 123 struct event *e;
124 124
125 e = e1; 125 e = e1;
126 126
127# ifdef xTRACE 127#ifdef xTRACE
128 if (Trace) 128 if (Trace)
129 printf("unschedule: type %d @ %.2f parm %d %d %d\n", 129 printf("unschedule: type %d @ %.2f parm %d %d %d\n",
130 e->evcode, e->date, e->x, e->y, e->systemname); 130 e->evcode, e->date, e->x, e->y, e->systemname);
131# endif 131#endif
132 Now.eventptr[e->evcode & E_EVENT] = 0; 132 Now.eventptr[e->evcode & E_EVENT] = 0;
133 e->date = TOOLARGE; 133 e->date = TOOLARGE;
134 e->evcode = 0; 134 e->evcode = 0;
135 return; 135 return;
136} 136}
137 137
138 138
139/* 139/*
140** Abreviated schedule routine 140** Abreviated schedule routine
141** 141**
142** Parameters are the event index and a factor for the time 142** Parameters are the event index and a factor for the time
143** figure. 143** figure.
144*/ 144*/

cvs diff -r1.6 -r1.7 src/games/trek/damaged.c (expand / switch to unified diff)

--- src/games/trek/damaged.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/damaged.c 2009/05/24 20:39:43 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: damaged.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,31 +24,31 @@ @@ -24,31 +24,31 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: damaged.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41# include "trek.h" 41#include "trek.h"
42 42
43/* DAMAGED -- check for device damaged 43/* DAMAGED -- check for device damaged
44** 44**
45** This is a boolean function which returns non-zero if the 45** This is a boolean function which returns non-zero if the
46** specified device is broken. It does this by checking the 46** specified device is broken. It does this by checking the
47** event list for a "device fix" action on that device. 47** event list for a "device fix" action on that device.
48*/ 48*/
49 49
50int 50int
51damaged(int dev) 51damaged(int dev)
52{ 52{
53 int d; 53 int d;
54 struct event *e; 54 struct event *e;

cvs diff -r1.6 -r1.7 src/games/trek/klmove.c (expand / switch to unified diff)

--- src/games/trek/klmove.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/klmove.c 2009/05/24 20:39:43 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: klmove.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: klmove.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include "trek.h" 42#include "trek.h"
43 43
44/* 44/*
45** Move Klingons Around 45** Move Klingons Around
46** 46**
47** This is a largely incomprehensible block of code that moves 47** This is a largely incomprehensible block of code that moves
48** Klingons around in a quadrant. It was written in a very 48** Klingons around in a quadrant. It was written in a very
49** "program as you go" fashion, and is a prime candidate for 49** "program as you go" fashion, and is a prime candidate for
50** rewriting. 50** rewriting.
@@ -68,30 +68,30 @@ void @@ -68,30 +68,30 @@ void
68klmove(int fl) 68klmove(int fl)
69{ 69{
70 int n; 70 int n;
71 struct kling *k; 71 struct kling *k;
72 double dx, dy; 72 double dx, dy;
73 int nextx, nexty; 73 int nextx, nexty;
74 int lookx, looky; 74 int lookx, looky;
75 int motion; 75 int motion;
76 int fudgex, fudgey; 76 int fudgex, fudgey;
77 int qx, qy; 77 int qx, qy;
78 double bigger; 78 double bigger;
79 int i; 79 int i;
80 80
81# ifdef xTRACE 81#ifdef xTRACE
82 if (Trace) 82 if (Trace)
83 printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling); 83 printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling);
84# endif 84#endif
85 for (n = 0; n < Etc.nkling; n++) 85 for (n = 0; n < Etc.nkling; n++)
86 { 86 {
87 k = &Etc.klingon[n]; 87 k = &Etc.klingon[n];
88 i = 100; 88 i = 100;
89 if (fl) 89 if (fl)
90 i = 100.0 * k->power / Param.klingpwr; 90 i = 100.0 * k->power / Param.klingpwr;
91 if (ranf(i) >= Param.moveprob[2 * Move.newquad + fl]) 91 if (ranf(i) >= Param.moveprob[2 * Move.newquad + fl])
92 continue; 92 continue;
93 /* compute distance to move */ 93 /* compute distance to move */
94 motion = ranf(75) - 25; 94 motion = ranf(75) - 25;
95 motion *= k->avgdist * Param.movefac[2 * Move.newquad + fl]; 95 motion *= k->avgdist * Param.movefac[2 * Move.newquad + fl];
96 /* compute direction */ 96 /* compute direction */
97 dx = Ship.sectx - k->x + ranf(3) - 1; 97 dx = Ship.sectx - k->x + ranf(3) - 1;

cvs diff -r1.12 -r1.13 src/games/trek/dumpgame.c (expand / switch to unified diff)

--- src/games/trek/dumpgame.c 2009/05/24 19:18:44 1.12
+++ src/games/trek/dumpgame.c 2009/05/24 20:39:43 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dumpgame.c,v 1.12 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,38 +24,38 @@ @@ -24,38 +24,38 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: dumpgame.c,v 1.12 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <err.h> 42#include <err.h>
43#include <unistd.h> 43#include <unistd.h>
44#include <fcntl.h> 44#include <fcntl.h>
45#include "trek.h" 45#include "trek.h"
46 46
47/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/ 47/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/
48# define VERSION 2 48#define VERSION 2
49 49
50struct dump 50struct dump
51{ 51{
52 char *area; 52 char *area;
53 int count; 53 int count;
54}; 54};
55 55
56static int readdump(int); 56static int readdump(int);
57 57
58 58
59struct dump Dump_template[] = 59struct dump Dump_template[] =
60{ 60{
61 { (char *)&Ship, sizeof (Ship) }, 61 { (char *)&Ship, sizeof (Ship) },

cvs diff -r1.12 -r1.13 src/games/trek/trek.h (expand / switch to unified diff)

--- src/games/trek/trek.h 2009/03/31 18:48:16 1.12
+++ src/games/trek/trek.h 2009/05/24 20:39:43 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: trek.h,v 1.12 2009/03/31 18:48:16 christos Exp $ */ 1/* $NetBSD: trek.h,v 1.13 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -38,176 +38,176 @@ @@ -38,176 +38,176 @@
38** file. Exceptions are those things which are initialized, which 38** file. Exceptions are those things which are initialized, which
39** are defined in "externs.c", and things which are local to one 39** are defined in "externs.c", and things which are local to one
40** program file. 40** program file.
41** 41**
42** So far as I know, nothing in here must be preinitialized to 42** So far as I know, nothing in here must be preinitialized to
43** zero. 43** zero.
44*/ 44*/
45 45
46/* external function definitions */ 46/* external function definitions */
47 47
48/********************* GALAXY **************************/ 48/********************* GALAXY **************************/
49 49
50/* galactic parameters */ 50/* galactic parameters */
51# define NSECTS 10 /* dimensions of quadrant in sectors */ 51#define NSECTS 10 /* dimensions of quadrant in sectors */
52# define NQUADS 8 /* dimension of galazy in quadrants */ 52#define NQUADS 8 /* dimension of galazy in quadrants */
53# define NINHAB 32 /* number of quadrants which are inhabited */ 53#define NINHAB 32 /* number of quadrants which are inhabited */
54 54
55struct quad /* definition for each quadrant */ 55struct quad /* definition for each quadrant */
56{ 56{
57 unsigned char bases; /* number of bases in this quadrant */ 57 unsigned char bases; /* number of bases in this quadrant */
58 char klings; /* number of Klingons in this quadrant */ 58 char klings; /* number of Klingons in this quadrant */
59 char holes; /* number of black holes in this quadrant */ 59 char holes; /* number of black holes in this quadrant */
60 int scanned; /* star chart entry (see below) */ 60 int scanned; /* star chart entry (see below) */
61 short stars; /* number of stars in this quadrant */ 61 short stars; /* number of stars in this quadrant */
62 char qsystemname; /* starsystem name (see below) */ 62 char qsystemname; /* starsystem name (see below) */
63}; 63};
64 64
65# define Q_DISTRESSED 0200 65#define Q_DISTRESSED 0200
66# define Q_SYSTEM 077 66#define Q_SYSTEM 077
67 67
68/* systemname conventions: 68/* systemname conventions:
69 * 1 -> NINHAB index into Systemname table for live system. 69 * 1 -> NINHAB index into Systemname table for live system.
70 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM 70 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
71 * is the index into the Event table which will 71 * is the index into the Event table which will
72 * have the system name 72 * have the system name
73 * 0 dead or nonexistent starsystem 73 * 0 dead or nonexistent starsystem
74 * 74 *
75 * starchart ("scanned") conventions: 75 * starchart ("scanned") conventions:
76 * 0 -> 999 taken as is 76 * 0 -> 999 taken as is
77 * -1 not yet scanned ("...") 77 * -1 not yet scanned ("...")
78 * 1000 supernova ("///") 78 * 1000 supernova ("///")
79 * 1001 starbase + ??? (".1.") 79 * 1001 starbase + ??? (".1.")
80*/ 80*/
81 81
82/* ascii names of systems */ 82/* ascii names of systems */
83extern const char *const Systemname[NINHAB]; 83extern const char *const Systemname[NINHAB];
84 84
85/* quadrant definition */ 85/* quadrant definition */
86extern struct quad Quad[NQUADS][NQUADS]; 86extern struct quad Quad[NQUADS][NQUADS];
87 87
88/* defines for sector map (below) */ 88/* defines for sector map (below) */
89# define EMPTY '.' 89#define EMPTY '.'
90# define STAR '*' 90#define STAR '*'
91# define BASE '#' 91#define BASE '#'
92# define ENTERPRISE 'E' 92#define ENTERPRISE 'E'
93# define QUEENE 'Q' 93#define QUEENE 'Q'
94# define KLINGON 'K' 94#define KLINGON 'K'
95# define INHABIT '@' 95#define INHABIT '@'
96# define HOLE ' ' 96#define HOLE ' '
97 97
98/* current sector map */ 98/* current sector map */
99extern char Sect[NSECTS][NSECTS]; 99extern char Sect[NSECTS][NSECTS];
100 100
101 101
102 102
103/************************ DEVICES ******************************/ 103/************************ DEVICES ******************************/
104 104
105# define NDEV 16 /* max number of devices */ 105#define NDEV 16 /* max number of devices */
106 106
107/* device tokens */ 107/* device tokens */
108# define WARP 0 /* warp engines */ 108#define WARP 0 /* warp engines */
109# define SRSCAN 1 /* short range scanners */ 109#define SRSCAN 1 /* short range scanners */
110# define LRSCAN 2 /* long range scanners */ 110#define LRSCAN 2 /* long range scanners */
111# define PHASER 3 /* phaser control */ 111#define PHASER 3 /* phaser control */
112# define TORPED 4 /* photon torpedo control */ 112#define TORPED 4 /* photon torpedo control */
113# define IMPULSE 5 /* impulse engines */ 113#define IMPULSE 5 /* impulse engines */
114# define SHIELD 6 /* shield control */ 114#define SHIELD 6 /* shield control */
115# define COMPUTER 7 /* on board computer */ 115#define COMPUTER 7 /* on board computer */
116# define SSRADIO 8 /* subspace radio */ 116#define SSRADIO 8 /* subspace radio */
117# define LIFESUP 9 /* life support systems */ 117#define LIFESUP 9 /* life support systems */
118# define SINS 10 /* Space Inertial Navigation System */ 118#define SINS 10 /* Space Inertial Navigation System */
119# define CLOAK 11 /* cloaking device */ 119#define CLOAK 11 /* cloaking device */
120# define XPORTER 12 /* transporter */ 120#define XPORTER 12 /* transporter */
121# define SHUTTLE 13 /* shuttlecraft */ 121#define SHUTTLE 13 /* shuttlecraft */
122 122
123/* device names */ 123/* device names */
124struct device 124struct device
125{ 125{
126 const char *name; /* device name */ 126 const char *name; /* device name */
127 const char *person; /* the person who fixes it */ 127 const char *person; /* the person who fixes it */
128}; 128};
129 129
130extern const struct device Device[NDEV]; 130extern const struct device Device[NDEV];
131 131
132/*************************** EVENTS ****************************/ 132/*************************** EVENTS ****************************/
133 133
134# define NEVENTS 12 /* number of different event types */ 134#define NEVENTS 12 /* number of different event types */
135 135
136# define E_LRTB 1 /* long range tractor beam */ 136#define E_LRTB 1 /* long range tractor beam */
137# define E_KATSB 2 /* Klingon attacks starbase */ 137#define E_KATSB 2 /* Klingon attacks starbase */
138# define E_KDESB 3 /* Klingon destroys starbase */ 138#define E_KDESB 3 /* Klingon destroys starbase */
139# define E_ISSUE 4 /* distress call is issued */ 139#define E_ISSUE 4 /* distress call is issued */
140# define E_ENSLV 5 /* Klingons enslave a quadrant */ 140#define E_ENSLV 5 /* Klingons enslave a quadrant */
141# define E_REPRO 6 /* a Klingon is reproduced */ 141#define E_REPRO 6 /* a Klingon is reproduced */
142# define E_FIXDV 7 /* fix a device */ 142#define E_FIXDV 7 /* fix a device */
143# define E_ATTACK 8 /* Klingon attack during rest period */ 143#define E_ATTACK 8 /* Klingon attack during rest period */
144# define E_SNAP 9 /* take a snapshot for time warp */ 144#define E_SNAP 9 /* take a snapshot for time warp */
145# define E_SNOVA 10 /* supernova occurs */ 145#define E_SNOVA 10 /* supernova occurs */
146 146
147# define E_GHOST 0100 /* ghost of a distress call if ssradio out */ 147#define E_GHOST 0100 /* ghost of a distress call if ssradio out */
148# define E_HIDDEN 0200 /* event that is unreportable because ssradio out */ 148#define E_HIDDEN 0200 /* event unreportable because ssradio out */
149# define E_EVENT 077 /* mask to get event code */ 149#define E_EVENT 077 /* mask to get event code */
150 150
151struct event 151struct event
152{ 152{
153 unsigned char x, y; /* coordinates */ 153 unsigned char x, y; /* coordinates */
154 double date; /* trap stardate */ 154 double date; /* trap stardate */
155 char evcode; /* event type */ 155 char evcode; /* event type */
156 unsigned char systemname; /* starsystem name */ 156 unsigned char systemname; /* starsystem name */
157}; 157};
158/* systemname conventions: 158/* systemname conventions:
159 * 1 -> NINHAB index into Systemname table for reported distress calls 159 * 1 -> NINHAB index into Systemname table for reported distress calls
160 * 160 *
161 * evcode conventions: 161 * evcode conventions:
162 * 1 -> NEVENTS-1 event type 162 * 1 -> NEVENTS-1 event type
163 * + E_HIDDEN unreported (SSradio out) 163 * + E_HIDDEN unreported (SSradio out)
164 * + E_GHOST actually already expired 164 * + E_GHOST actually already expired
165 * 0 unallocated 165 * 0 unallocated
166 */ 166 */
167 167
168# define MAXEVENTS 25 /* max number of concurrently pending events */ 168#define MAXEVENTS 25 /* max number of concurrently pending events */
169 169
170extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ 170extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
171 171
172/***************************** KLINGONS *******************************/ 172/***************************** KLINGONS *******************************/
173 173
174struct kling 174struct kling
175{ 175{
176 unsigned char x, y; /* coordinates */ 176 unsigned char x, y; /* coordinates */
177 int power; /* power left */ 177 int power; /* power left */
178 double dist; /* distance to Enterprise */ 178 double dist; /* distance to Enterprise */
179 double avgdist; /* average over this move */ 179 double avgdist; /* average over this move */
180 char srndreq; /* set if surrender has been requested */ 180 char srndreq; /* set if surrender has been requested */
181}; 181};
182 182
183# define MAXKLQUAD 9 /* maximum klingons per quadrant */ 183#define MAXKLQUAD 9 /* maximum klingons per quadrant */
184 184
185/********************** MISCELLANEOUS ***************************/ 185/********************** MISCELLANEOUS ***************************/
186 186
187/* condition codes */ 187/* condition codes */
188# define GREEN 0 188#define GREEN 0
189# define DOCKED 1 189#define DOCKED 1
190# define YELLOW 2 190#define YELLOW 2
191# define RED 3 191#define RED 3
192 192
193/* starbase coordinates */ 193/* starbase coordinates */
194# define MAXBASES 9 /* maximum number of starbases in galaxy */ 194#define MAXBASES 9 /* maximum number of starbases in galaxy */
195 195
196/* distress calls */ 196/* distress calls */
197# define MAXDISTR 5 /* maximum concurrent distress calls */ 197#define MAXDISTR 5 /* maximum concurrent distress calls */
198 198
199/* phaser banks */ 199/* phaser banks */
200# define NBANKS 6 /* number of phaser banks */ 200#define NBANKS 6 /* number of phaser banks */
201 201
202struct xy 202struct xy
203{ 203{
204 unsigned char x, y; /* coordinates */ 204 unsigned char x, y; /* coordinates */
205}; 205};
206 206
207 207
208/* 208/*
209 * note that much of the stuff in the following structs CAN NOT 209 * note that much of the stuff in the following structs CAN NOT
210 * be moved around!!!! 210 * be moved around!!!!
211 */ 211 */
212 212
213 213
@@ -332,55 +332,55 @@ struct Etc_struct @@ -332,55 +332,55 @@ struct Etc_struct
332 char fast; /* set if speed > 300 baud */ 332 char fast; /* set if speed > 300 baud */
333 struct xy starbase; /* starbase in current quadrant */ 333 struct xy starbase; /* starbase in current quadrant */
334 char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */ 334 char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */
335 char statreport; /* set to get a status report on a srscan */ 335 char statreport; /* set to get a status report on a srscan */
336}; 336};
337extern struct Etc_struct Etc; 337extern struct Etc_struct Etc;
338 338
339/* 339/*
340 * eventptr is a pointer to the event[] entry of the last 340 * eventptr is a pointer to the event[] entry of the last
341 * scheduled event of each type. Zero if no such event scheduled. 341 * scheduled event of each type. Zero if no such event scheduled.
342 */ 342 */
343 343
344/* Klingon move indicies */ 344/* Klingon move indicies */
345# define KM_OB 0 /* Old quadrant, Before attack */ 345#define KM_OB 0 /* Old quadrant, Before attack */
346# define KM_OA 1 /* Old quadrant, After attack */ 346#define KM_OA 1 /* Old quadrant, After attack */
347# define KM_EB 2 /* Enter quadrant, Before attack */ 347#define KM_EB 2 /* Enter quadrant, Before attack */
348# define KM_EA 3 /* Enter quadrant, After attack */ 348#define KM_EA 3 /* Enter quadrant, After attack */
349# define KM_LB 4 /* Leave quadrant, Before attack */ 349#define KM_LB 4 /* Leave quadrant, Before attack */
350# define KM_LA 5 /* Leave quadrant, After attack */ 350#define KM_LA 5 /* Leave quadrant, After attack */
351 351
352/* you lose codes */ 352/* you lose codes */
353# define L_NOTIME 1 /* ran out of time */ 353#define L_NOTIME 1 /* ran out of time */
354# define L_NOENGY 2 /* ran out of energy */ 354#define L_NOENGY 2 /* ran out of energy */
355# define L_DSTRYD 3 /* destroyed by a Klingon */ 355#define L_DSTRYD 3 /* destroyed by a Klingon */
356# define L_NEGENB 4 /* ran into the negative energy barrier */ 356#define L_NEGENB 4 /* ran into the negative energy barrier */
357# define L_SUICID 5 /* destroyed in a nova */ 357#define L_SUICID 5 /* destroyed in a nova */
358# define L_SNOVA 6 /* destroyed in a supernova */ 358#define L_SNOVA 6 /* destroyed in a supernova */
359# define L_NOLIFE 7 /* life support died (so did you) */ 359#define L_NOLIFE 7 /* life support died (so did you) */
360# define L_NOHELP 8 /* you could not be rematerialized */ 360#define L_NOHELP 8 /* you could not be rematerialized */
361# define L_TOOFAST 9 /* pretty stupid going at warp 10 */ 361#define L_TOOFAST 9 /* pretty stupid going at warp 10 */
362# define L_STAR 10 /* ran into a star */ 362#define L_STAR 10 /* ran into a star */
363# define L_DSTRCT 11 /* self destructed */ 363#define L_DSTRCT 11 /* self destructed */
364# define L_CAPTURED 12 /* captured by Klingons */ 364#define L_CAPTURED 12 /* captured by Klingons */
365# define L_NOCREW 13 /* you ran out of crew */ 365#define L_NOCREW 13 /* you ran out of crew */
366 366
367/****************** COMPILE OPTIONS ***********************/ 367/****************** COMPILE OPTIONS ***********************/
368 368
369/* Trace info */ 369/* Trace info */
370# define xTRACE 1 370#define xTRACE 1
371extern int Trace; 371extern int Trace;
372 372
373# define TOOLARGE (DBL_MAX / 2) /* < DOUBLE_MAX for everyone */ 373#define TOOLARGE (DBL_MAX / 2) /* < DOUBLE_MAX for everyone */
374 374
375/* abandon.c */ 375/* abandon.c */
376void abandon(int); 376void abandon(int);
377 377
378/* attack.c */ 378/* attack.c */
379void attack(int); 379void attack(int);
380 380
381/* autover.c */ 381/* autover.c */
382void autover(void); 382void autover(void);
383 383
384/* capture.c */ 384/* capture.c */
385void capture(int); 385void capture(int);
386struct kling *selectklingon(void); 386struct kling *selectklingon(void);

cvs diff -r1.14 -r1.15 src/games/trek/main.c (expand / switch to unified diff)

--- src/games/trek/main.c 2009/05/24 19:18:44 1.14
+++ src/games/trek/main.c 2009/05/24 20:39:43 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.14 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,42 +29,42 @@ @@ -29,42 +29,42 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1980, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1980, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; 40static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
41#else 41#else
42__RCSID("$NetBSD: main.c,v 1.14 2009/05/24 19:18:44 dholland Exp $"); 42__RCSID("$NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <stdio.h> 46#include <stdio.h>
47#include <setjmp.h> 47#include <setjmp.h>
48#include <termios.h> 48#include <termios.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <unistd.h> 50#include <unistd.h>
51#include <err.h> 51#include <err.h>
52#include <time.h> 52#include <time.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include "trek.h" 54#include "trek.h"
55#include "getpar.h" 55#include "getpar.h"
56 56
57# define PRIO 00 /* default priority */ 57#define PRIO 00 /* default priority */
58 58
59uid_t Mother = 51 + (51 << 8); 59uid_t Mother = 51 + (51 << 8);
60 60
61/* 61/*
62** #### ##### # #### ##### #### ##### # # 62** #### ##### # #### ##### #### ##### # #
63** # # # # # # # # # # # # 63** # # # # # # # # # # # #
64** ### # ##### #### # #### ### ### 64** ### # ##### #### # #### ### ###
65** # # # # # # # # # # # # 65** # # # # # # # # # # # #
66** #### # # # # # # # # ##### # # 66** #### # # # # # # # # ##### # #
67** 67**
68** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help 68** C version by Eric P. Allman 5/76 (U.C. Berkeley) with help
69** from Jeff Poskanzer and Pete Rubinstein. 69** from Jeff Poskanzer and Pete Rubinstein.
70** 70**
@@ -194,33 +194,33 @@ main(int argc, char **argv) @@ -194,33 +194,33 @@ main(int argc, char **argv)
194 { 194 {
195 case 'a': /* append to log file */ 195 case 'a': /* append to log file */
196 opencode = 'a'; 196 opencode = 'a';
197 break; 197 break;
198 198
199 case 'f': /* set fast mode */ 199 case 'f': /* set fast mode */
200 Etc.fast++; 200 Etc.fast++;
201 break; 201 break;
202 202
203 case 's': /* set slow mode */ 203 case 's': /* set slow mode */
204 Etc.fast = 0; 204 Etc.fast = 0;
205 break; 205 break;
206 206
207# ifdef xTRACE 207#ifdef xTRACE
208 case 't': /* trace */ 208 case 't': /* trace */
209 if (getuid() != Mother) 209 if (getuid() != Mother)
210 goto badflag; 210 goto badflag;
211 Trace++; 211 Trace++;
212 break; 212 break;
213# endif 213#endif
214 214
215 case 'p': /* set priority */ 215 case 'p': /* set priority */
216 if (getuid() != Mother) 216 if (getuid() != Mother)
217 goto badflag; 217 goto badflag;
218 prio = atoi(av[0] + 2); 218 prio = atoi(av[0] + 2);
219 break; 219 break;
220 220
221 default: 221 default:
222 badflag: 222 badflag:
223 printf("Invalid option: %s\n", av[0]); 223 printf("Invalid option: %s\n", av[0]);
224 224
225 } 225 }
226 ac--; 226 ac--;

cvs diff -r1.7 -r1.8 src/games/trek/move.c (expand / switch to unified diff)

--- src/games/trek/move.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/move.c 2009/05/24 20:39:43 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: move.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: move.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <math.h> 42#include <math.h>
43#include "trek.h" 43#include "trek.h"
44 44
45/* 45/*
46** Move Under Warp or Impulse Power 46** Move Under Warp or Impulse Power
47** 47**
48** `Ramflag' is set if we are to be allowed to ram stars, 48** `Ramflag' is set if we are to be allowed to ram stars,
49** Klingons, etc. This is passed from warp(), which gets it from 49** Klingons, etc. This is passed from warp(), which gets it from
50** either play() or ram(). Course is the course (0 -> 360) at 50** either play() or ram(). Course is the course (0 -> 360) at
@@ -81,104 +81,104 @@ double @@ -81,104 +81,104 @@ double
81move(int ramflag, int course, double time, double speed) 81move(int ramflag, int course, double time, double speed)
82{ 82{
83 double angle; 83 double angle;
84 double x, y, dx, dy; 84 double x, y, dx, dy;
85 int ix = 0, iy = 0; 85 int ix = 0, iy = 0;
86 double bigger; 86 double bigger;
87 int n; 87 int n;
88 int i; 88 int i;
89 double dist; 89 double dist;
90 double sectsize; 90 double sectsize;
91 double xn; 91 double xn;
92 double evtime; 92 double evtime;
93 93
94# ifdef xTRACE 94#ifdef xTRACE
95 if (Trace) 95 if (Trace)
96 printf("move: ramflag %d course %d time %.2f speed %.2f\n", 96 printf("move: ramflag %d course %d time %.2f speed %.2f\n",
97 ramflag, course, time, speed); 97 ramflag, course, time, speed);
98# endif 98#endif
99 sectsize = NSECTS; 99 sectsize = NSECTS;
100 /* initialize delta factors for move */ 100 /* initialize delta factors for move */
101 angle = course * 0.0174532925; 101 angle = course * 0.0174532925;
102 if (damaged(SINS)) 102 if (damaged(SINS))
103 angle += Param.navigcrud[1] * (franf() - 0.5); 103 angle += Param.navigcrud[1] * (franf() - 0.5);
104 else 104 else
105 if (Ship.sinsbad) 105 if (Ship.sinsbad)
106 angle += Param.navigcrud[0] * (franf() - 0.5); 106 angle += Param.navigcrud[0] * (franf() - 0.5);
107 dx = -cos(angle); 107 dx = -cos(angle);
108 dy = sin(angle); 108 dy = sin(angle);
109 bigger = fabs(dx); 109 bigger = fabs(dx);
110 dist = fabs(dy); 110 dist = fabs(dy);
111 if (dist > bigger) 111 if (dist > bigger)
112 bigger = dist; 112 bigger = dist;
113 dx /= bigger; 113 dx /= bigger;
114 dy /= bigger; 114 dy /= bigger;
115 115
116 /* check for long range tractor beams */ 116 /* check for long range tractor beams */
117 /**** TEMPORARY CODE == DEBUGGING ****/ 117 /**** TEMPORARY CODE == DEBUGGING ****/
118 evtime = Now.eventptr[E_LRTB]->date - Now.date; 118 evtime = Now.eventptr[E_LRTB]->date - Now.date;
119# ifdef xTRACE 119#ifdef xTRACE
120 if (Trace) 120 if (Trace)
121 printf("E.ep = %p, ->evcode = %d, ->date = %.2f, evtime = %.2f\n", 121 printf("E.ep = %p, ->evcode = %d, ->date = %.2f, evtime = %.2f\n",
122 Now.eventptr[E_LRTB], Now.eventptr[E_LRTB]->evcode, 122 Now.eventptr[E_LRTB], Now.eventptr[E_LRTB]->evcode,
123 Now.eventptr[E_LRTB]->date, evtime); 123 Now.eventptr[E_LRTB]->date, evtime);
124# endif 124#endif
125 if (time > evtime && Etc.nkling < 3) 125 if (time > evtime && Etc.nkling < 3)
126 { 126 {
127 /* then we got a LRTB */ 127 /* then we got a LRTB */
128 evtime += 0.005; 128 evtime += 0.005;
129 time = evtime; 129 time = evtime;
130 } 130 }
131 else 131 else
132 evtime = -1.0e50; 132 evtime = -1.0e50;
133 dist = time * speed; 133 dist = time * speed;
134 134
135 /* move within quadrant */ 135 /* move within quadrant */
136 Sect[Ship.sectx][Ship.secty] = EMPTY; 136 Sect[Ship.sectx][Ship.secty] = EMPTY;
137 x = Ship.sectx + 0.5; 137 x = Ship.sectx + 0.5;
138 y = Ship.secty + 0.5; 138 y = Ship.secty + 0.5;
139 xn = NSECTS * dist * bigger; 139 xn = NSECTS * dist * bigger;
140 n = xn + 0.5; 140 n = xn + 0.5;
141# ifdef xTRACE 141#ifdef xTRACE
142 if (Trace) 142 if (Trace)
143 printf("dx = %.2f, dy = %.2f, xn = %.2f, n = %d\n", dx, dy, xn, n); 143 printf("dx = %.2f, dy = %.2f, xn = %.2f, n = %d\n", dx, dy, xn, n);
144# endif 144#endif
145 Move.free = 0; 145 Move.free = 0;
146 146
147 for (i = 0; i < n; i++) 147 for (i = 0; i < n; i++)
148 { 148 {
149 ix = (x += dx); 149 ix = (x += dx);
150 iy = (y += dy); 150 iy = (y += dy);
151# ifdef xTRACE 151#ifdef xTRACE
152 if (Trace) 152 if (Trace)
153 printf("ix = %d, x = %.2f, iy = %d, y = %.2f\n", ix, x, iy, y); 153 printf("ix = %d, x = %.2f, iy = %d, y = %.2f\n", ix, x, iy, y);
154# endif 154#endif
155 if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize) 155 if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize)
156 { 156 {
157 /* enter new quadrant */ 157 /* enter new quadrant */
158 dx = Ship.quadx * NSECTS + Ship.sectx + dx * xn; 158 dx = Ship.quadx * NSECTS + Ship.sectx + dx * xn;
159 dy = Ship.quady * NSECTS + Ship.secty + dy * xn; 159 dy = Ship.quady * NSECTS + Ship.secty + dy * xn;
160 if (dx < 0.0) 160 if (dx < 0.0)
161 ix = -1; 161 ix = -1;
162 else 162 else
163 ix = dx + 0.5; 163 ix = dx + 0.5;
164 if (dy < 0.0) 164 if (dy < 0.0)
165 iy = -1; 165 iy = -1;
166 else 166 else
167 iy = dy + 0.5; 167 iy = dy + 0.5;
168# ifdef xTRACE 168#ifdef xTRACE
169 if (Trace) 169 if (Trace)
170 printf("New quad: ix = %d, iy = %d\n", ix, iy); 170 printf("New quad: ix = %d, iy = %d\n", ix, iy);
171# endif 171#endif
172 Ship.sectx = x; 172 Ship.sectx = x;
173 Ship.secty = y; 173 Ship.secty = y;
174 compkldist(0); 174 compkldist(0);
175 Move.newquad = 2; 175 Move.newquad = 2;
176 attack(0); 176 attack(0);
177 checkcond(); 177 checkcond();
178 Ship.quadx = ix / NSECTS; 178 Ship.quadx = ix / NSECTS;
179 Ship.quady = iy / NSECTS; 179 Ship.quady = iy / NSECTS;
180 Ship.sectx = ix % NSECTS; 180 Ship.sectx = ix % NSECTS;
181 Ship.secty = iy % NSECTS; 181 Ship.secty = iy % NSECTS;
182 if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 || 182 if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 ||
183 Ship.quady >= NQUADS) { 183 Ship.quady >= NQUADS) {
184 if (!damaged(COMPUTER)) { 184 if (!damaged(COMPUTER)) {

cvs diff -r1.7 -r1.8 src/games/trek/systemname.c (expand / switch to unified diff)

--- src/games/trek/systemname.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/systemname.c 2009/05/24 20:39:43 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: systemname.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: systemname.c,v 1.8 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,31 +24,31 @@ @@ -24,31 +24,31 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)systemname.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)systemname.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: systemname.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: systemname.c,v 1.8 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41# include "trek.h" 41#include "trek.h"
42 42
43/* 43/*
44** RETRIEVE THE STARSYSTEM NAME 44** RETRIEVE THE STARSYSTEM NAME
45** 45**
46** Very straightforward, this routine just gets the starsystem 46** Very straightforward, this routine just gets the starsystem
47** name. It returns zero if none in the specified quadrant 47** name. It returns zero if none in the specified quadrant
48** (which, by the way, is passed it). 48** (which, by the way, is passed it).
49** 49**
50** This routine knows all about such things as distressed 50** This routine knows all about such things as distressed
51** starsystems, etc. 51** starsystems, etc.
52*/ 52*/
53 53
54const char * 54const char *

cvs diff -r1.11 -r1.12 src/games/trek/phaser.c (expand / switch to unified diff)

--- src/games/trek/phaser.c 2009/05/24 19:18:44 1.11
+++ src/games/trek/phaser.c 2009/05/24 20:39:43 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: phaser.c,v 1.11 2009/05/24 19:18:44 dholland Exp $ */ 1/* $NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1993 4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,42 +24,42 @@ @@ -24,42 +24,42 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: phaser.c,v 1.11 2009/05/24 19:18:44 dholland Exp $"); 37__RCSID("$NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <math.h> 42#include <math.h>
43#include "trek.h" 43#include "trek.h"
44#include "getpar.h" 44#include "getpar.h"
45 45
46/* factors for phaser hits; see description below */ 46/* factors for phaser hits; see description below */
47 47
48# define ALPHA 3.0 /* spread */ 48#define ALPHA 3.0 /* spread */
49# define BETA 3.0 /* franf() */ 49#define BETA 3.0 /* franf() */
50# define GAMMA 0.30 /* cos(angle) */ 50#define GAMMA 0.30 /* cos(angle) */
51# define EPSILON 150.0 /* dist ** 2 */ 51#define EPSILON 150.0 /* dist ** 2 */
52# define OMEGA 10.596 /* overall scaling factor */ 52#define OMEGA 10.596 /* overall scaling factor */
53 53
54/* OMEGA ~= 100 * (ALPHA + 1) * (BETA + 1) / (EPSILON + 1) */ 54/* OMEGA ~= 100 * (ALPHA + 1) * (BETA + 1) / (EPSILON + 1) */
55 55
56/* 56/*
57** Phaser Control 57** Phaser Control
58** 58**
59** There are up to NBANKS phaser banks which may be fired 59** There are up to NBANKS phaser banks which may be fired
60** simultaneously. There are two modes, "manual" and 60** simultaneously. There are two modes, "manual" and
61** "automatic". In manual mode, you specify exactly which 61** "automatic". In manual mode, you specify exactly which
62** direction you want each bank to be aimed, the number 62** direction you want each bank to be aimed, the number
63** of units to fire, and the spread angle. In automatic 63** of units to fire, and the spread angle. In automatic
64** mode, you give only the total number of units to fire. 64** mode, you give only the total number of units to fire.
65** 65**
@@ -234,34 +234,34 @@ phaser(int v __unused) @@ -234,34 +234,34 @@ phaser(int v __unused)
234 k = &Etc.klingon[i]; 234 k = &Etc.klingon[i];
235 b = &bank[i]; 235 b = &bank[i];
236 distfactor = k->dist; 236 distfactor = k->dist;
237 anglefactor = ALPHA * BETA * OMEGA / (distfactor * distfactor + EPSILON); 237 anglefactor = ALPHA * BETA * OMEGA / (distfactor * distfactor + EPSILON);
238 anglefactor *= GAMMA; 238 anglefactor *= GAMMA;
239 distfactor = k->power; 239 distfactor = k->power;
240 distfactor /= anglefactor; 240 distfactor /= anglefactor;
241 hitreqd[i] = distfactor + 0.5; 241 hitreqd[i] = distfactor + 0.5;
242 dx = Ship.sectx - k->x; 242 dx = Ship.sectx - k->x;
243 dy = k->y - Ship.secty; 243 dy = k->y - Ship.secty;
244 b->angle = atan2(dy, dx); 244 b->angle = atan2(dy, dx);
245 b->spread = 0.0; 245 b->spread = 0.0;
246 b->units = ((n - i) / tot) * extra; 246 b->units = ((n - i) / tot) * extra;
247# ifdef xTRACE 247#ifdef xTRACE
248 if (Trace) 248 if (Trace)
249 { 249 {
250 printf("b%d hr%d u%d df%.2f af%.2f\n", 250 printf("b%d hr%d u%d df%.2f af%.2f\n",
251 i, hitreqd[i], b->units, 251 i, hitreqd[i], b->units,
252 distfactor, anglefactor); 252 distfactor, anglefactor);
253 } 253 }
254# endif 254#endif
255 extra -= b->units; 255 extra -= b->units;
256 hit = b->units - hitreqd[i]; 256 hit = b->units - hitreqd[i];
257 if (hit > 0) 257 if (hit > 0)
258 { 258 {
259 extra += hit; 259 extra += hit;
260 b->units -= hit; 260 b->units -= hit;
261 } 261 }
262 } 262 }
263 263
264 /* give out any extra energy we might have around */ 264 /* give out any extra energy we might have around */
265 if (extra > 0) 265 if (extra > 0)
266 { 266 {
267 for (i = 0; i < n; i++) 267 for (i = 0; i < n; i++)
@@ -275,40 +275,40 @@ phaser(int v __unused) @@ -275,40 +275,40 @@ phaser(int v __unused)
275 b->units += extra; 275 b->units += extra;
276 extra = 0; 276 extra = 0;
277 break; 277 break;
278 } 278 }
279 b->units = hitreqd[i]; 279 b->units = hitreqd[i];
280 extra -= hit; 280 extra -= hit;
281 } 281 }
282 if (extra > 0) 282 if (extra > 0)
283 printf("%d units overkill\n", extra); 283 printf("%d units overkill\n", extra);
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288# ifdef xTRACE 288#ifdef xTRACE
289 if (Trace) 289 if (Trace)
290 { 290 {
291 for (i = 0; i < NBANKS; i++) 291 for (i = 0; i < NBANKS; i++)
292 { 292 {
293 b = &bank[i]; 293 b = &bank[i];
294 printf("b%d u%d", i, b->units); 294 printf("b%d u%d", i, b->units);
295 if (b->units > 0) 295 if (b->units > 0)
296 printf(" a%.2f s%.2f\n", b->angle, b->spread); 296 printf(" a%.2f s%.2f\n", b->angle, b->spread);
297 else 297 else
298 printf("\n"); 298 printf("\n");
299 } 299 }
300 } 300 }
301# endif 301#endif
302 302
303 /* actually fire the shots */ 303 /* actually fire the shots */
304 Move.free = 0; 304 Move.free = 0;
305 for (i = 0; i < NBANKS; i++) 305 for (i = 0; i < NBANKS; i++)
306 { 306 {
307 b = &bank[i]; 307 b = &bank[i];
308 if (b->units <= 0) 308 if (b->units <= 0)
309 { 309 {
310 continue; 310 continue;
311 } 311 }
312 printf("\nPhaser bank %d fires:\n", i); 312 printf("\nPhaser bank %d fires:\n", i);
313 n = Etc.nkling; 313 n = Etc.nkling;
314 k = Etc.klingon; 314 k = Etc.klingon;