From fe8f18c5d717a580b978041125e231e42cc03d2f Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 15 Apr 2020 11:02:33 +0300 Subject: [PATCH] Mimic in a health food store could cause a panic Health food stores use a special "vegetarian class" of items, which mkobj doesn't understand. Just make the mimic use a random item class in that case. --- src/makemon.c | 2 +- src/shknam.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/makemon.c b/src/makemon.c index b4da8f5ad..d03801d65 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -2216,7 +2216,7 @@ register struct monst *mtmp; ap_type = M_AP_OBJECT; appear = -s_sym; } else { - if (s_sym == RANDOM_CLASS) + if (s_sym == RANDOM_CLASS || s_sym >= MAXOCLASSES) s_sym = syms[rn2((int) sizeof(syms) - 2) + 2]; goto assign_sym; } diff --git a/src/shknam.c b/src/shknam.c index 8e64c9b9b..0d61a95d1 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -802,7 +802,8 @@ struct obj *obj; return FALSE; } -/* positive value: class; negative value: specific object type */ +/* positive value: class; negative value: specific object type. + can also return non-existing object class (eg. VEGETARIAN_CLASS) */ int get_shop_item(type) int type;