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
commit3bfa6a0e2cba6b4fc8f53dac1e987c95fe7ed93c (patch)
tree634ca5f034290d081f240cfb4f75b33ffa7409d5 /src
parent3f59d3d407cd743f4e4b27791c4fe13785f8669d (diff)
Remove c_head, c_name, c_text
Diffstat (limited to 'src')
-rw-r--r--src/birth.cc38
-rw-r--r--src/dungeon.cc2
-rw-r--r--src/externs.h3
-rw-r--r--src/files.cc15
-rw-r--r--src/init1.cc100
-rw-r--r--src/init2.cc11
-rw-r--r--src/notes.cc5
-rw-r--r--src/squelch/condition.cc2
-rw-r--r--src/traps.cc6
-rw-r--r--src/types.h13
-rw-r--r--src/variable.cc3
-rw-r--r--src/xtra1.cc4
12 files changed, 71 insertions, 131 deletions
diff --git a/src/birth.cc b/src/birth.cc
index a4ad1d3f..a3e49fdb 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -1048,7 +1048,7 @@ static void player_outfit_spellbook(cptr spell_name)
static void player_outfit(void)
{
int i;
- cptr class_name = spp_ptr->title + c_name;
+ cptr class_name = spp_ptr->title;
cptr subrace_name = rmp_ptr->title + rmp_name;
/*
@@ -1253,8 +1253,6 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
char buf[80];
- cptr str;
-
/* Clean up */
clear_from(12);
@@ -1266,7 +1264,6 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
/* Analyze */
p_ptr->pclass = classes[n];
cp_ptr = &class_info[p_ptr->pclass];
- str = cp_ptr->title + c_name;
if (sel == n)
{
@@ -1276,14 +1273,14 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
/* Display */
strnfmt(buf, 80, "%c%c%c %s%s", p1,
- (n <= 25) ? I2A(n) : I2D(n - 26), p2, str, mod);
+ (n <= 25) ? I2A(n) : I2D(n - 26), p2, cp_ptr->title, mod);
/* Print some more info */
if (sel == n)
{
std::string desc;
- desc += (cp_ptr->desc + c_text);
+ desc += cp_ptr->desc;
if (cp_ptr->flags1 & PR1_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
@@ -1317,8 +1314,6 @@ int dump_specs(int sel)
char buf[80];
- cptr str;
-
/* Clean up */
clear_from(12);
@@ -1332,7 +1327,6 @@ int dump_specs(int sel)
/* Analyze */
p_ptr->pspec = n;
spp_ptr = &class_info[p_ptr->pclass].spec[p_ptr->pspec];
- str = spp_ptr->title + c_name;
if (sel == n)
{
@@ -1341,14 +1335,14 @@ int dump_specs(int sel)
}
/* Display */
- strnfmt(buf, 80, "%c%c%c %s", p1, I2A(n), p2, str);
+ strnfmt(buf, 80, "%c%c%c %s", p1, I2A(n), p2, spp_ptr->title);
/* Print some more info */
if (sel == n)
{
std::string desc;
- desc += (spp_ptr->desc + c_text);
+ desc += spp_ptr->desc;
if (spp_ptr->flags1 & PR1_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
@@ -1565,8 +1559,6 @@ static bool_ player_birth_aux_ask()
u32b restrictions[2];
- cptr str;
-
char c;
char p2 = ')';
@@ -1653,10 +1645,9 @@ static bool_ player_birth_aux_ask()
/* Analyze */
p_ptr->psex = n;
sp_ptr = &sex_info[p_ptr->psex];
- str = sp_ptr->title;
/* Display */
- strnfmt(buf, 200, "%c%c %s", I2A(n), p2, str);
+ strnfmt(buf, 200, "%c%c %s", I2A(n), p2, sp_ptr->title);
put_str(buf, 21 + (n / 5), 2 + 15 * (n % 5));
}
@@ -1689,10 +1680,9 @@ static bool_ player_birth_aux_ask()
/* Set sex */
p_ptr->psex = k;
sp_ptr = &sex_info[p_ptr->psex];
- str = sp_ptr->title;
/* Display */
- c_put_str(TERM_L_BLUE, str, 3, 9);
+ c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
/* Clean up */
clear_from(15);
@@ -1784,10 +1774,9 @@ static bool_ player_birth_aux_ask()
/* Set race */
p_ptr->prace = k;
rp_ptr = &race_info[p_ptr->prace];
- str = rp_ptr->title + rp_name;
/* Display */
- c_put_str(TERM_L_BLUE, str, 4, 9);
+ c_put_str(TERM_L_BLUE, rp_ptr->title + rp_name, 4, 9);
/* Get a random name */
if (!do_quick_start) create_random_name(p_ptr->prace, player_name);
@@ -2010,7 +1999,7 @@ static bool_ player_birth_aux_ask()
if ((k >= 0) && (k < n)) break;
if (c == '?')
{
- help_class(class_info[class_types[sel]].title + c_name);
+ help_class(class_info[class_types[sel]].title);
}
else if (c == '=')
{
@@ -2092,7 +2081,7 @@ static bool_ player_birth_aux_ask()
if ((k >= 0) && (k < n)) break;
if (c == '?')
{
- help_class(class_info[p_ptr->pclass].spec[sel].title + c_name);
+ help_class(class_info[p_ptr->pclass].spec[sel].title);
}
else if (c == '=')
{
@@ -2138,10 +2127,9 @@ static bool_ player_birth_aux_ask()
}
cp_ptr = &class_info[p_ptr->pclass];
spp_ptr = &class_info[p_ptr->pclass].spec[p_ptr->pspec];
- str = spp_ptr->title + c_name;
/* Display */
- c_put_str(TERM_L_BLUE, str, 5, 9);
+ c_put_str(TERM_L_BLUE, spp_ptr->title, 5, 9);
/* Clean up */
clear_from(15);
@@ -2736,7 +2724,7 @@ static bool_ player_birth_aux_auto()
c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
strnfmt(buf, 80, "%s", get_player_race_name(p_ptr->prace, p_ptr->pracem));
c_put_str(TERM_L_BLUE, buf, 4, 9);
- c_put_str(TERM_L_BLUE, spp_ptr->title + c_name, 5, 9);
+ c_put_str(TERM_L_BLUE, spp_ptr->title, 5, 9);
/* Label stats */
put_str("STR:", 2 + A_STR, 61);
@@ -3513,7 +3501,7 @@ void save_savefile_names()
fprintf(fff, "%s@%c%s@%s, the %s %s is %s\n", game_module,
(death) ? '0' : '1', player_base, player_name,
get_player_race_name(p_ptr->prace, p_ptr->pracem),
- spp_ptr->title + c_name,
+ spp_ptr->title,
(!death) ? "alive" : "dead");
for (i = 0; i < max; i++)
diff --git a/src/dungeon.cc b/src/dungeon.cc
index 370e48c9..020effb4 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -5004,7 +5004,7 @@ static void load_all_pref_files(void)
process_pref_file(buf);
/* Access the "class" pref file */
- sprintf(buf, "%s.prf", spp_ptr->title + c_name);
+ sprintf(buf, "%s.prf", spp_ptr->title);
/* Process that file */
process_pref_file(buf);
diff --git a/src/externs.h b/src/externs.h
index 86e3db0f..127ea0c8 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -332,10 +332,7 @@ extern randart_gen_type ra_gen[30];
extern monster_race *r_info;
extern monster_ego *re_info;
extern dungeon_info_type *d_info;
-extern header *c_head;
extern player_class *class_info;
-extern char *c_name;
-extern char *c_text;
extern meta_class_type *meta_class_info;
extern header *rp_head;
extern player_race *race_info;
diff --git a/src/files.cc b/src/files.cc
index 396883f5..005b4ed8 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -869,7 +869,7 @@ static cptr process_pref_file_expr(char **sp, char *fp)
/* Class */
else if (streq(b + 1, "CLASS"))
{
- v = spp_ptr->title + c_name;
+ v = spp_ptr->title;
}
/* Player */
@@ -2182,7 +2182,7 @@ void display_player(int mode)
c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
sprintf(buf, "%s", get_player_race_name(p_ptr->prace, p_ptr->pracem));
c_put_str(TERM_L_BLUE, buf, 4, 9);
- c_put_str(TERM_L_BLUE, spp_ptr->title + c_name, 5, 9);
+ c_put_str(TERM_L_BLUE, spp_ptr->title, 5, 9);
c_put_str(TERM_L_BLUE, r_ptr->name, 6, 9);
c_put_str(TERM_L_BLUE, deity_info[p_ptr->pgod].name, 7, 9);
@@ -4436,7 +4436,7 @@ static void print_tomb(void)
/* Normal */
else
{
- p = cp_ptr->titles[(p_ptr->lev - 1) / 5] + c_text;
+ p = cp_ptr->titles[(p_ptr->lev - 1) / 5];
}
center_string(buf, player_name);
@@ -4449,7 +4449,7 @@ static void print_tomb(void)
put_str(buf, 8, 11);
- center_string(buf, spp_ptr->title + c_name);
+ center_string(buf, spp_ptr->title);
put_str(buf, 10, 11);
(void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
@@ -4764,8 +4764,11 @@ static void display_scores_aux(int highscore_fd, int from, int to, int note, hig
/* Dump some info */
sprintf(out_val, "%3d.%9s %s the %s %s, Level %d",
- place, the_score.pts, the_score.who,
- get_player_race_name(pr, ps), class_info[pc].spec[pcs].title + c_name,
+ place,
+ the_score.pts,
+ the_score.who,
+ get_player_race_name(pr, ps),
+ class_info[pc].spec[pcs].title,
clev);
/* Append a "maximum level" */
diff --git a/src/init1.cc b/src/init1.cc
index 8cf7c3f1..aac41a8b 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -1624,7 +1624,7 @@ static errr grab_one_class_flag(u32b *choice, cptr what)
cptr s;
/* Scan classes flags */
- for (i = 0; i < max_c_idx && (s = class_info[i].title + c_name); i++)
+ for (i = 0; i < max_c_idx && (s = class_info[i].title); i++)
{
if (streq(what, s))
{
@@ -1855,8 +1855,6 @@ errr init_player_info_txt(FILE *fp, char *buf)
rp_head->text_size = 0;
rmp_head->name_size = 0;
rmp_head->text_size = 0;
- c_head->name_size = 0;
- c_head->text_size = 0;
/* Init general skills */
for (z = 0; z < MAX_SKILLS; z++)
@@ -2770,7 +2768,7 @@ errr init_player_info_txt(FILE *fp, char *buf)
if (i < error_idx) return (4);
/* Verify information */
- if (i >= c_head->info_num) return (2);
+ if (i >= max_c_idx) return (2);
/* Save the index */
error_idx = i;
@@ -2778,18 +2776,11 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Point at the "info" */
c_ptr = &class_info[i];
- /* Hack -- Verify space */
- if (c_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7);
-
- /* Advance and Save the name index */
- if (!c_ptr->title) c_ptr->title = ++c_head->name_size;
-
- /* Append chars to the name */
- strcpy(c_name + c_head->name_size, s);
-
- /* Advance the index */
- c_head->name_size += strlen(s);
+ /* Copy name */
+ assert(!c_ptr->title);
+ c_ptr->title = my_strdup(s);
+ /* Initialize */
c_ptr->powers[0] = c_ptr->powers[1] = c_ptr->powers[2] = c_ptr->powers[3] = -1;
powers = 0;
lev = 1;
@@ -2812,43 +2803,31 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Acquire the text */
s = buf + 6;
- /* Hack -- Verify space */
- if (c_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7);
-
switch (buf[4])
{
- case '0':
- /* Advance and Save the text index */
+ case '0': /* Class description */
if (!c_ptr->desc)
{
- c_ptr->desc = ++c_head->text_size;
- /* Append chars to the name */
- strcpy(c_text + c_head->text_size, s);
-
- /* Advance the index */
- c_head->text_size += strlen(s);
+ c_ptr->desc = my_strdup(s);
}
else
{
- /* Append chars to the name */
- strcpy(c_text + c_head->text_size, format("\n%s", s));
-
- /* Advance the index */
- c_head->text_size += strlen(s) + 1;
+ strappend(&c_ptr->desc, format("\n%s", s));
}
break;
- case '1':
- /* Advance and Save the text index */
- c_ptr->titles[tit_idx++] = ++c_head->text_size;
- /* Append chars to the name */
- strcpy(c_text + c_head->text_size, s);
+ case '1': /* Class title */
+ /* Copy */
+ assert(!c_ptr->titles[tit_idx]);
+ c_ptr->titles[tit_idx] = my_strdup(s);
+
+ /* Go to next title in array */
+ tit_idx++;
- /* Advance the index */
- c_head->text_size += strlen(s);
break;
- default:
+
+ default: /* Unknown */
return (6);
break;
}
@@ -3189,18 +3168,11 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Point at the "info" */
s_ptr = &c_ptr->spec[spec_idx];
- /* Hack -- Verify space */
- if (c_head->name_size + strlen(s) + 8 > FAKE_NAME_SIZE) return (7);
-
- /* Advance and Save the name index */
- if (!s_ptr->title) s_ptr->title = ++c_head->name_size;
-
- /* Append chars to the name */
- strcpy(c_name + c_head->name_size, s);
-
- /* Advance the index */
- c_head->name_size += strlen(s);
+ /* Copy title */
+ assert(!s_ptr->title);
+ s_ptr->title = my_strdup(s);
+ /* Initialize */
s_ptr->obj_num = 0;
cur_ab = 0;
for (z = 0; z < 10; z++)
@@ -3216,27 +3188,13 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Acquire the text */
s = buf + 6;
- /* Hack -- Verify space */
- if (c_head->text_size + strlen(s) + 8 > FAKE_TEXT_SIZE) return (7);
-
- /* Advance and Save the text index */
if (!s_ptr->desc)
{
- s_ptr->desc = ++c_head->text_size;
-
- /* Append chars to the name */
- strcpy(c_text + c_head->text_size, s);
-
- /* Advance the index */
- c_head->text_size += strlen(s);
+ s_ptr->desc = my_strdup(s);
}
else
{
- /* Append chars to the name */
- strcpy(c_text + c_head->text_size, format("\n%s", s));
-
- /* Advance the index */
- c_head->text_size += strlen(s) + 1;
+ strappend(&s_ptr->desc, format("\n%s", s));
}
/* Next... */
@@ -3430,7 +3388,10 @@ errr init_player_info_txt(FILE *fp, char *buf)
/* Find it in the list */
for (i = 0; i < max_c_idx; i++)
{
- if (iequals(s, class_info[i].title + c_name)) break;
+ if (class_info[i].title && iequals(s, class_info[i].title))
+ {
+ break;
+ }
}
if (i == max_c_idx) return (6);
@@ -3450,8 +3411,7 @@ errr init_player_info_txt(FILE *fp, char *buf)
++rp_head->text_size;
++rmp_head->name_size;
++rmp_head->text_size;
- ++c_head->name_size;
- ++c_head->text_size;
+
/* No version yet */
if (!okay) return (2);
@@ -11448,7 +11408,7 @@ static cptr process_dungeon_file_expr(char **sp, char *fp)
/* Class */
else if (streq(b + 1, "CLASS"))
{
- v = cp_ptr->title + c_name;
+ v = cp_ptr->title;
}
/* Player */
diff --git a/src/init2.cc b/src/init2.cc
index 17576e8a..212a5a34 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -980,11 +980,6 @@ static errr init_player_info(void)
/*** Make the header ***/
rmp_head = make_header(max_rmp_idx);
-
- /*** Make the header ***/
- c_head = make_header(max_c_idx);
-
-
/*** Make the fake arrays ***/
/* Allocate the "rp_info" array */
@@ -1002,11 +997,7 @@ static errr init_player_info(void)
rmp_text = make_array<char>(FAKE_TEXT_SIZE);
/* Allocate the "c_info" array */
- class_info = make_array<player_class>(c_head->info_num);
-
- /* Hack -- make "fake" arrays */
- c_name = make_array<char>(FAKE_NAME_SIZE);
- c_text = make_array<char>(FAKE_TEXT_SIZE);
+ class_info = make_array<player_class>(max_c_idx);
/* Allocate the "bg" array */
bg = make_array<hist_type>(max_bg_idx);
diff --git a/src/notes.cc b/src/notes.cc
index ecc64d43..7eb825dc 100644
--- a/src/notes.cc
+++ b/src/notes.cc
@@ -134,7 +134,10 @@ void add_note_type(int note_number)
char player[100];
/* Build the string containing the player information */
- sprintf(player, "the %s %s", get_player_race_name(p_ptr->prace, p_ptr->pracem), class_info[p_ptr->pclass].spec[p_ptr->pspec].title + c_name);
+ sprintf(player,
+ "the %s %s",
+ get_player_race_name(p_ptr->prace, p_ptr->pracem),
+ class_info[p_ptr->pclass].spec[p_ptr->pspec].title);
/* Add in "character start" information */
sprintf(buf,
diff --git a/src/squelch/condition.cc b/src/squelch/condition.cc
index 97f9fac6..1df22328 100644
--- a/src/squelch/condition.cc
+++ b/src/squelch/condition.cc
@@ -581,7 +581,7 @@ void SubraceCondition::to_json(json_t *j) const
bool ClassCondition::is_match(object_type *o_ptr) const
{
- return boost::algorithm::iequals(m_class, spp_ptr->title + c_name);
+ return boost::algorithm::iequals(m_class, spp_ptr->title);
}
std::shared_ptr<Condition> ClassCondition::from_json(json_t *j)
diff --git a/src/traps.cc b/src/traps.cc
index 5222fcd1..6410e76c 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -876,7 +876,7 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
{
/* no sense saying this unless you never have mana */
msg_format("Suddenly you feel glad you're a mere %s",
- spp_ptr->title + c_name);
+ spp_ptr->title);
}
else
{
@@ -1885,7 +1885,7 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
{
if (p_ptr->pgod == 0)
{
- msg_format("Suddenly you feel glad you're a mere %s", spp_ptr->title + c_name);
+ msg_format("Suddenly you feel glad you're a mere %s", spp_ptr->title);
}
else
{
@@ -1903,7 +1903,7 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
{
if (p_ptr->pgod == 0)
{
- msg_format("Suddenly you feel glad you're a mere %s", spp_ptr->title + c_name);
+ msg_format("Suddenly you feel glad you're a mere %s", spp_ptr->title);
}
else
{
diff --git a/src/types.h b/src/types.h
index e51690f3..d7ee1245 100644
--- a/src/types.h
+++ b/src/types.h
@@ -1196,8 +1196,8 @@ typedef struct player_spec player_spec;
struct player_spec
{
- s32b title; /* Type of class spec */
- s32b desc; /* Small desc of the class spec */
+ const char *title; /* Type of class spec */
+ char *desc; /* Small desc of the class spec */
char skill_basem[MAX_SKILLS]; /* Mod for value */
u32b skill_base[MAX_SKILLS]; /* value */
@@ -1229,11 +1229,12 @@ typedef struct player_class player_class;
struct player_class
{
- s32b title; /* Type of class */
- s32b desc; /* Small desc of the class */
- s32b titles[PY_MAX_LEVEL / 5];
+ const char *title; /* Type of class */
+ char *desc; /* Small desc of the class */
+ const char *titles[PY_MAX_LEVEL / 5];
+ /* Titles */
- s16b c_adj[6]; /* Class stat modifier */
+ s16b c_adj[6]; /* Class stat modifier */
s16b c_dis; /* class disarming */
s16b c_dev; /* class magic devices */
diff --git a/src/variable.cc b/src/variable.cc
index 4b8a848b..690082a4 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -691,10 +691,7 @@ char *rmp_text;
/*
* Player class arrays
*/
-header *c_head;
player_class *class_info;
-char *c_name;
-char *c_text;
meta_class_type *meta_class_info;
/*
diff --git a/src/xtra1.cc b/src/xtra1.cc
index 1c4acfc8..9e8fface 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -283,7 +283,7 @@ static void prt_title(void)
/* Normal */
else
{
- p = cp_ptr->titles[(p_ptr->lev - 1) / 5] + c_text;
+ p = cp_ptr->titles[(p_ptr->lev - 1) / 5];
}
@@ -1000,7 +1000,7 @@ static void prt_frame(void)
/* Race and Class */
prt_field(rp_ptr->title + rp_name, ROW_RACE, COL_RACE);
- prt_field(spp_ptr->title + c_name, ROW_CLASS, COL_CLASS);
+ prt_field(spp_ptr->title, ROW_CLASS, COL_CLASS);
/* Title */
prt_title();