summaryrefslogtreecommitdiff
path: root/src
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
commit460513b54733dbc3b10274622d960b3c47f60e85 (patch)
tree92e1557c69f62f158c275fb1bf79c2d54eeaee03 /src
parentb329b2fd77e32112a08fc41e1be58b32648225cf (diff)
Remove meta_class_info
We replace it with a single number on the C:N: line which determines the display order of the classes. (That's all that meta_class_info effectively did.)
Diffstat (limited to 'src')
-rw-r--r--src/birth.cc58
-rw-r--r--src/init1.cc140
-rw-r--r--src/init2.cc2
-rw-r--r--src/meta_class_type.hpp11
-rw-r--r--src/meta_class_type_fwd.hpp3
-rw-r--r--src/player_class.hpp2
-rw-r--r--src/variable.cc2
-rw-r--r--src/variable.hpp3
8 files changed, 56 insertions, 165 deletions
diff --git a/src/birth.cc b/src/birth.cc
index bb2f0816..67817673 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -24,7 +24,6 @@
#include "init2.hpp"
#include "mimic.hpp"
#include "messages.hpp"
-#include "meta_class_type.hpp"
#include "modules.hpp"
#include "monster2.hpp"
#include "monster_race.hpp"
@@ -1478,7 +1477,7 @@ static bool_ do_quick_start = FALSE;
static bool_ player_birth_aux_ask()
{
- int i, k, n, v, sel;
+ int k, n, v, sel;
int racem[100], max_racem = 0;
@@ -1787,52 +1786,29 @@ static bool_ player_birth_aux_ask()
}
else
{
- int z;
-
- for (z = 0; z < 2; z++)
+ for (int z = 0; z < 2; z++)
+ {
restrictions[z] = (rp_ptr->choice[z] | rmp_ptr->pclass[z]) & (~rmp_ptr->mclass[z]);
+ }
- if (max_mc_idx > 1)
+ // Get list of all the classes.
+ std::vector<u16b> class_types;
+ for (std::size_t i = 0; i < max_c_idx; i++)
{
- /* Extra info */
- Term_putstr(5, 13, -1, TERM_WHITE,
- "Your 'class' determines various intrinsic abilities and bonuses.");
-
- /* Get a class type */
- for (i = 0; i < max_mc_idx; i++)
- c_put_str(meta_class_info[i].color, format("%c) %s", I2A(i), meta_class_info[i].name), 16 + i, 2);
- while (1)
+ if (class_info[i].title)
{
- strnfmt(buf, 200, "Choose a class type (a-%c), * for random, = for options: ", I2A(max_mc_idx - 1));
- put_str(buf, 15, 2);
- c = inkey();
- if (c == 'Q') quit(NULL);
- if (c == 'S') return (FALSE);
- if (c == '*')
- {
- k = rand_int(max_mc_idx);
- break;
- }
- k = (islower(c) ? A2I(c) : (D2I(c) + 26));
- if ((k >= 0) && (k < max_mc_idx)) break;
- if (c == '?') do_cmd_help();
- else if (c == '=')
- {
- screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
- screen_load();
- }
- else bell();
+ class_types.push_back(i);
}
}
- else
- {
- k = 0;
- }
- clear_from(15);
-
- auto const &class_types = meta_class_info[k].classes;
+ // Sort into display order
+ std::stable_sort(
+ class_types.begin(),
+ class_types.end(),
+ [](auto i, auto j) {
+ return class_info[i].display_order_idx < class_info[j].display_order_idx;
+ }
+ );
/* Count classes */
n = class_types.size();
diff --git a/src/init1.cc b/src/init1.cc
index 086314a2..5867ef5a 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -15,7 +15,6 @@
#include "gods.hpp"
#include "hist_type.hpp"
#include "init2.hpp"
-#include "meta_class_type.hpp"
#include "monster2.hpp"
#include "monster_ego.hpp"
#include "monster_race.hpp"
@@ -55,6 +54,8 @@
#include "z-rand.hpp"
#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <stdlib.h>
using boost::algorithm::iequals;
@@ -925,18 +926,15 @@ static int read_ability(std::vector<player_race_ability_type> *abilities, char *
*/
errr init_player_info_txt(FILE *fp)
{
- int i = 0;
int lev = 1;
int tit_idx = 0;
char buf[1024];
- char *s, *t;
/* Current entry */
player_race *rp_ptr = NULL;
player_race_mod *rmp_ptr = NULL;
player_class *c_ptr = NULL;
player_spec *s_ptr = NULL;
- meta_class_type *mc_ptr = NULL;
/* Just before the first record */
@@ -1003,7 +1001,7 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'R') && (buf[2] == 'N'))
{
/* Find the colon before the name */
- s = strchr(buf + 4, ':');
+ char *s = strchr(buf + 4, ':');
/* Verify that colon */
if (!s) return (1);
@@ -1015,7 +1013,7 @@ errr init_player_info_txt(FILE *fp)
if (!*s) return (1);
/* Get the index */
- i = atoi(buf + 4);
+ int i = atoi(buf + 4);
/* Verify information */
if (i < error_idx) return (4);
@@ -1044,7 +1042,7 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'R') && (buf[2] == 'D'))
{
/* Acquire the text */
- s = buf + 4;
+ char const *s = buf + 4;
if (!rp_ptr->desc)
{
@@ -1113,12 +1111,11 @@ errr init_player_info_txt(FILE *fp)
/* Process 'Z' for "powers" */
if ((buf[0] == 'R') && (buf[2] == 'Z'))
{
- int i;
-
/* Acquire the text */
- s = buf + 4;
+ char const *s = buf + 4;
/* Find it in the list */
+ int i;
for (i = 0; i < POWER_MAX; i++)
{
if (iequals(s, powers_type[i].name)) break;
@@ -1226,7 +1223,7 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'S') && (buf[2] == 'N'))
{
/* Find the colon before the name */
- s = strchr(buf + 4, ':');
+ char *s = strchr(buf + 4, ':');
/* Verify that colon */
if (!s) return (1);
@@ -1238,7 +1235,7 @@ errr init_player_info_txt(FILE *fp)
if (!*s) return (1);
/* Get the index */
- i = atoi(buf + 4);
+ int i = atoi(buf + 4);
/* Verify information */
if (i < error_idx) return (4);
@@ -1266,7 +1263,7 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'S') && (buf[2] == 'D'))
{
/* Acquire the text */
- s = buf + 6;
+ char const *s = buf + 6;
/* Place */
if (buf[4] == 'A')
@@ -1344,12 +1341,11 @@ errr init_player_info_txt(FILE *fp)
/* Process 'Z' for "powers" */
if ((buf[0] == 'S') && (buf[2] == 'Z'))
{
- int i;
-
/* Acquire the text */
- s = buf + 4;
+ char const *s = buf + 4;
/* Find it in the list */
+ int i;
for (i = 0; i < POWER_MAX; i++)
{
if (iequals(s, powers_type[i].name)) break;
@@ -1481,25 +1477,26 @@ errr init_player_info_txt(FILE *fp)
/* Process 'N' for "New/Number/Name" */
if ((buf[0] == 'C') && (buf[2] == 'N'))
{
- /* Find the colon before the name */
- s = strchr(buf + 4, ':');
+ /* Advance beyond prefix */
+ char *s = strchr(buf + 4, ':');
/* Verify that colon */
if (!s) return (1);
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
+ /* Extract the suffix */
+ std::string suffix(s + 1);
+ if (suffix.empty()) return (1);
- /* Paranoia -- require a name */
- if (!*s) return (1);
+ /* Split suffix into fields */
+ std::vector<std::string> fields;
+ boost::algorithm::split(fields, suffix, boost::is_any_of(":"));
- /* Get the index */
- i = atoi(buf + 4);
+ /* Make sure we have two fields */
+ if (fields.size() < 2) return (1);
- /* Verify information */
+ /* Get the entry index */
+ int i = atoi(buf + 4);
if (i < error_idx) return (4);
-
- /* Verify information */
if (i >= max_c_idx) return (2);
/* Save the index */
@@ -1510,7 +1507,8 @@ errr init_player_info_txt(FILE *fp)
/* Copy name */
assert(!c_ptr->title);
- c_ptr->title = my_strdup(s);
+ c_ptr->display_order_idx = std::stoi(fields[0]);
+ c_ptr->title = my_strdup(fields[1].c_str());
/* Initialize */
lev = 1;
@@ -1524,7 +1522,7 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'C') && (buf[2] == 'D'))
{
/* Acquire the text */
- s = buf + 6;
+ char const *s = buf + 6;
switch (buf[4])
{
@@ -1667,12 +1665,11 @@ errr init_player_info_txt(FILE *fp)
/* Process 'Z' for "powers" */
if ((buf[0] == 'C') && (buf[2] == 'Z'))
{
- int i;
-
/* Acquire the text */
- s = buf + 4;
+ char const *s = buf + 4;
/* Find it in the list */
+ int i;
for (i = 0; i < POWER_MAX; i++)
{
if (iequals(s, powers_type[i].name)) break;
@@ -1735,8 +1732,10 @@ errr init_player_info_txt(FILE *fp)
if ((buf[0] == 'C') && (buf[2] == 'F'))
{
/* Parse every entry */
- for (s = buf + 4; *s; )
+ for (char *s = buf + 4; *s; )
{
+ char *t;
+
/* Find the end of this entry */
for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
@@ -1768,7 +1767,7 @@ errr init_player_info_txt(FILE *fp)
if (buf[4] == 'N')
{
/* Find the colon before the name */
- s = buf + 6;
+ char const *s = buf + 6;
/* Paranoia -- require a name */
if (!*s) return (1);
@@ -1788,7 +1787,7 @@ errr init_player_info_txt(FILE *fp)
if (buf[4] == 'D')
{
/* Acquire the text */
- s = buf + 6;
+ char const *s = buf + 6;
if (!s_ptr->desc)
{
@@ -1860,8 +1859,10 @@ errr init_player_info_txt(FILE *fp)
if (buf[4] == 'G')
{
/* Parse every entry */
- for (s = buf + 6; *s; )
+ for (char *s = buf + 6; *s; )
{
+ char *t;
+
/* Find the end of this entry */
for (t = s; *t && (*t != ' ') && (*t != '|'); ++t) /* loop */;
@@ -1887,69 +1888,6 @@ errr init_player_info_txt(FILE *fp)
}
}
- /* Process 'N' for "New/Number/Name" */
- if ((buf[0] == 'M') && (buf[2] == 'N'))
- {
- /* Find the colon before the name */
- s = strchr(buf + 4, ':');
-
- /* Verify that colon */
- if (!s) return (1);
-
- /* Nuke the colon, advance to the name */
- *s++ = '\0';
-
- /* Paranoia -- require a name */
- if (!*s) return (1);
-
- /* Get the index */
- i = atoi(buf + 4);
-
- /* Verify information */
- if (i < error_idx) return (4);
-
- /* Verify information */
- if (i >= max_mc_idx) return (2);
-
- /* Save the index */
- error_idx = i;
-
- /* Point at the "info" */
- mc_ptr = &meta_class_info[i];
-
- /* Append chars to the name */
- strcpy(mc_ptr->name, s + 2);
- mc_ptr->color = color_char_to_attr(s[0]);
-
- /* Next... */
- continue;
- }
-
- /* Process 'C' for "Classes" */
- if ((buf[0] == 'M') && (buf[2] == 'C'))
- {
- int i;
-
- /* Acquire the text */
- s = buf + 4;
-
- /* Find it in the list */
- for (i = 0; i < max_c_idx; i++)
- {
- if (class_info[i].title && iequals(s, class_info[i].title))
- {
- break;
- }
- }
-
- if (i == max_c_idx) return (6);
-
- mc_ptr->classes.push_back(i);
-
- /* Next... */
- continue;
- }
-
/* Oops */
return (6);
}
@@ -7031,10 +6969,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst
{
max_c_idx = atoi(zz[2]);
}
- else if (zz[1][0] == 'M')
- {
- max_mc_idx = atoi(zz[2]);
- }
else if (zz[1][0] == 'H')
{
max_bg_idx = atoi(zz[2]);
diff --git a/src/init2.cc b/src/init2.cc
index 160dbeef..327556e3 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -20,7 +20,6 @@
#include "init1.hpp"
#include "lua_bind.hpp"
#include "messages.hpp"
-#include "meta_class_type.hpp"
#include "modules.hpp"
#include "monster_ego.hpp"
#include "monster_race.hpp"
@@ -556,7 +555,6 @@ namespace {
race_mod_info = new player_race_mod[max_rmp_idx];
class_info = new player_class[max_c_idx];
bg = make_array<hist_type>(max_bg_idx);
- meta_class_info = new meta_class_type[max_mc_idx];
gen_skill = new skill_modifiers;
}
diff --git a/src/meta_class_type.hpp b/src/meta_class_type.hpp
deleted file mode 100644
index bd47f998..00000000
--- a/src/meta_class_type.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-#include "h-basic.h"
-#include <vector>
-
-struct meta_class_type
-{
- char name[80] = ""; /* Name */
- byte color = 0;
- std::vector<u16b> classes; /* List of classes */
-};
diff --git a/src/meta_class_type_fwd.hpp b/src/meta_class_type_fwd.hpp
deleted file mode 100644
index 2d0e482a..00000000
--- a/src/meta_class_type_fwd.hpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-struct meta_class_type;
diff --git a/src/player_class.hpp b/src/player_class.hpp
index 61d35b5b..0e6f5839 100644
--- a/src/player_class.hpp
+++ b/src/player_class.hpp
@@ -20,6 +20,8 @@ struct player_class
char *desc = nullptr; /* Small desc of the class */
const char *titles[PY_MAX_LEVEL / 5] { }; /* Titles */
+ int display_order_idx; /* Display order index; lowest first */
+
player_shared ps;
player_race_flag_set flags;
diff --git a/src/variable.cc b/src/variable.cc
index 1eb5aaab..0f51c49e 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -503,7 +503,6 @@ player_race_mod *race_mod_info;
* Player class arrays
*/
player_class *class_info;
-meta_class_type *meta_class_info;
/*
* The wilderness features arrays
@@ -693,7 +692,6 @@ u16b max_set_idx = 1;
u16b max_rp_idx;
u16b max_rmp_idx;
u16b max_c_idx;
-u16b max_mc_idx;
/*
* Maximum number of objects in the level
diff --git a/src/variable.hpp b/src/variable.hpp
index a42d246c..d8e5cb17 100644
--- a/src/variable.hpp
+++ b/src/variable.hpp
@@ -14,7 +14,6 @@
#include "fate.hpp"
#include "feature_type_fwd.hpp"
#include "hist_type_fwd.hpp"
-#include "meta_class_type_fwd.hpp"
#include "monster_ego_fwd.hpp"
#include "monster_race_fwd.hpp"
#include "monster_type_fwd.hpp"
@@ -174,7 +173,6 @@ extern monster_race *r_info;
extern monster_ego *re_info;
extern dungeon_info_type *d_info;
extern player_class *class_info;
-extern meta_class_type *meta_class_info;
extern player_race *race_info;
extern player_race_mod *race_mod_info;
extern trap_type *t_info;
@@ -206,7 +204,6 @@ extern u16b max_m_idx;
extern u16b max_t_idx;
extern u16b max_rp_idx;
extern u16b max_c_idx;
-extern u16b max_mc_idx;
extern u16b max_rmp_idx;
extern u16b max_st_idx;
extern u16b max_wf_idx;