Source:NetHack 3.3.0/shknam.c

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

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

1.   /*	SCCS Id: @(#)shknam.c	3.3	97/05/25	*/ 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_DCL void FDECL(mkshobj_at, (const struct shclass *,int,int)); 16.  STATIC_DCL void FDECL(nameshk, (struct monst *,const char **)); 17.  STATIC_DCL 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", "Kivenhoug", 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. 	    {{83, FOOD_CLASS}, {5, -POT_FRUIT_JUICE}, {4, -POT_BOOZE}, 194. 	     {5, -POT_WATER}, {3, -ICE_BOX}}, shkfoods}, 195. 	{"jewelers", RING_CLASS, 3, D_SHOP, 196. 	    {{85, RING_CLASS}, {10, GEM_CLASS}, {5, AMULET_CLASS}, {0, 0}}, 197. 	    shkrings}, 198. 	{"quality apparel and accessories", WAND_CLASS, 3, D_SHOP, 199. 	    {{90, WAND_CLASS}, {5, -LEATHER_GLOVES}, {5, -ELVEN_CLOAK}, {0, 0}}, 200. 	     shkwands}, 201. 	{"hardware store", TOOL_CLASS, 3, D_SHOP, 202. 	    {{100, TOOL_CLASS}, {0, 0}, {0, 0}}, shktools}, 203. 	/* Actually shktools is ignored; the code specifically chooses a  204. * random implementor name (along with candle shops having 205.  	 * random shopkeepers) 206. 	 */  207.  	{"rare books", SPBOOK_CLASS, 3, D_SHOP, 208. 	    {{90, SPBOOK_CLASS}, {10, SCROLL_CLASS}, {0, 0}}, shkbooks}, 209. 	/* Shops below this point are "unique". That is they must all have a 210. * probability of zero. They are only created via the special level 211. 	 * loader. 212. 	 */  213.  	{"lighting store", TOOL_CLASS, 0, D_SHOP, 214. 	    {{32, -WAX_CANDLE}, {50, -TALLOW_CANDLE}, 215. 	     {5, -BRASS_LANTERN}, {10, -OIL_LAMP}, {3, -MAGIC_LAMP}}, shklight}, 216. 	{(char *)0, 0, 0, 0, {{0, 0}, {0, 0}, {0, 0}}, 0} 217. };  218.   219.  #if 0 220. /* validate shop probabilities; otherwise incorrect local changes could 221.    end up provoking infinite loops or wild subscripts fetching garbage */ 222. void 223. init_shop_selection 224. {  225.  	register int i, j, item_prob, shop_prob; 226.  227.  	for (shop_prob = 0, i = 0; i < SIZE(shtypes); i++) { 228. 		shop_prob += shtypes[i].prob; 229. 		for (item_prob = 0, j = 0; j < SIZE(shtypes[0].iprobs); j++) 230. 			item_prob += shtypes[i].iprobs[j].iprob; 231. 		if (item_prob != 100) 232. 			panic("item probabilities total to %d for %s shops!",  233.  				item_prob, shtypes[i].name); 234. 	}  235.  	if (shop_prob != 100) 236. 		panic("shop probabilities total to %d!", shop_prob); 237. }  238.  #endif /*0*/ 239.  240.  STATIC_OVL void 241. mkshobj_at(shp, sx, sy) 242. /* make an object of the appropriate type for a shop square */ 243. const struct shclass *shp; 244. int sx, sy; 245. {  246.  	register struct monst *mtmp; 247. 	int atype; 248. 	struct permonst *ptr; 249.  250.  	if (rn2(100) < depth(&u.uz) &&  251.  	    !MON_AT(sx, sy) && (ptr = mkclass(S_MIMIC,0)) &&  252.  	    (mtmp=makemon(ptr,sx,sy,NO_MM_FLAGS))) { 253. 		/* note: makemon will set the mimic symbol to a shop item */ 254. 		if (rn2(10) >= depth(&u.uz)) { 255. 			mtmp->m_ap_type = M_AP_OBJECT; 256. 			mtmp->mappearance = STRANGE_OBJECT; 257. 		}  258.  	} else if ((atype = get_shop_item(shp - shtypes)) < 0) 259. 		(void) mksobj_at(-atype, sx, sy, TRUE); 260. 	else (void) mkobj_at(atype, sx, sy, TRUE); 261. }  262.   263.  /* extract a shopkeeper name for the given shop type */ 264. STATIC_OVL void 265. nameshk(shk, nlp) 266. struct monst *shk; 267. const char *nlp[]; 268. {  269.  	int i, trycnt, names_avail; 270. 	const char *shname = 0; 271. 	struct monst *mtmp; 272. 	int name_wanted; 273. 	s_level *sptr; 274.  275.  	if (nlp == shklight && In_mines(&u.uz)  276.  		&& (sptr = Is_special(&u.uz)) != 0 && sptr->flags.town) { 277. 	    /* special-case minetown lighting shk */ 278. 	    shname = "Izchak"; 279. 	    shk->female = FALSE; 280. 	} else { 281. 	    /* We want variation from game to game, without needing the save 282. 	       and restore support which would be necessary for randomization; 283. 	       try not to make too many assumptions about time_t's internals; 284. 	       use ledger_no rather than depth to keep mine town distinct. */ 285.  	    int nseed = (int)((long)u.ubirthday / 257L); 286.  287.  	    name_wanted = ledger_no(&u.uz) + (nseed % 13) - (nseed % 5); 288. 	    if (name_wanted < 0) name_wanted += (13 + 5); 289. 	    shk->female = name_wanted & 1; 290.  291.  	    for (names_avail = 0; nlp[names_avail]; names_avail++) 292. 		continue; 293.  294.  	    for (trycnt = 0; trycnt < 50; trycnt++) { 295. 		if (nlp == shktools) { 296. 		    shname = shktools[rn2(names_avail)]; 297. 		    shk->female = (*shname == '_'); 298. 		    if (shk->female) shname++; 299. 		} else if (name_wanted < names_avail) { 300. 		    shname = nlp[name_wanted]; 301. 		} else if ((i = rn2(names_avail)) != 0) { 302. 		    shname = nlp[i - 1]; 303. 		} else if (nlp != shkgeneral) { 304. 		    nlp = shkgeneral;	/* try general names */ 305. 		    for (names_avail = 0; nlp[names_avail]; names_avail++) 306. 			continue; 307. 		    continue;		/* next `trycnt' iteration */ 308. 		} else { 309. 		    shname = shk->female ? "Lucrezia" : "Dirk"; 310. 		}  311.   312.  		/* is name already is use on this level? */ 313.  		for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { 314. 		    if (mtmp == shk) continue; 315. 		    if (!mtmp->isshk) continue; 316. 		    if (strcmp(ESHK(mtmp)->shknam, shname)) continue; 317. 		    break; 318. 		}  319.  		if (!mtmp) break;	/* new name */ 320. 	    }  321.  	}  322.  	(void) strncpy(ESHK(shk)->shknam, shname, PL_NSIZ); 323. 	ESHK(shk)->shknam[PL_NSIZ-1] = 0; 324. }  325.   326.  STATIC_OVL int 327. shkinit(shp, sroom)	/* create a new shopkeeper in the given room */ 328. const struct shclass	*shp; 329. struct mkroom	*sroom; 330. {  331.  	register int sh, sx, sy; 332. 	struct monst *shk; 333.  334.  	/* place the shopkeeper in the given room */ 335. 	sh = sroom->fdoor; 336. 	sx = doors[sh].x;  337. sy = doors[sh].y; 338. 339. 	/* check that the shopkeeper placement is sane */ 340. 	if(sroom->irregular) { 341. 	    int rmno = (sroom - rooms) + ROOMOFFSET; 342. 	    if (isok(sx-1,sy) && !levl[sx-1][sy].edge &&  343.  		(int) levl[sx-1][sy].roomno == rmno) sx--; 344. 	    else if (isok(sx+1,sy) && !levl[sx+1][sy].edge &&  345.  		(int) levl[sx+1][sy].roomno == rmno) sx++; 346. 	    else if (isok(sx,sy-1) && !levl[sx][sy-1].edge &&  347.  		(int) levl[sx][sy-1].roomno == rmno) sy--; 348. 	    else if (isok(sx,sy+1) && !levl[sx][sy+1].edge &&  349.  		(int) levl[sx][sy+1].roomno == rmno) sx++; 350. 	    else goto shk_failed; 351. 	}  352.  	else if(sx == sroom->lx-1) sx++; 353. 	else if(sx == sroom->hx+1) sx--; 354. 	else if(sy == sroom->ly-1) sy++; 355. 	else if(sy == sroom->hy+1) sy--; else { 356. 	shk_failed: 357. #ifdef DEBUG 358. # ifdef WIZARD 359. 	    /* Said to happen sometimes, but I have never seen it. */ 360.  	    /* Supposedly fixed by fdoor change in mklev.c */ 361. 	    if(wizard) { 362. 		register int j = sroom->doorct; 363.  364.  		pline("Where is shopdoor?"); 365. 		pline("Room at (%d,%d),(%d,%d).",  366.  		      sroom->lx, sroom->ly, sroom->hx, sroom->hy); 367. 		pline("doormax=%d doorct=%d fdoor=%d",  368.  		      doorindex, sroom->doorct, sh); 369. 		while(j--) { 370. 		    pline("door [%d,%d]", doors[sh].x, doors[sh].y); 371. 		    sh++; 372. 		}  373.  		display_nhwindow(WIN_MESSAGE, FALSE); 374. 	    }  375.  # endif 376. #endif 377. 	    return(-1); 378. 	}  379.   380.  	if(MON_AT(sx, sy)) rloc(m_at(sx, sy)); /* insurance */ 381.  382.  	/* now initialize the shopkeeper monster structure */ 383. 	if(!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy, NO_MM_FLAGS))) 384. 		return(-1); 385. 	shk->isshk = shk->mpeaceful = 1; 386. 	set_malign(shk); 387. 	shk->msleeping = 0; 388. 	shk->mtrapseen = ~0;	/* we know all the traps already */ 389. 	ESHK(shk)->shoproom = (sroom - rooms) + ROOMOFFSET; 390. 	sroom->resident = shk; 391. 	ESHK(shk)->shoptype = sroom->rtype; 392. 	assign_level(&(ESHK(shk)->shoplevel), &u.uz); 393. 	ESHK(shk)->shd = doors[sh]; 394. 	ESHK(shk)->shk.x = sx; 395. 	ESHK(shk)->shk.y = sy; 396. 	ESHK(shk)->robbed = 0L; 397. 	ESHK(shk)->credit = 0L; 398. 	ESHK(shk)->debit = 0L; 399. 	ESHK(shk)->loan = 0L; 400. 	ESHK(shk)->visitct = 0; 401. 	ESHK(shk)->following = 0; 402. 	ESHK(shk)->billct = 0; 403. 	shk->mgold = 1000L + 30L*(long)rnd(100);	/* initial capital */ 404. 	nameshk(shk, shp->shknms); 405.  406.  	return(sh); 407. }  408.   409.  /* stock a newly-created room with objects */ 410. void 411. stock_room(shp_indx, sroom) 412. int shp_indx; 413. register struct mkroom *sroom; 414. {  415.      /*  416.       * Someday soon we'll dispatch on the shdist field of shclass to do  417. * different placements in this routine. Currently it only supports 418.      * shop-style placement (all squares except a row nearest the first  419.       * door get objects). 420.      */  421.      register int sx, sy, sh; 422.     char buf[BUFSZ]; 423.     int rmno = (sroom - rooms) + ROOMOFFSET; 424.     const struct shclass *shp = &shtypes[shp_indx]; 425.  426.      /* first, try to place a shopkeeper in the room */ 427.     if ((sh = shkinit(shp, sroom)) < 0) 428. 	return; 429.  430.      /* make sure no doorways without doors, and no */ 431.     /* trapped doors, in shops. */ 432.      sx = doors[sroom->fdoor].x;  433. sy = doors[sroom->fdoor].y; 434. 435.     if(levl[sx][sy].doormask == D_NODOOR) { 436. 	    levl[sx][sy].doormask = D_ISOPEN; 437. 	    newsym(sx,sy); 438.     }  439.      if(levl[sx][sy].typ == SDOOR) { 440. 	    cvt_sdoor_to_door(&levl[sx][sy]);	/* .typ = DOOR */ 441. 	    newsym(sx,sy); 442.     }  443.      if(levl[sx][sy].doormask & D_TRAPPED) 444. 	    levl[sx][sy].doormask = D_LOCKED; 445.  446.      if(levl[sx][sy].doormask == D_LOCKED) { 447. 	    register int m = sx, n = sy; 448.  449.  	    if(inside_shop(sx+1,sy)) m--; 450. 	    else if(inside_shop(sx-1,sy)) m++; 451. 	    if(inside_shop(sx,sy+1)) n--; 452. 	    else if(inside_shop(sx,sy-1)) n++; 453. 	    Sprintf(buf, "Closed for inventory"); 454. 	    make_engr_at(m, n, buf, 0L, DUST); 455.     }  456.   457.      for(sx = sroom->lx; sx <= sroom->hx; sx++) 458. 	for(sy = sroom->ly; sy <= sroom->hy; sy++) { 459. 	    if(sroom->irregular) { 460. 		if (levl[sx][sy].edge || (int) levl[sx][sy].roomno != rmno ||  461.  		   distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1) 462. 		    continue; 463. 	    } else if((sx == sroom->lx && doors[sh].x == sx-1) ||  464.  		      (sx == sroom->hx && doors[sh].x == sx+1) ||  465.  		      (sy == sroom->ly && doors[sh].y == sy-1) ||  466.  		      (sy == sroom->hy && doors[sh].y == sy+1)) continue; 467. 	    mkshobj_at(shp, sx, sy); 468. 	}  469.   470.      /*  471.       * Special monster placements (if any) should go here: that way, 472.      * monsters will sit on top of objects and not the other way around. 473.      */  474.   475.      level.flags.has_shop = TRUE; 476. }  477.   478.  #endif /* OVLB */ 479. #ifdef OVL0 480.  481.  /* does shkp's shop stock this item type? */ 482.  boolean 483. saleable(shkp, obj) 484. struct monst *shkp; 485. struct obj *obj; 486. {  487.      int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE; 488.     const struct shclass *shp = &shtypes[shp_indx]; 489.  490.      if (shp->symb == RANDOM_CLASS) return TRUE; 491.     else for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) 492. 		if (shp->iprobs[i].itype < 0 ?  493.  			shp->iprobs[i].itype == - obj->otyp :  494.  			shp->iprobs[i].itype == obj->oclass) return TRUE; 495.     /* not found */ 496.     return FALSE; 497. }  498.   499.  /* positive value: class; negative value: specific object type */ 500. int 501. get_shop_item(type) 502. int type; 503. {  504.  	const struct shclass *shp = shtypes+type; 505. 	register int i,j; 506.  507.  	/* select an appropriate object type at random */ 508. 	for(j = rnd(100), i = 0; (j -= shp->iprobs[i].iprob) > 0; i++) 509. 		continue; 510.  511.  	return shp->iprobs[i].itype; 512. }  513.   514.  #endif /* OVL0 */ 515.  516.  /*shknam.c*/