summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mutation.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-12 05:53:52 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-12 05:53:52 +0000
commit9dac0e0e3b594292e38fd818dc0ada31f289bfac (patch)
tree2980d3deeb573290922dbcd3c6c2001b7bfc7228 /crawl-ref/source/mutation.cc
parent76b79d4cfbb5791396ed38b4e3e57dfe977c21d3 (diff)
downloadcrawl-ref-9dac0e0e3b594292e38fd818dc0ada31f289bfac.tar.gz
crawl-ref-9dac0e0e3b594292e38fd818dc0ada31f289bfac.zip
Make extra-sure to reject invalid mutations. And if the player somehow
gets an invalid one anyways (a mutation for which mutation_name() has no name) then when listing abilities give a line with error information instead of a blank line. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5751 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mutation.cc')
-rw-r--r--crawl-ref/source/mutation.cc54
1 files changed, 48 insertions, 6 deletions
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index 63d6bde04a..078cf67eae 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -1281,6 +1281,8 @@ formatted_string describe_mutations()
// mutation is actually a demonic power
if (you.mutation[i] != 0 && you.demon_pow[i])
{
+ mutation_type mut_type = static_cast<mutation_type>(i);
+
have_any = true;
// these are already handled above:
@@ -1296,10 +1298,10 @@ formatted_string describe_mutations()
continue;
const bool fully_active
- = mutation_is_fully_active((mutation_type) i);
+ = mutation_is_fully_active(mut_type);
bool fully_inactive = false;
if (!fully_active)
- fully_inactive = _mutation_is_fully_inactive((mutation_type) i);
+ fully_inactive = _mutation_is_fully_inactive(mut_type);
const char* colourname = "";
if ( you.species == SP_DEMONSPAWN )
@@ -1331,7 +1333,23 @@ formatted_string describe_mutations()
if (fully_inactive)
result += "(";
- result += mutation_name(static_cast<mutation_type>(i));
+ std::string name = mutation_name(mut_type);
+
+ if (name == "")
+ {
+ int level;
+ if (!fully_active)
+ level = player_mutation_level(mut_type);
+ else // give description of fully active mutation
+ level = you.mutation[mut_type];
+
+ char buf[80];
+ sprintf(buf, "ERROR: no name for mutation #%d, level %d", i,
+ level);
+ name = buf;
+ }
+
+ result += name;
if (fully_inactive)
result += ")";
@@ -1351,6 +1369,8 @@ formatted_string describe_mutations()
{
if (you.mutation[i] != 0 && !you.demon_pow[i])
{
+ mutation_type mut_type = static_cast<mutation_type>(i);
+
// this is already handled above:
if (you.species == SP_NAGA
&& (i == MUT_BREATHE_POISON || i == MUT_FAST))
@@ -1363,19 +1383,35 @@ formatted_string describe_mutations()
have_any = true;
// not currently active?
- const bool need_grey = !mutation_is_fully_active((mutation_type) i);
+ const bool need_grey = !mutation_is_fully_active(mut_type);
bool inactive = false;
if (need_grey)
{
result += "<darkgrey>";
- if (_mutation_is_fully_inactive((mutation_type) i))
+ if (_mutation_is_fully_inactive(mut_type))
{
inactive = true;
result += "(";
}
}
- result += mutation_name(static_cast<mutation_type>(i));
+ std::string name = mutation_name(mut_type);
+
+ if (name == "")
+ {
+ int level;
+ if (!mutation_is_fully_active(mut_type))
+ level = player_mutation_level(mut_type);
+ else // give description of fully active mutation
+ level = you.mutation[mut_type];
+
+ char buf[80];
+ sprintf(buf, "ERROR: no name for mutation #%d, level %d", i,
+ level);
+ name = buf;
+ }
+
+ result += name;
if (need_grey)
{
@@ -1579,6 +1615,12 @@ static int calc_mutation_amusement_value(mutation_type which_mutation)
static bool accept_mutation(mutation_type mutat, bool ignore_rarity = false)
{
+ if (mutat == RANDOM_MUTATION
+ || mutation_defs[mutat].mutation == RANDOM_MUTATION)
+ {
+ return (false);
+ }
+
if (you.mutation[mutat] >= mutation_defs[mutat].levels)
return (false);