diff options
author | hubertf <hubertf@NetBSD.org> | 1999-02-10 00:45:45 +0000 |
---|---|---|
committer | hubertf <hubertf@NetBSD.org> | 1999-02-10 00:45:45 +0000 |
commit | 22a27dede77166c7bdf1de647d4d2b961fcd92c2 (patch) | |
tree | eba164fcad44498207f63281968e224f52d40bcb /sail/assorted.c | |
parent | e0e186091a777dfe9cf3c22deeff989f459d8db9 (diff) | |
download | bsdgames-darwin-22a27dede77166c7bdf1de647d4d2b961fcd92c2.tar.gz bsdgames-darwin-22a27dede77166c7bdf1de647d4d2b961fcd92c2.tar.zst bsdgames-darwin-22a27dede77166c7bdf1de647d4d2b961fcd92c2.zip |
The game sail(6) has a function Write() which is used both with
integer arguments and with string arguments (cast to long, and in one
place to int). The patch here cleans this up, making it into two
separate functions; this allows for the game to be made const-correct
in future and improves portability.
The patch also contains two other fragments: a change to use the
symbolic constant SEEK_END with fseek(), and a change to use snprintf
in one place to avoid a buffer overrun.
Via PR 6569 by Joseph Myers <jsm28@cam.ac.uk>.
Diffstat (limited to 'sail/assorted.c')
-rw-r--r-- | sail/assorted.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/sail/assorted.c b/sail/assorted.c index d7074e76..4a4b143f 100644 --- a/sail/assorted.c +++ b/sail/assorted.c @@ -1,4 +1,4 @@ -/* $NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $ */ +/* $NetBSD: assorted.c,v 1.7 1999/02/10 00:45:45 hubertf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $"); +__RCSID("$NetBSD: assorted.c,v 1.7 1999/02/10 00:45:45 hubertf Exp $"); #endif #endif /* not lint */ @@ -139,17 +139,17 @@ 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 $$"; @@ -217,7 +217,7 @@ 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"; @@ -233,10 +233,10 @@ int rig, shot, hittable, roll; if (on->specs->qual <= 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 makemsg(on, "crew demoralized"); - Write(W_QUAL, on, 0, on->specs->qual, 0, 0, 0); + Write(W_QUAL, on, on->specs->qual, 0, 0, 0); } */ if (!hull) @@ -249,12 +249,12 @@ 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)) { @@ -278,20 +278,20 @@ struct ship *ship, *from; 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!"); } |