MCPcopy Create free account
hub / github.com/NetHack/NetHack / saleable

Function saleable

src/shknam.c:804–824  ·  view source on GitHub ↗

does shkp's shop stock this item type? */

Source from the content-addressed store, hash-verified

802
803/* does shkp's shop stock this item type? */
804boolean
805saleable(struct monst *shkp, struct obj *obj)
806{
807 int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE;
808 const struct shclass *shp = &shtypes[shp_indx];
809
810 if (shp->symb == RANDOM_CLASS)
811 return TRUE;
812 for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) {
813 /* pseudo-class needs special handling */
814 if (shp->iprobs[i].itype == VEGETARIAN_CLASS) {
815 if (veggy_item(obj, 0))
816 return TRUE;
817 } else if ((shp->iprobs[i].itype < 0)
818 ? shp->iprobs[i].itype == -obj->otyp
819 : shp->iprobs[i].itype == obj->oclass)
820 return TRUE;
821 }
822 /* not found */
823 return FALSE;
824}
825
826/* positive value: class; negative value: specific object type.
827 can also return non-existing object class (eg. VEGETARIAN_CLASS) */

Callers 5

contained_costFunction · 0.85
dropped_containerFunction · 0.85
shk_names_objFunction · 0.85
sellobjFunction · 0.85
globby_bill_fixupFunction · 0.85

Calls 1

veggy_itemFunction · 0.85

Tested by

no test coverage detected