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/assorted.c | |
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/assorted.c')
-rw-r--r-- | games/sail/assorted.c | 95 |
1 files changed, 56 insertions, 39 deletions
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!"); } |