]> thyrsus.com Git - bs.git/commitdiff
cppcheck cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 6 Jun 2014 20:43:38 +0000 (16:43 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 6 Jun 2014 20:43:38 +0000 (16:43 -0400)
bs.c

diff --git a/bs.c b/bs.c
index 248494027ae9e7f5e638a231ec3d852e1cdaee8c..cf1788eaf7d1ce7cdfce93cb8d6982db77d32cb2 100644 (file)
--- 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)