X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/462fca95471224f85b85be911e72faee16cd1597..06d189c50fe0f27b79aa1e494c3b39d7478c1189:/sail/pl_5.c diff --git a/sail/pl_5.c b/sail/pl_5.c index 49980ddc..b3bdd77a 100644 --- a/sail/pl_5.c +++ b/sail/pl_5.c @@ -1,6 +1,8 @@ +/* $NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl Exp $ */ + /* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. + * 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 @@ -10,11 +12,7 @@ * 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 + * 3. 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. * @@ -31,16 +29,30 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)pl_5.c 5.4 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: pl_5.c,v 1.2 1993/08/01 18:51:37 mycroft Exp $"; +#if 0 +static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl 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; @@ -49,16 +61,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; @@ -72,22 +84,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': @@ -100,54 +111,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); + if (!isspace((unsigned char)*p)) { + 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, (int)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; @@ -178,31 +187,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]; @@ -222,34 +228,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."); } }