OSDN Git Service

Normal objects also are defined their activation type in k_info.txt.
[hengband/hengband.git] / src / util.c
index 28c3ab4..b626282 100644 (file)
@@ -293,7 +293,11 @@ static errr path_temp(char *buf, int max)
        if (!s) return (-1);
 
        /* Format to length */
+#ifndef WIN32
        (void)strnfmt(buf, max, "%s", s);
+#else
+       (void)strnfmt(buf, max, ".%s", s);
+#endif
 
        /* Success */
        return (0);
@@ -356,19 +360,19 @@ FILE *my_fopen(cptr file, cptr mode)
 {
        char buf[1024];
 
-#if defined(MACINTOSH) && defined(MAC_MPW)
+#if defined(MAC_MPW) || defined(MACH_O_CARBON)
        FILE *tempfff;
 #endif
 
        /* Hack -- Try to parse the path */
        if (path_parse(buf, 1024, file)) return (NULL);
 
-#if defined(MACINTOSH) && defined(MAC_MPW)
+#if defined(MAC_MPW) || defined(MACH_O_CARBON)
        if (my_strchr(mode, 'w'))
        {
                /* setting file type/creator */
                tempfff = fopen(buf, mode);
-               fsetfileinfo(file, _fcreator, _ftype);
+               fsetfileinfo(buf, _fcreator, _ftype);
                fclose(tempfff);
        }
 #endif
@@ -702,7 +706,7 @@ int fd_make(cptr file, int mode)
 
 #else /* BEN_HACK */
 
-# if defined(MACINTOSH) && defined(MAC_MPW)
+#if defined(MAC_MPW) || defined(MACH_O_CARBON)
        {
                int fdes;
                /* Create the file, fail if exists, write-only, binary */
@@ -2451,7 +2455,7 @@ void message_add(cptr str)
                }
 
                /* Limit the multiplier to 1000 */
-               if (buf && streq(buf, str) && (j < 1000))
+               if (streq(buf, str) && (j < 1000))
                {
                        j++;
 
@@ -3196,7 +3200,7 @@ void clear_from(int row)
  * ESCAPE clears the buffer and the window and returns FALSE.
  * RETURN accepts the current buffer contents and returns TRUE.
  */
-bool askfor_aux(char *buf, int len, bool numpad_cursor, bool allow_ascii_macro_trigger)
+bool askfor_aux(char *buf, int len, bool numpad_cursor)
 {
        int y, x;
        int pos = 0;
@@ -3237,7 +3241,7 @@ bool askfor_aux(char *buf, int len, bool numpad_cursor, bool allow_ascii_macro_t
                Term_gotoxy(x + pos, y);
 
                /* Get a special key code */
-               skey = inkey_special(numpad_cursor, allow_ascii_macro_trigger);
+               skey = inkey_special(numpad_cursor);
 
                /* Analyze the key */
                switch (skey)
@@ -3445,7 +3449,7 @@ bool askfor_aux(char *buf, int len, bool numpad_cursor, bool allow_ascii_macro_t
  */
 bool askfor(char *buf, int len)
 {
-       return askfor_aux(buf, len, TRUE, FALSE);
+       return askfor_aux(buf, len, TRUE);
 }
 
 
@@ -3459,7 +3463,7 @@ bool askfor(char *buf, int len)
  *
  * We clear the input, and return FALSE, on "ESCAPE".
  */
-bool get_string(cptr prompt, char *buf, int len, bool allow_ascii_macro_trigger)
+bool get_string(cptr prompt, char *buf, int len)
 {
        bool res;
 
@@ -3470,7 +3474,7 @@ bool get_string(cptr prompt, char *buf, int len, bool allow_ascii_macro_trigger)
        prt(prompt, 0, 0);
 
        /* Ask the user for a string */
-       res = askfor_aux(buf, len, TRUE, allow_ascii_macro_trigger);
+       res = askfor(buf, len);
 
        /* Clear prompt */
        prt("", 0, 0);
@@ -3622,7 +3626,10 @@ bool get_com(cptr prompt, char *command, bool z_escape)
        prt(prompt, 0, 0);
 
        /* Get a key */
-       *command = inkey();
+       if (get_com_no_macros)
+               *command = inkey_special(FALSE);
+       else
+               *command = inkey();
 
        /* Clear the prompt */
        prt("", 0, 0);
@@ -3713,7 +3720,7 @@ s16b get_quantity(cptr prompt, int max)
         * Ask for a quantity
         * Don't allow to use numpad as cursor key.
         */
-       res = askfor_aux(buf, 6, FALSE, TRUE);
+       res = askfor_aux(buf, 6, FALSE);
 
        /* Clear prompt */
        prt("", 0, 0);
@@ -4060,9 +4067,13 @@ special_menu_naiyou special_menu_info[] =
 {
        {"ĶǽÎÏ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_MINDCRAFTER},
        {"¤â¤Î¤Þ¤Í/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_IMITATOR},
+       {"²Î/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_BARD},
        {"ɬ»¦µ»/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_SAMURAI},
        {"Îýµ¤½Ñ/ËâË¡/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_FORCETRAINER},
+       {"µ»/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_BERSERKER},
+       {"µ»½Ñ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_SMITH},
        {"¶ÀËâË¡/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_MIRROR_MASTER},
+       {"Ǧ½Ñ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_NINJA},
        {"¹­°è¥Þ¥Ã¥×(<)", 2, 6, MENU_WILD, FALSE},
        {"Ä̾ï¥Þ¥Ã¥×(>)", 2, 7, MENU_WILD, TRUE},
        {"", 0, 0, 0, 0},
@@ -4072,9 +4083,13 @@ special_menu_naiyou special_menu_info[] =
 {
        {"MindCraft/Special", 0, 0, MENU_CLASS, CLASS_MINDCRAFTER},
        {"Imitation/Special", 0, 0, MENU_CLASS, CLASS_IMITATOR},
+       {"Song/Special", 0, 0, MENU_CLASS, CLASS_BARD},
        {"Technique/Special", 0, 0, MENU_CLASS, CLASS_SAMURAI},
        {"Mind/Magic/Special", 0, 0, MENU_CLASS, CLASS_FORCETRAINER},
+       {"BrutalPower/Special", 0, 0, MENU_CLASS, CLASS_BERSERKER},
+       {"Technique/Special", 0, 0, MENU_CLASS, CLASS_SMITH},
        {"MirrorMagic/Special", 0, 0, MENU_CLASS, CLASS_MIRROR_MASTER},
+       {"Ninjutsu/Special", 0, 0, MENU_CLASS, CLASS_NINJA},
        {"Enter global map(<)", 2, 6, MENU_WILD, FALSE},
        {"Enter local map(>)", 2, 7, MENU_WILD, TRUE},
        {"", 0, 0, 0, 0},
@@ -4838,14 +4853,9 @@ static void swap(tag_type *a, tag_type *b)
 {
        tag_type temp;
 
-       temp.tag = a->tag;
-       temp.pointer = a->pointer;
-
-       a->tag = b->tag;
-       a->pointer = b->pointer;
-
-       b->tag = temp.tag;
-       b->pointer = temp.pointer;
+       temp = *a;
+       *a = *b;
+       *b = temp;
 }
 
 
@@ -5206,26 +5216,29 @@ size_t my_strcpy(char *buf, const char *src, size_t bufsize)
        const char *s = src;
        size_t len = 0;
 
-       /* reserve for NUL termination */
-       bufsize--;
+       if (bufsize > 0) {
+               /* reserve for NUL termination */
+               bufsize--;
 
-       /* Copy as many bytes as will fit */
-       while (len < bufsize)
-       {
-               if (iskanji(*s))
+               /* Copy as many bytes as will fit */
+               while (*s && (len < bufsize))
                {
-                       if (len + 1 >= bufsize || !*(s+1)) break;
-                       *d++ = *s++;
-                       *d++ = *s++;
-                       len += 2;
-               }
-               else
-               {
-                       *d++ = *s++;
-                       len++;
+                       if (iskanji(*s))
+                       {
+                               if (len + 1 >= bufsize || !*(s+1)) break;
+                               *d++ = *s++;
+                               *d++ = *s++;
+                               len += 2;
+                       }
+                       else
+                       {
+                               *d++ = *s++;
+                               len++;
+                       }
                }
+               *d = '\0';
        }
-       *d = '\0';
+
        while(*s++) len++;
 
        return len;
@@ -5310,7 +5323,7 @@ char *my_strstr(const char *haystack, const char *needle)
 
 
 /*
- * A copy of ANSI my_strchr()
+ * A copy of ANSI strchr()
  *
  * my_strchr() can handle Kanji strings correctly.
  */
@@ -5356,7 +5369,7 @@ void str_tolower(char *str)
  * This function is a Mega-Hack and depend on pref-xxx.prf's.
  * Currently works on Linux(UNIX), Windows, and Macintosh only.
  */
-int inkey_special(bool numpad_cursor, bool allow_ascii_macro_trigger)
+int inkey_special(bool numpad_cursor)
 {
        static const struct {
                cptr keyname;
@@ -5406,6 +5419,12 @@ int inkey_special(bool numpad_cursor, bool allow_ascii_macro_trigger)
        int i;
        size_t trig_len;
 
+       /*
+        * Forget macro trigger ----
+        * It's important if we are already expanding macro action
+        */
+       inkey_macro_trigger_string[0] = '\0';
+
        /* Get a keypress */
        key = inkey();
 
@@ -5418,7 +5437,7 @@ int inkey_special(bool numpad_cursor, bool allow_ascii_macro_trigger)
        /*
         * Hack -- Ignore macro defined on ASCII characters.
         */
-       if ((trig_len == 1) && parse_macro && !allow_ascii_macro_trigger)
+       if (trig_len == 1 && parse_macro)
        {
                char c = inkey_macro_trigger_string[0];