"MIRROR",
"UNPERM",
"TELEPORTABLE",
-};
-
-
-/*
- * Special feature info tags
- */
-static cptr f_info_special_tags[] =
-{
- "*FLOOR*",
- "*WALL*",
- "*INNER*",
- "*OUTER*",
- "*SOLID*",
- "*STREAM1*",
- "*STREAM2*",
- NULL,
+ "CONVERT",
+ "GLASS",
};
"HIDE_TYPE",
"SHOW_MODS",
"XXX1",
- "FEATHER",
+ "LEVITATION",
"LITE",
"SEE_INVIS",
"TELEPATHY",
"ESP_NONLIVING",
"ESP_UNIQUE",
"FULL_NAME",
+ "FIXED_FLAVOR",
};
"NO_DOORS",
"WATER_RIVER",
"LAVA_RIVER",
- "XXX",
- "XXX",
+ "CURTAIN",
+ "GLASS_DOOR",
"CAVE",
"CAVERN",
"XXX",
"NO_VAULT",
"ARENA",
"DESTROY",
- "XXX",
+ "GLASS_ROOM",
"NO_CAVE",
"NO_MAGIC",
"NO_MELEE",
* Returns FALSE when there isn't enough space available to store
* the text.
*/
-static bool add_text(u32b *offset, header *head, cptr buf)
+static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
{
/* Hack -- Verify space */
if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
if (*offset == 0)
{
/* Advance and save the text index */
- *offset = ++head->text_size;
+ *offset = ++head->text_size;
+ }
+
+ /* Additional text */
+ else if (normal_text)
+ {
+ /*
+ * If neither the end of the last line nor
+ * the beginning of current line is not a space,
+ * fill up a space as a correct separator of two words.
+ */
+ if (head->text_size > 0 &&
+#ifdef JP
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
+ (buf[0] != ' ') && !iskanji(buf[0])
+#else
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ (buf[0] != ' ')
+#endif
+ )
+ {
+ /* Append a space */
+ *(head->text_ptr + head->text_size) = ' ';
+
+ /* Advance the index */
+ head->text_size++;
+ }
}
/* Append chars to the text */
/* Prepare the "fake" stuff */
head->name_size = 0;
head->text_size = 0;
- head->tag_size = 1;
+ head->tag_size = 0;
/* Parse */
while (0 == my_fgets(fp, buf, 1024))
s = buf+2;
/* Store the text */
- if (!add_text(&v_ptr->text, head, s)) return (7);
+ if (!add_text(&v_ptr->text, head, s, FALSE)) return (7);
}
/* Process 'X' for "Extra info" (one line only) */
else if (buf[0] == 'G')
{
int j;
- byte def_attr[F_LIT_MAX];
+ byte s_attr;
char char_tmp[F_LIT_MAX];
/* Paranoia */
char_tmp[F_LIT_STANDARD] = buf[2];
/* Extract the color */
- def_attr[F_LIT_STANDARD] = color_char_to_attr(buf[4]);
+ s_attr = color_char_to_attr(buf[4]);
/* Paranoia */
- if (def_attr[F_LIT_STANDARD] > 127) return (1);
+ if (s_attr > 127) return (1);
- /* Save the default values for lighting */
- for (j = 0; j < F_LIT_MAX; j++)
- {
- f_ptr->d_attr[j] = def_attr[F_LIT_STANDARD];
- f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
- }
+ /* Save the standard values */
+ f_ptr->d_attr[F_LIT_STANDARD] = s_attr;
+ f_ptr->d_char[F_LIT_STANDARD] = char_tmp[F_LIT_STANDARD];
/* Is this feature supports lighting? */
if (buf[5] == ':')
{
- def_attr[F_LIT_LITE] = lighting_colours[def_attr[F_LIT_STANDARD]][0];
- def_attr[F_LIT_DARK] = lighting_colours[def_attr[F_LIT_STANDARD]][1];
- def_attr[F_LIT_DARKDARK] = lighting_colours[lighting_colours[def_attr[F_LIT_STANDARD]][1]][1];
-
/* G:c:a:LIT (default) */
- if (streq(buf + 6, "LIT"))
- {
- for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
- {
- f_ptr->d_attr[j] = def_attr[j];
- }
- }
+ apply_default_feat_lighting(f_ptr->d_attr, f_ptr->d_char);
- /* G:c:a:lc:la:dc:da:Dc:Da */
- else
+ /* G:c:a:lc:la:dc:da */
+ if (!streq(buf + 6, "LIT"))
{
char attr_lite_tmp[F_LIT_MAX - F_LIT_NS_BEGIN];
- if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c:%c:%c",
+ if ((F_LIT_MAX - F_LIT_NS_BEGIN) * 2 != sscanf(buf + 6, "%c:%c:%c:%c",
&char_tmp[F_LIT_LITE], &attr_lite_tmp[F_LIT_LITE - F_LIT_NS_BEGIN],
- &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN],
- &char_tmp[F_LIT_DARKDARK], &attr_lite_tmp[F_LIT_DARKDARK - F_LIT_NS_BEGIN])) return 1;
+ &char_tmp[F_LIT_DARK], &attr_lite_tmp[F_LIT_DARK - F_LIT_NS_BEGIN])) return 1;
if (buf[F_LIT_MAX * 4 + 1]) return 1;
for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
{
case '*':
/* Use default lighting */
- f_ptr->d_attr[j] = def_attr[j];
break;
case '-':
/* No lighting support */
- f_ptr->d_attr[j] = def_attr[F_LIT_STANDARD];
+ f_ptr->d_attr[j] = f_ptr->d_attr[F_LIT_STANDARD];
break;
default:
/* Extract the color */
}
}
}
- else if (buf[5]) return 1;
+ else if (!buf[5])
+ {
+ for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
+ {
+ f_ptr->d_attr[j] = s_attr;
+ f_ptr->d_char[j] = char_tmp[F_LIT_STANDARD];
+ }
+ }
+ else return 1;
}
/* Hack -- Process 'F' for flags */
while (*t == ' ' || *t == '|') t++;
}
+ /* XXX XXX XXX Hack -- Read feature subtype */
+ if (1 == sscanf(s, "SUBTYPE_%d", &i))
+ {
+ /* Extract a "subtype" */
+ f_ptr->subtype = i;
+
+ /* Start at next entry */
+ s = t;
+
+ /* Continue */
+ continue;
+ }
+
/* XXX XXX XXX Hack -- Read feature power */
if (1 == sscanf(s, "POWER_%d", &i))
{
}
}
- /* Search for special index corresponding to this fake tag */
- for (i = 0; f_info_special_tags[i]; i++)
- {
- if (streq(f_info_special_tags[i], str))
- {
- /* Return the special index */
- return (s16b)(FEAT_DUNGEON_FLOOR - i);
- }
- }
-
/* Not found */
- return 0;
+ return -1;
}
}
}
- /* Search for special index corresponding to this fake tag */
- for (i = 0; f_info_special_tags[i]; i++)
- {
- if (streq(f_info_special_tags[i], f_tag + (-(*feat))))
- {
- /* Record special index */
- *feat = (s16b)(FEAT_DUNGEON_FLOOR - i);
- return;
- }
- }
-
/* Undefined tag */
#ifdef JP
msg_format("̤ÄêµÁ¤Î¥¿¥° '%s'¡£", f_tag + (-(*feat)));
/* Process 'N' for "New/Number/Name" */
if (buf[0] == 'N')
{
+#ifdef JP
+ char *flavor;
+#endif
+
/* Find the colon before the name */
s = my_strchr(buf+2, ':');
- /* Verify that colon */
+ /* Verify that colon */
if (!s) return (1);
/* Nuke the colon, advance to the name */
*s++ = '\0';
-#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
-#endif
/* Get the index */
i = atoi(buf+2);
k_ptr = &k_info[i];
#ifdef JP
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
+
+ /* Find the colon before the flavor */
+ flavor = my_strchr(s, ':');
+
+ /* Verify that colon */
+ if (flavor)
+ {
+ /* Nuke the colon, advance to the flavor */
+ *flavor++ = '\0';
+
+ /* Store the flavor */
+ if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
+ }
+
/* Store the name */
if (!add_name(&k_ptr->name, head, s)) return (7);
#endif
#else
else if (buf[0] == 'E')
{
- /* Acquire the Text */
+ char *flavor;
+
+ /* Acquire the name */
s = buf+2;
+ /* Find the colon before the flavor */
+ flavor = my_strchr(s, ':');
+
+ /* Verify that colon */
+ if (flavor)
+ {
+ /* Nuke the colon, advance to the flavor */
+ *flavor++ = '\0';
+
+ /* Store the flavor */
+ if (!add_name(&k_ptr->flavor_name, head, flavor)) return (7);
+ }
+
/* Store the name */
if (!add_name(&k_ptr->name, head, s)) return (7);
}
#endif
/* Store the text */
- if (!add_text(&k_ptr->text, head, s)) return (7);
+ if (!add_text(&k_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'G' for "Graphics" (one line only) */
#endif
/* Store the text */
- if (!add_text(&a_ptr->text, head, s)) return (7);
+ if (!add_text(&a_ptr->text, head, s, TRUE)) return (7);
}
s = buf+2;
/* Store the text */
- if (!add_text(&e_ptr->text, head, s)) return (7);
+ if (!add_text(&e_ptr->text, head, s, TRUE)) return (7);
}
#endif
#endif
/* Store the text */
- if (!add_text(&r_ptr->text, head, s)) return (7);
+ if (!add_text(&r_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'G' for "Graphics" (one line only) */
/* Save the values */
r_ptr->speed = spd;
- r_ptr->hdice = hp1;
- r_ptr->hside = hp2;
+ r_ptr->hdice = MAX(hp1, 1);
+ r_ptr->hside = MAX(hp2, 1);
r_ptr->aaf = aaf;
r_ptr->ac = ac;
r_ptr->sleep = slp;
#endif
/* Store the text */
- if (!add_text(&d_ptr->text, head, s)) return (7);
+ if (!add_text(&d_ptr->text, head, s, TRUE)) return (7);
}
/* Process 'W' for "More Info" (one line only) */
for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
{
d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
+ if (d_ptr->floor[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
d_ptr->floor[i].percent = atoi(zz[i * 2 + 1]);
}
d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
for (i = 0; i < DUNGEON_FEAT_PROB_NUM; i++)
{
d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
+ if (d_ptr->fill[i].feat < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
d_ptr->fill[i].percent = atoi(zz[i * 2 + 1]);
}
+
d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
+ if (d_ptr->outer_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
+ if (d_ptr->inner_wall < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
+ if (d_ptr->stream1 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
+
d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
+ if (d_ptr->stream2 < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
/* Process 'F' for "Dungeon Flags" (multiple lines) */
/* Random dungeon grid effects */
-#define RANDOM_NONE 0x00
-#define RANDOM_FEATURE 0x01
-#define RANDOM_MONSTER 0x02
-#define RANDOM_OBJECT 0x04
-#define RANDOM_EGO 0x08
-#define RANDOM_ARTIFACT 0x10
-#define RANDOM_TRAP 0x20
+#define RANDOM_NONE 0x00000000
+#define RANDOM_FEATURE 0x00000001
+#define RANDOM_MONSTER 0x00000002
+#define RANDOM_OBJECT 0x00000004
+#define RANDOM_EGO 0x00000008
+#define RANDOM_ARTIFACT 0x00000010
+#define RANDOM_TRAP 0x00000020
typedef struct dungeon_grid dungeon_grid;
int index = zz[0][0];
/* Reset the info for the letter */
- letter[index].feature = 0;
+ letter[index].feature = feat_none;
letter[index].monster = 0;
letter[index].object = 0;
letter[index].ego = 0;
letter[index].artifact = 0;
- letter[index].trap = 0;
+ letter[index].trap = feat_none;
letter[index].cave_info = 0;
letter[index].special = 0;
- letter[index].random = 0;
+ letter[index].random = RANDOM_NONE;
switch (num)
{
/* Fall through */
/* Trap */
case 8:
- if (zz[7][0] == '*')
+ if ((zz[7][0] == '*') && !zz[7][1])
{
letter[index].random |= RANDOM_TRAP;
-
- if (zz[7][1])
- {
- zz[7]++;
- letter[index].trap = atoi(zz[7]);
- }
}
else
{
- letter[index].trap = atoi(zz[7]);
+ letter[index].trap = f_tag_to_index(zz[7]);
+ if (letter[index].trap < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
/* Fall through */
/* Artifact */
if (zz[6][0] == '*')
{
letter[index].random |= RANDOM_ARTIFACT;
-
- if (zz[6][1])
- {
- zz[6]++;
- letter[index].artifact = atoi(zz[6]);
- }
+ if (zz[6][1]) letter[index].artifact = atoi(zz[6] + 1);
}
else
{
if (zz[5][0] == '*')
{
letter[index].random |= RANDOM_EGO;
-
- if (zz[5][1])
- {
- zz[5]++;
- letter[index].ego = atoi(zz[5]);
- }
+ if (zz[5][1]) letter[index].ego = atoi(zz[5] + 1);
}
else
{
if (zz[4][0] == '*')
{
letter[index].random |= RANDOM_OBJECT;
-
- if (zz[4][1])
- {
- zz[4]++;
- letter[index].object = atoi(zz[4]);
- }
+ if (zz[4][1]) letter[index].object = atoi(zz[4] + 1);
}
else
{
if (zz[3][0] == '*')
{
letter[index].random |= RANDOM_MONSTER;
- if (zz[3][1])
- {
- zz[3]++;
- letter[index].monster = atoi(zz[3]);
- }
+ if (zz[3][1]) letter[index].monster = atoi(zz[3] + 1);
}
else if (zz[3][0] == 'c')
{
- letter[index].monster = - atoi(zz[3]+1);
+ if (!zz[3][1]) return PARSE_ERROR_GENERIC;
+ letter[index].monster = - atoi(zz[3] + 1);
}
else
{
/* Fall through */
/* Feature */
case 2:
- if (zz[1][0] == '*')
+ if ((zz[1][0] == '*') && !zz[1][1])
{
letter[index].random |= RANDOM_FEATURE;
- if (zz[1][1])
- {
- zz[1]++;
- letter[index].feature = atoi(zz[1]);
- }
}
else
{
- letter[index].feature = atoi(zz[1]);
+ letter[index].feature = f_tag_to_index(zz[1]);
+ if (letter[index].feature < 0) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
}
break;
}
/*
- * Process "F:<letter>:<terrain>:<cave_info>:<monster>:<object>:<ego>:<artifact>:<trap>:<special>" -- info for dungeon grid
+ * Process "B:<Index>:<Command>:..." -- Building definition
*/
static errr parse_line_building(char *buf)
{
}
-static void drop_here(object_type *j_ptr, int by, int bx)
+/*
+ * Place the object j_ptr to a grid
+ */
+static void drop_here(object_type *j_ptr, int y, int x)
{
- int i, k, d, s;
-
- s16b o_idx = 0;
-
- s16b this_o_idx, next_o_idx = 0;
-
- bool done = FALSE;
-
- cave_type *c_ptr = &cave[by][bx];
-
- /* Scan objects in that grid for combination */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
- {
- object_type *o_ptr;
-
- /* Acquire object */
- o_ptr = &o_list[this_o_idx];
-
- /* Acquire next object */
- next_o_idx = o_ptr->next_o_idx;
-
- /* Check for combination */
- if (object_similar(o_ptr, j_ptr))
- {
- /* Combine the items */
- object_absorb(o_ptr, j_ptr);
-
- /* Success */
- done = TRUE;
-
- /* Done */
- break;
- }
- }
+ cave_type *c_ptr = &cave[y][x];
+ object_type *o_ptr;
/* Get new object */
- if (!done) o_idx = o_pop();
-
+ s16b o_idx = o_pop();
- /* Stack */
- if (!done)
- {
- /* Structure copy */
- object_copy(&o_list[o_idx], j_ptr);
-
- /* Access new object */
- j_ptr = &o_list[o_idx];
+ /* Access new object */
+ o_ptr = &o_list[o_idx];
- /* Locate */
- j_ptr->iy = by;
- j_ptr->ix = bx;
+ /* Structure copy */
+ object_copy(o_ptr, j_ptr);
- /* No monster */
- j_ptr->held_m_idx = 0;
- /* Build a stack */
- j_ptr->next_o_idx = c_ptr->o_idx;
+ /* Locate */
+ o_ptr->iy = y;
+ o_ptr->ix = x;
- /* Place the object */
- c_ptr->o_idx = o_idx;
+ /* No monster */
+ o_ptr->held_m_idx = 0;
- /* Success */
- done = TRUE;
- }
+ /* Build a stack */
+ o_ptr->next_o_idx = c_ptr->o_idx;
- /* Result */
- return;
+ /* Place the object */
+ c_ptr->o_idx = o_idx;
}
+
/*
* Parse a sub-file of the "extra info"
*/
int artifact_index = letter[idx].artifact;
/* Lay down a floor */
- c_ptr->feat = letter[idx].feature;
+ c_ptr->feat = conv_dungeon_feat(letter[idx].feature);
/* Only the features */
if (init_flags & INIT_ONLY_FEATURES) continue;
else if (letter[idx].trap)
{
c_ptr->mimic = c_ptr->feat;
- c_ptr->feat = letter[idx].trap;
+ c_ptr->feat = conv_dungeon_feat(letter[idx].trap);
}
else if (object_index)
{
else
{
/* Create the artifact */
- create_named_art(artifact_index, *y, *x);
-
- a_info[artifact_index].cur_num = 1;
+ if (create_named_art(artifact_index, *y, *x))
+ a_info[artifact_index].cur_num = 1;
}
}
else
{
/* Accept all printables except spaces and brackets */
+#ifdef JP
+ while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
+ {
+ if (iskanji(*s)) s++;
+ s++;
+ }
+#else
while (isprint(*s) && !my_strchr(" []", *s)) ++s;
+#endif
/* Extract final and Terminate */
if ((f = *s) != '\0') *s++ = '\0';
/* Player name */
else if (streq(b+1, "PLAYER"))
{
- v = player_base;
+ static char tmp_player_name[32];
+ char *pn, *tpn;
+ for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
+ {
+#ifdef JP
+ if (iskanji(*pn))
+ {
+ *(tpn++) = *(pn++);
+ *tpn = *pn;
+ continue;
+ }
+#endif
+ *tpn = my_strchr(" []", *pn) ? '_' : *pn;
+ }
+ *tpn = '\0';
+ v = tmp_player_name;
}
/* Town */