]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/warp.c
1 char rcsid
[] = "@(#)Header: warp.c,v 7.0.1.3 86/12/12 17:07:44 lwall Exp";
3 /* warp -- a real-time space war program
5 * helpers: Jonathan and Mark Biggar, and Dan Faigin
6 * special thanks to my sweetie Gloria who suggested the Planet Crusher
8 * Copyright (c) 2020 The NetBSD Foundation, Inc.
11 * This code is derived from software contributed to The NetBSD Foundation
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * version 5.0 04/20/83
36 * 5.1 05/05/83 various tidbits
37 * 5.2 05/12/83 VAX -> vax, ifdef'ed a SIGCONT
41 * Revision 7.0.1.3 86/12/12 17:07:44 lwall
42 * Baseline for net release.
44 * Revision 7.0.1.2 86/10/20 12:08:00 lwall
45 * Made all exits reset tty.
47 * Revision 7.0.1.1 86/10/16 10:54:13 lwall
48 * Added Damage. Fixed random bugs.
50 * Revision 7.0 86/10/08 15:14:47 lwall
51 * Split into separate files. Added amoebas and pirates.
53 * Revision 6.4 83/12/16 13:11:45 lwall
54 * Handled 15 bit random number generators.
56 * Fixed array overflow bug on multiple zaps.
58 * Multiple zaps now consolidated to minimize output.
60 * Tholian jackpot games outlawed under difficulty 15.
62 * Revision 6.3 83/08/24 11:17:49 lwall
63 * Fixed array overflow bug on multiple zap.
65 * Revision 6.2 83/08/23 18:06:37 lwall
67 * Warp -s should now work on dumb terminals
68 * Specifying difficulty >= 40 now just makes it a special game.
70 * No-delay read provided as alternative to FIONREAD.
71 * Warp won't report "-1 obsolete" when there are no Enterprises left.
72 * Some high-difficulty tuning.
74 * Revision 6.1 83/08/17 08:49:03 lwall
75 * Fixed obscure bug in storing UP that caused a %. in CM to occasionally
76 * foist garbage onto the screen.
78 * Revision 6.0 83/08/08 17:09:26 lwall
79 * New baseline version for net release.
81 * Revision 5.5 83/08/01 10:59:56 lwall
82 * Cloaking for the Enterprise.
83 * Difficulty now goes to 99, and many activities depending on difficulty
84 * have been adjusted in frequency.
85 * Simplified exit sequence, and reduced dependencies on control
86 * characters. You needn't see the scoreboard if you don't want to.
87 * Hitting i,w,c, or v switches to Enterprise. Hitting p switches to Base.
88 * Excessive use of q is not allowed.
89 * Excessive use of D is not allowed.
90 * Scoreboard may depend on either full name or login name.
91 * Integrated scoreboard lister. Login name now shows up on scoreboard.
92 * "Hidden" startup options are now upper case.
93 * Checks upon startup for no cursor movement, or screen too small.
94 * Checks upon startup that WARPDIR is correctly protected, and that warp
95 * is running setuid. As an additional bonus this prevents root from
96 * running warp, which mucks things up, UN*X be blessed.
97 * All gets's turned into fgets's for safety.
98 * Bonus Enterprises and Bases.
99 * Escalating bonuses for saving Base and Enterprise.
100 * Escalating Enterprise energy.
101 * Turbolasers decrease with distance.
102 * Really smart enemies can see through stars occasionally.
103 * Occasional Tholian jackpot waves. Tholians are a trifle nastier.
105 * An O or o can miss seeing you. Enemies can avoid a stationary O, o, or X.
106 * Warp 3 enemies and other nastinesses are possible in massacre mode.
107 * Enemies that decide to navigate when they see you can do other things than
108 * just come toward you.
109 * Gorns occasionally launch a salvo for the fun of it.
110 * Only star and enemy explosions can keep the round going now.
111 * Bounces don't always go back to starting spot now.
112 * Better full name processing. USG quirks handled. & substitution also
113 * handled now (whoever dreamed up that one must have been in the middle
114 * of the night before the morning after).
116 * Version number printer.
117 * Less signal catching during debugging.
119 * Revision 5.4 83/06/24 09:28:38 lwall
120 * 16 bit random number generators are now supported.
121 * Made warp not blow up on a null save file.
122 * Warp now prints E and B before the stars.
123 * Fixed bug which caused torp count to get decremented even when no torp
124 * was launched because of an obstacle.
125 * Put %<n>ld formats where appropriate.
126 * Fixed E: 0 0 bug on refresh.
128 * Revision 5.3 83/05/24 14:03:10 lwall
152 main(int argc
, char *argv
[])
154 char tmp
, *s
, *tcbuf
;
158 #ifdef lint /* to suppress "defined but never used" */
160 (void)stop_catcher();
163 (void)cont_catcher();
167 while (--argc
> 0 && (*++argv
)[0] == '-')
168 for (s
= argv
[0]+1; *s
!= '\0'; s
++)
209 inumenemies
= atoi(s
);
217 inumfriends
= atoi(s
);
238 inumpirates
= atoi(s
);
272 experimenting
= true;
279 fprintf(stderr
,"warp: illegal option %c\n", *s
);
280 fprintf(stderr
, "Usage: warp -dn -b -x -v -s\n");
284 fprintf(stderr
, "Usage: warp -dn -b -x -v -s\n");
296 tcbuf
= malloc(1024);
299 if (chdir(warplib
) < 0)
300 fprintf(stderr
,NOCD
,warplib
);
307 umask(022); /* mustn't rely on incoming umask--could be 033 which */
308 /* would disable people from running wscore */
316 mvaddstr(12,25,"*** restoring saved game ***");
323 for (keepgoing
= true;;) {
324 if (!experimenting
) {
325 if ((savfil
= fopen(savefilename
,"w")) == NULL
) {
327 printf("Can't open savefile `%s'\r\n", savefilename
);
331 "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n",
332 logname
, totalscore
, smarts
, cumsmarts
,
333 numents
, numbases
, wave
,
334 apolspec
? 'a' : ' ',
335 beginner
? 'b' : ' ',
336 crushspec
? 'c' : ' ',
337 gornspec
? 'g' : ' ',
338 massacre
? 'm' : ' ',
340 tholspec
? 't' : ' ',
341 lowspeed
? 'l' : ' ',
342 amoebaspec
? '&' : ' '
344 fprintf(savfil
," running on %s, process #%d\n",
349 lastscore
= totalscore
;
354 if (numents
<=0 && numbases
<=0)
356 if (!keepgoing
) break;
360 " [Hit space to continue, 'q' to quit] ");
364 "[Hit space to continue, 's' to save, 'q' to quit]");
370 if (tmp
== BREAKCH
|| tmp
== INTRCH
) {
376 if (tmp
== 'y' || tmp
== 'Y')
381 } while (tmp
!= INTRCH
&& tmp
!= BREAKCH
&& !strchr(" qQs",tmp
));
382 if (tmp
!= ' ' && tmp
!= 's') break;
383 if (!beginner
&& smarts
< 20)
385 else if (!beginner
&& smarts
< 35)
387 else if (smarts
< 99)
389 if (tmp
== 's') save_game();
393 } while (justonemoretime
);
396 unlink(savefilename
);