OSDN Git Service

#37287 (2.2.0.40) cmd1.c内のC4457警告に対応。 / Deal C4457 warning in cmd1.c.
[hengband/hengband.git] / src / util.c
index 13a5991..446b7e0 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;
@@ -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
@@ -1721,7 +1715,7 @@ 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);
 }
 
 /*
@@ -1733,6 +1727,12 @@ void select_floor_music()
        /* 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);
@@ -2773,12 +2773,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)
@@ -3151,7 +3146,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
@@ -3806,12 +3801,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;
@@ -3870,11 +3860,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 +4203,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 +4254,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();
@@ -4456,12 +4438,7 @@ void request_command(int shopping)
                        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 +4453,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 +4477,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 +4494,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 +4504,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 +4527,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 +4538,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);
                }
 
 
@@ -4704,12 +4646,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 = ' ';