From 429bfc5a5c0ad6f4b934c027c9e00f049d59b196 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 13 Aug 2009 15:43:15 +0000 Subject: Fix being unable to create hydra undead with requested number of heads (Eino). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10535 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mapdef.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'crawl-ref/source/mapdef.cc') diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 1a6d864f4e..d116bd6d4c 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -2407,27 +2407,33 @@ void mons_list::get_zombie_type(std::string s, mons_spec &spec) const { MONS_SPECTRAL_THING, MONS_SPECTRAL_THING }, }; - const int mod = ends_with(s, zombie_types); + int mod = ends_with(s, zombie_types); if (!mod) { - const std::string &spectre = "spectral "; + const std::string spectre("spectral "); if (s.find(spectre) == 0) { + mod = ends_with(" spectre", zombie_types); s = s.substr(spectre.length()); - spec.mid = MONS_SPECTRAL_THING; - spec.monbase = get_monster_by_name(s, true); - if (!mons_zombie_size(spec.monbase)) - spec.mid = MONS_PROGRAM_BUG; + } + else + { + spec.mid = MONS_PROGRAM_BUG; return; } - spec.mid = MONS_PROGRAM_BUG; - return; + } + else + { + s = s.substr(0, s.length() - strlen(zombie_types[mod - 1])); } - s = s.substr(0, s.length() - strlen(zombie_types[mod - 1])); trim_string(s); - spec.monbase = get_monster_by_name(s, true); + mons_spec base_monster = mons_by_name(s); + if (base_monster.mid < 0) + base_monster.mid = MONS_PROGRAM_BUG; + spec.monbase = static_cast(base_monster.mid); + spec.number = base_monster.number; const int zombie_size = mons_zombie_size(spec.monbase); if (!zombie_size) @@ -2604,7 +2610,7 @@ mons_spec mons_list::mons_by_name(std::string name) const if (name == "large abomination") return (MONS_ABOMINATION_LARGE); - if (ends_with(name, "-headed hydra")) + if (ends_with(name, "-headed hydra") && !starts_with(name, "spectral ")) return get_hydra_spec(name); mons_spec spec; -- cgit v1.2.3-54-g00ecf