summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:58 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:58 +0100
commit58e8024f17446bf3b1a36985d746f6de330874c0 (patch)
tree59ee37337149de5009a9e036e86bdeeb1e8d4663 /src
parente3405ca03eebafa60e773812c4f12fed7f4805db (diff)
Remove s_head, s_name, s_text
Diffstat (limited to 'src')
-rw-r--r--src/externs.h3
-rw-r--r--src/init1.cc58
-rw-r--r--src/init2.cc13
-rw-r--r--src/skills.cc39
-rw-r--r--src/squelch/condition.cc6
-rw-r--r--src/types.h7
-rw-r--r--src/variable.cc3
-rw-r--r--src/wizard1.cc2
8 files changed, 42 insertions, 89 deletions
diff --git a/src/externs.h b/src/externs.h
index 7b8540f8..3c69928c 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -313,10 +313,7 @@ extern artifact_select_flag *a_select_flags;
extern ability_type *ab_info;
-extern header *s_head;
extern skill_type *s_info;
-extern char *s_name;
-extern char *s_text;
extern vault_type *v_info;
extern header *f_head;
diff --git a/src/init1.cc b/src/init1.cc
index 76c33e9a..109ec2be 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -5627,7 +5627,7 @@ errr init_s_info_txt(FILE *fp, char *buf)
i = atoi(buf + 2);
/* Verify information */
- if (i >= s_head->info_num) return (2);
+ if (i >= max_s_idx) return (2);
/* Save the index */
error_idx = i;
@@ -5635,17 +5635,9 @@ errr init_s_info_txt(FILE *fp, char *buf)
/* Point at the "info" */
s_ptr = &s_info[i];
- /* Hack -- Verify space */
- if (s_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7);
-
- /* Advance and Save the name index */
- if (!s_ptr->name) s_ptr->name = ++s_head->name_size;
-
- /* Append chars to the name */
- strcpy(s_name + s_head->name_size, s);
-
- /* Advance the index */
- s_head->name_size += strlen(s);
+ /* Copy name */
+ assert(!s_ptr->name);
+ s_ptr->name = my_strdup(s);
/* Init */
s_ptr->action_mkey = 0;
@@ -5669,34 +5661,21 @@ errr init_s_info_txt(FILE *fp, char *buf)
/* Acquire the text */
s = buf + 2;
- /* Hack -- Verify space */
- if (s_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7);
-
- /* Advance and Save the text index */
+ /* Description */
if (!s_ptr->desc)
{
- s_ptr->desc = ++s_head->text_size;
-
- /* Append chars to the name */
- strcpy(s_text + s_head->text_size, s);
-
- /* Advance the index */
- s_head->text_size += strlen(s);
+ s_ptr->desc = my_strdup(s);
}
else
{
- /* Append chars to the name */
- strcpy(s_text + s_head->text_size, format("\n%s", s));
-
- /* Advance the index */
- s_head->text_size += strlen(s) + 1;
+ strappend(&s_ptr->desc, format("\n%s", s));
}
/* Next... */
continue;
}
- /* Process 'A' for "Activation Description" */
+ /* Process 'A' for "Activation Description" (one line only) */
if (buf[0] == 'A')
{
char *txt;
@@ -5708,19 +5687,13 @@ errr init_s_info_txt(FILE *fp, char *buf)
*txt = '\0';
txt++;
- /* Hack -- Verify space */
- if (s_head->text_size + strlen(txt) + 8 > FAKE_TEXT_SIZE) return (7);
+ /* Copy action description */
+ assert(!s_ptr->action_desc);
+ s_ptr->action_desc = my_strdup(txt);
- /* Advance and Save the text index */
- if (!s_ptr->action_desc) s_ptr->action_desc = ++s_head->text_size;
-
- /* Append chars to the name */
- strcpy(s_text + s_head->text_size, txt);
+ /* Copy mkey index */
s_ptr->action_mkey = atoi(s);
- /* Advance the index */
- s_head->text_size += strlen(txt);
-
/* Next... */
continue;
}
@@ -5794,16 +5767,9 @@ errr init_s_info_txt(FILE *fp, char *buf)
return (6);
}
-
- /* Complete the "name" and "text" sizes */
- ++s_head->name_size;
- ++s_head->text_size;
-
-
/* No version yet */
if (!okay) return (2);
-
/* Success */
return (0);
}
diff --git a/src/init2.cc b/src/init2.cc
index 11505edb..126d9934 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -530,19 +530,8 @@ static errr init_s_info(void)
/* General buffer */
char buf[1024];
-
- /*** Make the "header" ***/
- s_head = make_header(max_s_idx);
-
-
- /*** Make the fake arrays ***/
-
/* Allocate the "s_info" array */
- s_info = make_array<skill_type>(s_head->info_num);
-
- /* Hack -- make "fake" arrays */
- s_name = make_array<char>(FAKE_NAME_SIZE);
- s_text = make_array<char>(FAKE_TEXT_SIZE);
+ s_info = make_array<skill_type>(max_s_idx);
/*** Load the ascii template file ***/
diff --git a/src/skills.cc b/src/skills.cc
index 3ed64d17..a31b3fcd 100644
--- a/src/skills.cc
+++ b/src/skills.cc
@@ -102,10 +102,9 @@ s16b find_skill(cptr name)
/* Scan skill list */
for (i = 1; i < max_s_idx; i++)
{
- /* The name matches */
- if (s_info[i].name > 0)
+ if (s_info[i].name && streq(s_info[i].name, name))
{
- if (streq(s_info[i].name + s_name, name)) return (i);
+ return (i);
}
}
@@ -120,8 +119,9 @@ s16b find_skill_i(cptr name)
for (i = 1; i < max_s_idx; i++)
{
/* The name matches */
- if (s_info[i].name > 0) {
- if (iequals(s_info[i].name + s_name, name)) return (i);
+ if (s_info[i].name && iequals(s_info[i].name, name))
+ {
+ return (i);
}
}
@@ -258,11 +258,11 @@ void dump_skills(FILE *fff)
if (!has_child(i))
{
- strcat(buf, format(" . %s", s_info[i].name + s_name));
+ strcat(buf, format(" . %s", s_info[i].name));
}
else
{
- strcat(buf, format(" - %s", s_info[i].name + s_name));
+ strcat(buf, format(" - %s", s_info[i].name));
}
fprintf(fff, "%-49s%s%06.3f [%05.3f]",
@@ -292,7 +292,7 @@ void print_skills(int table[MAX_SKILLS][2], int max, int sel, int start)
display_message(0, 1, strlen(keys), TERM_WHITE, keys);
c_prt((p_ptr->skill_points) ? TERM_L_BLUE : TERM_L_RED,
format("Skill points left: %d", p_ptr->skill_points), 2, 0);
- print_desc_aux(s_info[table[sel][0]].desc + s_text, 3, 0);
+ print_desc_aux(s_info[table[sel][0]].desc, 3, 0);
for (j = start; j < start + (hgt - 7); j++)
{
@@ -318,17 +318,17 @@ void print_skills(int table[MAX_SKILLS][2], int max, int sel, int start)
}
if (!has_child(i))
{
- c_prt(color, format("%c.%c%s", deb, end, s_info[i].name + s_name),
+ c_prt(color, format("%c.%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
else if (s_info[i].dev)
{
- c_prt(color, format("%c-%c%s", deb, end, s_info[i].name + s_name),
+ c_prt(color, format("%c-%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
else
{
- c_prt(color, format("%c+%c%s", deb, end, s_info[i].name + s_name),
+ c_prt(color, format("%c+%c%s", deb, end, s_info[i].name),
j + 7 - start, table[j][1] * 4);
}
c_prt(color,
@@ -558,7 +558,7 @@ void do_cmd_skill()
/* Contextual help */
if (c == '?')
{
- help_skill(s_info[table[sel][0]].name + s_name);
+ help_skill(s_info[table[sel][0]].name);
}
/* Handle boundaries and scrolling */
@@ -805,7 +805,7 @@ static int do_cmd_activate_skill_aux()
}
if (next) continue;
- p.push_back(std::make_tuple(s_text + s_info[i].action_desc,
+ p.push_back(std::make_tuple(s_info[i].action_desc,
s_info[i].action_mkey));
}
}
@@ -1352,7 +1352,12 @@ void do_get_new_skill()
}
skl[i] = s_idx;
- items.push_back(format("%-40s: +%02ld.%03ld value, +%01d.%03d modifier", s_ptr->name + s_name, val[i] / SKILL_STEP, val[i] % SKILL_STEP, mod[i] / SKILL_STEP, mod[i] % SKILL_STEP));
+ items.push_back(format("%-40s: +%02ld.%03ld value, +%01d.%03d modifier",
+ s_ptr->name,
+ val[i] / SKILL_STEP,
+ val[i] % SKILL_STEP,
+ mod[i] / SKILL_STEP,
+ mod[i] % SKILL_STEP));
}
while (TRUE)
@@ -1395,7 +1400,7 @@ void do_get_new_skill()
/* Prepare prompt */
msg = format("This skill is mutually exclusive with "
"at least %s, continue?",
- s_info[oppose_skill].name + s_name);
+ s_info[oppose_skill].name);
/* The player rejected the choice */
if (!get_check(msg)) continue;
@@ -1407,12 +1412,12 @@ void do_get_new_skill()
if (mod[res])
{
msg_format("You can now learn the %s skill.",
- s_ptr->name + s_name);
+ s_ptr->name);
}
else
{
msg_format("Your knowledge of the %s skill increases.",
- s_ptr->name + s_name);
+ s_ptr->name);
}
break;
}
diff --git a/src/squelch/condition.cc b/src/squelch/condition.cc
index e187157b..e608300d 100644
--- a/src/squelch/condition.cc
+++ b/src/squelch/condition.cc
@@ -758,10 +758,8 @@ std::shared_ptr<Condition> SkillCondition::from_json(json_t *j)
void SkillCondition::write_tree(TreePrinter *p, Cursor *, uint8_t ecol, uint8_t bcol) const
{
- cptr skill_name = s_info[m_skill_idx].name + s_name;
-
p->write(ecol, "Your skill in ");
- p->write(bcol, skill_name);
+ p->write(bcol, s_info[m_skill_idx].name);
p->write(ecol, " is from ");
p->write(TERM_WHITE, format("%d", (int) m_min));
p->write(ecol, " to ");
@@ -772,7 +770,7 @@ void SkillCondition::write_tree(TreePrinter *p, Cursor *, uint8_t ecol, uint8_t
void SkillCondition::to_json(json_t *j) const
{
json_object_set_new(j, "name",
- json_string(s_info[m_skill_idx].name + s_name));
+ json_string(s_info[m_skill_idx].name));
json_object_set_new(j, "min",
json_integer(m_min));
json_object_set_new(j, "max",
diff --git a/src/types.h b/src/types.h
index 1e6103cf..2c4bd505 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2439,9 +2439,10 @@ struct cli_comm
typedef struct skill_type skill_type;
struct skill_type
{
- u32b name; /* Name */
- u32b desc; /* Description */
- u32b action_desc; /* Action Description */
+ const char *name; /* Name */
+ char *desc; /* Description */
+
+ const char *action_desc; /* Action Description */
s16b action_mkey; /* Action do to */
diff --git a/src/variable.cc b/src/variable.cc
index 2aa3c358..d7352054 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -660,10 +660,7 @@ ability_type *ab_info;
/*
* Player skills arrays
*/
-header *s_head;
skill_type *s_info;
-char *s_name;
-char *s_text;
/*
* Player race arrays
diff --git a/src/wizard1.cc b/src/wizard1.cc
index f6790ce4..818cbe99 100644
--- a/src/wizard1.cc
+++ b/src/wizard1.cc
@@ -2566,7 +2566,7 @@ void print_magic_powers( magic_power *powers, int max_powers, void(*power_info)(
/* Dump the header line */
spoiler_blanklines(2);
- sprintf(buf, "%s", s_info[skill_num].name + s_name);
+ sprintf(buf, "%s", s_info[skill_num].name);
spoiler_underline(buf);
spoiler_blanklines(1);