From 927a087250c6d788d6df6cc7fcb0359653e2efd3 Mon Sep 17 00:00:00 2001 From: dholland Date: Sun, 24 May 2009 21:44:56 +0000 Subject: KNF: brace and comment placement. Object files identical. --- trek/abandon.c | 32 ++++++----------- trek/attack.c | 28 ++++++--------- trek/capture.c | 13 +++---- trek/checkcond.c | 10 +++--- trek/compkl.c | 23 +++++------- trek/computer.c | 59 ++++++++++++------------------ trek/damage.c | 10 +++--- trek/damaged.c | 7 ++-- trek/dcrept.c | 17 ++++----- trek/destruct.c | 13 +++---- trek/dock.c | 22 +++++------- trek/dumpgame.c | 19 ++++------ trek/dumpme.c | 14 +++----- trek/dumpssradio.c | 13 +++---- trek/events.c | 103 ++++++++++++++++++++--------------------------------- trek/externs.c | 13 ++++--- trek/getpar.c | 51 +++++++++++--------------- trek/getpar.h | 7 ++-- trek/help.c | 34 +++++++----------- trek/impulse.c | 10 +++--- trek/initquad.c | 25 +++++-------- trek/kill.c | 43 ++++++++-------------- trek/klmove.c | 31 ++++++---------- trek/lose.c | 11 +++--- trek/lrscan.c | 25 +++++-------- trek/main.c | 24 ++++++------- trek/move.c | 34 ++++++++---------- trek/nova.c | 21 +++++------ trek/phaser.c | 95 +++++++++++++++++------------------------------- trek/play.c | 10 +++--- trek/ram.c | 10 +++--- trek/rest.c | 7 ++-- trek/schedule.c | 7 ++-- trek/score.c | 13 +++---- trek/setup.c | 49 ++++++++++--------------- trek/shield.c | 30 ++++++---------- trek/snova.c | 43 ++++++++-------------- trek/srscan.c | 39 ++++++++------------ trek/torped.c | 59 +++++++++++------------------- trek/trek.h | 53 +++++++++++++-------------- trek/visual.c | 7 ++-- trek/warp.c | 28 ++++++--------- trek/win.c | 12 +++---- 43 files changed, 440 insertions(+), 734 deletions(-) (limited to 'trek') diff --git a/trek/abandon.c b/trek/abandon.c index 7d67ddb7..5209d371 100644 --- a/trek/abandon.c +++ b/trek/abandon.c @@ -1,4 +1,4 @@ -/* $NetBSD: abandon.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: abandon.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)abandon.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: abandon.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: abandon.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -79,8 +79,7 @@ abandon(int v __unused) printf("You may not abandon ye Faire Queene\n"); return; } - if (Ship.cond != DOCKED) - { + if (Ship.cond != DOCKED) { if (damaged(SHUTTLE)) { out(SHUTTLE); return; @@ -88,14 +87,11 @@ abandon(int v __unused) printf("Officers escape in shuttlecraft\n"); /* decide on fate of crew */ q = &Quad[Ship.quadx][Ship.quady]; - if (q->qsystemname == 0 || damaged(XPORTER)) - { + if (q->qsystemname == 0 || damaged(XPORTER)) { printf("Entire crew of %d left to die in outer space\n", Ship.crew); Game.deaths += Ship.crew; - } - else - { + } else { printf("Crew beams down to planet %s\n", systemname(q)); } } @@ -117,8 +113,7 @@ abandon(int v __unused) Ship.warp3 = 125.0; Ship.cond = GREEN; /* clear out damages on old ship */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; @@ -128,10 +123,8 @@ abandon(int v __unused) i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK]; Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0; while (i > 0) - for (j = 0; j < NDEV; j++) - { - if (Param.damprob[j] != 0) - { + for (j = 0; j < NDEV; j++) { + if (Param.damprob[j] != 0) { Param.damprob[j] += 1; i--; if (i <= 0) @@ -143,20 +136,17 @@ abandon(int v __unused) Ship.quadx = Now.base[i].x; Ship.quady = Now.base[i].y; /* setup that quadrant */ - while (1) - { + while (1) { initquad(1); Sect[Ship.sectx][Ship.secty] = EMPTY; - for (i = 0; i < 5; i++) - { + for (i = 0; i < 5; i++) { Ship.sectx = Etc.starbase.x + ranf(3) - 1; if (Ship.sectx < 0 || Ship.sectx >= NSECTS) continue; Ship.secty = Etc.starbase.y + ranf(3) - 1; if (Ship.secty < 0 || Ship.secty >= NSECTS) continue; - if (Sect[Ship.sectx][Ship.secty] == EMPTY) - { + if (Sect[Ship.sectx][Ship.secty] == EMPTY) { Sect[Ship.sectx][Ship.secty] = QUEENE; dock(0); compkldist(0); diff --git a/trek/attack.c b/trek/attack.c index a984faee..060376a9 100644 --- a/trek/attack.c +++ b/trek/attack.c @@ -1,4 +1,4 @@ -/* $NetBSD: attack.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: attack.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)attack.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: attack.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: attack.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -92,8 +92,7 @@ attack(int resting) return; /* move before attack */ klmove(0); - if (Ship.cond == DOCKED) - { + if (Ship.cond == DOCKED) { if (!resting) printf("Starbase shields protect the %s\n", Ship.shipname); return; @@ -106,13 +105,11 @@ attack(int resting) hitflag = 0; /* let each Klingon do his damndest */ - for (i = 0; i < Etc.nkling; i++) - { + for (i = 0; i < Etc.nkling; i++) { /* if he's low on power he won't attack */ if (Etc.klingon[i].power < 20) continue; - if (!hitflag) - { + if (!hitflag) { printf("\nStardate %.2f: Klingon attack:\n", Now.date); hitflag++; @@ -126,8 +123,7 @@ attack(int resting) Etc.klingon[i].power = dustfac * Param.phasfac * (1.0 + (franf() - 0.5) * 0.2); /* see how much of hit shields will absorb */ shldabsb = 0; - if (Ship.shldup || Move.shldchg) - { + if (Ship.shldup || Move.shldchg) { propor = Ship.shield; propor /= Param.shield; shldabsb = propor * chgfac * hit; @@ -151,8 +147,7 @@ attack(int resting) maxhit = hit; Ship.energy -= hit; /* see if damages occurred */ - if (hit >= (15 - Game.skill) * (25 - ranf(12))) - { + if (hit >= (15 - Game.skill) * (25 - ranf(12))) { printf("CRITICAL HIT!!!\n"); /* select a device from probability vector */ cas = ranf(1000); @@ -163,8 +158,7 @@ attack(int resting) extradm = (hit * Param.damfac[l]) / (75 + ranf(25)) + 0.5; /* damage the device */ damage(l, extradm); - if (damaged(SHIELD)) - { + if (damaged(SHIELD)) { if (Ship.shldup) printf("Sulu: Shields knocked down, captain.\n"); Ship.shldup = 0; @@ -176,11 +170,9 @@ attack(int resting) } /* see what our casualities are like */ - if (maxhit >= 200 || tothit >= 500) - { + if (maxhit >= 200 || tothit >= 500) { cas = tothit * 0.015 * franf(); - if (cas >= 2) - { + if (cas >= 2) { printf("McCoy: we suffered %d casualties in that attack.\n", cas); Game.deaths += cas; diff --git a/trek/capture.c b/trek/capture.c index 9c7414d2..510e4346 100644 --- a/trek/capture.c +++ b/trek/capture.c @@ -1,4 +1,4 @@ -/* $NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: capture.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)capture.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: capture.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: capture.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -64,8 +64,7 @@ capture(int v __unused) double x; /* check for not cloaked */ - if (Ship.cloaked) - { + if (Ship.cloaked) { printf("Ship-ship communications out when cloaked\n"); return; } @@ -74,8 +73,7 @@ capture(int v __unused) return; } /* find out if there are any at all */ - if (Etc.nkling <= 0) - { + if (Etc.nkling <= 0) { printf("Uhura: Getting no response, sir\n"); return; } @@ -96,8 +94,7 @@ capture(int v __unused) if (Trace) printf("Prob = %d (%.4f)\n", i, x); #endif - if (i > ranf(100)) - { + if (i > ranf(100)) { /* guess what, he surrendered!!! */ printf("Klingon at %d,%d surrenders\n", k->x, k->y); i = ranf(Param.klingcrew); diff --git a/trek/checkcond.c b/trek/checkcond.c index 560138a1..a6251099 100644 --- a/trek/checkcond.c +++ b/trek/checkcond.c @@ -1,4 +1,4 @@ -/* $NetBSD: checkcond.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: checkcond.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)checkcond.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: checkcond.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: checkcond.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -91,13 +91,11 @@ checkcond(void) if (Ship.cond == DOCKED) return; - if (Etc.nkling > 0) - { + if (Etc.nkling > 0) { Ship.cond = RED; return; } - if (Ship.energy < Param.energylow) - { + if (Ship.energy < Param.energylow) { Ship.cond = YELLOW; return; } diff --git a/trek/compkl.c b/trek/compkl.c index 1850d78e..f86749dd 100644 --- a/trek/compkl.c +++ b/trek/compkl.c @@ -1,4 +1,4 @@ -/* $NetBSD: compkl.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: compkl.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)compkl.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: compkl.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: compkl.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -65,8 +65,7 @@ compkldist(int f) if (Etc.nkling == 0) return; - for (i = 0; i < Etc.nkling; i++) - { + for (i = 0; i < Etc.nkling; i++) { /* compute distance to the Klingon */ dx = Ship.sectx - Etc.klingon[i].x; dy = Ship.secty - Etc.klingon[i].y; @@ -74,13 +73,10 @@ compkldist(int f) d = sqrt(d); /* compute average of new and old distances to Klingon */ - if (!f) - { + if (!f) { temp = Etc.klingon[i].dist; Etc.klingon[i].avgdist = 0.5 * (temp + d); - } - else - { + } else { /* new quadrant: average is current */ Etc.klingon[i].avgdist = d; } @@ -106,16 +102,15 @@ sortkl(void) m = Etc.nkling - 1; f = 1; - while (f) - { + while (f) { f = 0; - for (i = 0; i < m; i++) - if (Etc.klingon[i].dist > Etc.klingon[i+1].dist) - { + for (i = 0; i < m; i++) { + if (Etc.klingon[i].dist > Etc.klingon[i+1].dist) { t = Etc.klingon[i]; Etc.klingon[i] = Etc.klingon[i+1]; Etc.klingon[i+1] = t; f = 1; } + } } } diff --git a/trek/computer.c b/trek/computer.c index 62a6c73d..f1f944be 100644 --- a/trek/computer.c +++ b/trek/computer.c @@ -1,4 +1,4 @@ -/* $NetBSD: computer.c,v 1.12 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: computer.c,v 1.13 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)computer.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: computer.c,v 1.12 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: computer.c,v 1.13 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -90,8 +90,7 @@ __RCSID("$NetBSD: computer.c,v 1.12 2009/05/24 19:18:44 dholland Exp $"); ** command processor. */ -struct cvntab Cputab[] = -{ +struct cvntab Cputab[] = { { "ch", "art", (cmdfun)1, 0 }, { "t", "rajectory", (cmdfun)2, 0 }, { "c", "ourse", (cmdfun)3, 0 }, @@ -124,11 +123,9 @@ computer(int v __unused) if (check_out(COMPUTER)) return; - while (1) - { + while (1) { r = getcodpar("\nRequest", Cputab); - switch ((long)r->value) - { + switch ((long)r->value) { case 1: /* star chart */ printf("Computer record of galaxy for all long range sensor scans\n\n"); @@ -137,13 +134,10 @@ computer(int v __unused) for (i = 0; i < NQUADS; i++) printf("-%d- ", i); printf("\n"); - for (i = 0; i < NQUADS; i++) - { + for (i = 0; i < NQUADS; i++) { printf("%d ", i); - for (j = 0; j < NQUADS; j++) - { - if (i == Ship.quadx && j == Ship.quady) - { + for (j = 0; j < NQUADS; j++) { + if (i == Ship.quadx && j == Ship.quady) { printf("$$$ "); continue; } @@ -170,18 +164,15 @@ computer(int v __unused) break; case 2: /* trajectory */ - if (check_out(SRSCAN)) - { + if (check_out(SRSCAN)) { break; } - if (Etc.nkling <= 0) - { + if (Etc.nkling <= 0) { printf("No Klingons in this quadrant\n"); break; } /* for each Klingon, give the course & distance */ - for (i = 0; i < Etc.nkling; i++) - { + for (i = 0; i < Etc.nkling; i++) { printf("Klingon at %d,%d", Etc.klingon[i].x, Etc.klingon[i].y); course = kalc(Ship.quadx, Ship.quady, Etc.klingon[i].x, Etc.klingon[i].y, &dist); prkalc(course, dist); @@ -189,13 +180,10 @@ computer(int v __unused) break; case 3: /* course calculation */ - if (readdelim('/')) - { + if (readdelim('/')) { tqx = Ship.quadx; tqy = Ship.quady; - } - else - { + } else { ix = getintpar("Quadrant"); if (ix < 0 || ix >= NSECTS) break; @@ -212,8 +200,7 @@ computer(int v __unused) if (iy < 0 || iy >= NSECTS) break; course = kalc(tqx, tqy, ix, iy, &dist); - if (r->value2) - { + if (r->value2) { warp(-1, course, dist); break; } @@ -262,14 +249,12 @@ computer(int v __unused) j = 1; printf("\n"); /* scan the event list */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; /* ignore hidden entries */ if (e->evcode & E_HIDDEN) continue; - switch (e->evcode & E_EVENT) - { + switch (e->evcode & E_EVENT) { case E_KDESB: printf("Klingon is attacking starbase in quadrant %d,%d\n", @@ -291,15 +276,15 @@ computer(int v __unused) } - /* skip to next semicolon or newline. Semicolon + /* + * Skip to next semicolon or newline. Semicolon * means get new computer request; newline means - * exit computer mode. */ - while ((i = cgetc(0)) != ';') - { + * exit computer mode. + */ + while ((i = cgetc(0)) != ';') { if (i == '\0') exit(1); - if (i == '\n') - { + if (i == '\n') { ungetc(i, stdin); return; } diff --git a/trek/damage.c b/trek/damage.c index d928883f..73dfbee9 100644 --- a/trek/damage.c +++ b/trek/damage.c @@ -1,4 +1,4 @@ -/* $NetBSD: damage.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: damage.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)damage.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: damage.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: damage.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -77,16 +77,14 @@ damage(int dev1, double dam) dam *= Param.dockfac; /* set the damage flag */ f = damaged(dev); - if (!f) - { + if (!f) { /* new damages -- schedule a fix */ schedule(E_FIXDV, dam, 0, 0, dev); return; } /* device already damaged -- add to existing damages */ /* scan for old damages */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV || e->systemname != dev) continue; diff --git a/trek/damaged.c b/trek/damaged.c index 0440f16d..b9dbad22 100644 --- a/trek/damaged.c +++ b/trek/damaged.c @@ -1,4 +1,4 @@ -/* $NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: damaged.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)damaged.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: damaged.c,v 1.7 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: damaged.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -56,8 +56,7 @@ damaged(int dev) d = dev; - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; diff --git a/trek/dcrept.c b/trek/dcrept.c index e1981823..e12ea304 100644 --- a/trek/dcrept.c +++ b/trek/dcrept.c @@ -1,4 +1,4 @@ -/* $NetBSD: dcrept.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: dcrept.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dcrept.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dcrept.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: dcrept.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -63,13 +63,10 @@ dcrept(int v __unused) struct event *e; /* set up the magic factors to output the time till fixed */ - if (Ship.cond == DOCKED) - { + if (Ship.cond == DOCKED) { m1 = 1.0 / Param.dockfac; m2 = 1.0; - } - else - { + } else { m1 = 1.0; m2 = Param.dockfac; } @@ -77,15 +74,13 @@ dcrept(int v __unused) f = 1; /* scan for damages */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; /* output the title first time */ - if (f) - { + if (f) { printf("\t\t\t repair times\n"); printf("device\t\t\tin flight docked\n"); f = 0; diff --git a/trek/destruct.c b/trek/destruct.c index 0ce2d0d3..d792f90e 100644 --- a/trek/destruct.c +++ b/trek/destruct.c @@ -1,4 +1,4 @@ -/* $NetBSD: destruct.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: destruct.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)destruct.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: destruct.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: destruct.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -79,8 +79,7 @@ destruct(int v __unused) printf("\n\07 --- WORKING ---\07\n"); sleep(3); /* output the count 10 9 8 7 6 */ - for (i = 10; i > 5; i--) - { + for (i = 10; i > 5; i--) { for (j = 10; j > i; j--) printf(" "); printf("%d\n", i); @@ -97,8 +96,7 @@ destruct(int v __unused) printf("Password verified; self destruct sequence continues:\n"); sleep(2); /* output count 5 4 3 2 1 0 */ - for (i = 5; i >= 0; i--) - { + for (i = 5; i >= 0; i--) { sleep(1); for (j = 5; j > i; j--) printf(" "); @@ -110,8 +108,7 @@ destruct(int v __unused) /* let's see what we can blow up!!!! */ zap = 20.0 * Ship.energy; Game.deaths += Ship.crew; - for (i = 0; i < Etc.nkling; ) - { + for (i = 0; i < Etc.nkling; ) { if (Etc.klingon[i].power * Etc.klingon[i].dist <= zap) killk(Etc.klingon[i].x, Etc.klingon[i].y); else diff --git a/trek/dock.c b/trek/dock.c index fd50faad..9abab3f7 100644 --- a/trek/dock.c +++ b/trek/dock.c @@ -1,4 +1,4 @@ -/* $NetBSD: dock.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: dock.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dock.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dock.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: dock.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -70,16 +70,13 @@ dock(int v __unused) } /* check for ok to dock, i.e., adjacent to a starbase */ ok = 0; - for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) - { + for (i = Ship.sectx - 1; i <= Ship.sectx + 1 && !ok; i++) { if (i < 0 || i >= NSECTS) continue; - for (j = Ship.secty - 1; j <= Ship.secty + 1; j++) - { + for (j = Ship.secty - 1; j <= Ship.secty + 1; j++) { if (j < 0 || j >= NSECTS) continue; - if (Sect[i][j] == BASE) - { + if (Sect[i][j] == BASE) { ok++; break; } @@ -111,8 +108,7 @@ dock(int v __unused) dumpssradio(); /* reschedule any device repairs */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; @@ -136,8 +132,7 @@ undock(int v __unused) struct event *e; int i; - if (Ship.cond != DOCKED) - { + if (Ship.cond != DOCKED) { printf("Sulu: Pardon me captain, but we are not docked.\n"); return; } @@ -145,8 +140,7 @@ undock(int v __unused) Move.free = 0; /* reschedule device repair times (again) */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; diff --git a/trek/dumpgame.c b/trek/dumpgame.c index eb72ee57..0c98662d 100644 --- a/trek/dumpgame.c +++ b/trek/dumpgame.c @@ -1,4 +1,4 @@ -/* $NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: dumpgame.c,v 1.14 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: dumpgame.c,v 1.14 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -47,8 +47,7 @@ __RCSID("$NetBSD: dumpgame.c,v 1.13 2009/05/24 20:39:43 dholland Exp $"); /*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/ #define VERSION 2 -struct dump -{ +struct dump { char *area; int count; }; @@ -56,8 +55,7 @@ struct dump static int readdump(int); -struct dump Dump_template[] = -{ +struct dump Dump_template[] = { { (char *)&Ship, sizeof (Ship) }, { (char *)&Now, sizeof (Now) }, { (char *)&Param, sizeof (Param) }, @@ -97,8 +95,7 @@ dumpgame(int v __unused) write(fd, &version, sizeof version); /* output the main data areas */ - for (d = Dump_template; d->area; d++) - { + for (d = Dump_template; d->area; d++) { write(fd, &d->area, sizeof d->area); i = d->count; write(fd, d->area, i); @@ -128,8 +125,7 @@ restartgame(void) if ((fd = open("trek.dump", O_RDONLY)) < 0 || read(fd, &version, sizeof version) != sizeof version || version != VERSION || - readdump(fd)) - { + readdump(fd)) { printf("cannot restart\n"); if (fd >= 0) close(fd); @@ -160,8 +156,7 @@ readdump(int fd1) fd = fd1; - for (d = Dump_template; d->area; d++) - { + for (d = Dump_template; d->area; d++) { if (read(fd, &junk, sizeof junk) != (sizeof junk)) return (1); if ((char *)junk != d->area) diff --git a/trek/dumpme.c b/trek/dumpme.c index e777dfe1..d723d4d4 100644 --- a/trek/dumpme.c +++ b/trek/dumpme.c @@ -1,4 +1,4 @@ -/* $NetBSD: dumpme.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: dumpme.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dumpme.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dumpme.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: dumpme.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -68,18 +68,14 @@ dumpme(int flag) Ship.secty = ranf(NSECTS); x = 1.5 * franf(); Move.time += x; - if (f) - { + if (f) { printf("%s falls into a black hole.\n", Ship.shipname); - } - else - { + } else { printf("Computer applies full reverse power to avoid hitting the\n"); printf(" negative energy barrier. A space warp was entered.\n"); } /* bump repair dates forward */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; diff --git a/trek/dumpssradio.c b/trek/dumpssradio.c index 99ad4aca..ce147392 100644 --- a/trek/dumpssradio.c +++ b/trek/dumpssradio.c @@ -1,4 +1,4 @@ -/* $NetBSD: dumpssradio.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: dumpssradio.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dumpssradio.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dumpssradio.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: dumpssradio.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -53,22 +53,19 @@ dumpssradio(void) int chkrest; chkrest = 0; - for (j = 0; j < MAXEVENTS; j++) - { + for (j = 0; j < MAXEVENTS; j++) { e = &Event[j]; /* if it is not hidden, then just ignore it */ if ((e->evcode & E_HIDDEN) == 0) continue; - if (e->evcode & E_GHOST) - { + if (e->evcode & E_GHOST) { unschedule(e); printf("Starsystem %s in quadrant %d,%d is no longer distressed\n", systemname(&Quad[e->x][e->y]), e->x, e->y); continue; } - switch (e->evcode) - { + switch (e->evcode) { case E_KDESB: printf("Starbase in quadrant %d,%d is under attack\n", diff --git a/trek/events.c b/trek/events.c index 9d76d702..e15ad251 100644 --- a/trek/events.c +++ b/trek/events.c @@ -1,4 +1,4 @@ -/* $NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: events.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)events.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: events.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: events.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -72,8 +72,7 @@ events(int timewarp) int restcancel; /* if nothing happened, just allow for any Klingons killed */ - if (Move.time <= 0.0) - { + if (Move.time <= 0.0) { Now.time = Now.resource / Now.klings; return (0); } @@ -89,21 +88,18 @@ events(int timewarp) schedule(E_ATTACK, 0.5, 0, 0, 0); /* scan the event list */ - while (1) - { + while (1) { restcancel = 0; evnum = -1; /* xdate is the date of the current event */ xdate = idate + Move.time; /* find the first event that has happened */ - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode == 0 || (e->evcode & E_GHOST)) continue; - if (e->date < xdate) - { + if (e->date < xdate) { xdate = e->date; ev = e; evnum = i; @@ -136,8 +132,7 @@ events(int timewarp) break; /* otherwise one did. Find out what it is */ - switch (e->evcode & E_EVENT) - { + switch (e->evcode & E_EVENT) { case E_SNOVA: /* supernova */ /* cause the supernova to happen */ @@ -150,14 +145,11 @@ events(int timewarp) /* schedule the next one */ xresched(e, E_LRTB, Now.klings); /* LRTB cannot occur if we are docked */ - if (Ship.cond != DOCKED) - { + if (Ship.cond != DOCKED) { /* pick a new quadrant */ i = ranf(Now.klings) + 1; - for (ix = 0; ix < NQUADS; ix++) - { - for (iy = 0; iy < NQUADS; iy++) - { + for (ix = 0; ix < NQUADS; ix++) { + for (iy = 0; iy < NQUADS; iy++) { q = &Quad[ix][iy]; if (q->stars >= 0) if ((i -= q->klings) <= 0) @@ -186,15 +178,13 @@ events(int timewarp) case E_KATSB: /* Klingon attacks starbase */ /* if out of bases, forget it */ - if (Now.bases <= 0) - { + if (Now.bases <= 0) { unschedule(e); break; } /* check for starbase and Klingons in same quadrant */ - for (i = 0; i < Now.bases; i++) - { + for (i = 0; i < Now.bases; i++) { ix = Now.base[i].x; iy = Now.base[i].y; /* see if a Klingon exists in this quadrant */ @@ -203,8 +193,7 @@ events(int timewarp) continue; /* see if already distressed */ - for (j = 0; j < MAXEVENTS; j++) - { + for (j = 0; j < MAXEVENTS; j++) { e = &Event[j]; if ((e->evcode & E_EVENT) != E_KDESB) continue; @@ -218,8 +207,7 @@ events(int timewarp) break; } e = ev; - if (i >= Now.bases) - { + if (i >= Now.bases) { /* not now; wait a while and see if some Klingons move in */ reschedule(e, 0.5 + 3.0 * franf()); break; @@ -229,17 +217,16 @@ events(int timewarp) e = xsched(E_KDESB, 1, ix, iy, 0); /* report it if we can */ - if (!damaged(SSRADIO)) - { + if (!damaged(SSRADIO)) { printf("\nUhura: Captain, we have received a distress signal\n"); printf(" from the starbase in quadrant %d,%d.\n", ix, iy); restcancel++; - } - else + } else { /* SSRADIO out, make it so we can't see the distress call */ /* but it's still there!!! */ e->evcode |= E_HIDDEN; + } break; case E_KDESB: /* Klingon destroys starbase */ @@ -250,15 +237,14 @@ events(int timewarp) if (q->bases <=0 || q->klings <= 0) break; /* are we in the same quadrant? */ - if (e->x == Ship.quadx && e->y == Ship.quady) - { + if (e->x == Ship.quadx && e->y == Ship.quady) { /* yep, kill one in this quadrant */ printf("\nSpock: "); killb(Ship.quadx, Ship.quady); - } - else + } else { /* kill one in some other quadrant */ killb(e->x, e->y); + } break; case E_ISSUE: /* issue a distress call */ @@ -267,8 +253,7 @@ events(int timewarp) if (Ship.distressed >= MAXDISTR) break; /* try a whole bunch of times to find something suitable */ - for (i = 0; i < 100; i++) - { + for (i = 0; i < 100; i++) { ix = ranf(NQUADS); iy = ranf(NQUADS); q = &Quad[ix][iy]; @@ -291,23 +276,21 @@ events(int timewarp) q->qsystemname = (e - Event) | Q_DISTRESSED; /* tell the captain about it if we can */ - if (!damaged(SSRADIO)) - { + if (!damaged(SSRADIO)) { printf("\nUhura: Captain, starsystem %s in quadrant %d,%d is under attack\n", Systemname[e->systemname], ix, iy); restcancel++; - } - else + } else { /* if we can't tell him, make it invisible */ e->evcode |= E_HIDDEN; + } break; case E_ENSLV: /* starsystem is enslaved */ unschedule(e); /* see if current distress call still active */ q = &Quad[e->x][e->y]; - if (q->klings <= 0) - { + if (q->klings <= 0) { /* no Klingons, clean up */ /* restore the system name */ q->qsystemname = e->systemname; @@ -318,22 +301,19 @@ events(int timewarp) e = schedule(E_REPRO, Param.eventdly[E_REPRO] * franf(), e->x, e->y, e->systemname); /* report the disaster if we can */ - if (!damaged(SSRADIO)) - { + if (!damaged(SSRADIO)) { printf("\nUhura: We've lost contact with starsystem %s\n", Systemname[e->systemname]); printf(" in quadrant %d,%d.\n", e->x, e->y); - } - else + } else e->evcode |= E_HIDDEN; break; case E_REPRO: /* Klingon reproduces */ /* see if distress call is still active */ q = &Quad[e->x][e->y]; - if (q->klings <= 0) - { + if (q->klings <= 0) { unschedule(e); q->qsystemname = e->systemname; break; @@ -342,17 +322,16 @@ events(int timewarp) /* reproduce one Klingon */ ix = e->x; iy = e->y; - if (Now.klings == 127) - break; /* full right now */ - if (q->klings >= MAXKLQUAD) - { + if (Now.klings == 127) { + /* full right now */ + break; + } + if (q->klings >= MAXKLQUAD) { /* this quadrant not ok, pick an adjacent one */ - for (i = ix - 1; i <= ix + 1; i++) - { + for (i = ix - 1; i <= ix + 1; i++) { if (i < 0 || i >= NQUADS) continue; - for (j = iy - 1; j <= iy + 1; j++) - { + for (j = iy - 1; j <= iy + 1; j++) { if (j < 0 || j >= NQUADS) continue; q = &Quad[i][j]; @@ -373,8 +352,7 @@ events(int timewarp) /* deliver the child */ q->klings++; Now.klings++; - if (ix == Ship.quadx && iy == Ship.quady) - { + if (ix == Ship.quadx && iy == Ship.quady) { /* we must position Klingon */ sector(&ix, &iy); Sect[ix][iy] = KLINGON; @@ -402,8 +380,7 @@ events(int timewarp) break; case E_ATTACK: /* Klingons attack during rest period */ - if (!Move.resting) - { + if (!Move.resting) { unschedule(e); break; } @@ -420,8 +397,7 @@ events(int timewarp) Device[i].person, Device[i].name); /* handle special processing upon fix */ - switch (i) - { + switch (i) { case LIFESUP: Ship.reserves = Param.reserves; @@ -455,8 +431,7 @@ events(int timewarp) if ((e = Now.eventptr[E_ATTACK]) != NULL) unschedule(e); - if (!timewarp) - { + if (!timewarp) { /* eat up energy if cloaked */ if (Ship.cloaked) Ship.energy -= Param.cloakenergy * Move.time; diff --git a/trek/externs.c b/trek/externs.c index b834d9bb..2addff68 100644 --- a/trek/externs.c +++ b/trek/externs.c @@ -1,4 +1,4 @@ -/* $NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: externs.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)externs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: externs.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -44,8 +44,7 @@ __RCSID("$NetBSD: externs.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); ** global variable definitions */ -const struct device Device[NDEV] = -{ +const struct device Device[NDEV] = { { "warp drive", "Scotty" }, { "S.R. scanners", "Scotty" }, { "L.R. scanners", "Scotty" }, @@ -64,8 +63,7 @@ const struct device Device[NDEV] = { "*ERR 15*", "Nobody" } }; -const char *const Systemname[NINHAB] = -{ +const char *const Systemname[NINHAB] = { "ERROR", "Talos IV", "Rigel III", @@ -105,7 +103,8 @@ struct quad Quad[NQUADS][NQUADS]; /* current sector map */ char Sect[NSECTS][NSECTS]; -struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ +/* dynamic event list; one entry per pending event */ +struct event Event[MAXEVENTS]; struct Ship_struct Ship; struct Game_struct Game; diff --git a/trek/getpar.c b/trek/getpar.c index b51a209d..25dcdb61 100644 --- a/trek/getpar.c +++ b/trek/getpar.c @@ -1,4 +1,4 @@ -/* $NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: getpar.c,v 1.13 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: getpar.c,v 1.14 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -56,8 +56,7 @@ getintpar(const char *s) int i; int n; - while (1) - { + while (1) { if (testnl() && s) printf("%s: ", s); i = scanf("%d", &n); @@ -80,8 +79,7 @@ getfltpar(const char *s) int i; double d; - while (1) - { + while (1) { if (testnl() && s) printf("%s: ", s); i = scanf("%lf", &d); @@ -98,8 +96,7 @@ getfltpar(const char *s) ** get yes/no parameter **/ -const struct cvntab Yntab[] = -{ +const struct cvntab Yntab[] = { { "y", "es", (cmdfun)1, 1 }, { "n", "o", (cmdfun)0, 0 }, { NULL, NULL, NULL, 0 } @@ -130,13 +127,14 @@ getcodpar(const char *s, const struct cvntab tab[]) int f; flag = 0; - while (1) - { + while (1) { flag |= (f = testnl()); if (flag) printf("%s: ", s); - if (f) - cgetc(0); /* throw out the newline */ + if (f) { + /* throw out the newline */ + cgetc(0); + } scanf("%*[ \t;]"); if ((c = scanf("%99[^ \t;\n]", input)) < 0) exit(1); @@ -145,11 +143,9 @@ getcodpar(const char *s, const struct cvntab tab[]) flag = 1; /* if command list, print four per line */ - if (input[0] == '?' && input[1] == 0) - { + if (input[0] == '?' && input[1] == 0) { c = 4; - for (r = tab; r->abrev; r++) - { + for (r = tab; r->abrev; r++) { strcpy(input, r->abrev); strcat(input, r->full); printf("%14.14s", input); @@ -164,14 +160,12 @@ getcodpar(const char *s, const struct cvntab tab[]) } /* search for in table */ - for (r = tab; r->abrev; r++) - { + for (r = tab; r->abrev; r++) { p = input; for (q = r->abrev; *q; q++) if (*p++ != *q) break; - if (!*q) - { + if (!*q) { for (q = r->full; *p && *q; q++, p++) if (*p != *q) break; @@ -181,12 +175,10 @@ getcodpar(const char *s, const struct cvntab tab[]) } /* check for not found */ - if (!r->abrev) - { + if (!r->abrev) { printf("invalid input; ? for valid inputs\n"); skiptonl(0); - } - else + } else return (r); } } @@ -206,8 +198,7 @@ getstrpar(const char *s, char *r, int l, const char *t) if (t == 0) t = " \t\n;"; (void)sprintf(format, "%%%d[^%s]", l, t); - while (1) - { + while (1) { if ((f = testnl()) && s) printf("%s: ", s); if (f) @@ -233,9 +224,8 @@ testnl(void) while ((c = cgetc(0)) != '\n') if ((c >= '0' && c <= '9') || c == '.' || c == '!' || - (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || c == '-') - { + (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || c == '-') { ungetc(c, stdin); return(0); } @@ -291,8 +281,7 @@ readdelim(int d) { char c; - while ((c = cgetc(0)) != '\0') - { + while ((c = cgetc(0)) != '\0') { if (c == d) return (1); if (c == ' ') diff --git a/trek/getpar.h b/trek/getpar.h index 20527c3b..77b93b18 100644 --- a/trek/getpar.h +++ b/trek/getpar.h @@ -1,4 +1,4 @@ -/* $NetBSD: getpar.h,v 1.10 2005/02/15 12:54:50 jsm Exp $ */ +/* $NetBSD: getpar.h,v 1.11 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -32,8 +32,9 @@ */ typedef void (*cmdfun)(int); -struct cvntab /* used for getcodpar() parameter list */ -{ + +/* used for getcodpar() parameter list */ +struct cvntab { const char *abrev; const char *full; cmdfun value; diff --git a/trek/help.c b/trek/help.c index 2d6447a1..027f7aa8 100644 --- a/trek/help.c +++ b/trek/help.c @@ -1,4 +1,4 @@ -/* $NetBSD: help.c,v 1.10 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: help.c,v 1.11 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)help.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: help.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: help.c,v 1.11 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -64,8 +64,9 @@ __RCSID("$NetBSD: help.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); ** to drop you. After that, it's your problem. */ -const char *const Cntvect[3] = -{"first", "second", "third"}; +const char *const Cntvect[3] = { + "first", "second", "third" +}; /*ARGSUSED*/ void @@ -97,11 +98,9 @@ help(int v __unused) /* find the closest base */ dist = TOOLARGE; - if (Quad[Ship.quadx][Ship.quady].bases <= 0) - { + if (Quad[Ship.quadx][Ship.quady].bases <= 0) { /* there isn't one in this quadrant */ - for (i = 0; i < Now.bases; i++) - { + for (i = 0; i < Now.bases; i++) { /* compute distance */ dx = Now.base[i].x - Ship.quadx; dy = Now.base[i].y - Ship.quady; @@ -109,8 +108,7 @@ help(int v __unused) x = sqrt(x); /* see if better than what we already have */ - if (x < dist) - { + if (x < dist) { dist = x; l = i; } @@ -120,9 +118,7 @@ help(int v __unused) Ship.quadx = Now.base[l].x; Ship.quady = Now.base[l].y; initquad(1); - } - else - { + } else { dist = 0.0; } @@ -134,15 +130,12 @@ help(int v __unused) x = pow(1.0 - pow(0.94, dist), 0.3333333); /* attempt to rematerialize */ - for (i = 0; i < 3; i++) - { + for (i = 0; i < 3; i++) { sleep(2); printf("%s attempt to rematerialize ", Cntvect[i]); - if (franf() > x) - { + if (franf() > x) { /* ok, that's good. let's see if we can set her down */ - for (j = 0; j < 5; j++) - { + for (j = 0; j < 5; j++) { dx = Etc.starbase.x + ranf(3) - 1; if (dx < 0 || dx >= NSECTS) continue; @@ -151,8 +144,7 @@ help(int v __unused) continue; break; } - if (j < 5) - { + if (j < 5) { /* found an empty spot */ printf("succeeds\n"); Ship.sectx = dx; diff --git a/trek/impulse.c b/trek/impulse.c index 50be22b9..b1491d0a 100644 --- a/trek/impulse.c +++ b/trek/impulse.c @@ -1,4 +1,4 @@ -/* $NetBSD: impulse.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: impulse.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)impulse.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: impulse.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: impulse.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -67,8 +67,7 @@ impulse(int v __unused) return; power = 20 + 100 * dist; percent = 100 * power / Ship.energy + 0.5; - if (percent >= 85) - { + if (percent >= 85) { printf("Scotty: That would consume %d%% of our remaining energy.\n", percent); if (!getynpar("Are you sure that is wise")) @@ -77,8 +76,7 @@ impulse(int v __unused) } time = dist / 0.095; percent = 100 * time / Now.time + 0.5; - if (percent >= 85) - { + if (percent >= 85) { printf("Spock: That would take %d%% of our remaining time.\n", percent); if (!getynpar("Are you sure that is wise")) diff --git a/trek/initquad.c b/trek/initquad.c index 72de8d63..0e8dbdc3 100644 --- a/trek/initquad.c +++ b/trek/initquad.c @@ -1,4 +1,4 @@ -/* $NetBSD: initquad.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: initquad.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)initquad.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: initquad.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: initquad.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -78,8 +78,7 @@ initquad(int f) nholes = q->holes; /* have we blundered into a battle zone w/ shields down? */ - if (Etc.nkling > 0 && !f) - { + if (Etc.nkling > 0 && !f) { printf("Condition RED\n"); Ship.cond = RED; if (!damaged(COMPUTER)) @@ -95,8 +94,7 @@ initquad(int f) Sect[Ship.sectx][Ship.secty] = Ship.ship; /* initialize Klingons */ - for (i = 0; i < Etc.nkling; i++) - { + for (i = 0; i < Etc.nkling; i++) { sector(&rx, &ry); Sect[rx][ry] = KLINGON; Etc.klingon[i].x = rx; @@ -107,8 +105,7 @@ initquad(int f) compkldist(1); /* initialize star base */ - if (nbases > 0) - { + if (nbases > 0) { sector(&rx, &ry); Sect[rx][ry] = BASE; Etc.starbase.x = rx; @@ -116,23 +113,20 @@ initquad(int f) } /* initialize inhabited starsystem */ - if (q->qsystemname != 0) - { + if (q->qsystemname != 0) { sector(&rx, &ry); Sect[rx][ry] = INHABIT; nstars -= 1; } /* initialize black holes */ - for (i = 0; i < nholes; i++) - { + for (i = 0; i < nholes; i++) { sector(&rx, &ry); Sect[rx][ry] = HOLE; } /* initialize stars */ - for (i = 0; i < nstars; i++) - { + for (i = 0; i < nstars; i++) { sector(&rx, &ry); Sect[rx][ry] = STAR; } @@ -145,8 +139,7 @@ sector(int *x, int *y) { int i, j; - do - { + do { i = ranf(NSECTS); j = ranf(NSECTS); } while (Sect[i][j] != EMPTY); diff --git a/trek/kill.c b/trek/kill.c index 6165cab9..51818827 100644 --- a/trek/kill.c +++ b/trek/kill.c @@ -1,4 +1,4 @@ -/* $NetBSD: kill.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: kill.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)kill.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: kill.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: kill.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -75,8 +75,7 @@ killk(int ix, int iy) /* find the Klingon in the Klingon list */ for (i = 0; i < Etc.nkling; i++) - if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) - { + if (ix == Etc.klingon[i].x && iy == Etc.klingon[i].y) { /* purge him from the list */ Etc.nkling -= 1; for (; i < Etc.nkling; i++) @@ -122,17 +121,13 @@ killb(int qx, int qy) if (qx == b->x && qy == b->y) break; *b = Now.base[Now.bases]; - if (qx == Ship.quadx && qy == Ship.quady) - { + if (qx == Ship.quadx && qy == Ship.quady) { Sect[Etc.starbase.x][Etc.starbase.y] = EMPTY; if (Ship.cond == DOCKED) undock(0); printf("Starbase at %d,%d destroyed\n", Etc.starbase.x, Etc.starbase.y); - } - else - { - if (!damaged(SSRADIO)) - { + } else { + if (!damaged(SSRADIO)) { printf("Uhura: Starfleet command reports that the starbase in\n"); printf(" quadrant %d,%d has been destroyed\n", qx, qy); } @@ -156,8 +151,7 @@ kills(int x, int y, int f) struct event *e; const char *name; - if (f) - { + if (f) { /* current quadrant */ q = &Quad[Ship.quadx][Ship.quady]; Sect[x][y] = EMPTY; @@ -168,14 +162,11 @@ kills(int x, int y, int f) name, x, y); if (f < 0) Game.killinhab += 1; - } - else - { + } else { /* different quadrant */ q = &Quad[x][y]; } - if (q->qsystemname & Q_DISTRESSED) - { + if (q->qsystemname & Q_DISTRESSED) { /* distressed starsystem */ e = &Event[q->qsystemname & Q_SYSTEM]; printf("Distress call for %s invalidated\n", @@ -202,16 +193,13 @@ killd(int x, int y, int f) struct quad *q; q = &Quad[x][y]; - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->x != x || e->y != y) continue; - switch (e->evcode) - { + switch (e->evcode) { case E_KDESB: - if (f) - { + if (f) { printf("Distress call for starbase in %d,%d nullified\n", x, y); unschedule(e); @@ -220,15 +208,12 @@ killd(int x, int y, int f) case E_ENSLV: case E_REPRO: - if (f) - { + if (f) { printf("Distress call for %s in quadrant %d,%d nullified\n", Systemname[e->systemname], x, y); q->qsystemname = e->systemname; unschedule(e); - } - else - { + } else { e->evcode |= E_GHOST; } } diff --git a/trek/klmove.c b/trek/klmove.c index b08b13bd..328b8a86 100644 --- a/trek/klmove.c +++ b/trek/klmove.c @@ -1,4 +1,4 @@ -/* $NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: klmove.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)klmove.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: klmove.c,v 1.7 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: klmove.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -82,8 +82,7 @@ klmove(int fl) if (Trace) printf("klmove: fl = %d, Etc.nkling = %d\n", fl, Etc.nkling); #endif - for (n = 0; n < Etc.nkling; n++) - { + for (n = 0; n < Etc.nkling; n++) { k = &Etc.klingon[n]; i = 100; if (fl) @@ -103,8 +102,7 @@ klmove(int fl) bigger = 1.0; dx = dx / bigger + 0.5; dy = dy / bigger + 0.5; - if (motion < 0) - { + if (motion < 0) { motion = -motion; dx = -dx; dy = -dy; @@ -113,12 +111,10 @@ klmove(int fl) /* try to move the klingon */ nextx = k->x; nexty = k->y; - for (; motion > 0; motion--) - { + for (; motion > 0; motion--) { lookx = nextx + dx; looky = nexty + dy; - if (lookx < 0 || lookx >= NSECTS || looky < 0 || looky >= NSECTS) - { + if (lookx < 0 || lookx >= NSECTS || looky < 0 || looky >= NSECTS) { /* new quadrant */ qx = Ship.quadx; qy = Ship.quady; @@ -135,8 +131,7 @@ klmove(int fl) if (qx < 0 || qx >= NQUADS || qy < 0 || qy >= NQUADS || Quad[qx][qy].stars < 0 || Quad[qx][qy].klings > MAXKLQUAD - 1) break; - if (!damaged(SRSCAN)) - { + if (!damaged(SRSCAN)) { printf("Klingon at %d,%d escapes to quadrant %d,%d\n", k->x, k->y, qx, qy); motion = Quad[qx][qy].scanned; @@ -154,17 +149,14 @@ klmove(int fl) k = 0; break; } - if (Sect[lookx][looky] != EMPTY) - { + if (Sect[lookx][looky] != EMPTY) { lookx = nextx + fudgex; if (lookx < 0 || lookx >= NSECTS) lookx = nextx + dx; - if (Sect[lookx][looky] != EMPTY) - { + if (Sect[lookx][looky] != EMPTY) { fudgex = -fudgex; looky = nexty + fudgey; - if (looky < 0 || looky >= NSECTS || Sect[lookx][looky] != EMPTY) - { + if (looky < 0 || looky >= NSECTS || Sect[lookx][looky] != EMPTY) { fudgey = -fudgey; break; } @@ -173,8 +165,7 @@ klmove(int fl) nextx = lookx; nexty = looky; } - if (k && (k->x != nextx || k->y != nexty)) - { + if (k && (k->x != nextx || k->y != nexty)) { if (!damaged(SRSCAN)) printf("Klingon at %d,%d moves to %d,%d\n", k->x, k->y, nextx, nexty); diff --git a/trek/lose.c b/trek/lose.c index eae32a91..974b1776 100644 --- a/trek/lose.c +++ b/trek/lose.c @@ -1,4 +1,4 @@ -/* $NetBSD: lose.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: lose.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lose.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lose.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: lose.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -54,8 +54,7 @@ __RCSID("$NetBSD: lose.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); extern jmp_buf env; -const char *const Losemsg[] = -{ +const char *const Losemsg[] = { "You ran out of time", "You ran out of energy", "You have been destroyed", @@ -77,9 +76,7 @@ lose(int why) Game.killed = 1; sleep(1); printf("\n%s\n", Losemsg[why - 1]); - switch (why) - { - + switch (why) { case L_NOTIME: Game.killed = 0; break; diff --git a/trek/lrscan.c b/trek/lrscan.c index 04138712..78b53ed9 100644 --- a/trek/lrscan.c +++ b/trek/lrscan.c @@ -1,4 +1,4 @@ -/* $NetBSD: lrscan.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: lrscan.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lrscan.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lrscan.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: lrscan.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -60,15 +60,13 @@ lrscan(int v __unused) int i, j; struct quad *q; - if (check_out(LRSCAN)) - { + if (check_out(LRSCAN)) { return; } printf("Long range scan for quadrant %d,%d\n\n", Ship.quadx, Ship.quady); /* print the header on top */ - for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) - { + for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) { if (j < 0 || j >= NQUADS) printf(" "); else @@ -76,11 +74,9 @@ lrscan(int v __unused) } /* scan the quadrants */ - for (i = Ship.quadx - 1; i <= Ship.quadx + 1; i++) - { + for (i = Ship.quadx - 1; i <= Ship.quadx + 1; i++) { printf("\n -------------------\n"); - if (i < 0 || i >= NQUADS) - { + if (i < 0 || i >= NQUADS) { /* negative energy barrier */ printf(" ! * ! * ! * !"); continue; @@ -88,17 +84,14 @@ lrscan(int v __unused) /* print the left hand margin */ printf("%1d !", i); - for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) - { - if (j < 0 || j >= NQUADS) - { + for (j = Ship.quady - 1; j <= Ship.quady + 1; j++) { + if (j < 0 || j >= NQUADS) { /* negative energy barrier again */ printf(" * !"); continue; } q = &Quad[i][j]; - if (q->stars < 0) - { + if (q->stars < 0) { /* supernova */ printf(" /// !"); q->scanned = 1000; diff --git a/trek/main.c b/trek/main.c index 253b8ac3..f82a18d2 100644 --- a/trek/main.c +++ b/trek/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: main.c,v 1.16 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.15 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: main.c,v 1.16 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -182,16 +182,13 @@ main(int argc, char **argv) opencode = 'w'; prio = PRIO; - if (tcgetattr(1, &argp) == 0) - { + if (tcgetattr(1, &argp) == 0) { if (cfgetispeed(&argp) < B1200) Etc.fast++; } - while (ac > 1 && av[0][0] == '-') - { - switch (av[0][1]) - { + while (ac > 1 && av[0][0] == '-') { + switch (av[0][1]) { case 'a': /* append to log file */ opencode = 'a'; break; @@ -228,20 +225,19 @@ main(int argc, char **argv) } if (ac > 2) errx(1, "arg count"); - /* + /* if (ac > 1) f_log = fopen(av[0], opencode); - */ + */ printf("\n * * * S T A R T R E K * * *\n\nPress return to continue.\n"); - if (setjmp(env)) - { + if (setjmp(env)) { if ( !getynpar("Another game") ) exit(0); } - do - { + + do { setup(); play(); } while (getynpar("Another game")); diff --git a/trek/move.c b/trek/move.c index 2b772821..14edb4fa 100644 --- a/trek/move.c +++ b/trek/move.c @@ -1,4 +1,4 @@ -/* $NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: move.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: move.c,v 1.8 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: move.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -122,13 +122,11 @@ move(int ramflag, int course, double time, double speed) Now.eventptr[E_LRTB], Now.eventptr[E_LRTB]->evcode, Now.eventptr[E_LRTB]->date, evtime); #endif - if (time > evtime && Etc.nkling < 3) - { + if (time > evtime && Etc.nkling < 3) { /* then we got a LRTB */ evtime += 0.005; time = evtime; - } - else + } else evtime = -1.0e50; dist = time * speed; @@ -144,16 +142,14 @@ move(int ramflag, int course, double time, double speed) #endif Move.free = 0; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { ix = (x += dx); iy = (y += dy); #ifdef xTRACE if (Trace) printf("ix = %d, x = %.2f, iy = %d, y = %.2f\n", ix, x, iy, y); #endif - if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize) - { + if (x < 0.0 || y < 0.0 || x >= sectsize || y >= sectsize) { /* enter new quadrant */ dx = Ship.quadx * NSECTS + Ship.sectx + dx * xn; dy = Ship.quady * NSECTS + Ship.secty + dy * xn; @@ -190,11 +186,9 @@ move(int ramflag, int course, double time, double speed) n = 0; break; } - if (Sect[ix][iy] != EMPTY) - { + if (Sect[ix][iy] != EMPTY) { /* we just hit something */ - if (!damaged(COMPUTER) && ramflag <= 0) - { + if (!damaged(COMPUTER) && ramflag <= 0) { ix = x - dx; iy = y - dy; printf("Computer reports navigation error; %s stopped at %d,%d\n", @@ -203,8 +197,7 @@ move(int ramflag, int course, double time, double speed) break; } /* test for a black hole */ - if (Sect[ix][iy] == HOLE) - { + if (Sect[ix][iy] == HOLE) { /* get dumped elsewhere in the galaxy */ dumpme(1); initquad(0); @@ -215,14 +208,15 @@ move(int ramflag, int course, double time, double speed) break; } } - if (n > 0) - { + if (n > 0) { dx = Ship.sectx - ix; dy = Ship.secty - iy; dist = sqrt(dx * dx + dy * dy) / NSECTS; time = dist / speed; - if (evtime > time) - time = evtime; /* spring the LRTB trap */ + if (evtime > time) { + /* spring the LRTB trap */ + time = evtime; + } Ship.sectx = ix; Ship.secty = iy; } diff --git a/trek/nova.c b/trek/nova.c index 8a417d30..eb24a284 100644 --- a/trek/nova.c +++ b/trek/nova.c @@ -1,4 +1,4 @@ -/* $NetBSD: nova.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: nova.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)nova.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: nova.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: nova.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -63,8 +63,7 @@ nova(int x, int y) if (Sect[x][y] != STAR || Quad[Ship.quadx][Ship.quady].stars < 0) return; - if (ranf(100) < 15) - { + if (ranf(100) < 15) { printf("Spock: Star at %d,%d failed to nova.\n", x, y); return; } @@ -74,26 +73,22 @@ nova(int x, int y) } printf("Spock: Star at %d,%d gone nova\n", x, y); - if (ranf(4) != 0) + if (ranf(4) != 0) { Sect[x][y] = EMPTY; - else - { + } else { Sect[x][y] = HOLE; Quad[Ship.quadx][Ship.quady].holes += 1; } Quad[Ship.quadx][Ship.quady].stars -= 1; Game.kills += 1; - for (i = x - 1; i <= x + 1; i++) - { + for (i = x - 1; i <= x + 1; i++) { if (i < 0 || i >= NSECTS) continue; - for (j = y - 1; j <= y + 1; j++) - { + for (j = y - 1; j <= y + 1; j++) { if (j < 0 || j >= NSECTS) continue; se = Sect[i][j]; - switch (se) - { + switch (se) { case EMPTY: case HOLE: diff --git a/trek/phaser.c b/trek/phaser.c index 8931cdb5..e3cfbfdc 100644 --- a/trek/phaser.c +++ b/trek/phaser.c @@ -1,4 +1,4 @@ -/* $NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: phaser.c,v 1.13 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)phaser.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: phaser.c,v 1.13 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -76,15 +76,13 @@ __RCSID("$NetBSD: phaser.c,v 1.12 2009/05/24 20:39:43 dholland Exp $"); ** Uses trace flag 30 */ -struct cvntab Matab[] = -{ +struct cvntab Matab[] = { { "m", "anual", (cmdfun) 1, 0 }, { "a", "utomatic", (cmdfun) 0, 0 }, { NULL, NULL, NULL, 0 } }; -struct banks -{ +struct banks { int units; double angle; double spread; @@ -122,8 +120,7 @@ phaser(int v __unused) printf("Sulu: Captain, we cannot fire through shields.\n"); return; } - if (Ship.cloaked) - { + if (Ship.cloaked) { printf("Sulu: Captain, surely you must realize that we cannot fire\n"); printf(" phasers with the cloaking device up.\n"); return; @@ -131,30 +128,23 @@ phaser(int v __unused) /* decide if we want manual or automatic mode */ manual = 0; - if (testnl()) - { - if (damaged(COMPUTER)) - { + if (testnl()) { + if (damaged(COMPUTER)) { printf("%s", Device[COMPUTER].name); manual++; + } else if (damaged(SRSCAN)) { + printf("%s", Device[SRSCAN].name); + manual++; } - else - if (damaged(SRSCAN)) - { - printf("%s", Device[SRSCAN].name); - manual++; - } if (manual) printf(" damaged, manual mode selected\n"); } - if (!manual) - { + if (!manual) { ptr = getcodpar("Manual or automatic", Matab); manual = (long) ptr->value; } - if (!manual && damaged(COMPUTER)) - { + if (!manual && damaged(COMPUTER)) { printf("Computer damaged, manual selected\n"); skiptonl(0); manual++; @@ -164,16 +154,13 @@ phaser(int v __unused) flag = 1; for (i = 0; i < NBANKS; i++) bank[i].units = 0; - if (manual) - { + if (manual) { /* collect manual mode statistics */ - while (flag) - { + while (flag) { printf("%d units available\n", Ship.energy); extra = 0; flag = 0; - for (i = 0; i < NBANKS; i++) - { + for (i = 0; i < NBANKS; i++) { b = &bank[i]; printf("\nBank %d:\n", i); hit = getintpar("units"); @@ -182,8 +169,7 @@ phaser(int v __unused) if (hit == 0) break; extra += hit; - if (extra > Ship.energy) - { + if (extra > Ship.energy) { printf("available energy exceeded. "); skiptonl(0); flag++; @@ -201,23 +187,19 @@ phaser(int v __unused) Ship.energy -= extra; } extra = 0; - } - else - { + } else { /* automatic distribution of power */ if (Etc.nkling <= 0) { printf("Sulu: But there are no Klingons in this quadrant\n"); return; } printf("Phasers locked on target. "); - while (flag) - { + while (flag) { printf("%d units available\n", Ship.energy); hit = getintpar("Units to fire"); if (hit <= 0) return; - if (hit > Ship.energy) - { + if (hit > Ship.energy) { printf("available energy exceeded. "); skiptonl(0); continue; @@ -229,8 +211,7 @@ phaser(int v __unused) if (n > NBANKS) n = NBANKS; tot = n * (n + 1) / 2; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { k = &Etc.klingon[i]; b = &bank[i]; distfactor = k->dist; @@ -245,8 +226,7 @@ phaser(int v __unused) b->spread = 0.0; b->units = ((n - i) / tot) * extra; #ifdef xTRACE - if (Trace) - { + if (Trace) { printf("b%d hr%d u%d df%.2f af%.2f\n", i, hitreqd[i], b->units, distfactor, anglefactor); @@ -254,24 +234,20 @@ phaser(int v __unused) #endif extra -= b->units; hit = b->units - hitreqd[i]; - if (hit > 0) - { + if (hit > 0) { extra += hit; b->units -= hit; } } /* give out any extra energy we might have around */ - if (extra > 0) - { - for (i = 0; i < n; i++) - { + if (extra > 0) { + for (i = 0; i < n; i++) { b = &bank[i]; hit = hitreqd[i] - b->units; if (hit <= 0) continue; - if (hit >= extra) - { + if (hit >= extra) { b->units += extra; extra = 0; break; @@ -286,10 +262,8 @@ phaser(int v __unused) } #ifdef xTRACE - if (Trace) - { - for (i = 0; i < NBANKS; i++) - { + if (Trace) { + for (i = 0; i < NBANKS; i++) { b = &bank[i]; printf("b%d u%d", i, b->units); if (b->units > 0) @@ -302,18 +276,15 @@ phaser(int v __unused) /* actually fire the shots */ Move.free = 0; - for (i = 0; i < NBANKS; i++) - { + for (i = 0; i < NBANKS; i++) { b = &bank[i]; - if (b->units <= 0) - { + if (b->units <= 0) { continue; } printf("\nPhaser bank %d fires:\n", i); n = Etc.nkling; k = Etc.klingon; - for (j = 0; j < n; j++) - { + for (j = 0; j < n; j++) { if (b->units <= 0) break; /* @@ -355,8 +326,7 @@ phaser(int v __unused) dy = k->y - Ship.secty; anglefactor = atan2(dy, dx) - b->angle; anglefactor = cos((anglefactor * b->spread) + GAMMA); - if (anglefactor < 0.0) - { + if (anglefactor < 0.0) { k++; continue; } @@ -367,8 +337,7 @@ phaser(int v __unused) printf(" at %d,%d", k->x, k->y); printf("\n"); b->units -= hit; - if (k->power <= 0) - { + if (k->power <= 0) { killk(k->x, k->y); continue; } diff --git a/trek/play.c b/trek/play.c index 9553ee8b..9d8e6347 100644 --- a/trek/play.c +++ b/trek/play.c @@ -1,4 +1,4 @@ -/* $NetBSD: play.c,v 1.10 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: play.c,v 1.11 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: play.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: play.c,v 1.11 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -56,8 +56,7 @@ __RCSID("$NetBSD: play.c,v 1.10 2009/05/24 19:18:44 dholland Exp $"); extern jmp_buf env; -const struct cvntab Comtab[] = -{ +const struct cvntab Comtab[] = { { "abandon", "", abandon, 0 }, { "ca", "pture", capture, 0 }, { "cl", "oak", shield, -1 }, @@ -97,8 +96,7 @@ play(void) { const struct cvntab *r; - while (1) - { + while (1) { Move.free = 1; Move.time = 0.0; Move.shldchg = 0; diff --git a/trek/ram.c b/trek/ram.c index 7e6c8781..ee706a25 100644 --- a/trek/ram.c +++ b/trek/ram.c @@ -1,4 +1,4 @@ -/* $NetBSD: ram.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: ram.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ram.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: ram.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: ram.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -61,8 +61,7 @@ ram(int ix, int iy) printf("\07RED ALERT\07: collision imminent\n"); c = Sect[ix][iy]; - switch (c) - { + switch (c) { case KLINGON: printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy); @@ -94,8 +93,7 @@ ram(int ix, int iy) printf("McCoy: Take it easy Jim; we had %d casualties.\n", i); /* damage devices with an 80% probability */ - for (i = 0; i < NDEV; i++) - { + for (i = 0; i < NDEV; i++) { if (ranf(100) < 20) continue; damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]); diff --git a/trek/rest.c b/trek/rest.c index 1478e9b4..1cac69c7 100644 --- a/trek/rest.c +++ b/trek/rest.c @@ -1,4 +1,4 @@ -/* $NetBSD: rest.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: rest.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)rest.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: rest.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: rest.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -68,8 +68,7 @@ rest(int v __unused) if (t <= 0.0) return; percent = 100 * t / Now.time + 0.5; - if (percent >= 70) - { + if (percent >= 70) { printf("Spock: That would take %d%% of our remaining time.\n", percent); if (!getynpar("Are you really certain that is wise")) diff --git a/trek/schedule.c b/trek/schedule.c index 70e6d160..286eb252 100644 --- a/trek/schedule.c +++ b/trek/schedule.c @@ -1,4 +1,4 @@ -/* $NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: schedule.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)schedule.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: schedule.c,v 1.9 2009/05/24 20:39:43 dholland Exp $"); +__RCSID("$NetBSD: schedule.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -62,8 +62,7 @@ schedule(int type, double offset, int x, int y, int z) double date; date = Now.date + offset; - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode) continue; diff --git a/trek/score.c b/trek/score.c index 553f0a2c..c19c7cbc 100644 --- a/trek/score.c +++ b/trek/score.c @@ -1,4 +1,4 @@ -/* $NetBSD: score.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: score.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: score.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: score.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -70,13 +70,11 @@ score(void) s += (t = -400 * r); if (t != 0) printf("Penalty for %d klingons remaining\t%6d\n", Now.klings, t); - if (Move.endgame > 0) - { + if (Move.endgame > 0) { s += (t = 100 * (u = Game.skill)); printf("Bonus for winning a %s%s game\t\t%6d\n", Skitab[u - 1].abrev, Skitab[u - 1].full, t); } - if (Game.killed) - { + if (Game.killed) { s -= 500; printf("Penalty for getting killed\t\t -500\n"); } @@ -92,8 +90,7 @@ score(void) s += (t = -150 * (u = Game.killinhab)); if (t != 0) printf("%d inhabited starsystems destroyed\t%6d\n", u, t); - if (Ship.ship != ENTERPRISE) - { + if (Ship.ship != ENTERPRISE) { s -= 200; printf("penalty for abandoning ship\t\t -200\n"); } diff --git a/trek/setup.c b/trek/setup.c index 715a3889..249f1497 100644 --- a/trek/setup.c +++ b/trek/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.11 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: setup.c,v 1.12 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: setup.c,v 1.11 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: setup.c,v 1.12 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -59,8 +59,7 @@ __RCSID("$NetBSD: setup.c,v 1.11 2009/05/24 19:18:44 dholland Exp $"); ** Game restart and tournament games are handled here. */ -const struct cvntab Lentab[] = -{ +const struct cvntab Lentab[] = { { "s", "hort", (cmdfun)1, 0 }, { "m", "edium", (cmdfun)2, 0 }, { "l", "ong", (cmdfun)4, 0 }, @@ -68,8 +67,7 @@ const struct cvntab Lentab[] = { NULL, NULL, NULL, 0 } }; -const struct cvntab Skitab[] = -{ +const struct cvntab Skitab[] = { { "n", "ovice", (cmdfun)1, 0 }, { "f", "air", (cmdfun)2, 0 }, { "g", "ood", (cmdfun)3, 0 }, @@ -91,12 +89,10 @@ setup(void) struct quad *q; struct event *e; - while (1) - { + while (1) { r = getcodpar("What length game", Lentab); Game.length = (long) r->value; - if (Game.length == 0) - { + if (Game.length == 0) { if (restartgame()) continue; return; @@ -107,8 +103,7 @@ setup(void) Game.skill = (long) r->value; Game.tourn = 0; getstrpar("Enter a password", Game.passwd, 14, 0); - if (strcmp(Game.passwd, "tournament") == 0) - { + if (strcmp(Game.passwd, "tournament") == 0) { getstrpar("Enter tournament code", Game.passwd, 14, 0); Game.tourn = 1; d = 0; @@ -209,8 +204,7 @@ setup(void) Param.navigcrud[1] = 0.75; Param.cloakenergy = 1000; Param.energylow = 1000; - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; e->date = TOOLARGE; e->evcode = 0; @@ -232,9 +226,8 @@ setup(void) Move.endgame = 0; /* setup stars */ - for (i = 0; i < NQUADS; i++) - for (j = 0; j < NQUADS; j++) - { + for (i = 0; i < NQUADS; i++) { + for (j = 0; j < NQUADS; j++) { short s5; q = &Quad[i][j]; q->klings = q->bases = 0; @@ -245,12 +238,11 @@ setup(void) q->holes = q->holes > s5 ? q->holes - s5 : 0; q->qsystemname = 0; } + } /* select inhabited starsystems */ - for (d = 1; d < NINHAB; d++) - { - do - { + for (d = 1; d < NINHAB; d++) { + do { i = ranf(NQUADS); j = ranf(NQUADS); q = &Quad[i][j]; @@ -259,10 +251,8 @@ setup(void) } /* position starbases */ - for (i = 0; i < Param.bases; i++) - { - while (1) - { + for (i = 0; i < Param.bases; i++) { + while (1) { ix = ranf(NQUADS); iy = ranf(NQUADS); q = &Quad[ix][iy]; @@ -275,21 +265,18 @@ setup(void) Now.base[i].y = iy; q->scanned = 1001; /* start the Enterprise near starbase */ - if (i == 0) - { + if (i == 0) { Ship.quadx = ix; Ship.quady = iy; } } /* position klingons */ - for (i = Param.klings; i > 0; ) - { + for (i = Param.klings; i > 0; ) { klump = ranf(4) + 1; if (klump > i) klump = i; - while (1) - { + while (1) { ix = ranf(NQUADS); iy = ranf(NQUADS); q = &Quad[ix][iy]; diff --git a/trek/shield.c b/trek/shield.c index c74444b0..d1030dbf 100644 --- a/trek/shield.c +++ b/trek/shield.c @@ -1,4 +1,4 @@ -/* $NetBSD: shield.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: shield.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: shield.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: shield.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -59,8 +59,7 @@ __RCSID("$NetBSD: shield.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); ** so you get partial hits. */ -const struct cvntab Udtab[] = -{ +const struct cvntab Udtab[] = { { "u", "p", (cmdfun)1, 0 }, { "d", "own", (cmdfun)0, 0 }, { NULL, NULL, NULL, 0 } @@ -78,8 +77,7 @@ shield(int f) if (f > 0 && (Ship.shldup || damaged(SRSCAN))) return; - if (f < 0) - { + if (f < 0) { /* cloaking device */ if (Ship.ship == QUEENE) { printf("Ye Faire Queene does not have the cloaking device.\n"); @@ -90,9 +88,7 @@ shield(int f) ind = CLOAK; dev3 = "it"; stat = &Ship.cloaked; - } - else - { + } else { /* shields */ device = "Shields"; dev2 = "are"; @@ -100,24 +96,19 @@ shield(int f) ind = SHIELD; stat = &Ship.shldup; } - if (damaged(ind)) - { + if (damaged(ind)) { if (f <= 0) out(ind); return; } - if (Ship.cond == DOCKED) - { + if (Ship.cond == DOCKED) { printf("%s %s down while docked\n", device, dev2); return; } - if (f <= 0 && !testnl()) - { + if (f <= 0 && !testnl()) { r = getcodpar("Up or down", Udtab); i = (long) r->value; - } - else - { + } else { if (*stat) (void)sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); else @@ -126,8 +117,7 @@ shield(int f) return; i = !*stat; } - if (*stat == i) - { + if (*stat == i) { printf("%s already ", device); if (i) printf("up\n"); diff --git a/trek/snova.c b/trek/snova.c index 073f10de..2b04ac74 100644 --- a/trek/snova.c +++ b/trek/snova.c @@ -1,4 +1,4 @@ -/* $NetBSD: snova.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: snova.c,v 1.7 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)snova.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: snova.c,v 1.6 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: snova.c,v 1.7 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -75,23 +75,19 @@ snova(int x, int y) f = 0; ix = x; - if (ix < 0) - { + if (ix < 0) { /* choose a quadrant */ - while (1) - { + while (1) { qx = ranf(NQUADS); qy = ranf(NQUADS); q = &Quad[qx][qy]; if (q->stars > 0) break; } - if (Ship.quadx == qx && Ship.quady == qy) - { + if (Ship.quadx == qx && Ship.quady == qy) { /* select a particular star */ n = ranf(q->stars); - for (ix = 0; ix < NSECTS; ix++) - { + for (ix = 0; ix < NSECTS; ix++) { for (iy = 0; iy < NSECTS; iy++) if (Sect[ix][iy] == STAR || Sect[ix][iy] == INHABIT) if ((n -= 1) <= 0) @@ -101,9 +97,7 @@ snova(int x, int y) } f = 1; } - } - else - { + } else { /* current quadrant */ iy = y; qx = Ship.quadx; @@ -111,25 +105,20 @@ snova(int x, int y) q = &Quad[qx][qy]; f = 1; } - if (f) - { + if (f) { /* supernova is in same quadrant as Enterprise */ printf("\nRED ALERT: supernova occuring at %d,%d\n", ix, iy); dx = ix - Ship.sectx; dy = iy - Ship.secty; - if (dx * dx + dy * dy <= 2) - { + if (dx * dx + dy * dy <= 2) { printf("*** Emergency override attem"); sleep(1); printf("\n"); lose(L_SNOVA); } q->scanned = 1000; - } - else - { - if (!damaged(SSRADIO)) - { + } else { + if (!damaged(SSRADIO)) { q->scanned = 1000; printf("\nUhura: Captain, Starfleet Command reports a supernova\n"); printf(" in quadrant %d,%d. Caution is advised\n", qx, qy); @@ -140,22 +129,20 @@ snova(int x, int y) dx = q->klings; dy = q->stars; Now.klings -= dx; - if (x >= 0) - { + if (x >= 0) { /* Enterprise caused supernova */ Game.kills += dy; if (q->bases) killb(qx, qy); Game.killk += dx; - } - else + } else { if (q->bases) killb(qx, qy); + } killd(qx, qy, (x >= 0)); q->stars = -1; q->klings = 0; - if (Now.klings <= 0) - { + if (Now.klings <= 0) { printf("Lucky devil, that supernova destroyed the last klingon\n"); win(); } diff --git a/trek/srscan.c b/trek/srscan.c index a1f45f79..df3010ab 100644 --- a/trek/srscan.c +++ b/trek/srscan.c @@ -1,4 +1,4 @@ -/* $NetBSD: srscan.c,v 1.7 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: srscan.c,v 1.8 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)srscan.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: srscan.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: srscan.c,v 1.8 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -57,8 +57,7 @@ __RCSID("$NetBSD: srscan.c,v 1.7 2009/05/24 19:18:44 dholland Exp $"); ** The current quadrant is filled in on the computer chart. */ -const char *const Color[4] = -{ +const char *const Color[4] = { "GREEN", "DOCKED", "YELLOW", @@ -75,41 +74,34 @@ srscan(int f) struct quad *q = NULL; const struct cvntab *p; - if (f >= 0 && check_out(SRSCAN)) - { + if (f >= 0 && check_out(SRSCAN)) { return; } - if (f) + if (f) { statinfo = 1; - else - { + } else { if (!testnl()) Etc.statreport = getynpar("status report"); statinfo = Etc.statreport; } - if (f > 0) - { + if (f > 0) { Etc.statreport = 1; if (!Etc.fast) return; } - if (f >= 0) - { + if (f >= 0) { printf("\nShort range sensor scan\n"); q = &Quad[Ship.quadx][Ship.quady]; q->scanned = q->klings * 100 + q->bases * 10 + q->stars; printf(" "); - for (i = 0; i < NSECTS; i++) - { + for (i = 0; i < NSECTS; i++) { printf("%d ", i); } printf("\n"); } - for (i = 0; i < NSECTS; i++) - { - if (f >= 0) - { + for (i = 0; i < NSECTS; i++) { + if (f >= 0) { printf("%d ", i); for (j = 0; j < NSECTS; j++) printf("%c ", Sect[i][j]); @@ -118,8 +110,7 @@ srscan(int f) printf(" "); } if (statinfo) - switch (i) - { + switch (i) { case 0: printf("stardate %.2f", Now.date); break; @@ -157,8 +148,7 @@ srscan(int f) break; case 9: printf("life support "); - if (damaged(LIFESUP)) - { + if (damaged(LIFESUP)) { printf("damaged, reserves = %.2f", Ship.reserves); break; } @@ -167,8 +157,7 @@ srscan(int f) } printf("\n"); } - if (f < 0) - { + if (f < 0) { printf("current crew %d\n", Ship.crew); printf("brig space %d\n", Ship.brigfree); printf("Klingon power %d\n", Param.klingpwr); diff --git a/trek/torped.c b/trek/torped.c index db22cafe..3f655ae8 100644 --- a/trek/torped.c +++ b/trek/torped.c @@ -1,4 +1,4 @@ -/* $NetBSD: torped.c,v 1.11 2009/05/24 20:43:09 dholland Exp $ */ +/* $NetBSD: torped.c,v 1.12 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)torped.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: torped.c,v 1.11 2009/05/24 20:43:09 dholland Exp $"); +__RCSID("$NetBSD: torped.c,v 1.12 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -79,15 +79,13 @@ torped(int v __unused) int burst; int n; - if (Ship.cloaked) - { + if (Ship.cloaked) { printf("Federation regulations do not permit attack while cloaked.\n"); return; } if (check_out(TORPED)) return; - if (Ship.torped <= 0) - { + if (Ship.torped <= 0) { printf("All photon torpedos expended\n"); return; } @@ -99,27 +97,21 @@ torped(int v __unused) burst = -1; /* need at least three torpedoes for a burst */ - if (Ship.torped < 3) - { + if (Ship.torped < 3) { printf("No-burst mode selected\n"); burst = 0; - } - else - { + } else { /* see if the user wants one */ - if (!testnl()) - { + if (!testnl()) { k = ungetc(cgetc(0), stdin); if (k >= '0' && k <= '9') burst = 1; } } - if (burst < 0) - { + if (burst < 0) { burst = getynpar("Do you want a burst"); } - if (burst) - { + if (burst) { burst = getintpar("burst angle"); if (burst <= 0) return; @@ -130,16 +122,15 @@ torped(int v __unused) } sectsize = NSECTS; n = -1; - if (burst) - { + if (burst) { n = 1; course -= burst; } - for (; n && n <= 3; n++) - { + for (; n && n <= 3; n++) { /* select a nice random course */ course2 = course + randcourse(n); - angle = course2 * 0.0174532925; /* convert to radians */ + /* convert to radians */ + angle = course2 * 0.0174532925; dx = -cos(angle); dy = sin(angle); bigger = fabs(dx); @@ -156,18 +147,15 @@ torped(int v __unused) if (n > 0) printf(", torpedo number %d", n); printf(":\n%6.1f\t%4.1f\n", x, y); - while (1) - { + while (1) { ix = x += dx; iy = y += dy; - if (x < 0.0 || x >= sectsize || y < 0.0 || y >= sectsize) - { + if (x < 0.0 || x >= sectsize || y < 0.0 || y >= sectsize) { printf("Torpedo missed\n"); break; } printf("%6.1f\t%4.1f\n", x, y); - switch (Sect[ix][iy]) - { + switch (Sect[ix][iy]) { case EMPTY: continue; @@ -176,13 +164,11 @@ torped(int v __unused) break; case KLINGON: - for (k = 0; k < Etc.nkling; k++) - { + for (k = 0; k < Etc.nkling; k++) { if (Etc.klingon[k].x != ix || Etc.klingon[k].y != iy) continue; Etc.klingon[k].power -= 500 + ranf(501); - if (Etc.klingon[k].power > 0) - { + if (Etc.klingon[k].power > 0) { printf("*** Hit on Klingon at %d,%d: extensive damages\n", ix, iy); break; @@ -236,21 +222,18 @@ randcourse(int n) int d; d = ((franf() + franf()) - 1.0) * 20; - if (abs(d) > 12) - { + if (abs(d) > 12) { printf("Photon tubes misfire"); if (n < 0) printf("\n"); else printf(" on torpedo %d\n", n); - if (ranf(2)) - { + if (ranf(2)) { damage(TORPED, 0.2 * abs(d) * (franf() + 1.0)); } d *= 1.0 + 2.0 * franf(); } - if (Ship.shldup || Ship.cond == DOCKED) - { + if (Ship.shldup || Ship.cond == DOCKED) { r = Ship.shield; r = 1.0 + r / Param.shield; if (Ship.cond == DOCKED) diff --git a/trek/trek.h b/trek/trek.h index 5617a977..a30d9976 100644 --- a/trek/trek.h +++ b/trek/trek.h @@ -1,4 +1,4 @@ -/* $NetBSD: trek.h,v 1.13 2009/05/24 20:39:43 dholland Exp $ */ +/* $NetBSD: trek.h,v 1.14 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -52,8 +52,8 @@ #define NQUADS 8 /* dimension of galazy in quadrants */ #define NINHAB 32 /* number of quadrants which are inhabited */ -struct quad /* definition for each quadrant */ -{ +/* definition for each quadrant */ +struct quad { 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 */ @@ -65,7 +65,8 @@ struct quad /* definition for each quadrant */ #define Q_DISTRESSED 0200 #define Q_SYSTEM 077 -/* systemname conventions: +/* + * systemname conventions: * 1 -> NINHAB index into Systemname table for live system. * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM * is the index into the Event table which will @@ -77,7 +78,7 @@ struct quad /* definition for each quadrant */ * -1 not yet scanned ("...") * 1000 supernova ("///") * 1001 starbase + ??? (".1.") -*/ + */ /* ascii names of systems */ extern const char *const Systemname[NINHAB]; @@ -121,8 +122,7 @@ extern char Sect[NSECTS][NSECTS]; #define SHUTTLE 13 /* shuttlecraft */ /* device names */ -struct device -{ +struct device { const char *name; /* device name */ const char *person; /* the person who fixes it */ }; @@ -148,14 +148,15 @@ extern const struct device Device[NDEV]; #define E_HIDDEN 0200 /* event unreportable because ssradio out */ #define E_EVENT 077 /* mask to get event code */ -struct event -{ +struct event { unsigned char x, y; /* coordinates */ double date; /* trap stardate */ char evcode; /* event type */ unsigned char systemname; /* starsystem name */ }; -/* systemname conventions: + +/* + * systemname conventions: * 1 -> NINHAB index into Systemname table for reported distress calls * * evcode conventions: @@ -165,14 +166,15 @@ struct event * 0 unallocated */ -#define MAXEVENTS 25 /* max number of concurrently pending events */ +/* max number of concurrently pending events */ +#define MAXEVENTS 25 -extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ +/* dynamic event list; one entry per pending event */ +extern struct event Event[MAXEVENTS]; /***************************** KLINGONS *******************************/ -struct kling -{ +struct kling { unsigned char x, y; /* coordinates */ int power; /* power left */ double dist; /* distance to Enterprise */ @@ -199,8 +201,7 @@ struct kling /* phaser banks */ #define NBANKS 6 /* number of phaser banks */ -struct xy -{ +struct xy { unsigned char x, y; /* coordinates */ }; @@ -212,8 +213,7 @@ struct xy /* information regarding the state of the starship */ -struct Ship_struct -{ +struct Ship_struct { double warp; /* warp factor */ double warp2; /* warp factor squared */ double warp3; /* warp factor cubed */ @@ -231,6 +231,7 @@ struct Ship_struct int sectx; /* sector x coord */ int secty; /* sector y coord */ unsigned char cond; /* condition code */ + /* sinsbad is set if SINS is working but not calibrated */ char sinsbad; /* Space Inertial Navigation System condition */ const char *shipname; /* name of current starship */ char ship; /* current starship */ @@ -238,11 +239,9 @@ struct Ship_struct }; extern struct Ship_struct Ship; -/* sinsbad is set if SINS is working but not calibrated */ /* game related information, mostly scoring */ -struct Game_struct -{ +struct Game_struct { int killk; /* number of klingons killed */ int deaths; /* number of deaths onboard Enterprise */ char negenbar; /* number of hits on negative energy barrier */ @@ -261,8 +260,7 @@ struct Game_struct extern struct Game_struct Game; /* per move information */ -struct Move_struct -{ +struct Move_struct { char free; /* set if a move is free */ char endgame; /* end of game flag */ char shldchg; /* set if shields changed this move */ @@ -273,8 +271,7 @@ struct Move_struct extern struct Move_struct Move; /* parametric information */ -struct Param_struct -{ +struct Param_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ @@ -310,8 +307,7 @@ extern struct Param_struct Param; /* Sum of damage probabilities must add to 1000 */ /* other information kept in a snapshot */ -struct Now_struct -{ +struct Now_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ @@ -324,8 +320,7 @@ struct Now_struct extern struct Now_struct Now; /* Other stuff, not dumped in a snapshot */ -struct Etc_struct -{ +struct Etc_struct { struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ short nkling; /* number of Klingons in this sector */ /* < 0 means automatic override mode */ diff --git a/trek/visual.c b/trek/visual.c index 258a3194..b0b2bb3e 100644 --- a/trek/visual.c +++ b/trek/visual.c @@ -1,4 +1,4 @@ -/* $NetBSD: visual.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: visual.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)visual.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: visual.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: visual.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -52,8 +52,7 @@ __RCSID("$NetBSD: visual.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); */ /* This struct[] has the delta x, delta y for particular directions */ -struct xy Visdelta[11] = -{ +struct xy Visdelta[11] = { { -1, -1 }, { -1, 0 }, { -1, 1 }, diff --git a/trek/warp.c b/trek/warp.c index f4e07d60..14e9e8bd 100644 --- a/trek/warp.c +++ b/trek/warp.c @@ -1,4 +1,4 @@ -/* $NetBSD: warp.c,v 1.9 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: warp.c,v 1.10 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)warp.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: warp.c,v 1.9 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: warp.c,v 1.10 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -89,8 +89,7 @@ warp(int fl, int c, double d) printf("%s is docked\n", Ship.shipname); return; } - if (damaged(WARP)) - { + if (damaged(WARP)) { out(WARP); return; } @@ -101,8 +100,7 @@ warp(int fl, int c, double d) /* check to see that we are not using an absurd amount of power */ power = (dist + 0.05) * Ship.warp3; percent = 100 * power / Ship.energy + 0.5; - if (percent >= 85) - { + if (percent >= 85) { printf("Scotty: That would consume %d%% of our remaining energy.\n", percent); if (!getynpar("Are you sure that is wise")) @@ -115,8 +113,7 @@ warp(int fl, int c, double d) /* check to see that that value is not ridiculous */ percent = 100 * time / Now.time + 0.5; - if (percent >= 85) - { + if (percent >= 85) { printf("Spock: That would take %d%% of our remaining time.\n", percent); if (!getynpar("Are you sure that is wise")) @@ -124,8 +121,7 @@ warp(int fl, int c, double d) } /* compute how far we will go if we get damages */ - if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) - { + if (Ship.warp > 6.0 && ranf(100) < 20 + 15 * (Ship.warp - 6.0)) { frac = franf(); dist *= frac; time *= frac; @@ -148,26 +144,22 @@ warp(int fl, int c, double d) sleep(2); printf("Crew experiencing extreme sensory distortion\n"); sleep(4); - if (ranf(100) >= 100 * dist) - { + if (ranf(100) >= 100 * dist) { printf("Equilibrium restored -- all systems normal\n"); return; } /* select a bizzare thing to happen to us */ percent = ranf(100); - if (percent < 70) - { + if (percent < 70) { /* time warp */ - if (percent < 35 || !Game.snap) - { + if (percent < 35 || !Game.snap) { /* positive time warp */ time = (Ship.warp - 8.0) * dist * (franf() + 1.0); Now.date += time; printf("Positive time portal entered -- it is now Stardate %.2f\n", Now.date); - for (i = 0; i < MAXEVENTS; i++) - { + for (i = 0; i < MAXEVENTS; i++) { percent = Event[i].evcode; if (percent == E_FIXDV || percent == E_LRTB) Event[i].date += time; diff --git a/trek/win.c b/trek/win.c index 31c3cfe9..2516113e 100644 --- a/trek/win.c +++ b/trek/win.c @@ -1,4 +1,4 @@ -/* $NetBSD: win.c,v 1.8 2009/05/24 19:18:44 dholland Exp $ */ +/* $NetBSD: win.c,v 1.9 2009/05/24 21:44:56 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: win.c,v 1.8 2009/05/24 19:18:44 dholland Exp $"); +__RCSID("$NetBSD: win.c,v 1.9 2009/05/24 21:44:56 dholland Exp $"); #endif #endif /* not lint */ @@ -74,13 +74,11 @@ win(void) /* decide if she gets a promotion */ if (Game.helps == 0 && Game.killb == 0 && Game.killinhab == 0 && 5 * Game.kills + Game.deaths < 100 && - s >= 1000 && Ship.ship == ENTERPRISE) - { + s >= 1000 && Ship.ship == ENTERPRISE) { printf("In fact, you are promoted one step in rank,\n"); - if (Game.skill >= 6) + if (Game.skill >= 6) { printf("to the exalted rank of Commodore Emeritus\n"); - else - { + } else { p = &Skitab[Game.skill - 1]; printf("from %s%s ", p->abrev, p->full); p++; -- cgit v1.2.3-56-ge451