summaryrefslogtreecommitdiff
path: root/src/init1.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/init1.cc')
-rw-r--r--src/init1.cc876
1 files changed, 186 insertions, 690 deletions
diff --git a/src/init1.cc b/src/init1.cc
index 5decdfaa..56b1a3ac 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -2034,24 +2034,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'R') && (buf[2] == 'G'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_player_race_flag(&rp_ptr->flags1, &rp_ptr->flags2, buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_player_race_flag(&rp_ptr->flags1, &rp_ptr->flags2, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2061,24 +2046,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'F' for "level Flags" (multiple lines) */
if ((buf[0] == 'R') && (buf[2] == 'F'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_race_kind_flag(&rp_ptr->oflags1[lev], &rp_ptr->oflags2[lev], &rp_ptr->oflags3[lev], &rp_ptr->oflags4[lev], &rp_ptr->oflags5[lev], &rp_ptr->oesp[lev], buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_kind_flag(&rp_ptr->oflags1[lev], &rp_ptr->oflags2[lev], &rp_ptr->oflags3[lev], &rp_ptr->oflags4[lev], &rp_ptr->oflags5[lev], &rp_ptr->oesp[lev], s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2116,24 +2086,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'C' for "Class choice flags" (multiple lines) */
if ((buf[0] == 'R') && (buf[2] == 'C'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_class_flag(rp_ptr->choice, buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_class_flag(rp_ptr->choice, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2375,24 +2330,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'G'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_player_race_flag(&rmp_ptr->flags1, &rmp_ptr->flags2, buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_player_race_flag(&rmp_ptr->flags1, &rmp_ptr->flags2, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2402,24 +2342,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'F' for "level Flags" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'F'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_race_kind_flag(&rmp_ptr->oflags1[lev], &rmp_ptr->oflags2[lev], &rmp_ptr->oflags3[lev], &rmp_ptr->oflags4[lev], &rmp_ptr->oflags5[lev], &rmp_ptr->oesp[lev], buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_kind_flag(&rmp_ptr->oflags1[lev], &rmp_ptr->oflags2[lev], &rmp_ptr->oflags3[lev], &rmp_ptr->oflags4[lev], &rmp_ptr->oflags5[lev], &rmp_ptr->oesp[lev], s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2457,24 +2382,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'A' for "Allowed races" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'A'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_race_allow_flag(rmp_ptr->choice, buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_allow_flag(rmp_ptr->choice, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -2484,32 +2394,23 @@ errr init_player_info_txt(FILE *fp)
/* Process 'C' for "Class choice flags" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'C'))
{
- u32b choice[2] = {0, 0}, z;
-
- /* Parse every entry */
- for (s = buf + 6; *s; )
+ u32b choice[2] = {0, 0};
+ if (0 != grab_one_class_flag(choice, buf + 6))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_class_flag(choice, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
- for (z = 0; z < 2; z++)
+ /* Combine into the class flags */
+ for (int z = 0; z < 2; z++)
{
- if (buf[4] == 'A') rmp_ptr->pclass[z] |= choice[z];
- else rmp_ptr->mclass[z] |= choice[z];
+ if (buf[4] == 'A')
+ {
+ rmp_ptr->pclass[z] |= choice[z];
+ }
+ else
+ {
+ rmp_ptr->mclass[z] |= choice[z];
+ }
}
/* Next... */
@@ -2869,24 +2770,9 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'C') && (buf[2] == 'G'))
{
- /* Parse every entry */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_player_race_flag(&c_ptr->flags1, &c_ptr->flags2, buf + 4))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_player_race_flag(&c_ptr->flags1, &c_ptr->flags2, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -3359,7 +3245,7 @@ errr init_f_info_txt(FILE *fp)
{
int i;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
feature_type *f_ptr = NULL;
@@ -3580,32 +3466,15 @@ errr init_f_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_feature_flag(&f_ptr->flags1, buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_feature_flag(&f_ptr->flags1, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
continue;
}
-
-
/* Oops */
return (6);
}
@@ -3945,24 +3814,9 @@ errr init_k_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_kind_flag(k_ptr, buf + 2, FALSE))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_kind_flag(k_ptr, s, FALSE)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -3972,24 +3826,9 @@ errr init_k_info_txt(FILE *fp)
/* Hack -- Process 'f' for obvious flags */
if (buf[0] == 'f')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_kind_flag(k_ptr, buf + 2, TRUE))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_kind_flag(k_ptr, s, TRUE)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -4048,7 +3887,7 @@ errr init_a_info_txt(FILE *fp)
{
int i;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
artifact_type *a_ptr = NULL;
@@ -4241,25 +4080,7 @@ errr init_a_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
- {
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_artifact_flag(a_ptr, s, FALSE)) return (5);
-
- /* Start the next entry */
- s = t;
- }
+ if (0 != grab_one_artifact_flag(a_ptr, buf+2, FALSE)) return (5);
/* Next... */
continue;
@@ -4268,25 +4089,7 @@ errr init_a_info_txt(FILE *fp)
/* Hack -- Process 'f' for obvious flags */
if (buf[0] == 'f')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
- {
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_artifact_flag(a_ptr, s, TRUE)) return (5);
-
- /* Start the next entry */
- s = t;
- }
+ if (0 != grab_one_artifact_flag(a_ptr, buf+2, TRUE)) return (5);
/* Next... */
continue;
@@ -4323,7 +4126,7 @@ errr init_set_info_txt(FILE *fp)
int cur_art = 0, cur_num = 0;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
set_type *set_ptr = NULL;
@@ -4456,30 +4259,16 @@ errr init_set_info_txt(FILE *fp)
/* Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ /* Parse this entry */
+ if (0 != grab_one_race_kind_flag(&set_ptr->arts[cur_art].flags1[cur_num],
+ &set_ptr->arts[cur_art].flags2[cur_num],
+ &set_ptr->arts[cur_art].flags3[cur_num],
+ &set_ptr->arts[cur_art].flags4[cur_num],
+ &set_ptr->arts[cur_art].flags5[cur_num],
+ &set_ptr->arts[cur_art].esp[cur_num],
+ buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_kind_flag(&set_ptr->arts[cur_art].flags1[cur_num],
- &set_ptr->arts[cur_art].flags2[cur_num],
- &set_ptr->arts[cur_art].flags3[cur_num],
- &set_ptr->arts[cur_art].flags4[cur_num],
- &set_ptr->arts[cur_art].flags5[cur_num],
- &set_ptr->arts[cur_art].esp[cur_num],
- s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -4774,26 +4563,9 @@ errr init_s_info_txt(FILE *fp)
/* Process 'F' for flags */
if (buf[0] == 'F')
{
- char *t;
-
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_skill_flag(&s_ptr->flags1, buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_skill_flag(&(s_ptr->flags1), s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -5419,24 +5191,9 @@ errr init_e_info_txt(FILE *fp)
/* Hack -- Process 'r:F' for forbidden flags */
if ((buf[0] == 'r') && (buf[2] == 'F'))
{
- /* Parse every entry textually */
- for (s = buf + 4; *s; )
+ if (0 != grab_one_ego_item_flag_restrict(e_ptr, buf + 4, FALSE))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_ego_item_flag_restrict(e_ptr, s, FALSE)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -5563,7 +5320,7 @@ errr init_ra_info_txt(FILE *fp)
{
int i, cur_t = 0, j, cur_g = 0;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
randart_part_type *ra_ptr = NULL;
@@ -5749,24 +5506,9 @@ errr init_ra_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_randart_item_flag(ra_ptr, buf + 2, 'F'))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_randart_item_flag(ra_ptr, s, 'F')) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -5776,24 +5518,9 @@ errr init_ra_info_txt(FILE *fp)
/* Hack -- Process 'A' for antagonic flags */
if (buf[0] == 'A')
{
- /* Parse every entry textually */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_randart_item_flag(ra_ptr, buf + 2, 'A'))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_randart_item_flag(ra_ptr, s, 'A')) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -6128,24 +5855,9 @@ errr init_r_info_txt(FILE *fp)
/* Process 'F' for "Basic Flags" (multiple lines) */
if (buf[0] == 'F')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_basic_flag(r_ptr, buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_basic_flag(r_ptr, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -6155,37 +5867,22 @@ errr init_r_info_txt(FILE *fp)
/* Process 'S' for "Spell Flags" (multiple lines) */
if (buf[0] == 'S')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ s = buf + 2;
+
+ /* XXX XXX XXX Hack -- Read spell frequency */
+ if (1 == sscanf(s, "1_IN_%d", &i))
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ /* Extract a "frequency" */
+ r_ptr->freq_spell = r_ptr->freq_inate = 100 / i;
+ }
- /* Nuke and skip any dividers */
- if (*t)
+ /* Parse this entry */
+ else
+ {
+ if (0 != grab_one_spell_flag(r_ptr, s))
{
- *t++ = '\0';
- while ((*t == ' ') || (*t == '|')) t++;
+ return (5);
}
-
- /* 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;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
- }
-
- /* Parse this entry */
- if (0 != grab_one_spell_flag(r_ptr, s)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -6533,39 +6230,24 @@ errr init_re_info_txt(FILE *fp)
char r_char;
/* Parse every entry */
- for (s = buf + 2; *s; )
+ s = buf + 2;
+
+ /* XXX XXX XXX Hack -- Read monster symbols */
+ if (1 == sscanf(s, "R_CHAR_%c", &r_char))
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ /* Limited to 5 races */
+ if (r_char_number >= 5) continue;
- /* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ /* Extract a "frequency" */
+ re_ptr->r_char[r_char_number++] = r_char;
+ }
- /* XXX XXX XXX Hack -- Read monster symbols */
- if (1 == sscanf(s, "R_CHAR_%c", &r_char))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_ego_flag(re_ptr, s, TRUE))
{
- /* Limited to 5 races */
- if (r_char_number >= 5) continue;
-
- /* Extract a "frequency" */
- re_ptr->r_char[r_char_number++] = r_char;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_ego_flag(re_ptr, s, TRUE)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -6578,39 +6260,24 @@ errr init_re_info_txt(FILE *fp)
char r_char;
/* Parse every entry */
- for (s = buf + 2; *s; )
+ s = buf + 2;
+
+ /* XXX XXX XXX Hack -- Read monster symbols */
+ if (1 == sscanf(s, "R_CHAR_%c", &r_char))
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ /* Limited to 5 races */
+ if (nr_char_number >= 5) continue;
- /* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ /* Extract a "frequency" */
+ re_ptr->nr_char[nr_char_number++] = r_char;
+ }
- /* XXX XXX XXX Hack -- Read monster symbols */
- if (1 == sscanf(s, "R_CHAR_%c", &r_char))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_ego_flag(re_ptr, s, FALSE))
{
- /* Limited to 5 races */
- if (nr_char_number >= 5) continue;
-
- /* Extract a "frequency" */
- re_ptr->nr_char[nr_char_number++] = r_char;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_ego_flag(re_ptr, s, FALSE)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -6620,24 +6287,9 @@ errr init_re_info_txt(FILE *fp)
/* Process 'M' for "Basic Monster Flags" (multiple lines) */
if (buf[0] == 'M')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_basic_ego_flag(re_ptr, buf + 2, TRUE))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_basic_ego_flag(re_ptr, s, TRUE)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -6647,37 +6299,21 @@ errr init_re_info_txt(FILE *fp)
/* Process 'O' for "Basic Monster -Flags" (multiple lines) */
if (buf[0] == 'O')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ s = buf + 2;
- /* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ /* XXX XXX XXX Hack -- Read no flags */
+ if (!strcmp(s, "MF_ALL"))
+ {
+ /* No flags */
+ re_ptr->nflags1 = re_ptr->nflags2 = re_ptr->nflags3 = re_ptr->nflags7 = re_ptr->nflags8 = re_ptr->nflags9 = 0xFFFFFFFF;
+ }
- /* XXX XXX XXX Hack -- Read no flags */
- if (!strcmp(s, "MF_ALL"))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_basic_ego_flag(re_ptr, s, FALSE))
{
- /* No flags */
- re_ptr->nflags1 = re_ptr->nflags2 = re_ptr->nflags3 = re_ptr->nflags7 = re_ptr->nflags8 = re_ptr->nflags9 = 0xFFFFFFFF;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_basic_ego_flag(re_ptr, s, FALSE)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -6687,37 +6323,21 @@ errr init_re_info_txt(FILE *fp)
/* Process 'S' for "Spell Flags" (multiple lines) */
if (buf[0] == 'S')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ s = buf + 2;
- /* Nuke and skip any dividers */
- 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" */
+ re_ptr->freq_spell = re_ptr->freq_inate = 100 / i;
+ }
- /* XXX XXX XXX Hack -- Read spell frequency */
- if (1 == sscanf(s, "1_IN_%d", &i))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_spell_ego_flag(re_ptr, s, TRUE))
{
- /* Extract a "frequency" */
- re_ptr->freq_spell = re_ptr->freq_inate = 100 / i;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_spell_ego_flag(re_ptr, s, TRUE)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -7021,7 +6641,7 @@ errr init_d_info_txt(FILE *fp)
byte r_char_number = 0;
- char *s, *t;
+ char *s;
/* Current entry */
dungeon_info_type *d_ptr = NULL;
@@ -7327,104 +6947,57 @@ errr init_d_info_txt(FILE *fp)
int artif = 0, monst = 0, obj = 0;
int ix = -1, iy = -1, ox = -1, oy = -1;
int fill_method;
+ s = buf + 2;
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ /* Read dungeon in/out coords */
+ if (4 == sscanf(s, "WILD_%d_%d__%d_%d", &ix, &iy, &ox, &oy))
{
- /* 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++;
- }
-
- /* Read dungeon in/out coords */
- if (4 == sscanf(s, "WILD_%d_%d__%d_%d", &ix, &iy, &ox, &oy))
- {
- d_ptr->ix = ix;
- d_ptr->iy = iy;
- d_ptr->ox = ox;
- d_ptr->oy = oy;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
- }
-
- /* Read dungeon size */
- if (2 == sscanf(s, "SIZE_%d_%d", &ix, &iy))
- {
- d_ptr->size_x = ix;
- d_ptr->size_y = iy;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
- }
-
- /* Read dungeon fill method */
- if (1 == sscanf(s, "FILL_METHOD_%d", &fill_method))
- {
- d_ptr->fill_method = fill_method;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
- }
-
- /* Read Final Object */
- if (1 == sscanf(s, "FINAL_OBJECT_%d", &obj))
- {
- /* Extract a "Final Artifact" */
- d_ptr->final_object = obj;
+ d_ptr->ix = ix;
+ d_ptr->iy = iy;
+ d_ptr->ox = ox;
+ d_ptr->oy = oy;
+ }
- /* Start at next entry */
- s = t;
+ /* Read dungeon size */
+ else if (2 == sscanf(s, "SIZE_%d_%d", &ix, &iy))
+ {
+ d_ptr->size_x = ix;
+ d_ptr->size_y = iy;
+ }
- /* Continue */
- continue;
- }
+ /* Read dungeon fill method */
+ else if (1 == sscanf(s, "FILL_METHOD_%d", &fill_method))
+ {
+ d_ptr->fill_method = fill_method;
+ }
- /* Read Final Artifact */
- if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif ))
- {
- /* Extract a "Final Artifact" */
- d_ptr->final_artifact = artif ;
+ /* Read Final Object */
+ else if (1 == sscanf(s, "FINAL_OBJECT_%d", &obj))
+ {
+ /* Extract a "Final Artifact" */
+ d_ptr->final_object = obj;
+ }
- /* Start at next entry */
- s = t;
+ /* Read Final Artifact */
+ else if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif ))
+ {
+ /* Extract a "Final Artifact" */
+ d_ptr->final_artifact = artif ;
+ }
- /* Continue */
- continue;
- }
+ /* Read Artifact Guardian */
+ else if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
+ {
+ /* Extract a "Artifact Guardian" */
+ d_ptr->final_guardian = monst;
+ }
- /* Read Artifact Guardian */
- if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_dungeon_flag(&(d_ptr->flags1), &(d_ptr->flags2), s))
{
- /* Extract a "Artifact Guardian" */
- d_ptr->final_guardian = monst;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_dungeon_flag(&(d_ptr->flags1), &(d_ptr->flags2), s)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -7470,41 +7043,24 @@ errr init_d_info_txt(FILE *fp)
if (buf[0] == 'M')
{
byte r_char;
+ s = buf + 2;
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ /* Read monster symbols */
+ if (1 == sscanf(s, "R_CHAR_%c", &r_char))
{
- /* Find the end of this entry */
- for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
+ /* Limited to 5 races */
+ if (r_char_number >= 5) continue;
- /* Nuke and skip any dividers */
- if (*t)
- {
- *t++ = '\0';
- while (*t == ' ' || *t == '|') t++;
- }
+ /* Extract a "frequency" */
+ d_ptr->rules[rule_num].r_char[r_char_number++] = r_char;
+ }
- /* Read monster symbols */
- if (1 == sscanf(s, "R_CHAR_%c", &r_char))
+ /* Parse this entry */
+ else {
+ if (0 != grab_one_basic_monster_flag(d_ptr, s, rule_num))
{
- /* Limited to 5 races */
- if (r_char_number >= 5) continue;
-
- /* Extract a "frequency" */
- d_ptr->rules[rule_num].r_char[r_char_number++] = r_char;
-
- /* Start at next entry */
- s = t;
-
- /* Continue */
- continue;
+ return (5);
}
-
- /* Parse this entry */
- if (0 != grab_one_basic_monster_flag(d_ptr, s, rule_num)) return (5);
-
- /* Start the next entry */
- s = t;
}
/* Next... */
@@ -7514,24 +7070,12 @@ errr init_d_info_txt(FILE *fp)
/* Process 'S' for "Spell Flags" (multiple lines) */
if (buf[0] == 'S')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_spell_monster_flag(d_ptr, s, rule_num)) return (5);
+ s = buf + 2;
- /* Start the next entry */
- s = t;
+ /* Parse this entry */
+ if (0 != grab_one_spell_monster_flag(d_ptr, s, rule_num))
+ {
+ return (5);
}
/* Next... */
@@ -7599,7 +7143,7 @@ errr init_st_info_txt(FILE *fp)
{
int i = 0, item_idx = 0;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
store_info_type *st_ptr = NULL;
@@ -7763,25 +7307,7 @@ errr init_st_info_txt(FILE *fp)
/* Process 'F' for "store Flags" (multiple lines) */
if (buf[0] == 'F')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
- {
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_store_flag(st_ptr, s)) return (5);
-
- /* Start the next entry */
- s = t;
- }
+ if (0 != grab_one_store_flag(st_ptr, buf + 2)) return (5);
/* Next... */
continue;
@@ -7957,7 +7483,7 @@ errr init_ow_info_txt(FILE *fp)
{
int i;
char buf[1024];
- char *s, *t;
+ char *s;
/* Current entry */
owner_type *ow_ptr = NULL;
@@ -8060,24 +7586,9 @@ errr init_ow_info_txt(FILE *fp)
/* Process 'L' for "Liked races/classes" (multiple lines) */
if (buf[0] == 'L')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_race_flag(ow_ptr, STORE_LIKED, buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_flag(ow_ptr, STORE_LIKED, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */
@@ -8086,24 +7597,9 @@ errr init_ow_info_txt(FILE *fp)
/* Process 'H' for "Hated races/classes" (multiple lines) */
if (buf[0] == 'H')
{
- /* Parse every entry */
- for (s = buf + 2; *s; )
+ if (0 != grab_one_race_flag(ow_ptr, STORE_HATED, buf + 2))
{
- /* 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++;
- }
-
- /* Parse this entry */
- if (0 != grab_one_race_flag(ow_ptr, STORE_HATED, s)) return (5);
-
- /* Start the next entry */
- s = t;
+ return (5);
}
/* Next... */