X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/b2ca333c4ad541145141d538923e93ec3464e29d..46062f71bb0dbda76cf0bde5c52bc325c97fd7a9:/trek/shield.c diff --git a/trek/shield.c b/trek/shield.c index 6b5d56fc..a14c22a7 100644 --- a/trek/shield.c +++ b/trek/shield.c @@ -1,4 +1,4 @@ -/* $NetBSD: shield.c,v 1.3 1995/04/22 10:59:28 cgd Exp $ */ +/* $NetBSD: shield.c,v 1.13 2009/08/12 08:54:54 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -12,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. * @@ -33,16 +29,18 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)shield.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: shield.c,v 1.3 1995/04/22 10:59:28 cgd Exp $"; +__RCSID("$NetBSD: shield.c,v 1.13 2009/08/12 08:54:54 dholland Exp $"); #endif #endif /* not lint */ -# include "trek.h" -# include "getpar.h" +#include +#include "trek.h" +#include "getpar.h" /* ** SHIELD AND CLOAKING DEVICE CONTROL @@ -61,39 +59,37 @@ static char rcsid[] = "$NetBSD: shield.c,v 1.3 1995/04/22 10:59:28 cgd Exp $"; ** so you get partial hits. */ -struct cvntab Udtab[] = -{ - "u", "p", (int (*)())1, 0, - "d", "own", 0, 0, - 0 +static const struct cvntab Udtab[] = { + { "u", "p", (cmdfun)1, 0 }, + { "d", "own", (cmdfun)0, 0 }, + { NULL, NULL, NULL, 0 } }; -shield(f) -int f; +void +shield(int f) { - register int i; - char c; - struct cvntab *r; - char s[100]; - char *device, *dev2, *dev3; - int ind; - char *stat; + int i; + const struct cvntab *r; + char s[100]; + const char *device, *dev2, *dev3; + int ind; + char *stat; if (f > 0 && (Ship.shldup || damaged(SRSCAN))) return; - if (f < 0) - { + if (f < 0) { /* cloaking device */ - if (Ship.ship == QUEENE) - return (printf("Ye Faire Queene does not have the cloaking device.\n")); + if (Ship.ship == QUEENE) { + printf("Ye Faire Queene does not have the " + "cloaking device.\n"); + return; + } device = "Cloaking device"; dev2 = "is"; ind = CLOAK; dev3 = "it"; stat = &Ship.cloaked; - } - else - { + } else { /* shields */ device = "Shields"; dev2 = "are"; @@ -101,34 +97,32 @@ int f; ind = SHIELD; stat = &Ship.shldup; } - if (damaged(ind)) - { + if (damaged(ind)) { if (f <= 0) out(ind); return; } - if (Ship.cond == DOCKED) - { + if (Ship.cond == DOCKED) { printf("%s %s down while docked\n", device, dev2); return; } - if (f <= 0 && !testnl()) - { + if (f <= 0 && !testnl()) { r = getcodpar("Up or down", Udtab); - i = (int) r->value; - } - else - { + i = (long) r->value; + } else { if (*stat) - (void)sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); + (void)snprintf(s, sizeof(s), + "%s %s up. Do you want %s down", + device, dev2, dev3); else - (void)sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); + (void)snprintf(s, sizeof(s), + "%s %s down. Do you want %s up", + device, dev2, dev3); if (!getynpar(s)) return; i = !*stat; } - if (*stat == i) - { + if (*stat == i) { printf("%s already ", device); if (i) printf("up\n"); @@ -136,11 +130,12 @@ int f; printf("down\n"); return; } - if (i) + if (i) { if (f >= 0) Ship.energy -= Param.shupengy; else Ship.cloakgood = 0; + } Move.free = 0; if (f >= 0) Move.shldchg = 1;