X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/a65a873e56c35780711e9f73872c4fe0254589b0..55897f8f7c105946fb5763a36e20db423fdced1e:/sail/pl_5.c diff --git a/sail/pl_5.c b/sail/pl_5.c index f8df3291..44c37c22 100644 --- a/sail/pl_5.c +++ b/sail/pl_5.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_5.c,v 1.4 1995/04/24 12:25:21 cgd Exp $ */ +/* $NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -33,19 +33,30 @@ * SUCH DAMAGE. */ +#include #ifndef lint #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 $"; +__RCSID("$NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $"); #endif #endif /* not lint */ +#include +#include +#include +#include +#include +#include "extern.h" #include "player.h" +#include "display.h" #define turnfirst(x) (*x == 'r' || *x == 'l') -acceptmove() +static void parties(struct ship *, int *, int, int); + +void +acceptmove(void) { int ta; int ma; @@ -54,16 +65,16 @@ 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; } ta = maxturns(ms, &af); ma = maxmove(ms, mf->dir, 0); - (void) sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta); + sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta); sgetstr(prompt, buf, sizeof buf); dir = mf->dir; vma = ma; @@ -77,22 +88,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 +115,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); + 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); + strcpy(movebuf, "d"); + Writestr(W_MOVE, ms, movebuf); + Msg("Helm: %s.", movebuf); } -acceptboard() +void +acceptboard(void) { - register struct ship *sp; - register int n; + struct ship *sp; + int n; int crew[3]; int men = 0; char c; @@ -183,31 +191,28 @@ 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); + parties(sp, crew, 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); - parties(crew, sp, 0, c); + c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1); + parties(sp, crew, 0, c); } } if (crew[2]) { c = sgetch("How many sections to repel boarders? ", (struct ship *)0, 1); - parties(crew, ms, 1, c); + parties(ms, crew, 1, c); } blockalarm(); draw_slot(); unblockalarm(); } -parties(crew, to, isdefense, buf) -register struct ship *to; -int crew[3]; -char isdefense; -char buf; +static void +parties(struct ship *to, int *crew, int isdefense, int buf) { - register int k, j, men; + int k, j, men; struct BP *ptr; int temp[3]; @@ -227,34 +232,32 @@ 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); + wmove(slot_w, 2, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) - (void) waddch(slot_w, k + '1'); + waddch(slot_w, k + '1'); else - (void) wmove(slot_w, 2, 1 + k); - (void) mvwaddstr(slot_w, 3, 0, "DBP"); - makesignal(ms, "repelling boarders", - (struct ship *)0); + wmove(slot_w, 2, 1 + k); + mvwaddstr(slot_w, 3, 0, "DBP"); + makemsg(ms, "repelling boarders"); } else { - (void) wmove(slot_w, 0, 0); + wmove(slot_w, 0, 0); for (k=0; k < NBP; k++) if (temp[k] && !crew[k]) - (void) waddch(slot_w, k + '1'); + waddch(slot_w, k + '1'); else - (void) wmove(slot_w, 0, 1 + k); - (void) mvwaddstr(slot_w, 1, 0, "OBP"); - makesignal(ms, "boarding the %s (%c%c)", to); + wmove(slot_w, 0, 1 + k); + mvwaddstr(slot_w, 1, 0, "OBP"); + makesignal(ms, "boarding the $$", to); } blockalarm(); - (void) wrefresh(slot_w); + wrefresh(slot_w); unblockalarm(); } else - Signal("Sending no crew sections.", (struct ship *)0); + Msg("Sending no crew sections."); } }