summaryrefslogtreecommitdiff
path: root/src/init1.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-10-05 18:45:08 +0200
committerBardur Arantsson <bardur@scientician.net>2016-10-05 18:45:08 +0200
commitdd76070a7d8676a5f13dcc91fc7ed2eb2639d9df (patch)
treef7ac9326989fbca5701fd3c3b45e77fda7bc3552 /src/init1.cc
parent616954ca62b114793735b8b5a888714e1263bdc3 (diff)
Move ab_info into GameEditData
Diffstat (limited to 'src/init1.cc')
-rw-r--r--src/init1.cc69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/init1.cc b/src/init1.cc
index 658cf8e2..977bad9a 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -3279,9 +3279,9 @@ errr init_s_info_txt(FILE *fp)
*/
errr init_ab_info_txt(FILE *fp)
{
- int i, z;
+ auto &ab_info = game->edit_data.ab_info;
+
char buf[1024];
- char *s;
/* Current entry */
ability_type *ab_ptr = NULL;
@@ -3310,7 +3310,7 @@ errr init_ab_info_txt(FILE *fp)
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf + 2, ':');
+ char *s = strchr(buf + 2, ':');
/* Verify that colon */
if (!s) return (1);
@@ -3322,16 +3322,13 @@ errr init_ab_info_txt(FILE *fp)
if (!*s) return (1);
/* Get the index */
- i = atoi(buf + 2);
-
- /* Verify information */
- if (i >= max_ab_idx) return (2);
+ int i = atoi(buf + 2);
/* Save the index */
error_idx = i;
/* Point at the "info" */
- ab_ptr = &ab_info[i];
+ ab_ptr = &expand_to_fit_index(ab_info, i);
/* Copy name */
assert(!ab_ptr->name);
@@ -3339,13 +3336,13 @@ errr init_ab_info_txt(FILE *fp)
/* Init */
ab_ptr->action_mkey = 0;
- for (z = 0; z < 10; z++)
+ for (std::size_t z = 0; z < 10; z++)
{
ab_ptr->skills[z] = -1;
ab_ptr->need_abilities[z] = -1;
ab_ptr->forbid_abilities[z] = -1;
}
- for (z = 0; z < 6; z++)
+ for (std::size_t z = 0; z < 6; z++)
{
ab_ptr->stat[z] = -1;
}
@@ -3361,7 +3358,7 @@ errr init_ab_info_txt(FILE *fp)
if (buf[0] == 'D')
{
/* Acquire the text */
- s = buf + 2;
+ char const *s = buf + 2;
/* Append description */
if (!ab_ptr->desc)
@@ -3383,7 +3380,7 @@ errr init_ab_info_txt(FILE *fp)
char *txt;
/* Acquire the text */
- s = buf + 2;
+ char *s = buf + 2;
if (NULL == (txt = strchr(s, ':'))) return (1);
*txt = '\0';
@@ -3438,8 +3435,14 @@ errr init_ab_info_txt(FILE *fp)
if (skill == -1) return (1);
+ std::size_t z;
for (z = 0; z < 10; z++)
- if (ab_ptr->skills[z] == -1) break;
+ {
+ if (ab_ptr->skills[z] == -1)
+ {
+ break;
+ }
+ }
if (z < 10)
{
@@ -3454,20 +3457,14 @@ errr init_ab_info_txt(FILE *fp)
/* Process 'a' for "needed ability" */
if (buf[0] == 'a')
{
- s16b ab;
-
- ab = find_ability(buf + 2);
-
- if (ab == -1) return (1);
-
- for (z = 0; z < 10; z++)
- if (ab_ptr->need_abilities[z] == -1) break;
-
- if (z < 10)
+ s16b ab = find_ability(buf + 2);
+ if (ab == -1)
{
- ab_ptr->need_abilities[z] = ab;
+ return (1);
}
+ ab_ptr->need_abilities.push_back(ab);
+
/* Next... */
continue;
}
@@ -3521,15 +3518,29 @@ errr init_ab_info_txt(FILE *fp)
if ((ab1 == -1) || (ab2 == -1)) return (1);
+ std::size_t z;
+
for (z = 0; z < 10; z++)
- if (ab_info[ab1].forbid_abilities[z] == -1) break;
+ {
+ if (ab_info[ab1].forbid_abilities[z] == -1)
+ {
+ break;
+ }
+ }
+
if (z < 10)
{
ab_info[ab1].forbid_abilities[z] = ab2;
}
for (z = 0; z < 10; z++)
- if (ab_info[ab2].forbid_abilities[z] == -1) break;
+ {
+ if (ab_info[ab2].forbid_abilities[z] == -1)
+ {
+ break;
+ }
+ }
+
if (z < 10)
{
ab_info[ab2].forbid_abilities[z] = ab1;
@@ -6901,12 +6912,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst
if (max_s_idx > MAX_SKILLS) return (1);
}
- /* Maximum ab_idx */
- else if (zz[0][0] == 'b')
- {
- max_ab_idx = atoi(zz[1]);
- }
-
/* Maximum k_idx */
else if (zz[0][0] == 'K')
{