From: Eric S. Raymond Date: Fri, 6 Jun 2014 20:43:38 +0000 (-0400) Subject: cppcheck cleanup. X-Git-Tag: 2.10~5 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=f49fefa009ba87c07ecb8e37104c4885f7e65202;p=bs.git cppcheck cleanup. --- diff --git a/bs.c b/bs.c index 2484940..cf1788e 100644 --- a/bs.c +++ b/bs.c @@ -523,8 +523,6 @@ static void initgame(void) static int getcoord(int atcpu) { - int ny, nx, c; - if (atcpu) cgoto(cury,curx); else @@ -532,6 +530,8 @@ static int getcoord(int atcpu) (void)refresh(); for (;;) { + int ny, nx, c; + if (atcpu) { (void) mvprintw(CYBASE + BDEPTH+1, CXBASE+11, "(%d, %c)", curx, 'A'+cury); @@ -715,11 +715,10 @@ static bool checkplace(int b, ship_t *ss, int vis) static int awinna(void) { int i, j; - ship_t *ss; for(i=0; i<2; ++i) { - ss = (i) ? cpuship : plyship; + ship_t *ss = (i) ? cpuship : plyship; for(j=0; j < SHIPTYPES; ++j, ++ss) if(ss->length > ss->hits) break; @@ -747,9 +746,12 @@ static ship_t *hitship(int x, int y) return((ship_t *)NULL); else /* sunk! */ { - int i, j; + int i; if (!closepack) + { + int j; + for (j = -1; j <= 1; j++) { int bx = ss->x + j * xincr[(ss->dir + 2) % 8]; @@ -784,6 +786,7 @@ static ship_t *hitship(int x, int y) } } } + } for (i = 0; i < ss->length; ++i) { @@ -884,12 +887,11 @@ static int plyturn(void) static int sgetc(const char *s) { const char *s1; - int ch; (void)refresh(); for(;;) { - ch = getch(); + int ch = getch(); if (islower(ch)) ch = toupper(ch); if (ch == CTRLC)