OSDN Git Service

TO開発チームからの報告を元にいろいろ修正。
[hengbandforosx/hengbandosx.git] / src / init1.c
index 0da37c6..83e34dd 100644 (file)
@@ -7,20 +7,15 @@
 
 #ifdef JP
 #undef strchr
-char* _strchr(char* ptr, char ch)
+static char *_strchr(const char *ptr, char ch)
 {
-  int k_flag = 0;
-
-  for ( ; *ptr != '\0'; ++ptr)
-    if (k_flag == 0) {
-      if (*ptr == ch)
-       return ptr;
-      if (iskanji(*ptr))
-       k_flag = 1;
-    } else
-      k_flag = 0;
-
-  return NULL;
+       for ( ; *ptr != '\0'; ++ptr)
+       {
+               if (*ptr == ch) return (char *)ptr;
+               if (iskanji(*ptr)) ++ptr;
+       }
+
+       return NULL;
 }
 #define strchr _strchr
 #endif
@@ -90,6 +85,7 @@ static cptr r_info_blow_method[] =
        "INSULT",
        "MOAN",
        "SHOW",
+       "SHOOT",
        NULL
 };
 
@@ -154,7 +150,7 @@ static cptr r_info_flags1[] =
        "FORCE_MAXHP",
        "FORCE_SLEEP",
        "FORCE_EXTRA",
-       "FRIEND",
+       "XXX1",
        "FRIENDS",
        "ESCORT",
        "ESCORTS",
@@ -172,8 +168,8 @@ static cptr r_info_flags1[] =
        "DROP_4D2",
        "DROP_GOOD",
        "DROP_GREAT",
-       "DROP_USEFUL",
-       "DROP_CHOSEN"
+       "XXX2",
+       "XXX3"
 };
 
 /*
@@ -211,7 +207,7 @@ static cptr r_info_flags2[] =
        "BRAIN_4",
        "BRAIN_5",
        "BRAIN_6",
-       "BRAIN_7",
+       "HUMAN",
        "QUANTUM"
 };
 
@@ -263,10 +259,10 @@ static cptr r_info_flags4[] =
        "XXX1",
        "DISPEL",
        "ROCKET",
-       "ARROW_1",
-       "ARROW_2",
-       "ARROW_3",
-       "ARROW_4",
+       "SHOOT",
+       "XXX2",
+       "XXX3",
+       "XXX4",
        "BR_ACID",
        "BR_ELEC",
        "BR_FIRE",
@@ -392,7 +388,7 @@ static cptr r_info_flags7[] =
        "GUARDIAN",
        "CHAMELEON",
        "KILL_EXP",
-       "XXX7X15",
+       "TANUKI",
        "XXX7X16",
        "XXX7X17",
        "XXX7X18",
@@ -495,7 +491,7 @@ static cptr r_info_flags9[] =
 /*
  * Object flags
  */
-static cptr k_info_flags1[] =
+static cptr k_info_flags[] =
 {
        "STR",
        "INT",
@@ -504,7 +500,7 @@ static cptr k_info_flags1[] =
        "CON",
        "CHR",
        "MAGIC_MASTERY",
-       "FORCE_WEPON",
+       "FORCE_WEAPON",
        "STEALTH",
        "SEARCH",
        "INFRA",
@@ -528,14 +524,8 @@ static cptr k_info_flags1[] =
        "BRAND_ACID",
        "BRAND_ELEC",
        "BRAND_FIRE",
-       "BRAND_COLD"
-};
+       "BRAND_COLD",
 
-/*
- * Object flags
- */
-static cptr k_info_flags2[] =
-{
        "SUST_STR",
        "SUST_INT",
        "SUST_WIS",
@@ -543,7 +533,7 @@ static cptr k_info_flags2[] =
        "SUST_CON",
        "SUST_CHR",
        "RIDING",
-       "XXX2",
+       "EASY_SPELL",
        "IM_ACID",
        "IM_ELEC",
        "IM_FIRE",
@@ -567,26 +557,20 @@ static cptr k_info_flags2[] =
        "RES_NETHER",
        "RES_NEXUS",
        "RES_CHAOS",
-       "RES_DISEN"
-};
+       "RES_DISEN",
 
-/*
- * Object flags
- */
-static cptr k_info_flags3[] =
-{
        "SH_FIRE",
        "SH_ELEC",
-       "QUESTITEM",
+       "SLAY_HUMAN",
        "SH_COLD",
        "NO_TELE",
        "NO_MAGIC",
        "DEC_MANA",
        "TY_CURSE",
-       "XXX1",
+       "WARNING",
        "HIDE_TYPE",
        "SHOW_MODS",
-       "INSTA_ART",
+       "XXX1",
        "FEATHER",
        "LITE",
        "SEE_INVIS",
@@ -604,9 +588,68 @@ static cptr k_info_flags3[] =
        "TELEPORT",
        "AGGRAVATE",
        "BLESSED",
+       "XXX3",
+       "XXX4",
+       "XXX5",
+
+       "KILL_ANIMAL",
+       "KILL_EVIL",
+       "KILL_UNDEAD",
+       "KILL_DEMON",
+       "KILL_ORC",
+       "KILL_TROLL",
+       "KILL_GIANT",
+       "KILL_HUMAN",
+       "ESP_ANIMAL",
+       "ESP_UNDEAD",
+       "ESP_DEMON",
+       "ESP_ORC",
+       "ESP_TROLL",
+       "ESP_GIANT",
+       "ESP_DRAGON",
+       "ESP_HUMAN",
+       "ESP_EVIL",
+       "ESP_GOOD",
+       "ESP_NONLIVING",
+       "ESP_UNIQUE",
+       "FULL_NAME",
+};
+
+
+static cptr k_info_gen_flags[] =
+{
+       "INSTA_ART",
+       "QUESTITEM",
+       "XTRA_POWER",
+       "ONE_SUSTAIN",
+       "XTRA_RES_OR_POWER",
+       "XTRA_H_RES",
+       "XTRA_E_RES",
+       "XTRA_L_RES",
+       "XTRA_D_RES",
+       "XTRA_RES",
        "CURSED",
        "HEAVY_CURSE",
-       "PERMA_CURSE"
+       "PERMA_CURSE",
+       "RANDOM_CURSE0",
+       "RANDOM_CURSE1",
+       "RANDOM_CURSE2",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
+       "XXX",
 };
 
 
@@ -615,46 +658,106 @@ static cptr k_info_flags3[] =
  */
 static cptr d_info_flags1[] =
 {
-        "WINNER",
-        "MAZE",
-        "SMALLEST",
-        "BEGINNER",
-        "BIG",
-        "NO_DOORS",
-        "WATER_RIVER",
-        "LAVA_RIVER",
-        "WATER_RIVERS",
-        "LAVA_RIVERS",
-        "CAVE",
-        "CAVERN",
-        "NO_UP",
-        "HOT",
-        "COLD",
-        "NO_DOWN",
-        "FORGET",
-        "LAKE_WATER",
-        "LAKE_LAVA",
-        "LAKE_RUBBLE",
-        "LAKE_TREE",
-        "NO_VAULT",
-        "ARENA",
-        "DESTROY",
-        "XXX1",
-        "NO_CAVE",
-        "NO_MAGIC",
-        "NO_MELEE",
-        "CHAMELEON",
-        "DARKNESS",
-        "XXX1",
-        "XXX1"
+       "WINNER",
+       "MAZE",
+       "SMALLEST",
+       "BEGINNER",
+       "BIG",
+       "NO_DOORS",
+       "WATER_RIVER",
+       "LAVA_RIVER",
+       "WATER_RIVERS",
+       "LAVA_RIVERS",
+       "CAVE",
+       "CAVERN",
+       "NO_UP",
+       "HOT",
+       "COLD",
+       "NO_DOWN",
+       "FORGET",
+       "LAKE_WATER",
+       "LAKE_LAVA",
+       "LAKE_RUBBLE",
+       "LAKE_TREE",
+       "NO_VAULT",
+       "ARENA",
+       "DESTROY",
+       "XXX1",
+       "NO_CAVE",
+       "NO_MAGIC",
+       "NO_MELEE",
+       "CHAMELEON",
+       "DARKNESS",
+       "XXX1",
+       "XXX1"
 };
 
 
 /*
+ * Add a text to the text-storage and store offset to it.
+ *
+ * Returns FALSE when there isn't enough space available to store
+ * the text.
+ */
+static bool add_text(u32b *offset, header *head, cptr buf)
+{
+       /* Hack -- Verify space */
+       if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
+               return (FALSE);
+
+       /* New text? */
+       if (*offset == 0)
+       {
+               /* Advance and save the text index */
+               *offset = ++head->text_size;    
+       }
+
+       /* Append chars to the text */
+       strcpy(head->text_ptr + head->text_size, buf);
+
+       /* Advance the index */
+       head->text_size += strlen(buf);
+
+       /* Success */
+       return (TRUE);
+}
+
+
+/*
+ * Add a name to the name-storage and return an offset to it.
+ *
+ * Returns FALSE when there isn't enough space available to store
+ * the name.
+ */
+static bool add_name(u32b *offset, header *head, cptr buf)
+{
+       /* Hack -- Verify space */
+       if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
+               return (FALSE);
+
+       /* New name? */
+       if (*offset == 0)
+       {
+               /* Advance and save the name index */
+               *offset = ++head->name_size;
+       }
+
+       /* Append chars to the names */
+       strcpy(head->name_ptr + head->name_size, buf);
+
+       /* Advance the index */
+       head->name_size += strlen(buf);
+
+       /* Success */
+       return (TRUE);
+}
+
+
+/*
  * Convert a "color letter" into an "actual" color
  * The colors are: dwsorgbuDWvyRGBU, as shown below
  */
-static int color_char_to_attr(char c)
+byte color_char_to_attr(char c)
 {
        switch (c)
        {
@@ -677,7 +780,7 @@ static int color_char_to_attr(char c)
                case 'U': return (TERM_L_UMBER);
        }
 
-       return (-1);
+       return (255);
 }
 
 
@@ -689,7 +792,7 @@ static int color_char_to_attr(char c)
  * Initialize an "*_info" array, by parsing an ascii "template" file
  */
 errr init_info_txt(FILE *fp, char *buf, header *head,
-                   parse_info_txt_func parse_info_txt_line)
+                  parse_info_txt_func parse_info_txt_line)
 {
        errr err;
 
@@ -724,6 +827,17 @@ errr init_info_txt(FILE *fp, char *buf, header *head,
                        continue;
                }
 
+               /* Mega Hack -- Calculate Check Sum */
+               if (buf[0] != 'N' && buf[0] != 'D')
+               {
+                       int i;
+                       for (i = 0; buf[i]; i++)
+                       {
+                               head->v_extra += (byte)buf[i];
+                               head->v_extra ^= (1 << (i % 8));
+                       }
+               }
+
                /* Parse the line */
                if ((err = (*parse_info_txt_line)(buf, head)) != 0)
                        return (err);
@@ -780,17 +894,8 @@ errr parse_v_info(char *buf, header *head)
                /* Point at the "info" */
                v_ptr = &v_info[i];
 
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!v_ptr->name) v_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&v_ptr->name, head, s)) return (7);
        }
 
        /* There better be a current v_ptr */
@@ -802,18 +907,8 @@ errr parse_v_info(char *buf, header *head)
                /* Acquire the text */
                s = buf+2;
 
-               /* Hack -- Verify space */
-               if (head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!v_ptr->text) v_ptr->text = ++head->text_size;
-
-               /* Append chars to the name */
-               strcpy(head->text_ptr + head->text_size, s);
-
-               /* Advance the index */
-               head->text_size += strlen(s);
-
+               /* Store the text */
+               if (!add_text(&v_ptr->text, head, s)) return (7);
        }
 
        /* Process 'X' for "Extra info" (one line only) */
@@ -1000,7 +1095,7 @@ errr parse_m_info(char *buf, header *head)
 
                /* Scan for the values */
                if (4 != sscanf(s, "%x:%d:%d:%d",
-                               &xtra, &type, &first, &weight)) return (1);
+                               (uint *)&xtra, &type, &first, &weight)) return (1);
 
                m_ptr->spell_xtra = xtra;
                m_ptr->spell_type = type;
@@ -1090,17 +1185,8 @@ errr parse_f_info(char *buf, header *head)
                f_ptr = &f_info[i];
 
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!f_ptr->name) f_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&f_ptr->name, head, s)) return (7);
 #endif
                /* Default "mimic" */
                f_ptr->mimic = i;
@@ -1122,44 +1208,11 @@ errr parse_f_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!f_ptr->name) f_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&f_ptr->name, head, s)) return (7);
        }
 #endif
 
-#if 0
-
-       /* Process 'D' for "Description" */
-       else if (buf[0] == 'D')
-       {
-               /* Acquire the text */
-               s = buf+2;
-
-                       /* Hack -- Verify space */
-               if (f_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!f_ptr->text) f_ptr->text = ++f_head->text_size;
-
-               /* Append chars to the name */
-               strcpy(f_text + f_head->text_size, s);
-
-               /* Advance the index */
-               f_head->text_size += strlen(s);
-
-       }
-
-#endif
-
 
        /* Process 'M' for "Mimic" (one line only) */
        else if (buf[0] == 'M')
@@ -1179,7 +1232,7 @@ errr parse_f_info(char *buf, header *head)
        /* Process 'G' for "Graphics" (one line only) */
        else if (buf[0] == 'G')
        {
-               int tmp;
+               byte tmp;
 
                /* Paranoia */
                if (!buf[2]) return (1);
@@ -1190,7 +1243,7 @@ errr parse_f_info(char *buf, header *head)
                tmp = color_char_to_attr(buf[4]);
 
                /* Paranoia */
-               if (tmp < 0) return (1);
+               if (tmp > 127) return (1);
 
                /* Save the values */
                f_ptr->d_attr = tmp;
@@ -1213,32 +1266,22 @@ static errr grab_one_kind_flag(object_kind *k_ptr, cptr what)
 {
        int i;
 
-       /* Check flags1 */
-       for (i = 0; i < 32; i++)
-       {
-               if (streq(what, k_info_flags1[i]))
-               {
-                       k_ptr->flags1 |= (1L << i);
-                       return (0);
-               }
-       }
-
-       /* Check flags2 */
-       for (i = 0; i < 32; i++)
+       /* Check flags */
+       for (i = 0; i < TR_FLAG_MAX; i++)
        {
-               if (streq(what, k_info_flags2[i]))
+               if (streq(what, k_info_flags[i]))
                {
-                       k_ptr->flags2 |= (1L << i);
+                       add_flag(k_ptr->flags, i);
                        return (0);
                }
        }
 
-       /* Check flags3 */
+       /* Check gen_flags */
        for (i = 0; i < 32; i++)
        {
-               if (streq(what, k_info_flags3[i]))
+               if (streq(what, k_info_gen_flags[i]))
                {
-                       k_ptr->flags3 |= (1L << i);
+                       k_ptr->gen_flags |= (1L << i);
                        return (0);
                }
        }
@@ -1301,17 +1344,8 @@ errr parse_k_info(char *buf, header *head)
                k_ptr = &k_info[i];
 
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!k_ptr->name) k_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&k_ptr->name, head, s)) return (7);
 #endif
        }
 
@@ -1332,48 +1366,35 @@ errr parse_k_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!k_ptr->name) k_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&k_ptr->name, head, s)) return (7);
        }
 #endif
-#if 0
 
        /* Process 'D' for "Description" */
        else if (buf[0] == 'D')
        {
+#ifdef JP
+               if (buf[2] == '$')
+                       return (0);
                /* Acquire the text */
                s = buf+2;
-
-                       /* Hack -- Verify space */
-               if (k_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!k_ptr->text) k_ptr->text = ++k_head->text_size;
-
-               /* Append chars to the name */
-               strcpy(k_text + k_head->text_size, s);
-
-               /* Advance the index */
-               k_head->text_size += strlen(s);
-       }
-
+#else
+               if (buf[2] != '$')
+                       return (0);
+               /* Acquire the text */
+               s = buf+3;
 #endif
 
+               /* Store the text */
+               if (!add_text(&k_ptr->text, head, s)) return (7);
+       }
 
        /* Process 'G' for "Graphics" (one line only) */
        else if (buf[0] == 'G')
        {
                char sym;
-               int tmp;
+               byte tmp;
 
                /* Paranoia */
                if (!buf[2]) return (1);
@@ -1387,7 +1408,7 @@ errr parse_k_info(char *buf, header *head)
                tmp = color_char_to_attr(buf[4]);
 
                /* Paranoia */
-               if (tmp < 0) return (1);
+               if (tmp > 127) return (1);
 
                /* Save the values */
                k_ptr->d_attr = tmp;
@@ -1513,32 +1534,22 @@ static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what)
 {
        int i;
 
-       /* Check flags1 */
-       for (i = 0; i < 32; i++)
+       /* Check flags */
+       for (i = 0; i < TR_FLAG_MAX; i++)
        {
-               if (streq(what, k_info_flags1[i]))
+               if (streq(what, k_info_flags[i]))
                {
-                       a_ptr->flags1 |= (1L << i);
+                       add_flag(a_ptr->flags, i);
                        return (0);
                }
        }
 
-       /* Check flags2 */
+       /* Check gen_flags */
        for (i = 0; i < 32; i++)
        {
-               if (streq(what, k_info_flags2[i]))
+               if (streq(what, k_info_gen_flags[i]))
                {
-                       a_ptr->flags2 |= (1L << i);
-                       return (0);
-               }
-       }
-
-       /* Check flags3 */
-       for (i = 0; i < 32; i++)
-       {
-               if (streq(what, k_info_flags3[i]))
-               {
-                       a_ptr->flags3 |= (1L << i);
+                       a_ptr->gen_flags |= (1L << i);
                        return (0);
                }
        }
@@ -1602,22 +1613,13 @@ errr parse_a_info(char *buf, header *head)
                a_ptr = &a_info[i];
 
                /* Ignore everything */
-               a_ptr->flags3 |= (TR3_IGNORE_ACID);
-               a_ptr->flags3 |= (TR3_IGNORE_ELEC);
-               a_ptr->flags3 |= (TR3_IGNORE_FIRE);
-               a_ptr->flags3 |= (TR3_IGNORE_COLD);
+               add_flag(a_ptr->flags, TR_IGNORE_ACID);
+               add_flag(a_ptr->flags, TR_IGNORE_ELEC);
+               add_flag(a_ptr->flags, TR_IGNORE_FIRE);
+               add_flag(a_ptr->flags, TR_IGNORE_COLD);
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!a_ptr->name) a_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&a_ptr->name, head, s)) return (7);
 #endif
        }
 
@@ -1638,17 +1640,8 @@ errr parse_a_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!a_ptr->name) a_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&a_ptr->name, head, s)) return (7);
        }
 #endif
 
@@ -1667,17 +1660,8 @@ errr parse_a_info(char *buf, header *head)
                s = buf+3;
 #endif
 
-               /* Hack -- Verify space */
-               if (head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!a_ptr->text) a_ptr->text = ++head->text_size;
-
-               /* Append chars to the name */
-               strcpy(head->text_ptr + head->text_size, s);
-
-               /* Advance the index */
-               head->text_size += strlen(s);
+               /* Store the text */
+               if (!add_text(&a_ptr->text, head, s)) return (7);
        }
 
 
@@ -1771,37 +1755,27 @@ static bool grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what)
 {
        int i;
 
-       /* Check flags1 */
-       for (i = 0; i < 32; i++)
-       {
-               if (streq(what, k_info_flags1[i]))
-               {
-                       e_ptr->flags1 |= (1L << i);
-                       return (0);
-               }
-       }
-
-       /* Check flags2 */
-       for (i = 0; i < 32; i++)
+       /* Check flags */
+       for (i = 0; i < TR_FLAG_MAX; i++)
        {
-               if (streq(what, k_info_flags2[i]))
+               if (streq(what, k_info_flags[i]))
                {
-                       e_ptr->flags2 |= (1L << i);
+                       add_flag(e_ptr->flags, i);
                        return (0);
                }
        }
-
-       /* Check flags3 */
+       
+       /* Check gen_flags */
        for (i = 0; i < 32; i++)
        {
-               if (streq(what, k_info_flags3[i]))
+               if (streq(what, k_info_gen_flags[i]))
                {
-                       e_ptr->flags3 |= (1L << i);
+                       e_ptr->gen_flags |= (1L << i);
                        return (0);
                }
        }
 
-       /* Oops */
+/* Oops */
 #ifdef JP
        msg_format("̤ÃΤÎ̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¡¦¥Õ¥é¥° '%s'¡£", what);
 #else
@@ -1866,17 +1840,8 @@ errr parse_e_info(char *buf, header *head)
                /* Point at the "info" */
                e_ptr = &e_info[i];
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!e_ptr->name) e_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&e_ptr->name, head, s)) return (7);
 #endif
        }
 
@@ -1897,17 +1862,8 @@ errr parse_e_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!e_ptr->name) e_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&e_ptr->name, head, s)) return (7);
        }
 #endif
 #if 0
@@ -1918,17 +1874,8 @@ errr parse_e_info(char *buf, header *head)
                /* Acquire the text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (e_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!e_ptr->text) e_ptr->text = ++e_head->text_size;
-
-               /* Append chars to the name */
-               strcpy(e_text + e_head->text_size, s);
-
-               /* Advance the index */
-               e_head->text_size += strlen(s);
+               /* Store the text */
+               if (!add_text(&e_ptr->text, head, s)) return (7);
        }
 
 #endif
@@ -2186,17 +2133,8 @@ errr parse_r_info(char *buf, header *head)
                /* Point at the "info" */
                r_ptr = &r_info[i];
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!r_ptr->name) r_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&r_ptr->name, head, s)) return (7);
 #endif
        }
 
@@ -2212,17 +2150,8 @@ errr parse_r_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!r_ptr->E_name) r_ptr->E_name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&r_ptr->E_name, head, s)) return (7);
        }
 #else
        else if (buf[0] == 'E')
@@ -2230,17 +2159,8 @@ errr parse_r_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-                       /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!r_ptr->name) r_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&r_ptr->name, head, s)) return (7);
        }
 #endif
        /* Process 'D' for "Description" */
@@ -2258,24 +2178,15 @@ errr parse_r_info(char *buf, header *head)
                s = buf+3;
 #endif
 
-               /* Hack -- Verify space */
-               if (head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!r_ptr->text) r_ptr->text = ++head->text_size;
-
-               /* Append chars to the name */
-               strcpy(head->text_ptr + head->text_size, s);
-
-               /* Advance the index */
-               head->text_size += strlen(s);
+               /* Store the text */
+               if (!add_text(&r_ptr->text, head, s)) return (7);
        }
 
        /* Process 'G' for "Graphics" (one line only) */
        else if (buf[0] == 'G')
        {
                char sym;
-               int tmp;
+               byte tmp;
 
                /* Paranoia */
                if (!buf[2]) return (1);
@@ -2289,7 +2200,7 @@ errr parse_r_info(char *buf, header *head)
                tmp = color_char_to_attr(buf[4]);
 
                /* Paranoia */
-               if (tmp < 0) return (1);
+               if (tmp > 127) return (1);
 
                /* Save the values */
                r_ptr->d_char = sym;
@@ -2473,18 +2384,18 @@ static errr grab_one_dungeon_flag(dungeon_info_type *d_ptr, cptr what)
        /* Scan flags1 */
        for (i = 0; i < 32; i++)
        {
-                if (streq(what, d_info_flags1[i]))
+               if (streq(what, d_info_flags1[i]))
                {
-                        d_ptr->flags1 |= (1L << i);
+                       d_ptr->flags1 |= (1L << i);
                        return (0);
                }
        }
 
        /* Oops */
 #ifdef JP
-        msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
+       msg_format("̤ÃΤΥÀ¥ó¥¸¥ç¥ó¡¦¥Õ¥é¥° '%s'¡£", what);
 #else
-        msg_format("Unknown dungeon type flag '%s'.", what);
+       msg_format("Unknown dungeon type flag '%s'.", what);
 #endif
 
        /* Failure */
@@ -2501,9 +2412,9 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        /* Scan flags1 */
        for (i = 0; i < 32; i++)
        {
-                if (streq(what, r_info_flags1[i]))
+               if (streq(what, r_info_flags1[i]))
                {
-                        d_ptr->mflags1 |= (1L << i);
+                       d_ptr->mflags1 |= (1L << i);
                        return (0);
                }
        }
@@ -2513,7 +2424,7 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags2[i]))
                {
-                        d_ptr->mflags2 |= (1L << i);
+                       d_ptr->mflags2 |= (1L << i);
                        return (0);
                }
        }
@@ -2523,7 +2434,7 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags3[i]))
                {
-                        d_ptr->mflags3 |= (1L << i);
+                       d_ptr->mflags3 |= (1L << i);
                        return (0);
                }
        }
@@ -2531,9 +2442,9 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        /* Scan flags7 */
        for (i = 0; i < 32; i++)
        {
-                if (streq(what, r_info_flags7[i]))
+               if (streq(what, r_info_flags7[i]))
                {
-                        d_ptr->mflags7 |= (1L << i);
+                       d_ptr->mflags7 |= (1L << i);
                        return (0);
                }
        }
@@ -2543,7 +2454,7 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags8[i]))
                {
-                        d_ptr->mflags8 |= (1L << i);
+                       d_ptr->mflags8 |= (1L << i);
                        return (0);
                }
        }
@@ -2553,7 +2464,7 @@ static errr grab_one_basic_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags9[i]))
                {
-                        d_ptr->mflags9 |= (1L << i);
+                       d_ptr->mflags9 |= (1L << i);
                        return (0);
                }
        }
@@ -2581,7 +2492,7 @@ static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags4[i]))
                {
-                        d_ptr->mflags4 |= (1L << i);
+                       d_ptr->mflags4 |= (1L << i);
                        return (0);
                }
        }
@@ -2591,7 +2502,7 @@ static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags5[i]))
                {
-                        d_ptr->mflags5 |= (1L << i);
+                       d_ptr->mflags5 |= (1L << i);
                        return (0);
                }
        }
@@ -2601,7 +2512,7 @@ static errr grab_one_spell_monster_flag(dungeon_info_type *d_ptr, cptr what)
        {
                if (streq(what, r_info_flags6[i]))
                {
-                        d_ptr->mflags6 |= (1L << i);
+                       d_ptr->mflags6 |= (1L << i);
                        return (0);
                }
        }
@@ -2660,17 +2571,8 @@ errr parse_d_info(char *buf, header *head)
                /* Point at the "info" */
                d_ptr = &d_info[i];
 #ifdef JP
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!d_ptr->name) d_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&d_ptr->name, head, s)) return (7);
 #endif
        }
 
@@ -2682,17 +2584,8 @@ errr parse_d_info(char *buf, header *head)
                /* Acquire the Text */
                s = buf+2;
 
-               /* Hack -- Verify space */
-               if (head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
-               /* Advance and Save the name index */
-               if (!d_ptr->name) d_ptr->name = ++head->name_size;
-
-               /* Append chars to the name */
-               strcpy(head->name_ptr + head->name_size, s);
-
-               /* Advance the index */
-               head->name_size += strlen(s);
+               /* Store the name */
+               if (!add_name(&d_ptr->name, head, s)) return (7);
        }
 #endif
 
@@ -2711,17 +2604,8 @@ errr parse_d_info(char *buf, header *head)
                s = buf+3;
 #endif
 
-               /* Hack -- Verify space */
-               if (head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
-               /* Advance and Save the text index */
-               if (!d_ptr->text) d_ptr->text = ++head->text_size;
-
-               /* Append chars to the name */
-               strcpy(d_text + head->text_size, s);
-
-               /* Advance the index */
-               head->text_size += strlen(s);
+               /* Store the text */
+               if (!add_text(&d_ptr->text, head, s)) return (7);
        }
 
        /* Process 'W' for "More Info" (one line only) */
@@ -2772,7 +2656,7 @@ errr parse_d_info(char *buf, header *head)
 
                /* Scan for the values */
                if (7 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d",
-                                &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) return (1);
+                               &f1, &p1, &f2, &p2, &f3, &p3, &tunnel)) return (1);
 
                /* Save the values */
                d_ptr->floor1 = f1;
@@ -2815,17 +2699,17 @@ errr parse_d_info(char *buf, header *head)
                /* Parse every entry */
                for (s = buf + 2; *s; )
                {
-                               /* Find the end of this entry */
+                       /* Find the end of this entry */
                        for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
 
-                               /* Nuke and skip any dividers */
+                       /* Nuke and skip any dividers */
                        if (*t)
                        {
                                *t++ = '\0';
                                while (*t == ' ' || *t == '|') t++;
                        }
 
-                                /* XXX XXX XXX Hack -- Read Final Artifact */
+                       /* XXX XXX XXX Hack -- Read Final Artifact */
                        if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
                        {
                                /* Extract a "Final Artifact" */
@@ -2838,7 +2722,7 @@ errr parse_d_info(char *buf, header *head)
                                continue;
                        }
 
-                                /* XXX XXX XXX Hack -- Read Final Object */
+                       /* XXX XXX XXX Hack -- Read Final Object */
                        if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
                        {
                                /* Extract a "Final Artifact" */
@@ -2851,7 +2735,7 @@ errr parse_d_info(char *buf, header *head)
                                continue;
                        }
 
-                                /* XXX XXX XXX Hack -- Read Artifact Guardian */
+                       /* XXX XXX XXX Hack -- Read Artifact Guardian */
                        if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
                        {
                                /* Extract a "Artifact Guardian" */
@@ -2864,7 +2748,7 @@ errr parse_d_info(char *buf, header *head)
                                continue;
                        }
 
-                                /* XXX XXX XXX Hack -- Read Special Percentage */
+                       /* XXX XXX XXX Hack -- Read Special Percentage */
                        if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
                        {
                                /* Extract a "Special %" */
@@ -2877,10 +2761,10 @@ errr parse_d_info(char *buf, header *head)
                                continue;
                        }
 
-                               /* Parse this entry */
+                       /* Parse this entry */
                        if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
 
-                               /* Start the next entry */
+                       /* Start the next entry */
                        s = t;
                }
        }
@@ -2888,29 +2772,27 @@ errr parse_d_info(char *buf, header *head)
        /* Process 'M' for "Basic Flags" (multiple lines) */
        else if (buf[0] == 'M')
        {
-               byte r_char_number = 0, r_char;
-
                /* Parse every entry */
                for (s = buf + 2; *s; )
                {
-                               /* Find the end of this entry */
+                       /* Find the end of this entry */
                        for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
 
-                               /* Nuke and skip any dividers */
+                       /* Nuke and skip any dividers */
                        if (*t)
                        {
                                *t++ = '\0';
                                while (*t == ' ' || *t == '|') t++;
                        }
 
-                                /* XXX XXX XXX Hack -- Read monster symbols */
-                       if (1 == sscanf(s, "R_CHAR_%c", &r_char))
+                       /* Hack -- Read monster symbols */
+                       if (!strncmp(s, "R_CHAR_", 7))
                        {
-                               /* Limited to 5 races */
-                               if(r_char_number >= 5) continue;
+                               /* Skip "R_CHAR_" */
+                               s += 7;
 
-                               /* Extract a "frequency" */
-                               d_ptr->r_char[r_char_number++] = r_char;
+                               /* Read a string */
+                               strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
 
                                /* Start at next entry */
                                s = t;
@@ -2919,10 +2801,10 @@ errr parse_d_info(char *buf, header *head)
                                continue;
                        }
 
-                               /* Parse this entry */
+                       /* Parse this entry */
                        if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
 
-                               /* Start the next entry */
+                       /* Start the next entry */
                        s = t;
                }
        }
@@ -3120,6 +3002,10 @@ static errr parse_line_feature(char *buf)
                                                letter[index].monster = atoi(zz[3]);
                                        }
                                }
+                               else if (zz[3][0] == 'c')
+                               {
+                                       letter[index].monster = - atoi(zz[3]+1);
+                               }
                                else
                                {
                                        letter[index].monster = atoi(zz[3]);
@@ -3293,22 +3179,8 @@ static errr parse_line_building(char *buf)
 
                case 'Z':
                {
-#ifdef USE_SCRIPT
-                       if (tokenize(s+2, 2, zz, 0) == 2)
-                       {
-                               /* Index of the action */
-                               int action_index = atoi(zz[0]);
-
-                               /* Name of the action */
-                               strcpy(building[index].act_script[action_index], zz[1]);
-
-                               break;
-                       }
-                       return (1);
-#else /* USE_SCRIPT */
                        /* Ignore scripts */
                        break;
-#endif /* USE_SCRIPT */
                }
 
                default:
@@ -3396,12 +3268,23 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        {
                                monster_level = base_level + monster_index;
 
-                               place_monster(*y, *x, TRUE, TRUE);
+                               place_monster(*y, *x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
 
                                monster_level = base_level;
                        }
                        else if (monster_index)
                        {
+                               int old_cur_num, old_max_num;
+                               bool clone = FALSE;
+
+                               if (monster_index < 0)
+                               {
+                                       monster_index = -monster_index;
+                                       clone = TRUE;
+                               }
+                               old_cur_num = r_info[monster_index].cur_num;
+                               old_max_num = r_info[monster_index].max_num;
+
                                /* Make alive again */
                                if (r_info[monster_index].flags1 & RF1_UNIQUE)
                                {
@@ -3419,7 +3302,16 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                }
 
                                /* Place it */
-                               place_monster_aux(*y, *x, monster_index, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE);
+                               place_monster_aux(0, *y, *x, monster_index, (PM_ALLOW_SLEEP | PM_NO_KAGE));
+                               if (clone)
+                               {
+                                       /* clone */
+                                       m_list[hack_m_idx_ii].smart |= SM_CLONED;
+
+                                       /* Make alive again for real unique monster */
+                                       r_info[monster_index].cur_num = old_cur_num;
+                                       r_info[monster_index].max_num = old_max_num;
+                               }
                        }
 
                        /* Object (and possible trap) */
@@ -3431,7 +3323,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                 * Random trap and random treasure defined
                                 * 25% chance for trap and 75% chance for object
                                 */
-                               if (rand_int(100) < 75)
+                               if (randint0(100) < 75)
                                {
                                        place_object(*y, *x, FALSE, FALSE);
                                }
@@ -3447,9 +3339,9 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                object_level = base_level + object_index;
 
                                /* Create an out of deep object */
-                               if (rand_int(100) < 75)
+                               if (randint0(100) < 75)
                                        place_object(*y, *x, FALSE, FALSE);
-                               else if (rand_int(100) < 80)
+                               else if (randint0(100) < 80)
                                        place_object(*y, *x, TRUE, FALSE);
                                else
                                        place_object(*y, *x, TRUE, TRUE);
@@ -3461,6 +3353,12 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        {
                                place_trap(*y, *x);
                        }
+                       /* Hidden trap (or door) */
+                       else if (letter[idx].trap)
+                       {
+                               c_ptr->mimic = c_ptr->feat;
+                               c_ptr->feat = letter[idx].trap;
+                       }
                        else if (object_index)
                        {
                                /* Get local object */
@@ -3479,10 +3377,6 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                /* Apply magic (no messages, no artifacts) */
                                apply_magic(o_ptr, base_level, FALSE, TRUE, FALSE, FALSE);
 
-#ifdef USE_SCRIPT
-                               o_ptr->python = object_create_callback(o_ptr);
-#endif /* USE_SCRIPT */
-
                                (void)drop_near(o_ptr, -1, *y, *x);
                        }
 
@@ -3491,14 +3385,11 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                        {
                                if (a_info[artifact_index].cur_num)
                                {
-                                       s16b k_idx = 198;
+                                       int k_idx = 198;
                                        object_type forge;
                                        object_type *q_ptr = &forge;
 
                                        object_prep(q_ptr, k_idx);
-#ifdef USE_SCRIPT
-                                       q_ptr->python = object_create_callback(q_ptr);
-#endif /* USE_SCRIPT */
 
                                        /* Drop it in the dungeon */
                                        (void)drop_near(q_ptr, -1, *y, *x);
@@ -3569,7 +3460,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                        r_ptr->flags1 |= RF1_QUESTOR;
 
                                a_ptr = &a_info[q_ptr->k_idx];
-                               a_ptr->flags3 |= TR3_QUESTITEM;
+                               a_ptr->gen_flags |= TRG_QUESTITEM;
                        }
                        return (0);
                }
@@ -3622,17 +3513,9 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                if (*x % SCREEN_WID) panels_x++;
                                cur_wid = panels_x * SCREEN_WID;
 
-                               /* Choose a panel row */
-                               max_panel_rows = (cur_hgt / SCREEN_HGT) * 2 - 2;
-                               if (max_panel_rows < 0) max_panel_rows = 0;
-
-                               /* Choose a panel col */
-                               max_panel_cols = (cur_wid / SCREEN_WID) * 2 - 2;
-                               if (max_panel_cols < 0) max_panel_cols = 0;
-
                                /* Assume illegal panel */
-                               panel_row = max_panel_rows;
-                               panel_col = max_panel_cols;
+                               panel_row_min = cur_hgt;
+                               panel_col_min = cur_wid;
 
                                /* Place player in a quest level */
                                if (p_ptr->inside_quest)
@@ -3719,10 +3602,10 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in
                                max_e_idx = atoi(zz[1]);
                        }
 
-                        /* Maximum d_idx */
-                        else if (zz[0][0] == 'D')
+                       /* Maximum d_idx */
+                       else if (zz[0][0] == 'D')
                        {
-                                max_d_idx = atoi(zz[1]); 
+                               max_d_idx = atoi(zz[1]); 
                        }
 
                        /* Maximum o_idx */
@@ -3940,7 +3823,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        else if (streq(b+1, "RACE"))
                        {
 #ifdef JP
-                                v = rp_ptr->E_title;
+                               v = rp_ptr->E_title;
 #else
                                v = rp_ptr->title;
 #endif
@@ -3950,7 +3833,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        else if (streq(b+1, "CLASS"))
                        {
 #ifdef JP
-                                v = cp_ptr->E_title;
+                               v = cp_ptr->E_title;
 #else
                                v = cp_ptr->title;
 #endif
@@ -3962,7 +3845,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
 #ifdef JP
                                v = E_realm_names[p_ptr->realm1];
 #else
-                                v = realm_names[p_ptr->realm1];
+                               v = realm_names[p_ptr->realm1];
 #endif
                        }
 
@@ -3970,7 +3853,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
                        else if (streq(b+1, "REALM2"))
                        {
 #ifdef JP
-                                v = E_realm_names[p_ptr->realm2];
+                               v = E_realm_names[p_ptr->realm2];
 #else
                                v = realm_names[p_ptr->realm2];
 #endif
@@ -4079,7 +3962,7 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
 
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_EDIT, name);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
 
        /* Open the file */
        fp = my_fopen(buf, "r");
@@ -4089,7 +3972,7 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
 
 
        /* Process the file */
-       while (0 == my_fgets(fp, buf, 1024))
+       while (0 == my_fgets(fp, buf, sizeof(buf)))
        {
                /* Count lines */
                num++;
@@ -4128,18 +4011,6 @@ errr process_dungeon_file(cptr name, int ymin, int xmin, int ymax, int xmax)
                /* Apply conditionals */
                if (bypass) continue;
 
-
-               /* Process "%:<file>" */
-               if (buf[0] == '%')
-               {
-                       /* Process that file if allowed */
-                       (void)process_dungeon_file(buf + 2, ymin, xmin, ymax, xmax);
-
-                       /* Continue */
-                       continue;
-               }
-
-
                /* Process the line */
                err = process_dungeon_file_aux(buf, ymin, xmin, ymax, xmax, &y, &x);