diff options
author | Neil Moore <neil@s-z.org> | 2014-07-31 17:58:14 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-07-31 18:19:52 -0400 |
commit | ba7f0067d3dcc93715e1aba3e2e6f5af80ec1092 (patch) | |
tree | 80345def94866eefa36483f541638b3cac9cbaf9 | |
parent | aadabb3ee9cf63f3e8a000bd8375c101a9d97824 (diff) | |
download | crawl-ref-ba7f0067d3dcc93715e1aba3e2e6f5af80ec1092.tar.gz crawl-ref-ba7f0067d3dcc93715e1aba3e2e6f5af80ec1092.zip |
Forbid butchering/eating Xtahua and Gastronok under Zin (#7726)
Now, if the corpse or chunk has an orig_monnum, we use that rather
than the mon_type (which is just the species) for determining the
intelligence of the monster from which it came.
Mixing chunks from Xtahua and a normal fire dragon could result in a
stack that is either all edible, or all inedible (depending on which
stack was the source of the merge and which the target). Furthermore,
these chunks are only marked by the forbidden tag, and only if you
worship Zin. This could be improved, but it is not clear how worthwhile
that would be. On the other hand, preserving names on chunks might be
"fun" for some players (even if that is kind of creepy).
-rw-r--r-- | crawl-ref/source/food.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 927e953cca..7fb52455eb 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -1420,12 +1420,24 @@ static int _contamination_ratio(corpse_effect_type chunk_effect) return ratio; } +static mon_intel_type _chunk_intelligence(const item_def &chunk) +{ + // An optimising compiler can assume an enum value is in range, so + // check the range on the uncast value. + const bool bad = chunk.orig_monnum < 0 || chunk.orig_monnum >= NUM_MONSTERS; + const monster_type orig_mt = static_cast<monster_type>(chunk.orig_monnum); + const monster_type type = bad || invalid_monster_type(orig_mt) + ? chunk.mon_type + : orig_mt; + return mons_class_intel(type); +} + // Never called directly - chunk_effect values must pass // through food::_determine_chunk_effect() first. {dlb}: static void _eat_chunk(item_def& food) { const bool cannibal = is_player_same_genus(food.mon_type); - const int intel = mons_class_intel(food.mon_type) - I_ANIMAL; + const int intel = _chunk_intelligence(food) - I_ANIMAL; const bool rotten = food_is_rotten(food); const bool orc = (mons_genus(food.mon_type) == MONS_ORC); const bool holy = (mons_class_holiness(food.mon_type) == MH_HOLY); @@ -1852,7 +1864,7 @@ bool is_forbidden_food(const item_def &food) } // Zin doesn't like it if you eat beings with a soul. - if (you_worship(GOD_ZIN) && mons_class_intel(food.mon_type) >= I_NORMAL) + if (you_worship(GOD_ZIN) && _chunk_intelligence(food) >= I_NORMAL) return true; // Everything else is allowed. |