diff --git a/include/mkroom.h b/include/mkroom.h index a2da67cbb..a67f349ec 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mkroom.h 3.5 1992/11/14 */ +/* SCCS Id: @(#)mkroom.h 3.5 2005/03/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -71,9 +71,10 @@ extern NEARDATA coord doors[DOORMAX]; #define WANDSHOP 21 #define TOOLSHOP 22 #define BOOKSHOP 23 -#define UNIQUESHOP 24 /* shops here & above not randomly gen'd. */ -#define CANDLESHOP 24 -#define MAXRTYPE 24 /* maximum valid room type */ +#define FODDERSHOP 24 /* health food store */ +#define UNIQUESHOP 25 /* shops here & below not randomly gen'd. */ +#define CANDLESHOP 25 +#define MAXRTYPE 25 /* maximum valid room type */ /* Special type for search_special() */ #define ANY_TYPE (-1) diff --git a/include/patchlevel.h b/include/patchlevel.h index 1be0e6e05..af645b65e 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)patchlevel.h 3.5 2005/01/22 */ +/* SCCS Id: @(#)patchlevel.h 3.5 2005/03/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -13,7 +13,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 20 +#define EDITLEVEL 21 #define COPYRIGHT_BANNER_A \ "NetHack, Copyright 1985-2005" diff --git a/src/mkroom.c b/src/mkroom.c index d78c16023..8683611be 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mkroom.c 3.5 2004/06/10 */ +/* SCCS Id: @(#)mkroom.c 3.5 2005/03/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -119,6 +119,8 @@ mkshop() goto gottype; if(*ep == 'g' || *ep == 'G') i = 0; + else if (*ep == 'v' || *ep == 'V') + i = FODDERSHOP - SHOPBASE; /* veggy food */ else i = -1; } diff --git a/src/shknam.c b/src/shknam.c index 77996e924..1d875956f 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -7,6 +7,9 @@ #include "hack.h" #include "eshk.h" +STATIC_DCL boolean FDECL(veggy_item, (struct obj *obj,int)); +STATIC_DCL int NDECL(shkveg); +STATIC_DCL void FDECL(mkveggy_at, (int,int)); STATIC_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int)); STATIC_DCL void FDECL(nameshk, (struct monst *,const char * const *)); STATIC_DCL int FDECL(shkinit, (const struct shclass *,struct mkroom *)); @@ -267,6 +270,38 @@ init_shop_selection() } #endif /*0*/ +/* decide whether an object or object type is considered vegetarian; + for types, items which might go either way are assumed to be veggy */ +STATIC_OVL boolean +veggy_item(obj, otyp) +struct obj *obj; +int otyp; /* used iff obj is null */ +{ + int corpsenm; + char oclass; + + if (obj) { + /* actual object; will check tin content and corpse species */ + otyp = (int) obj->otyp; + oclass = obj->oclass; + corpsenm = obj->corpsenm; + } else { + /* just a type; caller will have to handle tins and corpses */ + oclass = objects[otyp].oc_class; + corpsenm = PM_LICHEN; /* veggy standin */ + } + + if (oclass == FOOD_CLASS) { + if (objects[otyp].oc_material == VEGGY || otyp == EGG) + return TRUE; + if (otyp == TIN && corpsenm == NON_PM) /* implies obj is non-null */ + return (obj->spe == 1); /* 0 = empty, 1 = spinach */ + if (otyp == TIN || otyp == CORPSE) + return (corpsenm >= LOW_PM && vegetarian(&mons[corpsenm])); + } + return FALSE; +} + STATIC_OVL int shkveg() { @@ -276,11 +311,14 @@ shkveg() j = maxprob = 0; for (i = bases[(int)oclass]; i < NUM_OBJECTS; ++i) { - if (objects[i].oc_material == VEGGY) { + if (objects[i].oc_class != oclass) break; + + if (veggy_item((struct obj *)0, i)) { ok[j++] = i; maxprob += objects[i].oc_prob; } } + if (maxprob < 1) panic("shkveg no veggy objects"); prob = rnd(maxprob); j = 0; @@ -295,6 +333,18 @@ shkveg() return i; } +/* make a random item for health food store */ +STATIC_OVL void +mkveggy_at(sx, sy) +int sx, sy; +{ + struct obj *obj = mksobj_at(shkveg(), sx, sy, TRUE, TRUE); + + if (obj && obj->otyp == TIN) + set_tin_variety(obj, HEALTHY_TIN); + return; +} + STATIC_OVL void mkshobj_at(shp, sx, sy) /* make an object of the appropriate type for a shop square */ @@ -316,7 +366,7 @@ int sx, sy; } else { atype = get_shop_item(shp - shtypes); if (atype == VEGETARIAN_CLASS) - (void) mksobj_at(shkveg(), sx, sy, TRUE, TRUE); + mkveggy_at(sx, sy); else if (atype < 0) (void) mksobj_at(-atype, sx, sy, TRUE, TRUE); else @@ -564,15 +614,7 @@ struct obj *obj; for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) { /* pseudo-class needs special handling */ if (shp->iprobs[i].itype == VEGETARIAN_CLASS) { - if ((obj->otyp == TIN || obj->otyp == CORPSE) && - ((obj->corpsenm >= LOW_PM && - vegetarian(&mons[obj->corpsenm])) || - (obj->otyp == TIN && obj->spe == 1))) /* spinach */ - return TRUE; - if (obj->oclass == FOOD_CLASS && - (objects[obj->otyp].oc_material == VEGGY || - obj->otyp == EGG)) - return TRUE; + if (veggy_item(obj, 0)) return TRUE; } else if ((shp->iprobs[i].itype < 0) ? shp->iprobs[i].itype == - obj->otyp : shp->iprobs[i].itype == obj->oclass) diff --git a/util/lev_main.c b/util/lev_main.c index a6c3bb119..e39d19929 100644 --- a/util/lev_main.c +++ b/util/lev_main.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)lev_main.c 3.5 2002/03/27 */ +/* SCCS Id: @(#)lev_main.c 3.5 2005/03/12 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -162,6 +162,7 @@ static struct { { "wand shop", WANDSHOP }, { "tool shop", TOOLSHOP }, { "book shop", BOOKSHOP }, + { "health food shop", FODDERSHOP }, { "candle shop", CANDLESHOP }, { 0, 0 } };