KNF: brace and comment placement. Object files identical.diff -r1.8 -r1.9 src/games/trek/abandon.c
(dholland)
--- src/games/trek/abandon.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/abandon.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: abandon.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: abandon.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: abandon.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: abandon.c,v 1.9 2009/05/24 21:44:56 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 | ** Abandon Ship | 45 | ** Abandon Ship | |
46 | ** | 46 | ** | |
47 | ** The ship is abandoned. If your current ship is the Faire | 47 | ** The ship is abandoned. If your current ship is the Faire | |
48 | ** Queene, or if your shuttlecraft is dead, you're out of | 48 | ** Queene, or if your shuttlecraft is dead, you're out of | |
49 | ** luck. You need the shuttlecraft in order for the captain | 49 | ** luck. You need the shuttlecraft in order for the captain | |
50 | ** (that's you!!) to escape. | 50 | ** (that's you!!) to escape. | |
@@ -69,99 +69,89 @@ __RCSID("$NetBSD: abandon.c,v 1.8 2009/0 | @@ -69,99 +69,89 @@ __RCSID("$NetBSD: abandon.c,v 1.8 2009/0 | |||
69 | /*ARGSUSED*/ | 69 | /*ARGSUSED*/ | |
70 | void | 70 | void | |
71 | abandon(int v __unused) | 71 | abandon(int v __unused) | |
72 | { | 72 | { | |
73 | struct quad *q; | 73 | struct quad *q; | |
74 | int i; | 74 | int i; | |
75 | int j; | 75 | int j; | |
76 | struct event *e; | 76 | struct event *e; | |
77 | 77 | |||
78 | if (Ship.ship == QUEENE) { | 78 | if (Ship.ship == QUEENE) { | |
79 | printf("You may not abandon ye Faire Queene\n"); | 79 | printf("You may not abandon ye Faire Queene\n"); | |
80 | return; | 80 | return; | |
81 | } | 81 | } | |
82 | if (Ship.cond != DOCKED) | 82 | if (Ship.cond != DOCKED) { | |
83 | { | |||
84 | if (damaged(SHUTTLE)) { | 83 | if (damaged(SHUTTLE)) { | |
85 | out(SHUTTLE); | 84 | out(SHUTTLE); | |
86 | return; | 85 | return; | |
87 | } | 86 | } | |
88 | printf("Officers escape in shuttlecraft\n"); | 87 | printf("Officers escape in shuttlecraft\n"); | |
89 | /* decide on fate of crew */ | 88 | /* decide on fate of crew */ | |
90 | q = &Quad[Ship.quadx][Ship.quady]; | 89 | q = &Quad[Ship.quadx][Ship.quady]; | |
91 | if (q->qsystemname == 0 || damaged(XPORTER)) | 90 | if (q->qsystemname == 0 || damaged(XPORTER)) { | |
92 | { | |||
93 | printf("Entire crew of %d left to die in outer space\n", | 91 | printf("Entire crew of %d left to die in outer space\n", | |
94 | Ship.crew); | 92 | Ship.crew); | |
95 | Game.deaths += Ship.crew; | 93 | Game.deaths += Ship.crew; | |
96 | } | 94 | } else { | |
97 | else | |||
98 | { | |||
99 | printf("Crew beams down to planet %s\n", systemname(q)); | 95 | printf("Crew beams down to planet %s\n", systemname(q)); | |
100 | } | 96 | } | |
101 | } | 97 | } | |
102 | /* see if you can be exchanged */ | 98 | /* see if you can be exchanged */ | |
103 | if (Now.bases == 0 || Game.captives < 20 * Game.skill) | 99 | if (Now.bases == 0 || Game.captives < 20 * Game.skill) | |
104 | lose(L_CAPTURED); | 100 | lose(L_CAPTURED); | |
105 | /* re-outfit new ship */ | 101 | /* re-outfit new ship */ | |
106 | printf("You are hereby put in charge of an antiquated but still\n"); | 102 | printf("You are hereby put in charge of an antiquated but still\n"); | |
107 | printf(" functional ship, the Fairie Queene.\n"); | 103 | printf(" functional ship, the Fairie Queene.\n"); | |
108 | Ship.ship = QUEENE; | 104 | Ship.ship = QUEENE; | |
109 | Ship.shipname = "Fairie Queene"; | 105 | Ship.shipname = "Fairie Queene"; | |
110 | Param.energy = Ship.energy = 3000; | 106 | Param.energy = Ship.energy = 3000; | |
111 | Param.torped = Ship.torped = 6; | 107 | Param.torped = Ship.torped = 6; | |
112 | Param.shield = Ship.shield = 1250; | 108 | Param.shield = Ship.shield = 1250; | |
113 | Ship.shldup = 0; | 109 | Ship.shldup = 0; | |
114 | Ship.cloaked = 0; | 110 | Ship.cloaked = 0; | |
115 | Ship.warp = 5.0; | 111 | Ship.warp = 5.0; | |
116 | Ship.warp2 = 25.0; | 112 | Ship.warp2 = 25.0; | |
117 | Ship.warp3 = 125.0; | 113 | Ship.warp3 = 125.0; | |
118 | Ship.cond = GREEN; | 114 | Ship.cond = GREEN; | |
119 | /* clear out damages on old ship */ | 115 | /* clear out damages on old ship */ | |
120 | for (i = 0; i < MAXEVENTS; i++) | 116 | for (i = 0; i < MAXEVENTS; i++) { | |
121 | { | |||
122 | e = &Event[i]; | 117 | e = &Event[i]; | |
123 | if (e->evcode != E_FIXDV) | 118 | if (e->evcode != E_FIXDV) | |
124 | continue; | 119 | continue; | |
125 | unschedule(e); | 120 | unschedule(e); | |
126 | } | 121 | } | |
127 | /* get rid of some devices and redistribute probabilities */ | 122 | /* get rid of some devices and redistribute probabilities */ | |
128 | i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK]; | 123 | i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK]; | |
129 | Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0; | 124 | Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0; | |
130 | while (i > 0) | 125 | while (i > 0) | |
131 | for (j = 0; j < NDEV; j++) | 126 | for (j = 0; j < NDEV; j++) { | |
132 | { | 127 | if (Param.damprob[j] != 0) { | |
133 | if (Param.damprob[j] != 0) | |||
134 | { | |||
135 | Param.damprob[j] += 1; | 128 | Param.damprob[j] += 1; | |
136 | i--; | 129 | i--; | |
137 | if (i <= 0) | 130 | if (i <= 0) | |
138 | break; | 131 | break; | |
139 | } | 132 | } | |
140 | } | 133 | } | |
141 | /* pick a starbase to restart at */ | 134 | /* pick a starbase to restart at */ | |
142 | i = ranf(Now.bases); | 135 | i = ranf(Now.bases); | |
143 | Ship.quadx = Now.base[i].x; | 136 | Ship.quadx = Now.base[i].x; | |
144 | Ship.quady = Now.base[i].y; | 137 | Ship.quady = Now.base[i].y; | |
145 | /* setup that quadrant */ | 138 | /* setup that quadrant */ | |
146 | while (1) | 139 | while (1) { | |
147 | { | |||
148 | initquad(1); | 140 | initquad(1); | |
149 | Sect[Ship.sectx][Ship.secty] = EMPTY; | 141 | Sect[Ship.sectx][Ship.secty] = EMPTY; | |
150 | for (i = 0; i < 5; i++) | 142 | for (i = 0; i < 5; i++) { | |
151 | { | |||
152 | Ship.sectx = Etc.starbase.x + ranf(3) - 1; | 143 | Ship.sectx = Etc.starbase.x + ranf(3) - 1; | |
153 | if (Ship.sectx < 0 || Ship.sectx >= NSECTS) | 144 | if (Ship.sectx < 0 || Ship.sectx >= NSECTS) | |
154 | continue; | 145 | continue; | |
155 | Ship.secty = Etc.starbase.y + ranf(3) - 1; | 146 | Ship.secty = Etc.starbase.y + ranf(3) - 1; | |
156 | if (Ship.secty < 0 || Ship.secty >= NSECTS) | 147 | if (Ship.secty < 0 || Ship.secty >= NSECTS) | |
157 | continue; | 148 | continue; | |
158 | if (Sect[Ship.sectx][Ship.secty] == EMPTY) | 149 | if (Sect[Ship.sectx][Ship.secty] == EMPTY) { | |
159 | { | |||
160 | Sect[Ship.sectx][Ship.secty] = QUEENE; | 150 | Sect[Ship.sectx][Ship.secty] = QUEENE; | |
161 | dock(0); | 151 | dock(0); | |
162 | compkldist(0); | 152 | compkldist(0); | |
163 | return; | 153 | return; | |
164 | } | 154 | } | |
165 | } | 155 | } | |
166 | } | 156 | } | |
167 | } | 157 | } |
--- src/games/trek/dcrept.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/dcrept.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dcrept.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: dcrept.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: dcrept.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: dcrept.c,v 1.9 2009/05/24 21:44:56 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 | ** damage control report | 45 | ** damage control report | |
46 | ** | 46 | ** | |
47 | ** Print damages and time to fix. This is taken from the event | 47 | ** Print damages and time to fix. This is taken from the event | |
48 | ** list. A couple of factors are set up, based on whether or not | 48 | ** list. A couple of factors are set up, based on whether or not | |
49 | ** we are docked. (One of these factors will always be 1.0.) | 49 | ** we are docked. (One of these factors will always be 1.0.) | |
50 | ** The event list is then scanned for damage fix events, the | 50 | ** The event list is then scanned for damage fix events, the | |
@@ -53,49 +53,44 @@ __RCSID("$NetBSD: dcrept.c,v 1.8 2009/05 | @@ -53,49 +53,44 @@ __RCSID("$NetBSD: dcrept.c,v 1.8 2009/05 | |||
53 | ** fix things if you are docked. | 53 | ** fix things if you are docked. | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /*ARGSUSED*/ | 56 | /*ARGSUSED*/ | |
57 | void | 57 | void | |
58 | dcrept(int v __unused) | 58 | dcrept(int v __unused) | |
59 | { | 59 | { | |
60 | int i, f; | 60 | int i, f; | |
61 | double x; | 61 | double x; | |
62 | double m1, m2; | 62 | double m1, m2; | |
63 | struct event *e; | 63 | struct event *e; | |
64 | 64 | |||
65 | /* set up the magic factors to output the time till fixed */ | 65 | /* set up the magic factors to output the time till fixed */ | |
66 | if (Ship.cond == DOCKED) | 66 | if (Ship.cond == DOCKED) { | |
67 | { | |||
68 | m1 = 1.0 / Param.dockfac; | 67 | m1 = 1.0 / Param.dockfac; | |
69 | m2 = 1.0; | 68 | m2 = 1.0; | |
70 | } | 69 | } else { | |
71 | else | |||
72 | { | |||
73 | m1 = 1.0; | 70 | m1 = 1.0; | |
74 | m2 = Param.dockfac; | 71 | m2 = Param.dockfac; | |
75 | } | 72 | } | |
76 | printf("Damage control report:\n"); | 73 | printf("Damage control report:\n"); | |
77 | f = 1; | 74 | f = 1; | |
78 | 75 | |||
79 | /* scan for damages */ | 76 | /* scan for damages */ | |
80 | for (i = 0; i < MAXEVENTS; i++) | 77 | for (i = 0; i < MAXEVENTS; i++) { | |
81 | { | |||
82 | e = &Event[i]; | 78 | e = &Event[i]; | |
83 | if (e->evcode != E_FIXDV) | 79 | if (e->evcode != E_FIXDV) | |
84 | continue; | 80 | continue; | |
85 | 81 | |||
86 | /* output the title first time */ | 82 | /* output the title first time */ | |
87 | if (f) | 83 | if (f) { | |
88 | { | |||
89 | printf("\t\t\t repair times\n"); | 84 | printf("\t\t\t repair times\n"); | |
90 | printf("device\t\t\tin flight docked\n"); | 85 | printf("device\t\t\tin flight docked\n"); | |
91 | f = 0; | 86 | f = 0; | |
92 | } | 87 | } | |
93 | 88 | |||
94 | /* compute time till fixed, then adjust by the magic factors */ | 89 | /* compute time till fixed, then adjust by the magic factors */ | |
95 | x = e->date - Now.date; | 90 | x = e->date - Now.date; | |
96 | printf("%-24s%7.2f %7.2f\n", | 91 | printf("%-24s%7.2f %7.2f\n", | |
97 | Device[e->systemname].name, x * m1 + 0.005, x * m2 + 0.005); | 92 | Device[e->systemname].name, x * m1 + 0.005, x * m2 + 0.005); | |
98 | 93 | |||
99 | /* do a little consistancy checking */ | 94 | /* do a little consistancy checking */ | |
100 | } | 95 | } | |
101 | 96 |
--- src/games/trek/dock.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/dock.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dock.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: dock.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: dock.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: dock.c,v 1.9 2009/05/24 21:44:56 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 | ** DOCK TO STARBASE | 45 | ** DOCK TO STARBASE | |
46 | ** | 46 | ** | |
47 | ** The starship is docked to a starbase. For this to work you | 47 | ** The starship is docked to a starbase. For this to work you | |
48 | ** must be adjacent to a starbase. | 48 | ** must be adjacent to a starbase. | |
49 | ** | 49 | ** | |
50 | ** You get your supplies replenished and your captives are | 50 | ** You get your supplies replenished and your captives are | |
@@ -60,36 +60,33 @@ __RCSID("$NetBSD: dock.c,v 1.8 2009/05/2 | @@ -60,36 +60,33 @@ __RCSID("$NetBSD: dock.c,v 1.8 2009/05/2 | |||
60 | void | 60 | void | |
61 | dock(int v __unused) | 61 | dock(int v __unused) | |
62 | { | 62 | { | |
63 | int i, j; | 63 | int i, j; | |
64 | int ok; | 64 | int ok; | |
65 | struct event *e; | 65 | struct event *e; | |
66 | 66 | |||
67 | if (Ship.cond == DOCKED) { | 67 | if (Ship.cond == DOCKED) { | |
68 | printf("Chekov: But captain, we are already docked\n"); | 68 | printf("Chekov: But captain, we are already docked\n"); | |
69 | return; | 69 | return; | |
70 | } | 70 | } | |
71 | /* check for ok to dock, i.e., adjacent to a starbase */ | 71 | /* check for ok to dock, i.e., adjacent to a starbase */ | |
72 | ok = 0; | 72 | ok = 0; | |
73 | for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) | 73 | for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) { | |
74 | { | |||
75 | if (i < 0 || i >= NSECTS) | 74 | if (i < 0 || i >= NSECTS) | |
76 | continue; | 75 | continue; | |
77 | for (j = Ship.secty - 1; j <= Ship.secty + 1; j++) | 76 | for (j = Ship.secty - 1; j <= Ship.secty + 1; j++) { | |
78 | { | |||
79 | if (j < 0 || j >= NSECTS) | 77 | if (j < 0 || j >= NSECTS) | |
80 | continue; | 78 | continue; | |
81 | if (Sect[i][j] == BASE) | 79 | if (Sect[i][j] == BASE) { | |
82 | { | |||
83 | ok++; | 80 | ok++; | |
84 | break; | 81 | break; | |
85 | } | 82 | } | |
86 | } | 83 | } | |
87 | } | 84 | } | |
88 | if (!ok) { | 85 | if (!ok) { | |
89 | printf("Chekov: But captain, we are not adjacent to a starbase.\n"); | 86 | printf("Chekov: But captain, we are not adjacent to a starbase.\n"); | |
90 | return; | 87 | return; | |
91 | } | 88 | } | |
92 | 89 | |||
93 | /* restore resources */ | 90 | /* restore resources */ | |
94 | Ship.energy = Param.energy; | 91 | Ship.energy = Param.energy; | |
95 | Ship.torped = Param.torped; | 92 | Ship.torped = Param.torped; | |
@@ -101,56 +98,53 @@ dock(int v __unused) | @@ -101,56 +98,53 @@ dock(int v __unused) | |||
101 | /* reset ship's defenses */ | 98 | /* reset ship's defenses */ | |
102 | Ship.shldup = 0; | 99 | Ship.shldup = 0; | |
103 | Ship.cloaked = 0; | 100 | Ship.cloaked = 0; | |
104 | Ship.cond = DOCKED; | 101 | Ship.cond = DOCKED; | |
105 | Ship.reserves = Param.reserves; | 102 | Ship.reserves = Param.reserves; | |
106 | 103 | |||
107 | /* recalibrate space inertial navigation system */ | 104 | /* recalibrate space inertial navigation system */ | |
108 | Ship.sinsbad = 0; | 105 | Ship.sinsbad = 0; | |
109 | 106 | |||
110 | /* output any saved radio messages */ | 107 | /* output any saved radio messages */ | |
111 | dumpssradio(); | 108 | dumpssradio(); | |
112 | 109 | |||
113 | /* reschedule any device repairs */ | 110 | /* reschedule any device repairs */ | |
114 | for (i = 0; i < MAXEVENTS; i++) | 111 | for (i = 0; i < MAXEVENTS; i++) { | |
115 | { | |||
116 | e = &Event[i]; | 112 | e = &Event[i]; | |
117 | if (e->evcode != E_FIXDV) | 113 | if (e->evcode != E_FIXDV) | |
118 | continue; | 114 | continue; | |
119 | reschedule(e, (e->date - Now.date) * Param.dockfac); | 115 | reschedule(e, (e->date - Now.date) * Param.dockfac); | |
120 | } | 116 | } | |
121 | return; | 117 | return; | |
122 | } | 118 | } | |
123 | 119 | |||
124 | 120 | |||
125 | /* | 121 | /* | |
126 | ** LEAVE A STARBASE | 122 | ** LEAVE A STARBASE | |
127 | ** | 123 | ** | |
128 | ** This is the inverse of dock(). The main function it performs | 124 | ** This is the inverse of dock(). The main function it performs | |
129 | ** is to reschedule any damages so that they will take longer. | 125 | ** is to reschedule any damages so that they will take longer. | |
130 | */ | 126 | */ | |
131 | 127 | |||
132 | /*ARGSUSED*/ | 128 | /*ARGSUSED*/ | |
133 | void | 129 | void | |
134 | undock(int v __unused) | 130 | undock(int v __unused) | |
135 | { | 131 | { | |
136 | struct event *e; | 132 | struct event *e; | |
137 | int i; | 133 | int i; | |
138 | 134 | |||
139 | if (Ship.cond != DOCKED) | 135 | if (Ship.cond != DOCKED) { | |
140 | { | |||
141 | printf("Sulu: Pardon me captain, but we are not docked.\n"); | 136 | printf("Sulu: Pardon me captain, but we are not docked.\n"); | |
142 | return; | 137 | return; | |
143 | } | 138 | } | |
144 | Ship.cond = GREEN; | 139 | Ship.cond = GREEN; | |
145 | Move.free = 0; | 140 | Move.free = 0; | |
146 | 141 | |||
147 | /* reschedule device repair times (again) */ | 142 | /* reschedule device repair times (again) */ | |
148 | for (i = 0; i < MAXEVENTS; i++) | 143 | for (i = 0; i < MAXEVENTS; i++) { | |
149 | { | |||
150 | e = &Event[i]; | 144 | e = &Event[i]; | |
151 | if (e->evcode != E_FIXDV) | 145 | if (e->evcode != E_FIXDV) | |
152 | continue; | 146 | continue; | |
153 | reschedule(e, (e->date - Now.date) / Param.dockfac); | 147 | reschedule(e, (e->date - Now.date) / Param.dockfac); | |
154 | } | 148 | } | |
155 | return; | 149 | return; | |
156 | } | 150 | } |
--- src/games/trek/impulse.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/impulse.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: impulse.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: impulse.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: impulse.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: impulse.c,v 1.9 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /** | 45 | /** | |
46 | ** move under impulse power | 46 | ** move under impulse power | |
47 | **/ | 47 | **/ | |
48 | 48 | |||
49 | /*ARGSUSED*/ | 49 | /*ARGSUSED*/ | |
50 | void | 50 | void | |
@@ -57,34 +57,32 @@ impulse(int v __unused) | @@ -57,34 +57,32 @@ impulse(int v __unused) | |||
57 | 57 | |||
58 | if (Ship.cond == DOCKED) { | 58 | if (Ship.cond == DOCKED) { | |
59 | printf("Scotty: Sorry captain, but we are still docked.\n"); | 59 | printf("Scotty: Sorry captain, but we are still docked.\n"); | |
60 | return; | 60 | return; | |
61 | } | 61 | } | |
62 | if (damaged(IMPULSE)) { | 62 | if (damaged(IMPULSE)) { | |
63 | out(IMPULSE); | 63 | out(IMPULSE); | |
64 | return; | 64 | return; | |
65 | } | 65 | } | |
66 | if (getcodi(&course, &dist)) | 66 | if (getcodi(&course, &dist)) | |
67 | return; | 67 | return; | |
68 | power = 20 + 100 * dist; | 68 | power = 20 + 100 * dist; | |
69 | percent = 100 * power / Ship.energy + 0.5; | 69 | percent = 100 * power / Ship.energy + 0.5; | |
70 | if (percent >= 85) | 70 | if (percent >= 85) { | |
71 | { | |||
72 | printf("Scotty: That would consume %d%% of our remaining energy.\n", | 71 | printf("Scotty: That would consume %d%% of our remaining energy.\n", | |
73 | percent); | 72 | percent); | |
74 | if (!getynpar("Are you sure that is wise")) | 73 | if (!getynpar("Are you sure that is wise")) | |
75 | return; | 74 | return; | |
76 | printf("Aye aye, sir\n"); | 75 | printf("Aye aye, sir\n"); | |
77 | } | 76 | } | |
78 | time = dist / 0.095; | 77 | time = dist / 0.095; | |
79 | percent = 100 * time / Now.time + 0.5; | 78 | percent = 100 * time / Now.time + 0.5; | |
80 | if (percent >= 85) | 79 | if (percent >= 85) { | |
81 | { | |||
82 | printf("Spock: That would take %d%% of our remaining time.\n", | 80 | printf("Spock: That would take %d%% of our remaining time.\n", | |
83 | percent); | 81 | percent); | |
84 | if (!getynpar("Are you sure that is wise")) | 82 | if (!getynpar("Are you sure that is wise")) | |
85 | return; | 83 | return; | |
86 | printf("(He's finally gone mad)\n"); | 84 | printf("(He's finally gone mad)\n"); | |
87 | } | 85 | } | |
88 | Move.time = move(0, course, time, 0.095); | 86 | Move.time = move(0, course, time, 0.095); | |
89 | Ship.energy -= 20 + 100 * Move.time * 0.095; | 87 | Ship.energy -= 20 + 100 * Move.time * 0.095; | |
90 | } | 88 | } |
--- src/games/trek/lose.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/lose.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lose.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: lose.c,v 1.9 2009/05/24 21:44:56 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,68 +24,65 @@ | @@ -24,68 +24,65 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: lose.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: lose.c,v 1.9 2009/05/24 21:44:56 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 <setjmp.h> | 42 | #include <setjmp.h> | |
43 | #include <unistd.h> | 43 | #include <unistd.h> | |
44 | #include "trek.h" | 44 | #include "trek.h" | |
45 | #include "getpar.h" | 45 | #include "getpar.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** PRINT OUT LOSER MESSAGES | 48 | ** PRINT OUT LOSER MESSAGES | |
49 | ** | 49 | ** | |
50 | ** The messages are printed out, the score is computed and | 50 | ** The messages are printed out, the score is computed and | |
51 | ** printed, and the game is restarted. Oh yeh, any special | 51 | ** printed, and the game is restarted. Oh yeh, any special | |
52 | ** actions which need be taken are taken. | 52 | ** actions which need be taken are taken. | |
53 | */ | 53 | */ | |
54 | 54 | |||
55 | extern jmp_buf env; | 55 | extern jmp_buf env; | |
56 | 56 | |||
57 | const char *const Losemsg[] = | 57 | const char *const Losemsg[] = { | |
58 | { | |||
59 | "You ran out of time", | 58 | "You ran out of time", | |
60 | "You ran out of energy", | 59 | "You ran out of energy", | |
61 | "You have been destroyed", | 60 | "You have been destroyed", | |
62 | "You ran into the negative energy barrier", | 61 | "You ran into the negative energy barrier", | |
63 | "You destroyed yourself by nova'ing that star", | 62 | "You destroyed yourself by nova'ing that star", | |
64 | "You have been caught in a supernova", | 63 | "You have been caught in a supernova", | |
65 | "You just suffocated in outer space", | 64 | "You just suffocated in outer space", | |
66 | "You could not be rematerialized", | 65 | "You could not be rematerialized", | |
67 | "\n\032\014 ***\07 Ship's hull has imploded\07 ***", | 66 | "\n\032\014 ***\07 Ship's hull has imploded\07 ***", | |
68 | "You have burned up in a star", | 67 | "You have burned up in a star", | |
69 | "Well, you destroyed yourself, but it didn't do any good", | 68 | "Well, you destroyed yourself, but it didn't do any good", | |
70 | "You have been captured by Klingons and mercilessly tortured", | 69 | "You have been captured by Klingons and mercilessly tortured", | |
71 | "Your last crew member died", | 70 | "Your last crew member died", | |
72 | }; | 71 | }; | |
73 | 72 | |||
74 | void | 73 | void | |
75 | lose(int why) | 74 | lose(int why) | |
76 | { | 75 | { | |
77 | Game.killed = 1; | 76 | Game.killed = 1; | |
78 | sleep(1); | 77 | sleep(1); | |
79 | printf("\n%s\n", Losemsg[why - 1]); | 78 | printf("\n%s\n", Losemsg[why - 1]); | |
80 | switch (why) | 79 | switch (why) { | |
81 | { | |||
82 | ||||
83 | case L_NOTIME: | 80 | case L_NOTIME: | |
84 | Game.killed = 0; | 81 | Game.killed = 0; | |
85 | break; | 82 | break; | |
86 | } | 83 | } | |
87 | Move.endgame = -1; | 84 | Move.endgame = -1; | |
88 | score(); | 85 | score(); | |
89 | skiptonl(0); | 86 | skiptonl(0); | |
90 | longjmp(env, 1); | 87 | longjmp(env, 1); | |
91 | } | 88 | } |
--- src/games/trek/lrscan.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/lrscan.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lrscan.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: lrscan.c,v 1.9 2009/05/24 21:44:56 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,90 +24,83 @@ | @@ -24,90 +24,83 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: lrscan.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: lrscan.c,v 1.9 2009/05/24 21:44:56 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 | ** LONG RANGE OF SCANNERS | 45 | ** LONG RANGE OF SCANNERS | |
46 | ** | 46 | ** | |
47 | ** A summary of the quadrants that surround you is printed. The | 47 | ** A summary of the quadrants that surround you is printed. The | |
48 | ** hundreds digit is the number of Klingons in the quadrant, | 48 | ** hundreds digit is the number of Klingons in the quadrant, | |
49 | ** the tens digit is the number of starbases, and the units digit | 49 | ** the tens digit is the number of starbases, and the units digit | |
50 | ** is the number of stars. If the printout is "///" it means | 50 | ** is the number of stars. If the printout is "///" it means | |
51 | ** that that quadrant is rendered uninhabitable by a supernova. | 51 | ** that that quadrant is rendered uninhabitable by a supernova. | |
52 | ** It also updates the "scanned" field of the quadrants it scans, | 52 | ** It also updates the "scanned" field of the quadrants it scans, | |
53 | ** for future use by the "chart" option of the computer. | 53 | ** for future use by the "chart" option of the computer. | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | /*ARGSUSED*/ | 56 | /*ARGSUSED*/ | |
57 | void | 57 | void | |
58 | lrscan(int v __unused) | 58 | lrscan(int v __unused) | |
59 | { | 59 | { | |
60 | int i, j; | 60 | int i, j; | |
61 | struct quad *q; | 61 | struct quad *q; | |
62 | 62 | |||
63 | if (check_out(LRSCAN)) | 63 | if (check_out(LRSCAN)) { | |
64 | { | |||
65 | return; | 64 | return; | |
66 | } | 65 | } | |
67 | printf("Long range scan for quadrant %d,%d\n\n", Ship.quadx, Ship.quady); | 66 | printf("Long range scan for quadrant %d,%d\n\n", Ship.quadx, Ship.quady); | |
68 | 67 | |||
69 | /* print the header on top */ | 68 | /* print the header on top */ | |
70 | for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) | 69 | for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) { | |
71 | { | |||
72 | if (j < 0 || j >= NQUADS) | 70 | if (j < 0 || j >= NQUADS) | |
73 | printf(" "); | 71 | printf(" "); | |
74 | else | 72 | else | |
75 | printf(" %1d", j); | 73 | printf(" %1d", j); | |
76 | } | 74 | } | |
77 | 75 | |||
78 | /* scan the quadrants */ | 76 | /* scan the quadrants */ | |
79 | for (i = Ship.quadx - 1; i <= Ship.quadx + 1; i++) | 77 | for (i = Ship.quadx - 1; i <= Ship.quadx + 1; i++) { | |
80 | { | |||
81 | printf("\n -------------------\n"); | 78 | printf("\n -------------------\n"); | |
82 | if (i < 0 || i >= NQUADS) | 79 | if (i < 0 || i >= NQUADS) { | |
83 | { | |||
84 | /* negative energy barrier */ | 80 | /* negative energy barrier */ | |
85 | printf(" ! * ! * ! * !"); | 81 | printf(" ! * ! * ! * !"); | |
86 | continue; | 82 | continue; | |
87 | } | 83 | } | |
88 | 84 | |||
89 | /* print the left hand margin */ | 85 | /* print the left hand margin */ | |
90 | printf("%1d !", i); | 86 | printf("%1d !", i); | |
91 | for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) | 87 | for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) { | |
92 | { | 88 | if (j < 0 || j >= NQUADS) { | |
93 | if (j < 0 || j >= NQUADS) | |||
94 | { | |||
95 | /* negative energy barrier again */ | 89 | /* negative energy barrier again */ | |
96 | printf(" * !"); | 90 | printf(" * !"); | |
97 | continue; | 91 | continue; | |
98 | } | 92 | } | |
99 | q = &Quad[i][j]; | 93 | q = &Quad[i][j]; | |
100 | if (q->stars < 0) | 94 | if (q->stars < 0) { | |
101 | { | |||
102 | /* supernova */ | 95 | /* supernova */ | |
103 | printf(" /// !"); | 96 | printf(" /// !"); | |
104 | q->scanned = 1000; | 97 | q->scanned = 1000; | |
105 | continue; | 98 | continue; | |
106 | } | 99 | } | |
107 | q->scanned = q->klings * 100 + q->bases * 10 + q->stars; | 100 | q->scanned = q->klings * 100 + q->bases * 10 + q->stars; | |
108 | printf(" %3d !", q->scanned); | 101 | printf(" %3d !", q->scanned); | |
109 | } | 102 | } | |
110 | } | 103 | } | |
111 | printf("\n -------------------\n"); | 104 | printf("\n -------------------\n"); | |
112 | return; | 105 | return; | |
113 | } | 106 | } |
--- src/games/trek/move.c 2009/05/24 20:39:43 1.8
+++ src/games/trek/move.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: move.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: move.c,v 1.9 2009/05/24 21:44:56 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 | |
@@ -112,58 +112,54 @@ move(int ramflag, int course, double tim | @@ -112,58 +112,54 @@ move(int ramflag, int course, double tim | |||
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 | { | |||
127 | /* then we got a LRTB */ | 126 | /* then we got a LRTB */ | |
128 | evtime += 0.005; | 127 | evtime += 0.005; | |
129 | time = evtime; | 128 | time = evtime; | |
130 | } | 129 | } else | |
131 | else | |||
132 | evtime = -1.0e50; | 130 | evtime = -1.0e50; | |
133 | dist = time * speed; | 131 | dist = time * speed; | |
134 | 132 | |||
135 | /* move within quadrant */ | 133 | /* move within quadrant */ | |
136 | Sect[Ship.sectx][Ship.secty] = EMPTY; | 134 | Sect[Ship.sectx][Ship.secty] = EMPTY; | |
137 | x = Ship.sectx + 0.5; | 135 | x = Ship.sectx + 0.5; | |
138 | y = Ship.secty + 0.5; | 136 | y = Ship.secty + 0.5; | |
139 | xn = NSECTS * dist * bigger; | 137 | xn = NSECTS * dist * bigger; | |
140 | n = xn + 0.5; | 138 | n = xn + 0.5; | |
141 | #ifdef xTRACE | 139 | #ifdef xTRACE | |
142 | if (Trace) | 140 | if (Trace) | |
143 | printf("dx = %.2f, dy = %.2f, xn = %.2f, n = %d\n", dx, dy, xn, n); | 141 | printf("dx = %.2f, dy = %.2f, xn = %.2f, n = %d\n", dx, dy, xn, n); | |
144 | #endif | 142 | #endif | |
145 | Move.free = 0; | 143 | Move.free = 0; | |
146 | 144 | |||
147 | for (i = 0; i < n; i++) | 145 | for (i = 0; i < n; i++) { | |
148 | { | |||
149 | ix = (x += dx); | 146 | ix = (x += dx); | |
150 | iy = (y += dy); | 147 | iy = (y += dy); | |
151 | #ifdef xTRACE | 148 | #ifdef xTRACE | |
152 | if (Trace) | 149 | if (Trace) | |
153 | printf("ix = %d, x = %.2f, iy = %d, y = %.2f\n", ix, x, iy, y); | 150 | printf("ix = %d, x = %.2f, iy = %d, y = %.2f\n", ix, x, iy, y); | |
154 | #endif | 151 | #endif | |
155 | if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize) | 152 | if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize) { | |
156 | { | |||
157 | /* enter new quadrant */ | 153 | /* enter new quadrant */ | |
158 | dx = Ship.quadx * NSECTS + Ship.sectx + dx * xn; | 154 | dx = Ship.quadx * NSECTS + Ship.sectx + dx * xn; | |
159 | dy = Ship.quady * NSECTS + Ship.secty + dy * xn; | 155 | dy = Ship.quady * NSECTS + Ship.secty + dy * xn; | |
160 | if (dx < 0.0) | 156 | if (dx < 0.0) | |
161 | ix = -1; | 157 | ix = -1; | |
162 | else | 158 | else | |
163 | ix = dx + 0.5; | 159 | ix = dx + 0.5; | |
164 | if (dy < 0.0) | 160 | if (dy < 0.0) | |
165 | iy = -1; | 161 | iy = -1; | |
166 | else | 162 | else | |
167 | iy = dy + 0.5; | 163 | iy = dy + 0.5; | |
168 | #ifdef xTRACE | 164 | #ifdef xTRACE | |
169 | if (Trace) | 165 | if (Trace) | |
@@ -180,53 +176,51 @@ move(int ramflag, int course, double tim | @@ -180,53 +176,51 @@ move(int ramflag, int course, double tim | |||
180 | Ship.sectx = ix % NSECTS; | 176 | Ship.sectx = ix % NSECTS; | |
181 | Ship.secty = iy % NSECTS; | 177 | Ship.secty = iy % NSECTS; | |
182 | if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 || | 178 | if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 || | |
183 | Ship.quady >= NQUADS) { | 179 | Ship.quady >= NQUADS) { | |
184 | if (!damaged(COMPUTER)) { | 180 | if (!damaged(COMPUTER)) { | |
185 | dumpme(0); | 181 | dumpme(0); | |
186 | } else | 182 | } else | |
187 | lose(L_NEGENB); | 183 | lose(L_NEGENB); | |
188 | } | 184 | } | |
189 | initquad(0); | 185 | initquad(0); | |
190 | n = 0; | 186 | n = 0; | |
191 | break; | 187 | break; | |
192 | } | 188 | } | |
193 | if (Sect[ix][iy] != EMPTY) | 189 | if (Sect[ix][iy] != EMPTY) { | |
194 | { | |||
195 | /* we just hit something */ | 190 | /* we just hit something */ | |
196 | if (!damaged(COMPUTER) && ramflag <= 0) | 191 | if (!damaged(COMPUTER) && ramflag <= 0) { | |
197 | { | |||
198 | ix = x - dx; | 192 | ix = x - dx; | |
199 | iy = y - dy; | 193 | iy = y - dy; | |
200 | printf("Computer reports navigation error; %s stopped at %d,%d\n", | 194 | printf("Computer reports navigation error; %s stopped at %d,%d\n", | |
201 | Ship.shipname, ix, iy); | 195 | Ship.shipname, ix, iy); | |
202 | Ship.energy -= Param.stopengy * speed; | 196 | Ship.energy -= Param.stopengy * speed; | |
203 | break; | 197 | break; | |
204 | } | 198 | } | |
205 | /* test for a black hole */ | 199 | /* test for a black hole */ | |
206 | if (Sect[ix][iy] == HOLE) | 200 | if (Sect[ix][iy] == HOLE) { | |
207 | { | |||
208 | /* get dumped elsewhere in the galaxy */ | 201 | /* get dumped elsewhere in the galaxy */ | |
209 | dumpme(1); | 202 | dumpme(1); | |
210 | initquad(0); | 203 | initquad(0); | |
211 | n = 0; | 204 | n = 0; | |
212 | break; | 205 | break; | |
213 | } | 206 | } | |
214 | ram(ix, iy); | 207 | ram(ix, iy); | |
215 | break; | 208 | break; | |
216 | } | 209 | } | |
217 | } | 210 | } | |
218 | if (n > 0) | 211 | if (n > 0) { | |
219 | { | |||
220 | dx = Ship.sectx - ix; | 212 | dx = Ship.sectx - ix; | |
221 | dy = Ship.secty - iy; | 213 | dy = Ship.secty - iy; | |
222 | dist = sqrt(dx * dx + dy * dy) / NSECTS; | 214 | dist = sqrt(dx * dx + dy * dy) / NSECTS; | |
223 | time = dist / speed; | 215 | time = dist / speed; | |
224 | if (evtime > time) | 216 | if (evtime > time) { | |
225 | time = evtime; /* spring the LRTB trap */ | 217 | /* spring the LRTB trap */ | |
218 | time = evtime; | |||
219 | } | |||
226 | Ship.sectx = ix; | 220 | Ship.sectx = ix; | |
227 | Ship.secty = iy; | 221 | Ship.secty = iy; | |
228 | } | 222 | } | |
229 | Sect[Ship.sectx][Ship.secty] = Ship.ship; | 223 | Sect[Ship.sectx][Ship.secty] = Ship.ship; | |
230 | compkldist(0); | 224 | compkldist(0); | |
231 | return (time); | 225 | return (time); | |
232 | } | 226 | } |
--- src/games/trek/rest.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/rest.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rest.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: rest.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: rest.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: rest.c,v 1.9 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** REST FOR REPAIRS | 46 | ** REST FOR REPAIRS | |
47 | ** | 47 | ** | |
48 | ** You sit around and wait for repairs to happen. Actually, you | 48 | ** You sit around and wait for repairs to happen. Actually, you | |
49 | ** sit around and wait for anything to happen. I do want to point | 49 | ** sit around and wait for anything to happen. I do want to point | |
50 | ** out however, that Klingons are not as patient as you are, and | 50 | ** out however, that Klingons are not as patient as you are, and | |
@@ -58,28 +58,27 @@ __RCSID("$NetBSD: rest.c,v 1.8 2009/05/2 | @@ -58,28 +58,27 @@ __RCSID("$NetBSD: rest.c,v 1.8 2009/05/2 | |||
58 | 58 | |||
59 | /*ARGSUSED*/ | 59 | /*ARGSUSED*/ | |
60 | void | 60 | void | |
61 | rest(int v __unused) | 61 | rest(int v __unused) | |
62 | { | 62 | { | |
63 | double t; | 63 | double t; | |
64 | int percent; | 64 | int percent; | |
65 | 65 | |||
66 | /* get the time to rest */ | 66 | /* get the time to rest */ | |
67 | t = getfltpar("How long"); | 67 | t = getfltpar("How long"); | |
68 | if (t <= 0.0) | 68 | if (t <= 0.0) | |
69 | return; | 69 | return; | |
70 | percent = 100 * t / Now.time + 0.5; | 70 | percent = 100 * t / Now.time + 0.5; | |
71 | if (percent >= 70) | 71 | if (percent >= 70) { | |
72 | { | |||
73 | printf("Spock: That would take %d%% of our remaining time.\n", | 72 | printf("Spock: That would take %d%% of our remaining time.\n", | |
74 | percent); | 73 | percent); | |
75 | if (!getynpar("Are you really certain that is wise")) | 74 | if (!getynpar("Are you really certain that is wise")) | |
76 | return; | 75 | return; | |
77 | } | 76 | } | |
78 | Move.time = t; | 77 | Move.time = t; | |
79 | 78 | |||
80 | /* boundary condition is the LRTB */ | 79 | /* boundary condition is the LRTB */ | |
81 | t = Now.eventptr[E_LRTB]->date - Now.date; | 80 | t = Now.eventptr[E_LRTB]->date - Now.date; | |
82 | if (Ship.cond != DOCKED && Move.time > t) | 81 | if (Ship.cond != DOCKED && Move.time > t) | |
83 | Move.time = t + 0.0001; | 82 | Move.time = t + 0.0001; | |
84 | Move.free = 0; | 83 | Move.free = 0; | |
85 | Move.resting = 1; | 84 | Move.resting = 1; |
--- src/games/trek/visual.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/visual.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: visual.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: visual.c,v 1.9 2009/05/24 21:44:56 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,46 +24,45 @@ | @@ -24,46 +24,45 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: visual.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: visual.c,v 1.9 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** VISUAL SCAN | 46 | ** VISUAL SCAN | |
47 | ** | 47 | ** | |
48 | ** A visual scan is made in a particular direction of three sectors | 48 | ** A visual scan is made in a particular direction of three sectors | |
49 | ** in the general direction specified. This takes time, and | 49 | ** in the general direction specified. This takes time, and | |
50 | ** Klingons can attack you, so it should be done only when sensors | 50 | ** Klingons can attack you, so it should be done only when sensors | |
51 | ** are out. | 51 | ** are out. | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | /* This struct[] has the delta x, delta y for particular directions */ | 54 | /* This struct[] has the delta x, delta y for particular directions */ | |
55 | struct xy Visdelta[11] = | 55 | struct xy Visdelta[11] = { | |
56 | { | |||
57 | { -1, -1 }, | 56 | { -1, -1 }, | |
58 | { -1, 0 }, | 57 | { -1, 0 }, | |
59 | { -1, 1 }, | 58 | { -1, 1 }, | |
60 | { 0, 1 }, | 59 | { 0, 1 }, | |
61 | { 1, 1 }, | 60 | { 1, 1 }, | |
62 | { 1, 0 }, | 61 | { 1, 0 }, | |
63 | { 1, -1 }, | 62 | { 1, -1 }, | |
64 | { 0, -1 }, | 63 | { 0, -1 }, | |
65 | { -1, -1 }, | 64 | { -1, -1 }, | |
66 | { -1, 0 }, | 65 | { -1, 0 }, | |
67 | { -1, 1 } | 66 | { -1, 1 } | |
68 | }; | 67 | }; | |
69 | 68 |
--- src/games/trek/win.c 2009/05/24 19:18:44 1.8
+++ src/games/trek/win.c 2009/05/24 21:44:56 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: win.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: win.c,v 1.9 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: win.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: win.c,v 1.9 2009/05/24 21:44:56 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 <unistd.h> | 42 | #include <unistd.h> | |
43 | #include <setjmp.h> | 43 | #include <setjmp.h> | |
44 | #include "trek.h" | 44 | #include "trek.h" | |
45 | #include "getpar.h" | 45 | #include "getpar.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** Signal game won | 48 | ** Signal game won | |
49 | ** | 49 | ** | |
50 | ** This routine prints out the win message, arranges to print out | 50 | ** This routine prints out the win message, arranges to print out | |
@@ -64,31 +64,29 @@ win(void) | @@ -64,31 +64,29 @@ win(void) | |||
64 | { | 64 | { | |
65 | long s; | 65 | long s; | |
66 | const struct cvntab *p = NULL; | 66 | const struct cvntab *p = NULL; | |
67 | 67 | |||
68 | sleep(1); | 68 | sleep(1); | |
69 | printf("\nCongratulations, you have saved the Federation\n"); | 69 | printf("\nCongratulations, you have saved the Federation\n"); | |
70 | Move.endgame = 1; | 70 | Move.endgame = 1; | |
71 | 71 | |||
72 | /* print and return the score */ | 72 | /* print and return the score */ | |
73 | s = score(); | 73 | s = score(); | |
74 | 74 | |||
75 | /* decide if she gets a promotion */ | 75 | /* decide if she gets a promotion */ | |
76 | if (Game.helps == 0 && Game.killb == 0 && Game.killinhab == 0 && 5 * Game.kills + Game.deaths < 100 && | 76 | if (Game.helps == 0 && Game.killb == 0 && Game.killinhab == 0 && 5 * Game.kills + Game.deaths < 100 && | |
77 | s >= 1000 && Ship.ship == ENTERPRISE) | 77 | s >= 1000 && Ship.ship == ENTERPRISE) { | |
78 | { | |||
79 | printf("In fact, you are promoted one step in rank,\n"); | 78 | printf("In fact, you are promoted one step in rank,\n"); | |
80 | if (Game.skill >= 6) | 79 | if (Game.skill >= 6) { | |
81 | printf("to the exalted rank of Commodore Emeritus\n"); | 80 | printf("to the exalted rank of Commodore Emeritus\n"); | |
82 | else | 81 | } else { | |
83 | { | |||
84 | p = &Skitab[Game.skill - 1]; | 82 | p = &Skitab[Game.skill - 1]; | |
85 | printf("from %s%s ", p->abrev, p->full); | 83 | printf("from %s%s ", p->abrev, p->full); | |
86 | p++; | 84 | p++; | |
87 | printf("to %s%s\n", p->abrev, p->full); | 85 | printf("to %s%s\n", p->abrev, p->full); | |
88 | } | 86 | } | |
89 | } | 87 | } | |
90 | 88 | |||
91 | /* clean out input, and request new game */ | 89 | /* clean out input, and request new game */ | |
92 | skiptonl(0); | 90 | skiptonl(0); | |
93 | longjmp(env, 1); | 91 | longjmp(env, 1); | |
94 | } | 92 | } |
--- src/games/trek/attack.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/attack.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: attack.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: attack.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: attack.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: attack.c,v 1.7 2009/05/24 21:44:56 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 | ** Klingon Attack Routine | 46 | ** Klingon Attack Routine | |
47 | ** | 47 | ** | |
48 | ** This routine performs the Klingon attack provided that | 48 | ** This routine performs the Klingon attack provided that | |
49 | ** (1) Something happened this move (i.e., not free), and | 49 | ** (1) Something happened this move (i.e., not free), and | |
50 | ** (2) You are not cloaked. Note that if you issue the | 50 | ** (2) You are not cloaked. Note that if you issue the | |
@@ -82,114 +82,106 @@ attack(int resting) | @@ -82,114 +82,106 @@ attack(int resting) | |||
82 | double chgfac, propor, extradm; | 82 | double chgfac, propor, extradm; | |
83 | double dustfac, tothe; | 83 | double dustfac, tothe; | |
84 | int cas; | 84 | int cas; | |
85 | int hitflag; | 85 | int hitflag; | |
86 | 86 | |||
87 | if (Move.free) | 87 | if (Move.free) | |
88 | return; | 88 | return; | |
89 | if (Etc.nkling <= 0 || Quad[Ship.quadx][Ship.quady].stars < 0) | 89 | if (Etc.nkling <= 0 || Quad[Ship.quadx][Ship.quady].stars < 0) | |
90 | return; | 90 | return; | |
91 | if (Ship.cloaked && Ship.cloakgood) | 91 | if (Ship.cloaked && Ship.cloakgood) | |
92 | return; | 92 | return; | |
93 | /* move before attack */ | 93 | /* move before attack */ | |
94 | klmove(0); | 94 | klmove(0); | |
95 | if (Ship.cond == DOCKED) | 95 | if (Ship.cond == DOCKED) { | |
96 | { | |||
97 | if (!resting) | 96 | if (!resting) | |
98 | printf("Starbase shields protect the %s\n", Ship.shipname); | 97 | printf("Starbase shields protect the %s\n", Ship.shipname); | |
99 | return; | 98 | return; | |
100 | } | 99 | } | |
101 | /* setup shield effectiveness */ | 100 | /* setup shield effectiveness */ | |
102 | chgfac = 1.0; | 101 | chgfac = 1.0; | |
103 | if (Move.shldchg) | 102 | if (Move.shldchg) | |
104 | chgfac = 0.25 + 0.50 * franf(); | 103 | chgfac = 0.25 + 0.50 * franf(); | |
105 | maxhit = tothit = 0; | 104 | maxhit = tothit = 0; | |
106 | hitflag = 0; | 105 | hitflag = 0; | |
107 | 106 | |||
108 | /* let each Klingon do his damndest */ | 107 | /* let each Klingon do his damndest */ | |
109 | for (i = 0; i < Etc.nkling; i++) | 108 | for (i = 0; i < Etc.nkling; i++) { | |
110 | { | |||
111 | /* if he's low on power he won't attack */ | 109 | /* if he's low on power he won't attack */ | |
112 | if (Etc.klingon[i].power < 20) | 110 | if (Etc.klingon[i].power < 20) | |
113 | continue; | 111 | continue; | |
114 | if (!hitflag) | 112 | if (!hitflag) { | |
115 | { | |||
116 | printf("\nStardate %.2f: Klingon attack:\n", | 113 | printf("\nStardate %.2f: Klingon attack:\n", | |
117 | Now.date); | 114 | Now.date); | |
118 | hitflag++; | 115 | hitflag++; | |
119 | } | 116 | } | |
120 | /* complete the hit */ | 117 | /* complete the hit */ | |
121 | dustfac = 0.90 + 0.01 * franf(); | 118 | dustfac = 0.90 + 0.01 * franf(); | |
122 | tothe = Etc.klingon[i].avgdist; | 119 | tothe = Etc.klingon[i].avgdist; | |
123 | hit = Etc.klingon[i].power * pow(dustfac, tothe) * Param.hitfac; | 120 | hit = Etc.klingon[i].power * pow(dustfac, tothe) * Param.hitfac; | |
124 | /* deplete his energy */ | 121 | /* deplete his energy */ | |
125 | dustfac = Etc.klingon[i].power; | 122 | dustfac = Etc.klingon[i].power; | |
126 | Etc.klingon[i].power = dustfac * Param.phasfac * (1.0 + (franf() - 0.5) * 0.2); | 123 | Etc.klingon[i].power = dustfac * Param.phasfac * (1.0 + (franf() - 0.5) * 0.2); | |
127 | /* see how much of hit shields will absorb */ | 124 | /* see how much of hit shields will absorb */ | |
128 | shldabsb = 0; | 125 | shldabsb = 0; | |
129 | if (Ship.shldup || Move.shldchg) | 126 | if (Ship.shldup || Move.shldchg) { | |
130 | { | |||
131 | propor = Ship.shield; | 127 | propor = Ship.shield; | |
132 | propor /= Param.shield; | 128 | propor /= Param.shield; | |
133 | shldabsb = propor * chgfac * hit; | 129 | shldabsb = propor * chgfac * hit; | |
134 | if (shldabsb > Ship.shield) | 130 | if (shldabsb > Ship.shield) | |
135 | shldabsb = Ship.shield; | 131 | shldabsb = Ship.shield; | |
136 | Ship.shield -= shldabsb; | 132 | Ship.shield -= shldabsb; | |
137 | } | 133 | } | |
138 | /* actually do the hit */ | 134 | /* actually do the hit */ | |
139 | printf("HIT: %d units", hit); | 135 | printf("HIT: %d units", hit); | |
140 | if (!damaged(SRSCAN)) | 136 | if (!damaged(SRSCAN)) | |
141 | printf(" from %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); | 137 | printf(" from %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); | |
142 | cas = (shldabsb * 100) / hit; | 138 | cas = (shldabsb * 100) / hit; | |
143 | hit -= shldabsb; | 139 | hit -= shldabsb; | |
144 | if (shldabsb > 0) | 140 | if (shldabsb > 0) | |
145 | printf(", shields absorb %d%%, effective hit %d\n", | 141 | printf(", shields absorb %d%%, effective hit %d\n", | |
146 | cas, hit); | 142 | cas, hit); | |
147 | else | 143 | else | |
148 | printf("\n"); | 144 | printf("\n"); | |
149 | tothit += hit; | 145 | tothit += hit; | |
150 | if (hit > maxhit) | 146 | if (hit > maxhit) | |
151 | maxhit = hit; | 147 | maxhit = hit; | |
152 | Ship.energy -= hit; | 148 | Ship.energy -= hit; | |
153 | /* see if damages occurred */ | 149 | /* see if damages occurred */ | |
154 | if (hit >= (15 - Game.skill) * (25 - ranf(12))) | 150 | if (hit >= (15 - Game.skill) * (25 - ranf(12))) { | |
155 | { | |||
156 | printf("CRITICAL HIT!!!\n"); | 151 | printf("CRITICAL HIT!!!\n"); | |
157 | /* select a device from probability vector */ | 152 | /* select a device from probability vector */ | |
158 | cas = ranf(1000); | 153 | cas = ranf(1000); | |
159 | for (l = 0; cas >= 0; l++) | 154 | for (l = 0; cas >= 0; l++) | |
160 | cas -= Param.damprob[l]; | 155 | cas -= Param.damprob[l]; | |
161 | l -= 1; | 156 | l -= 1; | |
162 | /* compute amount of damage */ | 157 | /* compute amount of damage */ | |
163 | extradm = (hit * Param.damfac[l]) / (75 + ranf(25)) + 0.5; | 158 | extradm = (hit * Param.damfac[l]) / (75 + ranf(25)) + 0.5; | |
164 | /* damage the device */ | 159 | /* damage the device */ | |
165 | damage(l, extradm); | 160 | damage(l, extradm); | |
166 | if (damaged(SHIELD)) | 161 | if (damaged(SHIELD)) { | |
167 | { | |||
168 | if (Ship.shldup) | 162 | if (Ship.shldup) | |
169 | printf("Sulu: Shields knocked down, captain.\n"); | 163 | printf("Sulu: Shields knocked down, captain.\n"); | |
170 | Ship.shldup = 0; | 164 | Ship.shldup = 0; | |
171 | Move.shldchg = 0; | 165 | Move.shldchg = 0; | |
172 | } | 166 | } | |
173 | } | 167 | } | |
174 | if (Ship.energy <= 0) | 168 | if (Ship.energy <= 0) | |
175 | lose(L_DSTRYD); | 169 | lose(L_DSTRYD); | |
176 | } | 170 | } | |
177 | 171 | |||
178 | /* see what our casualities are like */ | 172 | /* see what our casualities are like */ | |
179 | if (maxhit >= 200 || tothit >= 500) | 173 | if (maxhit >= 200 || tothit >= 500) { | |
180 | { | |||
181 | cas = tothit * 0.015 * franf(); | 174 | cas = tothit * 0.015 * franf(); | |
182 | if (cas >= 2) | 175 | if (cas >= 2) { | |
183 | { | |||
184 | printf("McCoy: we suffered %d casualties in that attack.\n", | 176 | printf("McCoy: we suffered %d casualties in that attack.\n", | |
185 | cas); | 177 | cas); | |
186 | Game.deaths += cas; | 178 | Game.deaths += cas; | |
187 | Ship.crew -= cas; | 179 | Ship.crew -= cas; | |
188 | } | 180 | } | |
189 | } | 181 | } | |
190 | 182 | |||
191 | /* allow Klingons to move after attacking */ | 183 | /* allow Klingons to move after attacking */ | |
192 | klmove(1); | 184 | klmove(1); | |
193 | 185 | |||
194 | return; | 186 | return; | |
195 | } | 187 | } |
--- src/games/trek/checkcond.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/checkcond.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: checkcond.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: checkcond.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)checkcond.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)checkcond.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: checkcond.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: checkcond.c,v 1.7 2009/05/24 21:44:56 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 | ** Check for Condition After a Move | 44 | ** Check for Condition After a Move | |
45 | ** | 45 | ** | |
46 | ** Various ship conditions are checked. First we check | 46 | ** Various ship conditions are checked. First we check | |
47 | ** to see if we have already lost the game, due to running | 47 | ** to see if we have already lost the game, due to running | |
48 | ** out of life support reserves, running out of energy, | 48 | ** out of life support reserves, running out of energy, | |
49 | ** or running out of crew members. The check for running | 49 | ** or running out of crew members. The check for running | |
50 | ** out of time is in events(). | 50 | ** out of time is in events(). | |
@@ -81,26 +81,24 @@ checkcond(void) | @@ -81,26 +81,24 @@ checkcond(void) | |||
81 | /* call in automatic override if appropriate */ | 81 | /* call in automatic override if appropriate */ | |
82 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | 82 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | |
83 | autover(); | 83 | autover(); | |
84 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | 84 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | |
85 | lose(L_SNOVA); | 85 | lose(L_SNOVA); | |
86 | /* nullify distress call if appropriate */ | 86 | /* nullify distress call if appropriate */ | |
87 | if (Etc.nkling <= 0) | 87 | if (Etc.nkling <= 0) | |
88 | killd(Ship.quadx, Ship.quady, 1); | 88 | killd(Ship.quadx, Ship.quady, 1); | |
89 | 89 | |||
90 | /* set condition code */ | 90 | /* set condition code */ | |
91 | if (Ship.cond == DOCKED) | 91 | if (Ship.cond == DOCKED) | |
92 | return; | 92 | return; | |
93 | 93 | |||
94 | if (Etc.nkling > 0) | 94 | if (Etc.nkling > 0) { | |
95 | { | |||
96 | Ship.cond = RED; | 95 | Ship.cond = RED; | |
97 | return; | 96 | return; | |
98 | } | 97 | } | |
99 | if (Ship.energy < Param.energylow) | 98 | if (Ship.energy < Param.energylow) { | |
100 | { | |||
101 | Ship.cond = YELLOW; | 99 | Ship.cond = YELLOW; | |
102 | return; | 100 | return; | |
103 | } | 101 | } | |
104 | Ship.cond = GREEN; | 102 | Ship.cond = GREEN; | |
105 | return; | 103 | return; | |
106 | } | 104 | } |
--- src/games/trek/dumpme.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/dumpme.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dumpme.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: dumpme.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)dumpme.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)dumpme.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: dumpme.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: dumpme.c,v 1.7 2009/05/24 21:44:56 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 | ** Dump the starship somewhere in the galaxy | 45 | ** Dump the starship somewhere in the galaxy | |
46 | ** | 46 | ** | |
47 | ** Parameter is zero if bounce off of negative energy barrier, | 47 | ** Parameter is zero if bounce off of negative energy barrier, | |
48 | ** one if through a black hole | 48 | ** one if through a black hole | |
49 | ** | 49 | ** | |
50 | ** Note that the quadrant is NOT initialized here. This must | 50 | ** Note that the quadrant is NOT initialized here. This must | |
@@ -58,35 +58,31 @@ dumpme(int flag) | @@ -58,35 +58,31 @@ dumpme(int flag) | |||
58 | { | 58 | { | |
59 | int f; | 59 | int f; | |
60 | double x; | 60 | double x; | |
61 | struct event *e; | 61 | struct event *e; | |
62 | int i; | 62 | int i; | |
63 | 63 | |||
64 | f = flag; | 64 | f = flag; | |
65 | Ship.quadx = ranf(NQUADS); | 65 | Ship.quadx = ranf(NQUADS); | |
66 | Ship.quady = ranf(NQUADS); | 66 | Ship.quady = ranf(NQUADS); | |
67 | Ship.sectx = ranf(NSECTS); | 67 | Ship.sectx = ranf(NSECTS); | |
68 | Ship.secty = ranf(NSECTS); | 68 | Ship.secty = ranf(NSECTS); | |
69 | x = 1.5 * franf(); | 69 | x = 1.5 * franf(); | |
70 | Move.time += x; | 70 | Move.time += x; | |
71 | if (f) | 71 | if (f) { | |
72 | { | |||
73 | printf("%s falls into a black hole.\n", Ship.shipname); | 72 | printf("%s falls into a black hole.\n", Ship.shipname); | |
74 | } | 73 | } else { | |
75 | else | |||
76 | { | |||
77 | printf("Computer applies full reverse power to avoid hitting the\n"); | 74 | printf("Computer applies full reverse power to avoid hitting the\n"); | |
78 | printf(" negative energy barrier. A space warp was entered.\n"); | 75 | printf(" negative energy barrier. A space warp was entered.\n"); | |
79 | } | 76 | } | |
80 | /* bump repair dates forward */ | 77 | /* bump repair dates forward */ | |
81 | for (i = 0; i < MAXEVENTS; i++) | 78 | for (i = 0; i < MAXEVENTS; i++) { | |
82 | { | |||
83 | e = &Event[i]; | 79 | e = &Event[i]; | |
84 | if (e->evcode != E_FIXDV) | 80 | if (e->evcode != E_FIXDV) | |
85 | continue; | 81 | continue; | |
86 | reschedule(e, (e->date - Now.date) + x); | 82 | reschedule(e, (e->date - Now.date) + x); | |
87 | } | 83 | } | |
88 | events(1); | 84 | events(1); | |
89 | printf("You are now in quadrant %d,%d. It is stardate %.2f\n", | 85 | printf("You are now in quadrant %d,%d. It is stardate %.2f\n", | |
90 | Ship.quadx, Ship.quady, Now.date); | 86 | Ship.quadx, Ship.quady, Now.date); | |
91 | Move.time = 0; | 87 | Move.time = 0; | |
92 | } | 88 | } |
--- src/games/trek/dumpssradio.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/dumpssradio.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dumpssradio.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: dumpssradio.c,v 1.7 2009/05/24 21:44:56 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,61 +24,58 @@ | @@ -24,61 +24,58 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)dumpssradio.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)dumpssradio.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: dumpssradio.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: dumpssradio.c,v 1.7 2009/05/24 21:44:56 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 | ** output hidden distress calls | 45 | ** output hidden distress calls | |
46 | **/ | 46 | **/ | |
47 | 47 | |||
48 | int | 48 | int | |
49 | dumpssradio(void) | 49 | dumpssradio(void) | |
50 | { | 50 | { | |
51 | struct event *e; | 51 | struct event *e; | |
52 | int j; | 52 | int j; | |
53 | int chkrest; | 53 | int chkrest; | |
54 | 54 | |||
55 | chkrest = 0; | 55 | chkrest = 0; | |
56 | for (j = 0; j < MAXEVENTS; j++) | 56 | for (j = 0; j < MAXEVENTS; j++) { | |
57 | { | |||
58 | e = &Event[j]; | 57 | e = &Event[j]; | |
59 | /* if it is not hidden, then just ignore it */ | 58 | /* if it is not hidden, then just ignore it */ | |
60 | if ((e->evcode & E_HIDDEN) == 0) | 59 | if ((e->evcode & E_HIDDEN) == 0) | |
61 | continue; | 60 | continue; | |
62 | if (e->evcode & E_GHOST) | 61 | if (e->evcode & E_GHOST) { | |
63 | { | |||
64 | unschedule(e); | 62 | unschedule(e); | |
65 | printf("Starsystem %s in quadrant %d,%d is no longer distressed\n", | 63 | printf("Starsystem %s in quadrant %d,%d is no longer distressed\n", | |
66 | systemname(&Quad[e->x][e->y]), e->x, e->y); | 64 | systemname(&Quad[e->x][e->y]), e->x, e->y); | |
67 | continue; | 65 | continue; | |
68 | } | 66 | } | |
69 | 67 | |||
70 | switch (e->evcode) | 68 | switch (e->evcode) { | |
71 | { | |||
72 | 69 | |||
73 | case E_KDESB: | 70 | case E_KDESB: | |
74 | printf("Starbase in quadrant %d,%d is under attack\n", | 71 | printf("Starbase in quadrant %d,%d is under attack\n", | |
75 | e->x, e->y); | 72 | e->x, e->y); | |
76 | chkrest++; | 73 | chkrest++; | |
77 | break; | 74 | break; | |
78 | 75 | |||
79 | case E_ENSLV: | 76 | case E_ENSLV: | |
80 | case E_REPRO: | 77 | case E_REPRO: | |
81 | printf("Starsystem %s in quadrant %d,%d is distressed\n", | 78 | printf("Starsystem %s in quadrant %d,%d is distressed\n", | |
82 | systemname(&Quad[e->x][e->y]), e->x, e->y); | 79 | systemname(&Quad[e->x][e->y]), e->x, e->y); | |
83 | chkrest++; | 80 | chkrest++; | |
84 | break; | 81 | break; |
--- src/games/trek/initquad.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/initquad.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: initquad.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: initquad.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)initquad.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)initquad.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: initquad.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: initquad.c,v 1.7 2009/05/24 21:44:56 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 | ** Paramize Quadrant Upon Entering | 45 | ** Paramize Quadrant Upon Entering | |
46 | ** | 46 | ** | |
47 | ** A quadrant is initialized from the information held in the | 47 | ** A quadrant is initialized from the information held in the | |
48 | ** Quad matrix. Basically, everything is just initialized | 48 | ** Quad matrix. Basically, everything is just initialized | |
49 | ** randomly, except for the starship, which goes into a fixed | 49 | ** randomly, except for the starship, which goes into a fixed | |
50 | ** sector. | 50 | ** sector. | |
@@ -68,89 +68,82 @@ initquad(int f) | @@ -68,89 +68,82 @@ initquad(int f) | |||
68 | int nholes; | 68 | int nholes; | |
69 | 69 | |||
70 | q = &Quad[Ship.quadx][Ship.quady]; | 70 | q = &Quad[Ship.quadx][Ship.quady]; | |
71 | 71 | |||
72 | /* ignored supernova'ed quadrants (this is checked again later anyway */ | 72 | /* ignored supernova'ed quadrants (this is checked again later anyway */ | |
73 | if (q->stars < 0) | 73 | if (q->stars < 0) | |
74 | return; | 74 | return; | |
75 | Etc.nkling = q->klings; | 75 | Etc.nkling = q->klings; | |
76 | nbases = q->bases; | 76 | nbases = q->bases; | |
77 | nstars = q->stars; | 77 | nstars = q->stars; | |
78 | nholes = q->holes; | 78 | nholes = q->holes; | |
79 | 79 | |||
80 | /* have we blundered into a battle zone w/ shields down? */ | 80 | /* have we blundered into a battle zone w/ shields down? */ | |
81 | if (Etc.nkling > 0 && !f) | 81 | if (Etc.nkling > 0 && !f) { | |
82 | { | |||
83 | printf("Condition RED\n"); | 82 | printf("Condition RED\n"); | |
84 | Ship.cond = RED; | 83 | Ship.cond = RED; | |
85 | if (!damaged(COMPUTER)) | 84 | if (!damaged(COMPUTER)) | |
86 | shield(1); | 85 | shield(1); | |
87 | } | 86 | } | |
88 | 87 | |||
89 | /* clear out the quadrant */ | 88 | /* clear out the quadrant */ | |
90 | for (i = 0; i < NSECTS; i++) | 89 | for (i = 0; i < NSECTS; i++) | |
91 | for (j = 0; j < NSECTS; j++) | 90 | for (j = 0; j < NSECTS; j++) | |
92 | Sect[i][j] = EMPTY; | 91 | Sect[i][j] = EMPTY; | |
93 | 92 | |||
94 | /* initialize Enterprise */ | 93 | /* initialize Enterprise */ | |
95 | Sect[Ship.sectx][Ship.secty] = Ship.ship; | 94 | Sect[Ship.sectx][Ship.secty] = Ship.ship; | |
96 | 95 | |||
97 | /* initialize Klingons */ | 96 | /* initialize Klingons */ | |
98 | for (i = 0; i < Etc.nkling; i++) | 97 | for (i = 0; i < Etc.nkling; i++) { | |
99 | { | |||
100 | sector(&rx, &ry); | 98 | sector(&rx, &ry); | |
101 | Sect[rx][ry] = KLINGON; | 99 | Sect[rx][ry] = KLINGON; | |
102 | Etc.klingon[i].x = rx; | 100 | Etc.klingon[i].x = rx; | |
103 | Etc.klingon[i].y = ry; | 101 | Etc.klingon[i].y = ry; | |
104 | Etc.klingon[i].power = Param.klingpwr; | 102 | Etc.klingon[i].power = Param.klingpwr; | |
105 | Etc.klingon[i].srndreq = 0; | 103 | Etc.klingon[i].srndreq = 0; | |
106 | } | 104 | } | |
107 | compkldist(1); | 105 | compkldist(1); | |
108 | 106 | |||
109 | /* initialize star base */ | 107 | /* initialize star base */ | |
110 | if (nbases > 0) | 108 | if (nbases > 0) { | |
111 | { | |||
112 | sector(&rx, &ry); | 109 | sector(&rx, &ry); | |
113 | Sect[rx][ry] = BASE; | 110 | Sect[rx][ry] = BASE; | |
114 | Etc.starbase.x = rx; | 111 | Etc.starbase.x = rx; | |
115 | Etc.starbase.y = ry; | 112 | Etc.starbase.y = ry; | |
116 | } | 113 | } | |
117 | 114 | |||
118 | /* initialize inhabited starsystem */ | 115 | /* initialize inhabited starsystem */ | |
119 | if (q->qsystemname != 0) | 116 | if (q->qsystemname != 0) { | |
120 | { | |||
121 | sector(&rx, &ry); | 117 | sector(&rx, &ry); | |
122 | Sect[rx][ry] = INHABIT; | 118 | Sect[rx][ry] = INHABIT; | |
123 | nstars -= 1; | 119 | nstars -= 1; | |
124 | } | 120 | } | |
125 | 121 | |||
126 | /* initialize black holes */ | 122 | /* initialize black holes */ | |
127 | for (i = 0; i < nholes; i++) | 123 | for (i = 0; i < nholes; i++) { | |
128 | { | |||
129 | sector(&rx, &ry); | 124 | sector(&rx, &ry); | |
130 | Sect[rx][ry] = HOLE; | 125 | Sect[rx][ry] = HOLE; | |
131 | } | 126 | } | |
132 | 127 | |||
133 | /* initialize stars */ | 128 | /* initialize stars */ | |
134 | for (i = 0; i < nstars; i++) | 129 | for (i = 0; i < nstars; i++) { | |
135 | { | |||
136 | sector(&rx, &ry); | 130 | sector(&rx, &ry); | |
137 | Sect[rx][ry] = STAR; | 131 | Sect[rx][ry] = STAR; | |
138 | } | 132 | } | |
139 | Move.newquad = 1; | 133 | Move.newquad = 1; | |
140 | } | 134 | } | |
141 | 135 | |||
142 | 136 | |||
143 | void | 137 | void | |
144 | sector(int *x, int *y) | 138 | sector(int *x, int *y) | |
145 | { | 139 | { | |
146 | int i, j; | 140 | int i, j; | |
147 | 141 | |||
148 | do | 142 | do { | |
149 | { | |||
150 | i = ranf(NSECTS); | 143 | i = ranf(NSECTS); | |
151 | j = ranf(NSECTS); | 144 | j = ranf(NSECTS); | |
152 | } while (Sect[i][j] != EMPTY); | 145 | } while (Sect[i][j] != EMPTY); | |
153 | *x = i; | 146 | *x = i; | |
154 | *y = j; | 147 | *y = j; | |
155 | return; | 148 | return; | |
156 | } | 149 | } |
--- src/games/trek/ram.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/ram.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ram.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: ram.c,v 1.7 2009/05/24 21:44:56 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,55 +24,54 @@ | @@ -24,55 +24,54 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)ram.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)ram.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: ram.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: ram.c,v 1.7 2009/05/24 21:44:56 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 <unistd.h> | 42 | #include <unistd.h> | |
43 | #include "trek.h" | 43 | #include "trek.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** RAM SOME OBJECT | 46 | ** RAM SOME OBJECT | |
47 | ** | 47 | ** | |
48 | ** You have run into some sort of object. It may be a Klingon, | 48 | ** You have run into some sort of object. It may be a Klingon, | |
49 | ** a star, or a starbase. If you run into a star, you are really | 49 | ** a star, or a starbase. If you run into a star, you are really | |
50 | ** stupid, because there is no hope for you. | 50 | ** stupid, because there is no hope for you. | |
51 | ** | 51 | ** | |
52 | ** If you run into something else, you destroy that object. You | 52 | ** If you run into something else, you destroy that object. You | |
53 | ** also rack up incredible damages. | 53 | ** also rack up incredible damages. | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | void | 56 | void | |
57 | ram(int ix, int iy) | 57 | ram(int ix, int iy) | |
58 | { | 58 | { | |
59 | int i; | 59 | int i; | |
60 | char c; | 60 | char c; | |
61 | 61 | |||
62 | printf("\07RED ALERT\07: collision imminent\n"); | 62 | printf("\07RED ALERT\07: collision imminent\n"); | |
63 | c = Sect[ix][iy]; | 63 | c = Sect[ix][iy]; | |
64 | switch (c) | 64 | switch (c) { | |
65 | { | |||
66 | 65 | |||
67 | case KLINGON: | 66 | case KLINGON: | |
68 | printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy); | 67 | printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy); | |
69 | killk(ix, iy); | 68 | killk(ix, iy); | |
70 | break; | 69 | break; | |
71 | 70 | |||
72 | case STAR: | 71 | case STAR: | |
73 | case INHABIT: | 72 | case INHABIT: | |
74 | printf("Yeoman Rand: Captain, isn't it getting hot in here?\n"); | 73 | printf("Yeoman Rand: Captain, isn't it getting hot in here?\n"); | |
75 | sleep(2); | 74 | sleep(2); | |
76 | printf("Spock: Hull temperature approaching 550 Degrees Kelvin.\n"); | 75 | printf("Spock: Hull temperature approaching 550 Degrees Kelvin.\n"); | |
77 | lose(L_STAR); | 76 | lose(L_STAR); | |
78 | 77 | |||
@@ -84,23 +83,22 @@ ram(int ix, int iy) | @@ -84,23 +83,22 @@ ram(int ix, int iy) | |||
84 | Game.killb += 1; | 83 | Game.killb += 1; | |
85 | break; | 84 | break; | |
86 | } | 85 | } | |
87 | sleep(2); | 86 | sleep(2); | |
88 | printf("%s heavily damaged\n", Ship.shipname); | 87 | printf("%s heavily damaged\n", Ship.shipname); | |
89 | 88 | |||
90 | /* select the number of deaths to occur */ | 89 | /* select the number of deaths to occur */ | |
91 | i = 10 + ranf(20 * Game.skill); | 90 | i = 10 + ranf(20 * Game.skill); | |
92 | Game.deaths += i; | 91 | Game.deaths += i; | |
93 | Ship.crew -= i; | 92 | Ship.crew -= i; | |
94 | printf("McCoy: Take it easy Jim; we had %d casualties.\n", i); | 93 | printf("McCoy: Take it easy Jim; we had %d casualties.\n", i); | |
95 | 94 | |||
96 | /* damage devices with an 80% probability */ | 95 | /* damage devices with an 80% probability */ | |
97 | for (i = 0; i < NDEV; i++) | 96 | for (i = 0; i < NDEV; i++) { | |
98 | { | |||
99 | if (ranf(100) < 20) | 97 | if (ranf(100) < 20) | |
100 | continue; | 98 | continue; | |
101 | damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]); | 99 | damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]); | |
102 | } | 100 | } | |
103 | 101 | |||
104 | /* no chance that your shields remained up in all that */ | 102 | /* no chance that your shields remained up in all that */ | |
105 | Ship.shldup = 0; | 103 | Ship.shldup = 0; | |
106 | } | 104 | } |
--- src/games/trek/score.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/score.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: score.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: score.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: score.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: score.c,v 1.7 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** PRINT OUT THE CURRENT SCORE | 46 | ** PRINT OUT THE CURRENT SCORE | |
47 | */ | 47 | */ | |
48 | 48 | |||
49 | long | 49 | long | |
50 | score(void) | 50 | score(void) | |
@@ -60,49 +60,46 @@ score(void) | @@ -60,49 +60,46 @@ score(void) | |||
60 | printf("%d Klingons killed\t\t\t%6d\n", u, t); | 60 | printf("%d Klingons killed\t\t\t%6d\n", u, t); | |
61 | r = Now.date - Param.date; | 61 | r = Now.date - Param.date; | |
62 | if (r < 1.0) | 62 | if (r < 1.0) | |
63 | r = 1.0; | 63 | r = 1.0; | |
64 | r = Game.killk / r; | 64 | r = Game.killk / r; | |
65 | s += (t = 400 * r); | 65 | s += (t = 400 * r); | |
66 | if (t != 0) | 66 | if (t != 0) | |
67 | printf("Kill rate %.2f Klingons/stardate \t%6d\n", r, t); | 67 | printf("Kill rate %.2f Klingons/stardate \t%6d\n", r, t); | |
68 | r = Now.klings; | 68 | r = Now.klings; | |
69 | r /= Game.killk + 1; | 69 | r /= Game.killk + 1; | |
70 | s += (t = -400 * r); | 70 | s += (t = -400 * r); | |
71 | if (t != 0) | 71 | if (t != 0) | |
72 | printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t); | 72 | printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t); | |
73 | if (Move.endgame > 0) | 73 | if (Move.endgame > 0) { | |
74 | { | |||
75 | s += (t = 100 * (u = Game.skill)); | 74 | s += (t = 100 * (u = Game.skill)); | |
76 | printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t); | 75 | printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t); | |
77 | } | 76 | } | |
78 | if (Game.killed) | 77 | if (Game.killed) { | |
79 | { | |||
80 | s -= 500; | 78 | s -= 500; | |
81 | printf("Penalty for getting killed\t\t -500\n"); | 79 | printf("Penalty for getting killed\t\t -500\n"); | |
82 | } | 80 | } | |
83 | s += (t = -100 * (u = Game.killb)); | 81 | s += (t = -100 * (u = Game.killb)); | |
84 | if (t != 0) | 82 | if (t != 0) | |
85 | printf("%d starbases killed\t\t\t%6d\n", u, t); | 83 | printf("%d starbases killed\t\t\t%6d\n", u, t); | |
86 | s += (t = -100 * (u = Game.helps)); | 84 | s += (t = -100 * (u = Game.helps)); | |
87 | if (t != 0) | 85 | if (t != 0) | |
88 | printf("%d calls for help\t\t\t%6d\n", u, t); | 86 | printf("%d calls for help\t\t\t%6d\n", u, t); | |
89 | s += (t = -5 * (u = Game.kills)); | 87 | s += (t = -5 * (u = Game.kills)); | |
90 | if (t != 0) | 88 | if (t != 0) | |
91 | printf("%d stars destroyed\t\t\t%6d\n", u, t); | 89 | printf("%d stars destroyed\t\t\t%6d\n", u, t); | |
92 | s += (t = -150 * (u = Game.killinhab)); | 90 | s += (t = -150 * (u = Game.killinhab)); | |
93 | if (t != 0) | 91 | if (t != 0) | |
94 | printf("%d inhabited starsystems destroyed\t%6d\n", u, t); | 92 | printf("%d inhabited starsystems destroyed\t%6d\n", u, t); | |
95 | if (Ship.ship != ENTERPRISE) | 93 | if (Ship.ship != ENTERPRISE) { | |
96 | { | |||
97 | s -= 200; | 94 | s -= 200; | |
98 | printf("penalty for abandoning ship\t\t -200\n"); | 95 | printf("penalty for abandoning ship\t\t -200\n"); | |
99 | } | 96 | } | |
100 | s += (t = 3 * (u = Game.captives)); | 97 | s += (t = 3 * (u = Game.captives)); | |
101 | if (t != 0) | 98 | if (t != 0) | |
102 | printf("%d Klingons captured\t\t\t%6d\n", u, t); | 99 | printf("%d Klingons captured\t\t\t%6d\n", u, t); | |
103 | s += (t = -(u = Game.deaths)); | 100 | s += (t = -(u = Game.deaths)); | |
104 | if (t != 0) | 101 | if (t != 0) | |
105 | printf("%d casualties\t\t\t\t%6d\n", u, t); | 102 | printf("%d casualties\t\t\t\t%6d\n", u, t); | |
106 | printf("\n*** TOTAL\t\t\t%14ld\n", s); | 103 | printf("\n*** TOTAL\t\t\t%14ld\n", s); | |
107 | return (s); | 104 | return (s); | |
108 | } | 105 | } |
--- src/games/trek/snova.c 2009/05/24 19:18:44 1.6
+++ src/games/trek/snova.c 2009/05/24 21:44:56 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: snova.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: snova.c,v 1.7 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)snova.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)snova.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: snova.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: snova.c,v 1.7 2009/05/24 21:44:56 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 <unistd.h> | 42 | #include <unistd.h> | |
43 | #include "trek.h" | 43 | #include "trek.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** CAUSE SUPERNOVA TO OCCUR | 46 | ** CAUSE SUPERNOVA TO OCCUR | |
47 | ** | 47 | ** | |
48 | ** A supernova occurs. If 'ix' < 0, a random quadrant is chosen; | 48 | ** A supernova occurs. If 'ix' < 0, a random quadrant is chosen; | |
49 | ** otherwise, the current quadrant is taken, and (ix, iy) give | 49 | ** otherwise, the current quadrant is taken, and (ix, iy) give | |
50 | ** the sector quadrants of the star which is blowing up. | 50 | ** the sector quadrants of the star which is blowing up. | |
@@ -65,99 +65,86 @@ __RCSID("$NetBSD: snova.c,v 1.6 2009/05/ | @@ -65,99 +65,86 @@ __RCSID("$NetBSD: snova.c,v 1.6 2009/05/ | |||
65 | 65 | |||
66 | void | 66 | void | |
67 | snova(int x, int y) | 67 | snova(int x, int y) | |
68 | { | 68 | { | |
69 | int qx, qy; | 69 | int qx, qy; | |
70 | int ix, iy = 0; | 70 | int ix, iy = 0; | |
71 | int f; | 71 | int f; | |
72 | int dx, dy; | 72 | int dx, dy; | |
73 | int n; | 73 | int n; | |
74 | struct quad *q; | 74 | struct quad *q; | |
75 | 75 | |||
76 | f = 0; | 76 | f = 0; | |
77 | ix = x; | 77 | ix = x; | |
78 | if (ix < 0) | 78 | if (ix < 0) { | |
79 | { | |||
80 | /* choose a quadrant */ | 79 | /* choose a quadrant */ | |
81 | while (1) | 80 | while (1) { | |
82 | { | |||
83 | qx = ranf(NQUADS); | 81 | qx = ranf(NQUADS); | |
84 | qy = ranf(NQUADS); | 82 | qy = ranf(NQUADS); | |
85 | q = &Quad[qx][qy]; | 83 | q = &Quad[qx][qy]; | |
86 | if (q->stars > 0) | 84 | if (q->stars > 0) | |
87 | break; | 85 | break; | |
88 | } | 86 | } | |
89 | if (Ship.quadx == qx && Ship.quady == qy) | 87 | if (Ship.quadx == qx && Ship.quady == qy) { | |
90 | { | |||
91 | /* select a particular star */ | 88 | /* select a particular star */ | |
92 | n = ranf(q->stars); | 89 | n = ranf(q->stars); | |
93 | for (ix = 0; ix < NSECTS; ix++) | 90 | for (ix = 0; ix < NSECTS; ix++) { | |
94 | { | |||
95 | for (iy = 0; iy < NSECTS; iy++) | 91 | for (iy = 0; iy < NSECTS; iy++) | |
96 | if (Sect[ix][iy] == STAR || Sect[ix][iy] == INHABIT) | 92 | if (Sect[ix][iy] == STAR || Sect[ix][iy] == INHABIT) | |
97 | if ((n -= 1) <= 0) | 93 | if ((n -= 1) <= 0) | |
98 | break; | 94 | break; | |
99 | if (n <= 0) | 95 | if (n <= 0) | |
100 | break; | 96 | break; | |
101 | } | 97 | } | |
102 | f = 1; | 98 | f = 1; | |
103 | } | 99 | } | |
104 | } | 100 | } else { | |
105 | else | |||
106 | { | |||
107 | /* current quadrant */ | 101 | /* current quadrant */ | |
108 | iy = y; | 102 | iy = y; | |
109 | qx = Ship.quadx; | 103 | qx = Ship.quadx; | |
110 | qy = Ship.quady; | 104 | qy = Ship.quady; | |
111 | q = &Quad[qx][qy]; | 105 | q = &Quad[qx][qy]; | |
112 | f = 1; | 106 | f = 1; | |
113 | } | 107 | } | |
114 | if (f) | 108 | if (f) { | |
115 | { | |||
116 | /* supernova is in same quadrant as Enterprise */ | 109 | /* supernova is in same quadrant as Enterprise */ | |
117 | printf("\nRED ALERT: supernova occuring at %d,%d\n", ix, iy); | 110 | printf("\nRED ALERT: supernova occuring at %d,%d\n", ix, iy); | |
118 | dx = ix - Ship.sectx; | 111 | dx = ix - Ship.sectx; | |
119 | dy = iy - Ship.secty; | 112 | dy = iy - Ship.secty; | |
120 | if (dx * dx + dy * dy <= 2) | 113 | if (dx * dx + dy * dy <= 2) { | |
121 | { | |||
122 | printf("*** Emergency override attem"); | 114 | printf("*** Emergency override attem"); | |
123 | sleep(1); | 115 | sleep(1); | |
124 | printf("\n"); | 116 | printf("\n"); | |
125 | lose(L_SNOVA); | 117 | lose(L_SNOVA); | |
126 | } | 118 | } | |
127 | q->scanned = 1000; | 119 | q->scanned = 1000; | |
128 | } | 120 | } else { | |
129 | else | 121 | if (!damaged(SSRADIO)) { | |
130 | { | |||
131 | if (!damaged(SSRADIO)) | |||
132 | { | |||
133 | q->scanned = 1000; | 122 | q->scanned = 1000; | |
134 | printf("\nUhura: Captain, Starfleet Command reports a supernova\n"); | 123 | printf("\nUhura: Captain, Starfleet Command reports a supernova\n"); | |
135 | printf(" in quadrant %d,%d. Caution is advised\n", qx, qy); | 124 | printf(" in quadrant %d,%d. Caution is advised\n", qx, qy); | |
136 | } | 125 | } | |
137 | } | 126 | } | |
138 | 127 | |||
139 | /* clear out the supernova'ed quadrant */ | 128 | /* clear out the supernova'ed quadrant */ | |
140 | dx = q->klings; | 129 | dx = q->klings; | |
141 | dy = q->stars; | 130 | dy = q->stars; | |
142 | Now.klings -= dx; | 131 | Now.klings -= dx; | |
143 | if (x >= 0) | 132 | if (x >= 0) { | |
144 | { | |||
145 | /* Enterprise caused supernova */ | 133 | /* Enterprise caused supernova */ | |
146 | Game.kills += dy; | 134 | Game.kills += dy; | |
147 | if (q->bases) | 135 | if (q->bases) | |
148 | killb(qx, qy); | 136 | killb(qx, qy); | |
149 | Game.killk += dx; | 137 | Game.killk += dx; | |
150 | } | 138 | } else { | |
151 | else | |||
152 | if (q->bases) | 139 | if (q->bases) | |
153 | killb(qx, qy); | 140 | killb(qx, qy); | |
141 | } | |||
154 | killd(qx, qy, (x >= 0)); | 142 | killd(qx, qy, (x >= 0)); | |
155 | q->stars = -1; | 143 | q->stars = -1; | |
156 | q->klings = 0; | 144 | q->klings = 0; | |
157 | if (Now.klings <= 0) | 145 | if (Now.klings <= 0) { | |
158 | { | |||
159 | printf("Lucky devil, that supernova destroyed the last klingon\n"); | 146 | printf("Lucky devil, that supernova destroyed the last klingon\n"); | |
160 | win(); | 147 | win(); | |
161 | } | 148 | } | |
162 | return; | 149 | return; | |
163 | } | 150 | } |
--- src/games/trek/capture.c 2009/05/24 20:39:43 1.9
+++ src/games/trek/capture.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: capture.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: capture.c,v 1.10 2009/05/24 21:44:56 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 | |
@@ -54,60 +54,57 @@ __RCSID("$NetBSD: capture.c,v 1.9 2009/0 | @@ -54,60 +54,57 @@ __RCSID("$NetBSD: capture.c,v 1.9 2009/0 | |||
54 | ** is a function of that Klingon's remaining power, our power, | 54 | ** is a function of that Klingon's remaining power, our power, | |
55 | ** etc. | 55 | ** etc. | |
56 | */ | 56 | */ | |
57 | 57 | |||
58 | /*ARGSUSED*/ | 58 | /*ARGSUSED*/ | |
59 | void | 59 | void | |
60 | capture(int v __unused) | 60 | capture(int v __unused) | |
61 | { | 61 | { | |
62 | int i; | 62 | int i; | |
63 | struct kling *k; | 63 | struct kling *k; | |
64 | double x; | 64 | double x; | |
65 | 65 | |||
66 | /* check for not cloaked */ | 66 | /* check for not cloaked */ | |
67 | if (Ship.cloaked) | 67 | if (Ship.cloaked) { | |
68 | { | |||
69 | printf("Ship-ship communications out when cloaked\n"); | 68 | printf("Ship-ship communications out when cloaked\n"); | |
70 | return; | 69 | return; | |
71 | } | 70 | } | |
72 | if (damaged(SSRADIO)) { | 71 | if (damaged(SSRADIO)) { | |
73 | out(SSRADIO); | 72 | out(SSRADIO); | |
74 | return; | 73 | return; | |
75 | } | 74 | } | |
76 | /* find out if there are any at all */ | 75 | /* find out if there are any at all */ | |
77 | if (Etc.nkling <= 0) | 76 | if (Etc.nkling <= 0) { | |
78 | { | |||
79 | printf("Uhura: Getting no response, sir\n"); | 77 | printf("Uhura: Getting no response, sir\n"); | |
80 | return; | 78 | return; | |
81 | } | 79 | } | |
82 | 80 | |||
83 | /* if there is more than one Klingon, find out which one */ | 81 | /* if there is more than one Klingon, find out which one */ | |
84 | k = selectklingon(); | 82 | k = selectklingon(); | |
85 | Move.free = 0; | 83 | Move.free = 0; | |
86 | Move.time = 0.05; | 84 | Move.time = 0.05; | |
87 | 85 | |||
88 | /* check out that Klingon */ | 86 | /* check out that Klingon */ | |
89 | k->srndreq++; | 87 | k->srndreq++; | |
90 | x = Param.klingpwr; | 88 | x = Param.klingpwr; | |
91 | x *= Ship.energy; | 89 | x *= Ship.energy; | |
92 | x /= k->power * Etc.nkling; | 90 | x /= k->power * Etc.nkling; | |
93 | x *= Param.srndrprob; | 91 | x *= Param.srndrprob; | |
94 | i = x; | 92 | i = x; | |
95 | #ifdef xTRACE | 93 | #ifdef xTRACE | |
96 | if (Trace) | 94 | if (Trace) | |
97 | printf("Prob = %d (%.4f)\n", i, x); | 95 | printf("Prob = %d (%.4f)\n", i, x); | |
98 | #endif | 96 | #endif | |
99 | if (i > ranf(100)) | 97 | if (i > ranf(100)) { | |
100 | { | |||
101 | /* guess what, he surrendered!!! */ | 98 | /* guess what, he surrendered!!! */ | |
102 | printf("Klingon at %d,%d surrenders\n", k->x, k->y); | 99 | printf("Klingon at %d,%d surrenders\n", k->x, k->y); | |
103 | i = ranf(Param.klingcrew); | 100 | i = ranf(Param.klingcrew); | |
104 | if ( i > 0 ) | 101 | if ( i > 0 ) | |
105 | printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i); | 102 | printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i); | |
106 | if (i > Ship.brigfree) | 103 | if (i > Ship.brigfree) | |
107 | i = Ship.brigfree; | 104 | i = Ship.brigfree; | |
108 | Ship.brigfree -= i; | 105 | Ship.brigfree -= i; | |
109 | printf("%d captives taken\n", i); | 106 | printf("%d captives taken\n", i); | |
110 | killk(k->x, k->y); | 107 | killk(k->x, k->y); | |
111 | return; | 108 | return; | |
112 | } | 109 | } | |
113 | 110 |
--- src/games/trek/destruct.c 2009/05/24 19:18:44 1.9
+++ src/games/trek/destruct.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: destruct.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: destruct.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: destruct.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: destruct.c,v 1.10 2009/05/24 21:44:56 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 <unistd.h> | 43 | #include <unistd.h> | |
44 | #include "trek.h" | 44 | #include "trek.h" | |
45 | #include "getpar.h" | 45 | #include "getpar.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** Self Destruct Sequence | 48 | ** Self Destruct Sequence | |
49 | ** | 49 | ** | |
50 | ** The computer starts up the self destruct sequence. Obviously, | 50 | ** The computer starts up the self destruct sequence. Obviously, | |
@@ -69,55 +69,52 @@ void | @@ -69,55 +69,52 @@ void | |||
69 | destruct(int v __unused) | 69 | destruct(int v __unused) | |
70 | { | 70 | { | |
71 | char checkpass[15]; | 71 | char checkpass[15]; | |
72 | int i, j; | 72 | int i, j; | |
73 | double zap; | 73 | double zap; | |
74 | 74 | |||
75 | if (damaged(COMPUTER)) { | 75 | if (damaged(COMPUTER)) { | |
76 | out(COMPUTER); | 76 | out(COMPUTER); | |
77 | return; | 77 | return; | |
78 | } | 78 | } | |
79 | printf("\n\07 --- WORKING ---\07\n"); | 79 | printf("\n\07 --- WORKING ---\07\n"); | |
80 | sleep(3); | 80 | sleep(3); | |
81 | /* output the count 10 9 8 7 6 */ | 81 | /* output the count 10 9 8 7 6 */ | |
82 | for (i = 10; i > 5; i--) | 82 | for (i = 10; i > 5; i--) { | |
83 | { | |||
84 | for (j = 10; j > i; j--) | 83 | for (j = 10; j > i; j--) | |
85 | printf(" "); | 84 | printf(" "); | |
86 | printf("%d\n", i); | 85 | printf("%d\n", i); | |
87 | sleep(1); | 86 | sleep(1); | |
88 | } | 87 | } | |
89 | /* check for password on new line only */ | 88 | /* check for password on new line only */ | |
90 | skiptonl(0); | 89 | skiptonl(0); | |
91 | getstrpar("Enter password verification", checkpass, 14, 0); | 90 | getstrpar("Enter password verification", checkpass, 14, 0); | |
92 | sleep(2); | 91 | sleep(2); | |
93 | if (strcmp(checkpass, Game.passwd) != 0) { | 92 | if (strcmp(checkpass, Game.passwd) != 0) { | |
94 | printf("Self destruct sequence aborted\n"); | 93 | printf("Self destruct sequence aborted\n"); | |
95 | return; | 94 | return; | |
96 | } | 95 | } | |
97 | printf("Password verified; self destruct sequence continues:\n"); | 96 | printf("Password verified; self destruct sequence continues:\n"); | |
98 | sleep(2); | 97 | sleep(2); | |
99 | /* output count 5 4 3 2 1 0 */ | 98 | /* output count 5 4 3 2 1 0 */ | |
100 | for (i = 5; i >= 0; i--) | 99 | for (i = 5; i >= 0; i--) { | |
101 | { | |||
102 | sleep(1); | 100 | sleep(1); | |
103 | for (j = 5; j > i; j--) | 101 | for (j = 5; j > i; j--) | |
104 | printf(" "); | 102 | printf(" "); | |
105 | printf("%d\n", i); | 103 | printf("%d\n", i); | |
106 | } | 104 | } | |
107 | sleep(2); | 105 | sleep(2); | |
108 | printf("\032\014***** %s destroyed *****\n", Ship.shipname); | 106 | printf("\032\014***** %s destroyed *****\n", Ship.shipname); | |
109 | Game.killed = 1; | 107 | Game.killed = 1; | |
110 | /* let's see what we can blow up!!!! */ | 108 | /* let's see what we can blow up!!!! */ | |
111 | zap = 20.0 * Ship.energy; | 109 | zap = 20.0 * Ship.energy; | |
112 | Game.deaths += Ship.crew; | 110 | Game.deaths += Ship.crew; | |
113 | for (i = 0; i < Etc.nkling; ) | 111 | for (i = 0; i < Etc.nkling; ) { | |
114 | { | |||
115 | if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap) | 112 | if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap) | |
116 | killk(Etc.klingon[i].x, Etc.klingon[i].y); | 113 | killk(Etc.klingon[i].x, Etc.klingon[i].y); | |
117 | else | 114 | else | |
118 | i++; | 115 | i++; | |
119 | } | 116 | } | |
120 | /* if we didn't kill the last Klingon (detected by killk), */ | 117 | /* if we didn't kill the last Klingon (detected by killk), */ | |
121 | /* then we lose.... */ | 118 | /* then we lose.... */ | |
122 | lose(L_DSTRCT); | 119 | lose(L_DSTRCT); | |
123 | } | 120 | } |
--- src/games/trek/events.c 2009/05/24 20:39:43 1.9
+++ src/games/trek/events.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: events.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: events.c,v 1.10 2009/05/24 21:44:56 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 | |
@@ -62,58 +62,54 @@ events(int timewarp) | @@ -62,58 +62,54 @@ events(int timewarp) | |||
62 | int j = 0; | 62 | int j = 0; | |
63 | struct kling *k; | 63 | struct kling *k; | |
64 | double rtime; | 64 | double rtime; | |
65 | double xdate; | 65 | double xdate; | |
66 | double idate; | 66 | double idate; | |
67 | struct event *ev = NULL; | 67 | struct event *ev = NULL; | |
68 | int ix, iy; | 68 | int ix, iy; | |
69 | struct quad *q; | 69 | struct quad *q; | |
70 | struct event *e; | 70 | struct event *e; | |
71 | int evnum; | 71 | int evnum; | |
72 | int restcancel; | 72 | int restcancel; | |
73 | 73 | |||
74 | /* if nothing happened, just allow for any Klingons killed */ | 74 | /* if nothing happened, just allow for any Klingons killed */ | |
75 | if (Move.time <= 0.0) | 75 | if (Move.time <= 0.0) { | |
76 | { | |||
77 | Now.time = Now.resource / Now.klings; | 76 | Now.time = Now.resource / Now.klings; | |
78 | return (0); | 77 | return (0); | |
79 | } | 78 | } | |
80 | 79 | |||
81 | /* indicate that the cloaking device is now working */ | 80 | /* indicate that the cloaking device is now working */ | |
82 | Ship.cloakgood = 1; | 81 | Ship.cloakgood = 1; | |
83 | 82 | |||
84 | /* idate is the initial date */ | 83 | /* idate is the initial date */ | |
85 | idate = Now.date; | 84 | idate = Now.date; | |
86 | 85 | |||
87 | /* schedule attacks if resting too long */ | 86 | /* schedule attacks if resting too long */ | |
88 | if (Move.time > 0.5 && Move.resting) | 87 | if (Move.time > 0.5 && Move.resting) | |
89 | schedule(E_ATTACK, 0.5, 0, 0, 0); | 88 | schedule(E_ATTACK, 0.5, 0, 0, 0); | |
90 | 89 | |||
91 | /* scan the event list */ | 90 | /* scan the event list */ | |
92 | while (1) | 91 | while (1) { | |
93 | { | |||
94 | restcancel = 0; | 92 | restcancel = 0; | |
95 | evnum = -1; | 93 | evnum = -1; | |
96 | /* xdate is the date of the current event */ | 94 | /* xdate is the date of the current event */ | |
97 | xdate = idate + Move.time; | 95 | xdate = idate + Move.time; | |
98 | 96 | |||
99 | /* find the first event that has happened */ | 97 | /* find the first event that has happened */ | |
100 | for (i = 0; i < MAXEVENTS; i++) | 98 | for (i = 0; i < MAXEVENTS; i++) { | |
101 | { | |||
102 | e = &Event[i]; | 99 | e = &Event[i]; | |
103 | if (e->evcode == 0 || (e->evcode & E_GHOST)) | 100 | if (e->evcode == 0 || (e->evcode & E_GHOST)) | |
104 | continue; | 101 | continue; | |
105 | if (e->date < xdate) | 102 | if (e->date < xdate) { | |
106 | { | |||
107 | xdate = e->date; | 103 | xdate = e->date; | |
108 | ev = e; | 104 | ev = e; | |
109 | evnum = i; | 105 | evnum = i; | |
110 | } | 106 | } | |
111 | } | 107 | } | |
112 | e = ev; | 108 | e = ev; | |
113 | 109 | |||
114 | /* find the time between events */ | 110 | /* find the time between events */ | |
115 | rtime = xdate - Now.date; | 111 | rtime = xdate - Now.date; | |
116 | 112 | |||
117 | /* decrement the magic "Federation Resources" pseudo-variable */ | 113 | /* decrement the magic "Federation Resources" pseudo-variable */ | |
118 | Now.resource -= Now.klings * rtime; | 114 | Now.resource -= Now.klings * rtime; | |
119 | /* and recompute the time left */ | 115 | /* and recompute the time left */ | |
@@ -126,48 +122,44 @@ events(int timewarp) | @@ -126,48 +122,44 @@ events(int timewarp) | |||
126 | if (Now.time <= 0.0) | 122 | if (Now.time <= 0.0) | |
127 | lose(L_NOTIME); | 123 | lose(L_NOTIME); | |
128 | #ifdef xTRACE | 124 | #ifdef xTRACE | |
129 | if (evnum >= 0 && Trace) | 125 | if (evnum >= 0 && Trace) | |
130 | printf("xdate = %.2f, evcode %d params %d %d %d\n", | 126 | printf("xdate = %.2f, evcode %d params %d %d %d\n", | |
131 | xdate, e->evcode, e->x, e->y, e->systemname); | 127 | xdate, e->evcode, e->x, e->y, e->systemname); | |
132 | #endif | 128 | #endif | |
133 | 129 | |||
134 | /* if evnum < 0, no events occurred */ | 130 | /* if evnum < 0, no events occurred */ | |
135 | if (evnum < 0) | 131 | if (evnum < 0) | |
136 | break; | 132 | break; | |
137 | 133 | |||
138 | /* otherwise one did. Find out what it is */ | 134 | /* otherwise one did. Find out what it is */ | |
139 | switch (e->evcode & E_EVENT) | 135 | switch (e->evcode & E_EVENT) { | |
140 | { | |||
141 | 136 | |||
142 | case E_SNOVA: /* supernova */ | 137 | case E_SNOVA: /* supernova */ | |
143 | /* cause the supernova to happen */ | 138 | /* cause the supernova to happen */ | |
144 | snova(-1, 0); | 139 | snova(-1, 0); | |
145 | /* and schedule the next one */ | 140 | /* and schedule the next one */ | |
146 | xresched(e, E_SNOVA, 1); | 141 | xresched(e, E_SNOVA, 1); | |
147 | break; | 142 | break; | |
148 | 143 | |||
149 | case E_LRTB: /* long range tractor beam */ | 144 | case E_LRTB: /* long range tractor beam */ | |
150 | /* schedule the next one */ | 145 | /* schedule the next one */ | |
151 | xresched(e, E_LRTB, Now.klings); | 146 | xresched(e, E_LRTB, Now.klings); | |
152 | /* LRTB cannot occur if we are docked */ | 147 | /* LRTB cannot occur if we are docked */ | |
153 | if (Ship.cond != DOCKED) | 148 | if (Ship.cond != DOCKED) { | |
154 | { | |||
155 | /* pick a new quadrant */ | 149 | /* pick a new quadrant */ | |
156 | i = ranf(Now.klings) + 1; | 150 | i = ranf(Now.klings) + 1; | |
157 | for (ix = 0; ix < NQUADS; ix++) | 151 | for (ix = 0; ix < NQUADS; ix++) { | |
158 | { | 152 | for (iy = 0; iy < NQUADS; iy++) { | |
159 | for (iy = 0; iy < NQUADS; iy++) | |||
160 | { | |||
161 | q = &Quad[ix][iy]; | 153 | q = &Quad[ix][iy]; | |
162 | if (q->stars >= 0) | 154 | if (q->stars >= 0) | |
163 | if ((i -= q->klings) <= 0) | 155 | if ((i -= q->klings) <= 0) | |
164 | break; | 156 | break; | |
165 | } | 157 | } | |
166 | if (i <= 0) | 158 | if (i <= 0) | |
167 | break; | 159 | break; | |
168 | } | 160 | } | |
169 | 161 | |||
170 | /* test for LRTB to same quadrant */ | 162 | /* test for LRTB to same quadrant */ | |
171 | if (Ship.quadx == ix && Ship.quady == iy) | 163 | if (Ship.quadx == ix && Ship.quady == iy) | |
172 | break; | 164 | break; | |
173 | 165 | |||
@@ -176,215 +168,201 @@ events(int timewarp) | @@ -176,215 +168,201 @@ events(int timewarp) | |||
176 | Ship.quady = iy; | 168 | Ship.quady = iy; | |
177 | printf("\n%s caught in long range tractor beam\n", Ship.shipname); | 169 | printf("\n%s caught in long range tractor beam\n", Ship.shipname); | |
178 | printf("*** Pulled to quadrant %d,%d\n", Ship.quadx, Ship.quady); | 170 | printf("*** Pulled to quadrant %d,%d\n", Ship.quadx, Ship.quady); | |
179 | Ship.sectx = ranf(NSECTS); | 171 | Ship.sectx = ranf(NSECTS); | |
180 | Ship.secty = ranf(NSECTS); | 172 | Ship.secty = ranf(NSECTS); | |
181 | initquad(0); | 173 | initquad(0); | |
182 | /* truncate the move time */ | 174 | /* truncate the move time */ | |
183 | Move.time = xdate - idate; | 175 | Move.time = xdate - idate; | |
184 | } | 176 | } | |
185 | break; | 177 | break; | |
186 | 178 | |||
187 | case E_KATSB: /* Klingon attacks starbase */ | 179 | case E_KATSB: /* Klingon attacks starbase */ | |
188 | /* if out of bases, forget it */ | 180 | /* if out of bases, forget it */ | |
189 | if (Now.bases <= 0) | 181 | if (Now.bases <= 0) { | |
190 | { | |||
191 | unschedule(e); | 182 | unschedule(e); | |
192 | break; | 183 | break; | |
193 | } | 184 | } | |
194 | 185 | |||
195 | /* check for starbase and Klingons in same quadrant */ | 186 | /* check for starbase and Klingons in same quadrant */ | |
196 | for (i = 0; i < Now.bases; i++) | 187 | for (i = 0; i < Now.bases; i++) { | |
197 | { | |||
198 | ix = Now.base[i].x; | 188 | ix = Now.base[i].x; | |
199 | iy = Now.base[i].y; | 189 | iy = Now.base[i].y; | |
200 | /* see if a Klingon exists in this quadrant */ | 190 | /* see if a Klingon exists in this quadrant */ | |
201 | q = &Quad[ix][iy]; | 191 | q = &Quad[ix][iy]; | |
202 | if (q->klings <= 0) | 192 | if (q->klings <= 0) | |
203 | continue; | 193 | continue; | |
204 | 194 | |||
205 | /* see if already distressed */ | 195 | /* see if already distressed */ | |
206 | for (j = 0; j < MAXEVENTS; j++) | 196 | for (j = 0; j < MAXEVENTS; j++) { | |
207 | { | |||
208 | e = &Event[j]; | 197 | e = &Event[j]; | |
209 | if ((e->evcode & E_EVENT) != E_KDESB) | 198 | if ((e->evcode & E_EVENT) != E_KDESB) | |
210 | continue; | 199 | continue; | |
211 | if (e->x == ix && e->y == iy) | 200 | if (e->x == ix && e->y == iy) | |
212 | break; | 201 | break; | |
213 | } | 202 | } | |
214 | if (j < MAXEVENTS) | 203 | if (j < MAXEVENTS) | |
215 | continue; | 204 | continue; | |
216 | 205 | |||
217 | /* got a potential attack */ | 206 | /* got a potential attack */ | |
218 | break; | 207 | break; | |
219 | } | 208 | } | |
220 | e = ev; | 209 | e = ev; | |
221 | if (i >= Now.bases) | 210 | if (i >= Now.bases) { | |
222 | { | |||
223 | /* not now; wait a while and see if some Klingons move in */ | 211 | /* not now; wait a while and see if some Klingons move in */ | |
224 | reschedule(e, 0.5 + 3.0 * franf()); | 212 | reschedule(e, 0.5 + 3.0 * franf()); | |
225 | break; | 213 | break; | |
226 | } | 214 | } | |
227 | /* schedule a new attack, and a destruction of the base */ | 215 | /* schedule a new attack, and a destruction of the base */ | |
228 | xresched(e, E_KATSB, 1); | 216 | xresched(e, E_KATSB, 1); | |
229 | e = xsched(E_KDESB, 1, ix, iy, 0); | 217 | e = xsched(E_KDESB, 1, ix, iy, 0); | |
230 | 218 | |||
231 | /* report it if we can */ | 219 | /* report it if we can */ | |
232 | if (!damaged(SSRADIO)) | 220 | if (!damaged(SSRADIO)) { | |
233 | { | |||
234 | printf("\nUhura: Captain, we have received a distress signal\n"); | 221 | printf("\nUhura: Captain, we have received a distress signal\n"); | |
235 | printf(" from the starbase in quadrant %d,%d.\n", | 222 | printf(" from the starbase in quadrant %d,%d.\n", | |
236 | ix, iy); | 223 | ix, iy); | |
237 | restcancel++; | 224 | restcancel++; | |
238 | } | 225 | } else { | |
239 | else | |||
240 | /* SSRADIO out, make it so we can't see the distress call */ | 226 | /* SSRADIO out, make it so we can't see the distress call */ | |
241 | /* but it's still there!!! */ | 227 | /* but it's still there!!! */ | |
242 | e->evcode |= E_HIDDEN; | 228 | e->evcode |= E_HIDDEN; | |
229 | } | |||
243 | break; | 230 | break; | |
244 | 231 | |||
245 | case E_KDESB: /* Klingon destroys starbase */ | 232 | case E_KDESB: /* Klingon destroys starbase */ | |
246 | unschedule(e); | 233 | unschedule(e); | |
247 | q = &Quad[e->x][e->y]; | 234 | q = &Quad[e->x][e->y]; | |
248 | /* if the base has mysteriously gone away, or if the Klingon | 235 | /* if the base has mysteriously gone away, or if the Klingon | |
249 | got tired and went home, ignore this event */ | 236 | got tired and went home, ignore this event */ | |
250 | if (q->bases <=0 || q->klings <= 0) | 237 | if (q->bases <=0 || q->klings <= 0) | |
251 | break; | 238 | break; | |
252 | /* are we in the same quadrant? */ | 239 | /* are we in the same quadrant? */ | |
253 | if (e->x == Ship.quadx && e->y == Ship.quady) | 240 | if (e->x == Ship.quadx && e->y == Ship.quady) { | |
254 | { | |||
255 | /* yep, kill one in this quadrant */ | 241 | /* yep, kill one in this quadrant */ | |
256 | printf("\nSpock: "); | 242 | printf("\nSpock: "); | |
257 | killb(Ship.quadx, Ship.quady); | 243 | killb(Ship.quadx, Ship.quady); | |
258 | } | 244 | } else { | |
259 | else | |||
260 | /* kill one in some other quadrant */ | 245 | /* kill one in some other quadrant */ | |
261 | killb(e->x, e->y); | 246 | killb(e->x, e->y); | |
247 | } | |||
262 | break; | 248 | break; | |
263 | 249 | |||
264 | case E_ISSUE: /* issue a distress call */ | 250 | case E_ISSUE: /* issue a distress call */ | |
265 | xresched(e, E_ISSUE, 1); | 251 | xresched(e, E_ISSUE, 1); | |
266 | /* if we already have too many, throw this one away */ | 252 | /* if we already have too many, throw this one away */ | |
267 | if (Ship.distressed >= MAXDISTR) | 253 | if (Ship.distressed >= MAXDISTR) | |
268 | break; | 254 | break; | |
269 | /* try a whole bunch of times to find something suitable */ | 255 | /* try a whole bunch of times to find something suitable */ | |
270 | for (i = 0; i < 100; i++) | 256 | for (i = 0; i < 100; i++) { | |
271 | { | |||
272 | ix = ranf(NQUADS); | 257 | ix = ranf(NQUADS); | |
273 | iy = ranf(NQUADS); | 258 | iy = ranf(NQUADS); | |
274 | q = &Quad[ix][iy]; | 259 | q = &Quad[ix][iy]; | |
275 | /* need a quadrant which is not the current one, | 260 | /* need a quadrant which is not the current one, | |
276 | which has some stars which are inhabited and | 261 | which has some stars which are inhabited and | |
277 | not already under attack, which is not | 262 | not already under attack, which is not | |
278 | supernova'ed, and which has some Klingons in it */ | 263 | supernova'ed, and which has some Klingons in it */ | |
279 | if (!((ix == Ship.quadx && iy == Ship.quady) || q->stars < 0 || | 264 | if (!((ix == Ship.quadx && iy == Ship.quady) || q->stars < 0 || | |
280 | (q->qsystemname & Q_DISTRESSED) || | 265 | (q->qsystemname & Q_DISTRESSED) || | |
281 | (q->qsystemname & Q_SYSTEM) == 0 || q->klings <= 0)) | 266 | (q->qsystemname & Q_SYSTEM) == 0 || q->klings <= 0)) | |
282 | break; | 267 | break; | |
283 | } | 268 | } | |
284 | if (i >= 100) | 269 | if (i >= 100) | |
285 | /* can't seem to find one; ignore this call */ | 270 | /* can't seem to find one; ignore this call */ | |
286 | break; | 271 | break; | |
287 | 272 | |||
288 | /* got one!! Schedule its enslavement */ | 273 | /* got one!! Schedule its enslavement */ | |
289 | Ship.distressed++; | 274 | Ship.distressed++; | |
290 | e = xsched(E_ENSLV, 1, ix, iy, q->qsystemname); | 275 | e = xsched(E_ENSLV, 1, ix, iy, q->qsystemname); | |
291 | q->qsystemname = (e - Event) | Q_DISTRESSED; | 276 | q->qsystemname = (e - Event) | Q_DISTRESSED; | |
292 | 277 | |||
293 | /* tell the captain about it if we can */ | 278 | /* tell the captain about it if we can */ | |
294 | if (!damaged(SSRADIO)) | 279 | if (!damaged(SSRADIO)) { | |
295 | { | |||
296 | printf("\nUhura: Captain, starsystem %s in quadrant %d,%d is under attack\n", | 280 | printf("\nUhura: Captain, starsystem %s in quadrant %d,%d is under attack\n", | |
297 | Systemname[e->systemname], ix, iy); | 281 | Systemname[e->systemname], ix, iy); | |
298 | restcancel++; | 282 | restcancel++; | |
299 | } | 283 | } else { | |
300 | else | |||
301 | /* if we can't tell him, make it invisible */ | 284 | /* if we can't tell him, make it invisible */ | |
302 | e->evcode |= E_HIDDEN; | 285 | e->evcode |= E_HIDDEN; | |
286 | } | |||
303 | break; | 287 | break; | |
304 | 288 | |||
305 | case E_ENSLV: /* starsystem is enslaved */ | 289 | case E_ENSLV: /* starsystem is enslaved */ | |
306 | unschedule(e); | 290 | unschedule(e); | |
307 | /* see if current distress call still active */ | 291 | /* see if current distress call still active */ | |
308 | q = &Quad[e->x][e->y]; | 292 | q = &Quad[e->x][e->y]; | |
309 | if (q->klings <= 0) | 293 | if (q->klings <= 0) { | |
310 | { | |||
311 | /* no Klingons, clean up */ | 294 | /* no Klingons, clean up */ | |
312 | /* restore the system name */ | 295 | /* restore the system name */ | |
313 | q->qsystemname = e->systemname; | 296 | q->qsystemname = e->systemname; | |
314 | break; | 297 | break; | |
315 | } | 298 | } | |
316 | 299 | |||
317 | /* play stork and schedule the first baby */ | 300 | /* play stork and schedule the first baby */ | |
318 | e = schedule(E_REPRO, Param.eventdly[E_REPRO] * franf(), e->x, e->y, e->systemname); | 301 | e = schedule(E_REPRO, Param.eventdly[E_REPRO] * franf(), e->x, e->y, e->systemname); | |
319 | 302 | |||
320 | /* report the disaster if we can */ | 303 | /* report the disaster if we can */ | |
321 | if (!damaged(SSRADIO)) | 304 | if (!damaged(SSRADIO)) { | |
322 | { | |||
323 | printf("\nUhura: We've lost contact with starsystem %s\n", | 305 | printf("\nUhura: We've lost contact with starsystem %s\n", | |
324 | Systemname[e->systemname]); | 306 | Systemname[e->systemname]); | |
325 | printf(" in quadrant %d,%d.\n", | 307 | printf(" in quadrant %d,%d.\n", | |
326 | e->x, e->y); | 308 | e->x, e->y); | |
327 | } | 309 | } else | |
328 | else | |||
329 | e->evcode |= E_HIDDEN; | 310 | e->evcode |= E_HIDDEN; | |
330 | break; | 311 | break; | |
331 | 312 | |||
332 | case E_REPRO: /* Klingon reproduces */ | 313 | case E_REPRO: /* Klingon reproduces */ | |
333 | /* see if distress call is still active */ | 314 | /* see if distress call is still active */ | |
334 | q = &Quad[e->x][e->y]; | 315 | q = &Quad[e->x][e->y]; | |
335 | if (q->klings <= 0) | 316 | if (q->klings <= 0) { | |
336 | { | |||
337 | unschedule(e); | 317 | unschedule(e); | |
338 | q->qsystemname = e->systemname; | 318 | q->qsystemname = e->systemname; | |
339 | break; | 319 | break; | |
340 | } | 320 | } | |
341 | xresched(e, E_REPRO, 1); | 321 | xresched(e, E_REPRO, 1); | |
342 | /* reproduce one Klingon */ | 322 | /* reproduce one Klingon */ | |
343 | ix = e->x; | 323 | ix = e->x; | |
344 | iy = e->y; | 324 | iy = e->y; | |
345 | if (Now.klings == 127) | 325 | if (Now.klings == 127) { | |
346 | break; /* full right now */ | 326 | /* full right now */ | |
347 | if (q->klings >= MAXKLQUAD) | 327 | break; | |
348 | { | 328 | } | |
329 | if (q->klings >= MAXKLQUAD) { | |||
349 | /* this quadrant not ok, pick an adjacent one */ | 330 | /* this quadrant not ok, pick an adjacent one */ | |
350 | for (i = ix - 1; i <= ix + 1; i++) | 331 | for (i = ix - 1; i <= ix + 1; i++) { | |
351 | { | |||
352 | if (i < 0 || i >= NQUADS) | 332 | if (i < 0 || i >= NQUADS) | |
353 | continue; | 333 | continue; | |
354 | for (j = iy - 1; j <= iy + 1; j++) | 334 | for (j = iy - 1; j <= iy + 1; j++) { | |
355 | { | |||
356 | if (j < 0 || j >= NQUADS) | 335 | if (j < 0 || j >= NQUADS) | |
357 | continue; | 336 | continue; | |
358 | q = &Quad[i][j]; | 337 | q = &Quad[i][j]; | |
359 | /* check for this quad ok (not full & no snova) */ | 338 | /* check for this quad ok (not full & no snova) */ | |
360 | if (q->klings >= MAXKLQUAD || q->stars < 0) | 339 | if (q->klings >= MAXKLQUAD || q->stars < 0) | |
361 | continue; | 340 | continue; | |
362 | break; | 341 | break; | |
363 | } | 342 | } | |
364 | if (j <= iy + 1) | 343 | if (j <= iy + 1) | |
365 | break; | 344 | break; | |
366 | } | 345 | } | |
367 | if (j > iy + 1) | 346 | if (j > iy + 1) | |
368 | /* cannot create another yet */ | 347 | /* cannot create another yet */ | |
369 | break; | 348 | break; | |
370 | ix = i; | 349 | ix = i; | |
371 | iy = j; | 350 | iy = j; | |
372 | } | 351 | } | |
373 | /* deliver the child */ | 352 | /* deliver the child */ | |
374 | q->klings++; | 353 | q->klings++; | |
375 | Now.klings++; | 354 | Now.klings++; | |
376 | if (ix == Ship.quadx && iy == Ship.quady) | 355 | if (ix == Ship.quadx && iy == Ship.quady) { | |
377 | { | |||
378 | /* we must position Klingon */ | 356 | /* we must position Klingon */ | |
379 | sector(&ix, &iy); | 357 | sector(&ix, &iy); | |
380 | Sect[ix][iy] = KLINGON; | 358 | Sect[ix][iy] = KLINGON; | |
381 | k = &Etc.klingon[Etc.nkling++]; | 359 | k = &Etc.klingon[Etc.nkling++]; | |
382 | k->x = ix; | 360 | k->x = ix; | |
383 | k->y = iy; | 361 | k->y = iy; | |
384 | k->power = Param.klingpwr; | 362 | k->power = Param.klingpwr; | |
385 | k->srndreq = 0; | 363 | k->srndreq = 0; | |
386 | compkldist(Etc.klingon[0].dist == Etc.klingon[0].avgdist ? 0 : 1); | 364 | compkldist(Etc.klingon[0].dist == Etc.klingon[0].avgdist ? 0 : 1); | |
387 | } | 365 | } | |
388 | 366 | |||
389 | /* recompute time left */ | 367 | /* recompute time left */ | |
390 | Now.time = Now.resource / Now.klings; | 368 | Now.time = Now.resource / Now.klings; | |
@@ -392,46 +370,44 @@ events(int timewarp) | @@ -392,46 +370,44 @@ events(int timewarp) | |||
392 | 370 | |||
393 | case E_SNAP: /* take a snapshot of the galaxy */ | 371 | case E_SNAP: /* take a snapshot of the galaxy */ | |
394 | xresched(e, E_SNAP, 1); | 372 | xresched(e, E_SNAP, 1); | |
395 | p = (char *) Etc.snapshot; | 373 | p = (char *) Etc.snapshot; | |
396 | memcpy(p, Quad, sizeof (Quad)); | 374 | memcpy(p, Quad, sizeof (Quad)); | |
397 | p += sizeof(Quad); | 375 | p += sizeof(Quad); | |
398 | memcpy(p, Event, sizeof (Event)); | 376 | memcpy(p, Event, sizeof (Event)); | |
399 | p += sizeof(Event); | 377 | p += sizeof(Event); | |
400 | memcpy(p, &Now, sizeof (Now)); | 378 | memcpy(p, &Now, sizeof (Now)); | |
401 | Game.snap = 1; | 379 | Game.snap = 1; | |
402 | break; | 380 | break; | |
403 | 381 | |||
404 | case E_ATTACK: /* Klingons attack during rest period */ | 382 | case E_ATTACK: /* Klingons attack during rest period */ | |
405 | if (!Move.resting) | 383 | if (!Move.resting) { | |
406 | { | |||
407 | unschedule(e); | 384 | unschedule(e); | |
408 | break; | 385 | break; | |
409 | } | 386 | } | |
410 | attack(1); | 387 | attack(1); | |
411 | reschedule(e, 0.5); | 388 | reschedule(e, 0.5); | |
412 | break; | 389 | break; | |
413 | 390 | |||
414 | case E_FIXDV: | 391 | case E_FIXDV: | |
415 | i = e->systemname; | 392 | i = e->systemname; | |
416 | unschedule(e); | 393 | unschedule(e); | |
417 | 394 | |||
418 | /* de-damage the device */ | 395 | /* de-damage the device */ | |
419 | printf("%s reports repair work on the %s finished.\n", | 396 | printf("%s reports repair work on the %s finished.\n", | |
420 | Device[i].person, Device[i].name); | 397 | Device[i].person, Device[i].name); | |
421 | 398 | |||
422 | /* handle special processing upon fix */ | 399 | /* handle special processing upon fix */ | |
423 | switch (i) | 400 | switch (i) { | |
424 | { | |||
425 | 401 | |||
426 | case LIFESUP: | 402 | case LIFESUP: | |
427 | Ship.reserves = Param.reserves; | 403 | Ship.reserves = Param.reserves; | |
428 | break; | 404 | break; | |
429 | 405 | |||
430 | case SINS: | 406 | case SINS: | |
431 | if (Ship.cond == DOCKED) | 407 | if (Ship.cond == DOCKED) | |
432 | break; | 408 | break; | |
433 | printf("Spock has tried to recalibrate your Space Internal Navigation System,\n"); | 409 | printf("Spock has tried to recalibrate your Space Internal Navigation System,\n"); | |
434 | printf(" but he has no standard base to calibrate to. Suggest you get\n"); | 410 | printf(" but he has no standard base to calibrate to. Suggest you get\n"); | |
435 | printf(" to a starbase immediately so that you can properly recalibrate.\n"); | 411 | printf(" to a starbase immediately so that you can properly recalibrate.\n"); | |
436 | Ship.sinsbad = 1; | 412 | Ship.sinsbad = 1; | |
437 | break; | 413 | break; | |
@@ -445,28 +421,27 @@ events(int timewarp) | @@ -445,28 +421,27 @@ events(int timewarp) | |||
445 | default: | 421 | default: | |
446 | break; | 422 | break; | |
447 | } | 423 | } | |
448 | 424 | |||
449 | if (restcancel && Move.resting && getynpar("Spock: Shall we cancel our rest period")) | 425 | if (restcancel && Move.resting && getynpar("Spock: Shall we cancel our rest period")) | |
450 | Move.time = xdate - idate; | 426 | Move.time = xdate - idate; | |
451 | 427 | |||
452 | } | 428 | } | |
453 | 429 | |||
454 | /* unschedule an attack during a rest period */ | 430 | /* unschedule an attack during a rest period */ | |
455 | if ((e = Now.eventptr[E_ATTACK]) != NULL) | 431 | if ((e = Now.eventptr[E_ATTACK]) != NULL) | |
456 | unschedule(e); | 432 | unschedule(e); | |
457 | 433 | |||
458 | if (!timewarp) | 434 | if (!timewarp) { | |
459 | { | |||
460 | /* eat up energy if cloaked */ | 435 | /* eat up energy if cloaked */ | |
461 | if (Ship.cloaked) | 436 | if (Ship.cloaked) | |
462 | Ship.energy -= Param.cloakenergy * Move.time; | 437 | Ship.energy -= Param.cloakenergy * Move.time; | |
463 | 438 | |||
464 | /* regenerate resources */ | 439 | /* regenerate resources */ | |
465 | rtime = 1.0 - exp(-Param.regenfac * Move.time); | 440 | rtime = 1.0 - exp(-Param.regenfac * Move.time); | |
466 | Ship.shield += (Param.shield - Ship.shield) * rtime; | 441 | Ship.shield += (Param.shield - Ship.shield) * rtime; | |
467 | Ship.energy += (Param.energy - Ship.energy) * rtime; | 442 | Ship.energy += (Param.energy - Ship.energy) * rtime; | |
468 | 443 | |||
469 | /* decrement life support reserves */ | 444 | /* decrement life support reserves */ | |
470 | if (damaged(LIFESUP) && Ship.cond != DOCKED) | 445 | if (damaged(LIFESUP) && Ship.cond != DOCKED) | |
471 | Ship.reserves -= Move.time; | 446 | Ship.reserves -= Move.time; | |
472 | } | 447 | } |
--- src/games/trek/externs.c 2009/05/24 20:39:43 1.9
+++ src/games/trek/externs.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: externs.c,v 1.10 2009/05/24 21:44:56 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,58 +24,56 @@ | @@ -24,58 +24,56 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: externs.c,v 1.10 2009/05/24 21:44:56 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 | |||
47 | const struct device Device[NDEV] = | 47 | const struct device Device[NDEV] = { | |
48 | { | |||
49 | { "warp drive", "Scotty" }, | 48 | { "warp drive", "Scotty" }, | |
50 | { "S.R. scanners", "Scotty" }, | 49 | { "S.R. scanners", "Scotty" }, | |
51 | { "L.R. scanners", "Scotty" }, | 50 | { "L.R. scanners", "Scotty" }, | |
52 | { "phasers", "Sulu" }, | 51 | { "phasers", "Sulu" }, | |
53 | { "photon tubes", "Sulu" }, | 52 | { "photon tubes", "Sulu" }, | |
54 | { "impulse engines", "Scotty" }, | 53 | { "impulse engines", "Scotty" }, | |
55 | { "shield control", "Sulu" }, | 54 | { "shield control", "Sulu" }, | |
56 | { "computer", "Spock" }, | 55 | { "computer", "Spock" }, | |
57 | { "subspace radio", "Uhura" }, | 56 | { "subspace radio", "Uhura" }, | |
58 | { "life support", "Scotty" }, | 57 | { "life support", "Scotty" }, | |
59 | { "navigation system", "Chekov" }, | 58 | { "navigation system", "Chekov" }, | |
60 | { "cloaking device", "Scotty" }, | 59 | { "cloaking device", "Scotty" }, | |
61 | { "transporter", "Scotty" }, | 60 | { "transporter", "Scotty" }, | |
62 | { "shuttlecraft", "Scotty" }, | 61 | { "shuttlecraft", "Scotty" }, | |
63 | { "*ERR 14*", "Nobody" }, | 62 | { "*ERR 14*", "Nobody" }, | |
64 | { "*ERR 15*", "Nobody" } | 63 | { "*ERR 15*", "Nobody" } | |
65 | }; | 64 | }; | |
66 | 65 | |||
67 | const char *const Systemname[NINHAB] = | 66 | const char *const Systemname[NINHAB] = { | |
68 | { | |||
69 | "ERROR", | 67 | "ERROR", | |
70 | "Talos IV", | 68 | "Talos IV", | |
71 | "Rigel III", | 69 | "Rigel III", | |
72 | "Deneb VII", | 70 | "Deneb VII", | |
73 | "Canopus V", | 71 | "Canopus V", | |
74 | "Icarus I", | 72 | "Icarus I", | |
75 | "Prometheus II", | 73 | "Prometheus II", | |
76 | "Omega VII", | 74 | "Omega VII", | |
77 | "Elysium I", | 75 | "Elysium I", | |
78 | "Scalos IV", | 76 | "Scalos IV", | |
79 | "Procyon IV", | 77 | "Procyon IV", | |
80 | "Arachnid I", | 78 | "Arachnid I", | |
81 | "Argo VIII", | 79 | "Argo VIII", | |
@@ -95,23 +93,24 @@ const char *const Systemname[NINHAB] = | @@ -95,23 +93,24 @@ const char *const Systemname[NINHAB] = | |||
95 | "Ardana", | 93 | "Ardana", | |
96 | "Stratos", | 94 | "Stratos", | |
97 | "Eden", | 95 | "Eden", | |
98 | "Arrikis", | 96 | "Arrikis", | |
99 | "Epsilon Eridani IV", | 97 | "Epsilon Eridani IV", | |
100 | "Exo III" | 98 | "Exo III" | |
101 | }; | 99 | }; | |
102 | 100 | |||
103 | struct quad Quad[NQUADS][NQUADS]; | 101 | struct quad Quad[NQUADS][NQUADS]; | |
104 | 102 | |||
105 | /* current sector map */ | 103 | /* current sector map */ | |
106 | char Sect[NSECTS][NSECTS]; | 104 | char Sect[NSECTS][NSECTS]; | |
107 | 105 | |||
108 | struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ | 106 | /* dynamic event list; one entry per pending event */ | |
107 | struct event Event[MAXEVENTS]; | |||
109 | 108 | |||
110 | struct Ship_struct Ship; | 109 | struct Ship_struct Ship; | |
111 | struct Game_struct Game; | 110 | struct Game_struct Game; | |
112 | struct Move_struct Move; | 111 | struct Move_struct Move; | |
113 | struct Param_struct Param; | 112 | struct Param_struct Param; | |
114 | struct Now_struct Now; | 113 | struct Now_struct Now; | |
115 | struct Etc_struct Etc; | 114 | struct Etc_struct Etc; | |
116 | 115 | |||
117 | int Trace; | 116 | int Trace; |
--- src/games/trek/kill.c 2009/05/24 19:18:44 1.9
+++ src/games/trek/kill.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: kill.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: kill.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: kill.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: kill.c,v 1.10 2009/05/24 21:44:56 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 <limits.h> | 42 | #include <limits.h> | |
43 | #include "trek.h" | 43 | #include "trek.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** KILL KILL KILL !!! | 46 | ** KILL KILL KILL !!! | |
47 | ** | 47 | ** | |
48 | ** This file handles the killing off of almost anything. | 48 | ** This file handles the killing off of almost anything. | |
49 | */ | 49 | */ | |
50 | 50 | |||
@@ -65,28 +65,27 @@ killk(int ix, int iy) | @@ -65,28 +65,27 @@ killk(int ix, int iy) | |||
65 | 65 | |||
66 | printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy); | 66 | printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy); | |
67 | 67 | |||
68 | /* remove the scoundrel */ | 68 | /* remove the scoundrel */ | |
69 | Now.klings -= 1; | 69 | Now.klings -= 1; | |
70 | Sect[ix][iy] = EMPTY; | 70 | Sect[ix][iy] = EMPTY; | |
71 | Quad[Ship.quadx][Ship.quady].klings -= 1; | 71 | Quad[Ship.quadx][Ship.quady].klings -= 1; | |
72 | /* %%% IS THIS SAFE???? %%% */ | 72 | /* %%% IS THIS SAFE???? %%% */ | |
73 | Quad[Ship.quadx][Ship.quady].scanned -= 100; | 73 | Quad[Ship.quadx][Ship.quady].scanned -= 100; | |
74 | Game.killk += 1; | 74 | Game.killk += 1; | |
75 | 75 | |||
76 | /* find the Klingon in the Klingon list */ | 76 | /* find the Klingon in the Klingon list */ | |
77 | for (i = 0; i < Etc.nkling; i++) | 77 | for (i = 0; i < Etc.nkling; i++) | |
78 | if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) | 78 | if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) { | |
79 | { | |||
80 | /* purge him from the list */ | 79 | /* purge him from the list */ | |
81 | Etc.nkling -= 1; | 80 | Etc.nkling -= 1; | |
82 | for (; i < Etc.nkling; i++) | 81 | for (; i < Etc.nkling; i++) | |
83 | Etc.klingon[i] = Etc.klingon[i+1]; | 82 | Etc.klingon[i] = Etc.klingon[i+1]; | |
84 | break; | 83 | break; | |
85 | } | 84 | } | |
86 | 85 | |||
87 | /* find out if that was the last one */ | 86 | /* find out if that was the last one */ | |
88 | if (Now.klings <= 0) | 87 | if (Now.klings <= 0) | |
89 | win(); | 88 | win(); | |
90 | 89 | |||
91 | /* recompute time left */ | 90 | /* recompute time left */ | |
92 | Now.time = Now.resource / Now.klings; | 91 | Now.time = Now.resource / Now.klings; | |
@@ -112,125 +111,111 @@ killb(int qx, int qy) | @@ -112,125 +111,111 @@ killb(int qx, int qy) | |||
112 | /* then update starchart */ | 111 | /* then update starchart */ | |
113 | if (q->scanned < 1000) | 112 | if (q->scanned < 1000) | |
114 | q->scanned -= 10; | 113 | q->scanned -= 10; | |
115 | else | 114 | else | |
116 | if (q->scanned > 1000) | 115 | if (q->scanned > 1000) | |
117 | q->scanned = -1; | 116 | q->scanned = -1; | |
118 | } | 117 | } | |
119 | q->bases = 0; | 118 | q->bases = 0; | |
120 | Now.bases -= 1; | 119 | Now.bases -= 1; | |
121 | for (b = Now.base; ; b++) | 120 | for (b = Now.base; ; b++) | |
122 | if (qx == b->x && qy == b->y) | 121 | if (qx == b->x && qy == b->y) | |
123 | break; | 122 | break; | |
124 | *b = Now.base[Now.bases]; | 123 | *b = Now.base[Now.bases]; | |
125 | if (qx == Ship.quadx && qy == Ship.quady) | 124 | if (qx == Ship.quadx && qy == Ship.quady) { | |
126 | { | |||
127 | Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY; | 125 | Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY; | |
128 | if (Ship.cond == DOCKED) | 126 | if (Ship.cond == DOCKED) | |
129 | undock(0); | 127 | undock(0); | |
130 | printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y); | 128 | printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y); | |
131 | } | 129 | } else { | |
132 | else | 130 | if (!damaged(SSRADIO)) { | |
133 | { | |||
134 | if (!damaged(SSRADIO)) | |||
135 | { | |||
136 | printf("Uhura: Starfleet command reports that the starbase in\n"); | 131 | printf("Uhura: Starfleet command reports that the starbase in\n"); | |
137 | printf(" quadrant %d,%d has been destroyed\n", qx, qy); | 132 | printf(" quadrant %d,%d has been destroyed\n", qx, qy); | |
138 | } | 133 | } | |
139 | else | 134 | else | |
140 | schedule(E_KATSB | E_GHOST, TOOLARGE, qx, qy, 0); | 135 | schedule(E_KATSB | E_GHOST, TOOLARGE, qx, qy, 0); | |
141 | } | 136 | } | |
142 | } | 137 | } | |
143 | 138 | |||
144 | 139 | |||
145 | /** | 140 | /** | |
146 | ** kill an inhabited starsystem | 141 | ** kill an inhabited starsystem | |
147 | ** | 142 | ** | |
148 | ** x, y are quad coords if f == 0, else sector coords | 143 | ** x, y are quad coords if f == 0, else sector coords | |
149 | ** f != 0 -- this quad; f < 0 -- Enterprise's fault | 144 | ** f != 0 -- this quad; f < 0 -- Enterprise's fault | |
150 | **/ | 145 | **/ | |
151 | 146 | |||
152 | void | 147 | void | |
153 | kills(int x, int y, int f) | 148 | kills(int x, int y, int f) | |
154 | { | 149 | { | |
155 | struct quad *q; | 150 | struct quad *q; | |
156 | struct event *e; | 151 | struct event *e; | |
157 | const char *name; | 152 | const char *name; | |
158 | 153 | |||
159 | if (f) | 154 | if (f) { | |
160 | { | |||
161 | /* current quadrant */ | 155 | /* current quadrant */ | |
162 | q = &Quad[Ship.quadx][Ship.quady]; | 156 | q = &Quad[Ship.quadx][Ship.quady]; | |
163 | Sect[x][y] = EMPTY; | 157 | Sect[x][y] = EMPTY; | |
164 | name = systemname(q); | 158 | name = systemname(q); | |
165 | if (name == 0) | 159 | if (name == 0) | |
166 | return; | 160 | return; | |
167 | printf("Inhabited starsystem %s at %d,%d destroyed\n", | 161 | printf("Inhabited starsystem %s at %d,%d destroyed\n", | |
168 | name, x, y); | 162 | name, x, y); | |
169 | if (f < 0) | 163 | if (f < 0) | |
170 | Game.killinhab += 1; | 164 | Game.killinhab += 1; | |
171 | } | 165 | } else { | |
172 | else | |||
173 | { | |||
174 | /* different quadrant */ | 166 | /* different quadrant */ | |
175 | q = &Quad[x][y]; | 167 | q = &Quad[x][y]; | |
176 | } | 168 | } | |
177 | if (q->qsystemname & Q_DISTRESSED) | 169 | if (q->qsystemname & Q_DISTRESSED) { | |
178 | { | |||
179 | /* distressed starsystem */ | 170 | /* distressed starsystem */ | |
180 | e = &Event[q->qsystemname & Q_SYSTEM]; | 171 | e = &Event[q->qsystemname & Q_SYSTEM]; | |
181 | printf("Distress call for %s invalidated\n", | 172 | printf("Distress call for %s invalidated\n", | |
182 | Systemname[e->systemname]); | 173 | Systemname[e->systemname]); | |
183 | unschedule(e); | 174 | unschedule(e); | |
184 | } | 175 | } | |
185 | q->qsystemname = 0; | 176 | q->qsystemname = 0; | |
186 | q->stars -= 1; | 177 | q->stars -= 1; | |
187 | } | 178 | } | |
188 | 179 | |||
189 | 180 | |||
190 | /** | 181 | /** | |
191 | ** "kill" a distress call | 182 | ** "kill" a distress call | |
192 | ** | 183 | ** | |
193 | ** x, y are quadrant coordinates | 184 | ** x, y are quadrant coordinates | |
194 | ** f is set if user is to be informed | 185 | ** f is set if user is to be informed | |
195 | **/ | 186 | **/ | |
196 | 187 | |||
197 | void | 188 | void | |
198 | killd(int x, int y, int f) | 189 | killd(int x, int y, int f) | |
199 | { | 190 | { | |
200 | struct event *e; | 191 | struct event *e; | |
201 | int i; | 192 | int i; | |
202 | struct quad *q; | 193 | struct quad *q; | |
203 | 194 | |||
204 | q = &Quad[x][y]; | 195 | q = &Quad[x][y]; | |
205 | for (i = 0; i < MAXEVENTS; i++) | 196 | for (i = 0; i < MAXEVENTS; i++) { | |
206 | { | |||
207 | e = &Event[i]; | 197 | e = &Event[i]; | |
208 | if (e->x != x || e->y != y) | 198 | if (e->x != x || e->y != y) | |
209 | continue; | 199 | continue; | |
210 | switch (e->evcode) | 200 | switch (e->evcode) { | |
211 | { | |||
212 | case E_KDESB: | 201 | case E_KDESB: | |
213 | if (f) | 202 | if (f) { | |
214 | { | |||
215 | printf("Distress call for starbase in %d,%d nullified\n", | 203 | printf("Distress call for starbase in %d,%d nullified\n", | |
216 | x, y); | 204 | x, y); | |
217 | unschedule(e); | 205 | unschedule(e); | |
218 | } | 206 | } | |
219 | break; | 207 | break; | |
220 | 208 | |||
221 | case E_ENSLV: | 209 | case E_ENSLV: | |
222 | case E_REPRO: | 210 | case E_REPRO: | |
223 | if (f) | 211 | if (f) { | |
224 | { | |||
225 | printf("Distress call for %s in quadrant %d,%d nullified\n", | 212 | printf("Distress call for %s in quadrant %d,%d nullified\n", | |
226 | Systemname[e->systemname], x, y); | 213 | Systemname[e->systemname], x, y); | |
227 | q->qsystemname = e->systemname; | 214 | q->qsystemname = e->systemname; | |
228 | unschedule(e); | 215 | unschedule(e); | |
229 | } | 216 | } else { | |
230 | else | |||
231 | { | |||
232 | e->evcode |= E_GHOST; | 217 | e->evcode |= E_GHOST; | |
233 | } | 218 | } | |
234 | } | 219 | } | |
235 | } | 220 | } | |
236 | } | 221 | } |
--- src/games/trek/schedule.c 2009/05/24 20:39:43 1.9
+++ src/games/trek/schedule.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: schedule.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: schedule.c,v 1.10 2009/05/24 21:44:56 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' | |
@@ -52,28 +52,27 @@ __RCSID("$NetBSD: schedule.c,v 1.9 2009/ | @@ -52,28 +52,27 @@ __RCSID("$NetBSD: schedule.c,v 1.9 2009/ | |||
52 | ** considered the attributes for this event. | 52 | ** considered the attributes for this event. | |
53 | ** | 53 | ** | |
54 | ** The address of the slot is returned. | 54 | ** The address of the slot is returned. | |
55 | */ | 55 | */ | |
56 | 56 | |||
57 | struct event * | 57 | struct event * | |
58 | schedule(int type, double offset, int x, int y, int z) | 58 | schedule(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 | { | |||
67 | e = &Event[i]; | 66 | e = &Event[i]; | |
68 | if (e->evcode) | 67 | if (e->evcode) | |
69 | continue; | 68 | continue; | |
70 | /* got a slot */ | 69 | /* got a slot */ | |
71 | #ifdef xTRACE | 70 | #ifdef xTRACE | |
72 | if (Trace) | 71 | if (Trace) | |
73 | printf("schedule: type %d @ %.2f slot %d parm %d %d %d\n", | 72 | printf("schedule: type %d @ %.2f slot %d parm %d %d %d\n", | |
74 | type, date, i, x, y, z); | 73 | type, date, i, x, y, z); | |
75 | #endif | 74 | #endif | |
76 | e->evcode = type; | 75 | e->evcode = type; | |
77 | e->date = date; | 76 | e->date = date; | |
78 | e->x = x; | 77 | e->x = x; | |
79 | e->y = y; | 78 | e->y = y; |
--- src/games/trek/shield.c 2009/05/24 19:18:44 1.9
+++ src/games/trek/shield.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: shield.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: shield.c,v 1.10 2009/05/24 21:44:56 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,120 +24,110 @@ | @@ -24,120 +24,110 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: shield.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: shield.c,v 1.10 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** SHIELD AND CLOAKING DEVICE CONTROL | 46 | ** SHIELD AND CLOAKING DEVICE CONTROL | |
47 | ** | 47 | ** | |
48 | ** 'f' is one for auto shield up (in case of Condition RED), | 48 | ** 'f' is one for auto shield up (in case of Condition RED), | |
49 | ** zero for shield control, and negative one for cloaking | 49 | ** zero for shield control, and negative one for cloaking | |
50 | ** device control. | 50 | ** device control. | |
51 | ** | 51 | ** | |
52 | ** Called with an 'up' or 'down' on the same line, it puts | 52 | ** Called with an 'up' or 'down' on the same line, it puts | |
53 | ** the shields/cloak into the specified mode. Otherwise it | 53 | ** the shields/cloak into the specified mode. Otherwise it | |
54 | ** reports to the user the current mode, and asks if she wishes | 54 | ** reports to the user the current mode, and asks if she wishes | |
55 | ** to change. | 55 | ** to change. | |
56 | ** | 56 | ** | |
57 | ** This is not a free move. Hits that occur as a result of | 57 | ** This is not a free move. Hits that occur as a result of | |
58 | ** this move appear as though the shields are half up/down, | 58 | ** this move appear as though the shields are half up/down, | |
59 | ** so you get partial hits. | 59 | ** so you get partial hits. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | const struct cvntab Udtab[] = | 62 | const struct cvntab Udtab[] = { | |
63 | { | |||
64 | { "u", "p", (cmdfun)1, 0 }, | 63 | { "u", "p", (cmdfun)1, 0 }, | |
65 | { "d", "own", (cmdfun)0, 0 }, | 64 | { "d", "own", (cmdfun)0, 0 }, | |
66 | { NULL, NULL, NULL, 0 } | 65 | { NULL, NULL, NULL, 0 } | |
67 | }; | 66 | }; | |
68 | 67 | |||
69 | void | 68 | void | |
70 | shield(int f) | 69 | shield(int f) | |
71 | { | 70 | { | |
72 | int i; | 71 | int i; | |
73 | const struct cvntab *r; | 72 | const struct cvntab *r; | |
74 | char s[100]; | 73 | char s[100]; | |
75 | const char *device, *dev2, *dev3; | 74 | const char *device, *dev2, *dev3; | |
76 | int ind; | 75 | int ind; | |
77 | char *stat; | 76 | char *stat; | |
78 | 77 | |||
79 | if (f > 0 && (Ship.shldup || damaged(SRSCAN))) | 78 | if (f > 0 && (Ship.shldup || damaged(SRSCAN))) | |
80 | return; | 79 | return; | |
81 | if (f < 0) | 80 | if (f < 0) { | |
82 | { | |||
83 | /* cloaking device */ | 81 | /* cloaking device */ | |
84 | if (Ship.ship == QUEENE) { | 82 | if (Ship.ship == QUEENE) { | |
85 | printf("Ye Faire Queene does not have the cloaking device.\n"); | 83 | printf("Ye Faire Queene does not have the cloaking device.\n"); | |
86 | return; | 84 | return; | |
87 | } | 85 | } | |
88 | device = "Cloaking device"; | 86 | device = "Cloaking device"; | |
89 | dev2 = "is"; | 87 | dev2 = "is"; | |
90 | ind = CLOAK; | 88 | ind = CLOAK; | |
91 | dev3 = "it"; | 89 | dev3 = "it"; | |
92 | stat = &Ship.cloaked; | 90 | stat = &Ship.cloaked; | |
93 | } | 91 | } else { | |
94 | else | |||
95 | { | |||
96 | /* shields */ | 92 | /* shields */ | |
97 | device = "Shields"; | 93 | device = "Shields"; | |
98 | dev2 = "are"; | 94 | dev2 = "are"; | |
99 | dev3 = "them"; | 95 | dev3 = "them"; | |
100 | ind = SHIELD; | 96 | ind = SHIELD; | |
101 | stat = &Ship.shldup; | 97 | stat = &Ship.shldup; | |
102 | } | 98 | } | |
103 | if (damaged(ind)) | 99 | if (damaged(ind)) { | |
104 | { | |||
105 | if (f <= 0) | 100 | if (f <= 0) | |
106 | out(ind); | 101 | out(ind); | |
107 | return; | 102 | return; | |
108 | } | 103 | } | |
109 | if (Ship.cond == DOCKED) | 104 | if (Ship.cond == DOCKED) { | |
110 | { | |||
111 | printf("%s %s down while docked\n", device, dev2); | 105 | printf("%s %s down while docked\n", device, dev2); | |
112 | return; | 106 | return; | |
113 | } | 107 | } | |
114 | if (f <= 0 && !testnl()) | 108 | if (f <= 0 && !testnl()) { | |
115 | { | |||
116 | r = getcodpar("Up or down", Udtab); | 109 | r = getcodpar("Up or down", Udtab); | |
117 | i = (long) r->value; | 110 | i = (long) r->value; | |
118 | } | 111 | } else { | |
119 | else | |||
120 | { | |||
121 | if (*stat) | 112 | if (*stat) | |
122 | (void)sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); | 113 | (void)sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); | |
123 | else | 114 | else | |
124 | (void)sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); | 115 | (void)sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); | |
125 | if (!getynpar(s)) | 116 | if (!getynpar(s)) | |
126 | return; | 117 | return; | |
127 | i = !*stat; | 118 | i = !*stat; | |
128 | } | 119 | } | |
129 | if (*stat == i) | 120 | if (*stat == i) { | |
130 | { | |||
131 | printf("%s already ", device); | 121 | printf("%s already ", device); | |
132 | if (i) | 122 | if (i) | |
133 | printf("up\n"); | 123 | printf("up\n"); | |
134 | else | 124 | else | |
135 | printf("down\n"); | 125 | printf("down\n"); | |
136 | return; | 126 | return; | |
137 | } | 127 | } | |
138 | if (i) { | 128 | if (i) { | |
139 | if (f >= 0) | 129 | if (f >= 0) | |
140 | Ship.energy -= Param.shupengy; | 130 | Ship.energy -= Param.shupengy; | |
141 | else | 131 | else | |
142 | Ship.cloakgood = 0; | 132 | Ship.cloakgood = 0; | |
143 | } | 133 | } |
--- src/games/trek/warp.c 2009/05/24 19:18:44 1.9
+++ src/games/trek/warp.c 2009/05/24 21:44:56 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: warp.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: warp.c,v 1.10 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: warp.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: warp.c,v 1.10 2009/05/24 21:44:56 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 <string.h> | 43 | #include <string.h> | |
44 | #include <unistd.h> | 44 | #include <unistd.h> | |
45 | #include "trek.h" | 45 | #include "trek.h" | |
46 | #include "getpar.h" | 46 | #include "getpar.h" | |
47 | 47 | |||
48 | /* | 48 | /* | |
49 | ** MOVE UNDER WARP POWER | 49 | ** MOVE UNDER WARP POWER | |
50 | ** | 50 | ** | |
@@ -79,105 +79,97 @@ warp(int fl, int c, double d) | @@ -79,105 +79,97 @@ warp(int fl, int c, double d) | |||
79 | int course; | 79 | int course; | |
80 | double power; | 80 | double power; | |
81 | double dist; | 81 | double dist; | |
82 | double time; | 82 | double time; | |
83 | double speed; | 83 | double speed; | |
84 | double frac; | 84 | double frac; | |
85 | int percent; | 85 | int percent; | |
86 | int i; | 86 | int i; | |
87 | 87 | |||
88 | if (Ship.cond == DOCKED) { | 88 | if (Ship.cond == DOCKED) { | |
89 | printf("%s is docked\n", Ship.shipname); | 89 | printf("%s is docked\n", Ship.shipname); | |
90 | return; | 90 | return; | |
91 | } | 91 | } | |
92 | if (damaged(WARP)) | 92 | if (damaged(WARP)) { | |
93 | { | |||
94 | out(WARP); | 93 | out(WARP); | |
95 | return; | 94 | return; | |
96 | } | 95 | } | |
97 | 96 | |||
98 | course = c; | 97 | course = c; | |
99 | dist = d; | 98 | dist = d; | |
100 | 99 | |||
101 | /* check to see that we are not using an absurd amount of power */ | 100 | /* check to see that we are not using an absurd amount of power */ | |
102 | power = (dist + 0.05) * Ship.warp3; | 101 | power = (dist + 0.05) * Ship.warp3; | |
103 | percent = 100 * power / Ship.energy + 0.5; | 102 | percent = 100 * power / Ship.energy + 0.5; | |
104 | if (percent >= 85) | 103 | if (percent >= 85) { | |
105 | { | |||
106 | printf("Scotty: That would consume %d%% of our remaining energy.\n", | 104 | printf("Scotty: That would consume %d%% of our remaining energy.\n", | |
107 | percent); | 105 | percent); | |
108 | if (!getynpar("Are you sure that is wise")) | 106 | if (!getynpar("Are you sure that is wise")) | |
109 | return; | 107 | return; | |
110 | } | 108 | } | |
111 | 109 | |||
112 | /* compute the speed we will move at, and the time it will take */ | 110 | /* compute the speed we will move at, and the time it will take */ | |
113 | speed = Ship.warp2 / Param.warptime; | 111 | speed = Ship.warp2 / Param.warptime; | |
114 | time = dist / speed; | 112 | time = dist / speed; | |
115 | 113 | |||
116 | /* check to see that that value is not ridiculous */ | 114 | /* check to see that that value is not ridiculous */ | |
117 | percent = 100 * time / Now.time + 0.5; | 115 | percent = 100 * time / Now.time + 0.5; | |
118 | if (percent >= 85) | 116 | if (percent >= 85) { | |
119 | { | |||
120 | printf("Spock: That would take %d%% of our remaining time.\n", | 117 | printf("Spock: That would take %d%% of our remaining time.\n", | |
121 | percent); | 118 | percent); | |
122 | if (!getynpar("Are you sure that is wise")) | 119 | if (!getynpar("Are you sure that is wise")) | |
123 | return; | 120 | return; | |
124 | } | 121 | } | |
125 | 122 | |||
126 | /* compute how far we will go if we get damages */ | 123 | /* compute how far we will go if we get damages */ | |
127 | if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) | 124 | if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) { | |
128 | { | |||
129 | frac = franf(); | 125 | frac = franf(); | |
130 | dist *= frac; | 126 | dist *= frac; | |
131 | time *= frac; | 127 | time *= frac; | |
132 | damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20); | 128 | damage(WARP, (frac + 1.0) * Ship.warp * (franf() + 0.25) * 0.20); | |
133 | } | 129 | } | |
134 | 130 | |||
135 | /* do the move */ | 131 | /* do the move */ | |
136 | Move.time = move(fl, course, time, speed); | 132 | Move.time = move(fl, course, time, speed); | |
137 | 133 | |||
138 | /* see how far we actually went, and decrement energy appropriately */ | 134 | /* see how far we actually went, and decrement energy appropriately */ | |
139 | dist = Move.time * speed; | 135 | dist = Move.time * speed; | |
140 | Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1); | 136 | Ship.energy -= dist * Ship.warp3 * (Ship.shldup + 1); | |
141 | 137 | |||
142 | /* test for bizarre events */ | 138 | /* test for bizarre events */ | |
143 | if (Ship.warp <= 9.0) | 139 | if (Ship.warp <= 9.0) | |
144 | return; | 140 | return; | |
145 | printf("\n\n ___ Speed exceeding warp nine ___\n\n"); | 141 | printf("\n\n ___ Speed exceeding warp nine ___\n\n"); | |
146 | sleep(2); | 142 | sleep(2); | |
147 | printf("Ship's safety systems malfunction\n"); | 143 | printf("Ship's safety systems malfunction\n"); | |
148 | sleep(2); | 144 | sleep(2); | |
149 | printf("Crew experiencing extreme sensory distortion\n"); | 145 | printf("Crew experiencing extreme sensory distortion\n"); | |
150 | sleep(4); | 146 | sleep(4); | |
151 | if (ranf(100) >= 100 * dist) | 147 | if (ranf(100) >= 100 * dist) { | |
152 | { | |||
153 | printf("Equilibrium restored -- all systems normal\n"); | 148 | printf("Equilibrium restored -- all systems normal\n"); | |
154 | return; | 149 | return; | |
155 | } | 150 | } | |
156 | 151 | |||
157 | /* select a bizzare thing to happen to us */ | 152 | /* select a bizzare thing to happen to us */ | |
158 | percent = ranf(100); | 153 | percent = ranf(100); | |
159 | if (percent < 70) | 154 | if (percent < 70) { | |
160 | { | |||
161 | /* time warp */ | 155 | /* time warp */ | |
162 | if (percent < 35 || !Game.snap) | 156 | if (percent < 35 || !Game.snap) { | |
163 | { | |||
164 | /* positive time warp */ | 157 | /* positive time warp */ | |
165 | time = (Ship.warp - 8.0) * dist * (franf() + 1.0); | 158 | time = (Ship.warp - 8.0) * dist * (franf() + 1.0); | |
166 | Now.date += time; | 159 | Now.date += time; | |
167 | printf("Positive time portal entered -- it is now Stardate %.2f\n", | 160 | printf("Positive time portal entered -- it is now Stardate %.2f\n", | |
168 | Now.date); | 161 | Now.date); | |
169 | for (i = 0; i < MAXEVENTS; i++) | 162 | for (i = 0; i < MAXEVENTS; i++) { | |
170 | { | |||
171 | percent = Event[i].evcode; | 163 | percent = Event[i].evcode; | |
172 | if (percent == E_FIXDV || percent == E_LRTB) | 164 | if (percent == E_FIXDV || percent == E_LRTB) | |
173 | Event[i].date += time; | 165 | Event[i].date += time; | |
174 | } | 166 | } | |
175 | return; | 167 | return; | |
176 | } | 168 | } | |
177 | 169 | |||
178 | /* s/he got lucky: a negative time portal */ | 170 | /* s/he got lucky: a negative time portal */ | |
179 | time = Now.date; | 171 | time = Now.date; | |
180 | p = (char *) Etc.snapshot; | 172 | p = (char *) Etc.snapshot; | |
181 | memcpy(p, Quad, sizeof Quad); | 173 | memcpy(p, Quad, sizeof Quad); | |
182 | p += sizeof Quad; | 174 | p += sizeof Quad; | |
183 | memcpy(p, Event, sizeof Event); | 175 | memcpy(p, Event, sizeof Event); |
--- src/games/trek/compkl.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/compkl.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compkl.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: compkl.c,v 1.8 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)compkl.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)compkl.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: compkl.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: compkl.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); | |
38 | #endif | 38 | #endif | |
39 | #endif /* not lint */ | 39 | #endif /* not lint */ | |
40 | 40 | |||
41 | #include <math.h> | 41 | #include <math.h> | |
42 | #include "trek.h" | 42 | #include "trek.h" | |
43 | 43 | |||
44 | /* | 44 | /* | |
45 | ** compute klingon distances | 45 | ** compute klingon distances | |
46 | ** | 46 | ** | |
47 | ** The klingon list has the distances for all klingons recomputed | 47 | ** The klingon list has the distances for all klingons recomputed | |
48 | ** and sorted. The parameter is a Boolean flag which is set if | 48 | ** and sorted. The parameter is a Boolean flag which is set if | |
49 | ** we have just entered a new quadrant. | 49 | ** we have just entered a new quadrant. | |
50 | ** | 50 | ** | |
@@ -55,67 +55,62 @@ __RCSID("$NetBSD: compkl.c,v 1.7 2009/05 | @@ -55,67 +55,62 @@ __RCSID("$NetBSD: compkl.c,v 1.7 2009/05 | |||
55 | */ | 55 | */ | |
56 | 56 | |||
57 | static void sortkl(void); | 57 | static void sortkl(void); | |
58 | 58 | |||
59 | void | 59 | void | |
60 | compkldist(int f) | 60 | compkldist(int f) | |
61 | { | 61 | { | |
62 | int i, dx, dy; | 62 | int i, dx, dy; | |
63 | double d; | 63 | double d; | |
64 | double temp; | 64 | double temp; | |
65 | 65 | |||
66 | if (Etc.nkling == 0) | 66 | if (Etc.nkling == 0) | |
67 | return; | 67 | return; | |
68 | for (i = 0; i < Etc.nkling; i++) | 68 | for (i = 0; i < Etc.nkling; i++) { | |
69 | { | |||
70 | /* compute distance to the Klingon */ | 69 | /* compute distance to the Klingon */ | |
71 | dx = Ship.sectx - Etc.klingon[i].x; | 70 | dx = Ship.sectx - Etc.klingon[i].x; | |
72 | dy = Ship.secty - Etc.klingon[i].y; | 71 | dy = Ship.secty - Etc.klingon[i].y; | |
73 | d = dx * dx + dy * dy; | 72 | d = dx * dx + dy * dy; | |
74 | d = sqrt(d); | 73 | d = sqrt(d); | |
75 | 74 | |||
76 | /* compute average of new and old distances to Klingon */ | 75 | /* compute average of new and old distances to Klingon */ | |
77 | if (!f) | 76 | if (!f) { | |
78 | { | |||
79 | temp = Etc.klingon[i].dist; | 77 | temp = Etc.klingon[i].dist; | |
80 | Etc.klingon[i].avgdist = 0.5 * (temp + d); | 78 | Etc.klingon[i].avgdist = 0.5 * (temp + d); | |
81 | } | 79 | } else { | |
82 | else | |||
83 | { | |||
84 | /* new quadrant: average is current */ | 80 | /* new quadrant: average is current */ | |
85 | Etc.klingon[i].avgdist = d; | 81 | Etc.klingon[i].avgdist = d; | |
86 | } | 82 | } | |
87 | Etc.klingon[i].dist = d; | 83 | Etc.klingon[i].dist = d; | |
88 | } | 84 | } | |
89 | 85 | |||
90 | /* leave them sorted */ | 86 | /* leave them sorted */ | |
91 | sortkl(); | 87 | sortkl(); | |
92 | } | 88 | } | |
93 | 89 | |||
94 | 90 | |||
95 | /* | 91 | /* | |
96 | ** sort klingons | 92 | ** sort klingons | |
97 | ** | 93 | ** | |
98 | ** bubble sort on ascending distance | 94 | ** bubble sort on ascending distance | |
99 | */ | 95 | */ | |
100 | 96 | |||
101 | static void | 97 | static void | |
102 | sortkl(void) | 98 | sortkl(void) | |
103 | { | 99 | { | |
104 | struct kling t; | 100 | struct kling t; | |
105 | int f, i, m; | 101 | int f, i, m; | |
106 | 102 | |||
107 | m = Etc.nkling - 1; | 103 | m = Etc.nkling - 1; | |
108 | f = 1; | 104 | f = 1; | |
109 | while (f) | 105 | while (f) { | |
110 | { | |||
111 | f = 0; | 106 | f = 0; | |
112 | for (i = 0; i < m; i++) | 107 | for (i = 0; i < m; i++) { | |
113 | if (Etc.klingon[i].dist > Etc.klingon[i+1].dist) | 108 | if (Etc.klingon[i].dist > Etc.klingon[i+1].dist) { | |
114 | { | |||
115 | t = Etc.klingon[i]; | 109 | t = Etc.klingon[i]; | |
116 | Etc.klingon[i] = Etc.klingon[i+1]; | 110 | Etc.klingon[i] = Etc.klingon[i+1]; | |
117 | Etc.klingon[i+1] = t; | 111 | Etc.klingon[i+1] = t; | |
118 | f = 1; | 112 | f = 1; | |
119 | } | 113 | } | |
114 | } | |||
120 | } | 115 | } | |
121 | } | 116 | } |
--- src/games/trek/damage.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/damage.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: damage.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: damage.c,v 1.8 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: damage.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: damage.c,v 1.8 2009/05/24 21:44:56 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 "trek.h" | 43 | #include "trek.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** Schedule Ship.damages to a Device | 46 | ** Schedule Ship.damages to a Device | |
47 | ** | 47 | ** | |
48 | ** Device `dev1' is damaged in an amount `dam'. Dam is measured | 48 | ** Device `dev1' is damaged in an amount `dam'. Dam is measured | |
49 | ** in stardates, and is an additional amount of damage. It should | 49 | ** in stardates, and is an additional amount of damage. It should | |
50 | ** be the amount to occur in non-docked mode. The adjustment | 50 | ** be the amount to occur in non-docked mode. The adjustment | |
@@ -67,32 +67,30 @@ damage(int dev1, double dam) | @@ -67,32 +67,30 @@ damage(int dev1, double dam) | |||
67 | 67 | |||
68 | /* ignore zero damages */ | 68 | /* ignore zero damages */ | |
69 | if (dam <= 0.0) | 69 | if (dam <= 0.0) | |
70 | return; | 70 | return; | |
71 | dev = dev1; | 71 | dev = dev1; | |
72 | 72 | |||
73 | printf("\t%s damaged\n", Device[dev].name); | 73 | printf("\t%s damaged\n", Device[dev].name); | |
74 | 74 | |||
75 | /* find actual length till it will be fixed */ | 75 | /* find actual length till it will be fixed */ | |
76 | if (Ship.cond == DOCKED) | 76 | if (Ship.cond == DOCKED) | |
77 | dam *= Param.dockfac; | 77 | dam *= Param.dockfac; | |
78 | /* set the damage flag */ | 78 | /* set the damage flag */ | |
79 | f = damaged(dev); | 79 | f = damaged(dev); | |
80 | if (!f) | 80 | if (!f) { | |
81 | { | |||
82 | /* new damages -- schedule a fix */ | 81 | /* new damages -- schedule a fix */ | |
83 | schedule(E_FIXDV, dam, 0, 0, dev); | 82 | schedule(E_FIXDV, dam, 0, 0, dev); | |
84 | return; | 83 | return; | |
85 | } | 84 | } | |
86 | /* device already damaged -- add to existing damages */ | 85 | /* device already damaged -- add to existing damages */ | |
87 | /* scan for old damages */ | 86 | /* scan for old damages */ | |
88 | for (i = 0; i < MAXEVENTS; i++) | 87 | for (i = 0; i < MAXEVENTS; i++) { | |
89 | { | |||
90 | e = &Event[i]; | 88 | e = &Event[i]; | |
91 | if (e->evcode != E_FIXDV || e->systemname != dev) | 89 | if (e->evcode != E_FIXDV || e->systemname != dev) | |
92 | continue; | 90 | continue; | |
93 | /* got the right one; add on the new damages */ | 91 | /* got the right one; add on the new damages */ | |
94 | reschedule(e, e->date - Now.date + dam); | 92 | reschedule(e, e->date - Now.date + dam); | |
95 | return; | 93 | return; | |
96 | } | 94 | } | |
97 | errx(1, "Cannot find old damages %d", dev); | 95 | errx(1, "Cannot find old damages %d", dev); | |
98 | } | 96 | } |
--- src/games/trek/damaged.c 2009/05/24 20:39:43 1.7
+++ src/games/trek/damaged.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: damaged.c,v 1.8 2009/05/24 21:44:56 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,47 +24,46 @@ | @@ -24,47 +24,46 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: damaged.c,v 1.8 2009/05/24 21:44:56 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 | |||
50 | int | 50 | int | |
51 | damaged(int dev) | 51 | damaged(int dev) | |
52 | { | 52 | { | |
53 | int d; | 53 | int d; | |
54 | struct event *e; | 54 | struct event *e; | |
55 | int i; | 55 | int i; | |
56 | 56 | |||
57 | d = dev; | 57 | d = dev; | |
58 | 58 | |||
59 | for (i = 0; i < MAXEVENTS; i++) | 59 | for (i = 0; i < MAXEVENTS; i++) { | |
60 | { | |||
61 | e = &Event[i]; | 60 | e = &Event[i]; | |
62 | if (e->evcode != E_FIXDV) | 61 | if (e->evcode != E_FIXDV) | |
63 | continue; | 62 | continue; | |
64 | if (e->systemname == d) | 63 | if (e->systemname == d) | |
65 | return (1); | 64 | return (1); | |
66 | } | 65 | } | |
67 | 66 | |||
68 | /* device fix not in event list -- device must not be broken */ | 67 | /* device fix not in event list -- device must not be broken */ | |
69 | return (0); | 68 | return (0); | |
70 | } | 69 | } |
--- src/games/trek/klmove.c 2009/05/24 20:39:43 1.7
+++ src/games/trek/klmove.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: klmove.c,v 1.8 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: klmove.c,v 1.8 2009/05/24 21:44:56 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. | |
@@ -72,115 +72,106 @@ klmove(int fl) | @@ -72,115 +72,106 @@ klmove(int fl) | |||
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 | { | |||
87 | k = &Etc.klingon[n]; | 86 | k = &Etc.klingon[n]; | |
88 | i = 100; | 87 | i = 100; | |
89 | if (fl) | 88 | if (fl) | |
90 | i = 100.0 * k->power / Param.klingpwr; | 89 | i = 100.0 * k->power / Param.klingpwr; | |
91 | if (ranf(i) >= Param.moveprob[2 * Move.newquad + fl]) | 90 | if (ranf(i) >= Param.moveprob[2 * Move.newquad + fl]) | |
92 | continue; | 91 | continue; | |
93 | /* compute distance to move */ | 92 | /* compute distance to move */ | |
94 | motion = ranf(75) - 25; | 93 | motion = ranf(75) - 25; | |
95 | motion *= k->avgdist * Param.movefac[2 * Move.newquad + fl]; | 94 | motion *= k->avgdist * Param.movefac[2 * Move.newquad + fl]; | |
96 | /* compute direction */ | 95 | /* compute direction */ | |
97 | dx = Ship.sectx - k->x + ranf(3) - 1; | 96 | dx = Ship.sectx - k->x + ranf(3) - 1; | |
98 | dy = Ship.secty - k->y + ranf(3) - 1; | 97 | dy = Ship.secty - k->y + ranf(3) - 1; | |
99 | bigger = dx; | 98 | bigger = dx; | |
100 | if (dy > bigger) | 99 | if (dy > bigger) | |
101 | bigger = dy; | 100 | bigger = dy; | |
102 | if (bigger == 0.0) | 101 | if (bigger == 0.0) | |
103 | bigger = 1.0; | 102 | bigger = 1.0; | |
104 | dx = dx / bigger + 0.5; | 103 | dx = dx / bigger + 0.5; | |
105 | dy = dy / bigger + 0.5; | 104 | dy = dy / bigger + 0.5; | |
106 | if (motion < 0) | 105 | if (motion < 0) { | |
107 | { | |||
108 | motion = -motion; | 106 | motion = -motion; | |
109 | dx = -dx; | 107 | dx = -dx; | |
110 | dy = -dy; | 108 | dy = -dy; | |
111 | } | 109 | } | |
112 | fudgex = fudgey = 1; | 110 | fudgex = fudgey = 1; | |
113 | /* try to move the klingon */ | 111 | /* try to move the klingon */ | |
114 | nextx = k->x; | 112 | nextx = k->x; | |
115 | nexty = k->y; | 113 | nexty = k->y; | |
116 | for (; motion > 0; motion--) | 114 | for (; motion > 0; motion--) { | |
117 | { | |||
118 | lookx = nextx + dx; | 115 | lookx = nextx + dx; | |
119 | looky = nexty + dy; | 116 | looky = nexty + dy; | |
120 | if (lookx < 0 || lookx >= NSECTS || looky < 0 || looky >= NSECTS) | 117 | if (lookx < 0 || lookx >= NSECTS || looky < 0 || looky >= NSECTS) { | |
121 | { | |||
122 | /* new quadrant */ | 118 | /* new quadrant */ | |
123 | qx = Ship.quadx; | 119 | qx = Ship.quadx; | |
124 | qy = Ship.quady; | 120 | qy = Ship.quady; | |
125 | if (lookx < 0) | 121 | if (lookx < 0) | |
126 | qx -= 1; | 122 | qx -= 1; | |
127 | else | 123 | else | |
128 | if (lookx >= NSECTS) | 124 | if (lookx >= NSECTS) | |
129 | qx += 1; | 125 | qx += 1; | |
130 | if (looky < 0) | 126 | if (looky < 0) | |
131 | qy -= 1; | 127 | qy -= 1; | |
132 | else | 128 | else | |
133 | if (looky >= NSECTS) | 129 | if (looky >= NSECTS) | |
134 | qy += 1; | 130 | qy += 1; | |
135 | if (qx < 0 || qx >= NQUADS || qy < 0 || qy >= NQUADS || | 131 | if (qx < 0 || qx >= NQUADS || qy < 0 || qy >= NQUADS || | |
136 | Quad[qx][qy].stars < 0 || Quad[qx][qy].klings > MAXKLQUAD - 1) | 132 | Quad[qx][qy].stars < 0 || Quad[qx][qy].klings > MAXKLQUAD - 1) | |
137 | break; | 133 | break; | |
138 | if (!damaged(SRSCAN)) | 134 | if (!damaged(SRSCAN)) { | |
139 | { | |||
140 | printf("Klingon at %d,%d escapes to quadrant %d,%d\n", | 135 | printf("Klingon at %d,%d escapes to quadrant %d,%d\n", | |
141 | k->x, k->y, qx, qy); | 136 | k->x, k->y, qx, qy); | |
142 | motion = Quad[qx][qy].scanned; | 137 | motion = Quad[qx][qy].scanned; | |
143 | if (motion >= 0 && motion < 1000) | 138 | if (motion >= 0 && motion < 1000) | |
144 | Quad[qx][qy].scanned += 100; | 139 | Quad[qx][qy].scanned += 100; | |
145 | motion = Quad[Ship.quadx][Ship.quady].scanned; | 140 | motion = Quad[Ship.quadx][Ship.quady].scanned; | |
146 | if (motion >= 0 && motion < 1000) | 141 | if (motion >= 0 && motion < 1000) | |
147 | Quad[Ship.quadx][Ship.quady].scanned -= 100; | 142 | Quad[Ship.quadx][Ship.quady].scanned -= 100; | |
148 | } | 143 | } | |
149 | Sect[k->x][k->y] = EMPTY; | 144 | Sect[k->x][k->y] = EMPTY; | |
150 | Quad[qx][qy].klings += 1; | 145 | Quad[qx][qy].klings += 1; | |
151 | Etc.nkling -= 1; | 146 | Etc.nkling -= 1; | |
152 | *k = Etc.klingon[Etc.nkling]; | 147 | *k = Etc.klingon[Etc.nkling]; | |
153 | Quad[Ship.quadx][Ship.quady].klings -= 1; | 148 | Quad[Ship.quadx][Ship.quady].klings -= 1; | |
154 | k = 0; | 149 | k = 0; | |
155 | break; | 150 | break; | |
156 | } | 151 | } | |
157 | if (Sect[lookx][looky] != EMPTY) | 152 | if (Sect[lookx][looky] != EMPTY) { | |
158 | { | |||
159 | lookx = nextx + fudgex; | 153 | lookx = nextx + fudgex; | |
160 | if (lookx < 0 || lookx >= NSECTS) | 154 | if (lookx < 0 || lookx >= NSECTS) | |
161 | lookx = nextx + dx; | 155 | lookx = nextx + dx; | |
162 | if (Sect[lookx][looky] != EMPTY) | 156 | if (Sect[lookx][looky] != EMPTY) { | |
163 | { | |||
164 | fudgex = -fudgex; | 157 | fudgex = -fudgex; | |
165 | looky = nexty + fudgey; | 158 | looky = nexty + fudgey; | |
166 | if (looky < 0 || looky >= NSECTS || Sect[lookx][looky] != EMPTY) | 159 | if (looky < 0 || looky >= NSECTS || Sect[lookx][looky] != EMPTY) { | |
167 | { | |||
168 | fudgey = -fudgey; | 160 | fudgey = -fudgey; | |
169 | break; | 161 | break; | |
170 | } | 162 | } | |
171 | } | 163 | } | |
172 | } | 164 | } | |
173 | nextx = lookx; | 165 | nextx = lookx; | |
174 | nexty = looky; | 166 | nexty = looky; | |
175 | } | 167 | } | |
176 | if (k && (k->x != nextx || k->y != nexty)) | 168 | if (k && (k->x != nextx || k->y != nexty)) { | |
177 | { | |||
178 | if (!damaged(SRSCAN)) | 169 | if (!damaged(SRSCAN)) | |
179 | printf("Klingon at %d,%d moves to %d,%d\n", | 170 | printf("Klingon at %d,%d moves to %d,%d\n", | |
180 | k->x, k->y, nextx, nexty); | 171 | k->x, k->y, nextx, nexty); | |
181 | Sect[k->x][k->y] = EMPTY; | 172 | Sect[k->x][k->y] = EMPTY; | |
182 | Sect[k->x = nextx][k->y = nexty] = KLINGON; | 173 | Sect[k->x = nextx][k->y = nexty] = KLINGON; | |
183 | } | 174 | } | |
184 | } | 175 | } | |
185 | compkldist(0); | 176 | compkldist(0); | |
186 | } | 177 | } |
--- src/games/trek/nova.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/nova.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nova.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: nova.c,v 1.8 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)nova.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)nova.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: nova.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: nova.c,v 1.8 2009/05/24 21:44:56 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 | ** CAUSE A NOVA TO OCCUR | 45 | ** CAUSE A NOVA TO OCCUR | |
46 | ** | 46 | ** | |
47 | ** A nova occurs. It is the result of having a star hit with | 47 | ** A nova occurs. It is the result of having a star hit with | |
48 | ** a photon torpedo. There are several things which may happen. | 48 | ** a photon torpedo. There are several things which may happen. | |
49 | ** The star may not be affected. It may go nova. It may turn | 49 | ** The star may not be affected. It may go nova. It may turn | |
50 | ** into a black hole. Any (yummy) it may go supernova. | 50 | ** into a black hole. Any (yummy) it may go supernova. | |
@@ -53,57 +53,52 @@ __RCSID("$NetBSD: nova.c,v 1.7 2009/05/2 | @@ -53,57 +53,52 @@ __RCSID("$NetBSD: nova.c,v 1.7 2009/05/2 | |||
53 | ** the same probabilistic process. Klingons next to them are | 53 | ** the same probabilistic process. Klingons next to them are | |
54 | ** destroyed. And if the starship is next to it, it gets zapped. | 54 | ** destroyed. And if the starship is next to it, it gets zapped. | |
55 | ** If the zap is too much, it gets destroyed. | 55 | ** If the zap is too much, it gets destroyed. | |
56 | */ | 56 | */ | |
57 | 57 | |||
58 | void | 58 | void | |
59 | nova(int x, int y) | 59 | nova(int x, int y) | |
60 | { | 60 | { | |
61 | int i, j; | 61 | int i, j; | |
62 | int se; | 62 | int se; | |
63 | 63 | |||
64 | if (Sect[x][y] != STAR || Quad[Ship.quadx][Ship.quady].stars < 0) | 64 | if (Sect[x][y] != STAR || Quad[Ship.quadx][Ship.quady].stars < 0) | |
65 | return; | 65 | return; | |
66 | if (ranf(100) < 15) | 66 | if (ranf(100) < 15) { | |
67 | { | |||
68 | printf("Spock: Star at %d,%d failed to nova.\n", x, y); | 67 | printf("Spock: Star at %d,%d failed to nova.\n", x, y); | |
69 | return; | 68 | return; | |
70 | } | 69 | } | |
71 | if (ranf(100) < 5) { | 70 | if (ranf(100) < 5) { | |
72 | snova(x, y); | 71 | snova(x, y); | |
73 | return; | 72 | return; | |
74 | } | 73 | } | |
75 | printf("Spock: Star at %d,%d gone nova\n", x, y); | 74 | printf("Spock: Star at %d,%d gone nova\n", x, y); | |
76 | 75 | |||
77 | if (ranf(4) != 0) | 76 | if (ranf(4) != 0) { | |
78 | Sect[x][y] = EMPTY; | 77 | Sect[x][y] = EMPTY; | |
79 | else | 78 | } else { | |
80 | { | |||
81 | Sect[x][y] = HOLE; | 79 | Sect[x][y] = HOLE; | |
82 | Quad[Ship.quadx][Ship.quady].holes += 1; | 80 | Quad[Ship.quadx][Ship.quady].holes += 1; | |
83 | } | 81 | } | |
84 | Quad[Ship.quadx][Ship.quady].stars -= 1; | 82 | Quad[Ship.quadx][Ship.quady].stars -= 1; | |
85 | Game.kills += 1; | 83 | Game.kills += 1; | |
86 | for (i = x - 1; i <= x + 1; i++) | 84 | for (i = x - 1; i <= x + 1; i++) { | |
87 | { | |||
88 | if (i < 0 || i >= NSECTS) | 85 | if (i < 0 || i >= NSECTS) | |
89 | continue; | 86 | continue; | |
90 | for (j = y - 1; j <= y + 1; j++) | 87 | for (j = y - 1; j <= y + 1; j++) { | |
91 | { | |||
92 | if (j < 0 || j >= NSECTS) | 88 | if (j < 0 || j >= NSECTS) | |
93 | continue; | 89 | continue; | |
94 | se = Sect[i][j]; | 90 | se = Sect[i][j]; | |
95 | switch (se) | 91 | switch (se) { | |
96 | { | |||
97 | 92 | |||
98 | case EMPTY: | 93 | case EMPTY: | |
99 | case HOLE: | 94 | case HOLE: | |
100 | break; | 95 | break; | |
101 | 96 | |||
102 | case KLINGON: | 97 | case KLINGON: | |
103 | killk(i, j); | 98 | killk(i, j); | |
104 | break; | 99 | break; | |
105 | 100 | |||
106 | case STAR: | 101 | case STAR: | |
107 | nova(i, j); | 102 | nova(i, j); | |
108 | break; | 103 | break; | |
109 | 104 |
--- src/games/trek/srscan.c 2009/05/24 19:18:44 1.7
+++ src/games/trek/srscan.c 2009/05/24 21:44:56 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: srscan.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: srscan.c,v 1.8 2009/05/24 21:44:56 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,112 +24,103 @@ | @@ -24,112 +24,103 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: srscan.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: srscan.c,v 1.8 2009/05/24 21:44:56 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 | #include "getpar.h" | 43 | #include "getpar.h" | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | ** SHORT RANGE SENSOR SCAN | 46 | ** SHORT RANGE SENSOR SCAN | |
47 | ** | 47 | ** | |
48 | ** A short range scan is taken of the current quadrant. If the | 48 | ** A short range scan is taken of the current quadrant. If the | |
49 | ** flag 'f' is one, it is an "auto srscan", which is not done | 49 | ** flag 'f' is one, it is an "auto srscan", which is not done | |
50 | ** unless in 'fast' mode. It does a status report and a srscan. | 50 | ** unless in 'fast' mode. It does a status report and a srscan. | |
51 | ** If 'f' is -1, you get a status report only. If it is zero, | 51 | ** If 'f' is -1, you get a status report only. If it is zero, | |
52 | ** you get a srscan and an optional status report. The status | 52 | ** you get a srscan and an optional status report. The status | |
53 | ** report is taken if you enter "srscan yes"; for all srscans | 53 | ** report is taken if you enter "srscan yes"; for all srscans | |
54 | ** thereafter you get a status report with your srscan until | 54 | ** thereafter you get a status report with your srscan until | |
55 | ** you type "srscan no". It defaults to on. | 55 | ** you type "srscan no". It defaults to on. | |
56 | ** | 56 | ** | |
57 | ** The current quadrant is filled in on the computer chart. | 57 | ** The current quadrant is filled in on the computer chart. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | const char *const Color[4] = | 60 | const char *const Color[4] = { | |
61 | { | |||
62 | "GREEN", | 61 | "GREEN", | |
63 | "DOCKED", | 62 | "DOCKED", | |
64 | "YELLOW", | 63 | "YELLOW", | |
65 | "RED" | 64 | "RED" | |
66 | }; | 65 | }; | |
67 | 66 | |||
68 | void | 67 | void | |
69 | srscan(int f) | 68 | srscan(int f) | |
70 | { | 69 | { | |
71 | int i, j; | 70 | int i, j; | |
72 | int statinfo; | 71 | int statinfo; | |
73 | const char *s; | 72 | const char *s; | |
74 | int percent; | 73 | int percent; | |
75 | struct quad *q = NULL; | 74 | struct quad *q = NULL; | |
76 | const struct cvntab *p; | 75 | const struct cvntab *p; | |
77 | 76 | |||
78 | if (f >= 0 && check_out(SRSCAN)) | 77 | if (f >= 0 && check_out(SRSCAN)) { | |
79 | { | |||
80 | return; | 78 | return; | |
81 | } | 79 | } | |
82 | if (f) | 80 | if (f) { | |
83 | statinfo = 1; | 81 | statinfo = 1; | |
84 | else | 82 | } else { | |
85 | { | |||
86 | if (!testnl()) | 83 | if (!testnl()) | |
87 | Etc.statreport = getynpar("status report"); | 84 | Etc.statreport = getynpar("status report"); | |
88 | statinfo = Etc.statreport; | 85 | statinfo = Etc.statreport; | |
89 | } | 86 | } | |
90 | if (f > 0) | 87 | if (f > 0) { | |
91 | { | |||
92 | Etc.statreport = 1; | 88 | Etc.statreport = 1; | |
93 | if (!Etc.fast) | 89 | if (!Etc.fast) | |
94 | return; | 90 | return; | |
95 | } | 91 | } | |
96 | if (f >= 0) | 92 | if (f >= 0) { | |
97 | { | |||
98 | printf("\nShort range sensor scan\n"); | 93 | printf("\nShort range sensor scan\n"); | |
99 | q = &Quad[Ship.quadx][Ship.quady]; | 94 | q = &Quad[Ship.quadx][Ship.quady]; | |
100 | q->scanned = q->klings * 100 + q->bases * 10 + q->stars; | 95 | q->scanned = q->klings * 100 + q->bases * 10 + q->stars; | |
101 | printf(" "); | 96 | printf(" "); | |
102 | for (i = 0; i < NSECTS; i++) | 97 | for (i = 0; i < NSECTS; i++) { | |
103 | { | |||
104 | printf("%d ", i); | 98 | printf("%d ", i); | |
105 | } | 99 | } | |
106 | printf("\n"); | 100 | printf("\n"); | |
107 | } | 101 | } | |
108 | 102 | |||
109 | for (i = 0; i < NSECTS; i++) | 103 | for (i = 0; i < NSECTS; i++) { | |
110 | { | 104 | if (f >= 0) { | |
111 | if (f >= 0) | |||
112 | { | |||
113 | printf("%d ", i); | 105 | printf("%d ", i); | |
114 | for (j = 0; j < NSECTS; j++) | 106 | for (j = 0; j < NSECTS; j++) | |
115 | printf("%c ", Sect[i][j]); | 107 | printf("%c ", Sect[i][j]); | |
116 | printf("%d", i); | 108 | printf("%d", i); | |
117 | if (statinfo) | 109 | if (statinfo) | |
118 | printf(" "); | 110 | printf(" "); | |
119 | } | 111 | } | |
120 | if (statinfo) | 112 | if (statinfo) | |
121 | switch (i) | 113 | switch (i) { | |
122 | { | |||
123 | case 0: | 114 | case 0: | |
124 | printf("stardate %.2f", Now.date); | 115 | printf("stardate %.2f", Now.date); | |
125 | break; | 116 | break; | |
126 | case 1: | 117 | case 1: | |
127 | printf("condition %s", Color[Ship.cond]); | 118 | printf("condition %s", Color[Ship.cond]); | |
128 | if (Ship.cloaked) | 119 | if (Ship.cloaked) | |
129 | printf(", CLOAKED"); | 120 | printf(", CLOAKED"); | |
130 | break; | 121 | break; | |
131 | case 2: | 122 | case 2: | |
132 | printf("position %d,%d/%d,%d",Ship.quadx, Ship.quady, Ship.sectx, Ship.secty); | 123 | printf("position %d,%d/%d,%d",Ship.quadx, Ship.quady, Ship.sectx, Ship.secty); | |
133 | break; | 124 | break; | |
134 | case 3: | 125 | case 3: | |
135 | printf("warp factor %.1f", Ship.warp); | 126 | printf("warp factor %.1f", Ship.warp); | |
@@ -147,38 +138,36 @@ srscan(int f) | @@ -147,38 +138,36 @@ srscan(int f) | |||
147 | if (damaged(SHIELD)) | 138 | if (damaged(SHIELD)) | |
148 | s = "damaged"; | 139 | s = "damaged"; | |
149 | percent = 100.0 * Ship.shield / Param.shield; | 140 | percent = 100.0 * Ship.shield / Param.shield; | |
150 | printf("shields %s, %d%%", s, percent); | 141 | printf("shields %s, %d%%", s, percent); | |
151 | break; | 142 | break; | |
152 | case 7: | 143 | case 7: | |
153 | printf("Klingons left %d", Now.klings); | 144 | printf("Klingons left %d", Now.klings); | |
154 | break; | 145 | break; | |
155 | case 8: | 146 | case 8: | |
156 | printf("time left %.2f", Now.time); | 147 | printf("time left %.2f", Now.time); | |
157 | break; | 148 | break; | |
158 | case 9: | 149 | case 9: | |
159 | printf("life support "); | 150 | printf("life support "); | |
160 | if (damaged(LIFESUP)) | 151 | if (damaged(LIFESUP)) { | |
161 | { | |||
162 | printf("damaged, reserves = %.2f", Ship.reserves); | 152 | printf("damaged, reserves = %.2f", Ship.reserves); | |
163 | break; | 153 | break; | |
164 | } | 154 | } | |
165 | printf("active"); | 155 | printf("active"); | |
166 | break; | 156 | break; | |
167 | } | 157 | } | |
168 | printf("\n"); | 158 | printf("\n"); | |
169 | } | 159 | } | |
170 | if (f < 0) | 160 | if (f < 0) { | |
171 | { | |||
172 | printf("current crew %d\n", Ship.crew); | 161 | printf("current crew %d\n", Ship.crew); | |
173 | printf("brig space %d\n", Ship.brigfree); | 162 | printf("brig space %d\n", Ship.brigfree); | |
174 | printf("Klingon power %d\n", Param.klingpwr); | 163 | printf("Klingon power %d\n", Param.klingpwr); | |
175 | p = &Lentab[Game.length - 1]; | 164 | p = &Lentab[Game.length - 1]; | |
176 | if (Game.length > 2) | 165 | if (Game.length > 2) | |
177 | p--; | 166 | p--; | |
178 | printf("Length, Skill %s%s, ", p->abrev, p->full); | 167 | printf("Length, Skill %s%s, ", p->abrev, p->full); | |
179 | p = &Skitab[Game.skill - 1]; | 168 | p = &Skitab[Game.skill - 1]; | |
180 | printf("%s%s\n", p->abrev, p->full); | 169 | printf("%s%s\n", p->abrev, p->full); | |
181 | return; | 170 | return; | |
182 | } | 171 | } | |
183 | printf(" "); | 172 | printf(" "); | |
184 | for (i = 0; i < NSECTS; i++) | 173 | for (i = 0; i < NSECTS; i++) |
--- src/games/trek/computer.c 2009/05/24 19:18:44 1.12
+++ src/games/trek/computer.c 2009/05/24 21:44:56 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: computer.c,v 1.12 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: computer.c,v 1.13 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: computer.c,v 1.12 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: computer.c,v 1.13 2009/05/24 21:44:56 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 <stdlib.h> | 42 | #include <stdlib.h> | |
43 | #include <math.h> | 43 | #include <math.h> | |
44 | #include "trek.h" | 44 | #include "trek.h" | |
45 | #include "getpar.h" | 45 | #include "getpar.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** On-Board Computer | 48 | ** On-Board Computer | |
49 | ** | 49 | ** | |
50 | ** A computer request is fetched from the captain. The requests | 50 | ** A computer request is fetched from the captain. The requests | |
@@ -80,28 +80,27 @@ __RCSID("$NetBSD: computer.c,v 1.12 2009 | @@ -80,28 +80,27 @@ __RCSID("$NetBSD: computer.c,v 1.12 2009 | |||
80 | ** a given distance under a given warp speed. | 80 | ** a given distance under a given warp speed. | |
81 | ** | 81 | ** | |
82 | ** impcost -- Same for the impulse engines. | 82 | ** impcost -- Same for the impulse engines. | |
83 | ** | 83 | ** | |
84 | ** distresslist -- Gives a list of the currently known starsystems | 84 | ** distresslist -- Gives a list of the currently known starsystems | |
85 | ** or starbases which are distressed, together with their | 85 | ** or starbases which are distressed, together with their | |
86 | ** quadrant coordinates. | 86 | ** quadrant coordinates. | |
87 | ** | 87 | ** | |
88 | ** If a command is terminated with a semicolon, you remain in | 88 | ** If a command is terminated with a semicolon, you remain in | |
89 | ** the computer; otherwise, you escape immediately to the main | 89 | ** the computer; otherwise, you escape immediately to the main | |
90 | ** command processor. | 90 | ** command processor. | |
91 | */ | 91 | */ | |
92 | 92 | |||
93 | struct cvntab Cputab[] = | 93 | struct cvntab Cputab[] = { | |
94 | { | |||
95 | { "ch", "art", (cmdfun)1, 0 }, | 94 | { "ch", "art", (cmdfun)1, 0 }, | |
96 | { "t", "rajectory", (cmdfun)2, 0 }, | 95 | { "t", "rajectory", (cmdfun)2, 0 }, | |
97 | { "c", "ourse", (cmdfun)3, 0 }, | 96 | { "c", "ourse", (cmdfun)3, 0 }, | |
98 | { "m", "ove", (cmdfun)3, 1 }, | 97 | { "m", "ove", (cmdfun)3, 1 }, | |
99 | { "s", "core", (cmdfun)4, 0 }, | 98 | { "s", "core", (cmdfun)4, 0 }, | |
100 | { "p", "heff", (cmdfun)5, 0 }, | 99 | { "p", "heff", (cmdfun)5, 0 }, | |
101 | { "w", "arpcost", (cmdfun)6, 0 }, | 100 | { "w", "arpcost", (cmdfun)6, 0 }, | |
102 | { "i", "mpcost", (cmdfun)7, 0 }, | 101 | { "i", "mpcost", (cmdfun)7, 0 }, | |
103 | { "d", "istresslist", (cmdfun)8, 0 }, | 102 | { "d", "istresslist", (cmdfun)8, 0 }, | |
104 | { NULL, NULL, NULL, 0 } | 103 | { NULL, NULL, NULL, 0 } | |
105 | }; | 104 | }; | |
106 | 105 | |||
107 | static int kalc(int, int, int, int, double *); | 106 | static int kalc(int, int, int, int, double *); | |
@@ -114,116 +113,104 @@ computer(int v __unused) | @@ -114,116 +113,104 @@ computer(int v __unused) | |||
114 | int ix, iy; | 113 | int ix, iy; | |
115 | int i, j; | 114 | int i, j; | |
116 | int tqx, tqy; | 115 | int tqx, tqy; | |
117 | const struct cvntab *r; | 116 | const struct cvntab *r; | |
118 | int cost; | 117 | int cost; | |
119 | int course; | 118 | int course; | |
120 | double dist, time; | 119 | double dist, time; | |
121 | double warpfact; | 120 | double warpfact; | |
122 | struct quad *q; | 121 | struct quad *q; | |
123 | struct event *e; | 122 | struct event *e; | |
124 | 123 | |||
125 | if (check_out(COMPUTER)) | 124 | if (check_out(COMPUTER)) | |
126 | return; | 125 | return; | |
127 | while (1) | 126 | while (1) { | |
128 | { | |||
129 | r = getcodpar("\nRequest", Cputab); | 127 | r = getcodpar("\nRequest", Cputab); | |
130 | switch ((long)r->value) | 128 | switch ((long)r->value) { | |
131 | { | |||
132 | 129 | |||
133 | case 1: /* star chart */ | 130 | case 1: /* star chart */ | |
134 | printf("Computer record of galaxy for all long range sensor scans\n\n"); | 131 | printf("Computer record of galaxy for all long range sensor scans\n\n"); | |
135 | printf(" "); | 132 | printf(" "); | |
136 | /* print top header */ | 133 | /* print top header */ | |
137 | for (i = 0; i < NQUADS; i++) | 134 | for (i = 0; i < NQUADS; i++) | |
138 | printf("-%d- ", i); | 135 | printf("-%d- ", i); | |
139 | printf("\n"); | 136 | printf("\n"); | |
140 | for (i = 0; i < NQUADS; i++) | 137 | for (i = 0; i < NQUADS; i++) { | |
141 | { | |||
142 | printf("%d ", i); | 138 | printf("%d ", i); | |
143 | for (j = 0; j < NQUADS; j++) | 139 | for (j = 0; j < NQUADS; j++) { | |
144 | { | 140 | if (i == Ship.quadx && j == Ship.quady) { | |
145 | if (i == Ship.quadx && j == Ship.quady) | |||
146 | { | |||
147 | printf("$$$ "); | 141 | printf("$$$ "); | |
148 | continue; | 142 | continue; | |
149 | } | 143 | } | |
150 | q = &Quad[i][j]; | 144 | q = &Quad[i][j]; | |
151 | /* 1000 or 1001 is special case */ | 145 | /* 1000 or 1001 is special case */ | |
152 | if (q->scanned >= 1000) | 146 | if (q->scanned >= 1000) | |
153 | if (q->scanned > 1000) | 147 | if (q->scanned > 1000) | |
154 | printf(".1. "); | 148 | printf(".1. "); | |
155 | else | 149 | else | |
156 | printf("/// "); | 150 | printf("/// "); | |
157 | else | 151 | else | |
158 | if (q->scanned < 0) | 152 | if (q->scanned < 0) | |
159 | printf("... "); | 153 | printf("... "); | |
160 | else | 154 | else | |
161 | printf("%3d ", q->scanned); | 155 | printf("%3d ", q->scanned); | |
162 | } | 156 | } | |
163 | printf("%d\n", i); | 157 | printf("%d\n", i); | |
164 | } | 158 | } | |
165 | printf(" "); | 159 | printf(" "); | |
166 | /* print bottom footer */ | 160 | /* print bottom footer */ | |
167 | for (i = 0; i < NQUADS; i++) | 161 | for (i = 0; i < NQUADS; i++) | |
168 | printf("-%d- ", i); | 162 | printf("-%d- ", i); | |
169 | printf("\n"); | 163 | printf("\n"); | |
170 | break; | 164 | break; | |
171 | 165 | |||
172 | case 2: /* trajectory */ | 166 | case 2: /* trajectory */ | |
173 | if (check_out(SRSCAN)) | 167 | if (check_out(SRSCAN)) { | |
174 | { | |||
175 | break; | 168 | break; | |
176 | } | 169 | } | |
177 | if (Etc.nkling <= 0) | 170 | if (Etc.nkling <= 0) { | |
178 | { | |||
179 | printf("No Klingons in this quadrant\n"); | 171 | printf("No Klingons in this quadrant\n"); | |
180 | break; | 172 | break; | |
181 | } | 173 | } | |
182 | /* for each Klingon, give the course & distance */ | 174 | /* for each Klingon, give the course & distance */ | |
183 | for (i = 0; i < Etc.nkling; i++) | 175 | for (i = 0; i < Etc.nkling; i++) { | |
184 | { | |||
185 | printf("Klingon at %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); | 176 | printf("Klingon at %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); | |
186 | course = kalc(Ship.quadx, Ship.quady, Etc.klingon[i].x, Etc.klingon[i].y, &dist); | 177 | course = kalc(Ship.quadx, Ship.quady, Etc.klingon[i].x, Etc.klingon[i].y, &dist); | |
187 | prkalc(course, dist); | 178 | prkalc(course, dist); | |
188 | } | 179 | } | |
189 | break; | 180 | break; | |
190 | 181 | |||
191 | case 3: /* course calculation */ | 182 | case 3: /* course calculation */ | |
192 | if (readdelim('/')) | 183 | if (readdelim('/')) { | |
193 | { | |||
194 | tqx = Ship.quadx; | 184 | tqx = Ship.quadx; | |
195 | tqy = Ship.quady; | 185 | tqy = Ship.quady; | |
196 | } | 186 | } else { | |
197 | else | |||
198 | { | |||
199 | ix = getintpar("Quadrant"); | 187 | ix = getintpar("Quadrant"); | |
200 | if (ix < 0 || ix >= NSECTS) | 188 | if (ix < 0 || ix >= NSECTS) | |
201 | break; | 189 | break; | |
202 | iy = getintpar("q-y"); | 190 | iy = getintpar("q-y"); | |
203 | if (iy < 0 || iy >= NSECTS) | 191 | if (iy < 0 || iy >= NSECTS) | |
204 | break; | 192 | break; | |
205 | tqx = ix; | 193 | tqx = ix; | |
206 | tqy = iy; | 194 | tqy = iy; | |
207 | } | 195 | } | |
208 | ix = getintpar("Sector"); | 196 | ix = getintpar("Sector"); | |
209 | if (ix < 0 || ix >= NSECTS) | 197 | if (ix < 0 || ix >= NSECTS) | |
210 | break; | 198 | break; | |
211 | iy = getintpar("s-y"); | 199 | iy = getintpar("s-y"); | |
212 | if (iy < 0 || iy >= NSECTS) | 200 | if (iy < 0 || iy >= NSECTS) | |
213 | break; | 201 | break; | |
214 | course = kalc(tqx, tqy, ix, iy, &dist); | 202 | course = kalc(tqx, tqy, ix, iy, &dist); | |
215 | if (r->value2) | 203 | if (r->value2) { | |
216 | { | |||
217 | warp(-1, course, dist); | 204 | warp(-1, course, dist); | |
218 | break; | 205 | break; | |
219 | } | 206 | } | |
220 | printf("%d,%d/%d,%d to %d,%d/%d,%d", | 207 | printf("%d,%d/%d,%d to %d,%d/%d,%d", | |
221 | Ship.quadx, Ship.quady, Ship.sectx, Ship.secty, tqx, tqy, ix, iy); | 208 | Ship.quadx, Ship.quady, Ship.sectx, Ship.secty, tqx, tqy, ix, iy); | |
222 | prkalc(course, dist); | 209 | prkalc(course, dist); | |
223 | break; | 210 | break; | |
224 | 211 | |||
225 | case 4: /* score */ | 212 | case 4: /* score */ | |
226 | score(); | 213 | score(); | |
227 | break; | 214 | break; | |
228 | 215 | |||
229 | case 5: /* phaser effectiveness */ | 216 | case 5: /* phaser effectiveness */ | |
@@ -252,64 +239,62 @@ computer(int v __unused) | @@ -252,64 +239,62 @@ computer(int v __unused) | |||
252 | dist = getfltpar("distance"); | 239 | dist = getfltpar("distance"); | |
253 | if (dist < 0.0) | 240 | if (dist < 0.0) | |
254 | break; | 241 | break; | |
255 | cost = 20 + 100 * dist; | 242 | cost = 20 + 100 * dist; | |
256 | time = dist / 0.095; | 243 | time = dist / 0.095; | |
257 | printf("Distance %.2f cost %.2f stardates %d units\n", | 244 | printf("Distance %.2f cost %.2f stardates %d units\n", | |
258 | dist, time, cost); | 245 | dist, time, cost); | |
259 | break; | 246 | break; | |
260 | 247 | |||
261 | case 8: /* distresslist */ | 248 | case 8: /* distresslist */ | |
262 | j = 1; | 249 | j = 1; | |
263 | printf("\n"); | 250 | printf("\n"); | |
264 | /* scan the event list */ | 251 | /* scan the event list */ | |
265 | for (i = 0; i < MAXEVENTS; i++) | 252 | for (i = 0; i < MAXEVENTS; i++) { | |
266 | { | |||
267 | e = &Event[i]; | 253 | e = &Event[i]; | |
268 | /* ignore hidden entries */ | 254 | /* ignore hidden entries */ | |
269 | if (e->evcode & E_HIDDEN) | 255 | if (e->evcode & E_HIDDEN) | |
270 | continue; | 256 | continue; | |
271 | switch (e->evcode & E_EVENT) | 257 | switch (e->evcode & E_EVENT) { | |
272 | { | |||
273 | 258 | |||
274 | case E_KDESB: | 259 | case E_KDESB: | |
275 | printf("Klingon is attacking starbase in quadrant %d,%d\n", | 260 | printf("Klingon is attacking starbase in quadrant %d,%d\n", | |
276 | e->x, e->y); | 261 | e->x, e->y); | |
277 | j = 0; | 262 | j = 0; | |
278 | break; | 263 | break; | |
279 | 264 | |||
280 | case E_ENSLV: | 265 | case E_ENSLV: | |
281 | case E_REPRO: | 266 | case E_REPRO: | |
282 | printf("Starsystem %s in quadrant %d,%d is distressed\n", | 267 | printf("Starsystem %s in quadrant %d,%d is distressed\n", | |
283 | Systemname[e->systemname], e->x, e->y); | 268 | Systemname[e->systemname], e->x, e->y); | |
284 | j = 0; | 269 | j = 0; | |
285 | break; | 270 | break; | |
286 | } | 271 | } | |
287 | } | 272 | } | |
288 | if (j) | 273 | if (j) | |
289 | printf("No known distress calls are active\n"); | 274 | printf("No known distress calls are active\n"); | |
290 | break; | 275 | break; | |
291 | 276 | |||
292 | } | 277 | } | |
293 | 278 | |||
294 | /* skip to next semicolon or newline. Semicolon | 279 | /* | |
280 | * Skip to next semicolon or newline. Semicolon | |||
295 | * means get new computer request; newline means | 281 | * means get new computer request; newline means | |
296 | * exit computer mode. */ | 282 | * exit computer mode. | |
297 | while ((i = cgetc(0)) != ';') | 283 | */ | |
298 | { | 284 | while ((i = cgetc(0)) != ';') { | |
299 | if (i == '\0') | 285 | if (i == '\0') | |
300 | exit(1); | 286 | exit(1); | |
301 | if (i == '\n') | 287 | if (i == '\n') { | |
302 | { | |||
303 | ungetc(i, stdin); | 288 | ungetc(i, stdin); | |
304 | return; | 289 | return; | |
305 | } | 290 | } | |
306 | } | 291 | } | |
307 | } | 292 | } | |
308 | } | 293 | } | |
309 | 294 | |||
310 | 295 | |||
311 | /* | 296 | /* | |
312 | ** Course Calculation | 297 | ** Course Calculation | |
313 | ** | 298 | ** | |
314 | ** Computes and outputs the course and distance from position | 299 | ** Computes and outputs the course and distance from position | |
315 | ** sqx,sqy/ssx,ssy to tqx,tqy/tsx,tsy. | 300 | ** sqx,sqy/ssx,ssy to tqx,tqy/tsx,tsy. |
--- src/games/trek/phaser.c 2009/05/24 20:39:43 1.12
+++ src/games/trek/phaser.c 2009/05/24 21:44:56 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: phaser.c,v 1.13 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: phaser.c,v 1.13 2009/05/24 21:44:56 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) */ | |
@@ -66,35 +66,33 @@ __RCSID("$NetBSD: phaser.c,v 1.12 2009/0 | @@ -66,35 +66,33 @@ __RCSID("$NetBSD: phaser.c,v 1.12 2009/0 | |||
66 | ** The spread is specified as a number between zero and | 66 | ** The spread is specified as a number between zero and | |
67 | ** one, with zero being minimum spread and one being maximum | 67 | ** one, with zero being minimum spread and one being maximum | |
68 | ** spread. You will normally want zero spread, unless your | 68 | ** spread. You will normally want zero spread, unless your | |
69 | ** short range scanners are out, in which case you probably | 69 | ** short range scanners are out, in which case you probably | |
70 | ** don't know exactly where the Klingons are. In that case, | 70 | ** don't know exactly where the Klingons are. In that case, | |
71 | ** you really don't have any choice except to specify a | 71 | ** you really don't have any choice except to specify a | |
72 | ** fairly large spread. | 72 | ** fairly large spread. | |
73 | ** | 73 | ** | |
74 | ** Phasers spread slightly, even if you specify zero spread. | 74 | ** Phasers spread slightly, even if you specify zero spread. | |
75 | ** | 75 | ** | |
76 | ** Uses trace flag 30 | 76 | ** Uses trace flag 30 | |
77 | */ | 77 | */ | |
78 | 78 | |||
79 | struct cvntab Matab[] = | 79 | struct cvntab Matab[] = { | |
80 | { | |||
81 | { "m", "anual", (cmdfun) 1, 0 }, | 80 | { "m", "anual", (cmdfun) 1, 0 }, | |
82 | { "a", "utomatic", (cmdfun) 0, 0 }, | 81 | { "a", "utomatic", (cmdfun) 0, 0 }, | |
83 | { NULL, NULL, NULL, 0 } | 82 | { NULL, NULL, NULL, 0 } | |
84 | }; | 83 | }; | |
85 | 84 | |||
86 | struct banks | 85 | struct banks { | |
87 | { | |||
88 | int units; | 86 | int units; | |
89 | double angle; | 87 | double angle; | |
90 | double spread; | 88 | double spread; | |
91 | }; | 89 | }; | |
92 | 90 | |||
93 | 91 | |||
94 | 92 | |||
95 | /*ARGSUSED*/ | 93 | /*ARGSUSED*/ | |
96 | void | 94 | void | |
97 | phaser(int v __unused) | 95 | phaser(int v __unused) | |
98 | { | 96 | { | |
99 | int i; | 97 | int i; | |
100 | int j; | 98 | int j; | |
@@ -112,218 +110,191 @@ phaser(int v __unused) | @@ -112,218 +110,191 @@ phaser(int v __unused) | |||
112 | 110 | |||
113 | if (Ship.cond == DOCKED) { | 111 | if (Ship.cond == DOCKED) { | |
114 | printf("Phasers cannot fire through starbase shields\n"); | 112 | printf("Phasers cannot fire through starbase shields\n"); | |
115 | return; | 113 | return; | |
116 | } | 114 | } | |
117 | if (damaged(PHASER)) { | 115 | if (damaged(PHASER)) { | |
118 | out(PHASER); | 116 | out(PHASER); | |
119 | return; | 117 | return; | |
120 | } | 118 | } | |
121 | if (Ship.shldup) { | 119 | if (Ship.shldup) { | |
122 | printf("Sulu: Captain, we cannot fire through shields.\n"); | 120 | printf("Sulu: Captain, we cannot fire through shields.\n"); | |
123 | return; | 121 | return; | |
124 | } | 122 | } | |
125 | if (Ship.cloaked) | 123 | if (Ship.cloaked) { | |
126 | { | |||
127 | printf("Sulu: Captain, surely you must realize that we cannot fire\n"); | 124 | printf("Sulu: Captain, surely you must realize that we cannot fire\n"); | |
128 | printf(" phasers with the cloaking device up.\n"); | 125 | printf(" phasers with the cloaking device up.\n"); | |
129 | return; | 126 | return; | |
130 | } | 127 | } | |
131 | 128 | |||
132 | /* decide if we want manual or automatic mode */ | 129 | /* decide if we want manual or automatic mode */ | |
133 | manual = 0; | 130 | manual = 0; | |
134 | if (testnl()) | 131 | if (testnl()) { | |
135 | { | 132 | if (damaged(COMPUTER)) { | |
136 | if (damaged(COMPUTER)) | |||
137 | { | |||
138 | printf("%s", Device[COMPUTER].name); | 133 | printf("%s", Device[COMPUTER].name); | |
139 | manual++; | 134 | manual++; | |
135 | } else if (damaged(SRSCAN)) { | |||
136 | printf("%s", Device[SRSCAN].name); | |||
137 | manual++; | |||
140 | } | 138 | } | |
141 | else | |||
142 | if (damaged(SRSCAN)) | |||
143 | { | |||
144 | printf("%s", Device[SRSCAN].name); | |||
145 | manual++; | |||
146 | } | |||
147 | if (manual) | 139 | if (manual) | |
148 | printf(" damaged, manual mode selected\n"); | 140 | printf(" damaged, manual mode selected\n"); | |
149 | } | 141 | } | |
150 | 142 | |||
151 | if (!manual) | 143 | if (!manual) { | |
152 | { | |||
153 | ptr = getcodpar("Manual or automatic", Matab); | 144 | ptr = getcodpar("Manual or automatic", Matab); | |
154 | manual = (long) ptr->value; | 145 | manual = (long) ptr->value; | |
155 | } | 146 | } | |
156 | if (!manual && damaged(COMPUTER)) | 147 | if (!manual && damaged(COMPUTER)) { | |
157 | { | |||
158 | printf("Computer damaged, manual selected\n"); | 148 | printf("Computer damaged, manual selected\n"); | |
159 | skiptonl(0); | 149 | skiptonl(0); | |
160 | manual++; | 150 | manual++; | |
161 | } | 151 | } | |
162 | 152 | |||
163 | /* initialize the bank[] array */ | 153 | /* initialize the bank[] array */ | |
164 | flag = 1; | 154 | flag = 1; | |
165 | for (i = 0; i < NBANKS; i++) | 155 | for (i = 0; i < NBANKS; i++) | |
166 | bank[i].units = 0; | 156 | bank[i].units = 0; | |
167 | if (manual) | 157 | if (manual) { | |
168 | { | |||
169 | /* collect manual mode statistics */ | 158 | /* collect manual mode statistics */ | |
170 | while (flag) | 159 | while (flag) { | |
171 | { | |||
172 | printf("%d units available\n", Ship.energy); | 160 | printf("%d units available\n", Ship.energy); | |
173 | extra = 0; | 161 | extra = 0; | |
174 | flag = 0; | 162 | flag = 0; | |
175 | for (i = 0; i < NBANKS; i++) | 163 | for (i = 0; i < NBANKS; i++) { | |
176 | { | |||
177 | b = &bank[i]; | 164 | b = &bank[i]; | |
178 | printf("\nBank %d:\n", i); | 165 | printf("\nBank %d:\n", i); | |
179 | hit = getintpar("units"); | 166 | hit = getintpar("units"); | |
180 | if (hit < 0) | 167 | if (hit < 0) | |
181 | return; | 168 | return; | |
182 | if (hit == 0) | 169 | if (hit == 0) | |
183 | break; | 170 | break; | |
184 | extra += hit; | 171 | extra += hit; | |
185 | if (extra > Ship.energy) | 172 | if (extra > Ship.energy) { | |
186 | { | |||
187 | printf("available energy exceeded. "); | 173 | printf("available energy exceeded. "); | |
188 | skiptonl(0); | 174 | skiptonl(0); | |
189 | flag++; | 175 | flag++; | |
190 | break; | 176 | break; | |
191 | } | 177 | } | |
192 | b->units = hit; | 178 | b->units = hit; | |
193 | hit = getintpar("course"); | 179 | hit = getintpar("course"); | |
194 | if (hit < 0 || hit > 360) | 180 | if (hit < 0 || hit > 360) | |
195 | return; | 181 | return; | |
196 | b->angle = hit * 0.0174532925; | 182 | b->angle = hit * 0.0174532925; | |
197 | b->spread = getfltpar("spread"); | 183 | b->spread = getfltpar("spread"); | |
198 | if (b->spread < 0 || b->spread > 1) | 184 | if (b->spread < 0 || b->spread > 1) | |
199 | return; | 185 | return; | |
200 | } | 186 | } | |
201 | Ship.energy -= extra; | 187 | Ship.energy -= extra; | |
202 | } | 188 | } | |
203 | extra = 0; | 189 | extra = 0; | |
204 | } | 190 | } else { | |
205 | else | |||
206 | { | |||
207 | /* automatic distribution of power */ | 191 | /* automatic distribution of power */ | |
208 | if (Etc.nkling <= 0) { | 192 | if (Etc.nkling <= 0) { | |
209 | printf("Sulu: But there are no Klingons in this quadrant\n"); | 193 | printf("Sulu: But there are no Klingons in this quadrant\n"); | |
210 | return; | 194 | return; | |
211 | } | 195 | } | |
212 | printf("Phasers locked on target. "); | 196 | printf("Phasers locked on target. "); | |
213 | while (flag) | 197 | while (flag) { | |
214 | { | |||
215 | printf("%d units available\n", Ship.energy); | 198 | printf("%d units available\n", Ship.energy); | |
216 | hit = getintpar("Units to fire"); | 199 | hit = getintpar("Units to fire"); | |
217 | if (hit <= 0) | 200 | if (hit <= 0) | |
218 | return; | 201 | return; | |
219 | if (hit > Ship.energy) | 202 | if (hit > Ship.energy) { | |
220 | { | |||
221 | printf("available energy exceeded. "); | 203 | printf("available energy exceeded. "); | |
222 | skiptonl(0); | 204 | skiptonl(0); | |
223 | continue; | 205 | continue; | |
224 | } | 206 | } | |
225 | flag = 0; | 207 | flag = 0; | |
226 | Ship.energy -= hit; | 208 | Ship.energy -= hit; | |
227 | extra = hit; | 209 | extra = hit; | |
228 | n = Etc.nkling; | 210 | n = Etc.nkling; | |
229 | if (n > NBANKS) | 211 | if (n > NBANKS) | |
230 | n = NBANKS; | 212 | n = NBANKS; | |
231 | tot = n * (n + 1) / 2; | 213 | tot = n * (n + 1) / 2; | |
232 | for (i = 0; i < n; i++) | 214 | for (i = 0; i < n; i++) { | |
233 | { | |||
234 | k = &Etc.klingon[i]; | 215 | k = &Etc.klingon[i]; | |
235 | b = &bank[i]; | 216 | b = &bank[i]; | |
236 | distfactor = k->dist; | 217 | distfactor = k->dist; | |
237 | anglefactor = ALPHA * BETA * OMEGA / (distfactor * distfactor + EPSILON); | 218 | anglefactor = ALPHA * BETA * OMEGA / (distfactor * distfactor + EPSILON); | |
238 | anglefactor *= GAMMA; | 219 | anglefactor *= GAMMA; | |
239 | distfactor = k->power; | 220 | distfactor = k->power; | |
240 | distfactor /= anglefactor; | 221 | distfactor /= anglefactor; | |
241 | hitreqd[i] = distfactor + 0.5; | 222 | hitreqd[i] = distfactor + 0.5; | |
242 | dx = Ship.sectx - k->x; | 223 | dx = Ship.sectx - k->x; | |
243 | dy = k->y - Ship.secty; | 224 | dy = k->y - Ship.secty; | |
244 | b->angle = atan2(dy, dx); | 225 | b->angle = atan2(dy, dx); | |
245 | b->spread = 0.0; | 226 | b->spread = 0.0; | |
246 | b->units = ((n - i) / tot) * extra; | 227 | b->units = ((n - i) / tot) * extra; | |
247 | #ifdef xTRACE | 228 | #ifdef xTRACE | |
248 | if (Trace) | 229 | if (Trace) { | |
249 | { | |||
250 | printf("b%d hr%d u%d df%.2f af%.2f\n", | 230 | printf("b%d hr%d u%d df%.2f af%.2f\n", | |
251 | i, hitreqd[i], b->units, | 231 | i, hitreqd[i], b->units, | |
252 | distfactor, anglefactor); | 232 | distfactor, anglefactor); | |
253 | } | 233 | } | |
254 | #endif | 234 | #endif | |
255 | extra -= b->units; | 235 | extra -= b->units; | |
256 | hit = b->units - hitreqd[i]; | 236 | hit = b->units - hitreqd[i]; | |
257 | if (hit > 0) | 237 | if (hit > 0) { | |
258 | { | |||
259 | extra += hit; | 238 | extra += hit; | |
260 | b->units -= hit; | 239 | b->units -= hit; | |
261 | } | 240 | } | |
262 | } | 241 | } | |
263 | 242 | |||
264 | /* give out any extra energy we might have around */ | 243 | /* give out any extra energy we might have around */ | |
265 | if (extra > 0) | 244 | if (extra > 0) { | |
266 | { | 245 | for (i = 0; i < n; i++) { | |
267 | for (i = 0; i < n; i++) | |||
268 | { | |||
269 | b = &bank[i]; | 246 | b = &bank[i]; | |
270 | hit = hitreqd[i] - b->units; | 247 | hit = hitreqd[i] - b->units; | |
271 | if (hit <= 0) | 248 | if (hit <= 0) | |
272 | continue; | 249 | continue; | |
273 | if (hit >= extra) | 250 | if (hit >= extra) { | |
274 | { | |||
275 | b->units += extra; | 251 | b->units += extra; | |
276 | extra = 0; | 252 | extra = 0; | |
277 | break; | 253 | break; | |
278 | } | 254 | } | |
279 | b->units = hitreqd[i]; | 255 | b->units = hitreqd[i]; | |
280 | extra -= hit; | 256 | extra -= hit; | |
281 | } | 257 | } | |
282 | if (extra > 0) | 258 | if (extra > 0) | |
283 | printf("%d units overkill\n", extra); | 259 | printf("%d units overkill\n", extra); | |
284 | } | 260 | } | |
285 | } | 261 | } | |
286 | } | 262 | } | |
287 | 263 | |||
288 | #ifdef xTRACE | 264 | #ifdef xTRACE | |
289 | if (Trace) | 265 | if (Trace) { | |
290 | { | 266 | for (i = 0; i < NBANKS; i++) { | |
291 | for (i = 0; i < NBANKS; i++) | |||
292 | { | |||
293 | b = &bank[i]; | 267 | b = &bank[i]; | |
294 | printf("b%d u%d", i, b->units); | 268 | printf("b%d u%d", i, b->units); | |
295 | if (b->units > 0) | 269 | if (b->units > 0) | |
296 | printf(" a%.2f s%.2f\n", b->angle, b->spread); | 270 | printf(" a%.2f s%.2f\n", b->angle, b->spread); | |
297 | else | 271 | else | |
298 | printf("\n"); | 272 | printf("\n"); | |
299 | } | 273 | } | |
300 | } | 274 | } | |
301 | #endif | 275 | #endif | |
302 | 276 | |||
303 | /* actually fire the shots */ | 277 | /* actually fire the shots */ | |
304 | Move.free = 0; | 278 | Move.free = 0; | |
305 | for (i = 0; i < NBANKS; i++) | 279 | for (i = 0; i < NBANKS; i++) { | |
306 | { | |||
307 | b = &bank[i]; | 280 | b = &bank[i]; | |
308 | if (b->units <= 0) | 281 | if (b->units <= 0) { | |
309 | { | |||
310 | continue; | 282 | continue; | |
311 | } | 283 | } | |
312 | printf("\nPhaser bank %d fires:\n", i); | 284 | printf("\nPhaser bank %d fires:\n", i); | |
313 | n = Etc.nkling; | 285 | n = Etc.nkling; | |
314 | k = Etc.klingon; | 286 | k = Etc.klingon; | |
315 | for (j = 0; j < n; j++) | 287 | for (j = 0; j < n; j++) { | |
316 | { | |||
317 | if (b->units <= 0) | 288 | if (b->units <= 0) | |
318 | break; | 289 | break; | |
319 | /* | 290 | /* | |
320 | ** The formula for hit is as follows: | 291 | ** The formula for hit is as follows: | |
321 | ** | 292 | ** | |
322 | ** zap = OMEGA * [(sigma + ALPHA) * (rho + BETA)] | 293 | ** zap = OMEGA * [(sigma + ALPHA) * (rho + BETA)] | |
323 | ** / (dist ** 2 + EPSILON)] | 294 | ** / (dist ** 2 + EPSILON)] | |
324 | ** * [cos(delta * sigma) + GAMMA] | 295 | ** * [cos(delta * sigma) + GAMMA] | |
325 | ** * hit | 296 | ** * hit | |
326 | ** | 297 | ** | |
327 | ** where sigma is the spread factor, | 298 | ** where sigma is the spread factor, | |
328 | ** rho is a random number (0 -> 1), | 299 | ** rho is a random number (0 -> 1), | |
329 | ** GAMMA is a crud factor for angle (essentially | 300 | ** GAMMA is a crud factor for angle (essentially | |
@@ -345,40 +316,38 @@ phaser(int v __unused) | @@ -345,40 +316,38 @@ phaser(int v __unused) | |||
345 | ** never greater than one, but the same restric- | 316 | ** never greater than one, but the same restric- | |
346 | ** tion applies. | 317 | ** tion applies. | |
347 | */ | 318 | */ | |
348 | distfactor = BETA + franf(); | 319 | distfactor = BETA + franf(); | |
349 | distfactor *= ALPHA + b->spread; | 320 | distfactor *= ALPHA + b->spread; | |
350 | distfactor *= OMEGA; | 321 | distfactor *= OMEGA; | |
351 | anglefactor = k->dist; | 322 | anglefactor = k->dist; | |
352 | distfactor /= anglefactor * anglefactor + EPSILON; | 323 | distfactor /= anglefactor * anglefactor + EPSILON; | |
353 | distfactor *= b->units; | 324 | distfactor *= b->units; | |
354 | dx = Ship.sectx - k->x; | 325 | dx = Ship.sectx - k->x; | |
355 | dy = k->y - Ship.secty; | 326 | dy = k->y - Ship.secty; | |
356 | anglefactor = atan2(dy, dx) - b->angle; | 327 | anglefactor = atan2(dy, dx) - b->angle; | |
357 | anglefactor = cos((anglefactor * b->spread) + GAMMA); | 328 | anglefactor = cos((anglefactor * b->spread) + GAMMA); | |
358 | if (anglefactor < 0.0) | 329 | if (anglefactor < 0.0) { | |
359 | { | |||
360 | k++; | 330 | k++; | |
361 | continue; | 331 | continue; | |
362 | } | 332 | } | |
363 | hit = anglefactor * distfactor + 0.5; | 333 | hit = anglefactor * distfactor + 0.5; | |
364 | k->power -= hit; | 334 | k->power -= hit; | |
365 | printf("%d unit hit on Klingon", hit); | 335 | printf("%d unit hit on Klingon", hit); | |
366 | if (!damaged(SRSCAN)) | 336 | if (!damaged(SRSCAN)) | |
367 | printf(" at %d,%d", k->x, k->y); | 337 | printf(" at %d,%d", k->x, k->y); | |
368 | printf("\n"); | 338 | printf("\n"); | |
369 | b->units -= hit; | 339 | b->units -= hit; | |
370 | if (k->power <= 0) | 340 | if (k->power <= 0) { | |
371 | { | |||
372 | killk(k->x, k->y); | 341 | killk(k->x, k->y); | |
373 | continue; | 342 | continue; | |
374 | } | 343 | } | |
375 | k++; | 344 | k++; | |
376 | } | 345 | } | |
377 | } | 346 | } | |
378 | 347 | |||
379 | /* compute overkill */ | 348 | /* compute overkill */ | |
380 | for (i = 0; i < NBANKS; i++) | 349 | for (i = 0; i < NBANKS; i++) | |
381 | extra += bank[i].units; | 350 | extra += bank[i].units; | |
382 | if (extra > 0) | 351 | if (extra > 0) | |
383 | printf("\n%d units expended on empty space\n", extra); | 352 | printf("\n%d units expended on empty space\n", extra); | |
384 | } | 353 | } |
--- src/games/trek/dumpgame.c 2009/05/24 20:39:43 1.13
+++ src/games/trek/dumpgame.c 2009/05/24 21:44:56 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: dumpgame.c,v 1.14 2009/05/24 21:44:56 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,50 +24,48 @@ | @@ -24,50 +24,48 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $"); | 37 | __RCSID("$NetBSD: dumpgame.c,v 1.14 2009/05/24 21:44:56 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 | |||
50 | struct dump | 50 | struct dump { | |
51 | { | |||
52 | char *area; | 51 | char *area; | |
53 | int count; | 52 | int count; | |
54 | }; | 53 | }; | |
55 | 54 | |||
56 | static int readdump(int); | 55 | static int readdump(int); | |
57 | 56 | |||
58 | 57 | |||
59 | struct dump Dump_template[] = | 58 | struct dump Dump_template[] = { | |
60 | { | |||
61 | { (char *)&Ship, sizeof (Ship) }, | 59 | { (char *)&Ship, sizeof (Ship) }, | |
62 | { (char *)&Now, sizeof (Now) }, | 60 | { (char *)&Now, sizeof (Now) }, | |
63 | { (char *)&Param, sizeof (Param) }, | 61 | { (char *)&Param, sizeof (Param) }, | |
64 | { (char *)&Etc, sizeof (Etc) }, | 62 | { (char *)&Etc, sizeof (Etc) }, | |
65 | { (char *)&Game, sizeof (Game) }, | 63 | { (char *)&Game, sizeof (Game) }, | |
66 | { (char *)Sect, sizeof (Sect) }, | 64 | { (char *)Sect, sizeof (Sect) }, | |
67 | { (char *)Quad, sizeof (Quad) }, | 65 | { (char *)Quad, sizeof (Quad) }, | |
68 | { (char *)&Move, sizeof (Move) }, | 66 | { (char *)&Move, sizeof (Move) }, | |
69 | { (char *)Event, sizeof (Event) }, | 67 | { (char *)Event, sizeof (Event) }, | |
70 | { NULL, 0 } | 68 | { NULL, 0 } | |
71 | }; | 69 | }; | |
72 | 70 | |||
73 | /* | 71 | /* | |
@@ -87,28 +85,27 @@ dumpgame(int v __unused) | @@ -87,28 +85,27 @@ dumpgame(int v __unused) | |||
87 | int version; | 85 | int version; | |
88 | int fd; | 86 | int fd; | |
89 | struct dump *d; | 87 | struct dump *d; | |
90 | int i; | 88 | int i; | |
91 | 89 | |||
92 | if ((fd = creat("trek.dump", 0644)) < 0) { | 90 | if ((fd = creat("trek.dump", 0644)) < 0) { | |
93 | warn("cannot open `trek.dump'"); | 91 | warn("cannot open `trek.dump'"); | |
94 | return; | 92 | return; | |
95 | } | 93 | } | |
96 | version = VERSION; | 94 | version = VERSION; | |
97 | write(fd, &version, sizeof version); | 95 | write(fd, &version, sizeof version); | |
98 | 96 | |||
99 | /* output the main data areas */ | 97 | /* output the main data areas */ | |
100 | for (d = Dump_template; d->area; d++) | 98 | for (d = Dump_template; d->area; d++) { | |
101 | { | |||
102 | write(fd, &d->area, sizeof d->area); | 99 | write(fd, &d->area, sizeof d->area); | |
103 | i = d->count; | 100 | i = d->count; | |
104 | write(fd, d->area, i); | 101 | write(fd, d->area, i); | |
105 | } | 102 | } | |
106 | 103 | |||
107 | close(fd); | 104 | close(fd); | |
108 | } | 105 | } | |
109 | 106 | |||
110 | 107 | |||
111 | /* | 108 | /* | |
112 | ** RESTORE GAME | 109 | ** RESTORE GAME | |
113 | ** | 110 | ** | |
114 | ** The game is restored from the file "trek.dump". In order for | 111 | ** The game is restored from the file "trek.dump". In order for | |
@@ -118,28 +115,27 @@ dumpgame(int v __unused) | @@ -118,28 +115,27 @@ dumpgame(int v __unused) | |||
118 | ** | 115 | ** | |
119 | ** Return value is zero for success, one for failure. | 116 | ** Return value is zero for success, one for failure. | |
120 | */ | 117 | */ | |
121 | 118 | |||
122 | int | 119 | int | |
123 | restartgame(void) | 120 | restartgame(void) | |
124 | { | 121 | { | |
125 | int fd; | 122 | int fd; | |
126 | int version; | 123 | int version; | |
127 | 124 | |||
128 | if ((fd = open("trek.dump", O_RDONLY)) < 0 || | 125 | if ((fd = open("trek.dump", O_RDONLY)) < 0 || | |
129 | read(fd, &version, sizeof version) != sizeof version || | 126 | read(fd, &version, sizeof version) != sizeof version || | |
130 | version != VERSION || | 127 | version != VERSION || | |
131 | readdump(fd)) | 128 | readdump(fd)) { | |
132 | { | |||
133 | printf("cannot restart\n"); | 129 | printf("cannot restart\n"); | |
134 | if (fd >= 0) | 130 | if (fd >= 0) | |
135 | close(fd); | 131 | close(fd); | |
136 | return (1); | 132 | return (1); | |
137 | } | 133 | } | |
138 | 134 | |||
139 | close(fd); | 135 | close(fd); | |
140 | return (0); | 136 | return (0); | |
141 | } | 137 | } | |
142 | 138 | |||
143 | 139 | |||
144 | /* | 140 | /* | |
145 | ** READ DUMP | 141 | ** READ DUMP | |
@@ -150,27 +146,26 @@ restartgame(void) | @@ -150,27 +146,26 @@ restartgame(void) | |||
150 | ** Returns zero for success, one for failure. | 146 | ** Returns zero for success, one for failure. | |
151 | */ | 147 | */ | |
152 | 148 | |||
153 | static int | 149 | static int | |
154 | readdump(int fd1) | 150 | readdump(int fd1) | |
155 | { | 151 | { | |
156 | int fd; | 152 | int fd; | |
157 | struct dump *d; | 153 | struct dump *d; | |
158 | int i; | 154 | int i; | |
159 | long junk; | 155 | long junk; | |
160 | 156 | |||
161 | fd = fd1; | 157 | fd = fd1; | |
162 | 158 | |||
163 | for (d = Dump_template; d->area; d++) | 159 | for (d = Dump_template; d->area; d++) { | |
164 | { | |||
165 | if (read(fd, &junk, sizeof junk) != (sizeof junk)) | 160 | if (read(fd, &junk, sizeof junk) != (sizeof junk)) | |
166 | return (1); | 161 | return (1); | |
167 | if ((char *)junk != d->area) | 162 | if ((char *)junk != d->area) | |
168 | return (1); | 163 | return (1); | |
169 | i = d->count; | 164 | i = d->count; | |
170 | if (read(fd, d->area, i) != i) | 165 | if (read(fd, d->area, i) != i) | |
171 | return (1); | 166 | return (1); | |
172 | } | 167 | } | |
173 | 168 | |||
174 | /* make quite certain we are at EOF */ | 169 | /* make quite certain we are at EOF */ | |
175 | return (read(fd, &junk, 1)); | 170 | return (read(fd, &junk, 1)); | |
176 | } | 171 | } |
--- src/games/trek/getpar.c 2009/05/24 19:18:44 1.13
+++ src/games/trek/getpar.c 2009/05/24 21:44:56 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 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,92 +24,89 @@ | @@ -24,92 +24,89 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 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 <stdlib.h> | 42 | #include <stdlib.h> | |
43 | #include <string.h> | 43 | #include <string.h> | |
44 | #include "getpar.h" | 44 | #include "getpar.h" | |
45 | #include "trek.h" | 45 | #include "trek.h" | |
46 | 46 | |||
47 | static int testterm(void); | 47 | static int testterm(void); | |
48 | 48 | |||
49 | /** | 49 | /** | |
50 | ** get integer parameter | 50 | ** get integer parameter | |
51 | **/ | 51 | **/ | |
52 | 52 | |||
53 | int | 53 | int | |
54 | getintpar(const char *s) | 54 | getintpar(const char *s) | |
55 | { | 55 | { | |
56 | int i; | 56 | int i; | |
57 | int n; | 57 | int n; | |
58 | 58 | |||
59 | while (1) | 59 | while (1) { | |
60 | { | |||
61 | if (testnl() && s) | 60 | if (testnl() && s) | |
62 | printf("%s: ", s); | 61 | printf("%s: ", s); | |
63 | i = scanf("%d", &n); | 62 | i = scanf("%d", &n); | |
64 | if (i < 0) | 63 | if (i < 0) | |
65 | exit(1); | 64 | exit(1); | |
66 | if (i > 0 && testterm()) | 65 | if (i > 0 && testterm()) | |
67 | return (n); | 66 | return (n); | |
68 | printf("invalid input; please enter an integer\n"); | 67 | printf("invalid input; please enter an integer\n"); | |
69 | skiptonl(0); | 68 | skiptonl(0); | |
70 | } | 69 | } | |
71 | } | 70 | } | |
72 | 71 | |||
73 | /** | 72 | /** | |
74 | ** get floating parameter | 73 | ** get floating parameter | |
75 | **/ | 74 | **/ | |
76 | 75 | |||
77 | double | 76 | double | |
78 | getfltpar(const char *s) | 77 | getfltpar(const char *s) | |
79 | { | 78 | { | |
80 | int i; | 79 | int i; | |
81 | double d; | 80 | double d; | |
82 | 81 | |||
83 | while (1) | 82 | while (1) { | |
84 | { | |||
85 | if (testnl() && s) | 83 | if (testnl() && s) | |
86 | printf("%s: ", s); | 84 | printf("%s: ", s); | |
87 | i = scanf("%lf", &d); | 85 | i = scanf("%lf", &d); | |
88 | if (i < 0) | 86 | if (i < 0) | |
89 | exit(1); | 87 | exit(1); | |
90 | if (i > 0 && testterm()) | 88 | if (i > 0 && testterm()) | |
91 | return (d); | 89 | return (d); | |
92 | printf("invalid input; please enter a double\n"); | 90 | printf("invalid input; please enter a double\n"); | |
93 | skiptonl(0); | 91 | skiptonl(0); | |
94 | } | 92 | } | |
95 | } | 93 | } | |
96 | 94 | |||
97 | /** | 95 | /** | |
98 | ** get yes/no parameter | 96 | ** get yes/no parameter | |
99 | **/ | 97 | **/ | |
100 | 98 | |||
101 | const struct cvntab Yntab[] = | 99 | const struct cvntab Yntab[] = { | |
102 | { | |||
103 | { "y", "es", (cmdfun)1, 1 }, | 100 | { "y", "es", (cmdfun)1, 1 }, | |
104 | { "n", "o", (cmdfun)0, 0 }, | 101 | { "n", "o", (cmdfun)0, 0 }, | |
105 | { NULL, NULL, NULL, 0 } | 102 | { NULL, NULL, NULL, 0 } | |
106 | }; | 103 | }; | |
107 | 104 | |||
108 | int | 105 | int | |
109 | getynpar(const char *s) | 106 | getynpar(const char *s) | |
110 | { | 107 | { | |
111 | const struct cvntab *r; | 108 | const struct cvntab *r; | |
112 | 109 | |||
113 | r = getcodpar(s, Yntab); | 110 | r = getcodpar(s, Yntab); | |
114 | return r->value2; | 111 | return r->value2; | |
115 | } | 112 | } | |
@@ -120,132 +117,125 @@ getynpar(const char *s) | @@ -120,132 +117,125 @@ getynpar(const char *s) | |||
120 | **/ | 117 | **/ | |
121 | 118 | |||
122 | const struct cvntab * | 119 | const struct cvntab * | |
123 | getcodpar(const char *s, const struct cvntab tab[]) | 120 | getcodpar(const char *s, const struct cvntab tab[]) | |
124 | { | 121 | { | |
125 | char input[100]; | 122 | char input[100]; | |
126 | const struct cvntab *r; | 123 | const struct cvntab *r; | |
127 | int flag; | 124 | int flag; | |
128 | const char *p, *q; | 125 | const char *p, *q; | |
129 | int c; | 126 | int c; | |
130 | int f; | 127 | int f; | |
131 | 128 | |||
132 | flag = 0; | 129 | flag = 0; | |
133 | while (1) | 130 | while (1) { | |
134 | { | |||
135 | flag |= (f = testnl()); | 131 | flag |= (f = testnl()); | |
136 | if (flag) | 132 | if (flag) | |
137 | printf("%s: ", s); | 133 | printf("%s: ", s); | |
138 | if (f) | 134 | if (f) { | |
139 | cgetc(0); /* throw out the newline */ | 135 | /* throw out the newline */ | |
136 | cgetc(0); | |||
137 | } | |||
140 | scanf("%*[ \t;]"); | 138 | scanf("%*[ \t;]"); | |
141 | if ((c = scanf("%99[^ \t;\n]", input)) < 0) | 139 | if ((c = scanf("%99[^ \t;\n]", input)) < 0) | |
142 | exit(1); | 140 | exit(1); | |
143 | if (c == 0) | 141 | if (c == 0) | |
144 | continue; | 142 | continue; | |
145 | flag = 1; | 143 | flag = 1; | |
146 | 144 | |||
147 | /* if command list, print four per line */ | 145 | /* if command list, print four per line */ | |
148 | if (input[0] == '?' && input[1] == 0) | 146 | if (input[0] == '?' && input[1] == 0) { | |
149 | { | |||
150 | c = 4; | 147 | c = 4; | |
151 | for (r = tab; r->abrev; r++) | 148 | for (r = tab; r->abrev; r++) { | |
152 | { | |||
153 | strcpy(input, r->abrev); | 149 | strcpy(input, r->abrev); | |
154 | strcat(input, r->full); | 150 | strcat(input, r->full); | |
155 | printf("%14.14s", input); | 151 | printf("%14.14s", input); | |
156 | if (--c > 0) | 152 | if (--c > 0) | |
157 | continue; | 153 | continue; | |
158 | c = 4; | 154 | c = 4; | |
159 | printf("\n"); | 155 | printf("\n"); | |
160 | } | 156 | } | |
161 | if (c != 4) | 157 | if (c != 4) | |
162 | printf("\n"); | 158 | printf("\n"); | |
163 | continue; | 159 | continue; | |
164 | } | 160 | } | |
165 | 161 | |||
166 | /* search for in table */ | 162 | /* search for in table */ | |
167 | for (r = tab; r->abrev; r++) | 163 | for (r = tab; r->abrev; r++) { | |
168 | { | |||
169 | p = input; | 164 | p = input; | |
170 | for (q = r->abrev; *q; q++) | 165 | for (q = r->abrev; *q; q++) | |
171 | if (*p++ != *q) | 166 | if (*p++ != *q) | |
172 | break; | 167 | break; | |
173 | if (!*q) | 168 | if (!*q) { | |
174 | { | |||
175 | for (q = r->full; *p && *q; q++, p++) | 169 | for (q = r->full; *p && *q; q++, p++) | |
176 | if (*p != *q) | 170 | if (*p != *q) | |
177 | break; | 171 | break; | |
178 | if (!*p || !*q) | 172 | if (!*p || !*q) | |
179 | break; | 173 | break; | |
180 | } | 174 | } | |
181 | } | 175 | } | |
182 | 176 | |||
183 | /* check for not found */ | 177 | /* check for not found */ | |
184 | if (!r->abrev) | 178 | if (!r->abrev) { | |
185 | { | |||
186 | printf("invalid input; ? for valid inputs\n"); | 179 | printf("invalid input; ? for valid inputs\n"); | |
187 | skiptonl(0); | 180 | skiptonl(0); | |
188 | } | 181 | } else | |
189 | else | |||
190 | return (r); | 182 | return (r); | |
191 | } | 183 | } | |
192 | } | 184 | } | |
193 | 185 | |||
194 | 186 | |||
195 | /** | 187 | /** | |
196 | ** get string parameter | 188 | ** get string parameter | |
197 | **/ | 189 | **/ | |
198 | 190 | |||
199 | void | 191 | void | |
200 | getstrpar(const char *s, char *r, int l, const char *t) | 192 | getstrpar(const char *s, char *r, int l, const char *t) | |
201 | { | 193 | { | |
202 | int i; | 194 | int i; | |
203 | char format[20]; | 195 | char format[20]; | |
204 | int f; | 196 | int f; | |
205 | 197 | |||
206 | if (t == 0) | 198 | if (t == 0) | |
207 | t = " \t\n;"; | 199 | t = " \t\n;"; | |
208 | (void)sprintf(format, "%%%d[^%s]", l, t); | 200 | (void)sprintf(format, "%%%d[^%s]", l, t); | |
209 | while (1) | 201 | while (1) { | |
210 | { | |||
211 | if ((f = testnl()) && s) | 202 | if ((f = testnl()) && s) | |
212 | printf("%s: ", s); | 203 | printf("%s: ", s); | |
213 | if (f) | 204 | if (f) | |
214 | cgetc(0); | 205 | cgetc(0); | |
215 | scanf("%*[\t ;]"); | 206 | scanf("%*[\t ;]"); | |
216 | i = scanf(format, r); | 207 | i = scanf(format, r); | |
217 | if (i < 0) | 208 | if (i < 0) | |
218 | exit(1); | 209 | exit(1); | |
219 | if (i != 0) | 210 | if (i != 0) | |
220 | return; | 211 | return; | |
221 | } | 212 | } | |
222 | } | 213 | } | |
223 | 214 | |||
224 | 215 | |||
225 | /** | 216 | /** | |
226 | ** test if newline is next valid character | 217 | ** test if newline is next valid character | |
227 | **/ | 218 | **/ | |
228 | 219 | |||
229 | int | 220 | int | |
230 | testnl(void) | 221 | testnl(void) | |
231 | { | 222 | { | |
232 | char c; | 223 | char c; | |
233 | 224 | |||
234 | while ((c = cgetc(0)) != '\n') | 225 | while ((c = cgetc(0)) != '\n') | |
235 | if ((c >= '0' && c <= '9') || c == '.' || c == '!' || | 226 | if ((c >= '0' && c <= '9') || c == '.' || c == '!' || | |
236 | (c >= 'A' && c <= 'Z') || | 227 | (c >= 'A' && c <= 'Z') || | |
237 | (c >= 'a' && c <= 'z') || c == '-') | 228 | (c >= 'a' && c <= 'z') || c == '-') { | |
238 | { | |||
239 | ungetc(c, stdin); | 229 | ungetc(c, stdin); | |
240 | return(0); | 230 | return(0); | |
241 | } | 231 | } | |
242 | ungetc(c, stdin); | 232 | ungetc(c, stdin); | |
243 | return (1); | 233 | return (1); | |
244 | } | 234 | } | |
245 | 235 | |||
246 | 236 | |||
247 | /** | 237 | /** | |
248 | ** scan for newline | 238 | ** scan for newline | |
249 | **/ | 239 | **/ | |
250 | 240 | |||
251 | void | 241 | void | |
@@ -281,24 +271,23 @@ testterm(void) | @@ -281,24 +271,23 @@ testterm(void) | |||
281 | /* | 271 | /* | |
282 | ** TEST FOR SPECIFIED DELIMITER | 272 | ** TEST FOR SPECIFIED DELIMITER | |
283 | ** | 273 | ** | |
284 | ** The standard input is scanned for the parameter. If found, | 274 | ** The standard input is scanned for the parameter. If found, | |
285 | ** it is thrown away and non-zero is returned. If not found, | 275 | ** it is thrown away and non-zero is returned. If not found, | |
286 | ** zero is returned. | 276 | ** zero is returned. | |
287 | */ | 277 | */ | |
288 | 278 | |||
289 | int | 279 | int | |
290 | readdelim(int d) | 280 | readdelim(int d) | |
291 | { | 281 | { | |
292 | char c; | 282 | char c; | |
293 | 283 | |||
294 | while ((c = cgetc(0)) != '\0') | 284 | while ((c = cgetc(0)) != '\0') { | |
295 | { | |||
296 | if (c == d) | 285 | if (c == d) | |
297 | return (1); | 286 | return (1); | |
298 | if (c == ' ') | 287 | if (c == ' ') | |
299 | continue; | 288 | continue; | |
300 | ungetc(c, stdin); | 289 | ungetc(c, stdin); | |
301 | break; | 290 | break; | |
302 | } | 291 | } | |
303 | return (0); | 292 | return (0); | |
304 | } | 293 | } |
--- src/games/trek/trek.h 2009/05/24 20:39:43 1.13
+++ src/games/trek/trek.h 2009/05/24 21:44:56 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: trek.h,v 1.13 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: trek.h,v 1.14 2009/05/24 21:44:56 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. | |
@@ -42,52 +42,53 @@ | @@ -42,52 +42,53 @@ | |||
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 | |||
55 | struct quad /* definition for each quadrant */ | 55 | /* definition for each quadrant */ | |
56 | { | 56 | struct quad { | |
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 | /* | |
69 | * systemname conventions: | |||
69 | * 1 -> NINHAB index into Systemname table for live system. | 70 | * 1 -> NINHAB index into Systemname table for live system. | |
70 | * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM | 71 | * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM | |
71 | * is the index into the Event table which will | 72 | * is the index into the Event table which will | |
72 | * have the system name | 73 | * have the system name | |
73 | * 0 dead or nonexistent starsystem | 74 | * 0 dead or nonexistent starsystem | |
74 | * | 75 | * | |
75 | * starchart ("scanned") conventions: | 76 | * starchart ("scanned") conventions: | |
76 | * 0 -> 999 taken as is | 77 | * 0 -> 999 taken as is | |
77 | * -1 not yet scanned ("...") | 78 | * -1 not yet scanned ("...") | |
78 | * 1000 supernova ("///") | 79 | * 1000 supernova ("///") | |
79 | * 1001 starbase + ??? (".1.") | 80 | * 1001 starbase + ??? (".1.") | |
80 | */ | 81 | */ | |
81 | 82 | |||
82 | /* ascii names of systems */ | 83 | /* ascii names of systems */ | |
83 | extern const char *const Systemname[NINHAB]; | 84 | extern const char *const Systemname[NINHAB]; | |
84 | 85 | |||
85 | /* quadrant definition */ | 86 | /* quadrant definition */ | |
86 | extern struct quad Quad[NQUADS][NQUADS]; | 87 | extern struct quad Quad[NQUADS][NQUADS]; | |
87 | 88 | |||
88 | /* defines for sector map (below) */ | 89 | /* defines for sector map (below) */ | |
89 | #define EMPTY '.' | 90 | #define EMPTY '.' | |
90 | #define STAR '*' | 91 | #define STAR '*' | |
91 | #define BASE '#' | 92 | #define BASE '#' | |
92 | #define ENTERPRISE 'E' | 93 | #define ENTERPRISE 'E' | |
93 | #define QUEENE 'Q' | 94 | #define QUEENE 'Q' | |
@@ -111,180 +112,176 @@ extern char Sect[NSECTS][NSECTS]; | @@ -111,180 +112,176 @@ extern char Sect[NSECTS][NSECTS]; | |||
111 | #define PHASER 3 /* phaser control */ | 112 | #define PHASER 3 /* phaser control */ | |
112 | #define TORPED 4 /* photon torpedo control */ | 113 | #define TORPED 4 /* photon torpedo control */ | |
113 | #define IMPULSE 5 /* impulse engines */ | 114 | #define IMPULSE 5 /* impulse engines */ | |
114 | #define SHIELD 6 /* shield control */ | 115 | #define SHIELD 6 /* shield control */ | |
115 | #define COMPUTER 7 /* on board computer */ | 116 | #define COMPUTER 7 /* on board computer */ | |
116 | #define SSRADIO 8 /* subspace radio */ | 117 | #define SSRADIO 8 /* subspace radio */ | |
117 | #define LIFESUP 9 /* life support systems */ | 118 | #define LIFESUP 9 /* life support systems */ | |
118 | #define SINS 10 /* Space Inertial Navigation System */ | 119 | #define SINS 10 /* Space Inertial Navigation System */ | |
119 | #define CLOAK 11 /* cloaking device */ | 120 | #define CLOAK 11 /* cloaking device */ | |
120 | #define XPORTER 12 /* transporter */ | 121 | #define XPORTER 12 /* transporter */ | |
121 | #define SHUTTLE 13 /* shuttlecraft */ | 122 | #define SHUTTLE 13 /* shuttlecraft */ | |
122 | 123 | |||
123 | /* device names */ | 124 | /* device names */ | |
124 | struct device | 125 | struct device { | |
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 | |||
130 | extern const struct device Device[NDEV]; | 130 | extern 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 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 | |||
151 | struct event | 151 | struct event { | |
152 | { | |||
153 | unsigned char x, y; /* coordinates */ | 152 | unsigned char x, y; /* coordinates */ | |
154 | double date; /* trap stardate */ | 153 | double date; /* trap stardate */ | |
155 | char evcode; /* event type */ | 154 | char evcode; /* event type */ | |
156 | unsigned char systemname; /* starsystem name */ | 155 | unsigned char systemname; /* starsystem name */ | |
157 | }; | 156 | }; | |
158 | /* systemname conventions: | 157 | ||
158 | /* | |||
159 | * systemname conventions: | |||
159 | * 1 -> NINHAB index into Systemname table for reported distress calls | 160 | * 1 -> NINHAB index into Systemname table for reported distress calls | |
160 | * | 161 | * | |
161 | * evcode conventions: | 162 | * evcode conventions: | |
162 | * 1 -> NEVENTS-1 event type | 163 | * 1 -> NEVENTS-1 event type | |
163 | * + E_HIDDEN unreported (SSradio out) | 164 | * + E_HIDDEN unreported (SSradio out) | |
164 | * + E_GHOST actually already expired | 165 | * + E_GHOST actually already expired | |
165 | * 0 unallocated | 166 | * 0 unallocated | |
166 | */ | 167 | */ | |
167 | 168 | |||
168 | #define MAXEVENTS 25 /* max number of concurrently pending events */ | 169 | /* max number of concurrently pending events */ | |
170 | #define MAXEVENTS 25 | |||
169 | 171 | |||
170 | extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ | 172 | /* dynamic event list; one entry per pending event */ | |
173 | extern struct event Event[MAXEVENTS]; | |||
171 | 174 | |||
172 | /***************************** KLINGONS *******************************/ | 175 | /***************************** KLINGONS *******************************/ | |
173 | 176 | |||
174 | struct kling | 177 | struct kling { | |
175 | { | |||
176 | unsigned char x, y; /* coordinates */ | 178 | unsigned char x, y; /* coordinates */ | |
177 | int power; /* power left */ | 179 | int power; /* power left */ | |
178 | double dist; /* distance to Enterprise */ | 180 | double dist; /* distance to Enterprise */ | |
179 | double avgdist; /* average over this move */ | 181 | double avgdist; /* average over this move */ | |
180 | char srndreq; /* set if surrender has been requested */ | 182 | char srndreq; /* set if surrender has been requested */ | |
181 | }; | 183 | }; | |
182 | 184 | |||
183 | #define MAXKLQUAD 9 /* maximum klingons per quadrant */ | 185 | #define MAXKLQUAD 9 /* maximum klingons per quadrant */ | |
184 | 186 | |||
185 | /********************** MISCELLANEOUS ***************************/ | 187 | /********************** MISCELLANEOUS ***************************/ | |
186 | 188 | |||
187 | /* condition codes */ | 189 | /* condition codes */ | |
188 | #define GREEN 0 | 190 | #define GREEN 0 | |
189 | #define DOCKED 1 | 191 | #define DOCKED 1 | |
190 | #define YELLOW 2 | 192 | #define YELLOW 2 | |
191 | #define RED 3 | 193 | #define RED 3 | |
192 | 194 | |||
193 | /* starbase coordinates */ | 195 | /* starbase coordinates */ | |
194 | #define MAXBASES 9 /* maximum number of starbases in galaxy */ | 196 | #define MAXBASES 9 /* maximum number of starbases in galaxy */ | |
195 | 197 | |||
196 | /* distress calls */ | 198 | /* distress calls */ | |
197 | #define MAXDISTR 5 /* maximum concurrent distress calls */ | 199 | #define MAXDISTR 5 /* maximum concurrent distress calls */ | |
198 | 200 | |||
199 | /* phaser banks */ | 201 | /* phaser banks */ | |
200 | #define NBANKS 6 /* number of phaser banks */ | 202 | #define NBANKS 6 /* number of phaser banks */ | |
201 | 203 | |||
202 | struct xy | 204 | struct xy { | |
203 | { | |||
204 | unsigned char x, y; /* coordinates */ | 205 | unsigned char x, y; /* coordinates */ | |
205 | }; | 206 | }; | |
206 | 207 | |||
207 | 208 | |||
208 | /* | 209 | /* | |
209 | * note that much of the stuff in the following structs CAN NOT | 210 | * note that much of the stuff in the following structs CAN NOT | |
210 | * be moved around!!!! | 211 | * be moved around!!!! | |
211 | */ | 212 | */ | |
212 | 213 | |||
213 | 214 | |||
214 | /* information regarding the state of the starship */ | 215 | /* information regarding the state of the starship */ | |
215 | struct Ship_struct | 216 | struct Ship_struct { | |
216 | { | |||
217 | double warp; /* warp factor */ | 217 | double warp; /* warp factor */ | |
218 | double warp2; /* warp factor squared */ | 218 | double warp2; /* warp factor squared */ | |
219 | double warp3; /* warp factor cubed */ | 219 | double warp3; /* warp factor cubed */ | |
220 | char shldup; /* shield up flag */ | 220 | char shldup; /* shield up flag */ | |
221 | char cloaked; /* set if cloaking device on */ | 221 | char cloaked; /* set if cloaking device on */ | |
222 | int energy; /* starship's energy */ | 222 | int energy; /* starship's energy */ | |
223 | int shield; /* energy in shields */ | 223 | int shield; /* energy in shields */ | |
224 | double reserves; /* life support reserves */ | 224 | double reserves; /* life support reserves */ | |
225 | int crew; /* ship's complement */ | 225 | int crew; /* ship's complement */ | |
226 | int brigfree; /* space left in brig */ | 226 | int brigfree; /* space left in brig */ | |
227 | char torped; /* torpedoes */ | 227 | char torped; /* torpedoes */ | |
228 | char cloakgood; /* set if we have moved */ | 228 | char cloakgood; /* set if we have moved */ | |
229 | int quadx; /* quadrant x coord */ | 229 | int quadx; /* quadrant x coord */ | |
230 | int quady; /* quadrant y coord */ | 230 | int quady; /* quadrant y coord */ | |
231 | int sectx; /* sector x coord */ | 231 | int sectx; /* sector x coord */ | |
232 | int secty; /* sector y coord */ | 232 | int secty; /* sector y coord */ | |
233 | unsigned char cond; /* condition code */ | 233 | unsigned char cond; /* condition code */ | |
234 | /* sinsbad is set if SINS is working but not calibrated */ | |||
234 | char sinsbad; /* Space Inertial Navigation System condition */ | 235 | char sinsbad; /* Space Inertial Navigation System condition */ | |
235 | const char *shipname; /* name of current starship */ | 236 | const char *shipname; /* name of current starship */ | |
236 | char ship; /* current starship */ | 237 | char ship; /* current starship */ | |
237 | int distressed; /* number of distress calls */ | 238 | int distressed; /* number of distress calls */ | |
238 | }; | 239 | }; | |
239 | extern struct Ship_struct Ship; | 240 | extern struct Ship_struct Ship; | |
240 | 241 | |||
241 | /* sinsbad is set if SINS is working but not calibrated */ | |||
242 | 242 | |||
243 | /* game related information, mostly scoring */ | 243 | /* game related information, mostly scoring */ | |
244 | struct Game_struct | 244 | struct Game_struct { | |
245 | { | |||
246 | int killk; /* number of klingons killed */ | 245 | int killk; /* number of klingons killed */ | |
247 | int deaths; /* number of deaths onboard Enterprise */ | 246 | int deaths; /* number of deaths onboard Enterprise */ | |
248 | char negenbar; /* number of hits on negative energy barrier */ | 247 | char negenbar; /* number of hits on negative energy barrier */ | |
249 | char killb; /* number of starbases killed */ | 248 | char killb; /* number of starbases killed */ | |
250 | int kills; /* number of stars killed */ | 249 | int kills; /* number of stars killed */ | |
251 | char skill; /* skill rating of player */ | 250 | char skill; /* skill rating of player */ | |
252 | char length; /* length of game */ | 251 | char length; /* length of game */ | |
253 | char killed; /* set if you were killed */ | 252 | char killed; /* set if you were killed */ | |
254 | char killinhab; /* number of inhabited starsystems killed */ | 253 | char killinhab; /* number of inhabited starsystems killed */ | |
255 | char tourn; /* set if a tournament game */ | 254 | char tourn; /* set if a tournament game */ | |
256 | char passwd[15]; /* game password */ | 255 | char passwd[15]; /* game password */ | |
257 | char snap; /* set if snapshot taken */ | 256 | char snap; /* set if snapshot taken */ | |
258 | char helps; /* number of help calls */ | 257 | char helps; /* number of help calls */ | |
259 | int captives; /* total number of captives taken */ | 258 | int captives; /* total number of captives taken */ | |
260 | }; | 259 | }; | |
261 | extern struct Game_struct Game; | 260 | extern struct Game_struct Game; | |
262 | 261 | |||
263 | /* per move information */ | 262 | /* per move information */ | |
264 | struct Move_struct | 263 | struct Move_struct { | |
265 | { | |||
266 | char free; /* set if a move is free */ | 264 | char free; /* set if a move is free */ | |
267 | char endgame; /* end of game flag */ | 265 | char endgame; /* end of game flag */ | |
268 | char shldchg; /* set if shields changed this move */ | 266 | char shldchg; /* set if shields changed this move */ | |
269 | char newquad; /* set if just entered this quadrant */ | 267 | char newquad; /* set if just entered this quadrant */ | |
270 | char resting; /* set if this move is a rest */ | 268 | char resting; /* set if this move is a rest */ | |
271 | double time; /* time used this move */ | 269 | double time; /* time used this move */ | |
272 | }; | 270 | }; | |
273 | extern struct Move_struct Move; | 271 | extern struct Move_struct Move; | |
274 | 272 | |||
275 | /* parametric information */ | 273 | /* parametric information */ | |
276 | struct Param_struct | 274 | struct Param_struct { | |
277 | { | |||
278 | unsigned char bases; /* number of starbases */ | 275 | unsigned char bases; /* number of starbases */ | |
279 | char klings; /* number of klingons */ | 276 | char klings; /* number of klingons */ | |
280 | double date; /* stardate */ | 277 | double date; /* stardate */ | |
281 | double time; /* time left */ | 278 | double time; /* time left */ | |
282 | double resource; /* Federation resources */ | 279 | double resource; /* Federation resources */ | |
283 | int energy; /* starship's energy */ | 280 | int energy; /* starship's energy */ | |
284 | int shield; /* energy in shields */ | 281 | int shield; /* energy in shields */ | |
285 | double reserves; /* life support reserves */ | 282 | double reserves; /* life support reserves */ | |
286 | int crew; /* size of ship's complement */ | 283 | int crew; /* size of ship's complement */ | |
287 | int brigfree; /* max possible number of captives */ | 284 | int brigfree; /* max possible number of captives */ | |
288 | char torped; /* photon torpedos */ | 285 | char torped; /* photon torpedos */ | |
289 | double damfac[NDEV]; /* damage factor */ | 286 | double damfac[NDEV]; /* damage factor */ | |
290 | double dockfac; /* docked repair time factor */ | 287 | double dockfac; /* docked repair time factor */ | |
@@ -300,42 +297,40 @@ struct Param_struct | @@ -300,42 +297,40 @@ struct Param_struct | |||
300 | double navigcrud[2]; /* navigation crudup factor */ | 297 | double navigcrud[2]; /* navigation crudup factor */ | |
301 | int cloakenergy; /* cloaking device energy per stardate */ | 298 | int cloakenergy; /* cloaking device energy per stardate */ | |
302 | double damprob[NDEV]; /* damage probability */ | 299 | double damprob[NDEV]; /* damage probability */ | |
303 | double hitfac; /* Klingon attack factor */ | 300 | double hitfac; /* Klingon attack factor */ | |
304 | int klingcrew; /* number of Klingons in a crew */ | 301 | int klingcrew; /* number of Klingons in a crew */ | |
305 | double srndrprob; /* surrender probability */ | 302 | double srndrprob; /* surrender probability */ | |
306 | int energylow; /* low energy mark (cond YELLOW) */ | 303 | int energylow; /* low energy mark (cond YELLOW) */ | |
307 | }; | 304 | }; | |
308 | extern struct Param_struct Param; | 305 | extern struct Param_struct Param; | |
309 | 306 | |||
310 | /* Sum of damage probabilities must add to 1000 */ | 307 | /* Sum of damage probabilities must add to 1000 */ | |
311 | 308 | |||
312 | /* other information kept in a snapshot */ | 309 | /* other information kept in a snapshot */ | |
313 | struct Now_struct | 310 | struct Now_struct { | |
314 | { | |||
315 | unsigned char bases; /* number of starbases */ | 311 | unsigned char bases; /* number of starbases */ | |
316 | char klings; /* number of klingons */ | 312 | char klings; /* number of klingons */ | |
317 | double date; /* stardate */ | 313 | double date; /* stardate */ | |
318 | double time; /* time left */ | 314 | double time; /* time left */ | |
319 | double resource; /* Federation resources */ | 315 | double resource; /* Federation resources */ | |
320 | char distressed; /* number of currently distressed quadrants */ | 316 | char distressed; /* number of currently distressed quadrants */ | |
321 | struct event *eventptr[NEVENTS]; /* pointer to event structs */ | 317 | struct event *eventptr[NEVENTS]; /* pointer to event structs */ | |
322 | struct xy base[MAXBASES]; /* locations of starbases */ | 318 | struct xy base[MAXBASES]; /* locations of starbases */ | |
323 | }; | 319 | }; | |
324 | extern struct Now_struct Now; | 320 | extern struct Now_struct Now; | |
325 | 321 | |||
326 | /* Other stuff, not dumped in a snapshot */ | 322 | /* Other stuff, not dumped in a snapshot */ | |
327 | struct Etc_struct | 323 | struct Etc_struct { | |
328 | { | |||
329 | struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ | 324 | struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ | |
330 | short nkling; /* number of Klingons in this sector */ | 325 | short nkling; /* number of Klingons in this sector */ | |
331 | /* < 0 means automatic override mode */ | 326 | /* < 0 means automatic override mode */ | |
332 | char fast; /* set if speed > 300 baud */ | 327 | char fast; /* set if speed > 300 baud */ | |
333 | struct xy starbase; /* starbase in current quadrant */ | 328 | struct xy starbase; /* starbase in current quadrant */ | |
334 | char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */ | 329 | char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */ | |
335 | char statreport; /* set to get a status report on a srscan */ | 330 | char statreport; /* set to get a status report on a srscan */ | |
336 | }; | 331 | }; | |
337 | extern struct Etc_struct Etc; | 332 | extern struct Etc_struct Etc; | |
338 | 333 | |||
339 | /* | 334 | /* | |
340 | * eventptr is a pointer to the event[] entry of the last | 335 | * eventptr is a pointer to the event[] entry of the last | |
341 | * scheduled event of each type. Zero if no such event scheduled. | 336 | * scheduled event of each type. Zero if no such event scheduled. |
--- src/games/trek/getpar.h 2005/02/15 12:54:50 1.10
+++ src/games/trek/getpar.h 2009/05/24 21:44:56 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: getpar.h,v 1.10 2005/02/15 12:54:50 jsm Exp $ */ | 1 | /* $NetBSD: getpar.h,v 1.11 2009/05/24 21:44:56 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. | |
@@ -22,28 +22,29 @@ | @@ -22,28 +22,29 @@ | |||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
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 | * @(#)getpar.h 8.1 (Berkeley) 5/31/93 | 31 | * @(#)getpar.h 8.1 (Berkeley) 5/31/93 | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | typedef void (*cmdfun)(int); | 34 | typedef void (*cmdfun)(int); | |
35 | struct cvntab /* used for getcodpar() parameter list */ | 35 | ||
36 | { | 36 | /* used for getcodpar() parameter list */ | |
37 | struct cvntab { | |||
37 | const char *abrev; | 38 | const char *abrev; | |
38 | const char *full; | 39 | const char *full; | |
39 | cmdfun value; | 40 | cmdfun value; | |
40 | int value2; | 41 | int value2; | |
41 | }; | 42 | }; | |
42 | 43 | |||
43 | extern const struct cvntab Skitab[]; | 44 | extern const struct cvntab Skitab[]; | |
44 | extern const struct cvntab Lentab[]; | 45 | extern const struct cvntab Lentab[]; | |
45 | 46 | |||
46 | int getintpar(const char *); | 47 | int getintpar(const char *); | |
47 | double getfltpar(const char *); | 48 | double getfltpar(const char *); | |
48 | int getynpar(const char *); | 49 | int getynpar(const char *); | |
49 | const struct cvntab *getcodpar(const char *, const struct cvntab[]); | 50 | const struct cvntab *getcodpar(const char *, const struct cvntab[]); |
--- src/games/trek/help.c 2009/05/24 19:18:44 1.10
+++ src/games/trek/help.c 2009/05/24 21:44:56 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: help.c,v 1.10 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: help.c,v 1.11 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: help.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: help.c,v 1.11 2009/05/24 21:44:56 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 <unistd.h> | 43 | #include <unistd.h> | |
44 | #include <limits.h> | 44 | #include <limits.h> | |
45 | #include "trek.h" | 45 | #include "trek.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** call starbase for help | 48 | ** call starbase for help | |
49 | ** | 49 | ** | |
50 | ** First, the closest starbase is selected. If there is a | 50 | ** First, the closest starbase is selected. If there is a | |
@@ -54,28 +54,29 @@ __RCSID("$NetBSD: help.c,v 1.10 2009/05/ | @@ -54,28 +54,29 @@ __RCSID("$NetBSD: help.c,v 1.10 2009/05/ | |||
54 | ** A magic number is computed based on the distance which acts | 54 | ** A magic number is computed based on the distance which acts | |
55 | ** as the probability that you will be rematerialized. You | 55 | ** as the probability that you will be rematerialized. You | |
56 | ** get three tries. | 56 | ** get three tries. | |
57 | ** | 57 | ** | |
58 | ** When it is determined that you should be able to be remater- | 58 | ** When it is determined that you should be able to be remater- | |
59 | ** ialized (i.e., when the probability thing mentioned above | 59 | ** ialized (i.e., when the probability thing mentioned above | |
60 | ** comes up positive), you are put into that quadrant (anywhere). | 60 | ** comes up positive), you are put into that quadrant (anywhere). | |
61 | ** Then, we try to see if there is a spot adjacent to the star- | 61 | ** Then, we try to see if there is a spot adjacent to the star- | |
62 | ** base. If not, you can't be rematerialized!!! Otherwise, | 62 | ** base. If not, you can't be rematerialized!!! Otherwise, | |
63 | ** it drops you there. It only tries five times to find a spot | 63 | ** it drops you there. It only tries five times to find a spot | |
64 | ** to drop you. After that, it's your problem. | 64 | ** to drop you. After that, it's your problem. | |
65 | */ | 65 | */ | |
66 | 66 | |||
67 | const char *const Cntvect[3] = | 67 | const char *const Cntvect[3] = { | |
68 | {"first", "second", "third"}; | 68 | "first", "second", "third" | |
69 | }; | |||
69 | 70 | |||
70 | /*ARGSUSED*/ | 71 | /*ARGSUSED*/ | |
71 | void | 72 | void | |
72 | help(int v __unused) | 73 | help(int v __unused) | |
73 | { | 74 | { | |
74 | int i; | 75 | int i; | |
75 | double dist, x; | 76 | double dist, x; | |
76 | int dx = 0, dy = 0; | 77 | int dx = 0, dy = 0; | |
77 | int j, l = 0; | 78 | int j, l = 0; | |
78 | 79 | |||
79 | /* check to see if calling for help is reasonable ... */ | 80 | /* check to see if calling for help is reasonable ... */ | |
80 | if (Ship.cond == DOCKED) { | 81 | if (Ship.cond == DOCKED) { | |
81 | printf("Uhura: But Captain, we're already docked\n"); | 82 | printf("Uhura: But Captain, we're already docked\n"); | |
@@ -87,82 +88,73 @@ help(int v __unused) | @@ -87,82 +88,73 @@ help(int v __unused) | |||
87 | out(SSRADIO); | 88 | out(SSRADIO); | |
88 | return; | 89 | return; | |
89 | } | 90 | } | |
90 | if (Now.bases <= 0) { | 91 | if (Now.bases <= 0) { | |
91 | printf("Uhura: I'm not getting any response from starbase\n"); | 92 | printf("Uhura: I'm not getting any response from starbase\n"); | |
92 | return; | 93 | return; | |
93 | } | 94 | } | |
94 | 95 | |||
95 | /* tut tut, there goes the score */ | 96 | /* tut tut, there goes the score */ | |
96 | Game.helps += 1; | 97 | Game.helps += 1; | |
97 | 98 | |||
98 | /* find the closest base */ | 99 | /* find the closest base */ | |
99 | dist = TOOLARGE; | 100 | dist = TOOLARGE; | |
100 | if (Quad[Ship.quadx][Ship.quady].bases <= 0) | 101 | if (Quad[Ship.quadx][Ship.quady].bases <= 0) { | |
101 | { | |||
102 | /* there isn't one in this quadrant */ | 102 | /* there isn't one in this quadrant */ | |
103 | for (i = 0; i < Now.bases; i++) | 103 | for (i = 0; i < Now.bases; i++) { | |
104 | { | |||
105 | /* compute distance */ | 104 | /* compute distance */ | |
106 | dx = Now.base[i].x - Ship.quadx; | 105 | dx = Now.base[i].x - Ship.quadx; | |
107 | dy = Now.base[i].y - Ship.quady; | 106 | dy = Now.base[i].y - Ship.quady; | |
108 | x = dx * dx + dy * dy; | 107 | x = dx * dx + dy * dy; | |
109 | x = sqrt(x); | 108 | x = sqrt(x); | |
110 | 109 | |||
111 | /* see if better than what we already have */ | 110 | /* see if better than what we already have */ | |
112 | if (x < dist) | 111 | if (x < dist) { | |
113 | { | |||
114 | dist = x; | 112 | dist = x; | |
115 | l = i; | 113 | l = i; | |
116 | } | 114 | } | |
117 | } | 115 | } | |
118 | 116 | |||
119 | /* go to that quadrant */ | 117 | /* go to that quadrant */ | |
120 | Ship.quadx = Now.base[l].x; | 118 | Ship.quadx = Now.base[l].x; | |
121 | Ship.quady = Now.base[l].y; | 119 | Ship.quady = Now.base[l].y; | |
122 | initquad(1); | 120 | initquad(1); | |
123 | } | 121 | } else { | |
124 | else | |||
125 | { | |||
126 | dist = 0.0; | 122 | dist = 0.0; | |
127 | } | 123 | } | |
128 | 124 | |||
129 | /* dematerialize the Enterprise */ | 125 | /* dematerialize the Enterprise */ | |
130 | Sect[Ship.sectx][Ship.secty] = EMPTY; | 126 | Sect[Ship.sectx][Ship.secty] = EMPTY; | |
131 | printf("Starbase in %d,%d responds\n", Ship.quadx, Ship.quady); | 127 | printf("Starbase in %d,%d responds\n", Ship.quadx, Ship.quady); | |
132 | 128 | |||
133 | /* this next thing acts as a probability that it will work */ | 129 | /* this next thing acts as a probability that it will work */ | |
134 | x = pow(1.0 - pow(0.94, dist), 0.3333333); | 130 | x = pow(1.0 - pow(0.94, dist), 0.3333333); | |
135 | 131 | |||
136 | /* attempt to rematerialize */ | 132 | /* attempt to rematerialize */ | |
137 | for (i = 0; i < 3; i++) | 133 | for (i = 0; i < 3; i++) { | |
138 | { | |||
139 | sleep(2); | 134 | sleep(2); | |
140 | printf("%s attempt to rematerialize ", Cntvect[i]); | 135 | printf("%s attempt to rematerialize ", Cntvect[i]); | |
141 | if (franf() > x) | 136 | if (franf() > x) { | |
142 | { | |||
143 | /* ok, that's good. let's see if we can set her down */ | 137 | /* ok, that's good. let's see if we can set her down */ | |
144 | for (j = 0; j < 5; j++) | 138 | for (j = 0; j < 5; j++) { | |
145 | { | |||
146 | dx = Etc.starbase.x + ranf(3) - 1; | 139 | dx = Etc.starbase.x + ranf(3) - 1; | |
147 | if (dx < 0 || dx >= NSECTS) | 140 | if (dx < 0 || dx >= NSECTS) | |
148 | continue; | 141 | continue; | |
149 | dy = Etc.starbase.y + ranf(3) - 1; | 142 | dy = Etc.starbase.y + ranf(3) - 1; | |
150 | if (dy < 0 || dy >= NSECTS || Sect[dx][dy] != EMPTY) | 143 | if (dy < 0 || dy >= NSECTS || Sect[dx][dy] != EMPTY) | |
151 | continue; | 144 | continue; | |
152 | break; | 145 | break; | |
153 | } | 146 | } | |
154 | if (j < 5) | 147 | if (j < 5) { | |
155 | { | |||
156 | /* found an empty spot */ | 148 | /* found an empty spot */ | |
157 | printf("succeeds\n"); | 149 | printf("succeeds\n"); | |
158 | Ship.sectx = dx; | 150 | Ship.sectx = dx; | |
159 | Ship.secty = dy; | 151 | Ship.secty = dy; | |
160 | Sect[dx][dy] = Ship.ship; | 152 | Sect[dx][dy] = Ship.ship; | |
161 | dock(0); | 153 | dock(0); | |
162 | compkldist(0); | 154 | compkldist(0); | |
163 | return; | 155 | return; | |
164 | } | 156 | } | |
165 | /* the starbase must have been surrounded */ | 157 | /* the starbase must have been surrounded */ | |
166 | } | 158 | } | |
167 | printf("fails\n"); | 159 | printf("fails\n"); | |
168 | } | 160 | } |
--- src/games/trek/play.c 2009/05/24 19:18:44 1.10
+++ src/games/trek/play.c 2009/05/24 21:44:56 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: play.c,v 1.10 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: play.c,v 1.11 2009/05/24 21:44:56 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,50 +24,49 @@ | @@ -24,50 +24,49 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: play.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: play.c,v 1.11 2009/05/24 21:44:56 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 <setjmp.h> | 42 | #include <setjmp.h> | |
43 | #include "trek.h" | 43 | #include "trek.h" | |
44 | #include "getpar.h" | 44 | #include "getpar.h" | |
45 | 45 | |||
46 | /* | 46 | /* | |
47 | ** INSTRUCTION READ AND MAIN PLAY LOOP | 47 | ** INSTRUCTION READ AND MAIN PLAY LOOP | |
48 | ** | 48 | ** | |
49 | ** Well folks, this is it. Here we have the guts of the game. | 49 | ** Well folks, this is it. Here we have the guts of the game. | |
50 | ** This routine executes moves. It sets up per-move variables, | 50 | ** This routine executes moves. It sets up per-move variables, | |
51 | ** gets the command, and executes the command. After the command, | 51 | ** gets the command, and executes the command. After the command, | |
52 | ** it calls events() to use up time, attack() to have Klingons | 52 | ** it calls events() to use up time, attack() to have Klingons | |
53 | ** attack if the move was not free, and checkcond() to check up | 53 | ** attack if the move was not free, and checkcond() to check up | |
54 | ** on how we are doing after the move. | 54 | ** on how we are doing after the move. | |
55 | */ | 55 | */ | |
56 | 56 | |||
57 | extern jmp_buf env; | 57 | extern jmp_buf env; | |
58 | 58 | |||
59 | const struct cvntab Comtab[] = | 59 | const struct cvntab Comtab[] = { | |
60 | { | |||
61 | { "abandon", "", abandon, 0 }, | 60 | { "abandon", "", abandon, 0 }, | |
62 | { "ca", "pture", capture, 0 }, | 61 | { "ca", "pture", capture, 0 }, | |
63 | { "cl", "oak", shield, -1 }, | 62 | { "cl", "oak", shield, -1 }, | |
64 | { "c", "omputer", computer, 0 }, | 63 | { "c", "omputer", computer, 0 }, | |
65 | { "da", "mages", dcrept, 0 }, | 64 | { "da", "mages", dcrept, 0 }, | |
66 | { "destruct", "", destruct, 0 }, | 65 | { "destruct", "", destruct, 0 }, | |
67 | { "do", "ck", dock, 0 }, | 66 | { "do", "ck", dock, 0 }, | |
68 | { "help", "", help, 0 }, | 67 | { "help", "", help, 0 }, | |
69 | { "i", "mpulse", impulse, 0 }, | 68 | { "i", "mpulse", impulse, 0 }, | |
70 | { "l", "rscan", lrscan, 0 }, | 69 | { "l", "rscan", lrscan, 0 }, | |
71 | { "m", "ove", dowarp, 0 }, | 70 | { "m", "ove", dowarp, 0 }, | |
72 | { "p", "hasers", phaser, 0 }, | 71 | { "p", "hasers", phaser, 0 }, | |
73 | { "ram", "", dowarp, 1 }, | 72 | { "ram", "", dowarp, 1 }, | |
@@ -87,28 +86,27 @@ const struct cvntab Comtab[] = | @@ -87,28 +86,27 @@ const struct cvntab Comtab[] = | |||
87 | /*ARGSUSED*/ | 86 | /*ARGSUSED*/ | |
88 | void | 87 | void | |
89 | myreset(int v __unused) | 88 | myreset(int v __unused) | |
90 | { | 89 | { | |
91 | 90 | |||
92 | longjmp(env, 1); | 91 | longjmp(env, 1); | |
93 | } | 92 | } | |
94 | 93 | |||
95 | void | 94 | void | |
96 | play(void) | 95 | play(void) | |
97 | { | 96 | { | |
98 | const struct cvntab *r; | 97 | const struct cvntab *r; | |
99 | 98 | |||
100 | while (1) | 99 | while (1) { | |
101 | { | |||
102 | Move.free = 1; | 100 | Move.free = 1; | |
103 | Move.time = 0.0; | 101 | Move.time = 0.0; | |
104 | Move.shldchg = 0; | 102 | Move.shldchg = 0; | |
105 | Move.newquad = 0; | 103 | Move.newquad = 0; | |
106 | Move.resting = 0; | 104 | Move.resting = 0; | |
107 | skiptonl(0); | 105 | skiptonl(0); | |
108 | r = getcodpar("\nCommand", Comtab); | 106 | r = getcodpar("\nCommand", Comtab); | |
109 | (*r->value)(r->value2); | 107 | (*r->value)(r->value2); | |
110 | events(0); | 108 | events(0); | |
111 | attack(0); | 109 | attack(0); | |
112 | checkcond(); | 110 | checkcond(); | |
113 | } | 111 | } | |
114 | } | 112 | } |
--- src/games/trek/main.c 2009/05/24 20:39:43 1.15
+++ src/games/trek/main.c 2009/05/24 21:44:56 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $ */ | 1 | /* $NetBSD: main.c,v 1.16 2009/05/24 21:44:56 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,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
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 | |
40 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; | 40 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; | |
41 | #else | 41 | #else | |
42 | __RCSID("$NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $"); | 42 | __RCSID("$NetBSD: main.c,v 1.16 2009/05/24 21:44:56 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" | |
@@ -172,36 +172,33 @@ main(int argc, char **argv) | @@ -172,36 +172,33 @@ main(int argc, char **argv) | |||
172 | 172 | |||
173 | /* Revoke setgid privileges */ | 173 | /* Revoke setgid privileges */ | |
174 | setgid(getgid()); | 174 | setgid(getgid()); | |
175 | 175 | |||
176 | av = argv; | 176 | av = argv; | |
177 | ac = argc; | 177 | ac = argc; | |
178 | av++; | 178 | av++; | |
179 | time(&curtime); | 179 | time(&curtime); | |
180 | vect = (long) curtime; | 180 | vect = (long) curtime; | |
181 | srand(vect); | 181 | srand(vect); | |
182 | opencode = 'w'; | 182 | opencode = 'w'; | |
183 | prio = PRIO; | 183 | prio = PRIO; | |
184 | 184 | |||
185 | if (tcgetattr(1, &argp) == 0) | 185 | if (tcgetattr(1, &argp) == 0) { | |
186 | { | |||
187 | if (cfgetispeed(&argp) < B1200) | 186 | if (cfgetispeed(&argp) < B1200) | |
188 | Etc.fast++; | 187 | Etc.fast++; | |
189 | } | 188 | } | |
190 | 189 | |||
191 | while (ac > 1 && av[0][0] == '-') | 190 | while (ac > 1 && av[0][0] == '-') { | |
192 | { | 191 | switch (av[0][1]) { | |
193 | switch (av[0][1]) | |||
194 | { | |||
195 | case 'a': /* append to log file */ | 192 | case 'a': /* append to log file */ | |
196 | opencode = 'a'; | 193 | opencode = 'a'; | |
197 | break; | 194 | break; | |
198 | 195 | |||
199 | case 'f': /* set fast mode */ | 196 | case 'f': /* set fast mode */ | |
200 | Etc.fast++; | 197 | Etc.fast++; | |
201 | break; | 198 | break; | |
202 | 199 | |||
203 | case 's': /* set slow mode */ | 200 | case 's': /* set slow mode */ | |
204 | Etc.fast = 0; | 201 | Etc.fast = 0; | |
205 | break; | 202 | break; | |
206 | 203 | |||
207 | #ifdef xTRACE | 204 | #ifdef xTRACE | |
@@ -218,34 +215,33 @@ main(int argc, char **argv) | @@ -218,34 +215,33 @@ main(int argc, char **argv) | |||
218 | prio = atoi(av[0] + 2); | 215 | prio = atoi(av[0] + 2); | |
219 | break; | 216 | break; | |
220 | 217 | |||
221 | default: | 218 | default: | |
222 | badflag: | 219 | badflag: | |
223 | printf("Invalid option: %s\n", av[0]); | 220 | printf("Invalid option: %s\n", av[0]); | |
224 | 221 | |||
225 | } | 222 | } | |
226 | ac--; | 223 | ac--; | |
227 | av++; | 224 | av++; | |
228 | } | 225 | } | |
229 | if (ac > 2) | 226 | if (ac > 2) | |
230 | errx(1, "arg count"); | 227 | errx(1, "arg count"); | |
231 | /* | 228 | /* | |
232 | if (ac > 1) | 229 | if (ac > 1) | |
233 | f_log = fopen(av[0], opencode); | 230 | f_log = fopen(av[0], opencode); | |
234 | */ | 231 | */ | |
235 | 232 | |||
236 | printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n"); | 233 | printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n"); | |
237 | 234 | |||
238 | if (setjmp(env)) | 235 | if (setjmp(env)) { | |
239 | { | |||
240 | if ( !getynpar("Another game") ) | 236 | if ( !getynpar("Another game") ) | |
241 | exit(0); | 237 | exit(0); | |
242 | } | 238 | } | |
243 | do | 239 | ||
244 | { | 240 | do { | |
245 | setup(); | 241 | setup(); | |
246 | play(); | 242 | play(); | |
247 | } while (getynpar("Another game")); | 243 | } while (getynpar("Another game")); | |
248 | 244 | |||
249 | fflush(stdout); | 245 | fflush(stdout); | |
250 | return 0; | 246 | return 0; | |
251 | } | 247 | } |
--- src/games/trek/setup.c 2009/05/24 19:18:44 1.11
+++ src/games/trek/setup.c 2009/05/24 21:44:56 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: setup.c,v 1.11 2009/05/24 19:18:44 dholland Exp $ */ | 1 | /* $NetBSD: setup.c,v 1.12 2009/05/24 21:44:56 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,101 +24,96 @@ | @@ -24,101 +24,96 @@ | |||
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 | |
35 | static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: setup.c,v 1.11 2009/05/24 19:18:44 dholland Exp $"); | 37 | __RCSID("$NetBSD: setup.c,v 1.12 2009/05/24 21:44:56 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 <string.h> | 43 | #include <string.h> | |
44 | #include <unistd.h> | 44 | #include <unistd.h> | |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> | |
46 | #include <err.h> | 46 | #include <err.h> | |
47 | #include <limits.h> | 47 | #include <limits.h> | |
48 | #include "trek.h" | 48 | #include "trek.h" | |
49 | #include "getpar.h" | 49 | #include "getpar.h" | |
50 | 50 | |||
51 | /* | 51 | /* | |
52 | ** INITIALIZE THE GAME | 52 | ** INITIALIZE THE GAME | |
53 | ** | 53 | ** | |
54 | ** The length, skill, and password are read, and the game | 54 | ** The length, skill, and password are read, and the game | |
55 | ** is initialized. It is far too difficult to describe all | 55 | ** is initialized. It is far too difficult to describe all | |
56 | ** that goes on in here, but it is all straight-line code; | 56 | ** that goes on in here, but it is all straight-line code; | |
57 | ** give it a look. | 57 | ** give it a look. | |
58 | ** | 58 | ** | |
59 | ** Game restart and tournament games are handled here. | 59 | ** Game restart and tournament games are handled here. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | const struct cvntab Lentab[] = | 62 | const struct cvntab Lentab[] = { | |
63 | { | |||
64 | { "s", "hort", (cmdfun)1, 0 }, | 63 | { "s", "hort", (cmdfun)1, 0 }, | |
65 | { "m", "edium", (cmdfun)2, 0 }, | 64 | { "m", "edium", (cmdfun)2, 0 }, | |
66 | { "l", "ong", (cmdfun)4, 0 }, | 65 | { "l", "ong", (cmdfun)4, 0 }, | |
67 | { "restart", "", (cmdfun)0, 0 }, | 66 | { "restart", "", (cmdfun)0, 0 }, | |
68 | { NULL, NULL, NULL, 0 } | 67 | { NULL, NULL, NULL, 0 } | |
69 | }; | 68 | }; | |
70 | 69 | |||
71 | const struct cvntab Skitab[] = | 70 | const struct cvntab Skitab[] = { | |
72 | { | |||
73 | { "n", "ovice", (cmdfun)1, 0 }, | 71 | { "n", "ovice", (cmdfun)1, 0 }, | |
74 | { "f", "air", (cmdfun)2, 0 }, | 72 | { "f", "air", (cmdfun)2, 0 }, | |
75 | { "g", "ood", (cmdfun)3, 0 }, | 73 | { "g", "ood", (cmdfun)3, 0 }, | |
76 | { "e", "xpert", (cmdfun)4, 0 }, | 74 | { "e", "xpert", (cmdfun)4, 0 }, | |
77 | { "c", "ommodore", (cmdfun)5, 0 }, | 75 | { "c", "ommodore", (cmdfun)5, 0 }, | |
78 | { "i", "mpossible", (cmdfun)6, 0 }, | 76 | { "i", "mpossible", (cmdfun)6, 0 }, | |
79 | { NULL, NULL, NULL, 0 } | 77 | { NULL, NULL, NULL, 0 } | |
80 | }; | 78 | }; | |
81 | 79 | |||
82 | void | 80 | void | |
83 | setup(void) | 81 | setup(void) | |
84 | { | 82 | { | |
85 | const struct cvntab *r; | 83 | const struct cvntab *r; | |
86 | int i, j; | 84 | int i, j; | |
87 | double f; | 85 | double f; | |
88 | int d; | 86 | int d; | |
89 | int klump; | 87 | int klump; | |
90 | int ix, iy; | 88 | int ix, iy; | |
91 | struct quad *q; | 89 | struct quad *q; | |
92 | struct event *e; | 90 | struct event *e; | |
93 | 91 | |||
94 | while (1) | 92 | while (1) { | |
95 | { | |||
96 | r = getcodpar("What length game", Lentab); | 93 | r = getcodpar("What length game", Lentab); | |
97 | Game.length = (long) r->value; | 94 | Game.length = (long) r->value; | |
98 | if (Game.length == 0) | 95 | if (Game.length == 0) { | |
99 | { | |||
100 | if (restartgame()) | 96 | if (restartgame()) | |
101 | continue; | 97 | continue; | |
102 | return; | 98 | return; | |
103 | } | 99 | } | |
104 | break; | 100 | break; | |
105 | } | 101 | } | |
106 | r = getcodpar("What skill game", Skitab); | 102 | r = getcodpar("What skill game", Skitab); | |
107 | Game.skill = (long) r->value; | 103 | Game.skill = (long) r->value; | |
108 | Game.tourn = 0; | 104 | Game.tourn = 0; | |
109 | getstrpar("Enter a password", Game.passwd, 14, 0); | 105 | getstrpar("Enter a password", Game.passwd, 14, 0); | |
110 | if (strcmp(Game.passwd, "tournament") == 0) | 106 | if (strcmp(Game.passwd, "tournament") == 0) { | |
111 | { | |||
112 | getstrpar("Enter tournament code", Game.passwd, 14, 0); | 107 | getstrpar("Enter tournament code", Game.passwd, 14, 0); | |
113 | Game.tourn = 1; | 108 | Game.tourn = 1; | |
114 | d = 0; | 109 | d = 0; | |
115 | for (i = 0; Game.passwd[i]; i++) | 110 | for (i = 0; Game.passwd[i]; i++) | |
116 | d += Game.passwd[i] << i; | 111 | d += Game.passwd[i] << i; | |
117 | srand(d); | 112 | srand(d); | |
118 | } | 113 | } | |
119 | Param.bases = Now.bases = ranf(6 - Game.skill) + 2; | 114 | Param.bases = Now.bases = ranf(6 - Game.skill) + 2; | |
120 | if (Game.skill == 6) | 115 | if (Game.skill == 6) | |
121 | Param.bases = Now.bases = 1; | 116 | Param.bases = Now.bases = 1; | |
122 | Param.time = Now.time = 6.0 * Game.length + 2.0; | 117 | Param.time = Now.time = 6.0 * Game.length + 2.0; | |
123 | i = Game.skill; | 118 | i = Game.skill; | |
124 | j = Game.length; | 119 | j = Game.length; | |
@@ -199,107 +194,99 @@ setup(void) | @@ -199,107 +194,99 @@ setup(void) | |||
199 | Param.movefac[KM_LA] = 0.25; | 194 | Param.movefac[KM_LA] = 0.25; | |
200 | Param.eventdly[E_SNOVA] = 0.5; | 195 | Param.eventdly[E_SNOVA] = 0.5; | |
201 | Param.eventdly[E_LRTB] = 25.0; | 196 | Param.eventdly[E_LRTB] = 25.0; | |
202 | Param.eventdly[E_KATSB] = 1.0; | 197 | Param.eventdly[E_KATSB] = 1.0; | |
203 | Param.eventdly[E_KDESB] = 3.0; | 198 | Param.eventdly[E_KDESB] = 3.0; | |
204 | Param.eventdly[E_ISSUE] = 1.0; | 199 | Param.eventdly[E_ISSUE] = 1.0; | |
205 | Param.eventdly[E_SNAP] = 0.5; | 200 | Param.eventdly[E_SNAP] = 0.5; | |
206 | Param.eventdly[E_ENSLV] = 0.5; | 201 | Param.eventdly[E_ENSLV] = 0.5; | |
207 | Param.eventdly[E_REPRO] = 2.0; | 202 | Param.eventdly[E_REPRO] = 2.0; | |
208 | Param.navigcrud[0] = 1.50; | 203 | Param.navigcrud[0] = 1.50; | |
209 | Param.navigcrud[1] = 0.75; | 204 | Param.navigcrud[1] = 0.75; | |
210 | Param.cloakenergy = 1000; | 205 | Param.cloakenergy = 1000; | |
211 | Param.energylow = 1000; | 206 | Param.energylow = 1000; | |
212 | for (i = 0; i < MAXEVENTS; i++) | 207 | for (i = 0; i < MAXEVENTS; i++) { | |
213 | { | |||
214 | e = &Event[i]; | 208 | e = &Event[i]; | |
215 | e->date = TOOLARGE; | 209 | e->date = TOOLARGE; | |
216 | e->evcode = 0; | 210 | e->evcode = 0; | |
217 | } | 211 | } | |
218 | xsched(E_SNOVA, 1, 0, 0, 0); | 212 | xsched(E_SNOVA, 1, 0, 0, 0); | |
219 | xsched(E_LRTB, Param.klings, 0, 0, 0); | 213 | xsched(E_LRTB, Param.klings, 0, 0, 0); | |
220 | xsched(E_KATSB, 1, 0, 0, 0); | 214 | xsched(E_KATSB, 1, 0, 0, 0); | |
221 | xsched(E_ISSUE, 1, 0, 0, 0); | 215 | xsched(E_ISSUE, 1, 0, 0, 0); | |
222 | xsched(E_SNAP, 1, 0, 0, 0); | 216 | xsched(E_SNAP, 1, 0, 0, 0); | |
223 | Ship.sectx = ranf(NSECTS); | 217 | Ship.sectx = ranf(NSECTS); | |
224 | Ship.secty = ranf(NSECTS); | 218 | Ship.secty = ranf(NSECTS); | |
225 | Game.killk = Game.kills = Game.killb = 0; | 219 | Game.killk = Game.kills = Game.killb = 0; | |
226 | Game.deaths = Game.negenbar = 0; | 220 | Game.deaths = Game.negenbar = 0; | |
227 | Game.captives = 0; | 221 | Game.captives = 0; | |
228 | Game.killinhab = 0; | 222 | Game.killinhab = 0; | |
229 | Game.helps = 0; | 223 | Game.helps = 0; | |
230 | Game.killed = 0; | 224 | Game.killed = 0; | |
231 | Game.snap = 0; | 225 | Game.snap = 0; | |
232 | Move.endgame = 0; | 226 | Move.endgame = 0; | |
233 | 227 | |||
234 | /* setup stars */ | 228 | /* setup stars */ | |
235 | for (i = 0; i < NQUADS; i++) | 229 | for (i = 0; i < NQUADS; i++) { | |
236 | for (j = 0; j < NQUADS; j++) | 230 | for (j = 0; j < NQUADS; j++) { | |
237 | { | |||
238 | short s5; | 231 | short s5; | |
239 | q = &Quad[i][j]; | 232 | q = &Quad[i][j]; | |
240 | q->klings = q->bases = 0; | 233 | q->klings = q->bases = 0; | |
241 | q->scanned = -1; | 234 | q->scanned = -1; | |
242 | q->stars = ranf(9) + 1; | 235 | q->stars = ranf(9) + 1; | |
243 | q->holes = ranf(3); | 236 | q->holes = ranf(3); | |
244 | s5 = q->stars / 5; | 237 | s5 = q->stars / 5; | |
245 | q->holes = q->holes > s5 ? q->holes - s5 : 0; | 238 | q->holes = q->holes > s5 ? q->holes - s5 : 0; | |
246 | q->qsystemname = 0; | 239 | q->qsystemname = 0; | |
247 | } | 240 | } | |
241 | } | |||
248 | 242 | |||
249 | /* select inhabited starsystems */ | 243 | /* select inhabited starsystems */ | |
250 | for (d = 1; d < NINHAB; d++) | 244 | for (d = 1; d < NINHAB; d++) { | |
251 | { | 245 | do { | |
252 | do | |||
253 | { | |||
254 | i = ranf(NQUADS); | 246 | i = ranf(NQUADS); | |
255 | j = ranf(NQUADS); | 247 | j = ranf(NQUADS); | |
256 | q = &Quad[i][j]; | 248 | q = &Quad[i][j]; | |
257 | } while (q->qsystemname); | 249 | } while (q->qsystemname); | |
258 | q->qsystemname = d; | 250 | q->qsystemname = d; | |
259 | } | 251 | } | |
260 | 252 | |||
261 | /* position starbases */ | 253 | /* position starbases */ | |
262 | for (i = 0; i < Param.bases; i++) | 254 | for (i = 0; i < Param.bases; i++) { | |
263 | { | 255 | while (1) { | |
264 | while (1) | |||
265 | { | |||
266 | ix = ranf(NQUADS); | 256 | ix = ranf(NQUADS); | |
267 | iy = ranf(NQUADS); | 257 | iy = ranf(NQUADS); | |
268 | q = &Quad[ix][iy]; | 258 | q = &Quad[ix][iy]; | |
269 | if (q->bases > 0) | 259 | if (q->bases > 0) | |
270 | continue; | 260 | continue; | |
271 | break; | 261 | break; | |
272 | } | 262 | } | |
273 | q->bases = 1; | 263 | q->bases = 1; | |
274 | Now.base[i].x = ix; | 264 | Now.base[i].x = ix; | |
275 | Now.base[i].y = iy; | 265 | Now.base[i].y = iy; | |
276 | q->scanned = 1001; | 266 | q->scanned = 1001; | |
277 | /* start the Enterprise near starbase */ | 267 | /* start the Enterprise near starbase */ | |
278 | if (i == 0) | 268 | if (i == 0) { | |
279 | { | |||
280 | Ship.quadx = ix; | 269 | Ship.quadx = ix; | |
281 | Ship.quady = iy; | 270 | Ship.quady = iy; | |
282 | } | 271 | } | |
283 | } | 272 | } | |
284 | 273 | |||
285 | /* position klingons */ | 274 | /* position klingons */ | |
286 | for (i = Param.klings; i > 0; ) | 275 | for (i = Param.klings; i > 0; ) { | |
287 | { | |||
288 | klump = ranf(4) + 1; | 276 | klump = ranf(4) + 1; | |
289 | if (klump > i) | 277 | if (klump > i) | |
290 | klump = i; | 278 | klump = i; | |
291 | while (1) | 279 | while (1) { | |
292 | { | |||
293 | ix = ranf(NQUADS); | 280 | ix = ranf(NQUADS); | |
294 | iy = ranf(NQUADS); | 281 | iy = ranf(NQUADS); | |
295 | q = &Quad[ix][iy]; | 282 | q = &Quad[ix][iy]; | |
296 | if (q->klings + klump > MAXKLQUAD) | 283 | if (q->klings + klump > MAXKLQUAD) | |
297 | continue; | 284 | continue; | |
298 | q->klings += klump; | 285 | q->klings += klump; | |
299 | i -= klump; | 286 | i -= klump; | |
300 | break; | 287 | break; | |
301 | } | 288 | } | |
302 | } | 289 | } | |
303 | 290 | |||
304 | /* initialize this quadrant */ | 291 | /* initialize this quadrant */ | |
305 | printf("%d Klingons\n%d starbase", Param.klings, Param.bases); | 292 | printf("%d Klingons\n%d starbase", Param.klings, Param.bases); |
--- src/games/trek/torped.c 2009/05/24 20:43:09 1.11
+++ src/games/trek/torped.c 2009/05/24 21:44:56 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: torped.c,v 1.11 2009/05/24 20:43:09 dholland Exp $ */ | 1 | /* $NetBSD: torped.c,v 1.12 2009/05/24 21:44:56 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 | |
35 | static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93"; | 35 | static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: torped.c,v 1.11 2009/05/24 20:43:09 dholland Exp $"); | 37 | __RCSID("$NetBSD: torped.c,v 1.12 2009/05/24 21:44:56 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 <stdlib.h> | 42 | #include <stdlib.h> | |
43 | #include <math.h> | 43 | #include <math.h> | |
44 | #include "trek.h" | 44 | #include "trek.h" | |
45 | #include "getpar.h" | 45 | #include "getpar.h" | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | ** PHOTON TORPEDO CONTROL | 48 | ** PHOTON TORPEDO CONTROL | |
49 | ** | 49 | ** | |
50 | ** Either one or three photon torpedoes are fired. If three | 50 | ** Either one or three photon torpedoes are fired. If three | |
@@ -69,130 +69,116 @@ static int randcourse(int); | @@ -69,130 +69,116 @@ static int randcourse(int); | |||
69 | void | 69 | void | |
70 | torped(int v __unused) | 70 | torped(int v __unused) | |
71 | { | 71 | { | |
72 | int ix, iy; | 72 | int ix, iy; | |
73 | double x, y, dx, dy; | 73 | double x, y, dx, dy; | |
74 | double angle; | 74 | double angle; | |
75 | int course, course2; | 75 | int course, course2; | |
76 | int k; | 76 | int k; | |
77 | double bigger; | 77 | double bigger; | |
78 | double sectsize; | 78 | double sectsize; | |
79 | int burst; | 79 | int burst; | |
80 | int n; | 80 | int n; | |
81 | 81 | |||
82 | if (Ship.cloaked) | 82 | if (Ship.cloaked) { | |
83 | { | |||
84 | printf("Federation regulations do not permit attack while cloaked.\n"); | 83 | printf("Federation regulations do not permit attack while cloaked.\n"); | |
85 | return; | 84 | return; | |
86 | } | 85 | } | |
87 | if (check_out(TORPED)) | 86 | if (check_out(TORPED)) | |
88 | return; | 87 | return; | |
89 | if (Ship.torped <= 0) | 88 | if (Ship.torped <= 0) { | |
90 | { | |||
91 | printf("All photon torpedos expended\n"); | 89 | printf("All photon torpedos expended\n"); | |
92 | return; | 90 | return; | |
93 | } | 91 | } | |
94 | 92 | |||
95 | /* get the course */ | 93 | /* get the course */ | |
96 | course = getintpar("Torpedo course"); | 94 | course = getintpar("Torpedo course"); | |
97 | if (course < 0 || course > 360) | 95 | if (course < 0 || course > 360) | |
98 | return; | 96 | return; | |
99 | burst = -1; | 97 | burst = -1; | |
100 | 98 | |||
101 | /* need at least three torpedoes for a burst */ | 99 | /* need at least three torpedoes for a burst */ | |
102 | if (Ship.torped < 3) | 100 | if (Ship.torped < 3) { | |
103 | { | |||
104 | printf("No-burst mode selected\n"); | 101 | printf("No-burst mode selected\n"); | |
105 | burst = 0; | 102 | burst = 0; | |
106 | } | 103 | } else { | |
107 | else | |||
108 | { | |||
109 | /* see if the user wants one */ | 104 | /* see if the user wants one */ | |
110 | if (!testnl()) | 105 | if (!testnl()) { | |
111 | { | |||
112 | k = ungetc(cgetc(0), stdin); | 106 | k = ungetc(cgetc(0), stdin); | |
113 | if (k >= '0' && k <= '9') | 107 | if (k >= '0' && k <= '9') | |
114 | burst = 1; | 108 | burst = 1; | |
115 | } | 109 | } | |
116 | } | 110 | } | |
117 | if (burst < 0) | 111 | if (burst < 0) { | |
118 | { | |||
119 | burst = getynpar("Do you want a burst"); | 112 | burst = getynpar("Do you want a burst"); | |
120 | } | 113 | } | |
121 | if (burst) | 114 | if (burst) { | |
122 | { | |||
123 | burst = getintpar("burst angle"); | 115 | burst = getintpar("burst angle"); | |
124 | if (burst <= 0) | 116 | if (burst <= 0) | |
125 | return; | 117 | return; | |
126 | if (burst > 15) { | 118 | if (burst > 15) { | |
127 | printf("Maximum burst angle is 15 degrees\n"); | 119 | printf("Maximum burst angle is 15 degrees\n"); | |
128 | return; | 120 | return; | |
129 | } | 121 | } | |
130 | } | 122 | } | |
131 | sectsize = NSECTS; | 123 | sectsize = NSECTS; | |
132 | n = -1; | 124 | n = -1; | |
133 | if (burst) | 125 | if (burst) { | |
134 | { | |||
135 | n = 1; | 126 | n = 1; | |
136 | course -= burst; | 127 | course -= burst; | |
137 | } | 128 | } | |
138 | for (; n && n <= 3; n++) | 129 | for (; n && n <= 3; n++) { | |
139 | { | |||
140 | /* select a nice random course */ | 130 | /* select a nice random course */ | |
141 | course2 = course + randcourse(n); | 131 | course2 = course + randcourse(n); | |
142 | angle = course2 * 0.0174532925; /* convert to radians */ | 132 | /* convert to radians */ | |
133 | angle = course2 * 0.0174532925; | |||
143 | dx = -cos(angle); | 134 | dx = -cos(angle); | |
144 | dy = sin(angle); | 135 | dy = sin(angle); | |
145 | bigger = fabs(dx); | 136 | bigger = fabs(dx); | |
146 | x = fabs(dy); | 137 | x = fabs(dy); | |
147 | if (x > bigger) | 138 | if (x > bigger) | |
148 | bigger = x; | 139 | bigger = x; | |
149 | dx /= bigger; | 140 | dx /= bigger; | |
150 | dy /= bigger; | 141 | dy /= bigger; | |
151 | x = Ship.sectx + 0.5; | 142 | x = Ship.sectx + 0.5; | |
152 | y = Ship.secty + 0.5; | 143 | y = Ship.secty + 0.5; | |
153 | if (Ship.cond != DOCKED) | 144 | if (Ship.cond != DOCKED) | |
154 | Ship.torped -= 1; | 145 | Ship.torped -= 1; | |
155 | printf("Torpedo track"); | 146 | printf("Torpedo track"); | |
156 | if (n > 0) | 147 | if (n > 0) | |
157 | printf(", torpedo number %d", n); | 148 | printf(", torpedo number %d", n); | |
158 | printf(":\n%6.1f\t%4.1f\n", x, y); | 149 | printf(":\n%6.1f\t%4.1f\n", x, y); | |
159 | while (1) | 150 | while (1) { | |
160 | { | |||
161 | ix = x += dx; | 151 | ix = x += dx; | |
162 | iy = y += dy; | 152 | iy = y += dy; | |
163 | if (x < 0.0 || x >= sectsize || y < 0.0 || y >= sectsize) | 153 | if (x < 0.0 || x >= sectsize || y < 0.0 || y >= sectsize) { | |
164 | { | |||
165 | printf("Torpedo missed\n"); | 154 | printf("Torpedo missed\n"); | |
166 | break; | 155 | break; | |
167 | } | 156 | } | |
168 | printf("%6.1f\t%4.1f\n", x, y); | 157 | printf("%6.1f\t%4.1f\n", x, y); | |
169 | switch (Sect[ix][iy]) | 158 | switch (Sect[ix][iy]) { | |
170 | { | |||
171 | case EMPTY: | 159 | case EMPTY: | |
172 | continue; | 160 | continue; | |
173 | 161 | |||
174 | case HOLE: | 162 | case HOLE: | |
175 | printf("Torpedo disappears into a black hole\n"); | 163 | printf("Torpedo disappears into a black hole\n"); | |
176 | break; | 164 | break; | |
177 | 165 | |||
178 | case KLINGON: | 166 | case KLINGON: | |
179 | for (k = 0; k < Etc.nkling; k++) | 167 | for (k = 0; k < Etc.nkling; k++) { | |
180 | { | |||
181 | if (Etc.klingon[k].x != ix || Etc.klingon[k].y != iy) | 168 | if (Etc.klingon[k].x != ix || Etc.klingon[k].y != iy) | |
182 | continue; | 169 | continue; | |
183 | Etc.klingon[k].power -= 500 + ranf(501); | 170 | Etc.klingon[k].power -= 500 + ranf(501); | |
184 | if (Etc.klingon[k].power > 0) | 171 | if (Etc.klingon[k].power > 0) { | |
185 | { | |||
186 | printf("*** Hit on Klingon at %d,%d: extensive damages\n", | 172 | printf("*** Hit on Klingon at %d,%d: extensive damages\n", | |
187 | ix, iy); | 173 | ix, iy); | |
188 | break; | 174 | break; | |
189 | } | 175 | } | |
190 | killk(ix, iy); | 176 | killk(ix, iy); | |
191 | break; | 177 | break; | |
192 | } | 178 | } | |
193 | break; | 179 | break; | |
194 | 180 | |||
195 | case STAR: | 181 | case STAR: | |
196 | nova(ix, iy); | 182 | nova(ix, iy); | |
197 | break; | 183 | break; | |
198 | 184 | |||
@@ -226,36 +212,33 @@ torped(int v __unused) | @@ -226,36 +212,33 @@ torped(int v __unused) | |||
226 | ** | 212 | ** | |
227 | ** This routine randomizes the course for torpedo number 'n'. | 213 | ** This routine randomizes the course for torpedo number 'n'. | |
228 | ** Other things handled by this routine are misfires, damages | 214 | ** Other things handled by this routine are misfires, damages | |
229 | ** to the tubes, etc. | 215 | ** to the tubes, etc. | |
230 | */ | 216 | */ | |
231 | 217 | |||
232 | static int | 218 | static int | |
233 | randcourse(int n) | 219 | randcourse(int n) | |
234 | { | 220 | { | |
235 | double r; | 221 | double r; | |
236 | int d; | 222 | int d; | |
237 | 223 | |||
238 | d = ((franf() + franf()) - 1.0) * 20; | 224 | d = ((franf() + franf()) - 1.0) * 20; | |
239 | if (abs(d) > 12) | 225 | if (abs(d) > 12) { | |
240 | { | |||
241 | printf("Photon tubes misfire"); | 226 | printf("Photon tubes misfire"); | |
242 | if (n < 0) | 227 | if (n < 0) | |
243 | printf("\n"); | 228 | printf("\n"); | |
244 | else | 229 | else | |
245 | printf(" on torpedo %d\n", n); | 230 | printf(" on torpedo %d\n", n); | |
246 | if (ranf(2)) | 231 | if (ranf(2)) { | |
247 | { | |||
248 | damage(TORPED, 0.2 * abs(d) * (franf() + 1.0)); | 232 | damage(TORPED, 0.2 * abs(d) * (franf() + 1.0)); | |
249 | } | 233 | } | |
250 | d *= 1.0 + 2.0 * franf(); | 234 | d *= 1.0 + 2.0 * franf(); | |
251 | } | 235 | } | |
252 | if (Ship.shldup || Ship.cond == DOCKED) | 236 | if (Ship.shldup || Ship.cond == DOCKED) { | |
253 | { | |||
254 | r = Ship.shield; | 237 | r = Ship.shield; | |
255 | r = 1.0 + r / Param.shield; | 238 | r = 1.0 + r / Param.shield; | |
256 | if (Ship.cond == DOCKED) | 239 | if (Ship.cond == DOCKED) | |
257 | r = 2.0; | 240 | r = 2.0; | |
258 | d *= r; | 241 | d *= r; | |
259 | } | 242 | } | |
260 | return (d); | 243 | return (d); | |
261 | } | 244 | } |