OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。 / Ongoing type replacement.
[hengband/hengband.git] / src / util.c
index 13a5991..8270bad 100644 (file)
@@ -72,13 +72,7 @@ int usleep(huge usecs)
 
 
        /* Paranoia -- No excessive sleeping */
-#ifdef JP
-       if (usecs > 4000000L) core("不当な usleep() 呼び出し");
-#else
-       if (usecs > 4000000L) core("Illegal usleep() call");
-#endif
-
-
+       if (usecs > 4000000L) core(_("不当な usleep() 呼び出し", "Illegal usleep() call"));
 
        /* Wait for it */
        Timer.tv_sec = (usecs / 1000000L);
@@ -293,7 +287,7 @@ static errr path_temp(char *buf, int max)
        if (!s) return (-1);
 
        /* Format to length */
-#ifndef WIN32
+#if !defined(WIN32) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
        (void)strnfmt(buf, max, "%s", s);
 #else
        (void)strnfmt(buf, max, ".%s", s);
@@ -509,7 +503,7 @@ errr my_fgets(FILE *fff, char *buf, huge n)
                        }
 #endif
                        /* Handle printables */
-                       else if (isprint(*s))
+                       else if (isprint((unsigned char)*s))
                        {
                                /* Copy */
                                buf[i++] = *s;
@@ -702,7 +696,7 @@ errr fd_copy(cptr file, cptr what)
  * of "O_RDONLY", "O_WRONLY", and "O_RDWR" in "A-win-h", and then
  * we must simulate the effect of the proper "open()" call below.
  */
-int fd_make(cptr file, int mode)
+int fd_make(cptr file, BIT_FLAGS mode)
 {
        char buf[1024];
 
@@ -855,7 +849,7 @@ errr fd_chop(int fd, huge n)
        /* Verify the fd */
        if (fd < 0) return (-1);
 
-#if defined(SUNOS) || defined(ULTRIX) || defined(NeXT)
+#if defined(ULTRIX) || defined(NeXT)
        /* Truncate */
        ftruncate(fd, n);
 #endif
@@ -1203,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" */
@@ -1258,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 */
@@ -1328,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,18 +1715,24 @@ errr play_music(int type, int val)
        if (!use_music) return 1;
 
        /* Make a sound (if allowed) */
-       return Term_xtra(type , val);
+       return Term_xtra(type, val);
 }
 
 /*
  * Hack -- Select floor music.
  */
-void select_floor_music()
+void select_floor_music(void)
 {
        int i;
        /* No sound */
        if (!use_music) return;
 
+       if(ambush_flag)
+       {
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_AMBUSH);
+               return;
+       }
+
        if(p_ptr->wild_mode)
        {
                play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WILD);
@@ -1776,11 +1776,11 @@ void select_floor_music()
 
        if(dungeon_type)
        {
-               if(play_music(TERM_XTRA_MUSIC_DUNGEON, dungeon_type))
+               if(p_ptr->feeling == 2) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL2);
+               else if(p_ptr->feeling >= 3 && p_ptr->feeling <= 5) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL1);
+               else
                {
-                       if(p_ptr->feeling == 2) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL2);
-                       else if(p_ptr->feeling >= 3 && p_ptr->feeling <= 5) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL1);
-                       else
+                       if(play_music(TERM_XTRA_MUSIC_DUNGEON, dungeon_type))
                        {
                                if(dun_level < 40) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_LOW);
                                else if(dun_level < 80) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_MED);
@@ -2351,9 +2351,9 @@ void quark_init(void)
 /*
  * Add a new "quark" to the set of quarks.
  */
-s16b quark_add(cptr str)
+u16b quark_add(cptr str)
 {
-       int i;
+       u16b i;
 
        /* Look for an existing quark */
        for (i = 1; i < quark__num; i++)
@@ -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;
 
@@ -2419,10 +2419,11 @@ cptr quark_str(s16b i)
 
 
 
-/*
- * How many messages are "available"?
+/*!
+ * @brief 保存中の過去ゲームメッセージの数を返す。 / How many messages are "available"?
+ * @return 残っているメッセージの数
  */
-s16b message_num(void)
+s32b message_num(void)
 {
        int last, next, n;
 
@@ -2441,14 +2442,15 @@ s16b message_num(void)
 }
 
 
-
-/*
- * Recall the "text" of a saved message
+/*!
+ * @brief 過去のゲームメッセージを返す。 / Recall the "text" of a saved message
+ * @params age メッセージの世代
+ * @return メッセージの文字列ポインタ
  */
 cptr message_str(int age)
 {
-       s16b x;
-       s16b o;
+       s32b x;
+       s32b o;
        cptr s;
 
        /* Forgotten messages have no text */
@@ -2468,15 +2470,17 @@ cptr message_str(int age)
 }
 
 
-
-/*
- * Add a new message, with great efficiency
+/*!
+ * @brief ゲームメッセージをログに追加する。 / Add a new message, with great efficiency
+ * @params str 保存したいメッセージ
+ * @return なし
  */
 void message_add(cptr str)
 {
-       int i, k, x, m, n;
+       u32b i, n;
+       int k, x, m;
 
-       char u[1024];
+       char u[4096];
        char splitted1[81];
        cptr splitted2;
 
@@ -2491,39 +2495,37 @@ void message_add(cptr str)
        /* Important Hack -- Ignore "long" messages */
        if (n >= MESSAGE_BUF / 4) return;
 
-       /* extra step -- split the message if n>80.   (added by Mogami) */
+       /* extra step -- split the message if n>80.(added by Mogami) */
        if (n > 80) {
 #ifdef JP
-         cptr t = str;
-
-         for (n = 0; n < 80; n++, t++)
-           if(iskanji(*t)) {
-             t++;
-             n++;
-           }
-         if (n == 81) n = 79; /* 最後の文字が漢字半分 */
+               cptr t = str;
+
+               for (n = 0; n < 80; n++, t++)
+               {
+                       if(iskanji(*t)) {
+                               t++;
+                               n++;
+                       }
+               }
+               if (n == 81) n = 79; /* 最後の文字が漢字半分 */
 #else
-         for (n = 80; n > 60; n--)
-                 if (str[n] == ' ') break;
-         if (n == 60)
-                 n = 80;
+               for (n = 80; n > 60; n--)
+                       if (str[n] == ' ') break;
+               if (n == 60) n = 80;
 #endif
-         splitted2 = str + n;
-         strncpy(splitted1, str ,n);
-         splitted1[n] = '\0';
-         str = splitted1;
+               splitted2 = str + n;
+               strncpy(splitted1, str ,n);
+               splitted1[n] = '\0';
+               str = splitted1;
        } else {
-         splitted2 = NULL;
+               splitted2 = NULL;
        }
 
-       /*** Step 2 -- Attempt to optimize ***/
+       /*** Step 2 -- 最適化の試行 / Attempt to optimize ***/
 
        /* Limit number of messages to check */
        m = message_num();
-
        k = m / 4;
-
-       /* Limit number of messages to check */
        if (k > MESSAGE_MAX / 32) k = MESSAGE_MAX / 32;
 
        /* Check previous message */
@@ -2549,8 +2551,8 @@ void message_add(cptr str)
 
                /* Find multiple */
 #ifdef JP
- for (t = buf; *t && (*t != '<' || (*(t+1) != 'x' )); t++) 
-     if( iskanji(*t))t++;
              for (t = buf; *t && (*t != '<' || (*(t+1) != 'x' )); t++) 
+                       if(iskanji(*t))t++;
 #else
                for (t = buf; *t && (*t != '<'); t++);
 #endif
@@ -2598,8 +2600,7 @@ void message_add(cptr str)
        /* Check the last few messages (if any to count) */
        for (i = message__next; k; k--)
        {
-               u16b q;
-
+               int q;
                cptr old;
 
                /* Back up and wrap if needed */
@@ -2738,7 +2739,7 @@ void message_add(cptr str)
        message__head += n + 1;
 
        /* recursively add splitted message (added by Mogami) */
- end_of_message_add:
+end_of_message_add:
        if (splitted2 != NULL)
          message_add(splitted2);
 }
@@ -2773,12 +2774,7 @@ static void msg_flush(int x)
        if (!p_ptr->playing || !nagasu)
        {
                /* Pause for response */
-#ifdef JP
-               Term_putstr(x, 0, -1, a, "-続く-");
-#else
-               Term_putstr(x, 0, -1, a, "-more-");
-#endif
-
+               Term_putstr(x, 0, -1, a, _("-続く-", "-more-"));
 
                /* Get an acceptable keypress */
                while (1)
@@ -2832,11 +2828,8 @@ static void msg_flush(int x)
 void msg_print(cptr msg)
 {
        static int p = 0;
-
        int n;
-
        char *t;
-
        char buf[1024];
 
        if (world_monster) return;
@@ -2848,7 +2841,7 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-       /* Message Length */
+       /* Original Message Length */
        n = (msg ? strlen(msg) : 0);
 
        /* Hack -- flush when requested or needed */
@@ -2864,20 +2857,27 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-
        /* No message */
        if (!msg) return;
 
        /* Paranoia */
        if (n > 1000) return;
 
+       /* Copy it */
+       if (!cheat_turn)
+       {
+               strcpy(buf, msg);
+       }
+       else
+       {
+               sprintf(buf, ("T:%d - %s"), (int)turn, msg);
+       }
 
-       /* Memorize the message */
-       if (character_generated) message_add(msg);
-
+       /* New Message Length */
+       n = (buf ? strlen(buf) : 0);
 
-       /* Copy it */
-       strcpy(buf, msg);
+       /* Memorize the message */
+       if (character_generated) message_add(buf);
 
        /* Analyze the buffer */
        t = buf;
@@ -2953,7 +2953,6 @@ void msg_print(cptr msg)
                t += split; n -= split;
        }
 
-
        /* Display the tail of the message */
        Term_putstr(p, 0, n, TERM_WHITE, t);
 
@@ -2974,11 +2973,28 @@ void msg_print(cptr msg)
        p += n + 1;
 #endif
 
-
        /* Optional refresh */
        if (fresh_message) Term_fresh();
 }
 
+void msg_print_wizard(int cheat_type, cptr msg)
+{
+       if (!cheat_room && cheat_type == CHEAT_DUNGEON) return;
+       if (!cheat_peek && cheat_type == CHEAT_OBJECT) return;
+       if (!cheat_hear && cheat_type == CHEAT_MONSTER) return;
+       if (!cheat_xtra && cheat_type == CHEAT_MISC) return;
+
+       cptr cheat_mes[] = {"ITEM", "MONS", "DUNG", "MISC"};
+       char buf[1024];
+       sprintf(buf, "WIZ-%s:%s", cheat_mes[cheat_type], msg);
+       msg_print(buf);
+
+       if (cheat_diary_output)
+       {
+               do_cmd_write_nikki(NIKKI_WIZARD_LOG, 0, buf);
+       }
+
+}
 
 /*
  * Hack -- prevent "accidents" in "screen_save()" or "screen_load()"
@@ -3044,6 +3060,32 @@ void msg_format(cptr fmt, ...)
        msg_print(buf);
 }
 
+/*
+ * Display a formatted message, using "vstrnfmt()" and "msg_print()".
+ */
+void msg_format_wizard(int cheat_type, cptr fmt, ...)
+{
+       if(!cheat_room && cheat_type == CHEAT_DUNGEON) return;
+       if(!cheat_peek && cheat_type == CHEAT_OBJECT) return;
+       if(!cheat_hear && cheat_type == CHEAT_MONSTER) return;
+       if(!cheat_xtra && cheat_type == CHEAT_MISC) return;
+
+       va_list vp;
+       char buf[1024];
+
+       /* Begin the Varargs Stuff */
+       va_start(vp, fmt);
+
+       /* Format the args, save the length */
+       (void)vstrnfmt(buf, 1024, fmt, vp);
+
+       /* End the Varargs Stuff */
+       va_end(vp);
+
+       /* Display */
+       msg_print_wizard(cheat_type, buf);
+}
+
 
 
 /*
@@ -3151,7 +3193,7 @@ void c_roff(byte a, cptr str)
 
                /* Clean up the char */
 #ifdef JP
-               ch = ((isprint(*s) || k_flag) ? *s : ' ');
+               ch = ((k_flag || isprint(*s)) ? *s : ' ');
 #else
                ch = (isprint(*s) ? *s : ' ');
 #endif
@@ -3617,7 +3659,7 @@ bool get_check(cptr prompt)
  * mode & CHECK_NO_HISTORY  : no message_add
  * mode & CHECK_DEFAULT_Y   : accept any key as y, except n and Esc.
  */
-bool get_check_strict(cptr prompt, int mode)
+bool get_check_strict(cptr prompt, BIT_FLAGS mode)
 {
        int i;
        char buf[80];
@@ -3761,12 +3803,13 @@ 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;
+       bool res, result;
+       QUANTITY amt;
        char tmp[80];
        char buf[80];
+       COMMAND_CODE code;
 
 
        /* Use "command_arg" */
@@ -3788,7 +3831,9 @@ s16b get_quantity(cptr prompt, int max)
 #ifdef ALLOW_REPEAT /* TNB */
 
        /* Get the item index */
-       if ((max != 1) && repeat_pull(&amt))
+       result = repeat_pull(&code);
+       amt = (QUANTITY)code;
+       if ((max != 1) && result)
        {
                /* Enforce the maximum */
                if (amt > max) amt = max;
@@ -3806,12 +3851,7 @@ s16b get_quantity(cptr prompt, int max)
        if (!prompt)
        {
                /* Build a prompt */
-#ifdef JP
-               sprintf(tmp, "いくつですか (1-%d): ", max);
-#else
-               sprintf(tmp, "Quantity (1-%d): ", max);
-#endif
-
+               sprintf(tmp, _("いくつですか (1-%d): ", "Quantity (1-%d): "), max);
 
                /* Use that prompt */
                prompt = tmp;
@@ -3842,7 +3882,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;
@@ -3855,7 +3895,7 @@ s16b get_quantity(cptr prompt, int max)
 
 #ifdef ALLOW_REPEAT /* TNB */
 
-       if (amt) repeat_push(amt);
+       if (amt) repeat_push((COMMAND_CODE)amt);
 
 #endif /* ALLOW_REPEAT -- TNB */
 
@@ -3870,11 +3910,7 @@ s16b get_quantity(cptr prompt, int max)
 void pause_line(int row)
 {
        prt("", row, 0);
-#ifdef JP
-       put_str("[ 何かキーを押して下さい ]", row, 26);
-#else
-       put_str("[Press any key to continue]", row, 23);
-#endif
+       put_str(_("[ 何かキーを押して下さい ]", "[Press any key to continue]"), row, _(26, 23));
 
        (void)inkey();
        prt("", row, 0);
@@ -4217,7 +4253,7 @@ static char inkey_from_menu(void)
        int menu = 0;
        bool kisuu;
 
-       if (py - panel_row_min > 10) basey = 2;
+       if (p_ptr->y - panel_row_min > 10) basey = 2;
        else basey = 13;
        basex = 15;
 
@@ -4268,14 +4304,10 @@ static char inkey_from_menu(void)
                }
                max_num = i;
                kisuu = max_num % 2;
-#ifdef JP
-               put_str("》",basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
-#else
-               put_str("> ",basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
-#endif
+               put_str(_("》", "> "),basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
 
                /* Place the cursor on the player */
-               move_cursor_relative(py, px);
+               move_cursor_relative(p_ptr->y, p_ptr->x);
 
                /* Get a command */
                sub_cmd = inkey();
@@ -4376,7 +4408,7 @@ void request_command(int shopping)
 {
        int i;
 
-       char cmd;
+       s16b cmd;
        int mode;
 
        cptr act;
@@ -4450,18 +4482,13 @@ void request_command(int shopping)
                /* Command Count */
                if (cmd == '0')
                {
-                       int old_arg = command_arg;
+                       COMMAND_ARG old_arg = command_arg;
 
                        /* Reset */
                        command_arg = 0;
 
                        /* Begin the input */
-#ifdef JP
-                       prt("回数: ", 0, 0);
-#else
-                       prt("Count: ", 0, 0);
-#endif
-
+                       prt(_("回数: ", "Count: "), 0, 0);
 
                        /* Get a command count */
                        while (1)
@@ -4476,12 +4503,7 @@ void request_command(int shopping)
                                        command_arg = command_arg / 10;
 
                                        /* Show current count */
-#ifdef JP
-                                       prt(format("回数: %d", command_arg), 0, 0);
-#else
-                                       prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                                       prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                                }
 
                                /* Actual numeric data */
@@ -4505,12 +4527,7 @@ void request_command(int shopping)
                                        }
 
                                        /* Show current count */
-#ifdef JP
-                                       prt(format("回数: %d", command_arg), 0, 0);
-#else
-                                       prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                                       prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                                }
 
                                /* Exit on "unusable" input */
@@ -4527,12 +4544,7 @@ void request_command(int shopping)
                                command_arg = 99;
 
                                /* Show current count */
-#ifdef JP
-                               prt(format("回数: %d", command_arg), 0, 0);
-#else
-                               prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                               prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                        }
 
                        /* Hack -- Handle "old_arg" */
@@ -4542,24 +4554,14 @@ void request_command(int shopping)
                                command_arg = old_arg;
 
                                /* Show current count */
-#ifdef JP
-prt(format("回数: %d", command_arg), 0, 0);
-#else
-                               prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                               prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                        }
 
                        /* Hack -- white-space means "enter command now" */
                        if ((cmd == ' ') || (cmd == '\n') || (cmd == '\r'))
                        {
                                /* Get a real command */
-#ifdef JP
-                               if (!get_com("コマンド: ", (char *)&cmd, FALSE))
-#else
-                               if (!get_com("Command: ", (char *)&cmd, FALSE))
-#endif
-
+                               if (!get_com(_("コマンド: ", "Command: "), (char *)&cmd, FALSE))
                                {
                                        /* Clear count */
                                        command_arg = 0;
@@ -4575,12 +4577,7 @@ prt(format("回数: %d", command_arg), 0, 0);
                if (cmd == '\\')
                {
                        /* Get a real command */
-#ifdef JP
-                       (void)get_com("コマンド: ", (char *)&cmd, FALSE);
-#else
-                       (void)get_com("Command: ", (char *)&cmd, FALSE);
-#endif
-
+                       (void)get_com(_("コマンド: ", "Command: "), (char *)&cmd, FALSE);
 
                        /* Hack -- bypass keymaps */
                        if (!inkey_next) inkey_next = "";
@@ -4591,12 +4588,7 @@ prt(format("回数: %d", command_arg), 0, 0);
                if (cmd == '^')
                {
                        /* Get a new command and controlify it */
-#ifdef JP
-                       if (get_com("CTRL: ", (char *)&cmd, FALSE)) cmd = KTRL(cmd);
-#else
-                       if (get_com("Control: ", (char *)&cmd, FALSE)) cmd = KTRL(cmd);
-#endif
-
+                       if (get_com(_("CTRL: ", "Control: "), (char *)&cmd, FALSE)) cmd = KTRL(cmd);
                }
 
 
@@ -4632,7 +4624,7 @@ prt(format("回数: %d", command_arg), 0, 0);
        if (always_repeat && (command_arg <= 0))
        {
                /* Hack -- auto repeat certain commands */
-               if (my_strchr("TBDoc+", command_cmd))
+               if (my_strchr("TBDoc+", (char)command_cmd))
                {
                        /* Repeat 99 times */
                        command_arg = 99;
@@ -4704,12 +4696,7 @@ prt(format("回数: %d", command_arg), 0, 0);
 
                        {
                                /* Hack -- Verify command */
-#ifdef JP
-                               if (!get_check("本当ですか? "))
-#else
-                               if (!get_check("Are you sure? "))
-#endif
-
+                               if (!get_check(_("本当ですか? ", "Are you sure? ")))
                                {
                                        /* Hack -- Use space */
                                        command_cmd = ' ';
@@ -4830,7 +4817,7 @@ int get_keymap_dir(char ch)
        }
        else
        {
-               int mode;
+               BIT_FLAGS mode;
                cptr act, s;
 
                /* Roguelike */
@@ -4879,10 +4866,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;
@@ -4895,7 +4882,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);
@@ -4909,7 +4896,7 @@ bool repeat_pull(int *what)
 
 void repeat_check(void)
 {
-       int             what;
+       COMMAND_CODE what;
 
        /* Ignore some commands */
        if (command_cmd == ESCAPE) return;
@@ -5470,7 +5457,7 @@ void str_tolower(char *str)
                        continue;
                }
 #endif
-               *str = tolower(*str);
+               *str = (char)tolower(*str);
        }
 }