diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-08-19 07:42:28 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-08-19 07:42:28 +0000 |
commit | ed884b9fa4509c09f0f7ab71efe57a4e83a2e055 (patch) | |
tree | ef9d859a0754785b42ea5cacb27aff54b5000315 /games/trek | |
parent | f4fc9566a4d35c0cc2bf8c7f1136287d8eec8c44 (diff) |
tags, formatting, ANSI-fication, prototypes, de-typos, and the occasional
initialization, removal of unused variable, or other minor fix. Most
changes are from or inspired by NetBSD.
Diffstat (limited to 'games/trek')
53 files changed, 1014 insertions, 721 deletions
diff --git a/games/trek/Makefile b/games/trek/Makefile index f2748c55013..d4c1e917871 100644 --- a/games/trek/Makefile +++ b/games/trek/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 1997/09/21 11:37:09 deraadt Exp $ +# $OpenBSD: Makefile,v 1.3 1998/08/19 07:41:08 pjanzen Exp $ PROG= trek SRCS= abandon.c attack.c autover.c capture.c check_out.c checkcond.c \ @@ -6,9 +6,8 @@ SRCS= abandon.c attack.c autover.c capture.c check_out.c checkcond.c \ dock.c dumpgame.c dumpme.c dumpssradio.c events.c externs.c \ getcodi.c getpar.c help.c impulse.c initquad.c kill.c klmove.c \ lose.c lrscan.c main.c move.c nova.c out.c phaser.c play.c ram.c \ - ranf.c rest.c schedule.c score.c setup.c setwarp.c \ - shield.c snova.c srscan.c systemname.c torped.c utility.c \ - visual.c warp.c win.c cgetc.c + ranf.c rest.c schedule.c score.c setup.c setwarp.c shield.c \ + snova.c srscan.c systemname.c torped.c visual.c warp.c win.c cgetc.c MAN= trek.6 DPADD= ${LIBM} LDADD= -lm diff --git a/games/trek/abandon.c b/games/trek/abandon.c index b33d0f084f5..48f36a88ce4 100644 --- a/games/trek/abandon.c +++ b/games/trek/abandon.c @@ -1,3 +1,4 @@ +/* $OpenBSD: abandon.c,v 1.2 1998/08/19 07:41:09 pjanzen Exp $ */ /* $NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $"; +static char rcsid[] = "$OpenBSD: abandon.c,v 1.2 1998/08/19 07:41:09 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Abandon Ship @@ -68,7 +70,9 @@ static char rcsid[] = "$NetBSD: abandon.c,v 1.3 1995/04/22 10:58:24 cgd Exp $"; ** Uses trace flag 40 */ -abandon() +void +abandon(v) + int v; { register struct quad *q; register int i; @@ -76,11 +80,17 @@ abandon() register struct event *e; if (Ship.ship == QUEENE) - return (printf("You may not abandon ye Faire Queene\n")); + { + printf("You may not abandon ye Faire Queene\n"); + return; + } if (Ship.cond != DOCKED) { if (damaged(SHUTTLE)) - return (out(SHUTTLE)); + { + out(SHUTTLE); + return; + } printf("Officers escape in shuttlecraft\n"); /* decide on fate of crew */ q = &Quad[Ship.quadx][Ship.quady]; @@ -154,7 +164,7 @@ abandon() if (Sect[Ship.sectx][Ship.secty] == EMPTY) { Sect[Ship.sectx][Ship.secty] = QUEENE; - dock(); + dock(0); compkldist(0); return; } diff --git a/games/trek/attack.c b/games/trek/attack.c index b1b0abb64ff..0bfb0d3b92e 100644 --- a/games/trek/attack.c +++ b/games/trek/attack.c @@ -1,3 +1,4 @@ +/* $OpenBSD: attack.c,v 1.2 1998/08/19 07:41:10 pjanzen Exp $ */ /* $NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $"; +static char rcsid[] = "$OpenBSD: attack.c,v 1.2 1998/08/19 07:41:10 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include "trek.h" /* ** Klingon Attack Routine @@ -73,15 +76,16 @@ static char rcsid[] = "$NetBSD: attack.c,v 1.3 1995/04/22 10:58:26 cgd Exp $"; ** Casualties can also occur. */ +void attack(resting) -int resting; /* set if attack while resting */ + int resting; /* set if attack while resting */ { - register int hit, i, l; - int maxhit, tothit, shldabsb; - double chgfac, propor, extradm; - double dustfac, tothe; - int cas; - int hitflag; + register int hit, i, l; + int maxhit, tothit, shldabsb; + double chgfac, propor, extradm; + double dustfac, tothe; + int cas; + int hitflag; if (Move.free) return; @@ -189,6 +193,4 @@ int resting; /* set if attack while resting */ /* allow Klingons to move after attacking */ klmove(1); - - return; } diff --git a/games/trek/autover.c b/games/trek/autover.c index 96a78373ac7..0935ec71640 100644 --- a/games/trek/autover.c +++ b/games/trek/autover.c @@ -1,3 +1,4 @@ +/* $OpenBSD: autover.c,v 1.2 1998/08/19 07:41:12 pjanzen Exp $ */ /* $NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)autover.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $"; +static char rcsid[] = "$OpenBSD: autover.c,v 1.2 1998/08/19 07:41:12 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Automatic Override @@ -61,6 +63,7 @@ static char rcsid[] = "$NetBSD: autover.c,v 1.3 1995/04/22 10:58:28 cgd Exp $"; ** quadrants, since that is all that is needed. */ +void autover() { double dist; diff --git a/games/trek/capture.c b/games/trek/capture.c index d4849598e53..e062fc7ccc3 100644 --- a/games/trek/capture.c +++ b/games/trek/capture.c @@ -1,3 +1,4 @@ +/* $OpenBSD: capture.c,v 1.2 1998/08/19 07:41:13 pjanzen Exp $ */ /* $NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $"; +static char rcsid[] = "$OpenBSD: capture.c,v 1.2 1998/08/19 07:41:13 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Ask a Klingon To Surrender @@ -56,13 +58,13 @@ static char rcsid[] = "$NetBSD: capture.c,v 1.3 1995/04/22 10:58:32 cgd Exp $"; ** is a function of that Klingon's remaining power, our power, ** etc. */ - -capture() +void +capture(v) + int v; { register int i; register struct kling *k; double x; - extern struct kling *selectklingon(); /* check for not cloaked */ if (Ship.cloaked) @@ -71,7 +73,10 @@ capture() return; } if (damaged(SSRADIO)) - return (out(SSRADIO)); + { + out(SSRADIO); + return; + } /* find out if there are any at all */ if (Etc.nkling <= 0) { @@ -122,7 +127,8 @@ capture() ** Cruddy, just takes one at random. Should ask the captain. */ -struct kling *selectklingon() +struct kling * +selectklingon() { register int i; diff --git a/games/trek/cgetc.c b/games/trek/cgetc.c index 5a997bd3256..9e1f10ceaf8 100644 --- a/games/trek/cgetc.c +++ b/games/trek/cgetc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: cgetc.c,v 1.2 1998/08/19 07:41:15 pjanzen Exp $ */ /* $NetBSD: cgetc.c,v 1.3 1995/04/22 10:58:34 cgd Exp $ */ /* @@ -37,14 +38,15 @@ #if 0 static char sccsid[] = "@(#)cgetc.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: cgetc.c,v 1.3 1995/04/22 10:58:34 cgd Exp $"; +static char rcsid[] = "$OpenBSD: cgetc.c,v 1.2 1998/08/19 07:41:15 pjanzen Exp $"; #endif #endif /* not lint */ -# include <stdio.h> +#include <stdio.h> -char cgetc(i) -int i; +char +cgetc(i) + int i; { return ( getchar() ); } diff --git a/games/trek/check_out.c b/games/trek/check_out.c index 2ebdf45d61d..1ce3cf29902 100644 --- a/games/trek/check_out.c +++ b/games/trek/check_out.c @@ -1,3 +1,4 @@ +/* $OpenBSD: check_out.c,v 1.2 1998/08/19 07:41:16 pjanzen Exp $ */ /* $NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)check_out.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $"; +static char rcsid[] = "$OpenBSD: check_out.c,v 1.2 1998/08/19 07:41:16 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** CHECK IF A DEVICE IS OUT @@ -54,8 +56,9 @@ static char rcsid[] = "$NetBSD: check_out.c,v 1.3 1995/04/22 10:58:35 cgd Exp $" ** It prints appropriate messages too. */ +int check_out(device) -int device; + int device; { register int dev; diff --git a/games/trek/checkcond.c b/games/trek/checkcond.c index 3c565a142fc..cc3e0e296c7 100644 --- a/games/trek/checkcond.c +++ b/games/trek/checkcond.c @@ -1,3 +1,4 @@ +/* $OpenBSD: checkcond.c,v 1.2 1998/08/19 07:41:17 pjanzen Exp $ */ /* $NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $ */ /* @@ -37,11 +38,11 @@ #if 0 static char sccsid[] = "@(#)checkcond.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $"; +static char rcsid[] = "$OpenBSD: checkcond.c,v 1.2 1998/08/19 07:41:17 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include "trek.h" /* ** Check for Condition After a Move @@ -68,10 +69,9 @@ static char rcsid[] = "$NetBSD: checkcond.c,v 1.3 1995/04/22 10:58:37 cgd Exp $" ** and battle conditions. */ +void checkcond() { - register int i, j; - /* see if we are still alive and well */ if (Ship.reserves < 0.0) lose(L_NOLIFE); @@ -106,5 +106,4 @@ checkcond() return; } Ship.cond = GREEN; - return; } diff --git a/games/trek/compkl.c b/games/trek/compkl.c index 4aa0f056c5f..eac12ad0b6c 100644 --- a/games/trek/compkl.c +++ b/games/trek/compkl.c @@ -1,3 +1,4 @@ +/* $OpenBSD: compkl.c,v 1.2 1998/08/19 07:41:18 pjanzen Exp $ */ /* $NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)compkl.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $"; +static char rcsid[] = "$OpenBSD: compkl.c,v 1.2 1998/08/19 07:41:18 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <math.h> +#include "trek.h" /* ** compute klingon distances @@ -54,8 +56,11 @@ static char rcsid[] = "$NetBSD: compkl.c,v 1.3 1995/04/22 10:58:38 cgd Exp $"; ** move. */ +static void sortkl __P((void)); + +void compkldist(f) -int f; /* set if new quadrant */ + int f; /* set if new quadrant */ { register int i, dx, dy; double d; @@ -96,6 +101,7 @@ int f; /* set if new quadrant */ ** bubble sort on ascending distance */ +static void sortkl() { struct kling t; @@ -109,9 +115,9 @@ sortkl() for (i = 0; i < m; i++) if (Etc.klingon[i].dist > Etc.klingon[i+1].dist) { - bmove(&Etc.klingon[i], &t, sizeof t); - bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof t); - bmove(&t, &Etc.klingon[i+1], sizeof t); + t = Etc.klingon[i]; + Etc.klingon[i] = Etc.klingon[i + 1]; + Etc.klingon[i + 1] = t; f = 1; } } diff --git a/games/trek/computer.c b/games/trek/computer.c index dbf5e614291..c036a1f592f 100644 --- a/games/trek/computer.c +++ b/games/trek/computer.c @@ -1,3 +1,4 @@ +/* $OpenBSD: computer.c,v 1.2 1998/08/19 07:41:20 pjanzen Exp $ */ /* $NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $ */ /* @@ -37,13 +38,15 @@ #if 0 static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $"; +static char rcsid[] = "$OpenBSD: computer.c,v 1.2 1998/08/19 07:41:20 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" -# include <stdio.h> +#include <stdio.h> +#include <math.h> +#include "trek.h" +#include "getpar.h" + /* ** On-Board Computer ** @@ -92,23 +95,27 @@ static char rcsid[] = "$NetBSD: computer.c,v 1.4 1995/04/24 12:25:51 cgd Exp $"; struct cvntab Cputab[] = { - "ch", "art", (int (*)())1, 0, - "t", "rajectory", (int (*)())2, 0, - "c", "ourse", (int (*)())3, 0, - "m", "ove", (int (*)())3, 1, - "s", "core", (int (*)())4, 0, - "p", "heff", (int (*)())5, 0, - "w", "arpcost", (int (*)())6, 0, - "i", "mpcost", (int (*)())7, 0, - "d", "istresslist", (int (*)())8, 0, - 0 + { "ch", "art", (cmdfun)1, 0 }, + { "t", "rajectory", (cmdfun)2, 0 }, + { "c", "ourse", (cmdfun)3, 0 }, + { "m", "ove", (cmdfun)3, 1 }, + { "s", "core", (cmdfun)4, 0 }, + { "p", "heff", (cmdfun)5, 0 }, + { "w", "arpcost", (cmdfun)6, 0 }, + { "i", "mpcost", (cmdfun)7, 0 }, + { "d", "istresslist", (cmdfun)8, 0 }, + { NULL, NULL, NULL, 0 } }; -computer() +static int kalc __P((int, int, int, int, double *)); +static void prkalc __P((int, double)); + +void +computer(v) + int v; { int ix, iy; register int i, j; - int numout; int tqx, tqy; struct cvntab *r; int cost; @@ -146,10 +153,12 @@ computer() q = &Quad[i][j]; /* 1000 or 1001 is special case */ if (q->scanned >= 1000) + { if (q->scanned > 1000) printf(".1. "); else printf("/// "); + } else if (q->scanned < 0) printf("... "); @@ -311,12 +320,13 @@ computer() ** sqx,sqy/ssx,ssy to tqx,tqy/tsx,tsy. */ +static int kalc(tqx, tqy, tsx, tsy, dist) -int tqx; -int tqy; -int tsx; -int tsy; -double *dist; + int tqx; + int tqy; + int tsx; + int tsy; + double *dist; { double dx, dy; double quadsize; @@ -340,10 +350,10 @@ double *dist; return (course); } - +static void prkalc(course, dist) -int course; -double dist; + int course; + double dist; { printf(": course %d dist %.3f\n", course, dist); } diff --git a/games/trek/damage.c b/games/trek/damage.c index 35d05dbec87..e9981ddb0d5 100644 --- a/games/trek/damage.c +++ b/games/trek/damage.c @@ -1,3 +1,4 @@ +/* $OpenBSD: damage.c,v 1.2 1998/08/19 07:41:21 pjanzen Exp $ */ /* $NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $"; +static char rcsid[] = "$OpenBSD: damage.c,v 1.2 1998/08/19 07:41:21 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <err.h> +#include "trek.h" /* ** Schedule Ship.damages to a Device @@ -55,9 +58,10 @@ static char rcsid[] = "$NetBSD: damage.c,v 1.3 1995/04/22 10:58:40 cgd Exp $"; ** that the dock() and undock() have to reschedule the event. */ +void damage(dev1, dam) -int dev1; /* device index */ -double dam; /* time to repair */ + int dev1; /* device index */ + double dam; /* time to repair */ { register int i; register struct event *e; @@ -93,5 +97,5 @@ double dam; /* time to repair */ reschedule(e, e->date - Now.date + dam); return; } - syserr("Cannot find old damages %d\n", dev); + errx(1, "Cannot find old damages %d\n", dev); } diff --git a/games/trek/damaged.c b/games/trek/damaged.c index 004b2b05fd3..287264bca47 100644 --- a/games/trek/damaged.c +++ b/games/trek/damaged.c @@ -1,3 +1,4 @@ +/* $OpenBSD: damaged.c,v 1.2 1998/08/19 07:41:22 pjanzen Exp $ */ /* $NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $ */ /* @@ -37,11 +38,11 @@ #if 0 static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $"; +static char rcsid[] = "$OpenBSD: damaged.c,v 1.2 1998/08/19 07:41:22 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include "trek.h" /* DAMAGED -- check for device damaged ** @@ -50,8 +51,9 @@ static char rcsid[] = "$NetBSD: damaged.c,v 1.3 1995/04/22 10:58:41 cgd Exp $"; ** event list for a "device fix" action on that device. */ +int damaged(dev) -int dev; + int dev; { register int d; register struct event *e; diff --git a/games/trek/dcrept.c b/games/trek/dcrept.c index 0c6b55276ea..52cb3be46cb 100644 --- a/games/trek/dcrept.c +++ b/games/trek/dcrept.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dcrept.c,v 1.2 1998/08/19 07:41:23 pjanzen Exp $ */ /* $NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dcrept.c,v 1.2 1998/08/19 07:41:23 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** damage control report @@ -55,7 +57,9 @@ static char rcsid[] = "$NetBSD: dcrept.c,v 1.3 1995/04/22 10:58:43 cgd Exp $"; ** fix things if you are docked. */ -dcrept() +void +dcrept(v) + int v; { register int i, f; double x; diff --git a/games/trek/destruct.c b/games/trek/destruct.c index f4bee5c2feb..132d058b322 100644 --- a/games/trek/destruct.c +++ b/games/trek/destruct.c @@ -1,3 +1,4 @@ +/* $OpenBSD: destruct.c,v 1.2 1998/08/19 07:41:25 pjanzen Exp $ */ /* $NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $ */ /* @@ -37,11 +38,14 @@ #if 0 static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $"; +static char rcsid[] = "$OpenBSD: destruct.c,v 1.2 1998/08/19 07:41:25 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <unistd.h> +#include "trek.h" +#include "getpar.h" /* ** Self Destruct Sequence @@ -63,14 +67,19 @@ static char rcsid[] = "$NetBSD: destruct.c,v 1.3 1995/04/22 10:58:44 cgd Exp $"; ** Uses trace flag 41 */ -destruct() +void +destruct(v) + int v; { char checkpass[15]; register int i, j; double zap; if (damaged(COMPUTER)) - return (out(COMPUTER)); + { + out(COMPUTER); + return; + } printf("\n\07 --- WORKING ---\07\n"); sleep(3); /* output the count 10 9 8 7 6 */ @@ -85,8 +94,11 @@ destruct() skiptonl(0); getstrpar("Enter password verification", checkpass, 14, 0); sleep(2); - if (!sequal(checkpass, Game.passwd)) - return (printf("Self destruct sequence aborted\n")); + if (strcmp(checkpass, Game.passwd) != 0) + { + printf("Self destruct sequence aborted\n"); + return; + } printf("Password verified; self destruct sequence continues:\n"); sleep(2); /* output count 5 4 3 2 1 0 */ diff --git a/games/trek/dock.c b/games/trek/dock.c index 7dcc1f5215e..960dac72e8c 100644 --- a/games/trek/dock.c +++ b/games/trek/dock.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dock.c,v 1.2 1998/08/19 07:41:26 pjanzen Exp $ */ /* $NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dock.c,v 1.2 1998/08/19 07:41:26 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** DOCK TO STARBASE @@ -58,14 +60,19 @@ static char rcsid[] = "$NetBSD: dock.c,v 1.3 1995/04/22 10:58:45 cgd Exp $"; ** are docked. */ -dock() +void +dock(v) + int v; { register int i, j; int ok; register struct event *e; if (Ship.cond == DOCKED) - return (printf("Chekov: But captain, we are already docked\n")); + { + printf("Chekov: But captain, we are already docked\n"); + return; + } /* check for ok to dock, i.e., adjacent to a starbase */ ok = 0; for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) @@ -84,7 +91,10 @@ dock() } } if (!ok) - return (printf("Chekov: But captain, we are not adjacent to a starbase.\n")); + { + printf("Chekov: But captain, we are not adjacent to a starbase.\n"); + return; + } /* restore resources */ Ship.energy = Param.energy; @@ -114,7 +124,6 @@ dock() continue; reschedule(e, (e->date - Now.date) * Param.dockfac); } - return; } @@ -125,7 +134,9 @@ dock() ** is to reschedule any damages so that they will take longer. */ -undock() +void +undock(v) + int v; { register struct event *e; register int i; @@ -146,5 +157,4 @@ undock() continue; reschedule(e, (e->date - Now.date) / Param.dockfac); } - return; } diff --git a/games/trek/dumpgame.c b/games/trek/dumpgame.c index 17e7e7a19eb..c8344f31506 100644 --- a/games/trek/dumpgame.c +++ b/games/trek/dumpgame.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen Exp $ */ /* $NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $ */ /* @@ -37,11 +38,15 @@ #if 0 static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <err.h> +#include <unistd.h> +#include <fcntl.h> +#include "trek.h" /*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/ # define VERSION 2 @@ -55,18 +60,20 @@ struct dump struct dump Dump_template[] = { - (char *)&Ship, sizeof (Ship), - (char *)&Now, sizeof (Now), - (char *)&Param, sizeof (Param), - (char *)&Etc, sizeof (Etc), - (char *)&Game, sizeof (Game), - (char *)Sect, sizeof (Sect), - (char *)Quad, sizeof (Quad), - (char *)&Move, sizeof (Move), - (char *)Event, sizeof (Event), - 0 + { (char *)&Ship, sizeof (Ship) }, + { (char *)&Now, sizeof (Now) }, + { (char *)&Param, sizeof (Param) }, + { (char *)&Etc, sizeof (Etc) }, + { (char *)&Game, sizeof (Game) }, + { (char *)Sect, sizeof (Sect) }, + { (char *)Quad, sizeof (Quad) }, + { (char *)&Move, sizeof (Move) }, + { (char *)Event, sizeof (Event) }, + { NULL, 0 } }; +static int readdump __P((int)); + /* ** DUMP GAME ** @@ -77,7 +84,9 @@ struct dump Dump_template[] = ** output change. */ -dumpgame() +void +dumpgame(v) + int v; { int version; register int fd; @@ -85,7 +94,10 @@ dumpgame() register int i; if ((fd = creat("trek.dump", 0644)) < 0) - return (printf("cannot dump\n")); + { + warn("cannot open `trek.dump'"); + return; + } version = VERSION; write(fd, &version, sizeof version); @@ -112,6 +124,7 @@ dumpgame() ** Return value is zero for success, one for failure. */ +int restartgame() { register int fd; @@ -141,8 +154,9 @@ restartgame() ** Returns zero for success, one for failure. */ +static int readdump(fd1) -int fd1; + int fd1; { register int fd; register struct dump *d; diff --git a/games/trek/dumpme.c b/games/trek/dumpme.c index dfb38f0875e..3b2dc13b11d 100644 --- a/games/trek/dumpme.c +++ b/games/trek/dumpme.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dumpme.c,v 1.2 1998/08/19 07:41:30 pjanzen Exp $ */ /* $NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)dumpme.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dumpme.c,v 1.2 1998/08/19 07:41:30 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Dump the starship somewhere in the galaxy @@ -55,8 +57,9 @@ static char rcsid[] = "$NetBSD: dumpme.c,v 1.3 1995/04/22 10:58:48 cgd Exp $"; ** Repair of devices must be deferred. */ +void dumpme(flag) -int flag; + int flag; { register int f; double x; @@ -68,7 +71,7 @@ int flag; Ship.quady = ranf(NQUADS); Ship.sectx = ranf(NSECTS); Ship.secty = ranf(NSECTS); - x += 1.5 * franf(); + x = 1.5 * franf(); Move.time += x; if (f) { diff --git a/games/trek/dumpssradio.c b/games/trek/dumpssradio.c index c824312eff4..47022bb4137 100644 --- a/games/trek/dumpssradio.c +++ b/games/trek/dumpssradio.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dumpssradio.c,v 1.2 1998/08/19 07:41:31 pjanzen Exp $ */ /* $NetBSD: dumpssradio.c,v 1.3 1995/04/22 10:58:49 cgd Exp $ */ /* @@ -37,16 +38,18 @@ #if 0 static char sccsid[] = "@(#)dumpssradio.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dumpssradio.c,v 1.3 1995/04/22 10:58:49 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dumpssradio.c,v 1.2 1998/08/19 07:41:31 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /** ** output hidden distress calls **/ +int dumpssradio() { register struct event *e; @@ -64,7 +67,7 @@ dumpssradio() { unschedule(e); printf("Starsystem %s in quadrant %d,%d is no longer distressed\n", - systemname(e), e->x, e->y); + systemname(&Quad[e->x][e->y]), e->x, e->y); continue; } @@ -80,7 +83,7 @@ dumpssradio() case E_ENSLV: case E_REPRO: printf("Starsystem %s in quadrant %d,%d is distressed\n", - systemname(e), e->x, e->y); + systemname(&Quad[e->x][e->y]), e->x, e->y); chkrest++; break; diff --git a/games/trek/events.c b/games/trek/events.c index c150e10eebb..6faaf2bce9c 100644 --- a/games/trek/events.c +++ b/games/trek/events.c @@ -1,3 +1,4 @@ +/* $OpenBSD: events.c,v 1.2 1998/08/19 07:41:33 pjanzen Exp $ */ /* $NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $ */ /* @@ -37,11 +38,15 @@ #if 0 static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $"; +static char rcsid[] = "$OpenBSD: events.c,v 1.2 1998/08/19 07:41:33 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <string.h> +#include <math.h> +#include "getpar.h" +#include "trek.h" /* ** CAUSE TIME TO ELAPSE @@ -51,17 +56,18 @@ static char rcsid[] = "$NetBSD: events.c,v 1.3 1995/04/22 10:58:50 cgd Exp $"; ** and so on. */ - +int events(warp) -int warp; /* set if called in a time warp */ + int warp; /* set if called in a time warp */ { register int i; + char *p; int j; struct kling *k; double rtime; double xdate; double idate; - struct event *ev, *xsched(), *schedule(); + struct event *ev = NULL; int ix, iy; register struct quad *q; register struct event *e; @@ -138,7 +144,7 @@ int warp; /* set if called in a time warp */ case E_SNOVA: /* supernova */ /* cause the supernova to happen */ - snova(-1); + snova(-1, 0); /* and schedule the next one */ xresched(e, E_SNOVA, 1); break; @@ -389,10 +395,12 @@ int warp; /* set if called in a time warp */ case E_SNAP: /* take a snapshot of the galaxy */ xresched(e, E_SNAP, 1); - i = (int) Etc.snapshot; - i = bmove(Quad, i, sizeof (Quad)); - i = bmove(Event, i, sizeof (Event)); - i = bmove(&Now, i, sizeof (Now)); + p = (char *) Etc.snapshot; + memcpy(p, Quad, sizeof (Quad)); + p += sizeof (Quad); + memcpy(p, Event, sizeof (Event)); + p += sizeof (Event); + memcpy(p, &Now, sizeof (Now)); Game.snap = 1; break; @@ -447,7 +455,7 @@ int warp; /* set if called in a time warp */ } /* unschedule an attack during a rest period */ - if (e = Now.eventptr[E_ATTACK]) + if ((e = Now.eventptr[E_ATTACK])) unschedule(e); if (!warp) diff --git a/games/trek/externs.c b/games/trek/externs.c index c5a0f387e4d..731770e28c9 100644 --- a/games/trek/externs.c +++ b/games/trek/externs.c @@ -1,3 +1,4 @@ +/* $OpenBSD: externs.c,v 1.2 1998/08/19 07:41:34 pjanzen Exp $ */ /* $NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $ */ /* @@ -37,11 +38,11 @@ #if 0 static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $"; +static char rcsid[] = "$OpenBSD: externs.c,v 1.2 1998/08/19 07:41:34 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include "trek.h" /* ** global variable definitions @@ -49,22 +50,22 @@ static char rcsid[] = "$NetBSD: externs.c,v 1.3 1995/04/22 10:58:53 cgd Exp $"; struct device Device[NDEV] = { - "warp drive", "Scotty", - "S.R. scanners", "Scotty", - "L.R. scanners", "Scotty", - "phasers", "Sulu", - "photon tubes", "Sulu", - "impulse engines", "Scotty", - "shield control", "Sulu", - "computer", "Spock", - "subspace radio", "Uhura", - "life support", "Scotty", - "navigation system", "Chekov", - "cloaking device", "Scotty", - "transporter", "Scotty", - "shuttlecraft", "Scotty", - "*ERR 14*", "Nobody", - "*ERR 15*", "Nobody" + { "warp drive", "Scotty" }, + { "S.R. scanners", "Scotty" }, + { "L.R. scanners", "Scotty" }, + { "phasers", "Sulu" }, + { "photon tubes", "Sulu" }, + { "impulse engines", "Scotty" }, + { "shield control", "Sulu" }, + { "computer", "Spock" }, + { "subspace radio", "Uhura" }, + { "life support", "Scotty" }, + { "navigation system", "Chekov" }, + { "cloaking device", "Scotty" }, + { "transporter", "Scotty" }, + { "shuttlecraft", "Scotty" }, + { "*ERR 14*", "Nobody" }, + { "*ERR 15*", "Nobody" } }; char *Systemname[NINHAB] = diff --git a/games/trek/getcodi.c b/games/trek/getcodi.c index 3152addec4f..b1dc7bb3970 100644 --- a/games/trek/getcodi.c +++ b/games/trek/getcodi.c @@ -1,3 +1,4 @@ +/* $OpenBSD: getcodi.c,v 1.2 1998/08/19 07:41:35 pjanzen Exp $ */ /* $NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)getcodi.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $"; +static char rcsid[] = "$OpenBSD: getcodi.c,v 1.2 1998/08/19 07:41:35 pjanzen Exp $"; #endif #endif /* not lint */ -# include "getpar.h" +#include "getpar.h" +#include "trek.h" /* ** get course and distance @@ -53,11 +55,11 @@ static char rcsid[] = "$NetBSD: getcodi.c,v 1.3 1995/04/22 10:58:55 cgd Exp $"; ** (meaning to drop the request). */ +int getcodi(co, di) -int *co; -double *di; + int *co; + double *di; { - *co = getintpar("Course"); /* course must be in the interval [0, 360] */ diff --git a/games/trek/getpar.c b/games/trek/getpar.c index 77bfa360a9c..eedc05b6570 100644 --- a/games/trek/getpar.c +++ b/games/trek/getpar.c @@ -1,3 +1,4 @@ +/* $OpenBSD: getpar.c,v 1.2 1998/08/19 07:41:36 pjanzen Exp $ */ /* $NetBSD: getpar.c,v 1.4 1995/04/24 12:25:57 cgd Exp $ */ /* @@ -37,19 +38,24 @@ #if 0 static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: getpar.c,v 1.4 1995/04/24 12:25:57 cgd Exp $"; +static char rcsid[] = "$OpenBSD: getpar.c,v 1.2 1998/08/19 07:41:36 pjanzen Exp $"; #endif #endif /* not lint */ -# include <stdio.h> -# include "getpar.h" +#include <stdio.h> +#include <string.h> +#include "getpar.h" +#include "trek.h" + +static int testterm __P((void)); /** ** get integer parameter **/ +int getintpar(s) -char *s; + char *s; { register int i; int n; @@ -72,8 +78,9 @@ char *s; ** get floating parameter **/ -double getfltpar(s) -char *s; +double +getfltpar(s) + char *s; { register int i; double d; @@ -98,18 +105,19 @@ char *s; struct cvntab Yntab[] = { - "y", "es", (int (*)())1, 0, - "n", "o", (int (*)())0, 0, - 0 + { "y", "es", (cmdfun)1, 1 }, + { "n", "o", (cmdfun)0, 0 }, + { NULL, NULL, NULL, 0 } }; +int getynpar(s) -char *s; + char *s; { struct cvntab *r; r = getcodpar(s, Yntab); - return ((long) r->value); + return (r->value2); } @@ -117,9 +125,10 @@ char *s; ** get coded parameter **/ -struct cvntab *getcodpar(s, tab) -char *s; -struct cvntab tab[]; +struct cvntab * +getcodpar(s, tab) + char *s; + struct cvntab tab[]; { char input[100]; register struct cvntab *r; @@ -149,7 +158,8 @@ struct cvntab tab[]; c = 4; for (r = tab; r->abrev; r++) { - concat(r->abrev, r->full, input); + strcpy(input, r->abrev); + strcat(input, r->full); printf("%14.14s", input); if (--c > 0) continue; @@ -194,11 +204,12 @@ struct cvntab tab[]; ** get string parameter **/ +void getstrpar(s, r, l, t) -char *s; -char *r; -int l; -char *t; + char *s; + char *r; + int l; + char *t; { register int i; char format[20]; @@ -227,6 +238,7 @@ char *t; ** test if newline is next valid character **/ +int testnl() { register char c; @@ -248,8 +260,9 @@ testnl() ** scan for newline **/ +void skiptonl(c) -char c; + char c; { while (c != '\n') if (!(c = cgetc(0))) @@ -263,9 +276,10 @@ char c; ** test for valid terminator **/ +static int testterm() { - register char c; + char c; if (!(c = cgetc(0))) return (1); @@ -285,12 +299,13 @@ testterm() ** zero is returned. */ +int readdelim(d) -char d; + char d; { register char c; - while (c = cgetc(0)) + while ((c = cgetc(0))) { if (c == d) return (1); diff --git a/games/trek/getpar.h b/games/trek/getpar.h index f7ae0d8cffa..ce8cb129198 100644 --- a/games/trek/getpar.h +++ b/games/trek/getpar.h @@ -1,3 +1,4 @@ +/* $OpenBSD: getpar.h,v 1.2 1998/08/19 07:41:38 pjanzen Exp $ */ /* $NetBSD: getpar.h,v 1.3 1995/04/22 10:58:59 cgd Exp $ */ /* @@ -35,13 +36,23 @@ * @(#)getpar.h 8.1 (Berkeley) 5/31/93 */ +#include <sys/cdefs.h> + +typedef void (*cmdfun) __P((int)); + struct cvntab /* used for getcodpar() paramater list */ { char *abrev; char *full; - int (*value)(); + cmdfun value; int value2; }; -extern double getfltpar(); -extern struct cvntab *getcodpar(); +int getintpar __P((char *)); +double getfltpar __P((char *)); +int getynpar __P((char *)); +struct cvntab *getcodpar __P((char *, struct cvntab[])); +void getstrpar __P((char *, char *, int, char *)); +int testnl __P((void)); +void skiptonl __P((int)); +int readdelim __P((int)); diff --git a/games/trek/help.c b/games/trek/help.c index f718070ee94..fba6b90a84b 100644 --- a/games/trek/help.c +++ b/games/trek/help.c @@ -1,3 +1,4 @@ +/* $OpenBSD: help.c,v 1.2 1998/08/19 07:41:39 pjanzen Exp $ */ /* $NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $ */ /* @@ -37,11 +38,14 @@ #if 0 static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $"; +static char rcsid[] = "$OpenBSD: help.c,v 1.2 1998/08/19 07:41:39 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include <unistd.h> +#include "trek.h" /* ** call starbase for help @@ -66,22 +70,33 @@ static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/04/22 10:59:01 cgd Exp $"; char *Cntvect[3] = {"first", "second", "third"}; -help() +void +help(v) + int v; { register int i; double dist, x; - register int dx, dy; - int j, l; + register int dx = 0, dy = 0; + int j, l = 0; /* check to see if calling for help is reasonable ... */ if (Ship.cond == DOCKED) - return (printf("Uhura: But Captain, we're already docked\n")); + { + printf("Uhura: But Captain, we're already docked\n"); + return; + } /* or possible */ if (damaged(SSRADIO)) - return (out(SSRADIO)); + { + out(SSRADIO); + return; + } if (Now.bases <= 0) - return (printf("Uhura: I'm not getting any response from starbase\n")); + { + printf("Uhura: I'm not getting any response from starbase\n"); + return; + } /* tut tut, there goes the score */ Game.helps += 1; @@ -149,7 +164,7 @@ help() Ship.sectx = dx; Ship.secty = dy; Sect[dx][dy] = Ship.ship; - dock(); + dock(0); compkldist(0); return; } diff --git a/games/trek/impulse.c b/games/trek/impulse.c index c8f66e2ea34..d3a9118f1f1 100644 --- a/games/trek/impulse.c +++ b/games/trek/impulse.c @@ -1,3 +1,4 @@ +/* $OpenBSD: impulse.c,v 1.2 1998/08/19 07:41:40 pjanzen Exp $ */ /* $NetBSD: impulse.c,v 1.3 1995/04/22 10:59:03 cgd Exp $ */ /* @@ -37,28 +38,37 @@ #if 0 static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: impulse.c,v 1.3 1995/04/22 10:59:03 cgd Exp $"; +static char rcsid[] = "$OpenBSD: impulse.c,v 1.2 1998/08/19 07:41:40 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /** ** move under impulse power **/ -impulse() +void +impulse(v) + int v; { int course; register int power; double dist, time; register int percent; - extern double move(); if (Ship.cond == DOCKED) - return (printf("Scotty: Sorry captain, but we are still docked.\n")); + { + printf("Scotty: Sorry captain, but we are still docked.\n"); + return; + } if (damaged(IMPULSE)) - return (out(IMPULSE)); + { + out(IMPULSE); + return; + } if (getcodi(&course, &dist)) return; power = 20 + 100 * dist; diff --git a/games/trek/initquad.c b/games/trek/initquad.c index fd40ff05186..c6246609cf9 100644 --- a/games/trek/initquad.c +++ b/games/trek/initquad.c @@ -1,3 +1,4 @@ +/* $OpenBSD: initquad.c,v 1.2 1998/08/19 07:41:41 pjanzen Exp $ */ /* $NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)initquad.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $"; +static char rcsid[] = "$OpenBSD: initquad.c,v 1.2 1998/08/19 07:41:41 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Paramize Quadrant Upon Entering @@ -60,8 +62,9 @@ static char rcsid[] = "$NetBSD: initquad.c,v 1.3 1995/04/22 10:59:04 cgd Exp $"; ** to be docked, i.e., abandon() and help(). */ +void initquad(f) -int f; + int f; { register int i, j; int rx, ry; @@ -142,8 +145,9 @@ int f; } +void sector(x, y) -int *x, *y; + int *x, *y; { register int i, j; @@ -154,5 +158,4 @@ int *x, *y; } while (Sect[i][j] != EMPTY); *x = i; *y = j; - return; } diff --git a/games/trek/kill.c b/games/trek/kill.c index 9045339e9bd..9f5515d0f46 100644 --- a/games/trek/kill.c +++ b/games/trek/kill.c @@ -1,3 +1,4 @@ +/* $OpenBSD: kill.c,v 1.2 1998/08/19 07:41:43 pjanzen Exp $ */ /* $NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $"; +static char rcsid[] = "$OpenBSD: kill.c,v 1.2 1998/08/19 07:41:43 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** KILL KILL KILL !!! @@ -59,10 +61,11 @@ static char rcsid[] = "$NetBSD: kill.c,v 1.3 1995/04/22 10:59:06 cgd Exp $"; ** and the game is won if that was the last klingon. */ +void killk(ix, iy) -int ix, iy; + int ix, iy; { - register int i, j; + register int i; printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy); @@ -81,7 +84,7 @@ int ix, iy; /* purge him from the list */ Etc.nkling -= 1; for (; i < Etc.nkling; i++) - bmove(&Etc.klingon[i+1], &Etc.klingon[i], sizeof Etc.klingon[i]); + Etc.klingon[i] = Etc.klingon[i + 1]; break; } @@ -99,8 +102,9 @@ int ix, iy; ** handle a starbase's death */ +void killb(qx, qy) -int qx, qy; + int qx, qy; { register struct quad *q; register struct xy *b; @@ -110,23 +114,25 @@ int qx, qy; if (q->bases <= 0) return; if (!damaged(SSRADIO)) + { /* then update starchart */ if (q->scanned < 1000) q->scanned -= 10; else if (q->scanned > 1000) q->scanned = -1; + } q->bases = 0; Now.bases -= 1; for (b = Now.base; ; b++) if (qx == b->x && qy == b->y) break; - bmove(&Now.base[Now.bases], b, sizeof *b); + *b = Now.base[Now.bases]; if (qx == Ship.quadx && qy == Ship.quady) { Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY; if (Ship.cond == DOCKED) - undock(); + undock(0); printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y); } else @@ -146,14 +152,14 @@ int qx, qy; ** kill an inhabited starsystem **/ +void kills(x, y, f) -int x, y; /* quad coords if f == 0, else sector coords */ -int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */ + int x, y; /* quad coords if f == 0, else sector coords */ + int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */ { register struct quad *q; register struct event *e; register char *name; - char *systemname(); if (f) { @@ -190,9 +196,10 @@ int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */ ** "kill" a distress call **/ +void killd(x, y, f) -int x, y; /* quadrant coordinates */ -int f; /* set if user is to be informed */ + int x, y; /* quadrant coordinates */ + int f; /* set if user is to be informed */ { register struct event *e; register int i; diff --git a/games/trek/klmove.c b/games/trek/klmove.c index 060bcc74410..955d664ee9b 100644 --- a/games/trek/klmove.c +++ b/games/trek/klmove.c @@ -1,3 +1,4 @@ +/* $OpenBSD: klmove.c,v 1.2 1998/08/19 07:41:45 pjanzen Exp $ */ /* $NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $"; +static char rcsid[] = "$OpenBSD: klmove.c,v 1.2 1998/08/19 07:41:45 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Move Klingons Around @@ -66,6 +68,7 @@ static char rcsid[] = "$NetBSD: klmove.c,v 1.3 1995/04/22 10:59:07 cgd Exp $"; ** course around stars. */ +void klmove(fl) int fl; { @@ -84,7 +87,7 @@ int fl; if (Trace) printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling); # endif - for (n = 0; n < Etc.nkling; k && n++) + for (n = 0; n < Etc.nkling; n++) { k = &Etc.klingon[n]; i = 100; @@ -151,7 +154,7 @@ int fl; Sect[k->x][k->y] = EMPTY; Quad[qx][qy].klings += 1; Etc.nkling -= 1; - bmove(&Etc.klingon[Etc.nkling], k, sizeof *k); + *k = Etc.klingon[Etc.nkling]; Quad[Ship.quadx][Ship.quady].klings -= 1; k = 0; break; diff --git a/games/trek/lose.c b/games/trek/lose.c index ab9959d4435..98cf149f095 100644 --- a/games/trek/lose.c +++ b/games/trek/lose.c @@ -1,3 +1,4 @@ +/* $OpenBSD: lose.c,v 1.2 1998/08/19 07:41:46 pjanzen Exp $ */ /* $NetBSD: lose.c,v 1.3 1995/04/22 10:59:08 cgd Exp $ */ /* @@ -37,12 +38,15 @@ #if 0 static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: lose.c,v 1.3 1995/04/22 10:59:08 cgd Exp $"; +static char rcsid[] = "$OpenBSD: lose.c,v 1.2 1998/08/19 07:41:46 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include <setjmp.h> +#include <stdio.h> +#include <setjmp.h> +#include <unistd.h> +#include "trek.h" +#include "getpar.h" /* ** PRINT OUT LOSER MESSAGES @@ -69,8 +73,9 @@ char *Losemsg[] = "Your last crew member died", }; +void lose(why) -int why; + int why; { extern jmp_buf env; diff --git a/games/trek/lrscan.c b/games/trek/lrscan.c index 4d6e7d80c3c..635167c6d3c 100644 --- a/games/trek/lrscan.c +++ b/games/trek/lrscan.c @@ -1,3 +1,4 @@ +/* $OpenBSD: lrscan.c,v 1.2 1998/08/19 07:41:47 pjanzen Exp $ */ /* $NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $"; +static char rcsid[] = "$OpenBSD: lrscan.c,v 1.2 1998/08/19 07:41:47 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** LONG RANGE OF SCANNERS @@ -55,15 +57,15 @@ static char rcsid[] = "$NetBSD: lrscan.c,v 1.3 1995/04/22 10:59:09 cgd Exp $"; ** for future use by the "chart" option of the computer. */ -lrscan() +void +lrscan(v) + int v; { register int i, j; register struct quad *q; if (check_out(LRSCAN)) - { return; - } printf("Long range scan for quadrant %d,%d\n\n", Ship.quadx, Ship.quady); /* print the header on top */ @@ -109,5 +111,4 @@ lrscan() } } printf("\n -------------------\n"); - return; } diff --git a/games/trek/main.c b/games/trek/main.c index d173430fe6e..cc80438a8b9 100644 --- a/games/trek/main.c +++ b/games/trek/main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: main.c,v 1.6 1998/08/19 07:41:49 pjanzen Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */ /* @@ -43,14 +44,19 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.6 1998/08/19 07:41:49 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include <stdio.h> -# include <setjmp.h> -# include <termios.h> +#include <sys/types.h> +#include <stdio.h> +#include <setjmp.h> +#include <termios.h> +#include <stdlib.h> +#include <unistd.h> +#include <err.h> +#include "trek.h" +#include "getpar.h" # define PRIO 00 /* default priority */ @@ -157,10 +163,10 @@ jmp_buf env; int main(argc, argv) -int argc; -char **argv; + int argc; + char **argv; { - time_t vect; + time_t curtime; /* extern FILE *f_log; */ register char opencode; int prio; @@ -175,8 +181,8 @@ char **argv; av = argv; ac = argc; av++; - time(&vect); - srand(vect); + time(&curtime); + srandom((long)curtime); opencode = 'w'; prio = PRIO; @@ -225,7 +231,7 @@ char **argv; av++; } if (ac > 2) - syserr(0, "arg count"); + errx(1, "arg count"); /* if (ac > 1) f_log = fopen(av[0], opencode); @@ -245,4 +251,5 @@ char **argv; } while (getynpar("Another game")); fflush(stdout); + return 0; } diff --git a/games/trek/move.c b/games/trek/move.c index b20faf218b8..2a0ac6e1466 100644 --- a/games/trek/move.c +++ b/games/trek/move.c @@ -1,3 +1,4 @@ +/* $OpenBSD: move.c,v 1.2 1998/08/19 07:41:50 pjanzen Exp $ */ /* $NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $"; +static char rcsid[] = "$OpenBSD: move.c,v 1.2 1998/08/19 07:41:50 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include "trek.h" /* ** Move Under Warp or Impulse Power @@ -78,15 +81,16 @@ static char rcsid[] = "$NetBSD: move.c,v 1.3 1995/04/22 10:59:12 cgd Exp $"; ** Uses trace flag 4. */ -double move(ramflag, course, time, speed) -int ramflag; -int course; -double time; -double speed; +double +move(ramflag, course, time, speed) + int ramflag; + int course; + double time; + double speed; { double angle; double x, y, dx, dy; - register int ix, iy; + register int ix = 0, iy = 0; double bigger; int n; register int i; @@ -122,7 +126,7 @@ double speed; evtime = Now.eventptr[E_LRTB]->date - Now.date; # ifdef xTRACE if (Trace) - printf("E.ep = %u, ->evcode = %d, ->date = %.2f, evtime = %.2f\n", + printf("E.ep = %p, ->evcode = %d, ->date = %.2f, evtime = %.2f\n", Now.eventptr[E_LRTB], Now.eventptr[E_LRTB]->evcode, Now.eventptr[E_LRTB]->date, evtime); # endif @@ -184,12 +188,12 @@ double speed; Ship.sectx = ix % NSECTS; Ship.secty = iy % NSECTS; if (ix < 0 || Ship.quadx >= NQUADS || iy < 0 || Ship.quady >= NQUADS) + { if (!damaged(COMPUTER)) - { dumpme(0); - } else lose(L_NEGENB); + } initquad(0); n = 0; break; diff --git a/games/trek/nova.c b/games/trek/nova.c index 7c02a70eb4b..1def930561e 100644 --- a/games/trek/nova.c +++ b/games/trek/nova.c @@ -1,3 +1,4 @@ +/* $OpenBSD: nova.c,v 1.2 1998/08/19 07:41:51 pjanzen Exp $ */ /* $NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $ */ /* @@ -37,11 +38,12 @@ #if 0 static char sccsid[] = "@(#)nova.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $"; +static char rcsid[] = "$OpenBSD: nova.c,v 1.2 1998/08/19 07:41:51 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** CAUSE A NOVA TO OCCUR @@ -57,8 +59,9 @@ static char rcsid[] = "$NetBSD: nova.c,v 1.3 1995/04/22 10:59:14 cgd Exp $"; ** If the zap is too much, it gets destroyed. */ +void nova(x, y) -int x, y; + int x, y; { register int i, j; register int se; @@ -71,7 +74,10 @@ int x, y; return; } if (ranf(100) < 5) - return (snova(x, y)); + { + snova(x, y); + return; + } printf("Spock: Star at %d,%d gone nova\n", x, y); if (ranf(4) != 0) @@ -120,6 +126,7 @@ int x, y; case QUEENE: se = 2000; if (Ship.shldup) + { if (Ship.shield >= se) { Ship.shield -= se; @@ -130,6 +137,7 @@ int x, y; se -= Ship.shield; Ship.shield = 0; } + } Ship.energy -= se; if (Ship.energy <= 0) lose(L_SUICID); @@ -143,5 +151,4 @@ int x, y; } } } - return; } diff --git a/games/trek/out.c b/games/trek/out.c index ccd78cbb282..b14bb0374e5 100644 --- a/games/trek/out.c +++ b/games/trek/out.c @@ -1,3 +1,4 @@ +/* $OpenBSD: out.c,v 1.2 1998/08/19 07:41:52 pjanzen Exp $ */ /* $NetBSD: out.c,v 1.3 1995/04/22 10:59:16 cgd Exp $ */ /* @@ -37,24 +38,26 @@ #if 0 static char sccsid[] = "@(#)out.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: out.c,v 1.3 1995/04/22 10:59:16 cgd Exp $"; +static char rcsid[] = "$OpenBSD: out.c,v 1.2 1998/08/19 07:41:52 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" /* ** Announce Device Out */ +void out(dev) -int dev; + int dev; { register struct device *d; d = &Device[dev]; printf("%s reports %s ", d->person, d->name); - if (d->name[length(d->name) - 1] == 's') + if (d->name[strlen(d->name) - 1] == 's') printf("are"); else printf("is"); diff --git a/games/trek/phaser.c b/games/trek/phaser.c index 24b713a33da..e10b28661ef 100644 --- a/games/trek/phaser.c +++ b/games/trek/phaser.c @@ -1,3 +1,4 @@ +/* $OpenBSD: phaser.c,v 1.2 1998/08/19 07:41:54 pjanzen Exp $ */ /* $NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $ */ /* @@ -37,12 +38,14 @@ #if 0 static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $"; +static char rcsid[] = "$OpenBSD: phaser.c,v 1.2 1998/08/19 07:41:54 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include <math.h> +#include "trek.h" +#include "getpar.h" /* factors for phaser hits; see description below */ @@ -79,9 +82,9 @@ static char rcsid[] = "$NetBSD: phaser.c,v 1.4 1995/04/24 12:26:02 cgd Exp $"; struct cvntab Matab[] = { - "m", "anual", (int (*)())1, 0, - "a", "utomatic", 0, 0, - 0 + { "m", "anual", (cmdfun)1, 0 }, + { "a", "utomatic", (cmdfun)0, 0 }, + { NULL, NULL, NULL, 0 } }; struct banks @@ -92,8 +95,9 @@ struct banks }; - -phaser() +void +phaser(v) + int v; { register int i; int j; @@ -110,11 +114,20 @@ phaser() struct cvntab *ptr; if (Ship.cond == DOCKED) - return(printf("Phasers cannot fire through starbase shields\n")); + { + printf("Phasers cannot fire through starbase shields\n"); + return; + } if (damaged(PHASER)) - return (out(PHASER)); + { + out(PHASER); + return; + } if (Ship.shldup) - return (printf("Sulu: Captain, we cannot fire through shields.\n")); + { + printf("Sulu: Captain, we cannot fire through shields.\n"); + return; + } if (Ship.cloaked) { printf("Sulu: Captain, surely you must realize that we cannot fire\n"); @@ -199,7 +212,10 @@ phaser() { /* automatic distribution of power */ if (Etc.nkling <= 0) - return (printf("Sulu: But there are no Klingons in this quadrant\n")); + { + printf("Sulu: But there are no Klingons in this quadrant\n"); + return; + } printf("Phasers locked on target. "); while (flag) { diff --git a/games/trek/play.c b/games/trek/play.c index c2815437e61..4996d495a78 100644 --- a/games/trek/play.c +++ b/games/trek/play.c @@ -1,3 +1,4 @@ +/* $OpenBSD: play.c,v 1.2 1998/08/19 07:41:55 pjanzen Exp $ */ /* $NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $ */ /* @@ -37,13 +38,14 @@ #if 0 static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $"; +static char rcsid[] = "$OpenBSD: play.c,v 1.2 1998/08/19 07:41:55 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" -# include <setjmp.h> +#include <stdio.h> +#include <setjmp.h> +#include "trek.h" +#include "getpar.h" /* ** INSTRUCTION READ AND MAIN PLAY LOOP @@ -55,46 +57,45 @@ static char rcsid[] = "$NetBSD: play.c,v 1.3 1995/04/22 10:59:18 cgd Exp $"; ** attack if the move was not free, and checkcond() to check up ** on how we are doing after the move. */ -extern int abandon(), capture(), shield(), computer(), dcrept(), - destruct(), dock(), help(), impulse(), lrscan(), - warp(), dumpgame(), rest(), srscan(), - myreset(), torped(), visual(), setwarp(), undock(), phaser(); struct cvntab Comtab[] = { - "abandon", "", abandon, 0, - "ca", "pture", capture, 0, - "cl", "oak", shield, -1, - "c", "omputer", computer, 0, - "da", "mages", dcrept, 0, - "destruct", "", destruct, 0, - "do", "ck", dock, 0, - "help", "", help, 0, - "i", "mpulse", impulse, 0, - "l", "rscan", lrscan, 0, - "m", "ove", warp, 0, - "p", "hasers", phaser, 0, - "ram", "", warp, 1, - "dump", "", dumpgame, 0, - "r", "est", rest, 0, - "sh", "ield", shield, 0, - "s", "rscan", srscan, 0, - "st", "atus", srscan, -1, - "terminate", "", myreset, 0, - "t", "orpedo", torped, 0, - "u", "ndock", undock, 0, - "v", "isual", visual, 0, - "w", "arp", setwarp, 0, - 0 + { "abandon", "", abandon, 0 }, + { "ca", "pture", capture, 0 }, + { "cl", "oak", shield, -1 }, + { "c", "omputer", computer, 0 }, + { "da", "mages", dcrept, 0 }, + { "destruct", "", destruct, 0 }, + { "do", "ck", dock, 0 }, + { "help", "", help, 0 }, + { "i", "mpulse", impulse, 0 }, + { "l", "rscan", lrscan, 0 }, + { "m", "ove", dowarp, 0 }, + { "p", "hasers", phaser, 0 }, + { "ram", "", dowarp, 1 }, + { "dump", "", dumpgame, 0 }, + { "r", "est", rest, 0 }, + { "sh", "ield", shield, 0 }, + { "s", "rscan", srscan, 0 }, + { "st", "atus", srscan, -1 }, + { "terminate", "", myreset, 0 }, + { "t", "orpedo", torped, 0 }, + { "u", "ndock", undock, 0 }, + { "v", "isual", visual, 0 }, + { "w", "arp", setwarp, 0 }, + { NULL, NULL, NULL, 0 } }; -myreset() +void +myreset(v) + int v; { extern jmp_buf env; longjmp(env, 1); } +void play() { struct cvntab *r; diff --git a/games/trek/ram.c b/games/trek/ram.c index 9d28e444565..9f24fe75708 100644 --- a/games/trek/ram.c +++ b/games/trek/ram.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ram.c,v 1.2 1998/08/19 07:41:56 pjanzen Exp $ */ /* $NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)ram.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $"; +static char rcsid[] = "$OpenBSD: ram.c,v 1.2 1998/08/19 07:41:56 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <unistd.h> +#include "trek.h" /* ** RAM SOME OBJECT @@ -54,8 +57,9 @@ static char rcsid[] = "$NetBSD: ram.c,v 1.3 1995/04/22 10:59:19 cgd Exp $"; ** also rack up incredible damages. */ +void ram(ix, iy) -int ix, iy; + int ix, iy; { register int i; register char c; diff --git a/games/trek/ranf.c b/games/trek/ranf.c index 2229ca594e0..89a4d18bc3f 100644 --- a/games/trek/ranf.c +++ b/games/trek/ranf.c @@ -1,3 +1,4 @@ +/* $OpenBSD: ranf.c,v 1.2 1998/08/19 07:41:58 pjanzen Exp $ */ /* $NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $ */ /* @@ -37,27 +38,30 @@ #if 0 static char sccsid[] = "@(#)ranf.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $"; +static char rcsid[] = "$OpenBSD: ranf.c,v 1.2 1998/08/19 07:41:58 pjanzen Exp $"; #endif #endif /* not lint */ -# include <stdio.h> +#include <stdio.h> +#include <stdlib.h> +int ranf(max) -int max; + int max; { register int t; if (max <= 0) return (0); - t = rand() >> 5; + t = random() >> 5; return (t % max); } -double franf() +double +franf() { double t; - t = rand() & 077777; + t = random() & 077777; return (t / 32767.0); } diff --git a/games/trek/rest.c b/games/trek/rest.c index 6575a325f6a..65837866283 100644 --- a/games/trek/rest.c +++ b/games/trek/rest.c @@ -1,3 +1,4 @@ +/* $OpenBSD: rest.c,v 1.2 1998/08/19 07:41:59 pjanzen Exp $ */ /* $NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $ */ /* @@ -37,12 +38,13 @@ #if 0 static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $"; +static char rcsid[] = "$OpenBSD: rest.c,v 1.2 1998/08/19 07:41:59 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** REST FOR REPAIRS @@ -58,7 +60,9 @@ static char rcsid[] = "$NetBSD: rest.c,v 1.3 1995/04/22 10:59:22 cgd Exp $"; ** rest period if anything momentous happens. */ -rest() +void +rest(v) + int v; { double t; register int percent; diff --git a/games/trek/schedule.c b/games/trek/schedule.c index 41b20628b6d..a0d26da1a3b 100644 --- a/games/trek/schedule.c +++ b/games/trek/schedule.c @@ -1,3 +1,4 @@ +/* $OpenBSD: schedule.c,v 1.2 1998/08/19 07:42:01 pjanzen Exp $ */ /* $NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $ */ /* @@ -37,11 +38,14 @@ #if 0 static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $"; +static char rcsid[] = "$OpenBSD: schedule.c,v 1.2 1998/08/19 07:42:01 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include <err.h> +#include "trek.h" /* ** SCHEDULE AN EVENT @@ -53,11 +57,12 @@ static char rcsid[] = "$NetBSD: schedule.c,v 1.3 1995/04/22 10:59:23 cgd Exp $"; ** The address of the slot is returned. */ -struct event *schedule(type, offset, x, y, z) -int type; -double offset; -char x, y; -char z; +struct event * +schedule(type, offset, x, y, z) + int type; + double offset; + char x, y; + char z; { register struct event *e; register int i; @@ -83,7 +88,7 @@ char z; Now.eventptr[type] = e; return (e); } - syserr("Cannot schedule event %d parm %d %d %d", type, x, y, z); + errx(1, "Cannot schedule event %d parm %d %d %d", type, x, y, z); } @@ -94,9 +99,10 @@ char z; ** time plus 'offset'. */ +void reschedule(e1, offset) -struct event *e1; -double offset; + struct event *e1; + double offset; { double date; register struct event *e; @@ -120,8 +126,9 @@ double offset; ** The event at slot 'e' is deleted. */ +void unschedule(e1) -struct event *e1; + struct event *e1; { register struct event *e; @@ -146,10 +153,11 @@ struct event *e1; ** figure. */ -struct event *xsched(ev1, factor, x, y, z) -int ev1; -int factor; -int x, y, z; +struct event * +xsched(ev1, factor, x, y, z) + int ev1; + int factor; + int x, y, z; { register int ev; @@ -165,10 +173,11 @@ int x, y, z; ** division factor. Look at the code to see what really happens. */ +void xresched(e1, ev1, factor) -struct event *e1; -int ev1; -int factor; + struct event *e1; + int ev1; + int factor; { register int ev; register struct event *e; diff --git a/games/trek/score.c b/games/trek/score.c index f19f94a249a..797fc023b1b 100644 --- a/games/trek/score.c +++ b/games/trek/score.c @@ -1,3 +1,4 @@ +/* $OpenBSD: score.c,v 1.2 1998/08/19 07:42:02 pjanzen Exp $ */ /* $NetBSD: score.c,v 1.3 1995/04/22 10:59:24 cgd Exp $ */ /* @@ -37,24 +38,25 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: score.c,v 1.3 1995/04/22 10:59:24 cgd Exp $"; +static char rcsid[] = "$OpenBSD: score.c,v 1.2 1998/08/19 07:42:02 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** PRINT OUT THE CURRENT SCORE */ -long score() +long +score() { - register int u; - register int t; - long s; - double r; - extern struct cvntab Skitab[]; + register int u; + register int t; + long s; + double r; printf("\n*** Your score:\n"); s = t = Param.klingpwr / 4 * (u = Game.killk); diff --git a/games/trek/setup.c b/games/trek/setup.c index ce75202685c..9da38ac9396 100644 --- a/games/trek/setup.c +++ b/games/trek/setup.c @@ -1,3 +1,4 @@ +/* $OpenBSD: setup.c,v 1.2 1998/08/19 07:42:03 pjanzen Exp $ */ /* $NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $ */ /* @@ -37,12 +38,17 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $"; +static char rcsid[] = "$OpenBSD: setup.c,v 1.2 1998/08/19 07:42:03 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include <math.h> +#include <unistd.h> +#include <stdlib.h> +#include <err.h> +#include "trek.h" +#include "getpar.h" /* ** INITIALIZE THE GAME @@ -57,31 +63,31 @@ static char rcsid[] = "$NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $"; struct cvntab Lentab[] = { - "s", "hort", (int (*)())1, 0, - "m", "edium", (int (*)())2, 0, - "l", "ong", (int (*)())4, 0, - "restart", "", 0, 0, - 0 + { "s", "hort", (cmdfun)1, 0 }, + { "m", "edium", (cmdfun)2, 0 }, + { "l", "ong", (cmdfun)4, 0 }, + { "restart", "", (cmdfun)0, 0 }, + { NULL, NULL, NULL, 0 } }; struct cvntab Skitab[] = { - "n", "ovice", (int (*)())1, 0, - "f", "air", (int (*)())2, 0, - "g", "ood", (int (*)())3, 0, - "e", "xpert", (int (*)())4, 0, - "c", "ommodore", (int (*)())5, 0, - "i", "mpossible", (int (*)())6, 0, - 0 + { "n", "ovice", (cmdfun)1, 0 }, + { "f", "air", (cmdfun)2, 0 }, + { "g", "ood", (cmdfun)3, 0 }, + { "e", "xpert", (cmdfun)4, 0 }, + { "c", "ommodore", (cmdfun)5, 0 }, + { "i", "mpossible", (cmdfun)6, 0 }, + { NULL, NULL, NULL, 0 } }; +void setup() { struct cvntab *r; register int i, j; double f; int d; - int fd; int klump; int ix, iy; register struct quad *q; @@ -103,7 +109,7 @@ setup() Game.skill = (long) r->value; Game.tourn = 0; getstrpar("Enter a password", Game.passwd, 14, 0); - if (sequal(Game.passwd, "tournament")) + if (strcmp(Game.passwd, "tournament") == 0) { getstrpar("Enter tournament code", Game.passwd, 14, 0); Game.tourn = 1; @@ -165,7 +171,7 @@ setup() for (i = j = 0; i < NDEV; i++) j += Param.damprob[i]; if (j != 1000) - syserr("Device probabilities sum to %d", j); + errx(1, "Device probabilities sum to %d", j); Param.dockfac = 0.5; Param.regenfac = (5 - Game.skill) * 0.05; if (Param.regenfac < 0.0) diff --git a/games/trek/setwarp.c b/games/trek/setwarp.c index 74939ae6cc2..f6dfa685182 100644 --- a/games/trek/setwarp.c +++ b/games/trek/setwarp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: setwarp.c,v 1.2 1998/08/19 07:42:05 pjanzen Exp $ */ /* $NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $ */ /* @@ -37,12 +38,13 @@ #if 0 static char sccsid[] = "@(#)setwarp.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $"; +static char rcsid[] = "$OpenBSD: setwarp.c,v 1.2 1998/08/19 07:42:05 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** SET WARP FACTOR @@ -51,7 +53,9 @@ static char rcsid[] = "$NetBSD: setwarp.c,v 1.3 1995/04/22 10:59:27 cgd Exp $"; ** checked for consistancy. */ -setwarp() +void +setwarp(v) + int v; { double warpfac; @@ -59,9 +63,15 @@ setwarp() if (warpfac < 0.0) return; if (warpfac < 1.0) - return (printf("Minimum warp speed is 1.0\n")); + { + printf("Minimum warp speed is 1.0\n"); + return; + } if (warpfac > 10.0) - return (printf("Maximum speed is warp 10.0\n")); + { + printf("Maximum speed is warp 10.0\n"); + return; + } if (warpfac > 6.0) printf("Damage to warp engines may occur above warp 6.0\n"); Ship.warp = warpfac; diff --git a/games/trek/shield.c b/games/trek/shield.c index a2345dc1d93..bf546858aff 100644 --- a/games/trek/shield.c +++ b/games/trek/shield.c @@ -1,3 +1,4 @@ +/* $OpenBSD: shield.c,v 1.2 1998/08/19 07:42:06 pjanzen Exp $ */ /* $NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $ */ /* @@ -37,12 +38,13 @@ #if 0 static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $"; +static char rcsid[] = "$OpenBSD: shield.c,v 1.2 1998/08/19 07:42:06 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** SHIELD AND CLOAKING DEVICE CONTROL @@ -63,21 +65,21 @@ static char rcsid[] = "$NetBSD: shield.c,v 1.4 1995/04/24 12:26:09 cgd Exp $"; struct cvntab Udtab[] = { - "u", "p", (int (*)())1, 0, - "d", "own", 0, 0, - 0 + { "u", "p", (cmdfun)1, 0 }, + { "d", "own", (cmdfun)0, 0 }, + { NULL, NULL, NULL, 0 } }; +void shield(f) -int f; + int f; { - register int i; - char c; - struct cvntab *r; - char s[100]; - char *device, *dev2, *dev3; - int ind; - char *stat; + register int i; + struct cvntab *r; + char s[100]; + char *device, *dev2, *dev3; + int ind; + char *stat; if (f > 0 && (Ship.shldup || damaged(SRSCAN))) return; @@ -85,7 +87,10 @@ int f; { /* cloaking device */ if (Ship.ship == QUEENE) - return (printf("Ye Faire Queene does not have the cloaking device.\n")); + { + printf("Ye Faire Queene does not have the cloaking device.\n"); + return; + } device = "Cloaking device"; dev2 = "is"; ind = CLOAK; @@ -137,13 +142,14 @@ int f; return; } if (i) + { if (f >= 0) Ship.energy -= Param.shupengy; else Ship.cloakgood = 0; + } Move.free = 0; if (f >= 0) Move.shldchg = 1; *stat = i; - return; } diff --git a/games/trek/snova.c b/games/trek/snova.c index 8ab14646752..283cbf5d94e 100644 --- a/games/trek/snova.c +++ b/games/trek/snova.c @@ -1,3 +1,4 @@ +/* $OpenBSD: snova.c,v 1.2 1998/08/19 07:42:07 pjanzen Exp $ */ /* $NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)snova.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $"; +static char rcsid[] = "$OpenBSD: snova.c,v 1.2 1998/08/19 07:42:07 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <unistd.h> +#include "trek.h" /* ** CAUSE SUPERNOVA TO OCCUR @@ -64,11 +67,12 @@ static char rcsid[] = "$NetBSD: snova.c,v 1.3 1995/04/22 10:59:29 cgd Exp $"; ** override mode. */ +void snova(x, y) -int x, y; + int x, y; { int qx, qy; - register int ix, iy; + register int ix, iy = 0; int f; int dx, dy; int n; @@ -146,12 +150,12 @@ int x, y; /* Enterprise caused supernova */ Game.kills += dy; if (q->bases) - killb(qx, qy, -1); + killb(qx, qy); Game.killk += dx; } else if (q->bases) - killb(qx, qy, 0); + killb(qx, qy); killd(qx, qy, (x >= 0)); q->stars = -1; q->klings = 0; @@ -160,5 +164,4 @@ int x, y; printf("Lucky devil, that supernova destroyed the last klingon\n"); win(); } - return; } diff --git a/games/trek/srscan.c b/games/trek/srscan.c index 6c287262757..2d02b00de47 100644 --- a/games/trek/srscan.c +++ b/games/trek/srscan.c @@ -1,3 +1,4 @@ +/* $OpenBSD: srscan.c,v 1.2 1998/08/19 07:42:08 pjanzen Exp $ */ /* $NetBSD: srscan.c,v 1.3 1995/04/22 10:59:31 cgd Exp $ */ /* @@ -37,12 +38,13 @@ #if 0 static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: srscan.c,v 1.3 1995/04/22 10:59:31 cgd Exp $"; +static char rcsid[] = "$OpenBSD: srscan.c,v 1.2 1998/08/19 07:42:08 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** SHORT RANGE SENSOR SCAN @@ -67,22 +69,19 @@ char *Color[4] = "RED" }; +void srscan(f) -int f; + int f; { - register int i, j; - register int statinfo; - char *s; - int percent; - struct quad *q; - extern struct cvntab Skitab[]; - extern struct cvntab Lentab[]; - struct cvntab *p; + register int i, j; + register int statinfo; + char *s; + int percent; + struct quad *q = NULL; + struct cvntab *p; if (f >= 0 && check_out(SRSCAN)) - { return; - } if (f) statinfo = 1; else diff --git a/games/trek/systemname.c b/games/trek/systemname.c index cb4efa49a85..a46b9c3bcca 100644 --- a/games/trek/systemname.c +++ b/games/trek/systemname.c @@ -1,3 +1,4 @@ +/* $OpenBSD: systemname.c,v 1.2 1998/08/19 07:42:10 pjanzen Exp $ */ /* $NetBSD: systemname.c,v 1.3 1995/04/22 10:59:32 cgd Exp $ */ /* @@ -37,11 +38,11 @@ #if 0 static char sccsid[] = "@(#)systemname.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: systemname.c,v 1.3 1995/04/22 10:59:32 cgd Exp $"; +static char rcsid[] = "$OpenBSD: systemname.c,v 1.2 1998/08/19 07:42:10 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include "trek.h" /* ** RETRIEVE THE STARSYSTEM NAME diff --git a/games/trek/torped.c b/games/trek/torped.c index dd11fe223e5..7eec2a78001 100644 --- a/games/trek/torped.c +++ b/games/trek/torped.c @@ -1,3 +1,4 @@ +/* $OpenBSD: torped.c,v 1.2 1998/08/19 07:42:11 pjanzen Exp $ */ /* $NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $ */ /* @@ -37,12 +38,16 @@ #if 0 static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $"; +static char rcsid[] = "$OpenBSD: torped.c,v 1.2 1998/08/19 07:42:11 pjanzen Exp $"; #endif #endif /* not lint */ -# include <stdio.h> -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include "trek.h" +#include "getpar.h" + +static int randcourse __P((int)); /* ** PHOTON TORPEDO CONTROL @@ -63,28 +68,31 @@ static char rcsid[] = "$NetBSD: torped.c,v 1.3 1995/04/22 10:59:34 cgd Exp $"; ** the misfire damages your torpedo tubes. */ - -torped() +void +torped(v) + int v; { - register int ix, iy; - double x, y, dx, dy; - double angle; - int course, course2; - register int k; - double bigger; - double sectsize; - int burst; - int n; + register int ix, iy; + double x, y, dx, dy; + double angle; + int course, course2; + register int k; + double bigger; + double sectsize; + int burst; + int n; if (Ship.cloaked) { - return (printf("Federation regulations do not permit attack while cloaked.\n")); + printf("Federation regulations do not permit attack while cloaked.\n"); + return; } if (check_out(TORPED)) return; if (Ship.torped <= 0) { - return (printf("All photon torpedos expended\n")); + printf("All photon torpedos expended\n"); + return; } /* get the course */ @@ -119,7 +127,10 @@ torped() if (burst <= 0) return; if (burst > 15) - return (printf("Maximum burst angle is 15 degrees\n")); + { + printf("Maximum burst angle is 15 degrees\n"); + return; + } } sectsize = NSECTS; n = -1; @@ -221,8 +232,9 @@ torped() ** to the tubes, etc. */ +static int randcourse(n) -int n; + int n; { double r; register int d; diff --git a/games/trek/trek.h b/games/trek/trek.h index 94dcac1bec9..08f9bea1067 100644 --- a/games/trek/trek.h +++ b/games/trek/trek.h @@ -1,3 +1,4 @@ +/* $OpenBSD: trek.h,v 1.3 1998/08/19 07:42:12 pjanzen Exp $ */ /* $NetBSD: trek.h,v 1.3 1995/04/22 10:59:36 cgd Exp $ */ /* @@ -35,6 +36,8 @@ * @(#)trek.h 8.1 (Berkeley) 5/31/93 */ +#include <sys/cdefs.h> + /* ** Global Declarations ** @@ -53,26 +56,16 @@ ** actually allocate stuff in "externs.c" */ -/* external function definitions */ -extern double franf(); /* floating random number function */ -extern double sqrt(); /* square root */ -extern double sin(), cos(); /* trig functions */ -extern double atan2(); /* fancy arc tangent function */ -extern double log(); /* log base e */ -extern double pow(); /* power function */ -extern double fabs(); /* absolute value function */ -extern double exp(); /* exponential function */ - /********************* GALAXY **************************/ /* galactic parameters */ -# define NSECTS 10 /* dimensions of quadrant in sectors */ -# define NQUADS 8 /* dimension of galazy in quadrants */ -# define NINHAB 32 /* number of quadrants which are inhabited */ +#define NSECTS 10 /* dimensions of quadrant in sectors */ +#define NQUADS 8 /* dimension of galazy in quadrants */ +#define NINHAB 32 /* number of quadrants which are inhabited */ struct quad /* definition for each quadrant */ { - char bases; /* number of bases in this quadrant */ + unsigned char bases; /* number of bases in this quadrant */ char klings; /* number of Klingons in this quadrant */ char holes; /* number of black holes in this quadrant */ int scanned; /* star chart entry (see below) */ @@ -80,8 +73,8 @@ struct quad /* definition for each quadrant */ char qsystemname; /* starsystem name (see below) */ }; -# define Q_DISTRESSED 0200 -# define Q_SYSTEM 077 +#define Q_DISTRESSED 0200 +#define Q_SYSTEM 077 /* systemname conventions: * 1 -> NINHAB index into Systemname table for live system. @@ -104,14 +97,14 @@ extern char *Systemname[NINHAB]; struct quad Quad[NQUADS][NQUADS]; /* defines for sector map (below) */ -# define EMPTY '.' -# define STAR '*' -# define BASE '#' -# define ENTERPRISE 'E' -# define QUEENE 'Q' -# define KLINGON 'K' -# define INHABIT '@' -# define HOLE ' ' +#define EMPTY '.' +#define STAR '*' +#define BASE '#' +#define ENTERPRISE 'E' +#define QUEENE 'Q' +#define KLINGON 'K' +#define INHABIT '@' +#define HOLE ' ' /* current sector map */ char Sect[NSECTS][NSECTS]; @@ -119,23 +112,23 @@ char Sect[NSECTS][NSECTS]; /************************ DEVICES ******************************/ -# define NDEV 16 /* max number of devices */ +#define NDEV 16 /* max number of devices */ /* device tokens */ -# define WARP 0 /* warp engines */ -# define SRSCAN 1 /* short range scanners */ -# define LRSCAN 2 /* long range scanners */ -# define PHASER 3 /* phaser control */ -# define TORPED 4 /* photon torpedo control */ -# define IMPULSE 5 /* impulse engines */ -# define SHIELD 6 /* shield control */ -# define COMPUTER 7 /* on board computer */ -# define SSRADIO 8 /* subspace radio */ -# define LIFESUP 9 /* life support systems */ -# define SINS 10 /* Space Inertial Navigation System */ -# define CLOAK 11 /* cloaking device */ -# define XPORTER 12 /* transporter */ -# define SHUTTLE 13 /* shuttlecraft */ +#define WARP 0 /* warp engines */ +#define SRSCAN 1 /* short range scanners */ +#define LRSCAN 2 /* long range scanners */ +#define PHASER 3 /* phaser control */ +#define TORPED 4 /* photon torpedo control */ +#define IMPULSE 5 /* impulse engines */ +#define SHIELD 6 /* shield control */ +#define COMPUTER 7 /* on board computer */ +#define SSRADIO 8 /* subspace radio */ +#define LIFESUP 9 /* life support systems */ +#define SINS 10 /* Space Inertial Navigation System */ +#define CLOAK 11 /* cloaking device */ +#define XPORTER 12 /* transporter */ +#define SHUTTLE 13 /* shuttlecraft */ /* device names */ struct device @@ -148,29 +141,29 @@ struct device Device[NDEV]; /*************************** EVENTS ****************************/ -# define NEVENTS 12 /* number of different event types */ +#define NEVENTS 12 /* number of different event types */ -# define E_LRTB 1 /* long range tractor beam */ -# define E_KATSB 2 /* Klingon attacks starbase */ -# define E_KDESB 3 /* Klingon destroys starbase */ -# define E_ISSUE 4 /* distress call is issued */ -# define E_ENSLV 5 /* Klingons enslave a quadrant */ -# define E_REPRO 6 /* a Klingon is reproduced */ -# define E_FIXDV 7 /* fix a device */ -# define E_ATTACK 8 /* Klingon attack during rest period */ -# define E_SNAP 9 /* take a snapshot for time warp */ -# define E_SNOVA 10 /* supernova occurs */ +#define E_LRTB 1 /* long range tractor beam */ +#define E_KATSB 2 /* Klingon attacks starbase */ +#define E_KDESB 3 /* Klingon destroys starbase */ +#define E_ISSUE 4 /* distress call is issued */ +#define E_ENSLV 5 /* Klingons enslave a quadrant */ +#define E_REPRO 6 /* a Klingon is reproduced */ +#define E_FIXDV 7 /* fix a device */ +#define E_ATTACK 8 /* Klingon attack during rest period */ +#define E_SNAP 9 /* take a snapshot for time warp */ +#define E_SNOVA 10 /* supernova occurs */ -# define E_GHOST 0100 /* ghost of a distress call if ssradio out */ -# define E_HIDDEN 0200 /* event that is unreportable because ssradio out */ -# define E_EVENT 077 /* mask to get event code */ +#define E_GHOST 0100 /* ghost of a distress call if ssradio out */ +#define E_HIDDEN 0200 /* event that is unreportable because ssradio out */ +#define E_EVENT 077 /* mask to get event code */ struct event { - char x, y; /* coordinates */ - double date; /* trap stardate */ - char evcode; /* event type */ - char systemname; /* starsystem name */ + unsigned char x, y; /* coordinates */ + double date; /* trap stardate */ + char evcode; /* event type */ + unsigned char systemname; /* starsystem name */ }; /* systemname conventions: * 1 -> NINHAB index into Systemname table for reported distress calls @@ -182,7 +175,7 @@ struct event * 0 unallocated */ -# define MAXEVENTS 25 /* max number of concurrently pending events */ +#define MAXEVENTS 25 /* max number of concurrently pending events */ struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ @@ -190,38 +183,41 @@ struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending even struct kling { - char x, y; /* coordinates */ + unsigned char x, y; /* coordinates */ int power; /* power left */ double dist; /* distance to Enterprise */ double avgdist; /* average over this move */ char srndreq; /* set if surrender has been requested */ }; -# define MAXKLQUAD 9 /* maximum klingons per quadrant */ +#define MAXKLQUAD 9 /* maximum klingons per quadrant */ /********************** MISCELLANEOUS ***************************/ /* condition codes */ -# define GREEN 0 -# define DOCKED 1 -# define YELLOW 2 -# define RED 3 +#define GREEN 0 +#define DOCKED 1 +#define YELLOW 2 +#define RED 3 /* starbase coordinates */ -# define MAXBASES 9 /* maximum number of starbases in galaxy */ +#define MAXBASES 9 /* maximum number of starbases in galaxy */ /* distress calls */ -# define MAXDISTR 5 /* maximum concurrent distress calls */ +#define MAXDISTR 5 /* maximum concurrent distress calls */ /* phaser banks */ -# define NBANKS 6 /* number of phaser banks */ +#define NBANKS 6 /* number of phaser banks */ struct xy { - char x, y; /* coordinates */ + unsigned char x, y; /* coordinates */ }; +extern struct cvntab Skitab[]; +extern struct cvntab Lentab[]; + /* * note that much of the stuff in the following structs CAN NOT * be moved around!!!! @@ -247,7 +243,7 @@ struct int quady; /* quadrant y coord */ int sectx; /* sector x coord */ int secty; /* sector y coord */ - char cond; /* condition code */ + unsigned char cond; /* condition code */ char sinsbad; /* Space Inertial Navigation System condition */ char *shipname; /* name of current starship */ char ship; /* current starship */ @@ -289,7 +285,7 @@ struct /* parametric information */ struct { - char bases; /* number of starbases */ + unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ double time; /* time left */ @@ -325,7 +321,7 @@ struct /* other information kept in a snapshot */ struct { - char bases; /* number of starbases */ + unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ double time; /* time left */ @@ -353,30 +349,184 @@ struct */ /* Klingon move indicies */ -# define KM_OB 0 /* Old quadrant, Before attack */ -# define KM_OA 1 /* Old quadrant, After attack */ -# define KM_EB 2 /* Enter quadrant, Before attack */ -# define KM_EA 3 /* Enter quadrant, After attack */ -# define KM_LB 4 /* Leave quadrant, Before attack */ -# define KM_LA 5 /* Leave quadrant, After attack */ +#define KM_OB 0 /* Old quadrant, Before attack */ +#define KM_OA 1 /* Old quadrant, After attack */ +#define KM_EB 2 /* Enter quadrant, Before attack */ +#define KM_EA 3 /* Enter quadrant, After attack */ +#define KM_LB 4 /* Leave quadrant, Before attack */ +#define KM_LA 5 /* Leave quadrant, After attack */ /* you lose codes */ -# define L_NOTIME 1 /* ran out of time */ -# define L_NOENGY 2 /* ran out of energy */ -# define L_DSTRYD 3 /* destroyed by a Klingon */ -# define L_NEGENB 4 /* ran into the negative energy barrier */ -# define L_SUICID 5 /* destroyed in a nova */ -# define L_SNOVA 6 /* destroyed in a supernova */ -# define L_NOLIFE 7 /* life support died (so did you) */ -# define L_NOHELP 8 /* you could not be rematerialized */ -# define L_TOOFAST 9 /* pretty stupid going at warp 10 */ -# define L_STAR 10 /* ran into a star */ -# define L_DSTRCT 11 /* self destructed */ -# define L_CAPTURED 12 /* captured by Klingons */ -# define L_NOCREW 13 /* you ran out of crew */ +#define L_NOTIME 1 /* ran out of time */ +#define L_NOENGY 2 /* ran out of energy */ +#define L_DSTRYD 3 /* destroyed by a Klingon */ +#define L_NEGENB 4 /* ran into the negative energy barrier */ +#define L_SUICID 5 /* destroyed in a nova */ +#define L_SNOVA 6 /* destroyed in a supernova */ +#define L_NOLIFE 7 /* life support died (so did you) */ +#define L_NOHELP 8 /* you could not be rematerialized */ +#define L_TOOFAST 9 /* pretty stupid going at warp 10 */ +#define L_STAR 10 /* ran into a star */ +#define L_DSTRCT 11 /* self destructed */ +#define L_CAPTURED 12 /* captured by Klingons */ +#define L_NOCREW 13 /* you ran out of crew */ /****************** COMPILE OPTIONS ***********************/ /* Trace info */ -# define xTRACE 1 +#define xTRACE 1 int Trace; + +/* abandon.c */ +void abandon __P((int)); + +/* attack.c */ +void attack __P((int)); + +/* autover.c */ +void autover __P((void)); + +/* capture.c */ +void capture __P((int)); +struct kling *selectklingon __P((void)); + +/* cgetc.c */ +char cgetc __P((int)); + +/* check_out.c */ +int check_out __P((int)); + +/* checkcond.c */ +void checkcond __P((void)); + +/* compkl.c */ +void compkldist __P((int)); + +/* computer.c */ +void computer __P((int)); + +/* damage.c */ +void damage __P((int, double)); + +/* damaged.c */ +int damaged __P((int)); + +/* dcrept.c */ +void dcrept __P((int)); + +/* destruct.c */ +void destruct __P((int)); + +/* dock.c */ +void dock __P((int)); +void undock __P((int)); + +/* dumpgame.c */ +void dumpgame __P((int)); +int restartgame __P((void)); + +/* dumpme.c */ +void dumpme __P((int)); + +/* dumpssradio.c */ +int dumpssradio __P((void)); + +/* events.c */ +int events __P((int)); + +/* externs.c */ + +/* getcodi.c */ +int getcodi __P((int *, double *)); + +/* help.c */ +void help __P((int)); + +/* impulse.c */ +void impulse __P((int)); + +/* initquad.c */ +void initquad __P((int)); +void sector __P((int *, int *)); + +/* kill.c */ +void killk __P((int, int )); +void killb __P((int, int )); +void kills __P((int, int , int)); +void killd __P((int, int , int)); + +/* klmove.c */ +void klmove __P((int)); + +/* lose.c */ +void lose __P((int)); + +/* lrscan.c */ +void lrscan __P((int)); + +/* move.c */ +double move __P((int, int, double, double)); + +/* nova.c */ +void nova __P((int, int )); + +/* out.c */ +void out __P((int)); + +/* phaser.c */ +void phaser __P((int)); + +/* play.c */ +void myreset __P((int)); +void play __P((void)); + +/* ram.c */ +void ram __P((int, int )); + +/* ranf.c */ +int ranf __P((int)); +double franf __P((void)); + +/* rest.c */ +void rest __P((int)); + +/* schedule.c */ +struct event *schedule __P((int, double, int, int , int)); +void reschedule __P((struct event *, double)); +void unschedule __P((struct event *)); +struct event *xsched __P((int, int, int, int , int )); +void xresched __P((struct event *, int, int)); + +/* score.c */ +long score __P((void)); + +/* setup.c */ +void setup __P((void)); + +/* setwarp.c */ +void setwarp __P((int)); + +/* shield.c */ +void shield __P((int)); + +/* snova.c */ +void snova __P((int, int )); + +/* srscan.c */ +void srscan __P((int)); + +/* systemname.c */ +char *systemname __P((struct quad *)); + +/* torped.c */ +void torped __P((int)); + +/* visual.c */ +void visual __P((int)); + +/* warp.c */ +void dowarp __P((int)); +void warp __P((int, int, double)); + +/* win.c */ +void win __P((void)); diff --git a/games/trek/utility.c b/games/trek/utility.c deleted file mode 100644 index cfd2f0a66ac..00000000000 --- a/games/trek/utility.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: utility.c,v 1.3 1995/04/22 10:59:37 cgd Exp $ */ - -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)utility.c 8.1 (Berkeley) 5/31/93"; -#else -static char rcsid[] = "$NetBSD: utility.c,v 1.3 1995/04/22 10:59:37 cgd Exp $"; -#endif -#endif /* not lint */ - -/* -** ASSORTED UTILITY ROUTINES -*/ - -/* -** BLOCK MOVE -** -** Moves a block of storage of length `l' bytes from the data -** area pointed to by `a' to the area pointed to by `b'. -** Returns the address of the byte following the `b' field. -** Overflow of `b' is not tested. -*/ - -char *bmove(a, b, l) -char *a, *b; -int l; -{ - register int n; - register char *p, *q; - - p = a; - q = b; - n = l; - while (n--) - *q++ = *p++; - return (q); -} - - -/* -** STRING EQUALITY TEST -** null-terminated strings `a' and `b' are tested for -** absolute equality. -** returns one if equal, zero otherwise. -*/ - -sequal(a, b) -char *a, *b; -{ - register char *p, *q; - - p = a; - q = b; - while (*p || *q) - if (*p++ != *q++) - return(0); - return(1); -} - - -/* -** STRING CONCATENATE -** -** The strings `s1' and `s2' are concatenated and stored into -** `s3'. It is ok for `s1' to equal `s3', but terrible things -** will happen if `s2' equals `s3'. The return value is is a -** pointer to the end of `s3' field. -*/ - -char *concat(s1, s2, s3) -char *s1, *s2, *s3; -{ - register char *p; - register char *q; - - p = s3; - q = s1; - while (*q) - *p++ = *q++; - q = s2; - while (*q) - *p++ = *q++; - *p = 0; - return (p); -} - - -/* -** FIND STRING LENGTH -** -** The length of string `s' (excluding the null byte which -** terminates the string) is returned. -*/ - -length(s) -char *s; -{ - register int l; - register char *p; - - l = 0; - p = s; - while (*p++) - l++; - return(l); -} - - -/* -** SYSTEM ERROR -*/ - -syserr(p0, p1, p2, p3, p4, p5) -{ - extern int errno; - - printf("\n\07TREK SYSERR: "); - printf(p0, p1, p2, p3, p4, p5); - printf("\n"); - if (errno) - printf("\tsystem error %d\n", errno); - exit(-1); -} diff --git a/games/trek/visual.c b/games/trek/visual.c index 9bde9220676..3a8a6797200 100644 --- a/games/trek/visual.c +++ b/games/trek/visual.c @@ -1,3 +1,4 @@ +/* $OpenBSD: visual.c,v 1.2 1998/08/19 07:42:15 pjanzen Exp $ */ /* $NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $ */ /* @@ -37,11 +38,13 @@ #if 0 static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $"; +static char rcsid[] = "$OpenBSD: visual.c,v 1.2 1998/08/19 07:42:15 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include "trek.h" +#include "getpar.h" /* ** VISUAL SCAN @@ -55,20 +58,22 @@ static char rcsid[] = "$NetBSD: visual.c,v 1.3 1995/04/22 10:59:39 cgd Exp $"; /* This struct[] has the delta x, delta y for particular directions */ struct xy Visdelta[11] = { - -1, -1, - -1, 0, - -1, 1, - 0, 1, - 1, 1, - 1, 0, - 1, -1, - 0, -1, - -1, -1, - -1, 0, - -1, 1 + { -1, -1 }, + { -1, 0 }, + { -1, 1 }, + { 0, 1 }, + { 1, 1 }, + { 1, 0 }, + { 1, -1 }, + { 0, -1 }, + { -1, -1 }, + { -1, 0 }, + { -1, 1 } }; -visual() +void +visual(z) + int z; { register int ix, iy; int co; diff --git a/games/trek/warp.c b/games/trek/warp.c index fa87589dda2..6a3637bd4c7 100644 --- a/games/trek/warp.c +++ b/games/trek/warp.c @@ -1,3 +1,4 @@ +/* $OpenBSD: warp.c,v 1.2 1998/08/19 07:42:16 pjanzen Exp $ */ /* $NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $ */ /* @@ -37,11 +38,16 @@ #if 0 static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $"; +static char rcsid[] = "$OpenBSD: warp.c,v 1.2 1998/08/19 07:42:16 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" +#include <stdio.h> +#include <math.h> +#include <string.h> +#include <unistd.h> +#include "trek.h" +#include "getpar.h" /* ** MOVE UNDER WARP POWER @@ -59,34 +65,46 @@ static char rcsid[] = "$NetBSD: warp.c,v 1.3 1995/04/22 10:59:40 cgd Exp $"; ** case, there is code to handle time warps, etc. */ +void +dowarp(fl) + int fl; +{ + int c; + double d; + + if (getcodi(&c, &d)) + return; + warp(fl, c, d); +} + +void warp(fl, c, d) -int fl, c; -double d; + int fl, c; + double d; { - int course; - double power; - double dist; - double time; - double speed; - double frac; - register int percent; - register int i; - extern double move(); + char *p; + int course; + double power; + double dist; + double time; + double speed; + double frac; + register int percent; + register int i; if (Ship.cond == DOCKED) - return (printf("%s is docked\n", Ship.shipname)); - if (damaged(WARP)) { - return (out(WARP)); + printf("%s is docked\n", Ship.shipname); + return; } - if (fl < 0) + if (damaged(WARP)) { - course = c; - dist = d; + out(WARP); + return; } - else - if (getcodi(&course, &dist)) - return; + + course = c; + dist = d; /* check to see that we are not using an absurd amount of power */ power = (dist + 0.05) * Ship.warp3; @@ -140,10 +158,11 @@ double d; sleep(4); if (ranf(100) >= 100 * dist) { - return (printf("Equilibrium restored -- all systems normal\n")); + printf("Equilibrium restored -- all systems normal\n"); + return; } - /* select a bizzare thing to happen to us */ + /* select a bizarre thing to happen to us */ percent = ranf(100); if (percent < 70) { @@ -166,10 +185,12 @@ double d; /* s/he got lucky: a negative time portal */ time = Now.date; - i = (int) Etc.snapshot; - bmove(i, Quad, sizeof Quad); - bmove(i += sizeof Quad, Event, sizeof Event); - bmove(i += sizeof Event, &Now, sizeof Now); + p = (char *) Etc.snapshot; + memcpy(p, Quad, sizeof Quad); + p += sizeof Quad; + memcpy(p, Event, sizeof Event); + p += sizeof Event; + memcpy(p, &Now, sizeof Now); printf("Negative time portal entered -- it is now Stardate %.2f\n", Now.date); for (i = 0; i < MAXEVENTS; i++) diff --git a/games/trek/win.c b/games/trek/win.c index 85d3dc298ed..1ee3bfeeb2f 100644 --- a/games/trek/win.c +++ b/games/trek/win.c @@ -1,3 +1,4 @@ +/* $OpenBSD: win.c,v 1.2 1998/08/19 07:42:18 pjanzen Exp $ */ /* $NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $ */ /* @@ -37,13 +38,15 @@ #if 0 static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $"; +static char rcsid[] = "$OpenBSD: win.c,v 1.2 1998/08/19 07:42:18 pjanzen Exp $"; #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" -# include <setjmp.h> +#include <stdio.h> +#include <unistd.h> +#include <setjmp.h> +#include "trek.h" +#include "getpar.h" /* ** Signal game won @@ -58,13 +61,12 @@ static char rcsid[] = "$NetBSD: win.c,v 1.3 1995/04/22 10:59:41 cgd Exp $"; ** pretty off the wall. */ +void win() { long s; - extern jmp_buf env; - extern long score(); - extern struct cvntab Skitab[]; - register struct cvntab *p; + register struct cvntab *p = NULL; + extern jmp_buf env; sleep(1); printf("\nCongratulations, you have saved the Federation\n"); |