Difference between revisions of "Source:NetHack 3.4.3/src/shknam.c"

From NetHackWiki
Jump to navigation Jump to search
(General store: More name info and links.)
m (Adding __MIXEDSYNTAXHIGHLIGHT__)
Line 1: Line 1:
 +
__MIXEDSYNTAXHIGHLIGHT__
 
Below is the full text to src/shknam.c from NetHack 3.4.3. To link to a particular line, write [[shknam.c#line123|<nowiki>[[shknam.c#line123]]</nowiki>]], for example.
 
Below is the full text to src/shknam.c from NetHack 3.4.3. To link to a particular line, write [[shknam.c#line123|<nowiki>[[shknam.c#line123]]</nowiki>]], for example.
  

Revision as of 19:09, 20 November 2010

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

Top of file

/*	SCCS Id: @(#)shknam.c	3.4	2003/01/09	*/
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed.  See license for details. */

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.

/* shknam.c -- initialize a shop */

#include "hack.h"
#include "eshk.h"

#ifndef OVLB
extern const struct shclass shtypes[];

#else

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 *));

Shopkeeper names

Most shopkeeper names are names of cities, towns and villages of various sizes, some of them quite obscure and remote. The exceptions are the tool shop and ring shop names.

The shopkeeper name lists are among the most archaic parts of NetHack; many lists are unchanged since Hack 1.0.

Potion store

static const char * const shkliquors[] = {
/* Ukraine */
"Njezjin", "[[wikipedia:Chernihiv|Tsjernigof]]", "Ossipewsk", "[[wikipedia:Horlivka|Gorlowka]]",
/* Belarus */
"[[wikipedia:Homyel|Gomel]]",
/* N. Russia */
"Konosja", "[[wikipedia:Veliky Ustyug|Weliki Oestjoeg]]", "[[wikipedia:Syktywkar|Syktywkar]]", "Sablja",
"[[wikipedia:Mount Narodnaja|Narodnaja]]", "[[wikipedia:Kyzyl|Kyzyl]]",
/* Silezie */
"[[wikipedia:Wałbrzych|Walbrzych]]", "[[wikipedia:Świdnica|Swidnica]]", "[[wikipedia:Kłodzko|Klodzko]]", "[[wikipedia:Racibórz|Raciborz]]", "[[wikipedia:Gliwice|Gliwice]]",
"[[wikipedia:Brzeg|Brzeg]]", "[[wikipedia:Krnov|Krnov]]", "[[wikipedia:Hradec Králové|Hradec Kralove]]",
/* Schweiz */
"[[wikipedia:Leuk|Leuk]]", "[[wikipedia:Brig, Switzerland|Brig]]", "[[wikipedia:Brienz|Brienz]]", "[[wikipedia:Thun|Thun]]", "[[wikipedia:Sarnen|Sarnen]]", "[[wikipedia:Bürglen|Burglen]]", "[[wikipedia:Elm, Switzerland|Elm]]",
"[[wikipedia:Flims|Flims]]", "[[wikipedia:Vals, Switzerland|Vals]]", "[[wikipedia:Scuol|Schuls]]", "Zum Loch",
0
};

The Ukrainian names, as well as Gomel, are in their Russian forms; the places themselves are now named in the local languages.

Tsjernigof and Weliki Oestjoeg are given Dutch rather than English transliteration. The English names are Chernigov and Veliky Ustyug.

Gomel was placed in the Ukraine section through NetHack 3.4.1. It's close to the border, and the error is understandable, given that Hack 1.0 predates the breakup of the Soviet Union by several years. This list is otherwise unchanged since Hack 1.0.

Spellbook store

static const char * const shkbooks[] = {
/* Eire */
"[[wikipedia:Skibbereen|Skibbereen]]", "[[wikipedia:Kanturk|Kanturk]]", "[[wikipedia:Charleville, County Cork|Rath Luirc]]", "[[wikipedia:Ennistimon|Ennistymon]]", "[[wikipedia:Lahinch|Lahinch]]",
"[[wikipedia:Kinnegad|Kinnegad]]", "[[wikipedia:Lugnaquillia|Lugnaquillia]]", "[[wikipedia:Enniscorthy|Enniscorthy]]", "Gweebarra",
"Kittamagh", "[[wikipedia:Nenagh|Nenagh]]", "[[wikipedia:Sneem|Sneem]]", "[[wikipedia:Ballingeary|Ballingeary]]", "[[wikipedia:Kilgarvan|Kilgarvan]]",
"[[wikipedia:Cahirciveen|Cahersiveen]]", "Glenbeigh", "[[wikipedia:Kilmihil|Kilmihil]]", "Kiltamagh",
"[[wikipedia:Drogheda|Droichead Atha]]", "[[wikipedia:Inniscrone|Inniscrone]]", "[[wikipedia:Clonegal|Clonegal]]", "[[wikipedia:Lisnaskea|Lisnaskea]]",
"Culdaff", "[[wikipedia:Dunfanaghy|Dunfanaghy]]", "[[wikipedia:Inishbofin|Inishbofin]]", "[[wikipedia:Kesh, County Fermanagh|Kesh]]",
0
};

Skibbereen is the setting of an old song about the Potato Famine. Here is one version of the lyrics.

"Kittamagh" and "Kiltamagh" may be misspellings of Kiltimagh.

Two small offshore islands are named Inishbofin, one in Galway and the other in Donegal; the link goes to the disambiguation page.

The town of Kesh is actually in Northern Ireland. There is also a river called Kesh, but it is unclear at this time whether any part of it is in the Republic of Ireland.

Several names disappeared from this list in NetHack 2.2a: Loughrea, Croagh, Maumakeogh and Ballyjamesduff.

Armor store

static const char * const shkarmors[] = {
/* Turquie */
"[[wikipedia:Demirci|Demirci]]", "[[wikipedia:Kalecik|Kalecik]]", "Boyabai", "[[wikipedia:Yıldızeli|Yildizeli]]", "[[wikipedia:Gaziantep|Gaziantep]]",
"[[wikipedia:Siirt|Siirt]]", "Akhalataki", "[[wikipedia:Tirebolu|Tirebolu]]", "[[wikipedia:Aksaray|Aksaray]]", "[[wikipedia:Ermenek|Ermenak]]",
"[[wikipedia:İskenderun|Iskenderun]]", "[[wikipedia:Kadirli|Kadirli]]", "[[wikipedia:Siverek|Siverek]]", "[[wikipedia:Pervari|Pervari]]", "Malasgirt",
"[[wikipedia:Bayburt|Bayburt]]", "[[wikipedia:Ayancık|Ayancik]]", "[[wikipedia:Zonguldak|Zonguldak]]", "[[wikipedia:Balya|Balya]]", "[[wikipedia:Tefenni|Tefenni]]",
"[[wikipedia:Artvin|Artvin]]", "[[wikipedia:Kars|Kars]]", "Makharadze", "[[wikipedia:Malazgirt|Malazgirt]]", "[[wikipedia:Midyat|Midyat]]",
"[[wikipedia:Birecik|Birecik]]", "[[wikipedia:Kırıkkale|Kirikkale]]", "[[wikipedia:Alaca|Alaca]]", "[[wikipedia:Polatlı|Polatli]]", "[[wikipedia:Nallıhan|Nallihan]]",
0
};

Makharadze and Akhalataki are actually in the Republic of Georgia.

Malasgirt may refer to the same place as Malazgirt.

This list is unchanged since Hack 1.0.

Wand store

static const char * const shkwands[] = {
/* Wales */
"[[wikipedia:Mold, Flintshire|Yr Wyddgrug]]", "[[wikipedia:Welshpool|Trallwng]]", "[[wikipedia:Mallwyd|Mallwyd]]", "[[wikipedia:Devil's Bridge, Ceredigion|Pontarfynach]]",
"[[wikipedia:Pistyll Rhaeadr|Rhaeader]]", "[[wikipedia:Llandrindod Wells|Llandrindod]]", "[[wikipedia:Builth Wells|Llanfair-ym-muallt]]",
"[[wikipedia:Abergavenny|Y-Fenni]]", "[[wikipedia:Maesteg|Maesteg]]", "[[wikipedia:Ammanford|Rhydaman]]", "[[wikipedia:Beddgelert|Beddgelert]]",
"[[wikipedia:Capel Curig|Curig]]", "[[wikipedia:Llanrwst|Llanrwst]]", "[[wikipedia:Llanerchymedd|Llanerchymedd]]", "[[wikipedia:Holyhead|Caergybi]]",
/* Scotland */
"[[wikipedia:Nairn|Nairn]]", "[[wikipedia:Turriff|Turriff]]", "[[wikipedia:Inverurie|Inverurie]]", "[[wikipedia:Braemar|Braemar]]", "[[wikipedia:Lochnagar|Lochnagar]]",
"Kerloch", "[[wikipedia:Beinn a' Ghlò|Beinn a Ghlo]]", "[[wikipedia:Drumnadrochit|Drumnadrochit]]", "[[wikipedia:Morven|Morven]]",
"[[wikipedia:Uist|Uist]]", "[[wikipedia:The Storr|Storr]]", "[[wikipedia:Sgurr na Ciche|Sgurr na Ciche]]", "[[wikipedia:Cannich|Cannich]]", "[[wikipedia:Gairloch|Gairloch]]",
"[[wikipedia:Kyleakin|Kyleakin]]", "[[wikipedia:Dunvegan|Dunvegan]]",
0
};

Llanfair-ym-muallt is known in English as Builth Wells and is not to be confused with "Llanfair PG", said to have the longest town name in the UK.

Morven is the name of two mountains, one in Aberdeenshire and the other in Caithness. The link goes to the disambiguation page.

This list is unchanged since Hack 1.0.

Ring store

static const char * const shkrings[] = {
/* Hollandse familienamen */
"Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken",
"Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy",
"Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix",
"Ypey",
/* Skandinaviske navne */
"Rastegaisa", "Varjag Njarga", "[[wikipedia:Kautokeino|Kautekeino]]", "[[wikipedia:Abisko|Abisko]]",
"[[wikipedia:Enontekis|Enontekis]]", "[[wikipedia:Rovaniemi|Rovaniemi]]", "Avasaksa", "[[wikipedia:Haparanda|Haparanda]]",
"[[wikipedia:Lulea|Lulea]]", "[[wikipedia:G%C3%A4llivare_Municipality|Gellivare]]", "Oeloe", "[[wikipedia:Kajaani|Kajaani]]", "[[wikipedia:Fauske|Fauske]]",
0
};

The reason for "Hollandse familienamen" may be that Andries Brouwer is Dutch.

This list is unchanged since Hack 1.0.

Food store

static const char * const shkfoods[] = {
/* Indonesia */
"Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan",
"Bandjar", "Parbalingga", "Bojolali", "Sarangan",
"Ngebel", "Djombang", "Ardjawinangun", "Berbek",
"[[wikipedia:Papar, Sabah|Papar]]", "Baliga", "Tjisolok", "Siboga", "[[wikipedia:Banyuwangi|Banjoewangi]]",
"[[wikipedia:Trenggalek|Trenggalek]]", "Karangkobar", "Njalindoeng", "Pasawahan",
"Pameunpeuk", "Patjitan", "[[wikipedia:Kediri, East Java|Kediri]]", "Pemboeang", "Tringanoe",
"[[wikipedia:Butaritari|Makin]]", "Tipor", "[[wikipedia:Semai|Semai]]", "Berhala", "[[wikipedia:Tegal|Tegal]]", "Samoe",
0
};

Papar is actually in Malaysia, on the island of Borneo.

Makin is an island in Kiribati.

The Semai are an indigenous people of the Malay Peninsula.

This list is unchanged since Hack 1.0.

Weapon store

static const char * const shkweapons[] = {
/* Perigord */
"Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard",
"Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac",
"Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac",
"Cazelon", "Eypau", "Carignan", "[[wikipedia:Monbazillac|Monbazillac]]", "[[wikipedia:Jonzac|Jonzac]]",
"Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon",
"Eymoutiers", "Eygurande", "[[wikipedia:Eauze|Eauze]]", "Labouheyre",
0
};

This list is unchanged since Hack 1.0.

Tool store

static const char * const shktools[] = {
/* Spmi */
"Ymla", "Eed-morra", "Cubask", "Nieb", "Bnowr Falr", "Telloc Cyaj",
"Sperc", "Noskcirdneh", "Yawolloh", "Hyeghu", "Niskal", "Trahnil",
"Htargcm", "Enrobwem", "Kachzi Rellim", "Regien", "Donmyar",
"Yelpur", "Nosnehpets", "Stewe", "Renrut", "_Zlaw", "Nosalnef",
"Rewuorb", "Rellenk", "Yad", "Cire Htims", "Y-crad", "Nenilukah",
"Corsh", "Aned",
#ifdef OVERLAY
"Erreip", "Nehpets", "Mron", "Snivek", "Lapu", "Kahztiy",
#endif
#ifdef WIN32
"Lechaim", "Lexa", "Niod",
#endif
#ifdef MAC
"Nhoj-lee", "Evad\'kh", "Ettaw-noj", "Tsew-mot", "Ydna-s",
"Yao-hang", "Tonbar", "Kivenhoug",
#endif
#ifdef AMIGA
"Falo", "Nosid-da\'r", "Ekim-p", "Rebrol-nek", "Noslo", "Yl-rednow",
"Mured-oog", "Ivrajimsal",
#endif
#ifdef TOS
"Nivram",
#endif
#ifdef VMS
"Lez-tneg", "Ytnu-haled", "Niknar",
#endif
0
};

"Spmi" is "imps" spelled backward. The tool store keeper names are anagrams of names of various Hack and NetHack developers; usually the names are spelled backwards. This RGRN post gives a nearly complete list as of the then-current version of NetHack. These are matched with the names, and a few more recent additions provided, in the following table.

The "spmi" first appear in NetHack 3.0.0. Some additions to the list have been made since then.

The names in the OVERLAY section will not appear in any actual version of NetHack, as the 16-bit MS-DOS build is no longer supported (see MS-DOS).

Name Named after Version
Ymla Tom Almy 3.0.0
Eed-morra Ken Arromdee 3.0.0
Cubask Eric Backus 3.0.0
Nieb John S. Bien 3.0.0
Bnowr Falr Ralf Brown 3.0.0
Telloc Cyaj Jean-Christophe "JC" Collet 3.0.0
Sperc Steve Creps 3.0.0
Noskcirdneh Eric Hendrickson 3.0.0
Yawolloh Bruce Holloway 3.0.0
Hyeghu Richard P. Hughey 3.0.0
Niskal Greg Laskin 3.0.0
Trahnil Steve Linhart 3.0.0
Htargcm Roland McGrath 3.0.0
Enrobwem Bruce Mewborne 3.0.0
Kachzi Rellim Izchak Miller 3.0.0
Regien Gil Neiger 3.0.0
Donmyar Eric Raymond 3.0.0
Yelpur John Rupley 3.0.0
Nosnehpets Mike Stephenson 3.0.0
Stewe Kevin Sweet 3.0.0
Renrut Scott R Turner 3.0.0
Zlaw Janet Walz 3.0.0
Nosalnef Jay Fenlason 3.0.0
Rewuorb Andries Brouwer 3.0.0
Rellenk Don G Kneller 3.0.0
Yad Matt Day 3.0.8
Cire Htims Eric Smith 3.0.8
Y-crad Kevin Darcy 3.0.8
Nenilukah Timo Hakulinen 3.0.8
Corsh David Cohrs 3.1.3
Aned Dean Luick? 3.1.3
Erreip Pierre Martineau 3.0.8 - 3.3.1
Nehpets Stephen Spackman 3.0.8 - 3.3.1
Mron Norm Melluch 3.0.8 - 3.3.1
Snivek Kevin Smolkowski 3.0.8 - 3.3.1
Lapu Paul Winner 3.1.3 - 3.3.1
Kahztiy Yitzhak Sapir 3.2.0 - 3.3.1
Lechaim Michael Allison 3.1.3
Lexa Alex Kompel 3.4.0
Niod Dion Nicolaas 3.4.0
Nhoj-lee Johnny Lee 3.0.8
Evad'kh Dave KH? 3.0.8
Ettaw-noj Jon Watte 3.0.8
Tsew-mot Tom West 3.0.8
Ydna-s Andy Swanson 3.0.8
Yao-hang Hao-yang Wang 3.1.3
Tonbar Barton House 3.1.3
Kivenhoug Kevin Hugo 3.3.0
Falo Olaf Seibert 3.0.8
Nosid-da'r Richard Addison 3.0.8
Ekim-p Mike Passaretti 3.0.8
Rebrol-nek Ken Lorber 3.0.8
Noslo Greg Olson 3.0.8
Yl-rednow Gregg Wonderly 3.0.8
Mured-oog Mark Gooderum 3.0.8
Ivrajimsal Janne Salmijarvi 3.3.1
Nivram Christian "Marvin" Bressler 3.3.1
Lez-tneg David Gentzel 3.0.8
Ytnu-haled Joshua Delahunty 3.0.8
Niknar Pat Rankin 3.0.8

Light store

static const char * const shklight[] = {
/* Romania */
"[[wikipedia:Zărneşti|Zarnesti]]", "[[wikipedia:Slănic|Slanic]]", "Nehoiasu", "[[wikipedia:Luduş|Ludus]]", "[[wikipedia:Sighişoara|Sighisoara]]", "Nisipitu",
"Razboieni", "[[wikipedia:Bicaz|Bicaz]]", "[[wikipedia:Dorohoi|Dorohoi]]", "[[wikipedia:Vaslui|Vaslui]]", "[[wikipedia:Feteşti|Fetesti]]", "[[wikipedia:Tirgu Neamt|Tirgu Neamt]]",
"[[wikipedia:Babadag|Babadag]]", "[[wikipedia:Zimnicea|Zimnicea]]", "[[wikipedia:Zlatna|Zlatna]]", "[[wikipedia:Jiu River|Jiu]]", "[[wikipedia:Eforie|Eforie]]", "[[wikipedia:Mamaia|Mamaia]]",
/* Bulgaria */
"[[wikipedia:Silistra|Silistra]]", "Tulovo", "Panagyuritshte", "[[wikipedia:Smolyan|Smolyan]]", "[[wikipedia:Kırklareli|Kirklareli]]",
"[[wikipedia:Pernik|Pernik]]", "[[wikipedia:Lom, Bulgaria|Lom]]", "[[wikipedia:Haskovo|Haskovo]]", "Dobrinishte", "[[wikipedia:Varvara|Varvara]]", "[[wikipedia:Oryahovo|Oryahovo]]",
"[[wikipedia:Troyan|Troyan]]", "[[wikipedia:Lovech|Lovech]]", "[[wikipedia:Sliven|Sliven]]",
0
};

These names were introduced in NetHack 3.1.2, but have been in disuse since NetHack 3.2.0. An unmodified game has only one lighting store, and its keeper is Izchak.

SLASH'EM can generate a lighting store in the "mall" level of its main dungeon; its keeper will have a name from the above list.

Sighişoara is said to be the birthplace of Vlad Ţepeş -- Vlad the Impaler himself.

Kırklareli is actually in Turkey.

General store

static const char * const shkgeneral[] = {
/* Suriname */
"Hebiwerie", "[[wikipedia:Poesoegroenoe_Airstrip|Possogroenoe]]", "Asidonhopo", "Manlobbi",
"Adjama", "[[wikipedia:Pakka-Pakka|Pakka Pakka]]", "[[wikipedia:Kabalebo|Kabalebo]]", "Wonotobo",
"Akalapi", "[[wikipedia:Sipaliwini_District|Sipaliwini]]",
/* Greenland */
"[[wikipedia:Annoatok|Annootok]]", "[[wikipedia:Upernavik|Upernavik]]", "[[wikipedia:Tasiilaq|Angmagssalik]]",
/* N. Canada */
"[[wikipedia:Aklavik, Northwest Territories|Aklavik]]", "[[wikipedia:Inuvik, Northwest Territories|Inuvik]]", "[[wikipedia:Tuktoyaktuk|Tuktoyaktuk]]",
"[[wikipedia:Chicoutimi, Quebec|Chicoutimi]]", "[[wikipedia:Lac_Saint-Jean|Ouiatchouane]]", "[[wikipedia:Chibougamau,_Quebec|Chibougamau]]",
"[[wikipedia:Matagami, Quebec|Matagami]]", "[[wikipedia:Kipawa River|Kipawa]]", "Kinojevis",
"[[wikipedia:Abitibi|Abitibi]]", "Maganasipi",
/* Iceland */
"[[wikipedia:Akureyri|Akureyri]]", "[[wikipedia:Kópasker|Kopasker]]", "Budereyri", "[[wikipedia:Akranes|Akranes]]", "[[wikipedia:Bordeyri|Bordeyri]]",
"[[wikipedia:Hólmavík|Holmavik]]",
0
};

Most of the locations in Suriname seem to be in the Sipaliwini District, which is the southern part of Suriname. “Possogroenoe” is apparently a misspelling of “Poesoegroenoe”, where the “oe” vowels are the long [u] sound in Dutch. “Wonotobo” is the name of a famous waterfall in Suriname.

“Annootok” is a misspelling of Annoatok, an abandoned place in northeast Greenland. “Angmagssalik” is an older spelling of Ammassalik, a town in southeast Greenland which has since been renamed to Tasiilaq.

Ouiatchouane is a small river which empties into Lac Saint-Jean in Quebec.

“Kopasker” is actually Kópasker and Holmavik is actually Hólmavík, both small towns in Iceland.

This list is unchanged since Hack 1.0.

shtypes

/*
* To add new shop types, all that is necessary is to edit the shtypes[] array.
* See mkroom.h for the structure definition.  Typically, you'll have to lower
* some or all of the probability fields in old entries to free up some
* percentage for the new type.
*
* The placement type field is not yet used but will be in the near future.
*
* The iprobs array in each entry defines the probabilities for various kinds
* of objects to be present in the given shop type.  You can associate with
* each percentage either a generic object type (represented by one of the
* *_CLASS macros) or a specific object (represented by an onames.h define).
* In the latter case, prepend it with a unary minus so the code can know
* (by testing the sign) whether to use mkobj() or mksobj().
*/

const struct shclass shtypes[] = {
	{"general store", RANDOM_CLASS, 44,
	    D_SHOP, {{100, RANDOM_CLASS}, {0, 0}, {0, 0}}, shkgeneral},
	{"used armor dealership", ARMOR_CLASS, 14,
	    D_SHOP, {{90, ARMOR_CLASS}, {10, WEAPON_CLASS}, {0, 0}},
	     shkarmors},
	{"second-hand bookstore", SCROLL_CLASS, 10, D_SHOP,
	    {{90, SCROLL_CLASS}, {10, SPBOOK_CLASS}, {0, 0}}, shkbooks},
	{"liquor emporium", POTION_CLASS, 10, D_SHOP,
	    {{100, POTION_CLASS}, {0, 0}, {0, 0}}, shkliquors},
	{"antique weapons outlet", WEAPON_CLASS, 5, D_SHOP,
	    {{90, WEAPON_CLASS}, {10, ARMOR_CLASS}, {0, 0}}, shkweapons},
	{"delicatessen", FOOD_CLASS, 5, D_SHOP,
	    {{83, FOOD_CLASS}, {5, -POT_FRUIT_JUICE}, {4, -POT_BOOZE},
	     {5, -POT_WATER}, {3, -ICE_BOX}}, shkfoods},
	{"jewelers", RING_CLASS, 3, D_SHOP,
	    {{85, RING_CLASS}, {10, GEM_CLASS}, {5, AMULET_CLASS}, {0, 0}},
	    shkrings},
	{"quality apparel and accessories", WAND_CLASS, 3, D_SHOP,
	    {{90, WAND_CLASS}, {5, -LEATHER_GLOVES}, {5, -ELVEN_CLOAK}, {0, 0}},
	     shkwands},
	{"hardware store", TOOL_CLASS, 3, D_SHOP,
	    {{100, TOOL_CLASS}, {0, 0}, {0, 0}}, shktools},
	/* Actually shktools is ignored; the code specifically chooses a
	 * random implementor name (along with candle shops having
	 * random shopkeepers)
	 */
	{"rare books", SPBOOK_CLASS, 3, D_SHOP,
	    {{90, SPBOOK_CLASS}, {10, SCROLL_CLASS}, {0, 0}}, shkbooks},
	/* Shops below this point are "unique".  That is they must all have a
	 * probability of zero.  They are only created via the special level
	 * loader.
	 */
	{"lighting store", TOOL_CLASS, 0, D_SHOP,
	    {{32, -WAX_CANDLE}, {50, -TALLOW_CANDLE},
	     {5, -BRASS_LANTERN}, {10, -OIL_LAMP}, {3, -MAGIC_LAMP}}, shklight},
	{(char *)0, 0, 0, 0, {{0, 0}, {0, 0}, {0, 0}}, 0}
};

init_shop_selection

#if 0
/* validate shop probabilities; otherwise incorrect local changes could
end up provoking infinite loops or wild subscripts fetching garbage */
void
init_shop_selection()
{
	register int i, j, item_prob, shop_prob;

	for (shop_prob = 0, i = 0; i < SIZE(shtypes); i++) {
		shop_prob += shtypes[i].prob;
		for (item_prob = 0, j = 0; j < SIZE(shtypes[0].iprobs); j++)
			item_prob += shtypes[i].iprobs[j].iprob;
		if (item_prob != 100)
			panic("item probabilities total to %d for %s shops!",
				item_prob, shtypes[i].name);
	}
	if (shop_prob != 100)
		panic("shop probabilities total to %d!", shop_prob);
}
#endif /*0*/

mkshobj_at

STATIC_OVL void
mkshobj_at(shp, sx, sy)
/* make an object of the appropriate type for a shop square */
const struct shclass *shp;
int sx, sy;
{
	struct monst *mtmp;
	int atype;
	struct permonst *ptr;

	if (rn2(100) < depth(&u.uz) &&
		!MON_AT(sx, sy) && (ptr = mkclass(S_MIMIC,0)) &&
		(mtmp = makemon(ptr,sx,sy,NO_MM_FLAGS)) != 0) {
	    /* note: makemon will set the mimic symbol to a shop item */
	    if (rn2(10) >= depth(&u.uz)) {
		mtmp->m_ap_type = M_AP_OBJECT;
		mtmp->mappearance = STRANGE_OBJECT;
	    }
	} else {
	    atype = get_shop_item(shp - shtypes);
	    if (atype < 0)
		(void) mksobj_at(-atype, sx, sy, TRUE, TRUE);
	    else
		(void) mkobj_at(atype, sx, sy, TRUE);
	}
}

nameshk

/* extract a shopkeeper name for the given shop type */
STATIC_OVL void
nameshk(shk, nlp)
struct monst *shk;
const char * const *nlp;
{
	int i, trycnt, names_avail;
	const char *shname = 0;
	struct monst *mtmp;
	int name_wanted;
	s_level *sptr;

	if (nlp == shklight && In_mines(&u.uz)
		&& (sptr = Is_special(&u.uz)) != 0 && sptr->flags.town) {
	    /* special-case minetown lighting shk */
	    shname = "Izchak";
	    shk->female = FALSE;
	} else {
	    /* We want variation from game to game, without needing the save
	       and restore support which would be necessary for randomization;
	       try not to make too many assumptions about time_t's internals;
	       use ledger_no rather than depth to keep mine town distinct. */
	    int nseed = (int)((long)u.ubirthday / 257L);

	    name_wanted = ledger_no(&u.uz) + (nseed % 13) - (nseed % 5);
	    if (name_wanted < 0) name_wanted += (13 + 5);
	    shk->female = name_wanted & 1;

	    for (names_avail = 0; nlp[names_avail]; names_avail++)
		continue;

	    for (trycnt = 0; trycnt < 50; trycnt++) {
		if (nlp == shktools) {
		    shname = shktools[rn2(names_avail)];
		    shk->female = (*shname == '_');
		    if (shk->female) shname++;
		} else if (name_wanted < names_avail) {
		    shname = nlp[name_wanted];
		} else if ((i = rn2(names_avail)) != 0) {
		    shname = nlp[i - 1];
		} else if (nlp != shkgeneral) {
		    nlp = shkgeneral;	/* try general names */
		    for (names_avail = 0; nlp[names_avail]; names_avail++)
			continue;
		    continue;		/* next `trycnt' iteration */
		} else {
		    shname = shk->female ? "Lucrezia" : "Dirk";
		}

		/* is name already in use on this level? */
		for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
		    if (DEADMONSTER(mtmp) || (mtmp == shk) || !mtmp->isshk) continue;
		    if (strcmp(ESHK(mtmp)->shknam, shname)) continue;
		    break;
		}
		if (!mtmp) break;	/* new name */
	    }
	}
	(void) strncpy(ESHK(shk)->shknam, shname, PL_NSIZ);
	ESHK(shk)->shknam[PL_NSIZ-1] = 0;
}

shkinit

STATIC_OVL int
shkinit(shp, sroom)	/* create a new shopkeeper in the given room */
const struct shclass	*shp;
struct mkroom	*sroom;
{
	register int sh, sx, sy;
	struct monst *shk;

	/* place the shopkeeper in the given room */
	sh = sroom->fdoor;
	sx = doors[sh].x;
	sy = doors[sh].y;

	/* check that the shopkeeper placement is sane */
	if(sroom->irregular) {
	    int rmno = (sroom - rooms) + ROOMOFFSET;
	    if (isok(sx-1,sy) && !levl[sx-1][sy].edge &&
		(int) levl[sx-1][sy].roomno == rmno) sx--;
	    else if (isok(sx+1,sy) && !levl[sx+1][sy].edge &&
		(int) levl[sx+1][sy].roomno == rmno) sx++;
	    else if (isok(sx,sy-1) && !levl[sx][sy-1].edge &&
		(int) levl[sx][sy-1].roomno == rmno) sy--;
	    else if (isok(sx,sy+1) && !levl[sx][sy+1].edge &&
		(int) levl[sx][sy+1].roomno == rmno) sx++;
	    else goto shk_failed;
	}
	else if(sx == sroom->lx-1) sx++;
	else if(sx == sroom->hx+1) sx--;
	else if(sy == sroom->ly-1) sy++;
	else if(sy == sroom->hy+1) sy--; else {
	shk_failed:
#ifdef DEBUG
# ifdef WIZARD
	    /* Said to happen sometimes, but I have never seen it. */
	    /* Supposedly fixed by fdoor change in mklev.c */
	    if(wizard) {
		register int j = sroom->doorct;

		pline("Where is shopdoor?");
		pline("Room at (%d,%d),(%d,%d).",
		      sroom->lx, sroom->ly, sroom->hx, sroom->hy);
		pline("doormax=%d doorct=%d fdoor=%d",
		      doorindex, sroom->doorct, sh);
		while(j--) {
		    pline("door [%d,%d]", doors[sh].x, doors[sh].y);
		    sh++;
		}
		display_nhwindow(WIN_MESSAGE, FALSE);
	    }
# endif
#endif
	    return(-1);
	}

	if(MON_AT(sx, sy)) (void) rloc(m_at(sx, sy), FALSE); /* insurance */

	/* now initialize the shopkeeper monster structure */
	if(!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy, NO_MM_FLAGS)))
		return(-1);
	shk->isshk = shk->mpeaceful = 1;
	set_malign(shk);
	shk->msleeping = 0;
	shk->mtrapseen = ~0;	/* we know all the traps already */
	ESHK(shk)->shoproom = (sroom - rooms) + ROOMOFFSET;
	sroom->resident = shk;
	ESHK(shk)->shoptype = sroom->rtype;
	assign_level(&(ESHK(shk)->shoplevel), &u.uz);
	ESHK(shk)->shd = doors[sh];
	ESHK(shk)->shk.x = sx;
	ESHK(shk)->shk.y = sy;
	ESHK(shk)->robbed = 0L;
	ESHK(shk)->credit = 0L;
	ESHK(shk)->debit = 0L;
	ESHK(shk)->loan = 0L;
	ESHK(shk)->visitct = 0;
	ESHK(shk)->following = 0;
	ESHK(shk)->billct = 0;
#ifndef GOLDOBJ
	shk->mgold = 1000L + 30L*(long)rnd(100);	/* initial capital */
#else
mkmonmoney(shk, 1000L + 30L*(long)rnd(100));	/* initial capital */
#endif
	if (shp->shknms == shkrings)
	    (void) mongets(shk, TOUCHSTONE);
	nameshk(shk, shp->shknms);

	return(sh);
}

stock_room

/* stock a newly-created room with objects */
void
stock_room(shp_indx, sroom)
int shp_indx;
register struct mkroom *sroom;
{
/*
* Someday soon we'll dispatch on the shdist field of shclass to do
* different placements in this routine. Currently it only supports
* shop-style placement (all squares except a row nearest the first
* door get objects).
*/
register int sx, sy, sh;
char buf[BUFSZ];
int rmno = (sroom - rooms) + ROOMOFFSET;
const struct shclass *shp = &shtypes[shp_indx];

/* first, try to place a shopkeeper in the room */
if ((sh = shkinit(shp, sroom)) < 0)
	return;

/* make sure no doorways without doors, and no */
/* trapped doors, in shops.			   */
sx = doors[sroom->fdoor].x;
sy = doors[sroom->fdoor].y;

if(levl[sx][sy].doormask == D_NODOOR) {
	    levl[sx][sy].doormask = D_ISOPEN;
	    newsym(sx,sy);
}
if(levl[sx][sy].typ == SDOOR) {
	    cvt_sdoor_to_door(&levl[sx][sy]);	/* .typ = DOOR */
	    newsym(sx,sy);
}
if(levl[sx][sy].doormask & D_TRAPPED)
	    levl[sx][sy].doormask = D_LOCKED;

if(levl[sx][sy].doormask == D_LOCKED) {
	    register int m = sx, n = sy;

	    if(inside_shop(sx+1,sy)) m--;
	    else if(inside_shop(sx-1,sy)) m++;
	    if(inside_shop(sx,sy+1)) n--;
	    else if(inside_shop(sx,sy-1)) n++;
	    Sprintf(buf, "Closed for inventory");
	    make_engr_at(m, n, buf, 0L, DUST);
}

for(sx = sroom->lx; sx <= sroom->hx; sx++)
	for(sy = sroom->ly; sy <= sroom->hy; sy++) {
	    if(sroom->irregular) {
		if (levl[sx][sy].edge || (int) levl[sx][sy].roomno != rmno ||
		   distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1)
		    continue;
	    } else if((sx == sroom->lx && doors[sh].x == sx-1) ||
		      (sx == sroom->hx && doors[sh].x == sx+1) ||
		      (sy == sroom->ly && doors[sh].y == sy-1) ||
		      (sy == sroom->hy && doors[sh].y == sy+1)) continue;
	    mkshobj_at(shp, sx, sy);
	}

/*
* Special monster placements (if any) should go here: that way,
* monsters will sit on top of objects and not the other way around.
*/

level.flags.has_shop = TRUE;
}

#endif /* OVLB */

saleable

#ifdef OVL0

/* does shkp's shop stock this item type? */
boolean
saleable(shkp, obj)
struct monst *shkp;
struct obj *obj;
{
int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE;
const struct shclass *shp = &shtypes[shp_indx];

if (shp->symb == RANDOM_CLASS) return TRUE;
else for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++)
		if (shp->iprobs[i].itype < 0 ?
			shp->iprobs[i].itype == - obj->otyp :
			shp->iprobs[i].itype == obj->oclass) return TRUE;
/* not found */
return FALSE;
}

get_shop_item

/* positive value: class; negative value: specific object type */
int
get_shop_item(type)
int type;
{
	const struct shclass *shp = shtypes+type;
	register int i,j;

	/* select an appropriate object type at random */
	for(j = rnd(100), i = 0; (j -= shp->iprobs[i].iprob) > 0; i++)
		continue;

	return shp->iprobs[i].itype;
}

#endif /* OVL0 */

/*shknam.c*/