summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/initfile.cc15
-rw-r--r--crawl-ref/source/newgame.cc22
-rw-r--r--crawl-ref/source/ng-restr.cc3
-rw-r--r--crawl-ref/source/species.cc19
-rw-r--r--crawl-ref/source/species.h4
5 files changed, 34 insertions, 29 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 768f0b0182..2277f9ad0c 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -372,17 +372,8 @@ static species_type _str_to_species(const string &str)
if (ret == SP_UNKNOWN)
ret = str_to_species(str);
- if (!is_valid_species(ret)
- || (species_genus(ret) == GENPC_DRACONIAN
- && ret != SP_BASE_DRACONIAN))
- {
+ if (!is_species_valid_choice(ret))
ret = SP_UNKNOWN;
- }
-
-#if TAG_MAJOR_VERSION == 34
- if (ret == SP_SLUDGE_ELF)
- ret = SP_UNKNOWN;
-#endif
if (ret == SP_UNKNOWN)
fprintf(stderr, "Unknown species choice: %s\n", str.c_str());
@@ -416,8 +407,10 @@ static job_type _str_to_job(const string &str)
if (job == JOB_UNKNOWN)
job = get_job_by_name(str.c_str());
- // This catches JOB_UNKNOWN as well as removed jobs.
if (!is_job_valid_choice(job))
+ job = JOB_UNKNOWN;
+
+ if (job == JOB_UNKNOWN)
fprintf(stderr, "Unknown background choice: %s\n", str.c_str());
return job;
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 5f6ca5be65..b2b676b05f 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -152,20 +152,6 @@ static void _print_character_info(const newgame_def* ng)
cprintf("%s\n", _welcome(ng).c_str());
}
-// Determines if a species is a valid choice for a new game.
-static bool _is_species_valid_choice(species_type species)
-{
- if ((species == SP_LAVA_ORC || species == SP_DJINNI)
- && Version::ReleaseType != VER_ALPHA)
- {
- return false;
- }
-
- // Non-base draconians cannot be selected either.
- return is_valid_species(species)
- && !(species >= SP_RED_DRACONIAN && species < SP_BASE_DRACONIAN);
-}
-
#ifdef ASSERTS
static bool _species_is_undead(const species_type speci)
{
@@ -230,7 +216,7 @@ static void _resolve_species(newgame_def* ng, const newgame_def* ng_choice)
// any valid species will do
do
ng->species = get_species(random2(ng_num_species()));
- while (!_is_species_valid_choice(ng->species));
+ while (!is_species_valid_choice(ng->species));
}
else
{
@@ -334,7 +320,7 @@ static string _highlight_pattern(const newgame_def* ng)
for (int i = 0; i < ng_num_species(); ++i)
{
const species_type species = get_species(i);
- if (!_is_species_valid_choice(species))
+ if (!is_species_valid_choice(species))
continue;
if (is_good_combination(species, ng->job, true))
@@ -564,7 +550,7 @@ static void _construct_species_menu(const newgame_def* ng,
ASSERT(menu != NULL);
int items_in_column = 0;
for (int i = 0; i < NUM_SPECIES; ++i)
- if (_is_species_valid_choice((species_type)i))
+ if (is_species_valid_choice((species_type)i))
items_in_column++;
items_in_column = (items_in_column + 2) / 3;
// Construct the menu, 3 columns
@@ -576,7 +562,7 @@ static void _construct_species_menu(const newgame_def* ng,
for (int i = 0, pos = 0; i < ng_num_species(); ++i, ++pos)
{
const species_type species = get_species(i);
- if (!_is_species_valid_choice(species))
+ if (!is_species_valid_choice(species))
{
--pos;
continue;
diff --git a/crawl-ref/source/ng-restr.cc b/crawl-ref/source/ng-restr.cc
index 44215db87b..fb0bffd2fe 100644
--- a/crawl-ref/source/ng-restr.cc
+++ b/crawl-ref/source/ng-restr.cc
@@ -15,6 +15,9 @@
char_choice_restriction job_allowed(species_type speci, job_type job)
{
+ if (!is_species_valid_choice(speci) || !is_job_valid_choice(job))
+ return CC_BANNED;
+
switch (job)
{
case JOB_FIGHTER:
diff --git a/crawl-ref/source/species.cc b/crawl-ref/source/species.cc
index 675d29189b..0c478fc747 100644
--- a/crawl-ref/source/species.cc
+++ b/crawl-ref/source/species.cc
@@ -5,6 +5,8 @@
#include "libutil.h"
#include "random.h"
+#include "version.h"
+
// March 2008: change order of species and jobs on character selection
// screen as suggested by Markus Maier. Summarizing comments below are
// copied directly from Markus' SourceForge comments. (jpeg)
@@ -399,6 +401,23 @@ bool is_valid_species(species_type species)
return (species >= 0 && species <= LAST_VALID_SPECIES);
}
+bool is_species_valid_choice(species_type species)
+{
+#if TAG_MAJOR_VERSION == 34
+ if (species == SP_SLUDGE_ELF)
+ return false;
+#endif
+ if ((species == SP_LAVA_ORC || species == SP_DJINNI)
+ && Version::ReleaseType != VER_ALPHA)
+ {
+ return false;
+ }
+
+ // Non-base draconians cannot be selected either.
+ return is_valid_species(species)
+ && !(species >= SP_RED_DRACONIAN && species < SP_BASE_DRACONIAN);
+}
+
int species_exp_modifier(species_type species)
{
switch (species) // table: Experience
diff --git a/crawl-ref/source/species.h b/crawl-ref/source/species.h
index 381300af75..bf2ec04c5f 100644
--- a/crawl-ref/source/species.h
+++ b/crawl-ref/source/species.h
@@ -31,6 +31,10 @@ monster_type player_species_to_mons_species(species_type species);
// species_type bounds checking.
bool is_valid_species(species_type);
+
+// Is the species valid for a new game?
+bool is_species_valid_choice(species_type);
+
int species_exp_modifier(species_type species);
int species_hp_modifier(species_type species);
int species_mp_modifier(species_type species);