#ifdef JP
#undef strchr
-char* _strchr(unsigned char* ptr, unsigned 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
* of the platforms that we currently support.
*/
-
#ifdef ALLOW_TEMPLATES
+#include "init.h"
+
/*** Helper arrays for parsing ascii template files ***/
"INSULT",
"MOAN",
"SHOW",
+ "SHOOT",
NULL
};
"FORCE_MAXHP",
"FORCE_SLEEP",
"FORCE_EXTRA",
- "FRIEND",
+ "XXX1",
"FRIENDS",
"ESCORT",
"ESCORTS",
"DROP_4D2",
"DROP_GOOD",
"DROP_GREAT",
- "DROP_USEFUL",
- "DROP_CHOSEN"
+ "XXX2",
+ "XXX3"
};
/*
"BRAIN_4",
"BRAIN_5",
"BRAIN_6",
- "BRAIN_7",
+ "HUMAN",
"QUANTUM"
};
"XXX1",
"DISPEL",
"ROCKET",
- "ARROW_1",
- "ARROW_2",
- "ARROW_3",
- "ARROW_4",
+ "SHOOT",
+ "XXX2",
+ "XXX3",
+ "XXX4",
"BR_ACID",
"BR_ELEC",
"BR_FIRE",
"GUARDIAN",
"CHAMELEON",
"KILL_EXP",
- "XXX7X15",
+ "TANUKI",
"XXX7X16",
"XXX7X17",
"XXX7X18",
"XXX8X28",
"XXX8X29",
"WILD_SWAMP", /* ToDo: Implement Swamp */
- "WILD_TOO",
+ "WILD_ALL",
};
/*
* Object flags
*/
-static cptr k_info_flags1[] =
+static cptr k_info_flags[] =
{
"STR",
"INT",
"CON",
"CHR",
"MAGIC_MASTERY",
- "FORCE_WEPON",
+ "FORCE_WEAPON",
"STEALTH",
"SEARCH",
"INFRA",
"BRAND_ACID",
"BRAND_ELEC",
"BRAND_FIRE",
- "BRAND_COLD"
-};
+ "BRAND_COLD",
-/*
- * Object flags
- */
-static cptr k_info_flags2[] =
-{
"SUST_STR",
"SUST_INT",
"SUST_WIS",
"SUST_CON",
"SUST_CHR",
"RIDING",
- "XXX2",
+ "EASY_SPELL",
"IM_ACID",
"IM_ELEC",
"IM_FIRE",
"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",
"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",
};
*/
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)
{
case 'U': return (TERM_L_UMBER);
}
- return (-1);
+ return (255);
}
/*
- * Initialize the "v_info" array, by parsing an ascii "template" file
+ * Initialize an "*_info" array, by parsing an ascii "template" file
*/
-errr init_v_info_txt(FILE *fp, char *buf, bool start)
+errr init_info_txt(FILE *fp, char *buf, header *head,
+ parse_info_txt_func parse_info_txt_line)
{
- int i;
- char *s;
+ errr err;
- /* Current entry */
- vault_type *v_ptr = NULL;
+ /* Just before the first record */
+ error_idx = -1;
- if (start)
- {
- /* Just before the first record */
- error_idx = -1;
+ /* Just before the first line */
+ error_line = 0;
- /* Just before the first line */
- error_line = -1;
- /* Prepare the "fake" stuff */
- v_head->name_size = 0;
- v_head->text_size = 0;
- }
+ /* Prepare the "fake" stuff */
+ head->name_size = 0;
+ head->text_size = 0;
/* Parse */
while (0 == my_fgets(fp, buf, 1024))
/* Skip comments and blank lines */
if (!buf[0] || (buf[0] == '#')) continue;
- if ((buf[0] == 'Q') || (buf[0] == 'T')) continue;
/* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
+ if (buf[1] != ':') return (PARSE_ERROR_GENERIC);
/* Hack -- Process 'V' for "Version" */
continue;
}
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
+ /* Mega Hack -- Calculate Check Sum */
+ if (buf[0] != 'N' && buf[0] != 'D')
{
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ int i;
+ for (i = 0; buf[i]; i++)
+ {
+ head->v_extra += (byte)buf[i];
+ head->v_extra ^= (1 << (i % 8));
+ }
+ }
- /* Verify that colon */
- if (!s) return (1);
+ /* Parse the line */
+ if ((err = (*parse_info_txt_line)(buf, head)) != 0)
+ return (err);
+ }
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Complete the "name" and "text" sizes */
+ if (head->name_size) head->name_size++;
+ if (head->text_size) head->text_size++;
- /* Get the index */
- i = atoi(buf+2);
+ /* Success */
+ return (0);
+}
- /* Verify information */
- if (i <= error_idx) return (4);
- /* Verify information */
- if (i >= v_head->info_num) return (2);
+/*
+ * Initialize the "v_info" array, by parsing an ascii "template" file
+ */
+errr parse_v_info(char *buf, header *head)
+{
+ int i;
+ char *s;
+
+ /* Current entry */
+ static vault_type *v_ptr = NULL;
- /* Save the index */
- error_idx = i;
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
+ {
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
- /* Point at the "info" */
- v_ptr = &v_info[i];
+ /* Verify that colon */
+ if (!s) return (1);
- /* Hack -- Verify space */
- if (v_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
- /* Advance and Save the name index */
- if (!v_ptr->name) v_ptr->name = ++v_head->name_size;
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
- /* Append chars to the name */
- strcpy(v_name + v_head->name_size, s);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Advance the index */
- v_head->name_size += strlen(s);
+ /* Verify information */
+ if (i <= error_idx) return (4);
- /* Next... */
- continue;
- }
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* There better be a current v_ptr */
- if (!v_ptr) return (3);
+ /* Save the index */
+ error_idx = i;
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
- /* Acquire the text */
- s = buf+2;
+ /* Point at the "info" */
+ v_ptr = &v_info[i];
+
+ /* Store the name */
+ if (!add_name(&v_ptr->name, head, s)) return (7);
+ }
- /* Hack -- Verify space */
- if (v_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
+ /* There better be a current v_ptr */
+ else if (!v_ptr) return (3);
- /* Advance and Save the text index */
- if (!v_ptr->text) v_ptr->text = ++v_head->text_size;
+ /* Process 'D' for "Description" */
+ else if (buf[0] == 'D')
+ {
+ /* Acquire the text */
+ s = buf+2;
- /* Append chars to the name */
- strcpy(v_text + v_head->text_size, s);
+ /* Store the text */
+ if (!add_text(&v_ptr->text, head, s)) return (7);
+ }
- /* Advance the index */
- v_head->text_size += strlen(s);
+ /* Process 'X' for "Extra info" (one line only) */
+ else if (buf[0] == 'X')
+ {
+ int typ, rat, hgt, wid;
- /* Next... */
- continue;
- }
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%d",
+ &typ, &rat, &hgt, &wid)) return (1);
+ /* Save the values */
+ v_ptr->typ = typ;
+ v_ptr->rat = rat;
+ v_ptr->hgt = hgt;
+ v_ptr->wid = wid;
+ }
- /* Process 'X' for "Extra info" (one line only) */
- if (buf[0] == 'X')
- {
- int typ, rat, hgt, wid;
+ /* Oops */
+ else return (6);
+
+ /* Success */
+ return (0);
+}
- /* Scan for the values */
- if (4 != sscanf(buf+2, "%d:%d:%d:%d",
- &typ, &rat, &hgt, &wid)) return (1);
- /* Save the values */
- v_ptr->typ = typ;
- v_ptr->rat = rat;
- v_ptr->hgt = hgt;
- v_ptr->wid = wid;
- /* Next... */
- continue;
- }
+/*
+ * Initialize the "s_info" array, by parsing an ascii "template" file
+ */
+errr parse_s_info(char *buf, header *head)
+{
+ int i;
+
+ /* Current entry */
+ static skill_table *s_ptr = NULL;
- /* Oops */
- return (6);
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
+ {
+ /* Get the index */
+ i = atoi(buf+2);
+
+ /* Verify information */
+ if (i <= error_idx) return (4);
+
+ /* Verify information */
+ if (i >= head->info_num) return (2);
+
+ /* Save the index */
+ error_idx = i;
+
+ /* Point at the "info" */
+ s_ptr = &s_info[i];
}
+ /* There better be a current s_ptr */
+ else if (!s_ptr) return (3);
- /* Complete the "name" and "text" sizes */
- if (!start)
+ /* Process 'W' for "Weapon exp" */
+ else if (buf[0] == 'W')
+ {
+ int tval, sval, start, max;
+ const s16b exp_conv_table[] = { 0, 4000, 6000, 7000, 8000 };
+
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%d",
+ &tval, &sval, &start, &max)) return (1);
+
+ if (start < 0 || start > 4 || max < 0 || max > 4) return (8);
+
+ /* Save the values */
+ s_ptr->w_start[tval][sval] = exp_conv_table[start];
+ s_ptr->w_max[tval][sval] = exp_conv_table[max];
+ }
+
+ /* Process 'S' for "Skill exp" */
+ else if (buf[0] == 'S')
{
- ++v_head->name_size;
- ++v_head->text_size;
+ int num, start, max;
+
+ /* Scan for the values */
+ if (3 != sscanf(buf+2, "%d:%d:%d",
+ &num, &start, &max)) return (1);
+
+ if (start < 0 || start > 8000 || max < 0 || max > 8000) return (8);
+
+ /* Save the values */
+ s_ptr->s_start[num] = start;
+ s_ptr->s_max[num] = max;
}
+ /* Oops */
+ else return (6);
+
/* Success */
return (0);
}
-
/*
- * Initialize the "f_info" array, by parsing an ascii "template" file
+ * Initialize the "m_info" array, by parsing an ascii "template" file
*/
-errr init_f_info_txt(FILE *fp, char *buf)
+errr parse_m_info(char *buf, header *head)
{
int i;
char *s;
/* Current entry */
- feature_type *f_ptr = NULL;
+ static player_magic *m_ptr = NULL;
+ /* ---Hack--- */
+ static int realm, magic_idx = 0, readable = 0;
- /* Just before the first record */
- error_idx = -1;
- /* Just before the first line */
- error_line = -1;
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
+ {
+ /* Get the index */
+ i = atoi(buf+2);
+ /* Verify information */
+ if (i <= error_idx) return (4);
- /* Prepare the "fake" stuff */
- f_head->name_size = 0;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- f_head->E_name_size = 0;
-#endif
- f_head->text_size = 0;
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
- {
- /* Advance the line number */
- error_line++;
+ /* Save the index */
+ error_idx = i;
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
+ /* Point at the "info" */
+ m_ptr = &m_info[i];
+ }
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
+ /* There better be a current m_ptr */
+ else if (!m_ptr) return (3);
+ /* Process 'I' for "Info" (one line only) */
+ else if (buf[0] == 'I')
+ {
+ char *book, *stat;
+ int xtra, type, first, weight;
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
+ /* Verify that colon */
+ if (!s) return (1);
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
- /* Verify that colon */
- if (!s) return (1);
+ book = buf+2;
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ if (streq(book, "SORCERY")) m_ptr->spell_book = TV_SORCERY_BOOK;
+ else if (streq(book, "LIFE")) m_ptr->spell_book = TV_LIFE_BOOK;
+ else if (streq(book, "MUSIC")) m_ptr->spell_book = TV_MUSIC_BOOK;
+ else if (streq(book, "HISSATSU")) m_ptr->spell_book = TV_HISSATSU_BOOK;
+ else if (streq(book, "NONE")) m_ptr->spell_book = 0;
+ else return (5);
-#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
-#endif
+ stat = s;
- /* Get the index */
- i = atoi(buf+2);
+ /* Find the colon before the name */
+ s = strchr(s, ':');
- /* Verify information */
- if (i <= error_idx) return (4);
+ /* Verify that colon */
+ if (!s) return (1);
- /* Verify information */
- if (i >= f_head->info_num) return (2);
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
- /* Save the index */
- error_idx = i;
+ if (streq(stat, "STR")) m_ptr->spell_stat = A_STR;
+ else if (streq(stat, "INT")) m_ptr->spell_stat = A_INT;
+ else if (streq(stat, "WIS")) m_ptr->spell_stat = A_WIS;
+ else if (streq(stat, "DEX")) m_ptr->spell_stat = A_DEX;
+ else if (streq(stat, "CON")) m_ptr->spell_stat = A_CON;
+ else if (streq(stat, "CHR")) m_ptr->spell_stat = A_CHR;
+ else return (5);
- /* Point at the "info" */
- f_ptr = &f_info[i];
-#ifdef JP
- /* Hack -- Verify space */
- if (f_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
+ /* Scan for the values */
+ if (4 != sscanf(s, "%x:%d:%d:%d",
+ (uint *)&xtra, &type, &first, &weight)) return (1);
- /* Advance and Save the name index */
- if (!f_ptr->name) f_ptr->name = ++f_head->name_size;
+ m_ptr->spell_xtra = xtra;
+ m_ptr->spell_type = type;
+ m_ptr->spell_first = first;
+ m_ptr->spell_weight = weight;
+ }
- /* Append chars to the name */
- strcpy(f_name + f_head->name_size, s);
- /* Advance the index */
- f_head->name_size += strlen(s);
-#endif
- /* Default "mimic" */
- f_ptr->mimic = i;
+ /* Process 'R' for "Realm" (one line only) */
+ else if (buf[0] == 'R')
+ {
+ /* Scan for the values */
+ if (2 != sscanf(buf+2, "%d:%d",
+ &realm, &readable)) return (1);
- /* Next... */
- continue;
- }
+ magic_idx = 0;
+ }
- /* There better be a current f_ptr */
- if (!f_ptr) return (3);
+ else if (buf[0] == 'T')
+ {
+ int level, mana, fail, exp;
+
+ if (!readable) return (1);
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%d",
+ &level, &mana, &fail, &exp)) return (1);
+
+ m_ptr->info[realm][magic_idx].slevel = level;
+ m_ptr->info[realm][magic_idx].smana = mana;
+ m_ptr->info[realm][magic_idx].sfail = fail;
+ m_ptr->info[realm][magic_idx].sexp = exp;
+ magic_idx ++;
+ }
-#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
- /* Hack -- Verify space */
- if (f_head->E_name_size + strlen(s) + 8 > E_fake_name_size) return (7);
+ /* Oops */
+ else return (6);
+
+ /* Success */
+ return (0);
+}
- /* Advance and Save the name index */
- if (!f_ptr->E_name) f_ptr->E_name = ++f_head->E_name_size;
- /* Append chars to the name */
- strcpy(E_f_name+ f_head->E_name_size, s);
+/*
+ * Initialize the "f_info" array, by parsing an ascii "template" file
+ */
+errr parse_f_info(char *buf, header *head)
+{
+ int i;
- /* Advance the index */
- f_head->E_name_size += strlen(s);
+ char *s;
- /* Next... */
- continue;
- }
-#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
+ /* Current entry */
+ static feature_type *f_ptr = NULL;
- /* Hack -- Verify space */
- if (f_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
- /* Advance and Save the name index */
- if (!f_ptr->name) f_ptr->name = ++f_head->name_size;
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
+ {
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
- /* Append chars to the name */
- strcpy(f_name+ f_head->name_size, s);
+ /* Verify that colon */
+ if (!s) return (1);
- /* Advance the index */
- f_head->name_size += strlen(s);
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
- /* Next... */
- continue;
- }
+#ifdef JP
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
-#if 0
+ /* Get the index */
+ i = atoi(buf+2);
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
- /* Acquire the text */
- s = buf+2;
+ /* Verify information */
+ if (i <= error_idx) return (4);
- /* Hack -- Verify space */
- if (f_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Advance and Save the text index */
- if (!f_ptr->text) f_ptr->text = ++f_head->text_size;
+ /* Save the index */
+ error_idx = i;
- /* Append chars to the name */
- strcpy(f_text + f_head->text_size, s);
+ /* Point at the "info" */
+ f_ptr = &f_info[i];
- /* Advance the index */
- f_head->text_size += strlen(s);
+#ifdef JP
+ /* Store the name */
+ if (!add_name(&f_ptr->name, head, s)) return (7);
+#endif
+ /* Default "mimic" */
+ f_ptr->mimic = i;
+ }
- /* Next... */
- continue;
- }
+ /* There better be a current f_ptr */
+ else if (!f_ptr) return (3);
+
+#ifdef JP
+ /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
+ /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ else if (buf[0] == 'E')
+ {
+ /* nothing to do */
+ }
+#else
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
+ /* Store the name */
+ if (!add_name(&f_ptr->name, head, s)) return (7);
+ }
#endif
- /* Process 'M' for "Mimic" (one line only) */
- if (buf[0] == 'M')
- {
- int mimic;
+ /* Process 'M' for "Mimic" (one line only) */
+ else if (buf[0] == 'M')
+ {
+ int mimic;
- /* Scan for the values */
- if (1 != sscanf(buf+2, "%d",
+ /* Scan for the values */
+ if (1 != sscanf(buf+2, "%d",
&mimic)) return (1);
- /* Save the values */
- f_ptr->mimic = mimic;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ f_ptr->mimic = mimic;
+ }
- /* Process 'G' for "Graphics" (one line only) */
- if (buf[0] == 'G')
- {
- int tmp;
-
- /* Paranoia */
- if (!buf[2]) return (1);
- if (!buf[3]) return (1);
- if (!buf[4]) return (1);
- /* Extract the color */
- tmp = color_char_to_attr(buf[4]);
+ /* Process 'G' for "Graphics" (one line only) */
+ else if (buf[0] == 'G')
+ {
+ byte tmp;
- /* Paranoia */
- if (tmp < 0) return (1);
+ /* Paranoia */
+ if (!buf[2]) return (1);
+ if (!buf[3]) return (1);
+ if (!buf[4]) return (1);
- /* Save the values */
- f_ptr->d_attr = tmp;
- f_ptr->d_char = buf[2];
+ /* Extract the color */
+ tmp = color_char_to_attr(buf[4]);
- /* Next... */
- continue;
- }
+ /* Paranoia */
+ if (tmp > 127) return (1);
+ /* Save the values */
+ f_ptr->d_attr = tmp;
+ f_ptr->d_char = buf[2];
- /* Oops */
- return (6);
}
-
- /* Complete the "name" and "text" sizes */
- ++f_head->name_size;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- ++f_head->E_name_size;
-#endif
- ++f_head->text_size;
-
+ /* Oops */
+ else return (6);
/* Success */
return (0);
{
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);
}
}
/*
* Initialize the "k_info" array, by parsing an ascii "template" file
*/
-errr init_k_info_txt(FILE *fp, char *buf)
+errr parse_k_info(char *buf, header *head)
{
int i;
char *s, *t;
/* Current entry */
- object_kind *k_ptr = NULL;
+ static object_kind *k_ptr = NULL;
- /* Just before the first record */
- error_idx = -1;
-
- /* Just before the first line */
- error_line = -1;
-
-
- /* Prepare the "fake" stuff */
- k_head->name_size = 0;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- k_head->E_name_size = 0;
-#endif
- k_head->text_size = 0;
-
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
- {
- /* Advance the line number */
- error_line++;
-
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
-
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
-
-
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
-
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
+ {
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
/* Verify that colon */
- if (!s) return (1);
+ if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
- /* Get the index */
- i = atoi(buf+2);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Verify information */
- if (i <= error_idx) return (4);
+ /* Verify information */
+ if (i <= error_idx) return (4);
- /* Verify information */
- if (i >= k_head->info_num) return (2);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Save the index */
- error_idx = i;
+ /* Save the index */
+ error_idx = i;
- /* Point at the "info" */
- k_ptr = &k_info[i];
+ /* Point at the "info" */
+ k_ptr = &k_info[i];
#ifdef JP
- /* Hack -- Verify space */
- if (k_head->name_size + strlen(s) + 8 > fake_name_size)
- {
- fake_name_size += 1000;
-
- /* Reallocate the extra memory */
- k_info = realloc(k_name, fake_name_size);
- }
-
- /* Advance and Save the name index */
- if (!k_ptr->name) k_ptr->name = ++k_head->name_size;
-
- /* Append chars to the name */
- strcpy(k_name + k_head->name_size, s);
-
- /* Advance the index */
- k_head->name_size += strlen(s);
+ /* Store the name */
+ if (!add_name(&k_ptr->name, head, s)) return (7);
#endif
- /* Next... */
- continue;
- }
+ }
- /* There better be a current k_ptr */
- if (!k_ptr) return (3);
+ /* There better be a current k_ptr */
+ else if (!k_ptr) return (3);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (k_head->E_name_size + strlen(s) + 8 > E_fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!k_ptr->E_name) k_ptr->E_name = ++k_head->E_name_size;
-
- /* Append chars to the name */
- strcpy(E_k_name+ k_head->E_name_size, s);
-
- /* Advance the index */
- k_head->E_name_size += strlen(s);
-
- /* Next... */
- continue;
- }
+ /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
+ /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ else if (buf[0] == 'E')
+ {
+ /* nothing to do */
+ }
#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (k_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!k_ptr->name) k_ptr->name = ++k_head->name_size;
-
- /* Append chars to the name */
- strcpy(k_name+ k_head->name_size, s);
-
- /* Advance the index */
- k_head->name_size += strlen(s);
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&k_ptr->name, head, s)) return (7);
+ }
#endif
-#if 0
-
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
- /* 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);
-
- /* Next... */
- continue;
- }
+ /* Process 'D' for "Description" */
+ else if (buf[0] == 'D')
+ {
+#ifdef JP
+ if (buf[2] == '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+2;
+#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) */
- if (buf[0] == 'G')
- {
- char sym;
- int tmp;
-
- /* Paranoia */
- if (!buf[2]) return (1);
- if (!buf[3]) return (1);
- if (!buf[4]) return (1);
+ /* Process 'G' for "Graphics" (one line only) */
+ else if (buf[0] == 'G')
+ {
+ char sym;
+ byte tmp;
- /* Extract the char */
- sym = buf[2];
+ /* Paranoia */
+ if (!buf[2]) return (1);
+ if (!buf[3]) return (1);
+ if (!buf[4]) return (1);
- /* Extract the attr */
- tmp = color_char_to_attr(buf[4]);
+ /* Extract the char */
+ sym = buf[2];
- /* Paranoia */
- if (tmp < 0) return (1);
+ /* Extract the attr */
+ tmp = color_char_to_attr(buf[4]);
- /* Save the values */
- k_ptr->d_attr = tmp;
- k_ptr->d_char = sym;
+ /* Paranoia */
+ if (tmp > 127) return (1);
- /* Next... */
- continue;
- }
+ /* Save the values */
+ k_ptr->d_attr = tmp;
+ k_ptr->d_char = sym;
+ }
- /* Process 'I' for "Info" (one line only) */
- if (buf[0] == 'I')
- {
- int tval, sval, pval;
+ /* Process 'I' for "Info" (one line only) */
+ else if (buf[0] == 'I')
+ {
+ int tval, sval, pval;
- /* Scan for the values */
- if (3 != sscanf(buf+2, "%d:%d:%d",
+ /* Scan for the values */
+ if (3 != sscanf(buf+2, "%d:%d:%d",
&tval, &sval, &pval)) return (1);
- /* Save the values */
- k_ptr->tval = tval;
- k_ptr->sval = sval;
- k_ptr->pval = pval;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ k_ptr->tval = tval;
+ k_ptr->sval = sval;
+ k_ptr->pval = pval;
+ }
- /* Process 'W' for "More Info" (one line only) */
- if (buf[0] == 'W')
- {
- int level, extra, wgt;
- long cost;
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int level, extra, wgt;
+ long cost;
- /* Scan for the values */
- if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
&level, &extra, &wgt, &cost)) return (1);
- /* Save the values */
- k_ptr->level = level;
- k_ptr->extra = extra;
- k_ptr->weight = wgt;
- k_ptr->cost = cost;
+ /* Save the values */
+ k_ptr->level = level;
+ k_ptr->extra = extra;
+ k_ptr->weight = wgt;
+ k_ptr->cost = cost;
+ }
- /* Next... */
- continue;
- }
+ /* Process 'A' for "Allocation" (one line only) */
+ else if (buf[0] == 'A')
+ {
+ int i;
- /* Process 'A' for "Allocation" (one line only) */
- if (buf[0] == 'A')
+ /* XXX XXX XXX Simply read each number following a colon */
+ for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
{
- int i;
-
- /* XXX XXX XXX Simply read each number following a colon */
- for (i = 0, s = buf+1; s && (s[0] == ':') && s[1]; ++i)
- {
/* Default chance */
- k_ptr->chance[i] = 1;
+ k_ptr->chance[i] = 1;
/* Store the attack damage index */
- k_ptr->locale[i] = atoi(s+1);
+ k_ptr->locale[i] = atoi(s+1);
/* Find the slash */
- t = strchr(s+1, '/');
+ t = strchr(s+1, '/');
/* Find the next colon */
- s = strchr(s+1, ':');
+ s = strchr(s+1, ':');
/* If the slash is "nearby", use it */
- if (t && (!s || t < s))
- {
- int chance = atoi(t+1);
- if (chance > 0) k_ptr->chance[i] = chance;
- }
+ if (t && (!s || t < s))
+ {
+ int chance = atoi(t+1);
+ if (chance > 0) k_ptr->chance[i] = chance;
}
-
- /* Next... */
- continue;
}
+ }
- /* Hack -- Process 'P' for "power" and such */
- if (buf[0] == 'P')
- {
- int ac, hd1, hd2, th, td, ta;
+ /* Hack -- Process 'P' for "power" and such */
+ else if (buf[0] == 'P')
+ {
+ int ac, hd1, hd2, th, td, ta;
- /* Scan for the values */
- if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
+ /* Scan for the values */
+ if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
&ac, &hd1, &hd2, &th, &td, &ta)) return (1);
- k_ptr->ac = ac;
- k_ptr->dd = hd1;
- k_ptr->ds = hd2;
- k_ptr->to_h = th;
- k_ptr->to_d = td;
- k_ptr->to_a = ta;
-
- /* Next... */
- continue;
- }
+ k_ptr->ac = ac;
+ k_ptr->dd = hd1;
+ k_ptr->ds = hd2;
+ k_ptr->to_h = th;
+ k_ptr->to_d = td;
+ k_ptr->to_a = ta;
+ }
- /* Hack -- Process 'F' for flags */
- if (buf[0] == 'F')
+ /* Hack -- Process 'F' for flags */
+ else if (buf[0] == 'F')
+ {
+ /* Parse every entry textually */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while (*t == ' ' || *t == '|') t++;
+ }
/* Parse this entry */
- if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
+ if (0 != grab_one_kind_flag(k_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
-
-
- /* Oops */
- return (6);
}
- /* Complete the "name" and "text" sizes */
- ++k_head->name_size;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- ++k_head->E_name_size;
-#endif
- ++k_head->text_size;
+ /* Oops */
+ else return (6);
/* Success */
{
int i;
- /* Check flags1 */
- for (i = 0; i < 32; i++)
- {
- if (streq(what, k_info_flags1[i]))
- {
- a_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]))
{
- a_ptr->flags2 |= (1L << i);
+ add_flag(a_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]))
{
- a_ptr->flags3 |= (1L << i);
+ a_ptr->gen_flags |= (1L << i);
return (0);
}
}
/*
* Initialize the "a_info" array, by parsing an ascii "template" file
*/
-errr init_a_info_txt(FILE *fp, char *buf)
+errr parse_a_info(char *buf, header *head)
{
int i;
char *s, *t;
/* Current entry */
- artifact_type *a_ptr = NULL;
-
+ static artifact_type *a_ptr = NULL;
- /* Just before the first record */
- error_idx = -1;
- /* Just before the first line */
- error_line = -1;
-
-
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
{
- /* Advance the line number */
- error_line++;
-
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
-
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
-
-
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
-
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
/* Verify that colon */
- if (!s) return (1);
+ if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
- /* Get the index */
- i = atoi(buf+2);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Verify information */
- if (i < error_idx) return (4);
+ /* Verify information */
+ if (i < error_idx) return (4);
- /* Verify information */
- if (i >= a_head->info_num) return (2);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Save the index */
- error_idx = i;
+ /* Save the index */
+ error_idx = i;
- /* Point at the "info" */
- a_ptr = &a_info[i];
+ /* Point at the "info" */
+ 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);
+ /* Ignore everything */
+ 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 (a_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!a_ptr->name) a_ptr->name = ++a_head->name_size;
-
- /* Append chars to the name */
- strcpy(a_name + a_head->name_size, s);
-
- /* Advance the index */
- a_head->name_size += strlen(s);
+ /* Store the name */
+ if (!add_name(&a_ptr->name, head, s)) return (7);
#endif
- /* Next... */
- continue;
- }
+ }
- /* There better be a current a_ptr */
- if (!a_ptr) return (3);
+ /* There better be a current a_ptr */
+ else if (!a_ptr) return (3);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (a_head->E_name_size + strlen(s) + 8 > E_fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!a_ptr->E_name) a_ptr->E_name = ++a_head->E_name_size;
-
- /* Append chars to the name */
- strcpy(E_a_name+ a_head->E_name_size, s);
-
- /* Advance the index */
- a_head->E_name_size += strlen(s);
-
- /* Next... */
- continue;
- }
+ /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
+ /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾¤È¤·¤Æ¤¤¤ë */
+ else if (buf[0] == 'E')
+ {
+ /* nothing to do */
+ }
#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (a_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!a_ptr->name) a_ptr->name = ++a_head->name_size;
-
- /* Append chars to the name */
- strcpy(a_name+ a_head->name_size, s);
-
- /* Advance the index */
- a_head->name_size += strlen(s);
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&a_ptr->name, head, s)) return (7);
+ }
#endif
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
+ /* Process 'D' for "Description" */
+ else if (buf[0] == 'D')
+ {
#ifdef JP
- if (buf[2] == '$')
- continue;
- /* Acquire the text */
- s = buf+2;
+ if (buf[2] == '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+2;
#else
- if (buf[2] != '$')
- continue;
- /* Acquire the text */
- s = buf+3;
+ if (buf[2] != '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+3;
#endif
- /* Hack -- Verify space */
- if (a_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
- /* Advance and Save the text index */
- if (!a_ptr->text) a_ptr->text = ++a_head->text_size;
-
- /* Append chars to the name */
- strcpy(a_text + a_head->text_size, s);
-
- /* Advance the index */
- a_head->text_size += strlen(s);
-
- /* Next... */
- continue;
- }
+ /* Store the text */
+ if (!add_text(&a_ptr->text, head, s)) return (7);
+ }
- /* Process 'I' for "Info" (one line only) */
- if (buf[0] == 'I')
- {
- int tval, sval, pval;
+ /* Process 'I' for "Info" (one line only) */
+ else if (buf[0] == 'I')
+ {
+ int tval, sval, pval;
- /* Scan for the values */
- if (3 != sscanf(buf+2, "%d:%d:%d",
+ /* Scan for the values */
+ if (3 != sscanf(buf+2, "%d:%d:%d",
&tval, &sval, &pval)) return (1);
- /* Save the values */
- a_ptr->tval = tval;
- a_ptr->sval = sval;
- a_ptr->pval = pval;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ a_ptr->tval = tval;
+ a_ptr->sval = sval;
+ a_ptr->pval = pval;
+ }
- /* Process 'W' for "More Info" (one line only) */
- if (buf[0] == 'W')
- {
- int level, rarity, wgt;
- long cost;
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int level, rarity, wgt;
+ long cost;
- /* Scan for the values */
- if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
&level, &rarity, &wgt, &cost)) return (1);
- /* Save the values */
- a_ptr->level = level;
- a_ptr->rarity = rarity;
- a_ptr->weight = wgt;
- a_ptr->cost = cost;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ a_ptr->level = level;
+ a_ptr->rarity = rarity;
+ a_ptr->weight = wgt;
+ a_ptr->cost = cost;
+ }
- /* Hack -- Process 'P' for "power" and such */
- if (buf[0] == 'P')
- {
- int ac, hd1, hd2, th, td, ta;
+ /* Hack -- Process 'P' for "power" and such */
+ else if (buf[0] == 'P')
+ {
+ int ac, hd1, hd2, th, td, ta;
- /* Scan for the values */
- if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
+ /* Scan for the values */
+ if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
&ac, &hd1, &hd2, &th, &td, &ta)) return (1);
- a_ptr->ac = ac;
- a_ptr->dd = hd1;
- a_ptr->ds = hd2;
- a_ptr->to_h = th;
- a_ptr->to_d = td;
- a_ptr->to_a = ta;
-
- /* Next... */
- continue;
- }
+ a_ptr->ac = ac;
+ a_ptr->dd = hd1;
+ a_ptr->ds = hd2;
+ a_ptr->to_h = th;
+ a_ptr->to_d = td;
+ a_ptr->to_a = ta;
+ }
- /* Hack -- Process 'F' for flags */
- if (buf[0] == 'F')
+ /* Hack -- Process 'F' for flags */
+ else if (buf[0] == 'F')
+ {
+ /* Parse every entry textually */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while ((*t == ' ') || (*t == '|')) t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while ((*t == ' ') || (*t == '|')) t++;
+ }
/* Parse this entry */
- if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
+ if (0 != grab_one_artifact_flag(a_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
-
-
- /* Oops */
- return (6);
}
- /* Complete the "name" and "text" sizes */
- ++a_head->name_size;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- ++a_head->E_name_size;
-#endif
- ++a_head->text_size;
+ /* Oops */
+ else return (6);
/* Success */
{
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
/*
* Initialize the "e_info" array, by parsing an ascii "template" file
*/
-errr init_e_info_txt(FILE *fp, char *buf)
+errr parse_e_info(char *buf, header *head)
{
int i;
char *s, *t;
/* Current entry */
- ego_item_type *e_ptr = NULL;
+ static ego_item_type *e_ptr = NULL;
/* Just before the first record */
error_line = -1;
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
{
- /* Advance the line number */
- error_line++;
-
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
-
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
-
-
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
-
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
/* Verify that colon */
- if (!s) return (1);
+ if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
- /* Get the index */
- i = atoi(buf+2);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Verify information */
- if (i < error_idx) return (4);
+ /* Verify information */
+ if (i < error_idx) return (4);
- /* Verify information */
- if (i >= e_head->info_num) return (2);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Save the index */
- error_idx = i;
+ /* Save the index */
+ error_idx = i;
- /* Point at the "info" */
- e_ptr = &e_info[i];
+ /* Point at the "info" */
+ e_ptr = &e_info[i];
#ifdef JP
- /* Hack -- Verify space */
- if (e_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!e_ptr->name) e_ptr->name = ++e_head->name_size;
-
- /* Append chars to the name */
- strcpy(e_name + e_head->name_size, s);
-
- /* Advance the index */
- e_head->name_size += strlen(s);
+ /* Store the name */
+ if (!add_name(&e_ptr->name, head, s)) return (7);
#endif
- /* Next... */
- continue;
- }
+ }
- /* There better be a current e_ptr */
- if (!e_ptr) return (3);
+ /* There better be a current e_ptr */
+ else if (!e_ptr) return (3);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (e_head->E_name_size + strlen(s) + 8 > E_fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!e_ptr->E_name) e_ptr->E_name = ++e_head->E_name_size;
-
- /* Append chars to the name */
- strcpy(E_e_name+ e_head->E_name_size, s);
-
- /* Advance the index */
- e_head->E_name_size += strlen(s);
-
- /* Next... */
- continue;
- }
+ /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
+ /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
+ else if (buf[0] == 'E')
+ {
+ /* nothing to do */
+ }
#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (e_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!e_ptr->name) e_ptr->name = ++e_head->name_size;
-
- /* Append chars to the name */
- strcpy(e_name+ e_head->name_size, s);
-
- /* Advance the index */
- e_head->name_size += strlen(s);
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&e_ptr->name, head, s)) return (7);
+ }
#endif
#if 0
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
- /* 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);
+ /* Process 'D' for "Description" */
+ else if (buf[0] == 'D')
+ {
+ /* Acquire the text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the text */
+ if (!add_text(&e_ptr->text, head, s)) return (7);
+ }
#endif
- /* Process 'X' for "Xtra" (one line only) */
- if (buf[0] == 'X')
- {
- int slot, rating;
+ /* Process 'X' for "Xtra" (one line only) */
+ else if (buf[0] == 'X')
+ {
+ int slot, rating;
- /* Scan for the values */
- if (2 != sscanf(buf+2, "%d:%d",
+ /* Scan for the values */
+ if (2 != sscanf(buf+2, "%d:%d",
&slot, &rating)) return (1);
- /* Save the values */
- e_ptr->slot = slot;
- e_ptr->rating = rating;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ e_ptr->slot = slot;
+ e_ptr->rating = rating;
+ }
- /* Process 'W' for "More Info" (one line only) */
- if (buf[0] == 'W')
- {
- int level, rarity, pad2;
- long cost;
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int level, rarity, pad2;
+ long cost;
- /* Scan for the values */
- if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%ld",
&level, &rarity, &pad2, &cost)) return (1);
- /* Save the values */
- e_ptr->level = level;
- e_ptr->rarity = rarity;
- /* e_ptr->weight = wgt; */
- e_ptr->cost = cost;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ e_ptr->level = level;
+ e_ptr->rarity = rarity;
+ /* e_ptr->weight = wgt; */
+ e_ptr->cost = cost;
+ }
- /* Hack -- Process 'C' for "creation" */
- if (buf[0] == 'C')
- {
- int th, td, ta, pv;
+ /* Hack -- Process 'C' for "creation" */
+ else if (buf[0] == 'C')
+ {
+ int th, td, ta, pv;
- /* Scan for the values */
- if (4 != sscanf(buf+2, "%d:%d:%d:%d",
+ /* Scan for the values */
+ if (4 != sscanf(buf+2, "%d:%d:%d:%d",
&th, &td, &ta, &pv)) return (1);
- e_ptr->max_to_h = th;
- e_ptr->max_to_d = td;
- e_ptr->max_to_a = ta;
- e_ptr->max_pval = pv;
-
- /* Next... */
- continue;
- }
+ e_ptr->max_to_h = th;
+ e_ptr->max_to_d = td;
+ e_ptr->max_to_a = ta;
+ e_ptr->max_pval = pv;
+ }
- /* Hack -- Process 'F' for flags */
- if (buf[0] == 'F')
+ /* Hack -- Process 'F' for flags */
+ else if (buf[0] == 'F')
+ {
+ /* Parse every entry textually */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while ((*t == ' ') || (*t == '|')) t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while ((*t == ' ') || (*t == '|')) t++;
+ }
/* Parse this entry */
- if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
+ if (0 != grab_one_ego_item_flag(e_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
-
- /* Oops */
- return (6);
}
-
- /* Complete the "name" and "text" sizes */
- ++e_head->name_size;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- ++e_head->E_name_size;
-#endif
- ++e_head->text_size;
-
+ /* Oops */
+ else return (6);
/* Success */
return (0);
/*
* Initialize the "r_info" array, by parsing an ascii "template" file
*/
-errr init_r_info_txt(FILE *fp, char *buf)
+errr parse_r_info(char *buf, header *head)
{
int i;
char *s, *t;
/* Current entry */
- monster_race *r_ptr = NULL;
-
-
- /* Just before the first record */
- error_idx = -1;
+ static monster_race *r_ptr = NULL;
- /* Just before the first line */
- error_line = -1;
-
-
- /* Start the "fake" stuff */
- r_head->name_size = 0;
- r_head->text_size = 0;
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
{
- /* Advance the line number */
- error_line++;
-
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
-
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
-
-
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
-
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
/* Verify that colon */
- if (!s) return (1);
+ if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
- /* Get the index */
- i = atoi(buf+2);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Verify information */
- if (i < error_idx) return (4);
+ /* Verify information */
+ if (i < error_idx) return (4);
- /* Verify information */
- if (i >= r_head->info_num) return (2);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Save the index */
- error_idx = i;
+ /* Save the index */
+ error_idx = i;
- /* Point at the "info" */
- r_ptr = &r_info[i];
+ /* Point at the "info" */
+ r_ptr = &r_info[i];
#ifdef JP
- /* Hack -- Verify space */
- if (r_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!r_ptr->name) r_ptr->name = ++r_head->name_size;
-
- /* Append chars to the name */
- strcpy(r_name + r_head->name_size, s);
-
- /* Advance the index */
- r_head->name_size += strlen(s);
+ /* Store the name */
+ if (!add_name(&r_ptr->name, head, s)) return (7);
#endif
- /* Next... */
- continue;
- }
+ }
- /* There better be a current r_ptr */
- if (!r_ptr) return (3);
+ /* There better be a current r_ptr */
+ else if (!r_ptr) return (3);
#ifdef JP
- /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
- /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (r_head->E_name_size + strlen(s) + 8 > E_fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!r_ptr->E_name) r_ptr->E_name = ++r_head->E_name_size;
-
- /* Append chars to the name */
- strcpy(E_r_name+ r_head->E_name_size, s);
-
- /* Advance the index */
- r_head->E_name_size += strlen(s);
+ /* ±Ñ¸ì̾¤òÆɤà¥ë¡¼¥Á¥ó¤òÄɲà */
+ /* 'E' ¤«¤é»Ï¤Þ¤ë¹Ô¤Ï±Ñ¸ì̾ */
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&r_ptr->E_name, head, s)) return (7);
+ }
#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (r_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!r_ptr->name) r_ptr->name = ++r_head->name_size;
-
- /* Append chars to the name */
- strcpy(r_name+ r_head->name_size, s);
-
- /* Advance the index */
- r_head->name_size += strlen(s);
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&r_ptr->name, head, s)) return (7);
+ }
#endif
- /* Process 'D' for "Description" */
- if (buf[0] == 'D')
- {
+ /* Process 'D' for "Description" */
+ else if (buf[0] == 'D')
+ {
#ifdef JP
- if (buf[2] == '$')
- continue;
- /* Acquire the text */
- s = buf+2;
+ if (buf[2] == '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+2;
#else
- if (buf[2] != '$')
- continue;
- /* Acquire the text */
- s = buf+3;
+ if (buf[2] != '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+3;
#endif
- /* Hack -- Verify space */
- if (r_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
- /* Advance and Save the text index */
- if (!r_ptr->text) r_ptr->text = ++r_head->text_size;
-
- /* Append chars to the name */
- strcpy(r_text + r_head->text_size, s);
-
- /* Advance the index */
- r_head->text_size += strlen(s);
-
- /* Next... */
- continue;
- }
-
- /* Process 'G' for "Graphics" (one line only) */
- if (buf[0] == 'G')
- {
- char sym;
- int tmp;
+ /* Store the text */
+ if (!add_text(&r_ptr->text, head, s)) return (7);
+ }
- /* Paranoia */
- if (!buf[2]) return (1);
- if (!buf[3]) return (1);
- if (!buf[4]) return (1);
+ /* Process 'G' for "Graphics" (one line only) */
+ else if (buf[0] == 'G')
+ {
+ char sym;
+ byte tmp;
- /* Extract the char */
- sym = buf[2];
+ /* Paranoia */
+ if (!buf[2]) return (1);
+ if (!buf[3]) return (1);
+ if (!buf[4]) return (1);
- /* Extract the attr */
- tmp = color_char_to_attr(buf[4]);
+ /* Extract the char */
+ sym = buf[2];
- /* Paranoia */
- if (tmp < 0) return (1);
+ /* Extract the attr */
+ tmp = color_char_to_attr(buf[4]);
- /* Save the values */
- r_ptr->d_char = sym;
- r_ptr->d_attr = tmp;
+ /* Paranoia */
+ if (tmp > 127) return (1);
- /* Next... */
- continue;
- }
+ /* Save the values */
+ r_ptr->d_char = sym;
+ r_ptr->d_attr = tmp;
+ }
- /* Process 'I' for "Info" (one line only) */
- if (buf[0] == 'I')
- {
- int spd, hp1, hp2, aaf, ac, slp;
+ /* Process 'I' for "Info" (one line only) */
+ else if (buf[0] == 'I')
+ {
+ int spd, hp1, hp2, aaf, ac, slp;
- /* Scan for the other values */
- if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
+ /* Scan for the other values */
+ if (6 != sscanf(buf+2, "%d:%dd%d:%d:%d:%d",
&spd, &hp1, &hp2, &aaf, &ac, &slp)) return (1);
- /* Save the values */
- r_ptr->speed = spd;
- r_ptr->hdice = hp1;
- r_ptr->hside = hp2;
- r_ptr->aaf = aaf;
- r_ptr->ac = ac;
- r_ptr->sleep = slp;
-
- /* Next... */
- continue;
- }
+ /* Save the values */
+ r_ptr->speed = spd;
+ r_ptr->hdice = hp1;
+ r_ptr->hside = hp2;
+ r_ptr->aaf = aaf;
+ r_ptr->ac = ac;
+ r_ptr->sleep = slp;
+ }
- /* Process 'W' for "More Info" (one line only) */
- if (buf[0] == 'W')
- {
- int lev, rar, pad;
- long exp;
- long nextexp;
- int nextmon;
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int lev, rar, pad;
+ long exp;
+ long nextexp;
+ int nextmon;
- /* Scan for the values */
- if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
+ /* Scan for the values */
+ if (6 != sscanf(buf+2, "%d:%d:%d:%ld:%ld:%d",
&lev, &rar, &pad, &exp, &nextexp, &nextmon)) return (1);
- /* Save the values */
- r_ptr->level = lev;
- r_ptr->rarity = rar;
- r_ptr->extra = pad;
- r_ptr->mexp = exp;
- r_ptr->next_exp = nextexp;
- r_ptr->next_r_idx = nextmon;
-
- /* Next... */
- continue;
- }
-
- /* Process 'B' for "Blows" (up to four lines) */
- if (buf[0] == 'B')
- {
- int n1, n2;
+ /* Save the values */
+ r_ptr->level = lev;
+ r_ptr->rarity = rar;
+ r_ptr->extra = pad;
+ r_ptr->mexp = exp;
+ r_ptr->next_exp = nextexp;
+ r_ptr->next_r_idx = nextmon;
+ }
- /* Find the next empty blow slot (if any) */
- for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
+ /* Process 'B' for "Blows" (up to four lines) */
+ else if (buf[0] == 'B')
+ {
+ int n1, n2;
- /* Oops, no more slots */
- if (i == 4) return (1);
+ /* Find the next empty blow slot (if any) */
+ for (i = 0; i < 4; i++) if (!r_ptr->blow[i].method) break;
- /* Analyze the first field */
- for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
+ /* Oops, no more slots */
+ if (i == 4) return (1);
- /* Terminate the field (if necessary) */
- if (*t == ':') *t++ = '\0';
+ /* Analyze the first field */
+ for (s = t = buf+2; *t && (*t != ':'); t++) /* loop */;
- /* Analyze the method */
- for (n1 = 0; r_info_blow_method[n1]; n1++)
- {
- if (streq(s, r_info_blow_method[n1])) break;
- }
+ /* Terminate the field (if necessary) */
+ if (*t == ':') *t++ = '\0';
- /* Invalid method */
- if (!r_info_blow_method[n1]) return (1);
+ /* Analyze the method */
+ for (n1 = 0; r_info_blow_method[n1]; n1++)
+ {
+ if (streq(s, r_info_blow_method[n1])) break;
+ }
- /* Analyze the second field */
- for (s = t; *t && (*t != ':'); t++) /* loop */;
+ /* Invalid method */
+ if (!r_info_blow_method[n1]) return (1);
- /* Terminate the field (if necessary) */
- if (*t == ':') *t++ = '\0';
+ /* Analyze the second field */
+ for (s = t; *t && (*t != ':'); t++) /* loop */;
- /* Analyze effect */
- for (n2 = 0; r_info_blow_effect[n2]; n2++)
- {
- if (streq(s, r_info_blow_effect[n2])) break;
- }
+ /* Terminate the field (if necessary) */
+ if (*t == ':') *t++ = '\0';
- /* Invalid effect */
- if (!r_info_blow_effect[n2]) return (1);
+ /* Analyze effect */
+ for (n2 = 0; r_info_blow_effect[n2]; n2++)
+ {
+ if (streq(s, r_info_blow_effect[n2])) break;
+ }
- /* Analyze the third field */
- for (s = t; *t && (*t != 'd'); t++) /* loop */;
+ /* Invalid effect */
+ if (!r_info_blow_effect[n2]) return (1);
- /* Terminate the field (if necessary) */
- if (*t == 'd') *t++ = '\0';
+ /* Analyze the third field */
+ for (s = t; *t && (*t != 'd'); t++) /* loop */;
- /* Save the method */
- r_ptr->blow[i].method = n1;
+ /* Terminate the field (if necessary) */
+ if (*t == 'd') *t++ = '\0';
- /* Save the effect */
- r_ptr->blow[i].effect = n2;
+ /* Save the method */
+ r_ptr->blow[i].method = n1;
- /* Extract the damage dice and sides */
- r_ptr->blow[i].d_dice = atoi(s);
- r_ptr->blow[i].d_side = atoi(t);
+ /* Save the effect */
+ r_ptr->blow[i].effect = n2;
- /* Next... */
- continue;
- }
+ /* Extract the damage dice and sides */
+ r_ptr->blow[i].d_dice = atoi(s);
+ r_ptr->blow[i].d_side = atoi(t);
+ }
- /* Process 'F' for "Basic Flags" (multiple lines) */
- if (buf[0] == 'F')
+ /* Process 'F' for "Basic Flags" (multiple lines) */
+ else if (buf[0] == 'F')
+ {
+ /* Parse every entry */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while (*t == ' ' || *t == '|') t++;
+ }
/* Parse this entry */
- if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
+ if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
+ }
- /* Process 'S' for "Spell Flags" (multiple lines) */
- if (buf[0] == 'S')
+ /* Process 'S' for "Spell Flags" (multiple lines) */
+ else if (buf[0] == 'S')
+ {
+ /* Parse every entry */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while ((*t == ' ') || (*t == '|')) t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while ((*t == ' ') || (*t == '|')) t++;
+ }
/* XXX XXX XXX Hack -- Read spell frequency */
- if (1 == sscanf(s, "1_IN_%d", &i))
- {
- /* Extract a "frequency" */
- r_ptr->freq_spell = r_ptr->freq_inate = 100 / i;
+ if (1 == sscanf(s, "1_IN_%d", &i))
+ {
+ /* Extract a "frequency" */
+ r_ptr->freq_spell = r_ptr->freq_inate = 100 / i;
/* Start at next entry */
- s = t;
+ s = t;
- /* Continue */
- continue;
- }
+ /* Continue */
+ continue;
+ }
/* Parse this entry */
- if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
+ if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
-
- /* Oops */
- return (6);
}
+ /* Oops */
+ else return (6);
- /* Complete the "name" and "text" sizes */
- ++r_head->name_size;
-#ifdef JP
- /* ±Ñ¸ì̾ÍÑ */
- ++r_head->E_name_size;
-#endif
- ++r_head->text_size;
-
-
- for (i = 1; i < max_r_idx; i++)
- {
- /* Invert flag WILD_ONLY <-> RF8_DUNGEON */
- r_info[i].flags8 ^= 1L;
-
- /* WILD_TOO without any other wilderness flags enables all flags */
- if ((r_info[i].flags8 & RF8_WILD_TOO) && !(r_info[i].flags8 & 0x7FFFFFFE))
- r_info[i].flags8 = 0x0463;
- }
/* Success */
return (0);
/* 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 */
/* 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);
}
}
{
if (streq(what, r_info_flags2[i]))
{
- d_ptr->mflags2 |= (1L << i);
+ d_ptr->mflags2 |= (1L << i);
return (0);
}
}
{
if (streq(what, r_info_flags3[i]))
{
- d_ptr->mflags3 |= (1L << i);
+ d_ptr->mflags3 |= (1L << i);
return (0);
}
}
/* 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);
}
}
{
if (streq(what, r_info_flags8[i]))
{
- d_ptr->mflags8 |= (1L << i);
+ d_ptr->mflags8 |= (1L << i);
return (0);
}
}
{
if (streq(what, r_info_flags9[i]))
{
- d_ptr->mflags9 |= (1L << i);
+ d_ptr->mflags9 |= (1L << i);
return (0);
}
}
{
if (streq(what, r_info_flags4[i]))
{
- d_ptr->mflags4 |= (1L << i);
+ d_ptr->mflags4 |= (1L << i);
return (0);
}
}
{
if (streq(what, r_info_flags5[i]))
{
- d_ptr->mflags5 |= (1L << i);
+ d_ptr->mflags5 |= (1L << i);
return (0);
}
}
{
if (streq(what, r_info_flags6[i]))
{
- d_ptr->mflags6 |= (1L << i);
+ d_ptr->mflags6 |= (1L << i);
return (0);
}
}
/*
* Initialize the "d_info" array, by parsing an ascii "template" file
*/
-errr init_d_info_txt(FILE *fp, char *buf)
+errr parse_d_info(char *buf, header *head)
{
int i;
char *s, *t;
/* Current entry */
- dungeon_info_type *d_ptr = NULL;
-
-
- /* Just before the first record */
- error_idx = -1;
-
- /* Just before the first line */
- error_line = -1;
+ static dungeon_info_type *d_ptr = NULL;
- /* Start the "fake" stuff */
- d_head->name_size = 0;
- d_head->text_size = 0;
-
- /* Parse */
- while (0 == my_fgets(fp, buf, 1024))
+ /* Process 'N' for "New/Number/Name" */
+ if (buf[0] == 'N')
{
- /* Advance the line number */
- error_line++;
-
- /* Skip comments and blank lines */
- if (!buf[0] || (buf[0] == '#')) continue;
-
- /* Verify correct "colon" format */
- if (buf[1] != ':') return (1);
-
-
- /* Hack -- Process 'V' for "Version" */
- if (buf[0] == 'V')
- {
- /* ignore */
- continue;
- }
-
- /* Process 'N' for "New/Number/Name" */
- if (buf[0] == 'N')
- {
- /* Find the colon before the name */
- s = strchr(buf+2, ':');
+ /* Find the colon before the name */
+ s = strchr(buf+2, ':');
- /* Verify that colon */
- if (!s) return (1);
+ /* Verify that colon */
+ if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Nuke the colon, advance to the name */
+ *s++ = '\0';
#ifdef JP
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Paranoia -- require a name */
+ if (!*s) return (1);
#endif
- /* Get the index */
- i = atoi(buf+2);
+ /* Get the index */
+ i = atoi(buf+2);
- /* Verify information */
- if (i < error_idx) return (4);
+ /* Verify information */
+ if (i < error_idx) return (4);
- /* Verify information */
- if (i >= d_head->info_num) return (2);
+ /* Verify information */
+ if (i >= head->info_num) return (2);
- /* Save the index */
- error_idx = i;
+ /* Save the index */
+ error_idx = i;
- /* Point at the "info" */
- d_ptr = &d_info[i];
+ /* Point at the "info" */
+ d_ptr = &d_info[i];
#ifdef JP
- /* Hack -- Verify space */
- if (d_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!d_ptr->name) d_ptr->name = ++d_head->name_size;
-
- /* Append chars to the name */
- strcpy(d_name + d_head->name_size, s);
-
- /* Advance the index */
- d_head->name_size += strlen(s);
+ /* Store the name */
+ if (!add_name(&d_ptr->name, head, s)) return (7);
#endif
- /* Next... */
- continue;
- }
+ }
#ifdef JP
- if (buf[0] == 'E')
- continue;
+ else if (buf[0] == 'E') return (0);
#else
- if (buf[0] == 'E')
- {
- /* Acquire the Text */
- s = buf+2;
-
- /* Hack -- Verify space */
- if (d_head->name_size + strlen(s) + 8 > fake_name_size) return (7);
-
- /* Advance and Save the name index */
- if (!d_ptr->name) d_ptr->name = ++d_head->name_size;
-
- /* Append chars to the name */
- strcpy(d_name + d_head->name_size, s);
-
- /* Advance the index */
- d_head->name_size += strlen(s);
+ else if (buf[0] == 'E')
+ {
+ /* Acquire the Text */
+ s = buf+2;
- /* Next... */
- continue;
- }
+ /* Store the name */
+ if (!add_name(&d_ptr->name, head, s)) return (7);
+ }
#endif
- /* Process 'D' for "Description */
- if (buf[0] == 'D')
- {
+ /* Process 'D' for "Description */
+ else if (buf[0] == 'D')
+ {
#ifdef JP
- if (buf[2] == '$')
- continue;
- /* Acquire the text */
- s = buf+2;
+ if (buf[2] == '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+2;
#else
- if (buf[2] != '$')
- continue;
- /* Acquire the text */
- s = buf+3;
+ if (buf[2] != '$')
+ return (0);
+ /* Acquire the text */
+ s = buf+3;
#endif
- /* Hack -- Verify space */
- if (d_head->text_size + strlen(s) + 8 > fake_text_size) return (7);
-
- /* Advance and Save the text index */
- if (!d_ptr->text) d_ptr->text = ++d_head->text_size;
-
- /* Append chars to the name */
- strcpy(d_text + d_head->text_size, s);
-
- /* Advance the index */
- d_head->text_size += strlen(s);
-
- /* Next... */
- continue;
- }
+ /* Store the text */
+ if (!add_text(&d_ptr->text, head, s)) return (7);
+ }
- /* Process 'W' for "More Info" (one line only) */
- if (buf[0] == 'W')
- {
- int min_lev, max_lev;
- int min_plev, mode;
- int min_alloc, max_chance;
- int obj_good, obj_great;
- int pit, nest;
-
- /* Scan for the values */
- if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
- &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, &pit, &nest)) return (1);
-
- /* Save the values */
- d_ptr->mindepth = min_lev;
- d_ptr->maxdepth = max_lev;
- d_ptr->min_plev = min_plev;
- d_ptr->mode = mode;
- d_ptr->min_m_alloc_level = min_alloc;
- d_ptr->max_m_alloc_chance = max_chance;
- d_ptr->obj_good = obj_good;
- d_ptr->obj_great = obj_great;
- d_ptr->pit = pit;
- d_ptr->nest = nest;
-
- /* Next... */
- continue;
- }
+ /* Process 'W' for "More Info" (one line only) */
+ else if (buf[0] == 'W')
+ {
+ int min_lev, max_lev;
+ int min_plev, mode;
+ int min_alloc, max_chance;
+ int obj_good, obj_great;
+ int pit, nest;
+
+ /* Scan for the values */
+ if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x",
+ &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great, (unsigned int *)&pit, (unsigned int *)&nest)) return (1);
+
+ /* Save the values */
+ d_ptr->mindepth = min_lev;
+ d_ptr->maxdepth = max_lev;
+ d_ptr->min_plev = min_plev;
+ d_ptr->mode = mode;
+ d_ptr->min_m_alloc_level = min_alloc;
+ d_ptr->max_m_alloc_chance = max_chance;
+ d_ptr->obj_good = obj_good;
+ d_ptr->obj_great = obj_great;
+ d_ptr->pit = pit;
+ d_ptr->nest = nest;
+ }
- /* Process 'P' for "Place Info" */
- if (buf[0] == 'P')
- {
- int dy, dx;
+ /* Process 'P' for "Place Info" */
+ else if (buf[0] == 'P')
+ {
+ int dy, dx;
- /* Scan for the values */
- if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
+ /* Scan for the values */
+ if (2 != sscanf(buf+2, "%d:%d", &dy, &dx)) return (1);
- /* Save the values */
- d_ptr->dy = dy;
- d_ptr->dx = dx;
+ /* Save the values */
+ d_ptr->dy = dy;
+ d_ptr->dx = dx;
+ }
- /* Next... */
- continue;
- }
+ /* Process 'L' for "fLoor type" (one line only) */
+ else if (buf[0] == 'L')
+ {
+ int f1, f2, f3;
+ int p1, p2, p3;
+ int tunnel;
+
+ /* 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);
+
+ /* Save the values */
+ d_ptr->floor1 = f1;
+ d_ptr->floor_percent1 = p1;
+ d_ptr->floor2 = f2;
+ d_ptr->floor_percent2 = p2;
+ d_ptr->floor3 = f3;
+ d_ptr->floor_percent3 = p3;
+ d_ptr->tunnel_percent = tunnel;
+ }
- /* Process 'L' for "fLoor type" (one line only) */
- if (buf[0] == 'L')
- {
- int f1, f2, f3;
- int p1, p2, p3;
- int tunnel;
-
- /* 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);
-
- /* Save the values */
- d_ptr->floor1 = f1;
- d_ptr->floor_percent1 = p1;
- d_ptr->floor2 = f2;
- d_ptr->floor_percent2 = p2;
- d_ptr->floor3 = f3;
- d_ptr->floor_percent3 = p3;
- d_ptr->tunnel_percent = tunnel;
-
- /* Next... */
- continue;
- }
+ /* Process 'A' for "wAll type" (one line only) */
+ else if (buf[0] == 'A')
+ {
+ int w1, w2, w3, outer, inner, stream1, stream2;
+ int p1, p2, p3;
+
+ /* Scan for the values */
+ if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
+ &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) return (1);
+
+ /* Save the values */
+ d_ptr->fill_type1 = w1;
+ d_ptr->fill_percent1 = p1;
+ d_ptr->fill_type2 = w2;
+ d_ptr->fill_percent2 = p2;
+ d_ptr->fill_type3 = w3;
+ d_ptr->fill_percent3 = p3;
+ d_ptr->outer_wall = outer;
+ d_ptr->inner_wall = inner;
+ d_ptr->stream1 = stream1;
+ d_ptr->stream2 = stream2;
+ }
- /* Process 'A' for "wAll type" (one line only) */
- if (buf[0] == 'A')
- {
- int w1, w2, w3, outer, inner, stream1, stream2;
- int p1, p2, p3;
-
- /* Scan for the values */
- if (10 != sscanf(buf+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d",
- &w1, &p1, &w2, &p2, &w3, &p3, &outer, &inner, &stream1, &stream2)) return (1);
-
- /* Save the values */
- d_ptr->fill_type1 = w1;
- d_ptr->fill_percent1 = p1;
- d_ptr->fill_type2 = w2;
- d_ptr->fill_percent2 = p2;
- d_ptr->fill_type3 = w3;
- d_ptr->fill_percent3 = p3;
- d_ptr->outer_wall = outer;
- d_ptr->inner_wall = inner;
- d_ptr->stream1 = stream1;
- d_ptr->stream2 = stream2;
-
- /* Next... */
- continue;
- }
+ /* Process 'F' for "Dungeon Flags" (multiple lines) */
+ else if (buf[0] == 'F')
+ {
+ int artif = 0, monst = 0;
- /* Process 'F' for "Dungeon Flags" (multiple lines) */
- if (buf[0] == 'F')
+ /* Parse every entry */
+ for (s = buf + 2; *s; )
{
- int artif = 0, monst = 0;
+ /* Find the end of this entry */
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ /* Nuke and skip any dividers */
+ if (*t)
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
-
- /* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
-
- /* XXX XXX XXX Hack -- Read Final Artifact */
- if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
- {
- /* Extract a "Final Artifact" */
- d_ptr->final_artifact = artif;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
- }
+ *t++ = '\0';
+ while (*t == ' ' || *t == '|') t++;
+ }
- /* XXX XXX XXX Hack -- Read Final Object */
- if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
- {
- /* Extract a "Final Artifact" */
- d_ptr->final_object = artif;
+ /* XXX XXX XXX Hack -- Read Final Artifact */
+ if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif))
+ {
+ /* Extract a "Final Artifact" */
+ d_ptr->final_artifact = artif;
- /* Start at next entry */
- s = t;
+ /* Start at next entry */
+ s = t;
- /* Continue */
- continue;
- }
+ /* Continue */
+ continue;
+ }
- /* XXX XXX XXX Hack -- Read Artifact Guardian */
- if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
- {
- /* Extract a "Artifact Guardian" */
- d_ptr->final_guardian = monst;
+ /* XXX XXX XXX Hack -- Read Final Object */
+ if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif))
+ {
+ /* Extract a "Final Artifact" */
+ d_ptr->final_object = artif;
- /* Start at next entry */
- s = t;
+ /* Start at next entry */
+ s = t;
- /* Continue */
- continue;
- }
+ /* Continue */
+ continue;
+ }
- /* XXX XXX XXX Hack -- Read Special Percentage */
- if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
- {
- /* Extract a "Special %" */
- d_ptr->special_div = monst;
+ /* XXX XXX XXX Hack -- Read Artifact Guardian */
+ if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
+ {
+ /* Extract a "Artifact Guardian" */
+ d_ptr->final_guardian = monst;
- /* Start at next entry */
- s = t;
+ /* Start at next entry */
+ s = t;
- /* Continue */
- continue;
- }
+ /* Continue */
+ continue;
+ }
- /* Parse this entry */
- if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
+ /* XXX XXX XXX Hack -- Read Special Percentage */
+ if (1 == sscanf(s, "MONSTER_DIV_%d", &monst))
+ {
+ /* Extract a "Special %" */
+ d_ptr->special_div = monst;
- /* Start the next entry */
+ /* Start at next entry */
s = t;
+
+ /* Continue */
+ continue;
}
- /* Next... */
- continue;
+ /* Parse this entry */
+ if (0 != grab_one_dungeon_flag(d_ptr, s)) return (5);
+
+ /* Start the next entry */
+ s = t;
}
+ }
- /* Process 'M' for "Basic Flags" (multiple lines) */
- if (buf[0] == 'M')
+ /* Process 'M' for "Basic Flags" (multiple lines) */
+ else if (buf[0] == 'M')
+ {
+ /* Parse every entry */
+ for (s = buf + 2; *s; )
{
- byte r_char_number = 0, r_char;
+ /* Find the end of this entry */
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ /* Nuke and skip any dividers */
+ if (*t)
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
-
- /* 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))
- {
- /* Limited to 5 races */
- if(r_char_number >= 5) continue;
-
- /* Extract a "frequency" */
- d_ptr->r_char[r_char_number++] = r_char;
-
- /* Start at next entry */
- s = t;
+ *t++ = '\0';
+ while (*t == ' ' || *t == '|') t++;
+ }
- /* Continue */
- continue;
- }
+ /* Hack -- Read monster symbols */
+ if (!strncmp(s, "R_CHAR_", 7))
+ {
+ /* Skip "R_CHAR_" */
+ s += 7;
- /* Parse this entry */
- if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
+ /* Read a string */
+ strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
- /* Start the next entry */
+ /* Start at next entry */
s = t;
+
+ /* Continue */
+ continue;
}
- /* Next... */
- continue;
+ /* Parse this entry */
+ if (0 != grab_one_basic_monster_flag(d_ptr, s)) return (5);
+
+ /* Start the next entry */
+ s = t;
}
+ }
- /* Process 'S' for "Spell Flags" (multiple lines) */
- if (buf[0] == 'S')
+ /* Process 'S' for "Spell Flags" (multiple lines) */
+ else if (buf[0] == 'S')
+ {
+ /* Parse every entry */
+ for (s = buf + 2; *s; )
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
/* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
/* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while ((*t == ' ') || (*t == '|')) t++;
- }
+ if (*t)
+ {
+ *t++ = '\0';
+ while ((*t == ' ') || (*t == '|')) t++;
+ }
/* XXX XXX XXX Hack -- Read spell frequency */
- if (1 == sscanf(s, "1_IN_%d", &i))
- {
- /* Start at next entry */
- s = t;
+ if (1 == sscanf(s, "1_IN_%d", &i))
+ {
+ /* Start at next entry */
+ s = t;
/* Continue */
- continue;
- }
+ continue;
+ }
/* Parse this entry */
- if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
+ if (0 != grab_one_spell_monster_flag(d_ptr, s)) return (5);
/* Start the next entry */
- s = t;
- }
-
- /* Next... */
- continue;
+ s = t;
}
-
- /* Oops */
- return (6);
}
- ++d_head->text_size;
+ /* Oops */
+ else return (6);
/* Success */
return (0);
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]);
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:
{
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)
{
}
/* 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) */
* 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);
}
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);
{
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 */
/* 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);
}
{
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);
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);
}
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)
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 */
else if (streq(b+1, "RACE"))
{
#ifdef JP
- v = rp_ptr->E_title;
+ v = rp_ptr->E_title;
#else
v = rp_ptr->title;
#endif
else if (streq(b+1, "CLASS"))
{
#ifdef JP
- v = cp_ptr->E_title;
+ v = cp_ptr->E_title;
#else
v = cp_ptr->title;
#endif
#ifdef JP
v = E_realm_names[p_ptr->realm1];
#else
- v = realm_names[p_ptr->realm1];
+ v = realm_names[p_ptr->realm1];
#endif
}
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
/* 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");
/* Process the file */
- while (0 == my_fgets(fp, buf, 1024))
+ while (0 == my_fgets(fp, buf, sizeof(buf)))
{
/* Count lines */
num++;
/* 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);
+#if 0
void write_r_info_txt(void)
{
int i, j, z, fc, bc;
fclose(fff);
}
+#endif