diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-01-18 06:20:55 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-01-18 06:20:55 +0000 |
commit | 5134b02ec45c91ead7868a5b9f0cea921d296a7c (patch) | |
tree | 7a1b1519d35853321a624d35e4df02324a7b4e70 /games/sail | |
parent | 44f356a1eef9aaed32b992d35566e9f7e7d0db8c (diff) |
NetBSD merge with additional fixes from jsm28@cam.ac.uk. This game still
needs much more work.
Diffstat (limited to 'games/sail')
-rw-r--r-- | games/sail/:file | 10 | ||||
-rw-r--r-- | games/sail/:scene | 3 | ||||
-rw-r--r-- | games/sail/:ship | 4 | ||||
-rw-r--r-- | games/sail/:specs | 3 | ||||
-rw-r--r-- | games/sail/assorted.c | 95 | ||||
-rw-r--r-- | games/sail/dr_1.c | 77 | ||||
-rw-r--r-- | games/sail/dr_2.c | 100 | ||||
-rw-r--r-- | games/sail/dr_3.c | 104 | ||||
-rw-r--r-- | games/sail/dr_4.c | 24 | ||||
-rw-r--r-- | games/sail/dr_5.c | 31 | ||||
-rw-r--r-- | games/sail/dr_main.c | 25 | ||||
-rw-r--r-- | games/sail/driver.h | 7 | ||||
-rw-r--r-- | games/sail/externs.h | 312 | ||||
-rw-r--r-- | games/sail/game.c | 23 | ||||
-rw-r--r-- | games/sail/globals.c | 634 | ||||
-rw-r--r-- | games/sail/lo_main.c | 10 | ||||
-rw-r--r-- | games/sail/main.c | 41 | ||||
-rw-r--r-- | games/sail/misc.c | 70 | ||||
-rw-r--r-- | games/sail/parties.c | 36 | ||||
-rw-r--r-- | games/sail/pathnames.h | 3 | ||||
-rw-r--r-- | games/sail/pl_1.c | 40 | ||||
-rw-r--r-- | games/sail/pl_2.c | 16 | ||||
-rw-r--r-- | games/sail/pl_3.c | 85 | ||||
-rw-r--r-- | games/sail/pl_4.c | 37 | ||||
-rw-r--r-- | games/sail/pl_5.c | 74 | ||||
-rw-r--r-- | games/sail/pl_6.c | 43 | ||||
-rw-r--r-- | games/sail/pl_7.c | 160 | ||||
-rw-r--r-- | games/sail/pl_main.c | 53 | ||||
-rw-r--r-- | games/sail/player.h | 7 | ||||
-rw-r--r-- | games/sail/sync.c | 255 | ||||
-rw-r--r-- | games/sail/version.c | 5 |
31 files changed, 1196 insertions, 1191 deletions
diff --git a/games/sail/:file b/games/sail/:file deleted file mode 100644 index dd5762fd31a..00000000000 --- a/games/sail/:file +++ /dev/null @@ -1,10 +0,0 @@ -./"index"16t"captain"nD20C -+/"points"8t"loadL"8t"loadR"8t"readyL"8t"readyL"ndbbbb2+36+36+ -+/"struck"8t"capture"8t"pcrew"8t"movebuf"nb3+pd10C -+/"drift"8t"nfoul"8t"ngrap"nb1+dd -+/"foul:"8t"count"8t"turn"16t"count"8t"turn" -+,5/8tdd16tddn -+/"grap:"8t"count"8t"turn"16t"count"8t"turn" -+,5/8tdd16tddn -+/"RH"8t"RG"8t"RR"8t"FS"8t"explode"8t"sink"n6b -+/"dir"8t"col"8t"row"8t"loadwit"8t"stern"nb+2d2b diff --git a/games/sail/:scene b/games/sail/:scene deleted file mode 100644 index 43c4d816053..00000000000 --- a/games/sail/:scene +++ /dev/null @@ -1,3 +0,0 @@ -./"winddir windspd windchg vessels"n4b -.+8/"ship: "a -*(.-4)/S diff --git a/games/sail/:ship b/games/sail/:ship deleted file mode 100644 index fdf9dd09396..00000000000 --- a/games/sail/:ship +++ /dev/null @@ -1,4 +0,0 @@ -./"name"16t"specs"16t"nation"nppb+ -+/"row"8t"col"8t"dir"nddb+ -+/"file"np -+/t diff --git a/games/sail/:specs b/games/sail/:specs deleted file mode 100644 index 2a71f70afc4..00000000000 --- a/games/sail/:specs +++ /dev/null @@ -1,3 +0,0 @@ -./"bs bs ta guns class hull qual"n3b+d3b -+/"crew1 crew2 crew3 gunL gunR carL carR"n8b -+/"rig1 rig2 rig3 rig4 pts"n4b+d diff --git a/games/sail/assorted.c b/games/sail/assorted.c index 9d6ca9983a9..7facf0f109c 100644 --- a/games/sail/assorted.c +++ b/games/sail/assorted.c @@ -1,3 +1,4 @@ +/* $OpenBSD: assorted.c,v 1.2 1999/01/18 06:20:51 pjanzen Exp $ */ /* $NetBSD: assorted.c,v 1.3 1995/04/22 10:36:45 cgd Exp $ */ /* @@ -35,26 +36,33 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)assorted.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: assorted.c,v 1.3 1995/04/22 10:36:45 cgd Exp $"; +static char rcsid[] = "$OpenBSD: assorted.c,v 1.2 1999/01/18 06:20:51 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +#include <sys/cdefs.h> +#include <stdlib.h> +#include <unistd.h> +#include <err.h> +static void strike __P((struct ship *, struct ship *)); + +void table(rig, shot, hittable, on, from, roll) -struct ship *on, *from; -int rig, shot, hittable, roll; + struct ship *on, *from; + int rig, shot, hittable, roll; { - register int hhits = 0, chits = 0, ghits = 0, rhits = 0; + int hhits = 0, chits = 0, ghits = 0, rhits = 0; int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0; int guns, car, pc, hull; int crew[3]; - register int n; + int n; int rigg[4]; - char *message; - struct Tables *tp; + const char *message; + const struct Tables *tp; pc = on->file->pcrew; hull = on->specs->hull; @@ -107,7 +115,7 @@ int rig, shot, hittable, roll; rigg[3] -= rhits; } if (rig && !rigg[2] && (!rigg[3] || rigg[3] == -1)) - makesignal(on, "dismasted!", (struct ship *)0); + makemsg(on, "dismasted!"); if (portside(from, on, 0)) { guns = on->specs->gunR; car = on->specs->carR; @@ -132,32 +140,35 @@ int rig, shot, hittable, roll; hull -= ghits; if (Ghit) Write(portside(from, on, 0) ? W_GUNR : W_GUNL, - on, 0, guns, car, 0, 0); + on, guns, car, 0, 0); hull -= hhits; hull = hull < 0 ? 0 : hull; if (on->file->captured != 0 && Chit) - Write(W_PCREW, on, 0, pc, 0, 0, 0); + Write(W_PCREW, on, pc, 0, 0, 0); if (Hhit) - Write(W_HULL, on, 0, hull, 0, 0, 0); + Write(W_HULL, on, hull, 0, 0, 0); if (Chit) - Write(W_CREW, on, 0, crew[0], crew[1], crew[2], 0); + Write(W_CREW, on, crew[0], crew[1], crew[2], 0); if (Rhit) - Write(W_RIGG, on, 0, rigg[0], rigg[1], rigg[2], rigg[3]); + Write(W_RIGG, on, rigg[0], rigg[1], rigg[2], rigg[3]); switch (shot) { case L_ROUND: - message = "firing round shot on %s (%c%c)"; + message = "firing round shot on $$"; break; case L_GRAPE: - message = "firing grape shot on %s (%c%c)"; + message = "firing grape shot on $$"; break; case L_CHAIN: - message = "firing chain shot on %s (%c%c)"; + message = "firing chain shot on $$"; break; case L_DOUBLE: - message = "firing double shot on %s (%c%c)"; + message = "firing double shot on $$"; break; case L_EXPLODE: - message = "exploding shot on %s (%c%c)"; + message = "exploding shot on $$"; + break; + default: + errx(1, "Unknown shot type %d", shot); } makesignal(from, message, on); if (roll == 6 && rig) { @@ -183,8 +194,10 @@ int rig, shot, hittable, roll; case 7: message = "main topmast and mizzen mast shattered"; break; + default: + errx(1, "Bad Rhit = %d", Rhit); } - makesignal(on, message, (struct ship *)0); + makemsg(on, message); } else if (roll == 6) { switch (Hhit) { case 0: @@ -204,41 +217,44 @@ int rig, shot, hittable, roll; break; case 5: message = "rudder cables shot through"; - Write(W_TA, on, 0, 0, 0, 0, 0); + Write(W_TA, on, 0, 0, 0, 0); break; case 6: message = "shot holes below the water line"; break; + default: + errx(1, "Bad Hhit = %d", Hhit); } - makesignal(on, message, (struct ship *)0); + makemsg(on, message); } /* if (Chit > 1 && on->file->readyL&R_INITIAL && on->file->readyR&R_INITIAL) { on->specs->qual--; if (on->specs->qual <= 0) { - makesignal(on, "crew mutinying!", (struct ship *)0); + makemsg(on, "crew mutinying!"); on->specs->qual = 5; - Write(W_CAPTURED, on, 0, on->file->index, 0, 0, 0); + Write(W_CAPTURED, on, on->file->index, 0, 0, 0); } else - makesignal(on, "crew demoralized", (struct ship *)0); - Write(W_QUAL, on, 0, on->specs->qual, 0, 0, 0); + makemsg(on, "crew demoralized"); + Write(W_QUAL, on, on->specs->qual, 0, 0, 0); } */ if (!hull) strike(on, from); } +void Cleansnag(from, to, all, flag) -register struct ship *from, *to; -char all, flag; + struct ship *from, *to; + char all, flag; { if (flag & 1) { - Write(W_UNGRAP, from, 0, to->file->index, all, 0, 0); - Write(W_UNGRAP, to, 0, from->file->index, all, 0, 0); + Write(W_UNGRAP, from, to->file->index, all, 0, 0); + Write(W_UNGRAP, to, from->file->index, all, 0, 0); } if (flag & 2) { - Write(W_UNFOUL, from, 0, to->file->index, all, 0, 0); - Write(W_UNFOUL, to, 0, from->file->index, all, 0, 0); + Write(W_UNFOUL, from, to->file->index, all, 0, 0); + Write(W_UNFOUL, to, from->file->index, all, 0, 0); } if (!snagged2(from, to)) { if (!snagged(from)) { @@ -254,27 +270,28 @@ char all, flag; } } +static void strike(ship, from) -register struct ship *ship, *from; + struct ship *ship, *from; { int points; if (ship->file->struck) return; - Write(W_STRUCK, ship, 0, 1, 0, 0, 0); + Write(W_STRUCK, ship, 1, 0, 0, 0); points = ship->specs->pts + from->file->points; - Write(W_POINTS, from, 0, points, 0, 0, 0); + Write(W_POINTS, from, points, 0, 0, 0); unboard(ship, ship, 0); /* all offense */ unboard(ship, ship, 1); /* all defense */ switch (die()) { case 3: case 4: /* ship may sink */ - Write(W_SINK, ship, 0, 1, 0, 0, 0); + Write(W_SINK, ship, 1, 0, 0, 0); break; case 5: case 6: /* ship may explode */ - Write(W_EXPLODE, ship, 0, 1, 0, 0, 0); + Write(W_EXPLODE, ship, 1, 0, 0, 0); break; } - Write(W_SIGNAL, ship, 1, (int) "striking her colours!", 0, 0, 0); + Writestr(W_SIGNAL, ship, "striking her colours!"); } diff --git a/games/sail/dr_1.c b/games/sail/dr_1.c index de4c8c5f391..c03b5b51bab 100644 --- a/games/sail/dr_1.c +++ b/games/sail/dr_1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_1.c,v 1.2 1999/01/18 06:20:51 pjanzen Exp $ */ /* $NetBSD: dr_1.c,v 1.4 1995/04/24 12:25:10 cgd Exp $ */ /* @@ -37,18 +38,20 @@ #if 0 static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dr_1.c,v 1.4 1995/04/24 12:25:10 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_1.c,v 1.2 1999/01/18 06:20:51 pjanzen Exp $"; #endif #endif /* not lint */ #include "driver.h" +#include <stdlib.h> +void unfoul() { - register struct ship *sp; + struct ship *sp; struct ship *to; - register int nat; - register i; + int nat; + int i; foreachship(sp) { if (sp->file->captain[0]) @@ -56,7 +59,7 @@ unfoul() nat = capship(sp)->nationality; foreachship(to) { if (nat != capship(to)->nationality && - !toughmelee(sp, to, 0, 0)) + !is_toughmelee(sp, to, 0, 0)) continue; for (i = fouled2(sp, to); --i >= 0;) if (die() <= 2) @@ -65,10 +68,11 @@ unfoul() } } +void boardcomp() { int crew[3]; - register struct ship *sp, *sq; + struct ship *sp, *sq; foreachship(sp) { if (*sp->file->captain) @@ -129,9 +133,10 @@ boardcomp() } } +int fightitout(from, to, key) -struct ship *from, *to; -int key; + struct ship *from, *to; + int key; { struct ship *fromcap, *tocap; int crewfrom[3], crewto[3], menfrom, mento; @@ -162,7 +167,7 @@ int key; fromstrength = menfrom * fromcap->specs->qual; strengthto = mento * tocap->specs->qual; for (count = 0; - (fromstrength < strengthto * 3 && strengthto < fromstrength * 3 + ((fromstrength < strengthto * 3 && strengthto < fromstrength * 3) || fromstrength == -1) && count < 4; count++) { index = fromstrength/10; @@ -184,10 +189,10 @@ int key; unboard(to, from, 0); subtract(from, totalfrom, crewfrom, fromcap, pcfrom); subtract(to, totalto, crewto, tocap, pcto); - makesignal(from, "boarders from %s repelled", to); + makemsg(from, "boarders from %s repelled", to->shipname); (void) sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); - Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0); + Writestr(W_SIGNAL, to, message); if (key) return 1; } else if (strengthto >= fromstrength * 3) { @@ -196,7 +201,7 @@ int key; subtract(to, totalto, crewto, tocap, pcto); if (key) { if (fromcap != from) - Write(W_POINTS, fromcap, 0, + Write(W_POINTS, fromcap, fromcap->file->points - from->file->struck ? from->specs->pts @@ -207,11 +212,11 @@ int key; I guess that what is going on here is that the pointer is multiplied or something. */ - Write(W_CAPTURED, from, 0, to->file->index, 0, 0, 0); + Write(W_CAPTURED, from, to->file->index, 0, 0, 0); topoints = 2 * from->specs->pts + to->file->points; if (from->file->struck) topoints -= from->specs->pts; - Write(W_POINTS, to, 0, topoints, 0, 0, 0); + Write(W_POINTS, to, topoints, 0, 0, 0); mento = crewto[0] ? crewto[0] : crewto[1]; if (mento) { subtract(to, mento, crewto, tocap, pcto); @@ -219,10 +224,10 @@ int key; } (void) sprintf(message, "captured by the %s!", to->shipname); - Write(W_SIGNAL, from, 1, (long) message, 0, 0, 0); + Writestr(W_SIGNAL, from, message); (void) sprintf(message, "killed in melee: %d. %s: %d", totalto, from->shipname, totalfrom); - Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0); + Writestr(W_SIGNAL, to, message); mento = 0; return 0; } @@ -230,10 +235,11 @@ int key; return 0; } +void resolve() { int thwart; - register struct ship *sp, *sq; + struct ship *sp, *sq; foreachship(sp) { if (sp->file->dir == 0) @@ -260,10 +266,11 @@ resolve() } } +void compcombat() { - register n; - register struct ship *sp; + int n; + struct ship *sp; struct ship *closest; int crew[3], men = 0, target, temp; int r, guns, ready, load, car; @@ -352,11 +359,12 @@ compcombat() hit++; hit += QUAL[index][capship(sp)->specs->qual - 1]; for (n = 0; n < 3 && sp->file->captured == 0; n++) - if (!crew[n]) + if (!crew[n]) { if (index <= 5) hit--; else hit -= 2; + } if (ready & R_INITIAL) { if (!r) sp->file->readyL &= ~R_INITIAL; @@ -367,11 +375,12 @@ compcombat() else hit += 2; } - if (sp->file->captured != 0) + if (sp->file->captured != 0) { if (index <= 1) hit--; else hit -= 2; + } hit += AMMO[index][load - 1]; temp = sp->specs->class; if ((temp >= 5 || temp == 1) && windspeed == 5) @@ -389,16 +398,18 @@ compcombat() } } +int next() { - if (++turn % 55 == 0) + if (++turn % 55 == 0) { if (alive) alive = 0; else people = 0; + } if (people <= 0 || windspeed == 7) { - register struct ship *s; - struct ship *bestship; + struct ship *s; + struct ship *bestship = NULL; float net, best = 0.0; foreachship(s) { if (*s->file->captain) @@ -410,20 +421,24 @@ next() } } if (best > 0.0) { - char *p = getenv("WOTD"); - if (p == 0) + char *tp = getenv("WOTD"); + const char *p; + if (tp == 0) p = "Driver"; - if (islower(*p)) - *p = toupper(*p); + else { + if (islower(*tp)) + *tp = toupper(*tp); + p = tp; + } (void) strncpy(bestship->file->captain, p, sizeof bestship->file->captain); bestship->file->captain [sizeof bestship->file->captain - 1] = 0; - log(bestship); + logger(bestship); } return -1; } - Write(W_TURN, SHIP(0), 0, turn, 0, 0, 0); + Write(W_TURN, SHIP(0), turn, 0, 0, 0); if (turn % 7 == 0 && (die() >= cc->windchange || !windspeed)) { switch (die()) { case 1: @@ -461,7 +476,7 @@ next() } else windspeed++; - Write(W_WIND, SHIP(0), 0, winddir, windspeed, 0, 0); + Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0); } return 0; } diff --git a/games/sail/dr_2.c b/games/sail/dr_2.c index fbe58ba4959..209f5be2c41 100644 --- a/games/sail/dr_2.c +++ b/games/sail/dr_2.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_2.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: dr_2.c,v 1.4 1995/04/24 12:25:12 cgd Exp $ */ /* @@ -37,17 +38,19 @@ #if 0 static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dr_2.c,v 1.4 1995/04/24 12:25:12 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_2.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ #include "driver.h" +#include <stdlib.h> #define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5) +void thinkofgrapples() { - register struct ship *sp, *sq; + struct ship *sp, *sq; char friendly; foreachship(sp) { @@ -60,12 +63,12 @@ thinkofgrapples() continue; if (range(sp, sq) != 1) continue; - if (grappled2(sp, sq)) - if (toughmelee(sp, sq, 0, 0)) + if (grappled2(sp, sq)) { + if (is_toughmelee(sp, sq, 0, 0)) ungrap(sp, sq); else grap(sp, sq); - else if (couldwin(sp, sq)) { + } else if (couldwin(sp, sq)) { grap(sp, sq); sp->file->loadwith = L_GRAPE; } @@ -75,10 +78,11 @@ thinkofgrapples() } } +void checkup() { - register struct ship *sp, *sq; - register char explode, sink; + struct ship *sp, *sq; + char explode, sink; foreachship(sp) { if (sp->file->dir == 0) @@ -89,25 +93,26 @@ checkup() continue; if (die() < 5) continue; - Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 0, 2, 0, 0, 0); - Write(W_DIR, sp, 0, 0, 0, 0, 0); + Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 2, 0, 0, 0); + Write(W_DIR, sp, 0, 0, 0, 0); if (snagged(sp)) foreachship(sq) cleansnag(sp, sq, 1); if (sink != 1) { - makesignal(sp, "exploding!", (struct ship *)0); + makemsg(sp, "exploding!"); foreachship(sq) { if (sp != sq && sq->file->dir && range(sp, sq) < 4) table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6); } } else - makesignal(sp, "sinking!", (struct ship *)0); + makemsg(sp, "sinking!"); } } +void prizecheck() { - register struct ship *sp; + struct ship *sp; foreachship(sp) { if (sp->file->captured == 0) @@ -115,28 +120,29 @@ prizecheck() if (sp->file->struck || sp->file->dir == 0) continue; if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) { - Write(W_SIGNAL, sp, 1, - (long)"prize crew overthrown", 0, 0, 0); - Write(W_POINTS, sp->file->captured, 0, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0); - Write(W_CAPTURED, sp, 0, -1, 0, 0, 0); + Writestr(W_SIGNAL, sp, "prize crew overthrown"); + Write(W_POINTS, sp->file->captured, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0); + Write(W_CAPTURED, sp, -1, 0, 0, 0); } } } -strend(str) -char *str; +int +str_end(str) + const char *str; { - register char *p; + const char *p; for (p = str; *p; p++) ; return p == str ? 0 : p[-1]; } +void closeon(from, to, command, ta, ma, af) -register struct ship *from, *to; -char command[]; -int ma, ta, af; + struct ship *from, *to; + char command[]; + int ma, ta, af; { int high; char temp[10]; @@ -146,23 +152,24 @@ int ma, ta, af; try(command, temp, ma, ta, af, ma, from->file->dir, from, to, &high, 0); } -int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ +const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ +int score(movement, ship, to, onlytemp) -char movement[]; -register struct ship *ship, *to; -char onlytemp; + char movement[]; + struct ship *ship, *to; + char onlytemp; { char drift; int row, col, dir, total, ran; - register struct File *fp = ship->file; + struct File *fp = ship->file; if ((dir = fp->dir) == 0) return 0; row = fp->row; col = fp->col; drift = fp->drift; - move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift); + move_ship(movement, ship, &fp->dir, &fp->row, &fp->col, &drift); if (!*movement) (void) strcpy(movement, "d"); @@ -181,12 +188,13 @@ char onlytemp; return total; } -move(p, ship, dir, row, col, drift) -register char *p; -register struct ship *ship; -register char *dir; -register short *row, *col; -register char *drift; +void +move_ship(p, ship, dir, row, col, drift) + const char *p; + struct ship *ship; + unsigned char *dir; + short *row, *col; + char *drift; { int dist; char moved = 0; @@ -215,7 +223,7 @@ register char *drift; } if (!moved) { if (windspeed != 0 && ++*drift > 2) { - if (ship->specs->class >= 3 && !snagged(ship) + if ((ship->specs->class >= 3 && !snagged(ship)) || (turn & 1) == 0) { *row -= dr[winddir]; *col -= dc[winddir]; @@ -225,16 +233,17 @@ register char *drift; *drift = 0; } +void try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme) -register struct ship *f, *t; -int ma, ta, af, *high, rakeme; -char command[], temp[]; + struct ship *f, *t; + int ma, ta, af, vma, dir, *high, rakeme; + char command[], temp[]; { - register int new, n; + int new, n; char st[4]; #define rakeyou (gunsbear(f, t) && !gunsbear(t, f)) - if ((n = strend(temp)) < '1' || n > '9') + if ((n = str_end(temp)) < '1' || n > '9') for (n = 1; vma - n >= 0; n++) { (void) sprintf(st, "%d", n); (void) strcat(temp, st); @@ -247,17 +256,17 @@ char command[], temp[]; dir, f, t, high, rakeme); rmend(temp); } - if (ma > 0 && ta > 0 && (n = strend(temp)) != 'l' && n != 'r' || !strlen(temp)) { + if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) { (void) strcat(temp, "r"); new = score(temp, f, t, rakeme); - if (new > *high && (!rakeme || gunsbear(f, t) && !gunsbear(t, f))) { + if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) { *high = new; (void) strcpy(command, temp); } try(command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1),f,t,high,rakeme); rmend(temp); } - if ((ma > 0 && ta > 0 && (n = strend(temp)) != 'l' && n != 'r') || !strlen(temp)){ + if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){ (void) strcat(temp, "l"); new = score(temp, f, t, rakeme); if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){ @@ -269,10 +278,11 @@ char command[], temp[]; } } +void rmend(str) -char *str; + char *str; { - register char *p; + char *p; for (p = str; *p; p++) ; diff --git a/games/sail/dr_3.c b/games/sail/dr_3.c index 389d9e92ffe..f7e84d8f5fc 100644 --- a/games/sail/dr_3.c +++ b/games/sail/dr_3.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_3.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: dr_3.c,v 1.3 1995/04/22 10:36:49 cgd Exp $ */ /* @@ -37,17 +38,19 @@ #if 0 static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: dr_3.c,v 1.3 1995/04/22 10:36:49 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_3.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ #include "driver.h" +#include <stdlib.h> +void moveall() /* move all comp ships */ { - register struct ship *sp, *sq; /* r11, r10 */ - register int n; /* r9 */ - register int k, l; /* r8, r7 */ + struct ship *sp, *sq; /* r11, r10 */ + int n; /* r9 */ + int k, l; /* r8, r7 */ int row[NSHIP], col[NSHIP], dir[NSHIP], drift[NSHIP]; char moved[NSHIP]; @@ -116,7 +119,7 @@ moveall() /* move all comp ships */ */ n = 0; foreachship(sp) { - if (sp->file->dir == 0 || isolated(sp)) + if (sp->file->dir == 0 || is_isolated(sp)) goto cont1; l = 0; foreachship(sq) { @@ -131,14 +134,12 @@ moveall() /* move all comp ships */ if (snagged2(sp, sq) && range(sp, sq) > 1) snap++; if (!range(sp, sq) && !fouled2(sp, sq)) { - makesignal(sp, - "collision with %s (%c%c)", sq); + makesignal(sp, "collision with $$", sq); if (die() < 4) { - makesignal(sp, - "fouled with %s (%c%c)", + makesignal(sp, "fouled with $$", sq); - Write(W_FOUL, sp, 0, l, 0, 0, 0); - Write(W_FOUL, sq, 0, n, 0, 0, 0); + Write(W_FOUL, sp, l, 0, 0, 0); + Write(W_FOUL, sq, n, 0, 0, 0); } snap++; } @@ -169,22 +170,23 @@ moveall() /* move all comp ships */ if (sp->file->dir != 0) { *sp->file->movebuf = 0; if (row[n] != sp->file->row) - Write(W_ROW, sp, 0, sp->file->row, 0, 0, 0); + Write(W_ROW, sp, sp->file->row, 0, 0, 0); if (col[n] != sp->file->col) - Write(W_COL, sp, 0, sp->file->col, 0, 0, 0); + Write(W_COL, sp, sp->file->col, 0, 0, 0); if (dir[n] != sp->file->dir) - Write(W_DIR, sp, 0, sp->file->dir, 0, 0, 0); + Write(W_DIR, sp, sp->file->dir, 0, 0, 0); if (drift[n] != sp->file->drift) - Write(W_DRIFT, sp, 0, sp->file->drift, 0, 0, 0); + Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0); } n++; } } +int stillmoving(k) -register int k; + int k; { - register struct ship *sp; + struct ship *sp; foreachship(sp) if (sp->file->movebuf[k]) @@ -192,10 +194,11 @@ register int k; return 0; } -isolated(ship) -register struct ship *ship; +int +is_isolated(ship) + struct ship *ship; { - register struct ship *sp; + struct ship *sp; foreachship(sp) { if (ship != sp && range(ship, sp) <= 10) @@ -204,10 +207,11 @@ register struct ship *ship; return 1; } +int push(from, to) -register struct ship *from, *to; + struct ship *from, *to; { - register int bs, sb; + int bs, sb; sb = to->specs->guns; bs = from->specs->guns; @@ -218,12 +222,13 @@ register struct ship *from, *to; return from < to; } +void step(com, sp, moved) -char com; -register struct ship *sp; -char *moved; + char com; + struct ship *sp; + char *moved; { - register int dist; + int dist; switch (com) { case 'r': @@ -249,7 +254,7 @@ char *moved; case 'd': if (!*moved) { if (windspeed != 0 && ++sp->file->drift > 2 && - (sp->specs->class >= 3 && !snagged(sp) + ((sp->specs->class >= 3 && !snagged(sp)) || (turn & 1) == 0)) { sp->file->row -= dr[winddir]; sp->file->col -= dc[winddir]; @@ -260,34 +265,35 @@ char *moved; } } +void sendbp(from, to, sections, isdefense) -register struct ship *from, *to; -int sections; -char isdefense; + struct ship *from, *to; + int sections; + char isdefense; { int n; - register struct BP *bp; + struct BP *bp; bp = isdefense ? from->file->DBP : from->file->OBP; for (n = 0; n < NBP && bp[n].turnsent; n++) ; if (n < NBP && sections) { - Write(isdefense ? W_DBP : W_OBP, from, 0, + Write(isdefense ? W_DBP : W_OBP, from, n, turn, to->file->index, sections); if (isdefense) - makesignal(from, "repelling boarders", - (struct ship *)0); + makemsg(from, "repelling boarders"); else - makesignal(from, "boarding the %s (%c%c)", to); + makesignal(from, "boarding the $$", to); } } -toughmelee(ship, to, isdefense, count) -register struct ship *ship, *to; -int isdefense, count; +int +is_toughmelee(ship, to, isdefense, count) + struct ship *ship, *to; + int isdefense, count; { - register struct BP *bp; - register obp = 0; + struct BP *bp; + int obp = 0; int n, OBP = 0, DBP = 0, dbp = 0; int qual; @@ -305,35 +311,37 @@ int isdefense, count; } if (count || isdefense) return obp; - OBP = toughmelee(to, ship, 0, count + 1); - dbp = toughmelee(ship, to, 1, count + 1); - DBP = toughmelee(to, ship, 1, count + 1); + OBP = is_toughmelee(to, ship, 0, count + 1); + dbp = is_toughmelee(ship, to, 1, count + 1); + DBP = is_toughmelee(to, ship, 1, count + 1); if (OBP > obp + 10 || OBP + DBP >= obp + dbp + 10) return 1; else return 0; } +void reload() { - register struct ship *sp; + struct ship *sp; foreachship(sp) { sp->file->loadwith = 0; } } +void checksails() { - register struct ship *sp; - register int rig, full; + struct ship *sp; + int rig, full; struct ship *close; foreachship(sp) { if (sp->file->captain[0] != 0) continue; rig = sp->specs->rig1; - if (windspeed == 6 || windspeed == 5 && sp->specs->class > 4) + if (windspeed == 6 || (windspeed == 5 && sp->specs->class > 4)) rig = 0; if (rig && sp->specs->crew3) { close = closestenemy(sp, 0, 0); @@ -347,6 +355,6 @@ checksails() } else full = 0; if ((sp->file->FS != 0) != full) - Write(W_FS, sp, 0, full, 0, 0, 0); + Write(W_FS, sp, full, 0, 0, 0); } } diff --git a/games/sail/dr_4.c b/games/sail/dr_4.c index 723b10257e7..e4db80a8668 100644 --- a/games/sail/dr_4.c +++ b/games/sail/dr_4.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_4.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: dr_4.c,v 1.3 1995/04/22 10:36:50 cgd Exp $ */ /* @@ -35,18 +36,20 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)dr_4.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: dr_4.c,v 1.3 1995/04/22 10:36:50 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_4.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +#include <stdlib.h> +void ungrap(from, to) -register struct ship *from, *to; + struct ship *from, *to; { - register k; + int k; char friend; if ((k = grappled2(from, to)) == 0) @@ -55,17 +58,18 @@ register struct ship *from, *to; while (--k >= 0) { if (friend || die() < 3) { cleangrapple(from, to, 0); - makesignal(from, "ungrappling %s (%c%c)", to); + makesignal(from, "ungrappling $$", to); } } } +void grap(from, to) -register struct ship *from, *to; + struct ship *from, *to; { if (capship(from)->nationality != capship(to)->nationality && die() > 2) return; - Write(W_GRAP, from, 0, to->file->index, 0, 0, 0); - Write(W_GRAP, to, 0, from->file->index, 0, 0, 0); - makesignal(from, "grappled with %s (%c%c)", to); + Write(W_GRAP, from, to->file->index, 0, 0, 0); + Write(W_GRAP, to, from->file->index, 0, 0, 0); + makesignal(from, "grappled with $$", to); } diff --git a/games/sail/dr_5.c b/games/sail/dr_5.c index 229577445ae..8fc6eda2a6b 100644 --- a/games/sail/dr_5.c +++ b/games/sail/dr_5.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_5.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: dr_5.c,v 1.3 1995/04/22 10:36:51 cgd Exp $ */ /* @@ -35,20 +36,21 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)dr_5.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: dr_5.c,v 1.3 1995/04/22 10:36:51 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_5.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +void subtract(from, totalfrom, crewfrom, fromcap, pcfrom) -struct ship *from, *fromcap; -int pcfrom; -register int totalfrom, crewfrom[3]; + struct ship *from, *fromcap; + int pcfrom; + int totalfrom, crewfrom[3]; { - register int n; + int n; if (fromcap == from && totalfrom) { /* if not captured */ for (n = 0; n < 3; n++) { @@ -60,23 +62,24 @@ register int totalfrom, crewfrom[3]; totalfrom = 0; } } - Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0); + Write(W_CREW, from, crewfrom[0], crewfrom[1], crewfrom[2], 0); } else if (totalfrom) { pcfrom -= totalfrom; pcfrom = pcfrom < 0 ? 0 : pcfrom; - Write(W_PCREW, from, 0, pcfrom, 0, 0, 0); + Write(W_PCREW, from, pcfrom, 0, 0, 0); } } +int mensent(from, to, crew, captured, pc, isdefense) -struct ship *from, *to, **captured; -int crew[3], *pc; -char isdefense; + struct ship *from, *to, **captured; + int crew[3], *pc; + char isdefense; { /* returns # of crew squares sent */ int men = 0; - register int n; + int n; int c1, c2, c3; - register struct BP *bp; + struct BP *bp; *pc = from->file->pcrew; *captured = from->file->captured; diff --git a/games/sail/dr_main.c b/games/sail/dr_main.c index 265bdb32e7b..07b6383dfc2 100644 --- a/games/sail/dr_main.c +++ b/games/sail/dr_main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: dr_main.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: dr_main.c,v 1.4 1995/04/22 10:36:52 cgd Exp $ */ /* @@ -37,34 +38,32 @@ #if 0 static char sccsid[] = "@(#)dr_main.c 8.2 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$NetBSD: dr_main.c,v 1.4 1995/04/22 10:36:52 cgd Exp $"; +static char rcsid[] = "$OpenBSD: dr_main.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ #include "driver.h" +#include <stdlib.h> +#include <unistd.h> +#include <err.h> +int dr_main() { - register int n; - register struct ship *sp; + int n; + struct ship *sp; int nat[NNATION]; int value = 0; (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); (void) signal(SIGTSTP, SIG_IGN); - if (issetuid) - (void) setuid(geteuid()); - if (game < 0 || game >= NSCENE) { - fprintf(stderr, "DRIVER: Bad game number %d\n", game); - exit(1); - } + if (game < 0 || game >= NSCENE) + errx(1, "driver: Bad game number %d\n", game); cc = &scene[game]; ls = SHIP(cc->vessels); - if (sync_open() < 0) { - perror("driver: syncfile"); - exit(1); - } + if (sync_open() < 0) + err(1, "driver: syncfile"); for (n = 0; n < NNATION; n++) nat[n] = 0; foreachship(sp) { diff --git a/games/sail/driver.h b/games/sail/driver.h index ca6ba93f575..8ce2ce6a9c9 100644 --- a/games/sail/driver.h +++ b/games/sail/driver.h @@ -1,3 +1,4 @@ +/* $OpenBSD: driver.h,v 1.3 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: driver.h,v 1.3 1995/04/22 10:36:54 cgd Exp $ */ /* @@ -32,9 +33,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)driver.h 8.1 (Berkeley) 5/31/93 + * @(#)driver.h 8.2 (Berkeley) 5/3/95 */ -#include "externs.h" +#include "extern.h" -int dtab[8]; +extern const int dtab[]; diff --git a/games/sail/externs.h b/games/sail/externs.h deleted file mode 100644 index 04a81dd3ec3..00000000000 --- a/games/sail/externs.h +++ /dev/null @@ -1,312 +0,0 @@ -/* $NetBSD: externs.h,v 1.4 1995/04/24 12:25:15 cgd Exp $ */ - -/* - * Copyright (c) 1983, 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. - * - * @(#)externs.h 8.1 (Berkeley) 5/31/93 - */ - -#include <stdio.h> -#include <signal.h> -#include <string.h> -#include <ctype.h> -#include <setjmp.h> -#include "machdep.h" - - /* program mode */ -int mode; -jmp_buf restart; -#define MODE_PLAYER 1 -#define MODE_DRIVER 2 -#define MODE_LOGGER 3 - - /* command line flags */ -char debug; /* -D */ -char randomize; /* -x, give first available ship */ -char longfmt; /* -l, print score in long format */ -char nobells; /* -b, don't ring bell before Signal */ - - /* other initial modes */ -char issetuid; /* running setuid */ - -#define die() ((rand() >> 3) % 6 + 1) -#define sqr(a) ((a) * (a)) -#define abs(a) ((a) > 0 ? (a) : -(a)) -#define min(a,b) ((a) < (b) ? (a) : (b)) - -#define grappled(a) ((a)->file->ngrap) -#define fouled(a) ((a)->file->nfoul) -#define snagged(a) (grappled(a) + fouled(a)) - -#define grappled2(a, b) ((a)->file->grap[(b)->file->index].sn_count) -#define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count) -#define snagged2(a, b) (grappled2(a, b) + fouled2(a, b)) - -#define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0) -#define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0) -#define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b)) - -#define cleangrapple(a, b, c) Cleansnag(a, b, c, 1) -#define cleanfoul(a, b, c) Cleansnag(a, b, c, 2) -#define cleansnag(a, b, c) Cleansnag(a, b, c, 3) - -#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0)) -#define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir]) -#define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir]) - -#define capship(sp) ((sp)->file->captured?(sp)->file->captured:(sp)) - -#define readyname(r) ((r) & R_LOADING ? '*' : ((r) & R_INITIAL ? '!' : ' ')) - -/* loadL and loadR, should match loadname[] */ -#define L_EMPTY 0 /* should be 0, don't change */ -#define L_GRAPE 1 -#define L_CHAIN 2 -#define L_ROUND 3 -#define L_DOUBLE 4 -#define L_EXPLODE 5 - -/* - * readyL and readyR, these are bits, except R_EMPTY - */ -#define R_EMPTY 0 /* not loaded and not loading */ -#define R_LOADING 1 /* loading */ -#define R_DOUBLE 2 /* loading double */ -#define R_LOADED 4 /* loaded */ -#define R_INITIAL 8 /* loaded initial */ - -#define HULL 0 -#define RIGGING 1 - -#define W_CAPTAIN 1 -#define W_CAPTURED 2 -#define W_CLASS 3 -#define W_CREW 4 -#define W_DBP 5 -#define W_DRIFT 6 -#define W_EXPLODE 7 -#define W_FILE 8 -#define W_FOUL 9 -#define W_GUNL 10 -#define W_GUNR 11 -#define W_HULL 12 -#define W_MOVE 13 -#define W_OBP 14 -#define W_PCREW 15 -#define W_UNFOUL 16 -#define W_POINTS 17 -#define W_QUAL 18 -#define W_UNGRAP 19 -#define W_RIGG 20 -#define W_COL 21 -#define W_DIR 22 -#define W_ROW 23 -#define W_SIGNAL 24 -#define W_SINK 25 -#define W_STRUCK 26 -#define W_TA 27 -#define W_ALIVE 28 -#define W_TURN 29 -#define W_WIND 30 -#define W_FS 31 -#define W_GRAP 32 -#define W_RIG1 33 -#define W_RIG2 34 -#define W_RIG3 35 -#define W_RIG4 36 -#define W_BEGIN 37 -#define W_END 38 -#define W_DDEAD 39 - -#define NLOG 10 -struct logs { - char l_name[20]; - int l_uid; - int l_shipnum; - int l_gamenum; - int l_netpoints; -}; - -struct BP { - short turnsent; - struct ship *toship; - short mensent; -}; - -struct snag { - short sn_count; - short sn_turn; -}; - -#define NSCENE nscene -#define NSHIP 10 -#define NBP 3 - -#define NNATION 8 -#define N_A 0 -#define N_B 1 -#define N_S 2 -#define N_F 3 -#define N_J 4 -#define N_D 5 -#define N_K 6 -#define N_O 7 - -struct File { - int index; - char captain[20]; /* 0 */ - short points; /* 20 */ - char loadL; /* 22 */ - char loadR; /* 24 */ - char readyL; /* 26 */ - char readyR; /* 28 */ - struct BP OBP[NBP]; /* 30 */ - struct BP DBP[NBP]; /* 48 */ - char struck; /* 66 */ - struct ship *captured; /* 68 */ - short pcrew; /* 70 */ - char movebuf[60]; /* 72 */ - char drift; /* 132 */ - short nfoul; - short ngrap; - struct snag foul[NSHIP]; /* 134 */ - struct snag grap[NSHIP]; /* 144 */ - char RH; /* 274 */ - char RG; /* 276 */ - char RR; /* 278 */ - char FS; /* 280 */ - char explode; /* 282 */ - char sink; /* 284 */ - char dir; - short col; - short row; - char loadwith; - char stern; -}; - -struct ship { - char *shipname; /* 0 */ - struct shipspecs *specs; /* 2 */ - char nationality; /* 4 */ - short shiprow; /* 6 */ - short shipcol; /* 8 */ - char shipdir; /* 10 */ - struct File *file; /* 12 */ -}; - -struct scenario { - char winddir; /* 0 */ - char windspeed; /* 2 */ - char windchange; /* 4 */ - char vessels; /* 12 */ - char *name; /* 14 */ - struct ship ship[NSHIP]; /* 16 */ -}; -struct scenario scene[32]; -int nscene; - -struct shipspecs { - char bs; - char fs; - char ta; - short guns; - char class; - char hull; - char qual; - char crew1; - char crew2; - char crew3; - char gunL; - char gunR; - char carL; - char carR; - char rig1; - char rig2; - char rig3; - char rig4; - short pts; -}; -struct shipspecs specs[84]; - -struct scenario *cc; /* the current scenario */ -struct ship *ls; /* &cc->ship[cc->vessels] */ - -#define SHIP(s) (&cc->ship[s]) -#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++) - -struct windeffects { - char A, B, C, D; -}; -struct windeffects WET[7][6]; - -struct Tables { - char H, G, C, R; -}; -struct Tables RigTable[11][6]; -struct Tables HullTable[11][6]; - -char AMMO[9][4]; -char HDT[9][10]; -char HDTrake[9][10]; -char QUAL[9][5]; -char MT[9][3]; - -char *countryname[8]; -char *classname[7]; -char *directionname[9]; -char *qualname[6]; -char loadname[6]; - -char rangeofshot[5]; - -int dr[9], dc[9]; - -int winddir; -int windspeed; -int turn; -int game; -int alive; -int people; -char hasdriver; - -char *info(); -char *quality(); -double arctan(); -char *saywhat(); -struct ship *closestenemy(); - -char *calloc(); -char *strcpy(); -char *strcat(); -char *strncpy(); -char *getenv(); -char *gets(); diff --git a/games/sail/game.c b/games/sail/game.c index a6ecc4fc090..d4adeddb133 100644 --- a/games/sail/game.c +++ b/games/sail/game.c @@ -1,3 +1,4 @@ +/* $OpenBSD: game.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: game.c,v 1.3 1995/04/22 10:36:56 cgd Exp $ */ /* @@ -35,22 +36,23 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)game.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)game.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: game.c,v 1.3 1995/04/22 10:36:56 cgd Exp $"; +static char rcsid[] = "$OpenBSD: game.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +int maxturns(ship, af) -register struct ship *ship; -char *af; + struct ship *ship; + char *af; { - register int turns; + int turns; turns = ship->specs->ta; - if (*af = (ship->file->drift > 1 && turns)) { + if ((*af = (ship->file->drift > 1 && turns)) != 0) { turns--; if (ship->file->FS == 1) turns = 0; @@ -58,11 +60,12 @@ char *af; return turns; } +int maxmove(ship, dir, fs) -register struct ship *ship; -int dir, fs; + struct ship *ship; + int dir, fs; { - register int riggone = 0, Move, flank = 0; + int riggone = 0, Move, flank = 0; Move = ship->specs->bs; if (!ship->specs->rig1) diff --git a/games/sail/globals.c b/games/sail/globals.c index 2e9c1008347..ce09b9476ca 100644 --- a/games/sail/globals.c +++ b/games/sail/globals.c @@ -1,3 +1,4 @@ +/* $OpenBSD: globals.c,v 1.4 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: globals.c,v 1.4 1995/04/22 10:36:57 cgd Exp $ */ /* @@ -35,13 +36,13 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)globals.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: globals.c,v 1.4 1995/04/22 10:36:57 cgd Exp $"; +static char rcsid[] = "$OpenBSD: globals.c,v 1.4 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" struct scenario scene[] = { /* @@ -52,328 +53,360 @@ struct scenario scene[] = { * char *name; * struct ship ship[NSHIP]; */ - 5, 3, 5, 2, "Ranger vs. Drake", - { - { "Ranger", specs+0, N_A, 7, 20, 4, 0 }, - { "Drake", specs+1, N_B, 7, 31, 5, 0 } + { 5, 3, 5, 2, "Ranger vs. Drake", + { + { "Ranger", specs+0, N_A, 7, 20, 4, 0 }, + { "Drake", specs+1, N_B, 7, 31, 5, 0 } + } }, - 1, 3, 6, 2, "The Battle of Flamborough Head", - { - { "Bonhomme Rich", specs+2, N_A, 13, 40, 2, 0 }, - { "Serapis", specs+3, N_B, 2, 42, 2, 0 } + { 1, 3, 6, 2, "The Battle of Flamborough Head", + { + { "Bonhomme Rich", specs+2, N_A, 13, 40, 2, 0 }, + { "Serapis", specs+3, N_B, 2, 42, 2, 0 } + } }, - 5, 5, 5, 10, "Arbuthnot and Des Touches", - { - { "America", specs+4, N_B, 7, 37, 4, 0 }, - { "Befford", specs+5, N_B, 5, 35, 4, 0 }, - { "Adamant", specs+6, N_B, 3, 33, 4, 0 }, - { "London", specs+7, N_B, 1, 31, 4, 0 }, - { "Royal Oak", specs+8, N_B, -1, 29, 4, 0 }, - { "Neptune", specs+9, N_F, 6, 44, 4, 0 }, - { "Duc Bougogne", specs+10, N_F, 8, 46, 4, 0 }, - { "Conquerant", specs+48, N_F, 10, 48, 4, 0 }, - { "Provence", specs+11, N_F, 12, 50, 4, 0 }, - { "Romulus", specs+12, N_F, 20, 58, 4, 0 } + { 5, 5, 5, 10, "Arbuthnot and Des Touches", + { + { "America", specs+4, N_B, 7, 37, 4, 0 }, + { "Befford", specs+5, N_B, 5, 35, 4, 0 }, + { "Adamant", specs+6, N_B, 3, 33, 4, 0 }, + { "London", specs+7, N_B, 1, 31, 4, 0 }, + { "Royal Oak", specs+8, N_B, -1, 29, 4, 0 }, + { "Neptune", specs+9, N_F, 6, 44, 4, 0 }, + { "Duc Bougogne", specs+10, N_F, 8, 46, 4, 0 }, + { "Conquerant", specs+48, N_F, 10, 48, 4, 0 }, + { "Provence", specs+11, N_F, 12, 50, 4, 0 }, + { "Romulus", specs+12, N_F, 20, 58, 4, 0 } + } }, - 1, 3, 5, 10, "Suffren and Hughes", - { - { "Monmouth", specs+52, N_B, 9, 45, 2, 0 }, - { "Hero", specs+5, N_B, 13, 49, 2, 0 }, - { "Isis", specs+6, N_B, 12, 48, 2, 0 }, - { "Superb", specs+50, N_B, 10, 46, 2, 0 }, - { "Burford", specs+48, N_B, 11, 47, 2, 0 }, - { "Flamband", specs+13, N_F, 7, 59, 4, 0 }, - { "Annibal", specs+9, N_F, 4, 56, 4, 0 }, - { "Severe", specs+11, N_F, 2, 54, 4, 0 }, - { "Brilliant", specs+49, N_F, -1, 51, 4, 0 }, - { "Sphinx", specs+51, N_F, -5, 47, 4, 0 } + { 1, 3, 5, 10, "Suffren and Hughes", + { + { "Monmouth", specs+52, N_B, 9, 45, 2, 0 }, + { "Hero", specs+5, N_B, 13, 49, 2, 0 }, + { "Isis", specs+6, N_B, 12, 48, 2, 0 }, + { "Superb", specs+50, N_B, 10, 46, 2, 0 }, + { "Burford", specs+48, N_B, 11, 47, 2, 0 }, + { "Flamband", specs+13, N_F, 7, 59, 4, 0 }, + { "Annibal", specs+9, N_F, 4, 56, 4, 0 }, + { "Severe", specs+11, N_F, 2, 54, 4, 0 }, + { "Brilliant", specs+49, N_F, -1, 51, 4, 0 }, + { "Sphinx", specs+51, N_F, -5, 47, 4, 0 } + } }, - 1, 3, 4, 2, "Nymphe vs. Cleopatre", - { - { "Nymphe", specs+14, N_B, 13, 30, 2, 0 }, - { "Cleopatre", specs+15, N_F, 3, 41, 2, 0 } + { 1, 3, 4, 2, "Nymphe vs. Cleopatre", + { + { "Nymphe", specs+14, N_B, 13, 30, 2, 0 }, + { "Cleopatre", specs+15, N_F, 3, 41, 2, 0 } + } }, - 1, 3, 5, 2, "Mars vs. Hercule", - { - { "Mars", specs+16, N_B, 13, 30, 2, 0 }, - { "Hercule", specs+17, N_F, 3, 41, 2, 0 } + { 1, 3, 5, 2, "Mars vs. Hercule", + { + { "Mars", specs+16, N_B, 13, 30, 2, 0 }, + { "Hercule", specs+17, N_F, 3, 41, 2, 0 } + } }, - 5, 3, 5, 2, "Ambuscade vs. Baionnaise", - { - { "Ambuscade", specs+18, N_B, 13, 30, 2, 0 }, - { "Baionnaise", specs+19, N_F, 3, 41, 2, 0 } + { 5, 3, 5, 2, "Ambuscade vs. Baionnaise", + { + { "Ambuscade", specs+18, N_B, 13, 30, 2, 0 }, + { "Baionnaise", specs+19, N_F, 3, 41, 2, 0 } + } }, - 1, 5, 6, 2, "Constellation vs. Insurgent", - { - { "Constellation", specs+20, N_A, 9, 50, 8, 0 }, - { "Insurgent", specs+22, N_F, 4, 24, 2, 0 } + { 1, 5, 6, 2, "Constellation vs. Insurgent", + { + { "Constellation", specs+20, N_A, 9, 50, 8, 0 }, + { "Insurgent", specs+22, N_F, 4, 24, 2, 0 } + } }, - 1, 3, 5, 2, "Constellation vs. Vengeance", - { - { "Constellation", specs+20, N_A, 12, 40, 2, 0 }, - { "Vengeance", specs+21, N_F, 1, 43, 2, 0 } + { 1, 3, 5, 2, "Constellation vs. Vengeance", + { + { "Constellation", specs+20, N_A, 12, 40, 2, 0 }, + { "Vengeance", specs+21, N_F, 1, 43, 2, 0 } + } }, - 1, 3, 6, 10, "The Battle of Lissa", - { - { "Amphion", specs+23, N_B, 8, 50, 4, 0 }, - { "Active", specs+24, N_B, 6, 48, 4, 0 }, - { "Volage", specs+25, N_B, 4, 46, 4, 0 }, - { "Cerberus", specs+26, N_B, 2, 44, 4, 0 }, - { "Favorite", specs+27, N_F, 9, 34, 2, 0 }, - { "Flore", specs+21, N_F, 13, 39, 2, 0 }, - { "Danae", specs+64, N_F, 15, 37, 2, 0 }, - { "Bellona", specs+28, N_F, 17, 35, 2, 0 }, - { "Corona", specs+29, N_F, 12, 31, 2, 0 }, - { "Carolina", specs+30, N_F, 15, 28, 2, 0 } + { 1, 3, 6, 10, "The Battle of Lissa", + { + { "Amphion", specs+23, N_B, 8, 50, 4, 0 }, + { "Active", specs+24, N_B, 6, 48, 4, 0 }, + { "Volage", specs+25, N_B, 4, 46, 4, 0 }, + { "Cerberus", specs+26, N_B, 2, 44, 4, 0 }, + { "Favorite", specs+27, N_F, 9, 34, 2, 0 }, + { "Flore", specs+21, N_F, 13, 39, 2, 0 }, + { "Danae", specs+64, N_F, 15, 37, 2, 0 }, + { "Bellona", specs+28, N_F, 17, 35, 2, 0 }, + { "Corona", specs+29, N_F, 12, 31, 2, 0 }, + { "Carolina", specs+30, N_F, 15, 28, 2, 0 } + } }, - 2, 5, 6, 2, "Constitution vs. Guerriere", - { - { "Constitution", specs+31, N_A, 7, 35, 1, 0 }, - { "Guerriere", specs+32, N_B, 7, 47, 4, 0 } + { 2, 5, 6, 2, "Constitution vs. Guerriere", + { + { "Constitution", specs+31, N_A, 7, 35, 1, 0 }, + { "Guerriere", specs+32, N_B, 7, 47, 4, 0 } + } }, - 1, 3, 5, 2, "United States vs. Macedonian", - { - { "United States", specs+33, N_A, 1, 52, 6, 0 }, - { "Macedonian", specs+34, N_B, 14, 40, 1, 0 } + { 1, 3, 5, 2, "United States vs. Macedonian", + { + { "United States", specs+33, N_A, 1, 52, 6, 0 }, + { "Macedonian", specs+34, N_B, 14, 40, 1, 0 } + } }, - 1, 3, 6, 2, "Constitution vs. Java", - { - { "Constitution", specs+31, N_A, 1, 40, 2, 0 }, - { "Java", specs+35, N_B, 11, 40, 2, 0 } + { 1, 3, 6, 2, "Constitution vs. Java", + { + { "Constitution", specs+31, N_A, 1, 40, 2, 0 }, + { "Java", specs+35, N_B, 11, 40, 2, 0 } + } }, - 1, 3, 5, 2, "Chesapeake vs. Shannon", - { - { "Chesapeake", specs+36, N_A, 13, 40, 2, 0 }, - { "Shannon", specs+37, N_B, 1, 42, 2, 0 } + { 1, 3, 5, 2, "Chesapeake vs. Shannon", + { + { "Chesapeake", specs+36, N_A, 13, 40, 2, 0 }, + { "Shannon", specs+37, N_B, 1, 42, 2, 0 } + } }, - 1, 1, 6, 5, "The Battle of Lake Erie", - { - { "Lawrence", specs+38, N_A, 4, 55, 8, 0 }, - { "Niagara", specs+42, N_A, 7, 61, 8, 0 }, - { "Lady Prevost", specs+39, N_B, 4, 25, 2, 0 }, - { "Detroit", specs+40, N_B, 7, 22, 2, 0 }, - { "Q. Charlotte", specs+41, N_B, 10, 19, 2, 0 } + { 1, 1, 6, 5, "The Battle of Lake Erie", + { + { "Lawrence", specs+38, N_A, 4, 55, 8, 0 }, + { "Niagara", specs+42, N_A, 7, 61, 8, 0 }, + { "Lady Prevost", specs+39, N_B, 4, 25, 2, 0 }, + { "Detroit", specs+40, N_B, 7, 22, 2, 0 }, + { "Q. Charlotte", specs+41, N_B, 10, 19, 2, 0 } + } }, - 1, 1, 5, 2, "Wasp vs. Reindeer", - { - { "Wasp", specs+42, N_A, 3, 41, 2, 0 }, - { "Reindeer", specs+43, N_B, 10, 48, 2, 0 } + { 1, 1, 5, 2, "Wasp vs. Reindeer", + { + { "Wasp", specs+42, N_A, 3, 41, 2, 0 }, + { "Reindeer", specs+43, N_B, 10, 48, 2, 0 } + } }, - 1, 2, 5, 3, "Constitution vs. Cyane and Levant", - { - { "Constitution", specs+31, N_A, 10, 45, 2, 0 }, - { "Cyane", specs+44, N_B, 3, 37, 2, 0 }, - { "Levant", specs+45, N_B, 5, 35, 2, 0 } + { 1, 2, 5, 3, "Constitution vs. Cyane and Levant", + { + { "Constitution", specs+31, N_A, 10, 45, 2, 0 }, + { "Cyane", specs+44, N_B, 3, 37, 2, 0 }, + { "Levant", specs+45, N_B, 5, 35, 2, 0 } + } }, - 5, 5, 5, 3, "Pellew vs. Droits de L'Homme", - { - { "Indefatigable", specs+46, N_B, 12, 45, 6, 0 }, - { "Amazon", specs+47, N_B, 9, 48, 6, 0 }, - { "Droits L'Hom", specs+48, N_F, 3, 28, 5, 0 } + { 5, 5, 5, 3, "Pellew vs. Droits de L'Homme", + { + { "Indefatigable", specs+46, N_B, 12, 45, 6, 0 }, + { "Amazon", specs+47, N_B, 9, 48, 6, 0 }, + { "Droits L'Hom", specs+48, N_F, 3, 28, 5, 0 } + } }, - 2, 2, 3, 10, "Algeciras", - { - { "Caesar", specs+49, N_B, 7, 70, 6, 0 }, - { "Pompee", specs+50, N_B, 5, 72, 6, 0 }, - { "Spencer", specs+5, N_B, 3, 74, 6, 0 }, - { "Hannibal", specs+7, N_B, 1, 76, 6, 0 }, - { "Real-Carlos", specs+53, N_S, 9, 20, 3, 0 }, - { "San Fernando", specs+54, N_S, 11, 16, 3, 0 }, - { "Argonauta", specs+55, N_S, 10, 14, 4, 0 }, - { "San Augustine", specs+56, N_S, 6, 22, 4, 0 }, - { "Indomptable", specs+51, N_F, 7, 23, 5, 0 }, - { "Desaix", specs+52, N_F, 7, 27, 7, 0 } + { 2, 2, 3, 10, "Algeciras", + { + { "Caesar", specs+49, N_B, 7, 70, 6, 0 }, + { "Pompee", specs+50, N_B, 5, 72, 6, 0 }, + { "Spencer", specs+5, N_B, 3, 74, 6, 0 }, + { "Hannibal", specs+7, N_B, 1, 76, 6, 0 }, + { "Real-Carlos", specs+53, N_S, 9, 20, 3, 0 }, + { "San Fernando", specs+54, N_S, 11, 16, 3, 0 }, + { "Argonauta", specs+55, N_S, 10, 14, 4, 0 }, + { "San Augustine", specs+56, N_S, 6, 22, 4, 0 }, + { "Indomptable", specs+51, N_F, 7, 23, 5, 0 }, + { "Desaix", specs+52, N_F, 7, 27, 7, 0 } + } }, - 5, 3, 6, 7, "Lake Champlain", - { - { "Saratoga", specs+60, N_A, 8, 10, 1, 0 }, - { "Eagle", specs+61, N_A, 9, 13, 2, 0 }, - { "Ticonderoga", specs+62, N_A, 12, 17, 3, 0 }, - { "Preble", specs+63, N_A, 14, 20, 2, 0 }, - { "Confiance", specs+57, N_B, 4, 70, 6, 0 }, - { "Linnet", specs+58, N_B, 7, 68, 6, 0 }, - { "Chubb", specs+59, N_B, 10, 65, 6, 0 } + { 5, 3, 6, 7, "Lake Champlain", + { + { "Saratoga", specs+60, N_A, 8, 10, 1, 0 }, + { "Eagle", specs+61, N_A, 9, 13, 2, 0 }, + { "Ticonderoga", specs+62, N_A, 12, 17, 3, 0 }, + { "Preble", specs+63, N_A, 14, 20, 2, 0 }, + { "Confiance", specs+57, N_B, 4, 70, 6, 0 }, + { "Linnet", specs+58, N_B, 7, 68, 6, 0 }, + { "Chubb", specs+59, N_B, 10, 65, 6, 0 } + } }, - 5, 3, 6, 4, "Last Voyage of the USS President", - { - { "President", specs+67, N_A, 12, 42, 5, 0 }, - { "Endymion", specs+64, N_B, 5, 42, 5, 0 }, - { "Pomone", specs+65, N_B, 7, 82, 6, 0 }, - { "Tenedos", specs+66, N_B, 7, -1, 4, 0 } + { 5, 3, 6, 4, "Last Voyage of the USS President", + { + { "President", specs+67, N_A, 12, 42, 5, 0 }, + { "Endymion", specs+64, N_B, 5, 42, 5, 0 }, + { "Pomone", specs+65, N_B, 7, 82, 6, 0 }, + { "Tenedos", specs+66, N_B, 7, -1, 4, 0 } + } }, - 7, 5, 5, 2, "Hornblower and the Natividad", - { - { "Lydia", specs+68, N_B, 12, 40, 2, 0 }, - { "Natividad", specs+69, N_S, 2, 40, 4, 0 } + { 7, 5, 5, 2, "Hornblower and the Natividad", + { + { "Lydia", specs+68, N_B, 12, 40, 2, 0 }, + { "Natividad", specs+69, N_S, 2, 40, 4, 0 } + } }, - 1, 3, 6, 2, "Curse of the Flying Dutchman", - { - { "Piece of Cake", specs+19, N_S, 7, 40, 2, 0 }, - { "Flying Dutchy", specs+71, N_F, 7, 41, 1, 0 } + { 1, 3, 6, 2, "Curse of the Flying Dutchman", + { + { "Piece of Cake", specs+19, N_S, 7, 40, 2, 0 }, + { "Flying Dutchy", specs+71, N_F, 7, 41, 1, 0 } + } }, - 1, 4, 1, 4, "The South Pacific", - { - { "USS Scurvy", specs+70, N_A, 7, 40, 1, 0 }, - { "HMS Tahiti", specs+71, N_B, 12, 60, 1, 0 }, - { "Australian", specs+18, N_S, 5, 20, 8, 0 }, - { "Bikini Atoll", specs+63, N_F, 2, 60, 4, 0 } + { 1, 4, 1, 4, "The South Pacific", + { + { "USS Scurvy", specs+70, N_A, 7, 40, 1, 0 }, + { "HMS Tahiti", specs+71, N_B, 12, 60, 1, 0 }, + { "Australian", specs+18, N_S, 5, 20, 8, 0 }, + { "Bikini Atoll", specs+63, N_F, 2, 60, 4, 0 } + } }, - 7, 3, 6, 5, "Hornblower and the battle of Rosas bay", - { - { "Sutherland", specs+5, N_B, 13, 30, 2, 0 }, - { "Turenne", specs+10, N_F, 9, 35, 6, 0 }, - { "Nightmare", specs+9, N_F, 7, 37, 6, 0 }, - { "Paris", specs+53, N_F, 3, 45, 4, 0 }, - { "Napoleon", specs+56, N_F, 1, 40, 6, 0 } + { 7, 3, 6, 5, "Hornblower and the battle of Rosas bay", + { + { "Sutherland", specs+5, N_B, 13, 30, 2, 0 }, + { "Turenne", specs+10, N_F, 9, 35, 6, 0 }, + { "Nightmare", specs+9, N_F, 7, 37, 6, 0 }, + { "Paris", specs+53, N_F, 3, 45, 4, 0 }, + { "Napoleon", specs+56, N_F, 1, 40, 6, 0 } + } }, - 6, 4, 7, 5, "Cape Horn", - { - { "Concord", specs+51, N_A, 3, 20, 4, 0 }, - { "Berkeley", specs+7, N_A, 5, 50, 5, 0 }, - { "Thames", specs+71, N_B, 10, 40, 1, 0 }, - { "Madrid", specs+53, N_S, 13, 60, 8, 0 }, - { "Musket", specs+10, N_F, 10, 60, 7, 0 } + { 6, 4, 7, 5, "Cape Horn", + { + { "Concord", specs+51, N_A, 3, 20, 4, 0 }, + { "Berkeley", specs+7, N_A, 5, 50, 5, 0 }, + { "Thames", specs+71, N_B, 10, 40, 1, 0 }, + { "Madrid", specs+53, N_S, 13, 60, 8, 0 }, + { "Musket", specs+10, N_F, 10, 60, 7, 0 } + } }, - 8, 3, 7, 3, "New Orleans", - { - { "Alligator", specs+71, N_A, 13, 5, 1, 0 }, - { "Firefly", specs+50, N_B, 10, 20, 8, 0 }, - { "Cypress", specs+46, N_B, 5, 10, 6, 0 } + { 8, 3, 7, 3, "New Orleans", + { + { "Alligator", specs+71, N_A, 13, 5, 1, 0 }, + { "Firefly", specs+50, N_B, 10, 20, 8, 0 }, + { "Cypress", specs+46, N_B, 5, 10, 6, 0 } + } }, - 5, 3, 7, 3, "Botany Bay", - { - { "Shark", specs+11, N_B, 6, 15, 4, 0 }, - { "Coral Snake", specs+31, N_F, 3, 30, 6, 0 }, - { "Sea Lion", specs+33, N_F, 13, 50, 8, 0 } + { 5, 3, 7, 3, "Botany Bay", + { + { "Shark", specs+11, N_B, 6, 15, 4, 0 }, + { "Coral Snake", specs+31, N_F, 3, 30, 6, 0 }, + { "Sea Lion", specs+33, N_F, 13, 50, 8, 0 } + } }, - 4, 3, 6, 4, "Voyage to the Bottom of the Sea", - { - { "Seaview", specs+71, N_A, 6, 3, 3, 0 }, - { "Flying Sub", specs+64, N_A, 8, 3, 3, 0 }, - { "Mermaid", specs+70, N_B, 2, 5, 5, 0 }, - { "Giant Squid", specs+53, N_S, 10, 30, 8, 0 } + { 4, 3, 6, 4, "Voyage to the Bottom of the Sea", + { + { "Seaview", specs+71, N_A, 6, 3, 3, 0 }, + { "Flying Sub", specs+64, N_A, 8, 3, 3, 0 }, + { "Mermaid", specs+70, N_B, 2, 5, 5, 0 }, + { "Giant Squid", specs+53, N_S, 10, 30, 8, 0 } + } }, - 7, 3, 6, 3, "Frigate Action", - { - { "Killdeer", specs+21, N_A, 7, 20, 8, 0 }, - { "Sandpiper", specs+27, N_B, 5, 40, 8, 0 }, - { "Curlew", specs+34, N_S, 10, 60, 8, 0 } + { 7, 3, 6, 3, "Frigate Action", + { + { "Killdeer", specs+21, N_A, 7, 20, 8, 0 }, + { "Sandpiper", specs+27, N_B, 5, 40, 8, 0 }, + { "Curlew", specs+34, N_S, 10, 60, 8, 0 } + } }, - 7, 2, 5, 6, "The Battle of Midway", - { - { "Enterprise", specs+49, N_A, 10, 70, 8, 0 }, - { "Yorktown", specs+51, N_A, 3, 70, 7, 0 }, - { "Hornet", specs+52, N_A, 6, 70, 7, 0 }, - { "Akagi", specs+53, N_J, 6, 10, 4, 0 }, - { "Kaga", specs+54, N_J, 4, 12, 4, 0 }, - { "Soryu", specs+55, N_J, 2, 14, 4, 0 } + { 7, 2, 5, 6, "The Battle of Midway", + { + { "Enterprise", specs+49, N_A, 10, 70, 8, 0 }, + { "Yorktown", specs+51, N_A, 3, 70, 7, 0 }, + { "Hornet", specs+52, N_A, 6, 70, 7, 0 }, + { "Akagi", specs+53, N_J, 6, 10, 4, 0 }, + { "Kaga", specs+54, N_J, 4, 12, 4, 0 }, + { "Soryu", specs+55, N_J, 2, 14, 4, 0 } + } }, - 1, 3, 4, 8, "Star Trek", - { - { "Enterprise", specs+76, N_D,-10, 60, 7, 0 }, - { "Yorktown", specs+77, N_D, 0, 70, 7, 0 }, - { "Reliant", specs+78, N_D, 10, 70, 7, 0 }, - { "Galileo", specs+79, N_D, 20, 60, 7, 0 }, - { "Kobayashi Maru", specs+80, N_K, 0,120, 7, 0 }, - { "Klingon II", specs+81, N_K, 10,120, 7, 0 }, - { "Red Orion", specs+82, N_O, 0, 0, 3, 0 }, - { "Blue Orion", specs+83, N_O, 10, 0, 3, 0 } + { 1, 3, 4, 8, "Star Trek", + { + { "Enterprise", specs+76, N_D,-10, 60, 7, 0 }, + { "Yorktown", specs+77, N_D, 0, 70, 7, 0 }, + { "Reliant", specs+78, N_D, 10, 70, 7, 0 }, + { "Galileo", specs+79, N_D, 20, 60, 7, 0 }, + { "Kobayashi Maru", specs+80, N_K, 0,120, 7, 0 }, + { "Klingon II", specs+81, N_K, 10,120, 7, 0 }, + { "Red Orion", specs+82, N_O, 0, 0, 3, 0 }, + { "Blue Orion", specs+83, N_O, 10, 0, 3, 0 } + } } }; int nscene = sizeof scene / sizeof (struct scenario); struct shipspecs specs[] = { /* bs fs ta guns hull crew1 crew3 gunR carR rig2 rig4 pts */ -/* class qual crew2 gunL carL rig1 rig3 */ -/*00*/ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7, -/*01*/ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 4, 4, 3, 3, 3, 3, 6, -/*02*/ 3, 5, 2, 42, 4, 7, 4, 2, 2, 2, 2, 2, 0, 0, 5, 5, 5, -1, 11, -/*03*/ 4, 6, 3, 44, 3, 7, 4, 2, 2, 2, 3, 3, 0, 0, 5, 5, 5, 5, 12, -/*04*/ 3, 5, 2, 64, 2, 17, 4, 8, 6, 6, 12, 12, 2, 2, 7, 7, 7, -1, 20, -/*05*/ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26, -/*06*/ 3, 5, 2, 50, 2, 12, 4, 6, 4, 4, 8, 8, 2, 2, 6, 6, 6, -1, 17, -/*07*/ 3, 5, 1, 98, 1, 23, 4, 10, 10, 10, 18, 18, 2, 2, 8, 8, 8, -1, 28, -/*08*/ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26, -/*09*/ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 24, -/*10*/ 3, 5, 1, 80, 1, 23, 3, 12, 12, 10, 22, 22, 0, 0, 7, 7, 7, -1, 27, -/*11*/ 3, 5, 2, 64, 2, 18, 3, 8, 8, 6, 12, 12, 0, 0, 7, 7, 7, -1, 18, -/*12*/ 3, 5, 2, 44, 2, 11, 3, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, -1, 10, -/*13*/ 3, 5, 2, 50, 2, 14, 3, 6, 6, 4, 8, 8, 0, 0, 6, 6, 6, -1, 14, -/*14*/ 4, 6, 3, 36, 3, 11, 4, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 11, -/*15*/ 4, 6, 3, 36, 3, 11, 3, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 10, -/*16*/ 3, 5, 2, 74, 2, 21, 4, 10, 8, 8, 18, 18, 2, 2, 7, 7, 7, -1, 26, -/*17*/ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 23, -/*18*/ 4, 6, 3, 32, 3, 8, 3, 4, 2, 2, 4, 4, 2, 2, 5, 5, 5, 5, 9, -/*19*/ 4, 6, 3, 24, 4, 6, 3, 4, 4, 4, 2, 2, 0, 0, 4, 4, 4, 4, 9, -/*20*/ 4, 7, 3, 38, 4, 14, 5, 6, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5, 17, -/*21*/ 4, 6, 3, 40, 3, 15, 3, 8, 6, 6, 6, 6, 4, 4, 5, 5, 5, 5, 15, -/*22*/ 4, 7, 3, 36, 4, 11, 3, 6, 6, 4, 4, 4, 2, 2, 5, 5, 5, 5, 11, -/*23*/ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13, -/*24*/ 4, 6, 3, 38, 3, 14, 5, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 18, -/*25*/ 4, 6, 3, 22, 3, 6, 5, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 11, -/*26*/ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13, -/*27*/ 4, 6, 3, 40, 3, 14, 3, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 15, -/*28*/ 4, 6, 3, 32, 3, 11, 2, 4, 4, 4, 4, 4, 0, 0, 5, 5, 5, 5, 9, -/*29*/ 4, 6, 3, 40, 3, 14, 2, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 12, -/*30*/ 4, 6, 3, 32, 3, 8, 2, 4, 4, 1, 2, 2, 0, 0, 4, 4, 4, 4, 7, -/*31*/ 4, 7, 3, 44, 4, 18, 5, 6, 6, 6, 8, 8, 6, 6, 6, 6, 6, 6, 24, -/*32*/ 4, 6, 3, 38, 3, 14, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 15, -/*33*/ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24, -/*34*/ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 16, -/*35*/ 4, 7, 3, 38, 4, 14, 4, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 19, -/*36*/ 4, 6, 3, 38, 3, 14, 3, 6, 6, 4, 6, 6, 6, 6, 5, 5, 5, 5, 14, -/*37*/ 4, 6, 3, 38, 3, 14, 5, 6, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 17, -/*38*/ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9, -/*39*/ 4, 7, 3, 13, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5, -/*40*/ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7, -/*41*/ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 3, 3, 3, 3, 6, -/*42*/ 4, 7, 3, 20, 5, 6, 5, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 12, -/*43*/ 4, 7, 3, 18, 5, 5, 5, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9, -/*44*/ 4, 7, 3, 24, 5, 6, 4, 4, 2, 2, 0, 0,10,10, 4, 4, 4, 4, 11, -/*45*/ 4, 7, 3, 20, 5, 6, 4, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 10, -/*46*/ 4, 6, 3, 44, 3, 11, 5, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 14, -/*47*/ 4, 6, 3, 36, 3, 12, 4, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, 5, 14, -/*48*/ 3, 5, 2, 74, 2, 21, 3, 10, 8, 8, 20, 20, 2, 2, 4, 4, 7, -1, 24, -/*49*/ 3, 5, 2, 80, 2, 24, 4, 10, 8, 8, 20, 20, 2, 2, 8, 8, 8, -1, 31, -/*50*/ 3, 5, 2, 74, 2, 21, 4, 8, 8, 6, 16, 16, 4, 4, 7, 7, 7, -1, 27, -/*51*/ 3, 5, 2, 80, 2, 24, 3, 12, 12, 10, 22, 22, 2, 2, 7, 7, 7, -1, 27, -/*52*/ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 24, -/*53*/ 3, 5, 1, 112, 1, 27, 2, 12, 12, 12, 24, 24, 0, 0, 9, 9, 9, -1, 27, -/*54*/ 3, 5, 1, 96, 1, 24, 2, 12, 12, 10, 20, 20, 0, 0, 8, 8, 8, -1, 24, -/*55*/ 3, 5, 2, 80, 2, 23, 2, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 23, -/*56*/ 3, 5, 2, 74, 2, 21, 2, 10, 8, 8, 16, 16, 4, 4, 7, 7, 7, -1, 20, -/*57*/ 4, 6, 3, 37, 3, 12, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 14, -/*58*/ 4, 7, 3, 16, 5, 5, 5, 2, 2, 2, 0, 0, 4, 4, 4, 4, 4, 4, 10, -/*59*/ 4, 7, 3, 11, 6, 3, 4, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5, -/*60*/ 4, 7, 3, 26, 5, 6, 4, 4, 2, 2, 2, 2, 6, 6, 4, 4, 4, 4, 12, -/*61*/ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 11, -/*62*/ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9, -/*63*/ 4, 7, 3, 7, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 4, -/*64*/ 4, 6, 3, 40, 3, 15, 4, 4, 4, 4, 8, 8, 6, 6, 5, 5, 5, 5, 17, -/*65*/ 4, 6, 3, 44, 3, 15, 4, 8, 8, 6, 10, 10, 2, 2, 6, 6, 6, 6, 20, -/*66*/ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 15, -/*67*/ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24, -/*68*/ 4, 6, 3, 36, 3, 9, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13, -/*69*/ 3, 5, 2, 50, 2, 14, 2, 6, 6, 6, 8, 8, 0, 0, 6, 6, 6, -1, 14, -/*70*/ 3, 5, 1, 136, 1, 30, 1, 8, 14, 14, 28, 28, 0, 0, 9, 9, 9, -1, 27, -/*71*/ 3, 5, 1, 120, 1, 27, 5, 16, 14, 14, 28, 28, 2, 2, 9, 9, 9, -1, 43, -/*72*/ 3, 5, 1, 120, 2, 21, 5, 15, 17, 15, 25, 25, 7, 7, 9, 9, 9, -1, 36, -/*73*/ 3, 5, 1, 90, 3, 18, 4, 13, 15, 13, 20, 20, 6, 6, 5, 5, 5, 5, 28, -/*74*/ 4, 7, 3, 6, 6, 3, 4, 2, 2, 2, 20, 20, 6, 6, 2, 2, 3, 3, 5, -/*75*/ 3, 5, 1, 110, 2, 20, 4, 14, 15, 11, 26, 26, 8, 8, 7, 8, 9, -1, 34, -/*76*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*77*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*78*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*79*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*80*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*81*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*82*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, -/*83*/ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75, +/* class qual crew2 gunL carL rig1 rig3 */ +/*00*/{ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, +/*01*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 4, 4, 3, 3, 3, 3, 6 }, +/*02*/{ 3, 5, 2, 42, 4, 7, 4, 2, 2, 2, 2, 2, 0, 0, 5, 5, 5, -1, 11 }, +/*03*/{ 4, 6, 3, 44, 3, 7, 4, 2, 2, 2, 3, 3, 0, 0, 5, 5, 5, 5, 12 }, +/*04*/{ 3, 5, 2, 64, 2, 17, 4, 8, 6, 6, 12, 12, 2, 2, 7, 7, 7, -1, 20 }, +/*05*/{ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26 }, +/*06*/{ 3, 5, 2, 50, 2, 12, 4, 6, 4, 4, 8, 8, 2, 2, 6, 6, 6, -1, 17 }, +/*07*/{ 3, 5, 1, 98, 1, 23, 4, 10, 10, 10, 18, 18, 2, 2, 8, 8, 8, -1, 28 }, +/*08*/{ 3, 5, 2, 74, 2, 20, 4, 8, 8, 8, 16, 16, 2, 2, 7, 7, 7, -1, 26 }, +/*09*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 24 }, +/*10*/{ 3, 5, 1, 80, 1, 23, 3, 12, 12, 10, 22, 22, 0, 0, 7, 7, 7, -1, 27 }, +/*11*/{ 3, 5, 2, 64, 2, 18, 3, 8, 8, 6, 12, 12, 0, 0, 7, 7, 7, -1, 18 }, +/*12*/{ 3, 5, 2, 44, 2, 11, 3, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, -1, 10 }, +/*13*/{ 3, 5, 2, 50, 2, 14, 3, 6, 6, 4, 8, 8, 0, 0, 6, 6, 6, -1, 14 }, +/*14*/{ 4, 6, 3, 36, 3, 11, 4, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 11 }, +/*15*/{ 4, 6, 3, 36, 3, 11, 3, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 10 }, +/*16*/{ 3, 5, 2, 74, 2, 21, 4, 10, 8, 8, 18, 18, 2, 2, 7, 7, 7, -1, 26 }, +/*17*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 23 }, +/*18*/{ 4, 6, 3, 32, 3, 8, 3, 4, 2, 2, 4, 4, 2, 2, 5, 5, 5, 5, 9 }, +/*19*/{ 4, 6, 3, 24, 4, 6, 3, 4, 4, 4, 2, 2, 0, 0, 4, 4, 4, 4, 9 }, +/*20*/{ 4, 7, 3, 38, 4, 14, 5, 6, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5, 17 }, +/*21*/{ 4, 6, 3, 40, 3, 15, 3, 8, 6, 6, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, +/*22*/{ 4, 7, 3, 36, 4, 11, 3, 6, 6, 4, 4, 4, 2, 2, 5, 5, 5, 5, 11 }, +/*23*/{ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, +/*24*/{ 4, 6, 3, 38, 3, 14, 5, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 18 }, +/*25*/{ 4, 6, 3, 22, 3, 6, 5, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 11 }, +/*26*/{ 4, 6, 3, 32, 3, 11, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, +/*27*/{ 4, 6, 3, 40, 3, 14, 3, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, +/*28*/{ 4, 6, 3, 32, 3, 11, 2, 4, 4, 4, 4, 4, 0, 0, 5, 5, 5, 5, 9 }, +/*29*/{ 4, 6, 3, 40, 3, 14, 2, 6, 6, 4, 6, 6, 4, 4, 5, 5, 5, 5, 12 }, +/*30*/{ 4, 6, 3, 32, 3, 8, 2, 4, 4, 1, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, +/*31*/{ 4, 7, 3, 44, 4, 18, 5, 6, 6, 6, 8, 8, 6, 6, 6, 6, 6, 6, 24 }, +/*32*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 15 }, +/*33*/{ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24 }, +/*34*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 4, 4, 5, 5, 5, 5, 16 }, +/*35*/{ 4, 7, 3, 38, 4, 14, 4, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 19 }, +/*36*/{ 4, 6, 3, 38, 3, 14, 3, 6, 6, 4, 6, 6, 6, 6, 5, 5, 5, 5, 14 }, +/*37*/{ 4, 6, 3, 38, 3, 14, 5, 6, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 17 }, +/*38*/{ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, +/*39*/{ 4, 7, 3, 13, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5 }, +/*40*/{ 4, 7, 3, 19, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 4, 4, 4, 4, 7 }, +/*41*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 2, 2, 0, 0, 3, 3, 3, 3, 6 }, +/*42*/{ 4, 7, 3, 20, 5, 6, 5, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 12 }, +/*43*/{ 4, 7, 3, 18, 5, 5, 5, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, +/*44*/{ 4, 7, 3, 24, 5, 6, 4, 4, 2, 2, 0, 0,10,10, 4, 4, 4, 4, 11 }, +/*45*/{ 4, 7, 3, 20, 5, 6, 4, 2, 2, 2, 0, 0, 8, 8, 4, 4, 4, 4, 10 }, +/*46*/{ 4, 6, 3, 44, 3, 11, 5, 4, 4, 4, 4, 4, 2, 2, 5, 5, 5, 5, 14 }, +/*47*/{ 4, 6, 3, 36, 3, 12, 4, 4, 4, 4, 6, 6, 2, 2, 5, 5, 5, 5, 14 }, +/*48*/{ 3, 5, 2, 74, 2, 21, 3, 10, 8, 8, 20, 20, 2, 2, 4, 4, 7, -1, 24 }, +/*49*/{ 3, 5, 2, 80, 2, 24, 4, 10, 8, 8, 20, 20, 2, 2, 8, 8, 8, -1, 31 }, +/*50*/{ 3, 5, 2, 74, 2, 21, 4, 8, 8, 6, 16, 16, 4, 4, 7, 7, 7, -1, 27 }, +/*51*/{ 3, 5, 2, 80, 2, 24, 3, 12, 12, 10, 22, 22, 2, 2, 7, 7, 7, -1, 27 }, +/*52*/{ 3, 5, 2, 74, 2, 21, 3, 10, 10, 8, 20, 20, 2, 2, 7, 7, 7, -1, 24 }, +/*53*/{ 3, 5, 1, 112, 1, 27, 2, 12, 12, 12, 24, 24, 0, 0, 9, 9, 9, -1, 27 }, +/*54*/{ 3, 5, 1, 96, 1, 24, 2, 12, 12, 10, 20, 20, 0, 0, 8, 8, 8, -1, 24 }, +/*55*/{ 3, 5, 2, 80, 2, 23, 2, 10, 10, 8, 20, 20, 0, 0, 7, 7, 7, -1, 23 }, +/*56*/{ 3, 5, 2, 74, 2, 21, 2, 10, 8, 8, 16, 16, 4, 4, 7, 7, 7, -1, 20 }, +/*57*/{ 4, 6, 3, 37, 3, 12, 4, 4, 4, 2, 6, 6, 4, 4, 5, 5, 5, 5, 14 }, +/*58*/{ 4, 7, 3, 16, 5, 5, 5, 2, 2, 2, 0, 0, 4, 4, 4, 4, 4, 4, 10 }, +/*59*/{ 4, 7, 3, 11, 6, 3, 4, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 5 }, +/*60*/{ 4, 7, 3, 26, 5, 6, 4, 4, 2, 2, 2, 2, 6, 6, 4, 4, 4, 4, 12 }, +/*61*/{ 4, 7, 3, 20, 5, 6, 4, 4, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 11 }, +/*62*/{ 4, 7, 3, 17, 5, 5, 4, 2, 2, 2, 0, 0, 6, 6, 4, 4, 4, 4, 9 }, +/*63*/{ 4, 7, 3, 7, 6, 3, 4, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 4 }, +/*64*/{ 4, 6, 3, 40, 3, 15, 4, 4, 4, 4, 8, 8, 6, 6, 5, 5, 5, 5, 17 }, +/*65*/{ 4, 6, 3, 44, 3, 15, 4, 8, 8, 6, 10, 10, 2, 2, 6, 6, 6, 6, 20 }, +/*66*/{ 4, 6, 3, 38, 3, 14, 4, 4, 4, 4, 6, 6, 6, 6, 5, 5, 5, 5, 15 }, +/*67*/{ 4, 5, 3, 44, 3, 18, 5, 8, 6, 6, 8, 8, 8, 8, 6, 6, 6, 6, 24 }, +/*68*/{ 4, 6, 3, 36, 3, 9, 5, 4, 4, 2, 4, 4, 2, 2, 5, 5, 5, 5, 13 }, +/*69*/{ 3, 5, 2, 50, 2, 14, 2, 6, 6, 6, 8, 8, 0, 0, 6, 6, 6, -1, 14 }, +/*70*/{ 3, 5, 1, 136, 1, 30, 1, 8, 14, 14, 28, 28, 0, 0, 9, 9, 9, -1, 27 }, +/*71*/{ 3, 5, 1, 120, 1, 27, 5, 16, 14, 14, 28, 28, 2, 2, 9, 9, 9, -1, 43 }, +/*72*/{ 3, 5, 1, 120, 2, 21, 5, 15, 17, 15, 25, 25, 7, 7, 9, 9, 9, -1, 36 }, +/*73*/{ 3, 5, 1, 90, 3, 18, 4, 13, 15, 13, 20, 20, 6, 6, 5, 5, 5, 5, 28 }, +/*74*/{ 4, 7, 3, 6, 6, 3, 4, 2, 2, 2, 20, 20, 6, 6, 2, 2, 3, 3, 5 }, +/*75*/{ 3, 5, 1, 110, 2, 20, 4, 14, 15, 11, 26, 26, 8, 8, 7, 8, 9, -1, 34 }, +/*76*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*77*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*78*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*79*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*80*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*81*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*82*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 }, +/*83*/{ 4, 7, 3, 450, 1, 99, 5, 50, 40, 40, 50, 50,25,25, 9, 9, 9, -1, 75 } /* bs fs ta guns hull crew1 crew3 gunR carR rig2 rig4 pts */ -/* class qual crew2 gunL carL rig1 rig3 */ +/* class qual crew2 gunL carL rig1 rig3 */ }; -struct windeffects WET[7][6] = { +const struct windeffects WET[7][6] = { { {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9} }, { {3,2,2,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {2,1,0,0}, {2,1,0,0} }, { {1,1,1,0}, {1,1,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0} }, @@ -383,7 +416,7 @@ struct windeffects WET[7][6] = { { {2,1,1,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {3,3,2,0}, {3,3,2,0} } }; -struct Tables RigTable[11][6] = { +const struct Tables RigTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0} }, { {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0}, {1,0,0,1}, {0,1,1,1} }, { {0,0,0,0}, {0,0,0,1}, {0,0,1,1}, {0,1,0,1}, {0,1,0,1}, {1,0,1,2} }, @@ -396,7 +429,8 @@ struct Tables RigTable[11][6] = { { {1,1,0,4}, {1,0,1,4}, {2,0,0,5}, {0,2,1,5}, {0,1,2,6}, {0,2,0,7} }, { {1,0,1,5}, {0,2,0,6}, {1,2,0,6}, {1,1,1,6}, {2,0,2,6}, {1,1,2,7} } }; -struct Tables HullTable[11][6] = { + +const struct Tables HullTable[11][6] = { { {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,0,0,0}, {0,1,0,0} }, { {0,0,0,0}, {0,0,0,0}, {0,1,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1} }, { {0,1,0,0}, {1,0,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1}, {2,1,0,0} }, @@ -410,7 +444,7 @@ struct Tables HullTable[11][6] = { { {2,2,4,0}, {3,3,1,1}, {4,2,1,1}, {5,1,0,2}, {5,1,2,1}, {6,2,2,0} }, }; -char AMMO[9][4] = { +const char AMMO[9][4] = { { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, { -1, 1, 0, 1 }, @@ -422,7 +456,7 @@ char AMMO[9][4] = { { -3, 2, 0, 3 } }; -char HDT[9][10] = { +const char HDT[9][10] = { { 1, 0,-1,-2,-3,-3,-4,-4,-4,-4 }, { 1, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, @@ -434,7 +468,7 @@ char HDT[9][10] = { { 5, 4, 3, 2, 1, 1, 0, 0, 0, 0 } }; -char HDTrake[9][10] = { +const char HDTrake[9][10] = { { 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 }, { 2, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, { 3, 2, 1, 0,-1,-1,-2,-2,-2,-2 }, @@ -446,7 +480,7 @@ char HDTrake[9][10] = { { 9, 8, 7, 6, 5, 5, 4, 4, 4, 4 } }; -char QUAL[9][5] = { +const char QUAL[9][5] = { { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 1 }, { -1, 0, 0, 1, 2 }, @@ -458,7 +492,7 @@ char QUAL[9][5] = { { -2,-1, 0, 2, 3 } }; -char MT[9][3] = { +const char MT[9][3] = { { 1, 0, 0 }, { 1, 1, 0 }, { 2, 1, 0 }, @@ -470,7 +504,7 @@ char MT[9][3] = { { 4, 4, 2 } }; -char rangeofshot[5] = { +const char rangeofshot[] = { 0, 1, /* grape */ 3, /* chain */ @@ -478,12 +512,12 @@ char rangeofshot[5] = { 1 /* double */ }; -char *countryname[8] = { +const char *const countryname[] = { "American", "British", "Spanish", "French", "Japanese", "Federation", "Klingon", "Orion" }; -char *classname[7] = { +const char *const classname[] = { "Drift wood", "Ship of the Line", "Ship of the Line", @@ -493,7 +527,7 @@ char *classname[7] = { "Brig" }; -char *directionname[9] = { +const char *const directionname[] = { "dead ahead", "off the starboard bow", "off the starboard beam", @@ -505,11 +539,11 @@ char *directionname[9] = { "dead ahead" }; -char *qualname[6] = { +const char *const qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" }; -char loadname[6] = { '-', 'G', 'C', 'R', 'D', 'E' }; +const char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' }; -int dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; -int dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 }; +const char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 }; +const char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 }; diff --git a/games/sail/lo_main.c b/games/sail/lo_main.c index c4f3a143bb4..8d09e281caf 100644 --- a/games/sail/lo_main.c +++ b/games/sail/lo_main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: lo_main.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $ */ /* $NetBSD: lo_main.c,v 1.3 1995/04/22 10:36:59 cgd Exp $ */ /* @@ -35,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)lo_main.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)lo_main.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: lo_main.c,v 1.3 1995/04/22 10:36:59 cgd Exp $"; +static char rcsid[] = "$OpenBSD: lo_main.c,v 1.2 1999/01/18 06:20:52 pjanzen Exp $"; #endif #endif /* not lint */ @@ -48,15 +49,16 @@ static char rcsid[] = "$NetBSD: lo_main.c,v 1.3 1995/04/22 10:36:59 cgd Exp $"; */ #include <sys/types.h> #include <pwd.h> -#include "externs.h" +#include "extern.h" #include "pathnames.h" -char *title[] = { +const char *const title[] = { "Admiral", "Commodore", "Captain", "Captain", "Captain", "Captain", "Captain", "Commander", "Commander", "Lieutenant" }; +int lo_main() { FILE *fp; diff --git a/games/sail/main.c b/games/sail/main.c index 3d32adbe96b..a29dc0b52a7 100644 --- a/games/sail/main.c +++ b/games/sail/main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: main.c,v 1.3 1995/04/22 10:37:01 cgd Exp $ */ /* @@ -41,25 +42,40 @@ static char copyright[] = #ifndef lint #if 0 -static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/04/22 10:37:01 cgd Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <err.h> /*ARGSUSED*/ +int main(argc, argv) int argc; - register char **argv; + char **argv; { - register char *p; + char *p; int i; + int fd; - (void) srand(getpid()); - issetuid = getuid() != geteuid(); - if (p = strrchr(*argv, '/')) + gid = getgid(); + egid = getegid(); + setegid(gid); + + fd = open("/dev/null", O_RDONLY); + if (fd < 3) + exit(1); + close(fd); + + srandom(getpid()); + if ((p = strrchr(*argv, '/'))) p++; else p = *argv; @@ -81,7 +97,7 @@ main(argc, argv) debug++; break; case 'x': - randomize; + randomize++; break; case 'l': longfmt++; @@ -90,14 +106,13 @@ main(argc, argv) nobells++; break; default: - fprintf(stderr, "SAIL: Unknown flag %s.\n", p); - exit(1); + errx(1, "unknown flag %s", p); } if (*argv) game = atoi(*argv); else game = -1; - if (i = setjmp(restart)) + if ((i = setjmp(restart))) mode = i; switch (mode) { case MODE_PLAYER: @@ -107,7 +122,7 @@ main(argc, argv) case MODE_LOGGER: return lo_main(); default: - fprintf(stderr, "SAIL: Unknown mode %d.\n", mode); + warnx("Unknown mode %d", mode); abort(); } /*NOTREACHED*/ diff --git a/games/sail/misc.c b/games/sail/misc.c index 6dc18c728bc..bea2d896ace 100644 --- a/games/sail/misc.c +++ b/games/sail/misc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: misc.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: misc.c,v 1.3 1995/04/22 10:37:03 cgd Exp $ */ /* @@ -35,24 +36,29 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: misc.c,v 1.3 1995/04/22 10:37:03 cgd Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include <fcntl.h> +#include <stdlib.h> +#include <sys/file.h> +#include <unistd.h> +#include "extern.h" #include "pathnames.h" #define distance(x,y) (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2) /* XXX */ +int range(from, to) -struct ship *from, *to; + struct ship *from, *to; { - register bow1r, bow1c, bow2r, bow2c; + int bow1r, bow1c, bow2r, bow2c; int stern1r, stern1c, stern2c, stern2r; - register int bb, bs, sb, ss, result; + int bb, bs, sb, ss, result; if (!to->file->dir) return -1; @@ -76,11 +82,11 @@ struct ship *from, *to; struct ship * closestenemy(from, side, anyship) -register struct ship *from; -char side, anyship; + struct ship *from; + char side, anyship; { - register struct ship *sp; - register char a; + struct ship *sp; + char a; int olddist = 30000, dist; struct ship *closest = 0; @@ -103,10 +109,11 @@ char side, anyship; return closest; } +int angle(dr, dc) -register dr, dc; + int dr, dc; { - register i; + int i; if (dc >= 0 && dr > 0) i = 0; @@ -130,11 +137,12 @@ register dr, dc; return i % 8 + 1; } +int gunsbear(from, to) /* checks for target bow or stern */ -register struct ship *from, *to; + struct ship *from, *to; { int Dr, Dc, i; - register ang; + int ang; Dr = from->file->row - to->file->row; Dc = to->file->col - from->file->col; @@ -151,12 +159,13 @@ register struct ship *from, *to; return 0; } +int portside(from, on, quick) -register struct ship *from, *on; -int quick; /* returns true if fromship is */ + struct ship *from, *on; + int quick; /* returns true if fromship is */ { /* shooting at onship's starboard side */ - register ang; - register Dr, Dc; + int ang; + int Dr, Dc; Dr = from->file->row - on->file->row; Dc = on->file->col - from->file->col; @@ -171,36 +180,41 @@ int quick; /* returns true if fromship is */ return ang < 5; } +int colours(sp) -register struct ship *sp; + struct ship *sp; { - register char flag; + char flag; - if (sp->file->struck) + if (sp->file->struck) { flag = '!'; + return flag; + } if (sp->file->explode) flag = '#'; if (sp->file->sink) flag = '~'; - if (sp->file->struck) - return flag; flag = *countryname[capship(sp)->nationality]; return sp->file->FS ? flag : tolower(flag); } -#include <sys/file.h> -log(s) -register struct ship *s; +void +logger(s) + struct ship *s; { FILE *fp; int persons; int n; struct logs log[NLOG]; float net; - register struct logs *lp; + struct logs *lp; - if ((fp = fopen(_PATH_LOGFILE, "r+")) == NULL) + setegid(egid); + if ((fp = fopen(_PATH_LOGFILE, "r+")) == NULL) { + setegid(gid); return; + } + setegid(gid); #ifdef LOCK_EX if (flock(fileno(fp), LOCK_EX) < 0) return; diff --git a/games/sail/parties.c b/games/sail/parties.c index 7cfe13bac2d..de95e199c27 100644 --- a/games/sail/parties.c +++ b/games/sail/parties.c @@ -1,3 +1,4 @@ +/* $OpenBSD: parties.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: parties.c,v 1.3 1995/04/22 10:37:04 cgd Exp $ */ /* @@ -35,20 +36,21 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)parties.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)parties.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: parties.c,v 1.3 1995/04/22 10:37:04 cgd Exp $"; +static char rcsid[] = "$OpenBSD: parties.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include "extern.h" +int meleeing(from, to) -struct ship *from; -register struct ship *to; + struct ship *from; + struct ship *to; { - register struct BP *p = from->file->OBP; - register struct BP *q = p + NBP; + struct BP *p = from->file->OBP; + struct BP *q = p + NBP; for (; p < q; p++) if (p->turnsent && p->toship == to) @@ -56,12 +58,13 @@ register struct ship *to; return 0; } +int boarding(from, isdefense) -register struct ship *from; -char isdefense; + struct ship *from; + char isdefense; { - register struct BP *p = isdefense ? from->file->DBP : from->file->OBP; - register struct BP *q = p + NBP; + struct BP *p = isdefense ? from->file->DBP : from->file->OBP; + struct BP *q = p + NBP; for (; p < q; p++) if (p->turnsent) @@ -69,14 +72,15 @@ char isdefense; return 0; } +void unboard(ship, to, isdefense) -register struct ship *ship, *to; -register char isdefense; + struct ship *ship, *to; + char isdefense; { - register struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP; - register n; + struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP; + int n; for (n = 0; n < NBP; p++, n++) if (p->turnsent && (p->toship == to || isdefense || ship == to)) - Write(isdefense ? W_DBP : W_OBP, ship, 0, n, 0, 0, 0); + Write(isdefense ? W_DBP : W_OBP, ship, n, 0, 0, 0); } diff --git a/games/sail/pathnames.h b/games/sail/pathnames.h index ab17358f80c..249184e534a 100644 --- a/games/sail/pathnames.h +++ b/games/sail/pathnames.h @@ -1,3 +1,4 @@ +/* $OpenBSD: pathnames.h,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pathnames.h,v 1.3 1995/04/22 10:37:06 cgd Exp $ */ /*- @@ -36,3 +37,5 @@ */ #define _PATH_LOGFILE "/var/games/saillog" +#define _PATH_SYNC "/tmp/#sailsink.%d" +#define _PATH_LOCK "/tmp/#saillock.%d" diff --git a/games/sail/pl_1.c b/games/sail/pl_1.c index 5577f22f62f..a67ff635adf 100644 --- a/games/sail/pl_1.c +++ b/games/sail/pl_1.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_1.c,v 1.4 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_1.c,v 1.4 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ @@ -45,6 +46,7 @@ static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $"; #include <sys/types.h> #include <errno.h> #include <sys/wait.h> +#include <unistd.h> /* * If we get here before a ship is chosen, then ms == 0 and @@ -54,8 +56,9 @@ static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $"; * Of course, we don't do any more Sync()'s if we got here * because of a Sync() failure. */ +void leave(conditions) -int conditions; + int conditions; { (void) signal(SIGHUP, SIG_IGN); (void) signal(SIGINT, SIG_IGN); @@ -64,28 +67,24 @@ int conditions; (void) signal(SIGCHLD, SIG_IGN); if (done_curses) { - Signal("It looks like you've had it!", - (struct ship *)0); + Msg("It looks like you've had it!"); switch (conditions) { case LEAVE_QUIT: break; case LEAVE_CAPTURED: - Signal("Your ship was captured.", - (struct ship *)0); + Msg("Your ship was captured."); break; case LEAVE_HURRICAN: - Signal("Hurricane! All ships destroyed.", - (struct ship *)0); + Msg("Hurricane! All ships destroyed."); break; case LEAVE_DRIVER: - Signal("The driver died.", (struct ship *)0); + Msg("The driver died."); break; case LEAVE_SYNC: - Signal("Synchronization error.", (struct ship *)0); + Msg("Synchronization error."); break; default: - Signal("A funny thing happened (%d).", - (struct ship *)0, conditions); + Msg("A funny thing happened (%d).", conditions); } } else { switch (conditions) { @@ -107,27 +106,30 @@ int conditions; } if (ms != 0) { - log(ms); + logger(ms); if (conditions != LEAVE_SYNC) { - makesignal(ms, "Captain %s relinquishing.", - (struct ship *)0, mf->captain); - Write(W_END, ms, 0, 0, 0, 0, 0); + makemsg(ms, "Captain %s relinquishing.", + mf->captain); + Write(W_END, ms, 0, 0, 0, 0); (void) Sync(); } } sync_close(!hasdriver); + sleep(5); cleanupscreen(); exit(0); } void -choke() +choke(n) + int n; { leave(LEAVE_QUIT); } void -child() +child(n) + int n; { union wait status; int pid; @@ -136,7 +138,7 @@ child() (void) signal(SIGCHLD, SIG_IGN); do { pid = wait3((int *)&status, WNOHANG, (struct rusage *)0); - if (pid < 0 || pid > 0 && !WIFSTOPPED(status)) + if (pid < 0 || (pid > 0 && !WIFSTOPPED(status))) hasdriver = 0; } while (pid > 0); (void) signal(SIGCHLD, child); diff --git a/games/sail/pl_2.c b/games/sail/pl_2.c index e1b975f1165..e5cb1d0959c 100644 --- a/games/sail/pl_2.c +++ b/games/sail/pl_2.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_2.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_2.c,v 1.3 1995/04/22 10:37:08 cgd Exp $ */ /* @@ -37,15 +38,16 @@ #if 0 static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_2.c,v 1.3 1995/04/22 10:37:08 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_2.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include "player.h" +void play() { - register struct ship *sp; + struct ship *sp; for (;;) { switch (sgetch("~\b", (struct ship *)0, 0)) { @@ -62,7 +64,7 @@ play() unfoulplayer(); break; case 'v': - Signal("%s", (struct ship *)0, version); + Msg("%s", version); break; case 'b': acceptboard(); @@ -80,7 +82,7 @@ play() repair(); break; case 'B': - Signal("'Hands to stations!'", (struct ship *)0); + Msg("'Hands to stations!'"); unboard(ms, ms, 1); /* cancel DBP's */ unboard(ms, ms, 0); /* cancel offense */ break; @@ -96,10 +98,10 @@ play() mf->loadR = L_EMPTY; mf->readyL = R_EMPTY; mf->readyR = R_EMPTY; - Signal("Broadsides unloaded", (struct ship *)0); + Msg("Broadsides unloaded"); break; case 'q': - Signal("Type 'Q' to quit", (struct ship *)0); + Msg("Type 'Q' to quit"); break; case 'Q': leave(LEAVE_QUIT); @@ -111,7 +113,7 @@ play() break; case 'i': if ((sp = closestenemy(ms, 0, 1)) == 0) - Signal("No more ships left."); + Msg("No more ships left."); else eyeball(sp); break; diff --git a/games/sail/pl_3.c b/games/sail/pl_3.c index c860ec7ca55..71bb7bbae0a 100644 --- a/games/sail/pl_3.c +++ b/games/sail/pl_3.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_3.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_3.c,v 1.3 1995/04/22 10:37:09 cgd Exp $ */ /* @@ -37,12 +38,14 @@ #if 0 static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_3.c,v 1.3 1995/04/22 10:37:09 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_3.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include "player.h" +#include <stdlib.h> +void acceptcombat() { int men = 0; @@ -84,7 +87,7 @@ acceptcombat() guns = mc->gunL; car = mc->carL; } - if (!guns && !car || load == L_EMPTY || (ready & R_LOADED) == 0) + if ((!guns && !car) || load == L_EMPTY || (ready & R_LOADED) == 0) goto cant; if (mf->struck || !crew[2]) goto cant; @@ -94,9 +97,9 @@ acceptcombat() if (closest->file->struck) goto cant; target = range(ms, closest); - if (target > rangeofshot[load] || !guns && target >= 3) + if (target > rangeofshot[load] || (!guns && target >= 3)) goto cant; - Signal("%s (%c%c) within range of %s broadside.", + Signal("$$ within range of %s broadside.", closest, r ? "right" : "left"); if (load > L_CHAIN && target < 6) { switch (sgetch("Aim for hull or rigging? ", @@ -109,14 +112,12 @@ acceptcombat() break; default: shootat = -1; - Signal("'Avast there! Hold your fire.'", - (struct ship *)0); + Msg("'Avast there! Hold your fire.'"); } } else { if (sgetch("Fire? ", (struct ship *)0, 1) == 'n') { shootat = -1; - Signal("Belay that! Hold your fire.", - (struct ship *)0); + Msg("Belay that! Hold your fire."); } else shootat = RIGGING; } @@ -130,11 +131,13 @@ acceptcombat() else if (temp > 8) temp -= 8; sternrake = temp > 4 && temp < 6; - if (rakehim) + if (rakehim) { if (!sternrake) - Signal("Raking the %s!", closest); + Msg("Raking the %s!", closest->shipname); else - Signal("Stern Rake! %s splintering!", closest); + Msg("Stern Rake! %s splintering!", + closest->shipname); + } index = guns; if (target < 3) index += car; @@ -148,21 +151,24 @@ acceptcombat() hit++; hit += QUAL[index][mc->qual-1]; for (n = 0; n < 3 && mf->captured == 0; n++) - if (!crew[n]) + if (!crew[n]) { if (index <= 5) hit--; else hit -= 2; - if (ready & R_INITIAL) + } + if (ready & R_INITIAL) { if (index <= 3) hit++; else hit += 2; - if (mf->captured != 0) + } + if (mf->captured != 0) { if (index <= 1) hit--; else hit -= 2; + } hit += AMMO[index][load - 1]; if (((temp = mc->class) >= 5 || temp == 1) && windspeed == 5) hit--; @@ -175,7 +181,7 @@ acceptcombat() if (load == L_GRAPE) chits = hit; else { - struct Tables *t; + const struct Tables *t; if (hit > 10) hit = 10; t = &(shootat == RIGGING ? RigTable : HullTable) @@ -193,10 +199,9 @@ acceptcombat() } table(shootat, load, hit, closest, ms, roll); } - Signal("Damage inflicted on the %s:", - (struct ship *)0, closest->shipname); - Signal("\t%d HULL, %d GUNS, %d CREW, %d RIGGING", - (struct ship *)0, hhits, ghits, chits, rhits); + Msg("Damage inflicted on the %s:", closest->shipname); + Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING", + hhits, ghits, chits, rhits); if (!r) { mf->loadL = L_EMPTY; mf->readyL = R_EMPTY; @@ -206,35 +211,35 @@ acceptcombat() } continue; cant: - Signal("Unable to fire %s broadside", - (struct ship *)0, r ? "right" : "left"); + Msg("Unable to fire %s broadside", r ? "right" : "left"); } blockalarm(); draw_stat(); unblockalarm(); } +void grapungrap() { - register struct ship *sp; - register int i; + struct ship *sp; + int i; foreachship(sp) { if (sp == ms || sp->file->dir == 0) continue; if (range(ms, sp) > 1 && !grappled2(ms, sp)) continue; - switch (sgetch("Attempt to grapple or ungrapple %s (%c%c): ", + switch (sgetch("Attempt to grapple or ungrapple $$: ", sp, 1)) { case 'g': if (die() < 3 || ms->nationality == capship(sp)->nationality) { - Write(W_GRAP, ms, 0, sp->file->index, 0, 0, 0); - Write(W_GRAP, sp, 0, player, 0, 0, 0); - Signal("Attempt succeeds!", (struct ship *)0); - makesignal(ms, "grappled with %s (%c%c)", sp); + Write(W_GRAP, ms, sp->file->index, 0, 0, 0); + Write(W_GRAP, sp, player, 0, 0, 0); + Msg("Attempt succeeds!"); + makesignal(ms, "grappled with $$", sp); } else - Signal("Attempt fails.", (struct ship *)0); + Msg("Attempt fails."); break; case 'u': for (i = grappled2(ms, sp); --i >= 0;) { @@ -242,37 +247,35 @@ grapungrap() == capship(sp)->nationality || die() < 3) { cleangrapple(ms, sp, 0); - Signal("Attempt succeeds!", - (struct ship *)0); - makesignal(ms, - "ungrappling with %s (%c%c)", + Msg("Attempt succeeds!"); + makesignal(ms, "ungrappling with $$", sp); } else - Signal("Attempt fails.", - (struct ship *)0); + Msg("Attempt fails."); } break; } } } +void unfoulplayer() { - register struct ship *to; - register i; + struct ship *to; + int i; foreachship(to) { if (fouled2(ms, to) == 0) continue; - if (sgetch("Attempt to unfoul with the %s (%c%c)? ", to, 1) != 'y') + if (sgetch("Attempt to unfoul with the $$? ", to, 1) != 'y') continue; for (i = fouled2(ms, to); --i >= 0;) { if (die() <= 2) { cleanfoul(ms, to, 0); - Signal("Attempt succeeds!", (struct ship *)0); - makesignal(ms, "Unfouling %s (%c%c)", to); + Msg("Attempt succeeds!"); + makesignal(ms, "Unfouling $$", to); } else - Signal("Attempt fails.", (struct ship *)0); + Msg("Attempt fails."); } } } diff --git a/games/sail/pl_4.c b/games/sail/pl_4.c index 535ed86bfd7..2574593ece7 100644 --- a/games/sail/pl_4.c +++ b/games/sail/pl_4.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_4.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_4.c,v 1.4 1995/04/24 12:25:17 cgd Exp $ */ /* @@ -37,42 +38,44 @@ #if 0 static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_4.c,v 1.4 1995/04/24 12:25:17 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_4.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include "player.h" +void changesail() { int rig, full; rig = mc->rig1; full = mf->FS; - if (windspeed == 6 || windspeed == 5 && mc->class > 4) + if (windspeed == 6 || (windspeed == 5 && mc->class > 4)) rig = 0; if (mc->crew3 && rig) { if (!full) { if (sgetch("Increase to Full sails? ", (struct ship *)0, 1) == 'y') { changed = 1; - Write(W_FS, ms, 0, 1, 0, 0, 0); + Write(W_FS, ms, 1, 0, 0, 0); } } else { if (sgetch("Reduce to Battle sails? ", (struct ship *)0, 1) == 'y') { - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); changed = 1; } } } else if (!rig) - Signal("Sails rent to pieces", (struct ship *)0); + Msg("Sails rent to pieces"); } +void acceptsignal() { char buf[60]; - register char *p = buf; + char *p = buf; *p++ = '"'; sgetstr("Message? ", p, sizeof buf - 2); @@ -80,14 +83,15 @@ acceptsignal() ; p[-1] = '"'; *p = 0; - Write(W_SIGNAL, ms, 1, (long)buf, 0, 0, 0); + Writestr(W_SIGNAL, ms, buf); } +void lookout() { - register struct ship *sp; + struct ship *sp; char buf[3]; - register char c; + char c; sgetstr("What ship? ", buf, sizeof buf); foreachship(sp) { @@ -100,10 +104,10 @@ lookout() } } -char * +const char * saywhat(sp, flag) -register struct ship *sp; -char flag; + struct ship *sp; + char flag; { if (sp->file->captain[0]) return sp->file->captain; @@ -117,18 +121,19 @@ char flag; return "(computer)"; } +void eyeball(ship) -register struct ship *ship; + struct ship *ship; { int i; if (ship->file->dir != 0) { - Signal("Sail ho! (range %d, %s)", - (struct ship *)0, range(ms, ship), saywhat(ship, 0)); + Msg("Sail ho! (range %d, %s)", + range(ms, ship), saywhat(ship, 0)); i = portside(ms, ship, 1) - mf->dir; if (i <= 0) i += 8; - Signal("%s (%c%c) %s %s %s.", + Signal("$$ %s %s %s.", ship, countryname[ship->nationality], classname[ship->specs->class], directionname[i]); } diff --git a/games/sail/pl_5.c b/games/sail/pl_5.c index f8df3291e55..fd78af65bd5 100644 --- a/games/sail/pl_5.c +++ b/games/sail/pl_5.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_5.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_5.c,v 1.4 1995/04/24 12:25:21 cgd Exp $ */ /* @@ -37,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_5.c,v 1.4 1995/04/24 12:25:21 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_5.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ @@ -45,6 +46,7 @@ static char rcsid[] = "$NetBSD: pl_5.c,v 1.4 1995/04/24 12:25:21 cgd Exp $"; #define turnfirst(x) (*x == 'r' || *x == 'l') +void acceptmove() { int ta; @@ -54,10 +56,10 @@ acceptmove() int vma, dir; char prompt[60]; char buf[60], last = '\0'; - register char *p; + char *p; if (!mc->crew3 || snagged(ms) || !windspeed) { - Signal("Unable to move", (struct ship *)0); + Msg("Unable to move"); return; } @@ -77,22 +79,21 @@ acceptmove() else if (dir == 9) dir = 1; if (last == 't') { - Signal("Ship can't turn that fast.", - (struct ship *)0); + Msg("Ship can't turn that fast."); *p-- = '\0'; } last = 't'; ma--; ta--; vma = min(ma, maxmove(ms, dir, 0)); - if (ta < 0 && moved || vma < 0 && moved) + if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; case 'b': ma--; vma--; last = 'b'; - if (ta < 0 && moved || vma < 0 && moved) + if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; case '0': @@ -105,54 +106,52 @@ acceptmove() case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (last == '0') { - Signal("Can't move that fast.", - (struct ship *)0); + Msg("Can't move that fast."); *p-- = '\0'; } last = '0'; moved = 1; ma -= *p - '0'; vma -= *p - '0'; - if (ta < 0 && moved || vma < 0 && moved) + if ((ta < 0 && moved) || (vma < 0 && moved)) *p-- = '\0'; break; default: if (!isspace(*p)) { - Signal("Input error.", (struct ship *)0); + Msg("Input error."); *p-- = '\0'; } } - if (ta < 0 && moved || vma < 0 && moved - || af && turnfirst(buf) && moved) { - Signal("Movement error.", (struct ship *)0); + if ((ta < 0 && moved) || (vma < 0 && moved) + || (af && turnfirst(buf) && moved)) { + Msg("Movement error."); if (ta < 0 && moved) { if (mf->FS == 1) { - Write(W_FS, ms, 0, 0, 0, 0, 0); - Signal("No hands to set full sails.", - (struct ship *)0); + Write(W_FS, ms, 0, 0, 0, 0); + Msg("No hands to set full sails."); } } else if (ma >= 0) buf[1] = '\0'; } if (af && !moved) { if (mf->FS == 1) { - Write(W_FS, ms, 0, 0, 0, 0, 0); - Signal("No hands to set full sails.", - (struct ship *)0); + Write(W_FS, ms, 0, 0, 0, 0); + Msg("No hands to set full sails."); } } if (*buf) (void) strcpy(movebuf, buf); else (void) strcpy(movebuf, "d"); - Write(W_MOVE, ms, 1, (long)movebuf, 0, 0, 0); - Signal("Helm: %s.", (struct ship *)0, movebuf); + Writestr(W_MOVE, ms, movebuf); + Msg("Helm: %s.", movebuf); } +void acceptboard() { - register struct ship *sp; - register int n; + struct ship *sp; + int n; int crew[3]; int men = 0; char c; @@ -183,11 +182,11 @@ acceptboard() if (ms->nationality == capship(sp)->nationality) continue; if (meleeing(ms, sp) && crew[2]) { - c = sgetch("How many more to board the %s (%c%c)? ", + c = sgetch("How many more to board the $$? ", sp, 1); parties(crew, sp, 0, c); } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { - c = sgetch("Crew sections to board the %s (%c%c) (3 max) ?", sp, 1); + c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1); parties(crew, sp, 0, c); } } @@ -201,13 +200,14 @@ acceptboard() unblockalarm(); } +void parties(crew, to, isdefense, buf) -register struct ship *to; -int crew[3]; -char isdefense; -char buf; + struct ship *to; + int crew[3]; + char isdefense; + char buf; { - register int k, j, men; + int k, j, men; struct BP *ptr; int temp[3]; @@ -227,9 +227,8 @@ char buf; buf--; } if (buf > '0') - Signal("Sending all crew sections.", - (struct ship *)0); - Write(isdefense ? W_DBP : W_OBP, ms, 0, + Msg("Sending all crew sections."); + Write(isdefense ? W_DBP : W_OBP, ms, j, turn, to->file->index, men); if (isdefense) { (void) wmove(slot_w, 2, 0); @@ -239,8 +238,7 @@ char buf; else (void) wmove(slot_w, 2, 1 + k); (void) mvwaddstr(slot_w, 3, 0, "DBP"); - makesignal(ms, "repelling boarders", - (struct ship *)0); + makemsg(ms, "repelling boarders"); } else { (void) wmove(slot_w, 0, 0); for (k=0; k < NBP; k++) @@ -249,12 +247,12 @@ char buf; else (void) wmove(slot_w, 0, 1 + k); (void) mvwaddstr(slot_w, 1, 0, "OBP"); - makesignal(ms, "boarding the %s (%c%c)", to); + makesignal(ms, "boarding the $$", to); } blockalarm(); (void) wrefresh(slot_w); unblockalarm(); } else - Signal("Sending no crew sections.", (struct ship *)0); + Msg("Sending no crew sections."); } } diff --git a/games/sail/pl_6.c b/games/sail/pl_6.c index 03f339bd3ba..932c3793196 100644 --- a/games/sail/pl_6.c +++ b/games/sail/pl_6.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_6.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_6.c,v 1.3 1995/04/22 10:37:15 cgd Exp $ */ /* @@ -37,24 +38,25 @@ #if 0 static char sccsid[] = "@(#)pl_6.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_6.c,v 1.3 1995/04/22 10:37:15 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_6.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include "player.h" +void repair() { char c; - register char *repairs; - register struct shipspecs *ptr = mc; - register int count; + char *repairs; + struct shipspecs *ptr = mc; + int count; #define FIX(x, m) (m - ptr->x > count \ ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m)) if (repaired || loaded || fired || changed || turned()) { - Signal("No hands free to repair", (struct ship *)0); + Msg("No hands free to repair"); return; } c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1); @@ -69,7 +71,7 @@ repair() repairs = &mf->RR; break; default: - Signal("Avast heaving!", (struct ship *)0); + Msg("Avast heaving!"); return; } if (++*repairs >= 3) { @@ -79,7 +81,7 @@ repair() int max = ptr->guns/4; if (ptr->hull < max) { FIX(hull, max); - Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0); + Write(W_HULL, ms, ptr->hull, 0, 0, 0); } break; } @@ -88,14 +90,14 @@ repair() int max = ptr->guns/5 - ptr->carL; if (ptr->gunL < max) { FIX(gunL, max); - Write(W_GUNL, ms, 0, ptr->gunL, + Write(W_GUNL, ms, ptr->gunL, ptr->carL, 0, 0); } } else { int max = ptr->guns/5 - ptr->carR; if (ptr->gunR < max) { FIX(gunR, max); - Write(W_GUNR, ms, 0, ptr->gunR, + Write(W_GUNR, ms, ptr->gunR, ptr->carR, 0, 0); } } @@ -104,24 +106,24 @@ repair() #define X 2 if (ptr->rig4 >= 0 && ptr->rig4 < X) { FIX(rig4, X); - Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0); + Write(W_RIG4, ms, ptr->rig4, 0, 0, 0); } if (count && ptr->rig3 < X) { FIX(rig3, X); - Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0); + Write(W_RIG3, ms, ptr->rig3, 0, 0, 0); } if (count && ptr->rig2 < X) { FIX(rig2, X); - Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0); + Write(W_RIG2, ms, ptr->rig2, 0, 0, 0); } if (count && ptr->rig1 < X) { FIX(rig1, X); - Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0); + Write(W_RIG1, ms, ptr->rig1, 0, 0, 0); } break; } if (count == 2) { - Signal("Repairs completed.", (struct ship *)0); + Msg("Repairs completed."); *repairs = 2; } else { *repairs = 0; @@ -136,9 +138,10 @@ repair() repaired = 1; } +int turned() { - register char *p; + char *p; for (p = movebuf; *p; p++) if (*p == 'r' || *p == 'l') @@ -146,13 +149,14 @@ turned() return 0; } +void loadplayer() { char c; - register loadL, loadR, ready, load; + int loadL, loadR, ready, load; if (!mc->crew3) { - Signal("Out of crew", (struct ship *)0); + Msg("Out of crew"); return; } loadL = mf->loadL; @@ -165,7 +169,7 @@ loadplayer() else loadR = 1; } - if (!loadL && loadR || loadL && !loadR) { + if ((!loadL && loadR) || (loadL && !loadR)) { c = sgetch("Reload with (round, double, chain, grape)? ", (struct ship *)0, 1); switch (c) { @@ -186,8 +190,7 @@ loadplayer() ready = 0; break; default: - Signal("Broadside not loaded.", - (struct ship *)0); + Msg("Broadside not loaded."); return; } if (!loadR) { diff --git a/games/sail/pl_7.c b/games/sail/pl_7.c index 1268c1fe89a..cda98867c30 100644 --- a/games/sail/pl_7.c +++ b/games/sail/pl_7.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_7.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_7.c,v 1.6 1995/04/22 10:37:17 cgd Exp $ */ /* @@ -37,12 +38,19 @@ #if 0 static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_7.c,v 1.6 1995/04/22 10:37:17 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_7.c,v 1.2 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include <sys/ttydefaults.h> #include "player.h" +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include <unistd.h> +#include <err.h> /* @@ -50,12 +58,15 @@ static char rcsid[] = "$NetBSD: pl_7.c,v 1.6 1995/04/22 10:37:17 cgd Exp $"; */ static char sc_hasprompt; -static char *sc_prompt; -static char *sc_buf; +static const char *sc_prompt; +static const char *sc_buf; static int sc_line; +void initscreen() { + if (!SCREENTEST()) + errx(1, "can't sail on this terminal."); /* initscr() already done in SCREENTEST() */ view_w = newwin(VIEW_Y, VIEW_X, VIEW_T, VIEW_L); slot_w = newwin(SLOT_Y, SLOT_X, SLOT_T, SLOT_L); @@ -71,6 +82,7 @@ initscreen() crmode(); } +void cleanupscreen() { /* alarm already turned off */ @@ -82,25 +94,29 @@ cleanupscreen() } } +/* ARGSUSED */ void -newturn() +newturn(n) + int n; { repaired = loaded = fired = changed = 0; movebuf[0] = '\0'; (void) alarm(0); - if (mf->readyL & R_LOADING) + if (mf->readyL & R_LOADING) { if (mf->readyL & R_DOUBLE) mf->readyL = R_LOADING; else mf->readyL = R_LOADED; - if (mf->readyR & R_LOADING) + } + if (mf->readyR & R_LOADING) { if (mf->readyR & R_DOUBLE) mf->readyR = R_LOADING; else mf->readyR = R_LOADED; + } if (!hasdriver) - Write(W_DDEAD, SHIP(0), 0, 0, 0, 0, 0); + Write(W_DDEAD, SHIP(0), 0, 0, 0, 0); if (sc_hasprompt) { (void) wmove(scroll_w, sc_line, 0); @@ -114,11 +130,11 @@ newturn() (void) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf); if (turn % 50 == 0) - Write(W_ALIVE, SHIP(0), 0, 0, 0, 0, 0); + Write(W_ALIVE, SHIP(0), 0, 0, 0, 0); if (mf->FS && (!mc->rig1 || windspeed == 6)) - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); if (mf->FS == 1) - Write(W_FS, ms, 0, 2, 0, 0, 0); + Write(W_FS, ms, 2, 0, 0, 0); if (mf->struck) leave(LEAVE_QUIT); @@ -135,23 +151,73 @@ newturn() } /*VARARGS2*/ -Signal(fmt, ship, a, b, c, d) -char *fmt; -register struct ship *ship; -int a, b, c, d; +void +#ifdef __STDC__ +Signal(char *fmt, struct ship *ship, ...) +#else +Signal(va_alist) + va_dcl +#endif { + va_list ap; + char format[BUFSIZ]; +#ifndef __STDC__ + char *fmt; + struct ship *ship; + + va_start(ap); + fmt = va_arg(ap, const char *); + ship = va_arg(ap, struct ship *); +#else + va_start(ap, ship); +#endif if (!done_curses) return; if (*fmt == '\7') putchar(*fmt++); - if (ship == 0) - (void) wprintw(scroll_w, fmt, a, b, c, d); - else - (void) wprintw(scroll_w, fmt, ship->shipname, - colours(ship), sterncolour(ship), a, b, c, d); + fmtship(format, sizeof(format), fmt, ship); +#ifdef __STDC__ + (void) vw_printw(scroll_w, format, ap); +#else + (void) vwprintw(scroll_w, format, ap); +#endif + va_end(ap); Scroll(); } +/*VARARGS2*/ +void +#ifdef __STDC__ +Msg(char *fmt, ...) +#else +Msg(va_alist) + va_dcl +#endif +{ + va_list ap; +#ifndef __STDC__ + char *fmt; + + va_start(ap); + fmt = va_arg(ap, const char *); +#else + va_start(ap, fmt); +#endif + + if (!done_curses) + return; + if (*fmt == '\7') + putchar(*fmt++); +#ifdef __STDC__ + (void) vw_printw(scroll_w, fmt, ap); +#else + (void) vwprintw(scroll_w, fmt, ap); +#endif + va_end(ap); + Scroll(); +} + +void Scroll() { if (++sc_line >= SCROLL_Y) @@ -160,37 +226,36 @@ Scroll() (void) wclrtoeol(scroll_w); } +void prompt(p, ship) -register char *p; -struct ship *ship; + const char *p; + struct ship *ship; { - static char buf[60]; + static char buf[BUFSIZ]; - if (ship != 0) { - (void)sprintf(buf, p, ship->shipname, colours(ship), - sterncolour(ship)); - p = buf; - } - sc_prompt = p; + fmtship(buf, sizeof(buf), p, ship); + sc_prompt = buf; sc_buf = ""; sc_hasprompt = 1; - (void) waddstr(scroll_w, p); + (void) waddstr(scroll_w, buf); } +void endprompt(flag) -char flag; + char flag; { sc_hasprompt = 0; if (flag) Scroll(); } +int sgetch(p, ship, flag) -char *p; -struct ship *ship; -char flag; + const char *p; + struct ship *ship; + char flag; { - register c; + int c; prompt(p, ship); blockalarm(); @@ -204,13 +269,14 @@ char flag; return c; } +void sgetstr(pr, buf, n) -char *pr; -register char *buf; -register n; + const char *pr; + char *buf; + int n; { - register c; - register char *p = buf; + int c; + char *p = buf; prompt(pr, (struct ship *)0); sc_buf = buf; @@ -242,6 +308,7 @@ register n; } } +void draw_screen() { draw_view(); @@ -251,9 +318,10 @@ draw_screen() (void) wrefresh(scroll_w); /* move the cursor */ } +void draw_view() { - register struct ship *sp; + struct ship *sp; (void) werase(view_w); foreachship(sp) { @@ -274,6 +342,7 @@ draw_view() (void) wrefresh(view_w); } +void draw_turn() { (void) wmove(turn_w, 0, 0); @@ -281,6 +350,7 @@ draw_turn() (void) wrefresh(turn_w); } +void draw_stat() { (void) wmove(stat_w, STAT_1, 0); @@ -321,6 +391,7 @@ draw_stat() (void) wrefresh(stat_w); } +void draw_slot() { if (!boarding(ms, 0)) { @@ -384,9 +455,10 @@ draw_slot() (void) wrefresh(slot_w); } +void draw_board() { - register int n; + int n; (void) clear(); (void) werase(view_w); @@ -431,32 +503,38 @@ draw_board() (void) refresh(); } +void centerview() { viewrow = mf->row - VIEW_Y / 2; viewcol = mf->col - VIEW_X / 2; } +void upview() { viewrow -= VIEW_Y / 3; } +void downview() { viewrow += VIEW_Y / 3; } +void leftview() { viewcol -= VIEW_X / 5; } +void rightview() { viewcol += VIEW_X / 5; } +void adjustview() { if (dont_adjust) diff --git a/games/sail/pl_main.c b/games/sail/pl_main.c index 248d9c6f2f1..77781f56504 100644 --- a/games/sail/pl_main.c +++ b/games/sail/pl_main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pl_main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: pl_main.c,v 1.5 1995/04/24 12:25:25 cgd Exp $ */ /* @@ -37,34 +38,36 @@ #if 0 static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pl_main.c,v 1.5 1995/04/24 12:25:25 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pl_main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $"; #endif #endif /* not lint */ #include "player.h" #include <sys/types.h> #include <sys/wait.h> - -void choke(), child(); +#include <stdlib.h> +#include <unistd.h> +#include <err.h> /*ARGSUSED*/ +int pl_main() { - initialize(); - Signal("Aye aye, Sir", (struct ship *)0); + Msg("Aye aye, Sir"); play(); return 0; /* for lint, play() never returns */ } +void initialize() { - register struct File *fp; - register struct ship *sp; + struct File *fp; + struct ship *sp; char captain[80]; char message[60]; int load; - register int n; + int n; char *nameptr; int nat[NNATION]; @@ -84,10 +87,8 @@ reprint: while (getchar() != '\n') ; } - if (game < 0 || game >= NSCENE) { - (void) puts("Very funny."); - exit(1); - } + if (game < 0 || game >= NSCENE) + errx(1, "Very funny."); cc = &scene[game]; ls = SHIP(cc->vessels); @@ -95,10 +96,8 @@ reprint: nat[n] = 0; foreachship(sp) { if (sp->file == NULL && - (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { - (void) puts("OUT OF MEMORY"); - exit(1); - } + (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) + errx(1, "out of memory"); sp->file->index = sp - SHIP(0); sp->file->stern = nat[sp->nationality]++; sp->file->dir = sp->shipdir; @@ -112,10 +111,8 @@ reprint: (void) signal(SIGINT, choke); hasdriver = sync_exists(game); - if (sync_open() < 0) { - perror("sail: syncfile"); - exit(1); - } + if (sync_open() < 0) + err(1, "syncfile"); if (hasdriver) { (void) puts("Synchronizing with the other players..."); @@ -174,7 +171,7 @@ reprint: mf = ms->file; mc = ms->specs; - Write(W_BEGIN, ms, 0, 0, 0, 0, 0); + Write(W_BEGIN, ms, 0, 0, 0, 0); if (Sync() < 0) leave(LEAVE_SYNC); @@ -207,7 +204,7 @@ reprint: captain[strlen(captain) - 1] = '\0'; } captain[sizeof captain - 1] = '\0'; - Write(W_CAPTAIN, ms, 1, (long)captain, 0, 0, 0); + Writestr(W_CAPTAIN, ms, captain); for (n = 0; n < 2; n++) { char buf[10]; @@ -240,14 +237,10 @@ reprint: } } - /* SCREENTEST calls initscr */ - if (!SCREENTEST()) { - printf("Can't sail on this terminal.\n"); - exit(1); - } initscreen(); draw_board(); - (void) sprintf(message, "Captain %s assuming command", captain); - Write(W_SIGNAL, ms, 1, (long)message, 0, 0, 0); - newturn(); + (void) snprintf(message, sizeof message, "Captain %s assuming command", + captain); + Writestr(W_SIGNAL, ms, message); + newturn(0); } diff --git a/games/sail/player.h b/games/sail/player.h index 9faf86986cd..8fb605218e2 100644 --- a/games/sail/player.h +++ b/games/sail/player.h @@ -1,3 +1,4 @@ +/* $OpenBSD: player.h,v 1.5 1999/01/18 06:20:53 pjanzen Exp $ */ /* $NetBSD: player.h,v 1.4 1995/04/22 10:37:22 cgd Exp $ */ /* @@ -32,11 +33,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)player.h 8.1 (Berkeley) 5/31/93 + * @(#)player.h 8.2 (Berkeley) 5/3/95 */ #include <curses.h> -#include "externs.h" +#include "extern.h" /* sizes and coordinates for the screen */ @@ -109,7 +110,7 @@ char loaded, fired, changed, repaired; char dont_adjust; int viewrow, viewcol; char movebuf[sizeof SHIP(0)->file->movebuf]; -char *version; +extern char version[]; int player; struct ship *ms; /* memorial structure, &cc->ship[player] */ struct File *mf; /* ms->file */ diff --git a/games/sail/sync.c b/games/sail/sync.c index 20ab46cdfea..97f9e6ef71a 100644 --- a/games/sail/sync.c +++ b/games/sail/sync.c @@ -1,4 +1,5 @@ -/* $NetBSD: sync.c,v 1.4 1995/04/24 12:25:28 cgd Exp $ */ +/* $OpenBSD: sync.c,v 1.2 1999/01/18 06:20:54 pjanzen Exp $ */ +/* $NetBSD: sync.c,v 1.9 1998/08/30 09:19:40 veego Exp $ */ /* * Copyright (c) 1983, 1993 @@ -33,50 +34,128 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint #if 0 -static char sccsid[] = "@(#)sync.c 8.1 (Berkeley) 5/31/93"; +static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$NetBSD: sync.c,v 1.4 1995/04/24 12:25:28 cgd Exp $"; +static char rcsid[] = "$OpenBSD: sync.c,v 1.2 1999/01/18 06:20:54 pjanzen Exp $"; #endif #endif /* not lint */ -#include "externs.h" +#include <fcntl.h> +#include <errno.h> +#ifdef __STDC__ +#include <stdarg.h> +#else +#include <varargs.h> +#endif +#include <stdlib.h> +#include <unistd.h> #include <sys/file.h> -#include <sys/errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <time.h> +#include "extern.h" +#include "pathnames.h" #define BUFSIZE 4096 +static const char SF[] = _PATH_SYNC; +static const char LF[] = _PATH_LOCK; static char sync_buf[BUFSIZE]; static char *sync_bp = sync_buf; -static char sync_lock[25]; -static char sync_file[25]; +static char sync_lock[sizeof SF]; +static char sync_file[sizeof LF]; static long sync_seek; static FILE *sync_fp; -#define SF "/tmp/#sailsink.%d" -#define LF "/tmp/#saillock.%d" + +void +fmtship(buf, len, fmt, ship) + char *buf; + size_t len; + const char *fmt; + struct ship *ship; +{ + while (*fmt) { + if (len-- == 0) { + *buf = '\0'; + return; + } + if (*fmt == '$' && fmt[1] == '$') { + size_t l = snprintf(buf, len, "%s (%c%c)", + ship->shipname, colours(ship), sterncolour(ship)); + buf += l; + len -= l - 1; + fmt += 2; + } + else + *buf++ = *fmt++; + } + + if (len > 0) + *buf = '\0'; +} + /*VARARGS3*/ -makesignal(from, fmt, ship, a, b, c) +void +#ifdef __STDC__ +makesignal(struct ship *from, const char *fmt, struct ship *ship, ...) +#else +makesignal(va_alias) + va_dcl +#endif +{ + char message[BUFSIZ]; + char format[BUFSIZ]; + va_list ap; +#ifndef __STDC__ struct ship *from; - char *fmt; - register struct ship *ship; - long a, b, c; + const char *fmt; + struct ship *ship; + + va_start(ap); + from = va_arg(ap, struct ship *); + fmt = va_arg(ap, const char *); + ship = va_arg(ap, struct ship *); +#else + va_start(ap, ship); +#endif + fmtship(format, sizeof(format), fmt, ship); + (void) vsprintf(message, format, ap); + va_end(ap); + Writestr(W_SIGNAL, from, message); +} + +void +#ifdef __STDC__ +makemsg(struct ship *from, const char *fmt, ...) +#else +makemsg(va_alias) + va_dcl +#endif { - char message[80]; + char message[BUFSIZ]; + va_list ap; +#ifndef __STDC__ + struct ship *from; + const char *fmt; - if (ship == 0) - (void) sprintf(message, fmt, a, b, c); - else - (void) sprintf(message, fmt, - ship->shipname, colours(ship), - sterncolour(ship), a, b, c); - Write(W_SIGNAL, from, 1, (long)message, 0, 0, 0); + va_start(ap); + from = va_arg(ap, struct ship *); + fmt = va_arg(ap, const char *); +#else + va_start(ap, fmt); +#endif + (void) vsprintf(message, fmt, ap); + va_end(ap); + Writestr(W_SIGNAL, from, message); } -#include <sys/types.h> -#include <sys/stat.h> +int sync_exists(game) + int game; { char buf[sizeof sync_file]; struct stat s; @@ -84,73 +163,100 @@ sync_exists(game) (void) sprintf(buf, SF, game); (void) time(&t); - if (stat(buf, &s) < 0) + setegid(egid); + if (stat(buf, &s) < 0) { + setegid(gid); return 0; + } if (s.st_mtime < t - 60*60*2) { /* 2 hours */ (void) unlink(buf); (void) sprintf(buf, LF, game); (void) unlink(buf); + setegid(gid); return 0; - } else - return 1; + } + setegid(gid); + return 1; } +int sync_open() { + struct stat tmp; + if (sync_fp != NULL) (void) fclose(sync_fp); (void) sprintf(sync_lock, LF, game); (void) sprintf(sync_file, SF, game); - if (access(sync_file, 0) < 0) { - int omask = umask(issetuid ? 077 : 011); + setegid(egid); + if (stat(sync_file, &tmp) < 0) { + mode_t omask = umask(002); sync_fp = fopen(sync_file, "w+"); (void) umask(omask); } else sync_fp = fopen(sync_file, "r+"); + setegid(gid); if (sync_fp == NULL) return -1; sync_seek = 0; return 0; } +void sync_close(remove) char remove; { if (sync_fp != 0) (void) fclose(sync_fp); - if (remove) + if (remove) { + setegid(egid); (void) unlink(sync_file); + setegid(gid); + } } -Write(type, ship, isstr, a, b, c, d) +void +Write(type, ship, a, b, c, d) int type; struct ship *ship; - char isstr; long a, b, c, d; { - if (isstr) - (void) sprintf(sync_bp, "%d %d %d %s\n", - type, ship->file->index, isstr, a); - else - (void) sprintf(sync_bp, "%d %d %d %d %d %d %d\n", - type, ship->file->index, isstr, a, b, c, d); + (void) sprintf(sync_bp, "%d %d 0 %ld %ld %ld %ld\n", + type, ship->file->index, a, b, c, d); while (*sync_bp++) ; sync_bp--; if (sync_bp >= &sync_buf[sizeof sync_buf]) abort(); - (void) sync_update(type, ship, a, b, c, d); + (void) sync_update(type, ship, NULL, a, b, c, d); } +void +Writestr(type, ship, a) + int type; + struct ship *ship; + const char *a; +{ + (void) sprintf(sync_bp, "%d %d 1 %s\n", + type, ship->file->index, a); + while (*sync_bp++) + ; + sync_bp--; + if (sync_bp >= &sync_buf[sizeof sync_buf]) + abort(); + (void) sync_update(type, ship, a, 0, 0, 0, 0); +} + +int Sync() { sig_t sighup, sigint; - register n; + int n; int type, shipnum, isstr; + char *astr; long a, b, c, d; char buf[80]; char erred = 0; - extern errno; sighup = signal(SIGHUP, SIG_IGN); sigint = signal(SIGINT, SIG_IGN); @@ -161,8 +267,12 @@ Sync() if (errno != EWOULDBLOCK) return -1; #else - if (link(sync_file, sync_lock) >= 0) + setegid(egid); + if (link(sync_file, sync_lock) >= 0) { + setegid(gid); break; + } + setegid(gid); if (errno != EEXIST) return -1; #endif @@ -170,7 +280,7 @@ Sync() } if (n <= 0) return -1; - (void) fseek(sync_fp, sync_seek, 0); + (void) fseek(sync_fp, sync_seek, SEEK_SET); for (;;) { switch (fscanf(sync_fp, "%d%d%d", &type, &shipnum, &isstr)) { case 3: @@ -185,7 +295,7 @@ Sync() if (isstr != 0 && isstr != 1) goto bad; if (isstr) { - register char *p; + char *p; for (p = buf;;) { switch (*p++ = getc(sync_fp)) { case '\n': @@ -202,19 +312,21 @@ Sync() *p = 0; for (p = buf; *p == ' '; p++) ; - a = (long)p; - b = c = d = 0; - } else - if (fscanf(sync_fp, "%d%d%d%d", &a, &b, &c, &d) != 4) + astr = p; + a = b = c = d = 0; + } else { + if (fscanf(sync_fp, "%ld%ld%ld%ld", &a, &b, &c, &d) != 4) goto bad; - if (sync_update(type, SHIP(shipnum), a, b, c, d) < 0) + astr = NULL; + } + if (sync_update(type, SHIP(shipnum), astr, a, b, c, d) < 0) goto bad; } bad: erred++; out: if (!erred && sync_bp != sync_buf) { - (void) fseek(sync_fp, 0L, 2); + (void) fseek(sync_fp, 0L, SEEK_END); (void) fwrite(sync_buf, sizeof *sync_buf, sync_bp - sync_buf, sync_fp); (void) fflush(sync_fp); @@ -224,35 +336,39 @@ out: #ifdef LOCK_EX (void) flock(fileno(sync_fp), LOCK_UN); #else + setegid(egid); (void) unlink(sync_lock); + setegid(gid); #endif (void) signal(SIGHUP, sighup); (void) signal(SIGINT, sigint); return erred ? -1 : 0; } -sync_update(type, ship, a, b, c, d) +int +sync_update(type, ship, astr, a, b, c, d) int type; - register struct ship *ship; + struct ship *ship; + const char *astr; long a, b, c, d; { switch (type) { case W_DBP: { - register struct BP *p = &ship->file->DBP[a]; + struct BP *p = &ship->file->DBP[a]; p->turnsent = b; p->toship = SHIP(c); p->mensent = d; break; } case W_OBP: { - register struct BP *p = &ship->file->OBP[a]; + struct BP *p = &ship->file->OBP[a]; p->turnsent = b; p->toship = SHIP(c); p->mensent = d; break; } case W_FOUL: { - register struct snag *p = &ship->file->foul[a]; + struct snag *p = &ship->file->foul[a]; if (SHIP(a)->file->dir == 0) break; if (p->sn_count++ == 0) @@ -261,7 +377,7 @@ sync_update(type, ship, a, b, c, d) break; } case W_GRAP: { - register struct snag *p = &ship->file->grap[a]; + struct snag *p = &ship->file->grap[a]; if (SHIP(a)->file->dir == 0) break; if (p->sn_count++ == 0) @@ -270,8 +386,8 @@ sync_update(type, ship, a, b, c, d) break; } case W_UNFOUL: { - register struct snag *p = &ship->file->foul[a]; - if (p->sn_count > 0) + struct snag *p = &ship->file->foul[a]; + if (p->sn_count > 0) { if (b) { ship->file->nfoul -= p->sn_count; p->sn_count = 0; @@ -279,11 +395,12 @@ sync_update(type, ship, a, b, c, d) ship->file->nfoul--; p->sn_count--; } + } break; } case W_UNGRAP: { - register struct snag *p = &ship->file->grap[a]; - if (p->sn_count > 0) + struct snag *p = &ship->file->grap[a]; + if (p->sn_count > 0) { if (b) { ship->file->ngrap -= p->sn_count; p->sn_count = 0; @@ -291,24 +408,26 @@ sync_update(type, ship, a, b, c, d) ship->file->ngrap--; p->sn_count--; } + } break; } case W_SIGNAL: - if (mode == MODE_PLAYER) + if (mode == MODE_PLAYER) { if (nobells) - Signal("%s (%c%c): %s", ship, a); + Signal("$$: %s", ship, astr); else - Signal("\7%s (%c%c): %s", ship, a); + Signal("\7$$: %s", ship, astr); + } break; case W_CREW: { - register struct shipspecs *s = ship->specs; + struct shipspecs *s = ship->specs; s->crew1 = a; s->crew2 = b; s->crew3 = c; break; } case W_CAPTAIN: - (void) strncpy(ship->file->captain, (char *)a, + (void) strncpy(ship->file->captain, astr, sizeof ship->file->captain - 1); ship->file->captain[sizeof ship->file->captain - 1] = 0; break; @@ -332,13 +451,13 @@ sync_update(type, ship, a, b, c, d) ship->file->FS = a; break; case W_GUNL: { - register struct shipspecs *s = ship->specs; + struct shipspecs *s = ship->specs; s->gunL = a; s->carL = b; break; } case W_GUNR: { - register struct shipspecs *s = ship->specs; + struct shipspecs *s = ship->specs; s->gunR = a; s->carR = b; break; @@ -347,7 +466,7 @@ sync_update(type, ship, a, b, c, d) ship->specs->hull = a; break; case W_MOVE: - (void) strncpy(ship->file->movebuf, (char *)a, + (void) strncpy(ship->file->movebuf, astr, sizeof ship->file->movebuf - 1); ship->file->movebuf[sizeof ship->file->movebuf - 1] = 0; break; @@ -361,7 +480,7 @@ sync_update(type, ship, a, b, c, d) ship->specs->qual = a; break; case W_RIGG: { - register struct shipspecs *s = ship->specs; + struct shipspecs *s = ship->specs; s->rig1 = a; s->rig2 = b; s->rig3 = c; diff --git a/games/sail/version.c b/games/sail/version.c index 46904d1d610..0fc98a5679e 100644 --- a/games/sail/version.c +++ b/games/sail/version.c @@ -1,3 +1,4 @@ +/* $OpenBSD: version.c,v 1.3 1999/01/18 06:20:54 pjanzen Exp $ */ /* $NetBSD: version.c,v 1.3 1995/04/22 10:37:27 cgd Exp $ */ /* @@ -37,8 +38,8 @@ #if 0 static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: version.c,v 1.3 1995/04/22 10:37:27 cgd Exp $"; +static char rcsid[] = "$OpenBSD: version.c,v 1.3 1999/01/18 06:20:54 pjanzen Exp $"; #endif #endif /* not lint */ -char *version = "Wooden Ships and Iron Men, Version 8.1 (93/05/31)"; +char version[] = "Wooden Ships and Iron Men, Version 8.2 (95/04/28)"; |