Source:NetHack 3.2.0/shknam.c

From NetHackWiki
(Redirected from NetHack 3.2.0/shknam.c)
Jump to navigation Jump to search

Below is the full text to shknam.c from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/shknam.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /*	SCCS Id: @(#)shknam.c	3.2	96/02/27	*/
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    /* shknam.c -- initialize a shop */
6.    
7.    #include "hack.h"
8.    #include "eshk.h"
9.    
10.   #ifndef OVLB
11.   extern const struct shclass shtypes[];
12.   
13.   #else
14.   
15.   static void FDECL(mkshobj_at, (const struct shclass *,int,int));
16.   static void FDECL(nameshk, (struct monst *,const char **));
17.   static int  FDECL(shkinit, (const struct shclass *,struct mkroom *));
18.   
19.   static const char *shkliquors[] = {
20.       /* Ukraine */
21.       "Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka",
22.       /* N. Russia */
23.       "Konosja", "Weliki Oestjoeg", "Syktywkar", "Sablja",
24.       "Narodnaja", "Kyzyl",
25.       /* Silezie */
26.       "Walbrzych", "Swidnica", "Klodzko", "Raciborz", "Gliwice",
27.       "Brzeg", "Krnov", "Hradec Kralove",
28.       /* Schweiz */
29.       "Leuk", "Brig", "Brienz", "Thun", "Sarnen", "Burglen", "Elm",
30.       "Flims", "Vals", "Schuls", "Zum Loch",
31.       0
32.   };
33.   
34.   static const char *shkbooks[] = {
35.       /* Eire */
36.       "Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch",
37.       "Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra",
38.       "Kittamagh", "Nenagh", "Sneem", "Ballingeary", "Kilgarvan",
39.       "Cahersiveen", "Glenbeigh", "Kilmihil", "Kiltamagh",
40.       "Droichead Atha", "Inniscrone", "Clonegal", "Lisnaskea",
41.       "Culdaff", "Dunfanaghy", "Inishbofin", "Kesh",
42.       0
43.   };
44.   
45.   static const char *shkarmors[] = {
46.       /* Turquie */
47.       "Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep",
48.       "Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak",
49.       "Iskenderun", "Kadirli", "Siverek", "Pervari", "Malasgirt",
50.       "Bayburt", "Ayancik", "Zonguldak", "Balya", "Tefenni",
51.       "Artvin", "Kars", "Makharadze", "Malazgirt", "Midyat",
52.       "Birecik", "Kirikkale", "Alaca", "Polatli", "Nallihan",
53.       0
54.   };
55.   
56.   static const char *shkwands[] = {
57.       /* Wales */
58.       "Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach",
59.       "Rhaeader", "Llandrindod", "Llanfair-ym-muallt",
60.       "Y-Fenni", "Measteg", "Rhydaman", "Beddgelert",
61.       "Curig", "Llanrwst", "Llanerchymedd", "Caergybi",
62.       /* Scotland */
63.       "Nairn", "Turriff", "Inverurie", "Braemar", "Lochnagar",
64.       "Kerloch", "Beinn a Ghlo", "Drumnadrochit", "Morven",
65.       "Uist", "Storr", "Sgurr na Ciche", "Cannich", "Gairloch",
66.       "Kyleakin", "Dunvegan",
67.       0
68.   };
69.   
70.   static const char *shkrings[] = {
71.       /* Hollandse familienamen */
72.       "Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken",
73.       "Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy",
74.       "Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix",
75.       "Ypey",
76.       /* Skandinaviske navne */
77.       "Rastegaisa", "Varjag Njarga", "Kautekeino", "Abisko",
78.       "Enontekis", "Rovaniemi", "Avasaksa", "Haparanda",
79.       "Lulea", "Gellivare", "Oeloe", "Kajaani", "Fauske",
80.       0
81.   };
82.   
83.   static const char *shkfoods[] = {
84.       /* Indonesia */
85.       "Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan",
86.       "Bandjar", "Parbalingga", "Bojolali", "Sarangan",
87.       "Ngebel", "Djombang", "Ardjawinangun", "Berbek",
88.       "Papar", "Baliga", "Tjisolok", "Siboga", "Banjoewangi",
89.       "Trenggalek", "Karangkobar", "Njalindoeng", "Pasawahan",
90.       "Pameunpeuk", "Patjitan", "Kediri", "Pemboeang", "Tringanoe",
91.       "Makin", "Tipor", "Semai", "Berhala", "Tegal", "Samoe",
92.       0
93.   };
94.   
95.   static const char *shkweapons[] = {
96.       /* Perigord */
97.       "Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard",
98.       "Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac",
99.       "Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac",
100.      "Cazelon", "Eypau", "Carignan", "Monbazillac", "Jonzac",
101.      "Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon",
102.      "Eymoutiers", "Eygurande", "Eauze", "Labouheyre",
103.      0
104.  };
105.  
106.  static const char *shktools[] = {
107.      /* Spmi */
108.      "Ymla", "Eed-morra", "Cubask", "Nieb", "Bnowr Falr", "Telloc Cyaj",
109.      "Sperc", "Noskcirdneh", "Yawolloh", "Hyeghu", "Niskal", "Trahnil",
110.      "Htargcm", "Enrobwem", "Kachzi Rellim", "Regien", "Donmyar",
111.      "Yelpur", "Nosnehpets", "Stewe", "Renrut", "_Zlaw", "Nosalnef",
112.      "Rewuorb", "Rellenk", "Yad", "Cire Htims", "Y-crad", "Nenilukah",
113.      "Corsh", "Aned",
114.  #ifdef OVERLAY
115.      "Erreip", "Nehpets", "Mron", "Snivek", "Lapu", "Kahztiy",
116.  #endif
117.  #ifdef WIN32
118.      "Lechaim",
119.  #endif
120.  #ifdef MAC
121.      "Nhoj-lee", "Evad\'kh", "Ettaw-noj", "Tsew-mot", "Ydna-s",
122.      "Yao-hang", "Tonbar",
123.  #endif
124.  #ifdef AMIGA
125.      "Falo", "Nosid-da\'r", "Ekim-p", "Rebrol-nek", "Noslo", "Yl-rednow",
126.      "Mured-oog",
127.  #endif
128.  #ifdef VMS
129.      "Lez-tneg", "Ytnu-haled", "Niknar",
130.  #endif
131.      0
132.  };
133.  
134.  static const char *shklight[] = {
135.      /* Romania */
136.      "Zarnesti", "Slanic", "Nehoiasu", "Ludus", "Sighisoara", "Nisipitu",
137.      "Razboieni", "Bicaz", "Dorohoi", "Vaslui", "Fetesti", "Tirgu Neamt",
138.      "Babadag", "Zimnicea", "Zlatna", "Jiu", "Eforie", "Mamaia",
139.      /* Bulgaria */
140.      "Silistra", "Tulovo", "Panagyuritshte", "Smolyan", "Kirklareli",
141.      "Pernik", "Lom", "Haskovo", "Dobrinishte", "Varvara", "Oryahovo",
142.      "Troyan", "Lovech", "Sliven",
143.      0
144.  };
145.  
146.  static const char *shkgeneral[] = {
147.      /* Suriname */
148.      "Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi",
149.      "Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo",
150.      "Akalapi", "Sipaliwini",
151.      /* Greenland */
152.      "Annootok", "Upernavik", "Angmagssalik",
153.      /* N. Canada */
154.      "Aklavik", "Inuvik", "Tuktoyaktuk",
155.      "Chicoutimi", "Ouiatchouane", "Chibougamau",
156.      "Matagami", "Kipawa", "Kinojevis",
157.      "Abitibi", "Maganasipi",
158.      /* Iceland */
159.      "Akureyri", "Kopasker", "Budereyri", "Akranes", "Bordeyri",
160.      "Holmavik",
161.      0
162.  };
163.  
164.  /*
165.   * To add new shop types, all that is necessary is to edit the shtypes[] array.
166.   * See mkroom.h for the structure definition.  Typically, you'll have to lower
167.   * some or all of the probability fields in old entries to free up some
168.   * percentage for the new type.
169.   *
170.   * The placement type field is not yet used but will be in the near future.
171.   *
172.   * The iprobs array in each entry defines the probabilities for various kinds
173.   * of objects to be present in the given shop type.  You can associate with
174.   * each percentage either a generic object type (represented by one of the
175.   * *_CLASS macros) or a specific object (represented by an onames.h define).
176.   * In the latter case, prepend it with a unary minus so the code can know
177.   * (by testing the sign) whether to use mkobj() or mksobj().
178.   */
179.  
180.  const struct shclass shtypes[] = {
181.  	{"general store", RANDOM_CLASS, 44,
182.  	    D_SHOP, {{100, RANDOM_CLASS}, {0, 0}, {0, 0}}, shkgeneral},
183.  	{"used armor dealership", ARMOR_CLASS, 14,
184.  	    D_SHOP, {{90, ARMOR_CLASS}, {10, WEAPON_CLASS}, {0, 0}},
185.  	     shkarmors},
186.  	{"second-hand bookstore", SCROLL_CLASS, 10, D_SHOP,
187.  	    {{90, SCROLL_CLASS}, {10, SPBOOK_CLASS}, {0, 0}}, shkbooks},
188.  	{"liquor emporium", POTION_CLASS, 10, D_SHOP,
189.  	    {{100, POTION_CLASS}, {0, 0}, {0, 0}}, shkliquors},
190.  	{"antique weapons outlet", WEAPON_CLASS, 5, D_SHOP,
191.  	    {{90, WEAPON_CLASS}, {10, ARMOR_CLASS}, {0, 0}}, shkweapons},
192.  	{"delicatessen", FOOD_CLASS, 5, D_SHOP,
193.  	    {{95, FOOD_CLASS}, {5, POTION_CLASS}, {0, 0}}, shkfoods},
194.  	{"jewelers", RING_CLASS, 3, D_SHOP,
195.  	    {{85, RING_CLASS}, {10, GEM_CLASS}, {5, AMULET_CLASS}, {0, 0}},
196.  	    shkrings},
197.  	{"quality apparel and accessories", WAND_CLASS, 3, D_SHOP,
198.  	    {{90, WAND_CLASS}, {5, -LEATHER_GLOVES}, {5, -ELVEN_CLOAK}, {0, 0}},
199.  	     shkwands},
200.  	{"hardware store", TOOL_CLASS, 3, D_SHOP,
201.  	    {{100, TOOL_CLASS}, {0, 0}, {0, 0}}, shktools},
202.  	/* Actually shktools is ignored; the code specifically chooses a
203.  	 * random implementor name (along with candle shops having
204.  	 * random shopkeepers)
205.  	 */
206.  	{"rare books", SPBOOK_CLASS, 3, D_SHOP,
207.  	    {{90, SPBOOK_CLASS}, {10, SCROLL_CLASS}, {0, 0}}, shkbooks},
208.  	/* Shops below this point are "unique".  That is they must all have a
209.  	 * probability of zero.  They are only created via the special level
210.  	 * loader.
211.  	 */
212.  	{"lighting store", TOOL_CLASS, 0, D_SHOP,
213.  	    {{32, -WAX_CANDLE}, {50, -TALLOW_CANDLE},
214.  	     {5, -BRASS_LANTERN}, {10, -OIL_LAMP}, {3, -MAGIC_LAMP}}, shklight},
215.  	{(char *)0, 0, 0, 0, {{0, 0}, {0, 0}, {0, 0}}, 0}
216.  };
217.  
218.  #if 0
219.  /* validate shop probabilities; otherwise incorrect local changes could
220.     end up provoking infinite loops or wild subscripts fetching garbage */
221.  void
222.  init_shop_selection()
223.  {
224.  	register int i, j, item_prob, shop_prob;
225.  
226.  	for (shop_prob = 0, i = 0; i < SIZE(shtypes); i++) {
227.  		shop_prob += shtypes[i].prob;
228.  		for (item_prob = 0, j = 0; j < SIZE(shtypes[0].iprobs); j++)
229.  			item_prob += shtypes[i].iprobs[j].iprob;
230.  		if (item_prob != 100)
231.  			panic("item probabilities total to %d for %s shops!",
232.  				item_prob, shtypes[i].name);
233.  	}
234.  	if (shop_prob != 100)
235.  		panic("shop probabilities total to %d!", shop_prob);
236.  }
237.  #endif /*0*/
238.  
239.  static void
240.  mkshobj_at(shp, sx, sy)
241.  /* make an object of the appropriate type for a shop square */
242.  const struct shclass *shp;
243.  int sx, sy;
244.  {
245.  	register struct monst *mtmp;
246.  	int atype;
247.  	struct permonst *ptr;
248.  
249.  	if (rn2(100) < depth(&u.uz) &&
250.  	    !MON_AT(sx, sy) && (ptr = mkclass(S_MIMIC,0)) &&
251.  	    (mtmp=makemon(ptr,sx,sy))) {
252.  		/* note: makemon will set the mimic symbol to a shop item */
253.  		if (rn2(10) >= depth(&u.uz)) {
254.  			mtmp->m_ap_type = M_AP_OBJECT;
255.  			mtmp->mappearance = STRANGE_OBJECT;
256.  		}
257.  	} else if ((atype = get_shop_item(shp - shtypes)) < 0)
258.  		(void) mksobj_at(-atype, sx, sy, TRUE);
259.  	else (void) mkobj_at(atype, sx, sy, TRUE);
260.  }
261.  
262.  /* extract a shopkeeper name for the given shop type */
263.  static void
264.  nameshk(shk, nlp)
265.  struct monst *shk;
266.  const char *nlp[];
267.  {
268.  	int i, trycnt, names_avail;
269.  	const char *shname = 0;
270.  	struct monst *mtmp;
271.  	int name_wanted;
272.  	s_level *sptr;
273.  
274.  	if (nlp == shklight && In_mines(&u.uz)
275.  		&& (sptr = Is_special(&u.uz)) != 0 && sptr->flags.town) {
276.  	    /* special-case minetown lighting shk */
277.  	    shname = "Izchak";
278.  	    shk->female = FALSE;
279.  	} else {
280.  	    /* We want variation from game to game, without needing the save
281.  	       and restore support which would be necessary for randomization;
282.  	       try not to make too many assumptions about time_t's internals;
283.  	       use ledger_no rather than depth to keep mine town distinct. */
284.  	    int nseed = (int)((long)u.ubirthday / 257L);
285.  
286.  	    name_wanted = ledger_no(&u.uz) + (nseed % 13) - (nseed % 5);
287.  	    if (name_wanted < 0) name_wanted += (13 + 5);
288.  	    shk->female = name_wanted & 1;
289.  
290.  	    for (names_avail = 0; nlp[names_avail]; names_avail++)
291.  		continue;
292.  
293.  	    for (trycnt = 0; trycnt < 50; trycnt++) {
294.  		if (nlp == shktools) {
295.  		    shname = shktools[rn2(names_avail)];
296.  		    shk->female = (*shname == '_');
297.  		    if (shk->female) shname++;
298.  		} else if (name_wanted < names_avail) {
299.  		    shname = nlp[name_wanted];
300.  		} else if ((i = rn2(names_avail)) != 0) {
301.  		    shname = nlp[i - 1];
302.  		} else if (nlp != shkgeneral) {
303.  		    nlp = shkgeneral;	/* try general names */
304.  		    for (names_avail = 0; nlp[names_avail]; names_avail++)
305.  			continue;
306.  		    continue;		/* next `trycnt' iteration */
307.  		} else {
308.  		    shname = shk->female ? "Lucrezia" : "Dirk";
309.  		}
310.  
311.  		/* is name already is use on this level? */
312.  		for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
313.  		    if (mtmp == shk) continue;
314.  		    if (!mtmp->isshk) continue;
315.  		    if (strcmp(ESHK(mtmp)->shknam, shname)) continue;
316.  		    break;
317.  		}
318.  		if (!mtmp) break;	/* new name */
319.  	    }
320.  	}
321.  	(void) strncpy(ESHK(shk)->shknam, shname, PL_NSIZ);
322.  	ESHK(shk)->shknam[PL_NSIZ-1] = 0;
323.  }
324.  
325.  static int
326.  shkinit(shp, sroom)	/* create a new shopkeeper in the given room */
327.  const struct shclass	*shp;
328.  struct mkroom	*sroom;
329.  {
330.  	register int sh, sx, sy;
331.  	struct monst *shk;
332.  
333.  	/* place the shopkeeper in the given room */
334.  	sh = sroom->fdoor;
335.  	sx = doors[sh].x;
336.  	sy = doors[sh].y;
337.  
338.  	/* check that the shopkeeper placement is sane */
339.  	if(sroom->irregular) {
340.  	    int rmno = (sroom - rooms) + ROOMOFFSET;
341.  	    if(isok(sx-1,sy) &&
342.  	       levl[sx-1][sy].roomno == rmno && !levl[sx-1][sy].edge) sx--;
343.  	    else if(isok(sx+1,sy) &&
344.  	       levl[sx+1][sy].roomno == rmno && !levl[sx+1][sy].edge) sx++;
345.  	    else if(isok(sx,sy-1) &&
346.  	       levl[sx][sy-1].roomno == rmno && !levl[sx][sy-1].edge) sy--;
347.  	    else if(isok(sx,sy+1) &&
348.  	       levl[sx][sy+1].roomno == rmno && !levl[sx][sy+1].edge) sx++;
349.  	    else goto shk_failed;
350.  	}
351.  	else if(sx == sroom->lx-1) sx++;
352.  	else if(sx == sroom->hx+1) sx--;
353.  	else if(sy == sroom->ly-1) sy++;
354.  	else if(sy == sroom->hy+1) sy--; else {
355.  	shk_failed:
356.  #ifdef DEBUG
357.  # ifdef WIZARD
358.  	    /* Said to happen sometimes, but I have never seen it. */
359.  	    /* Supposedly fixed by fdoor change in mklev.c */
360.  	    if(wizard) {
361.  		register int j = sroom->doorct;
362.  
363.  		pline("Where is shopdoor?");
364.  		pline("Room at (%d,%d),(%d,%d).",
365.  		      sroom->lx, sroom->ly, sroom->hx, sroom->hy);
366.  		pline("doormax=%d doorct=%d fdoor=%d",
367.  		      doorindex, sroom->doorct, sh);
368.  		while(j--) {
369.  		    pline("door [%d,%d]", doors[sh].x, doors[sh].y);
370.  		    sh++;
371.  		}
372.  		display_nhwindow(WIN_MESSAGE, FALSE);
373.  	    }
374.  # endif
375.  #endif
376.  	    return(-1);
377.  	}
378.  
379.  	if(MON_AT(sx, sy)) rloc(m_at(sx, sy)); /* insurance */
380.  
381.  	/* now initialize the shopkeeper monster structure */
382.  	if(!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy))) return(-1);
383.  	shk->isshk = shk->mpeaceful = TRUE;
384.  	set_malign(shk);
385.  	shk->msleep = FALSE;
386.  	shk->mtrapseen = ~0;	/* we know all the traps already */
387.  	ESHK(shk)->shoproom = (sroom - rooms) + ROOMOFFSET;
388.  	sroom->resident = shk;
389.  	ESHK(shk)->shoptype = sroom->rtype;
390.  	assign_level(&(ESHK(shk)->shoplevel), &u.uz);
391.  	ESHK(shk)->shd = doors[sh];
392.  	ESHK(shk)->shk.x = sx;
393.  	ESHK(shk)->shk.y = sy;
394.  	ESHK(shk)->robbed = 0L;
395.  	ESHK(shk)->credit = 0L;
396.  	ESHK(shk)->debit = 0L;
397.  	ESHK(shk)->loan = 0L;
398.  	ESHK(shk)->visitct = 0;
399.  	ESHK(shk)->following = 0;
400.  	ESHK(shk)->billct = 0;
401.  	shk->mgold = 1000L + 30L*(long)rnd(100);	/* initial capital */
402.  	nameshk(shk, shp->shknms);
403.  
404.  	return(sh);
405.  }
406.  
407.  /* stock a newly-created room with objects */
408.  void
409.  stock_room(shp_indx, sroom)
410.  int shp_indx;
411.  register struct mkroom *sroom;
412.  {
413.      /*
414.       * Someday soon we'll dispatch on the shdist field of shclass to do
415.       * different placements in this routine. Currently it only supports
416.       * shop-style placement (all squares except a row nearest the first
417.       * door get objects).
418.       */
419.      register int sx, sy, sh;
420.      char buf[BUFSZ];
421.      int rmno = (sroom - rooms) + ROOMOFFSET;
422.      const struct shclass *shp = &shtypes[shp_indx];
423.  
424.      /* first, try to place a shopkeeper in the room */
425.      if ((sh = shkinit(shp, sroom)) < 0)
426.  	return;
427.  
428.      /* make sure no doorways without doors, and no */
429.      /* trapped doors, in shops.			   */
430.      sx = doors[sroom->fdoor].x;
431.      sy = doors[sroom->fdoor].y;
432.  
433.      if(levl[sx][sy].doormask == D_NODOOR) {
434.  	    levl[sx][sy].doormask = D_ISOPEN;
435.  	    newsym(sx,sy);
436.      }
437.      if(levl[sx][sy].typ == SDOOR) {
438.  	    levl[sx][sy].typ = DOOR;
439.  	    levl[sx][sy].doormask = exposed_sdoor_mask(&levl[sx][sy]);
440.  	    newsym(sx,sy);
441.      }
442.      if(levl[sx][sy].doormask & D_TRAPPED)
443.  	    levl[sx][sy].doormask = D_LOCKED;
444.  
445.      if(levl[sx][sy].doormask == D_LOCKED) {
446.  	    register int m = sx, n = sy;
447.  
448.  	    if(inside_shop(sx+1,sy)) m--;
449.  	    else if(inside_shop(sx-1,sy)) m++;
450.  	    if(inside_shop(sx,sy+1)) n--;
451.  	    else if(inside_shop(sx,sy-1)) n++;
452.  	    Sprintf(buf, "Closed for inventory");
453.  	    make_engr_at(m, n, buf, 0L, DUST);
454.      }
455.  
456.      for(sx = sroom->lx; sx <= sroom->hx; sx++)
457.  	for(sy = sroom->ly; sy <= sroom->hy; sy++) {
458.  	    if(sroom->irregular) {
459.  		if(levl[sx][sy].edge || levl[sx][sy].roomno != rmno ||
460.  		   distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1)
461.  		    continue;
462.  	    } else if((sx == sroom->lx && doors[sh].x == sx-1) ||
463.  		      (sx == sroom->hx && doors[sh].x == sx+1) ||
464.  		      (sy == sroom->ly && doors[sh].y == sy-1) ||
465.  		      (sy == sroom->hy && doors[sh].y == sy+1)) continue;
466.  	    mkshobj_at(shp, sx, sy);
467.  	}
468.  
469.      /*
470.       * Special monster placements (if any) should go here: that way,
471.       * monsters will sit on top of objects and not the other way around.
472.       */
473.  
474.      level.flags.has_shop = TRUE;
475.  }
476.  
477.  #endif /* OVLB */
478.  #ifdef OVL0
479.  
480.  /* does shkp's shop stock this item type? */
481.  boolean
482.  saleable(shkp, obj)
483.  struct monst *shkp;
484.  struct obj *obj;
485.  {
486.      int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE;
487.      const struct shclass *shp = &shtypes[shp_indx];
488.  
489.      if (shp->symb == RANDOM_CLASS) return TRUE;
490.      else for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++)
491.  		if (shp->iprobs[i].itype < 0 ?
492.  			shp->iprobs[i].itype == - obj->otyp :
493.  			shp->iprobs[i].itype == obj->oclass) return TRUE;
494.      /* not found */
495.      return FALSE;
496.  }
497.  
498.  /* positive value: class; negative value: specific object type */
499.  int
500.  get_shop_item(type)
501.  int type;
502.  {
503.  	const struct shclass *shp = shtypes+type;
504.  	register int i,j;
505.  
506.  	/* select an appropriate object type at random */
507.  	for(j = rnd(100), i = 0; (j -= shp->iprobs[i].iprob) > 0; i++)
508.  		continue;
509.  
510.  	return shp->iprobs[i].itype;
511.  }
512.  
513.  #endif /* OVL0 */
514.  
515.  /*shknam.c*/