diff options
Diffstat (limited to 'test/bs.c')
| -rw-r--r-- | test/bs.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/test/bs.c b/test/bs.c index c7569cf207fd..4bb0ede7bada 100644 --- a/test/bs.c +++ b/test/bs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2022,2023 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -35,7 +35,7 @@ * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 with ncurses mouse support, September 1995 * - * $Id: bs.c,v 1.79 2023/05/27 20:13:10 tom Exp $ + * $Id: bs.c,v 1.83 2025/07/05 15:21:56 tom Exp $ */ #include <test.priv.h> @@ -147,7 +147,7 @@ typedef struct { bool placed; /* has it been placed on the board? */ } ship_t; -static bool checkplace(int b, ship_t * ss, int vis); +static bool checkplace(int b, const ship_t * ss, int vis); #define SHIPIT(name, symbol, length) { name, 0, symbol, length, 0,0, 0, FALSE } @@ -224,12 +224,12 @@ intro(void) { const char *tmpname; - srand((unsigned) (time(0L) + getpid())); /* Kick the random number generator */ + srand((unsigned) (time(NULL) + getpid())); /* Kick the random number generator */ InitAndCatch(initscr(), uninitgame); - if ((tmpname = getlogin()) != 0 && - (your_name = strdup(tmpname)) != 0) { + if ((tmpname = getlogin()) != NULL && + (your_name = strdup(tmpname)) != NULL) { your_name[0] = (char) toupper(UChar(your_name[0])); } else { your_name = strdup(dftname); @@ -475,7 +475,7 @@ initgame(void) } else if (c == FF) { (void) clearok(stdscr, TRUE); (void) refresh(); - } else if (ss == 0) { + } else if (ss == NULL) { beep(); /* simple to verify, unlikely to happen */ } else if (c == 'r') { prompt(1, "Random-placing your %s", ss->name); @@ -686,7 +686,7 @@ collidecheck(int b, int y, int x) } static bool -checkplace(int b, ship_t * ss, int vis) +checkplace(int b, const ship_t * ss, int vis) { int l, xend, yend; @@ -877,7 +877,7 @@ plyturn(void) m = " You'll pick up survivors from my %s, I hope...!"; break; } - if (m != 0) { + if (m != NULL) { (void) printw(m, ss->name); } (void) beep(); @@ -1193,7 +1193,7 @@ usage(int ok) ,USAGE_COMMON ,"Options:" ," -b play a blitz game" - ," -c ships may be adjacent" + ," -p ships may be packed/adjacent" ," -s play a salvo game" }; size_t n; @@ -1212,7 +1212,7 @@ main(int argc, char *argv[]) { int ch; - while ((ch = getopt(argc, argv, OPTS_COMMON "bcs")) != -1) { + while ((ch = getopt(argc, argv, OPTS_COMMON "bps")) != -1) { switch (ch) { case 'b': blitz = 1; @@ -1230,14 +1230,11 @@ main(int argc, char *argv[]) ExitProgram(EXIT_FAILURE); } break; - case 'c': + case 'p': closepack = 1; break; - case OPTS_VERSION: - show_version(argv); - ExitProgram(EXIT_SUCCESS); default: - usage(ch == OPTS_USAGE); + CASE_COMMON; /* NOTREACHED */ } } |
