OSDN Git Service

#37287 (2.2.0.89) C4706警告にエンバグを修正しつつ対応。 / Fix C4706 warning with correcting new bug.
[hengband/hengband.git] / src / util.c
index 7e377a6..26f8ff1 100644 (file)
@@ -1197,8 +1197,8 @@ void text_to_ascii(char *buf, cptr str)
                        /* Hex-mode XXX */
                        if (*str == 'x')
                        {
-                               *s = 16 * dehex(*++str);
-                               *s++ += dehex(*++str);
+                               *s = 16 * (char)dehex(*++str);
+                               *s++ += (char)dehex(*++str);
                        }
 
                        /* Hack -- simple way to specify "backslash" */
@@ -1252,29 +1252,29 @@ void text_to_ascii(char *buf, cptr str)
                        /* Octal-mode */
                        else if (*str == '0')
                        {
-                               *s = 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '1')
                        {
-                               *s = 64 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '2')
                        {
-                               *s = 64 * 2 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 * 2 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '3')
                        {
-                               *s = 64 * 3 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 * 3 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Skip the final char */
@@ -1322,7 +1322,7 @@ static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
                switch(ch)
                {
                case '&':
-                       while ((tmp = my_strchr(macro_modifier_chr, *str)))
+                       while ((tmp = my_strchr(macro_modifier_chr, *str)) != 0)
                        {
                                j = (int)(tmp - macro_modifier_chr);
                                tmp = macro_modifier_name[j];
@@ -1721,7 +1721,7 @@ errr play_music(int type, int val)
 /*
  * Hack -- Select floor music.
  */
-void select_floor_music()
+void select_floor_music(void)
 {
        int i;
        /* No sound */
@@ -2379,7 +2379,7 @@ s16b quark_add(cptr str)
 /*
  * This function looks up a quark
  */
-cptr quark_str(s16b i)
+cptr quark_str(STR_OFFSET i)
 {
        cptr q;
 
@@ -2833,16 +2833,6 @@ void msg_print(cptr msg)
 
        if (world_monster) return;
 
-       /* Copy it */
-       if(!cheat_turn)
-       {
-               strcpy(buf, msg);
-       }
-       else
-       {
-               sprintf(buf,("T:%d - %s"), turn, msg);
-       }
-
        /* Hack -- Reset */
        if (!msg_flag) {
                /* Clear the line */
@@ -2850,14 +2840,11 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-       /* Message Length */
-       n = (buf ? strlen(buf) : 0);
-
-       /* Paranoia */
-       if (n > 1000) return;
+       /* Original Message Length */
+       n = (msg ? strlen(msg) : 0);
 
        /* Hack -- flush when requested or needed */
-       if (p && (!buf || ((p + n) > 72)))
+       if (p && (!msg || ((p + n) > 72)))
        {
                /* Flush */
                msg_flush(p);
@@ -2872,6 +2859,22 @@ void msg_print(cptr msg)
        /* No message */
        if (!msg) return;
 
+       /* Paranoia */
+       if (n > 1000) return;
+
+       /* Copy it */
+       if (!cheat_turn)
+       {
+               strcpy(buf, msg);
+       }
+       else
+       {
+               sprintf(buf, ("T:%d - %s"), turn, msg);
+       }
+
+       /* New Message Length */
+       n = (buf ? strlen(buf) : 0);
+
        /* Memorize the message */
        if (character_generated) message_add(buf);
 
@@ -3799,10 +3802,10 @@ bool get_com(cptr prompt, char *command, bool z_escape)
  *
  * Hack -- allow "command_arg" to specify a quantity
  */
-s16b get_quantity(cptr prompt, int max)
+QUANTITY get_quantity(cptr prompt, QUANTITY max)
 {
        bool res;
-       int amt;
+       COMMAND_CODE amt;
        char tmp[80];
        char buf[80];
 
@@ -3875,7 +3878,7 @@ s16b get_quantity(cptr prompt, int max)
        if (!res) return 0;
 
        /* Extract a number */
-       amt = atoi(buf);
+       amt = (COMMAND_CODE)atoi(buf);
 
        /* A letter means "all" */
        if (isalpha(buf[0])) amt = max;
@@ -4617,7 +4620,7 @@ void request_command(int shopping)
        if (always_repeat && (command_arg <= 0))
        {
                /* Hack -- auto repeat certain commands */
-               if (my_strchr("TBDoc+", command_cmd))
+               if (my_strchr("TBDoc+", (COMMAND_CODE)command_cmd))
                {
                        /* Repeat 99 times */
                        command_arg = 99;
@@ -4859,10 +4862,10 @@ static int repeat__cnt = 0;
 static int repeat__idx = 0;
 
 /* Saved "stuff" */
-static int repeat__key[REPEAT_MAX];
+static COMMAND_CODE repeat__key[REPEAT_MAX];
 
 
-void repeat_push(int what)
+void repeat_push(COMMAND_CODE what)
 {
        /* Too many keys */
        if (repeat__cnt == REPEAT_MAX) return;
@@ -4875,7 +4878,7 @@ void repeat_push(int what)
 }
 
 
-bool repeat_pull(int *what)
+bool repeat_pull(COMMAND_CODE *what)
 {
        /* All out of keys */
        if (repeat__idx == repeat__cnt) return (FALSE);
@@ -4889,7 +4892,7 @@ bool repeat_pull(int *what)
 
 void repeat_check(void)
 {
-       int             what;
+       COMMAND_CODE what;
 
        /* Ignore some commands */
        if (command_cmd == ESCAPE) return;