summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/goditem.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2012-06-17 19:22:44 -0400
committerNeil Moore <neil@s-z.org>2012-06-17 19:22:44 -0400
commit205ee368b4b1991792f3cfa036a04a95e486dd2c (patch)
treedeb3040e58b0affcd4e5f72c76d83a58f0e3fb5a /crawl-ref/source/goditem.cc
parent2a056f758e3583a6f4ef973ffeb624aebedad814 (diff)
downloadcrawl-ref-205ee368b4b1991792f3cfa036a04a95e486dd2c.tar.gz
crawl-ref-205ee368b4b1991792f3cfa036a04a95e486dd2c.zip
Do not crash when good worshippers see an unknown rod in tiles.
_is_bookrod_type() was being called on an item_info with sub_type == NUM_RODS. Handle this and the corresponding case for spellbooks. This happened only in tiles (where autopickup highlighting is determined based on item_infos from map_knowledge), but could probably be triggered by other uses of map_knowledge. Fixes #5792.
Diffstat (limited to 'crawl-ref/source/goditem.cc')
-rw-r--r--crawl-ref/source/goditem.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/crawl-ref/source/goditem.cc b/crawl-ref/source/goditem.cc
index 756fb6caac..2995fef749 100644
--- a/crawl-ref/source/goditem.cc
+++ b/crawl-ref/source/goditem.cc
@@ -17,6 +17,7 @@
#include "artefact.h"
#include "itemname.h"
#include "itemprop.h"
+#include "items.h"
#include "religion.h"
#include "spl-book.h"
#include "spl-cast.h"
@@ -28,6 +29,10 @@ static bool _is_bookrod_type(const item_def& item,
if (!item_is_spellbook(item) && item.base_type != OBJ_RODS)
return false;
+ // Return false for item_infos of unknown subtype (== NUM_{BOOKS,RODS})
+ if (item.sub_type == get_max_subtype(item.base_type))
+ return false;
+
int total = 0;
int total_liked = 0;