From: <gi...@cr...> - 2025-07-22 02:05:10
|
via 525eb422377a87c00ea1131aecb8aae12b634b47 (commit) from 4ac789b6285661837dd5120f94a9dcda6e0efe61 (commit) ----------------------------------------------------------------------- commit 525eb422377a87c00ea1131aecb8aae12b634b47 Author: WizardIke <ik...@ya...> Date: Tue Jul 22 14:03:50 2025 +1200 Fix a crash when examining a monster with unknown wand (#4499) There are various bugs that can result in a monster being in view with an unidentified wand and it would be better not to crash when examining them. For example, monsters opening doors or peeking down a stairscase in descent mode etc can result in you seeing monsters with unidentified wands. ----------------------------------------------------------------------- Summary of changes: crawl-ref/source/mon-info.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index cfe9a0efa4..a0c8037487 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -1866,8 +1866,7 @@ bool monster_info::has_spells() const } // Wand spells - const item_def* wand = inv[MSLOT_WAND].get(); - if (itemuse() >= MONUSE_STARTING_EQUIPMENT && wand) + if (get_wand_spell() != SPELL_NO_SPELL) return true; const mon_spellbook_type book = get_spellbook(*this); @@ -1908,7 +1907,9 @@ spell_type monster_info::get_wand_spell() const return SPELL_NO_SPELL; const wand_type wandtyp = static_cast<wand_type>(wand->sub_type); - ASSERT(wandtyp < NUM_WANDS); + // Don't count unidentified wands + if (wandtyp >= NUM_WANDS) + return SPELL_NO_SPELL; return spell_in_wand(wandtyp); } -- Dungeon Crawl Stone Soup |