OSDN Git Service

#37287 (2.2.0.85) z-term.c, z-rand.c, z-form.c 中のVCコンパイラ警告を修正。C4710は抑制。 / Fix warning...
authorDeskull <desull@users.sourceforge.jp>
Tue, 12 Sep 2017 12:25:20 +0000 (21:25 +0900)
committerDeskull <desull@users.sourceforge.jp>
Tue, 12 Sep 2017 12:25:20 +0000 (21:25 +0900)
Hengband_vcs2015/Hengband/Hengband.vcxproj
src/defines.h
src/z-form.c
src/z-rand.c
src/z-term.c

index 9cf27a4..23ae2bf 100644 (file)
@@ -69,7 +69,7 @@
       <WarningLevel>EnableAllWarnings</WarningLevel>\r
       <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r
       <CompileAs>CompileAsC</CompileAs>\r
-      <DisableSpecificWarnings>4127;4996;4244;4820;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
+      <DisableSpecificWarnings>4127;4710;4996;4244;4820;%(DisableSpecificWarnings)</DisableSpecificWarnings>\r
     </ClCompile>\r
     <Link>\r
       <AdditionalDependencies>winmm.lib;wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
index 10e6554..92a1825 100644 (file)
@@ -53,7 +53,7 @@
 #define FAKE_VER_MAJOR 12 /*!< ゲームのバージョン番号定義(メジャー番号 + 10) */
 #define FAKE_VER_MINOR 2 /*!< ゲームのバージョン番号定義(マイナー番号) */
 #define FAKE_VER_PATCH 0 /*!< ゲームのバージョン番号定義(パッチ番号) */
-#define FAKE_VER_EXTRA 85 /*!< ゲームのバージョン番号定義(エクストラ番号) */
+#define FAKE_VER_EXTRA 86 /*!< ゲームのバージョン番号定義(エクストラ番号) */
 
 
  /*!
index d0d6c88..34367c6 100644 (file)
@@ -466,7 +466,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, int);
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg);
+                               sprintf(tmp, "%c", arg);
 
                                /* Done */
                                break;
@@ -483,7 +483,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        arg = va_arg(vp, long);
 
                                        /* Format the argument */
-                                       sprintf(tmp, aux, arg);
+                                       sprintf(tmp, "%ld", arg);
                                }
                                else
                                {
@@ -493,7 +493,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        arg = va_arg(vp, int);
 
                                        /* Format the argument */
-                                       sprintf(tmp, aux, arg);
+                                       sprintf(tmp, "%d", arg);
                                }
 
                                /* Done */
@@ -511,7 +511,25 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        arg = va_arg(vp, unsigned long);
 
                                        /* Format the argument */
-                                       sprintf(tmp, aux, arg);
+                                       switch (aux[q-1])
+                                       {
+                                               case 'u':
+                                                       sprintf(tmp, "%lu", arg);
+                                                       break;
+                                               case 'o':
+                                                       sprintf(tmp, "%lo", arg);
+                                                       break;
+                                               case 'x':
+                                                       sprintf(tmp, "%lx", arg);
+                                                       break;
+                                               case 'X':
+                                                       sprintf(tmp, "%lX", arg);
+                                                       break;
+                                               default:
+                                                       sprintf(tmp, "");
+                                                       break;
+                                       }
+
                                }
                                else
                                {
@@ -521,7 +539,24 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        arg = va_arg(vp, unsigned int);
 
                                        /* Format the argument */
-                                       sprintf(tmp, aux, arg);
+                                       switch (aux[q - 1])
+                                       {
+                                       case 'u':
+                                               sprintf(tmp, "%u", arg);
+                                               break;
+                                       case 'o':
+                                               sprintf(tmp, "%o", arg);
+                                               break;
+                                       case 'x':
+                                               sprintf(tmp, "%x", arg);
+                                               break;
+                                       case 'X':
+                                               sprintf(tmp, "%X", arg);
+                                               break;
+                                       default:
+                                               sprintf(tmp, "");
+                                               break;
+                                       }
                                }
 
                                /* Done */
@@ -539,7 +574,27 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, double);
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg);
+                               switch (aux[q - 1])
+                               {
+                               case 'f':
+                                       sprintf(tmp, "%f", arg);
+                                       break;
+                               case 'e':
+                                       sprintf(tmp, "%e", arg);
+                                       break;
+                               case 'E':
+                                       sprintf(tmp, "%E", arg);
+                                       break;
+                               case 'g':
+                                       sprintf(tmp, "%g", arg);
+                                       break;
+                               case 'G':
+                                       sprintf(tmp, "%G", arg);
+                                       break;
+                               default:
+                                       sprintf(tmp, aux, arg);
+                                       break;
+                               }
 
                                /* Done */
                                break;
@@ -554,7 +609,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, vptr);
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg);
+                               sprintf(tmp, "%p", arg);
 
                                /* Done */
                                break;
@@ -577,7 +632,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg2[1023] = '\0';
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg2);
+                               sprintf(tmp, "%s", arg2);
 
                                /* Done */
                                break;
@@ -593,7 +648,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, vptr);
 
                                /* Format the "user data" */
-                               (void)vstrnfmt_aux(tmp, 1000, aux, arg);
+                               (void)vstrnfmt_aux(tmp, 1000, aux[q-1] == 'V' ? "%V" : "%v", arg);
 
                                /* Done */
                                break;
@@ -626,7 +681,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                {
                                        /* Capitalize if possible */
                                        if (islower(tmp[q]))
-                                               tmp[q] = toupper(tmp[q]);
+                                               tmp[q] = (char)toupper(tmp[q]);
 
                                        /* Done */
                                        break;
index 8f9ce59..9ca8786 100644 (file)
@@ -362,7 +362,7 @@ s16b randnor(int mean, int stand)
        s16b high = RANDNOR_NUM;
 
        /* Paranoia */
-       if (stand < 1) return (mean);
+       if (stand < 1) return (s16b)(mean);
 
        /* Roll for probability */
        tmp = (s16b)randint0(32768);
@@ -381,7 +381,7 @@ s16b randnor(int mean, int stand)
                /* Move left otherwise */
                else
                {
-                       high = mid;
+                       high = (s16b)mid;
                }
        }
 
@@ -404,7 +404,7 @@ s16b damroll(int num, int sides)
 {
        int i, sum = 0;
        for (i = 0; i < num; i++) sum += randint1(sides);
-       return (sum);
+       return (s16b)(sum);
 }
 
 
@@ -463,7 +463,7 @@ s32b Rand_external(s32b m)
        if (!initialized)
        {
                /* Initialize with new seed */
-               u32b seed = time(NULL);
+               u32b seed = (u32b)time(NULL);
                Rand_Xorshift_seed(seed, Rand_state_external);
                initialized = TRUE;
        }
index e84c518..da4d9f8 100644 (file)
@@ -535,12 +535,12 @@ void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc)
        *scr_tcc = tc;
 
        /* Check for new min/max row info */
-       if (y < Term->y1) Term->y1 = y;
-       if (y > Term->y2) Term->y2 = y;
+       if (y < Term->y1) Term->y1 = (byte_hack)y;
+       if (y > Term->y2) Term->y2 = (byte_hack)y;
 
        /* Check for new min/max col info for this row */
-       if (x < Term->x1[y]) Term->x1[y] = x;
-       if (x > Term->x2[y]) Term->x2[y] = x;
+       if (x < Term->x1[y]) Term->x1[y] = (byte_hack)x;
+       if (x > Term->x2[y]) Term->x2[y] = (byte_hack)x;
 
 #ifdef JP
        if (((scrn->a[y][x] & AF_BIGTILE2) == AF_BIGTILE2) ||
@@ -695,12 +695,12 @@ void Term_queue_line(int x, int y, int n, byte *a, char *c, byte *ta, char *tc)
        if (x1 >= 0)
        {
                /* Check for new min/max row info */
-               if (y < Term->y1) Term->y1 = y;
-               if (y > Term->y2) Term->y2 = y;
+               if (y < Term->y1) Term->y1 = (byte_hack)y;
+               if (y > Term->y2) Term->y2 = (byte_hack)y;
 
                /* Check for new min/max col info in this row */
-               if (x1 < Term->x1[y]) Term->x1[y] = x1;
-               if (x2 > Term->x2[y]) Term->x2[y] = x2;
+               if (x1 < Term->x1[y]) Term->x1[y] = (byte_hack)x1;
+               if (x2 > Term->x2[y]) Term->x2[y] = (byte_hack)x2;
        }
 }
 
@@ -828,12 +828,12 @@ void Term_queue_chars(int x, int y, int n, byte a, cptr s)
        if (x1 >= 0)
        {
                /* Check for new min/max row info */
-               if (y < Term->y1) Term->y1 = y;
-               if (y > Term->y2) Term->y2 = y;
+               if (y < Term->y1) Term->y1 = (byte_hack)y;
+               if (y > Term->y2) Term->y2 = (byte_hack)y;
 
                /* Check for new min/max col info in this row */
-               if (x1 < Term->x1[y]) Term->x1[y] = x1;
-               if (x2 > Term->x2[y]) Term->x2[y] = x2;
+               if (x1 < Term->x1[y]) Term->x1[y] = (byte_hack)x1;
+               if (x2 > Term->x2[y]) Term->x2[y] = (byte_hack)x2;
        }
 }
 
@@ -1692,7 +1692,7 @@ errr Term_fresh(void)
                                }
 
                                /* This row is all done */
-                               Term->x1[y] = w;
+                               Term->x1[y] = (byte_hack)w;
                                Term->x2[y] = 0;
 
                                /* Hack -- Flush that row (if allowed) */
@@ -1701,7 +1701,7 @@ errr Term_fresh(void)
                }
 
                /* No rows are invalid */
-               Term->y1 = h;
+               Term->y1 = (byte_hack)h;
                Term->y2 = 0;
        }
 
@@ -1796,7 +1796,7 @@ errr Term_set_cursor(int v)
        if (Term->scr->cv == v) return (1);
 
        /* Change */
-       Term->scr->cv = v;
+       Term->scr->cv = (bool_hack)v;
 
        /* Success */
        return (0);
@@ -1818,8 +1818,8 @@ errr Term_gotoxy(int x, int y)
        if ((y < 0) || (y >= h)) return (-1);
 
        /* Remember the cursor */
-       Term->scr->cx = x;
-       Term->scr->cy = y;
+       Term->scr->cx = (byte_hack)x;
+       Term->scr->cy = (byte_hack)y;
 
        /* The cursor is not useless */
        Term->scr->cu = 0;
@@ -1975,7 +1975,7 @@ errr Term_addstr(int n, byte a, cptr s)
        Term_queue_chars(Term->scr->cx, Term->scr->cy, n, a, s);
 
        /* Advance the cursor */
-       Term->scr->cx += n;
+       Term->scr->cx += (byte_hack)n;
 
        /* Hack -- Notice "Useless" cursor */
        if (res) Term->scr->cu = 1;
@@ -2124,8 +2124,8 @@ errr Term_erase(int x, int y, int n)
                        n++;
 #endif
                /* Save the "literal" information */
-               scr_aa[x] = na;
-               scr_cc[x] = nc;
+               scr_aa[x] = (byte_hack)na;
+               scr_cc[x] = (char)nc;
 
                scr_taa[x] = 0;
                scr_tcc[x] = 0;
@@ -2141,12 +2141,12 @@ errr Term_erase(int x, int y, int n)
        if (x1 >= 0)
        {
                /* Check for new min/max row info */
-               if (y < Term->y1) Term->y1 = y;
-               if (y > Term->y2) Term->y2 = y;
+               if (y < Term->y1) Term->y1 = (byte_hack)y;
+               if (y > Term->y2) Term->y2 = (byte_hack)y;
 
                /* Check for new min/max col info in this row */
-               if (x1 < Term->x1[y]) Term->x1[y] = x1;
-               if (x2 > Term->x2[y]) Term->x2[y] = x2;
+               if (x1 < Term->x1[y]) Term->x1[y] = (byte_hack)x1;
+               if (x2 > Term->x2[y]) Term->x2[y] = (byte_hack)x2;
        }
 
        /* Success */
@@ -2246,8 +2246,8 @@ errr Term_redraw_section(int x1, int y1, int x2, int y2)
        if (x1 < 0) x1 = 0;
 
        /* Set y limits */
-       Term->y1 = y1;
-       Term->y2 = y2;
+       Term->y1 = (byte_hack)y1;
+       Term->y2 = (byte_hack)y2;
 
        /* Set the x limits */
        for (i = Term->y1; i <= Term->y2; i++)
@@ -2266,8 +2266,8 @@ errr Term_redraw_section(int x1, int y1, int x2, int y2)
                        if (Term->scr->a[i][x2j] & AF_KANJI1) x2j++;
                }
    
-               Term->x1[i] = x1j;
-               Term->x2[i] = x2j;
+               Term->x1[i] = (byte_hack)x1j;
+               Term->x2[i] = (byte_hack)x2j;
    
                c_ptr = Term->old->c[i];
    
@@ -2401,7 +2401,7 @@ errr Term_keypress(int k)
        if (!k) return (-1);
 
        /* Store the char, advance the queue */
-       Term->key_queue[Term->key_head++] = k;
+       Term->key_queue[Term->key_head++] = (char)k;
 
        /* Circular queue, handle wrap */
        if (Term->key_head == Term->key_size) Term->key_head = 0;
@@ -2431,7 +2431,7 @@ errr Term_key_push(int k)
        if (Term->key_tail == 0) Term->key_tail = Term->key_size;
 
        /* Back up, Store the char */
-       Term->key_queue[--Term->key_tail] = k;
+       Term->key_queue[--Term->key_tail] = (char)k;
 
        /* Success (unless overflow) */
        if (Term->key_head != Term->key_tail) return (0);
@@ -2782,8 +2782,8 @@ errr Term_resize(int w, int h)
        }
 
        /* Save new size */
-       Term->wid = w;
-       Term->hgt = h;
+       Term->wid = (byte_hack)w;
+       Term->hgt = (byte_hack)h;
 
        /* Force "total erase" */
        Term->total_erase = TRUE;
@@ -2940,15 +2940,15 @@ errr term_init(term *t, int w, int h, int k)
        t->key_head = t->key_tail = 0;
 
        /* Determine the input queue size */
-       t->key_size = k;
+       t->key_size = (u16b)k;
 
        /* Allocate the input queue */
        C_MAKE(t->key_queue, t->key_size, char);
 
 
        /* Save the size */
-       t->wid = w;
-       t->hgt = h;
+       t->wid = (byte_hack)w;
+       t->hgt = (byte_hack)h;
 
        /* Allocate change arrays */
        C_MAKE(t->x1, h, byte);