]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/warp.c
941b4ca2dd89030f888bbe690ae28187c3d6bef5
1 char rcsid
[] = "@(#)$Header: /cvsroot/src/games/warp/warp.c,v 1.1 2020/11/09 23:37:05 kamil 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) 1986, Larry Wall
10 * This program may be copied as long as this copyright notice is
11 * included, and as long as it is not being copied for purposes
12 * of profit. If you want to modify this program in any way other
13 * than normal configuration changes, common decency would suggest
14 * that you also modify the name of the program so that my good name
15 * (what there is of it) is not impugned. (Calling it something like
16 * "warpx" or "superwarp" would be fine.) Also, give it another
17 * WARPDIR so that the scoreboards don't get confused.
19 * version 5.0 04/20/83
20 * 5.1 05/05/83 various tidbits
21 * 5.2 05/12/83 VAX -> vax, ifdef'ed a SIGCONT
25 * Revision 1.1 2020/11/09 23:37:05 kamil
26 * Add Warp Kit, Version 7.0 by Larry Wall
28 * Warp is a real-time space war game that doesn't get boring very quickly.
29 * Read warp.doc and the manual page for more information.
31 * games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
32 * world via NetBSD. Its remnants were still mentioned in games/Makefile.
34 * Larry Wall, the original author and the copyright holder, generously
35 * donated the game and copyright to The NetBSD Foundation, Inc.
37 * Import the game sources as-is from 4.3BSD-Reno, with the cession
38 * of the copyright and license to BSD-2-clause NetBSD-style.
40 * Signed-off-by: Larry Wall <larry@wall.org>
41 * Signed-off-by: Kamil Rytarowski <kamil@netbsd.org>
43 * Revision 7.0.1.3 86/12/12 17:07:44 lwall
44 * Baseline for net release.
46 * Revision 7.0.1.2 86/10/20 12:08:00 lwall
47 * Made all exits reset tty.
49 * Revision 7.0.1.1 86/10/16 10:54:13 lwall
50 * Added Damage. Fixed random bugs.
52 * Revision 7.0 86/10/08 15:14:47 lwall
53 * Split into separate files. Added amoebas and pirates.
55 * Revision 6.4 83/12/16 13:11:45 lwall
56 * Handled 15 bit random number generators.
58 * Fixed array overflow bug on multiple zaps.
60 * Multiple zaps now consolidated to minimize output.
62 * Tholian jackpot games outlawed under difficulty 15.
64 * Revision 6.3 83/08/24 11:17:49 lwall
65 * Fixed array overflow bug on multiple zap.
67 * Revision 6.2 83/08/23 18:06:37 lwall
69 * Warp -s should now work on dumb terminals
70 * Specifying difficulty >= 40 now just makes it a special game.
72 * No-delay read provided as alternative to FIONREAD.
73 * Warp won't report "-1 obsolete" when there are no Enterprises left.
74 * Some high-difficulty tuning.
76 * Revision 6.1 83/08/17 08:49:03 lwall
77 * Fixed obscure bug in storing UP that caused a %. in CM to occasionally
78 * foist garbage onto the screen.
80 * Revision 6.0 83/08/08 17:09:26 lwall
81 * New baseline version for net release.
83 * Revision 5.5 83/08/01 10:59:56 lwall
84 * Cloaking for the Enterprise.
85 * Difficulty now goes to 99, and many activities depending on difficulty
86 * have been adjusted in frequency.
87 * Simplified exit sequence, and reduced dependencies on control
88 * characters. You needn't see the scoreboard if you don't want to.
89 * Hitting i,w,c, or v switches to Enterprise. Hitting p switches to Base.
90 * Excessive use of q is not allowed.
91 * Excessive use of D is not allowed.
92 * Scoreboard may depend on either full name or login name.
93 * Integrated scoreboard lister. Login name now shows up on scoreboard.
94 * "Hidden" startup options are now upper case.
95 * Checks upon startup for no cursor movement, or screen too small.
96 * Checks upon startup that WARPDIR is correctly protected, and that warp
97 * is running setuid. As an additional bonus this prevents root from
98 * running warp, which mucks things up, UN*X be blessed.
99 * All gets's turned into fgets's for safety.
100 * Bonus Enterprises and Bases.
101 * Escalating bonuses for saving Base and Enterprise.
102 * Escalating Enterprise energy.
103 * Turbolasers decrease with distance.
104 * Really smart enemies can see through stars occasionally.
105 * Occasional Tholian jackpot waves. Tholians are a trifle nastier.
107 * An O or o can miss seeing you. Enemies can avoid a stationary O, o, or X.
108 * Warp 3 enemies and other nastinesses are possible in massacre mode.
109 * Enemies that decide to navigate when they see you can do other things than
110 * just come toward you.
111 * Gorns occasionally launch a salvo for the fun of it.
112 * Only star and enemy explosions can keep the round going now.
113 * Bounces don't always go back to starting spot now.
114 * Better full name processing. USG quirks handled. & substitution also
115 * handled now (whoever dreamed up that one must have been in the middle
116 * of the night before the morning after).
118 * Version number printer.
119 * Less signal catching during debugging.
121 * Revision 5.4 83/06/24 09:28:38 lwall
122 * 16 bit random number generators are now supported.
123 * Made warp not blow up on a null save file.
124 * Warp now prints E and B before the stars.
125 * Fixed bug which caused torp count to get decremented even when no torp
126 * was launched because of an obstacle.
127 * Put %<n>ld formats where appropriate.
128 * Fixed E: 0 0 bug on refresh.
130 * Revision 5.3 83/05/24 14:03:10 lwall
157 char tmp
, *s
, *tcbuf
;
167 printf("Recompile with RANDBITS = 15 or 16.\n");
171 for (i
=100; i
; i
--) {
175 printf("Recompile with RANDBITS = 15.\n");
181 #ifdef lint /* to suppress "defined but never used" */
183 (void)stop_catcher();
186 (void)cont_catcher();
190 while (--argc
> 0 && (*++argv
)[0] == '-')
191 for (s
= argv
[0]+1; *s
!= '\0'; s
++)
232 inumenemies
= atoi(s
);
240 inumfriends
= atoi(s
);
261 inumpirates
= atoi(s
);
295 experimenting
= TRUE
;
302 fprintf(stderr
,"warp: illegal option %c\n", *s
);
303 fprintf(stderr
, "Usage: warp -dn -b -x -v -s\n");
307 fprintf(stderr
, "Usage: warp -dn -b -x -v -s\n");
319 tcbuf
= malloc(1024);
322 if (chdir(warplib
) < 0)
323 fprintf(stderr
,nocd
,warplib
);
330 umask(022); /* mustn't rely on incoming umask--could be 033 which */
331 /* would disable people from running wscore */
339 mvaddstr(12,25,"*** restoring saved game ***");
346 for (keepgoing
= TRUE
;;) {
347 if (!experimenting
) {
348 if ((savfil
= fopen(savefilename
,"w")) == NULL
) {
350 printf("Can't open savefile\r\n");
354 "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n",
355 logname
, totalscore
, smarts
, cumsmarts
,
356 numents
, numbases
, wave
,
357 apolspec
? 'a' : ' ',
358 beginner
? 'b' : ' ',
359 crushspec
? 'c' : ' ',
360 gornspec
? 'g' : ' ',
361 massacre
? 'm' : ' ',
363 tholspec
? 't' : ' ',
364 lowspeed
? 'l' : ' ',
365 amoebaspec
? '&' : ' '
367 fprintf(savfil
," running on %s, process #%d\n",
372 lastscore
= totalscore
;
377 if (numents
<=0 && numbases
<=0)
379 if (!keepgoing
) break;
383 " [Hit space to continue, 'q' to quit] ");
387 "[Hit space to continue, 's' to save, 'q' to quit]");
393 if (tmp
== BREAKCH
|| tmp
== INTRCH
) {
399 if (tmp
== 'y' || tmp
== 'Y')
404 } while (tmp
!= INTRCH
&& tmp
!= BREAKCH
&& !index(" qQs",tmp
));
405 if (tmp
!= ' ' && tmp
!= 's') break;
406 if (!beginner
&& smarts
< 20)
408 else if (!beginner
&& smarts
< 35)
410 else if (smarts
< 99)
412 if (tmp
== 's') save_game();
416 } while (justonemoretime
);
419 unlink(savefilename
);