xref: /netbsd-src/games/hack/hack.shknam.c (revision 277bd0756ca50f412c495785caa07bb33578fd50)
1*277bd075Sdholland /*	$NetBSD: hack.shknam.c,v 1.8 2012/06/19 05:46:08 dholland Exp $	*/
23ea4a95cSchristos 
3210cab45Smycroft /*
41c7f94e5Sjsm  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
51c7f94e5Sjsm  * Amsterdam
61c7f94e5Sjsm  * All rights reserved.
71c7f94e5Sjsm  *
81c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
91c7f94e5Sjsm  * modification, are permitted provided that the following conditions are
101c7f94e5Sjsm  * met:
111c7f94e5Sjsm  *
121c7f94e5Sjsm  * - Redistributions of source code must retain the above copyright notice,
131c7f94e5Sjsm  * this list of conditions and the following disclaimer.
141c7f94e5Sjsm  *
151c7f94e5Sjsm  * - Redistributions in binary form must reproduce the above copyright
161c7f94e5Sjsm  * notice, this list of conditions and the following disclaimer in the
171c7f94e5Sjsm  * documentation and/or other materials provided with the distribution.
181c7f94e5Sjsm  *
191c7f94e5Sjsm  * - Neither the name of the Stichting Centrum voor Wiskunde en
201c7f94e5Sjsm  * Informatica, nor the names of its contributors may be used to endorse or
211c7f94e5Sjsm  * promote products derived from this software without specific prior
221c7f94e5Sjsm  * written permission.
231c7f94e5Sjsm  *
241c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
251c7f94e5Sjsm  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
261c7f94e5Sjsm  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
271c7f94e5Sjsm  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
281c7f94e5Sjsm  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
291c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
301c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
311c7f94e5Sjsm  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
321c7f94e5Sjsm  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
331c7f94e5Sjsm  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
341c7f94e5Sjsm  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
351c7f94e5Sjsm  */
361c7f94e5Sjsm 
371c7f94e5Sjsm /*
381c7f94e5Sjsm  * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
391c7f94e5Sjsm  * All rights reserved.
401c7f94e5Sjsm  *
411c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
421c7f94e5Sjsm  * modification, are permitted provided that the following conditions
431c7f94e5Sjsm  * are met:
441c7f94e5Sjsm  * 1. Redistributions of source code must retain the above copyright
451c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer.
461c7f94e5Sjsm  * 2. Redistributions in binary form must reproduce the above copyright
471c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer in the
481c7f94e5Sjsm  *    documentation and/or other materials provided with the distribution.
491c7f94e5Sjsm  * 3. The name of the author may not be used to endorse or promote products
501c7f94e5Sjsm  *    derived from this software without specific prior written permission.
511c7f94e5Sjsm  *
521c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
531c7f94e5Sjsm  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
541c7f94e5Sjsm  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
551c7f94e5Sjsm  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
561c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
571c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
581c7f94e5Sjsm  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
591c7f94e5Sjsm  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
601c7f94e5Sjsm  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
611c7f94e5Sjsm  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62210cab45Smycroft  */
63210cab45Smycroft 
643ea4a95cSchristos #include <sys/cdefs.h>
65210cab45Smycroft #ifndef lint
66*277bd075Sdholland __RCSID("$NetBSD: hack.shknam.c,v 1.8 2012/06/19 05:46:08 dholland Exp $");
67210cab45Smycroft #endif				/* not lint */
6861f28255Scgd 
6961f28255Scgd #include "hack.h"
703ea4a95cSchristos #include "extern.h"
7161f28255Scgd 
729b92b189Sdholland static const char *const shkliquors[] = {
7361f28255Scgd 	/* Ukraine */
7461f28255Scgd 	"Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka",
7561f28255Scgd 	/* N. Russia */
7661f28255Scgd 	"Konosja", "Weliki Oestjoeg", "Syktywkar", "Sablja",
7761f28255Scgd 	"Narodnaja", "Kyzyl",
7861f28255Scgd 	/* Silezie */
7961f28255Scgd 	"Walbrzych", "Swidnica", "Klodzko", "Raciborz", "Gliwice",
8061f28255Scgd 	"Brzeg", "Krnov", "Hradec Kralove",
8161f28255Scgd 	/* Schweiz */
8261f28255Scgd 	"Leuk", "Brig", "Brienz", "Thun", "Sarnen", "Burglen", "Elm",
8361f28255Scgd 	"Flims", "Vals", "Schuls", "Zum Loch",
8461f28255Scgd 	0
8561f28255Scgd };
8661f28255Scgd 
879b92b189Sdholland static const char *const shkbooks[] = {
8861f28255Scgd 	/* Eire */
8961f28255Scgd 	"Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch",
9061f28255Scgd 	"Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff",
9161f28255Scgd 	"Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra",
9261f28255Scgd 	"Kittamagh", "Nenagh", "Sneem", "Ballingeary", "Kilgarvan",
9361f28255Scgd 	"Cahersiveen", "Glenbeigh", "Kilmihil", "Kiltamagh",
9461f28255Scgd 	"Droichead Atha", "Inniscrone", "Clonegal", "Lisnaskea",
9561f28255Scgd 	"Culdaff", "Dunfanaghy", "Inishbofin", "Kesh",
9661f28255Scgd 	0
9761f28255Scgd };
9861f28255Scgd 
999b92b189Sdholland static const char *const shkarmors[] = {
10061f28255Scgd 	/* Turquie */
10161f28255Scgd 	"Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep",
10261f28255Scgd 	"Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak",
10361f28255Scgd 	"Iskenderun", "Kadirli", "Siverek", "Pervari", "Malasgirt",
10461f28255Scgd 	"Bayburt", "Ayancik", "Zonguldak", "Balya", "Tefenni",
10561f28255Scgd 	"Artvin", "Kars", "Makharadze", "Malazgirt", "Midyat",
10661f28255Scgd 	"Birecik", "Kirikkale", "Alaca", "Polatli", "Nallihan",
10761f28255Scgd 	0
10861f28255Scgd };
10961f28255Scgd 
1109b92b189Sdholland static const char *const shkwands[] = {
11161f28255Scgd 	/* Wales */
11261f28255Scgd 	"Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach",
11361f28255Scgd 	"Rhaeader", "Llandrindod", "Llanfair-ym-muallt",
11461f28255Scgd 	"Y-Fenni", "Measteg", "Rhydaman", "Beddgelert",
11561f28255Scgd 	"Curig", "Llanrwst", "Llanerchymedd", "Caergybi",
11661f28255Scgd 	/* Scotland */
11761f28255Scgd 	"Nairn", "Turriff", "Inverurie", "Braemar", "Lochnagar",
11861f28255Scgd 	"Kerloch", "Beinn a Ghlo", "Drumnadrochit", "Morven",
11961f28255Scgd 	"Uist", "Storr", "Sgurr na Ciche", "Cannich", "Gairloch",
12061f28255Scgd 	"Kyleakin", "Dunvegan",
12161f28255Scgd 	0
12261f28255Scgd };
12361f28255Scgd 
1249b92b189Sdholland static const char *const shkrings[] = {
12561f28255Scgd 	/* Hollandse familienamen */
12661f28255Scgd 	"Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken",
12761f28255Scgd 	"Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy",
12861f28255Scgd 	"Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix",
12961f28255Scgd 	"Ypey",
13061f28255Scgd 	/* Skandinaviske navne */
13161f28255Scgd 	"Rastegaisa", "Varjag Njarga", "Kautekeino", "Abisko",
13261f28255Scgd 	"Enontekis", "Rovaniemi", "Avasaksa", "Haparanda",
13361f28255Scgd 	"Lulea", "Gellivare", "Oeloe", "Kajaani", "Fauske",
13461f28255Scgd 	0
13561f28255Scgd };
13661f28255Scgd 
1379b92b189Sdholland static const char *const shkfoods[] = {
13861f28255Scgd 	/* Indonesia */
13961f28255Scgd 	"Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan",
14061f28255Scgd 	"Bandjar", "Parbalingga", "Bojolali", "Sarangan",
14161f28255Scgd 	"Ngebel", "Djombang", "Ardjawinangun", "Berbek",
14261f28255Scgd 	"Papar", "Baliga", "Tjisolok", "Siboga", "Banjoewangi",
14361f28255Scgd 	"Trenggalek", "Karangkobar", "Njalindoeng", "Pasawahan",
14461f28255Scgd 	"Pameunpeuk", "Patjitan", "Kediri", "Pemboeang", "Tringanoe",
14561f28255Scgd 	"Makin", "Tipor", "Semai", "Berhala", "Tegal", "Samoe",
14661f28255Scgd 	0
14761f28255Scgd };
14861f28255Scgd 
1499b92b189Sdholland static const char *const shkweapons[] = {
15061f28255Scgd 	/* Perigord */
15161f28255Scgd 	"Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard",
15261f28255Scgd 	"Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac",
15361f28255Scgd 	"Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac",
15461f28255Scgd 	"Cazelon", "Eypau", "Carignan", "Monbazillac", "Jonzac",
15561f28255Scgd 	"Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon",
15661f28255Scgd 	"Eymoutiers", "Eygurande", "Eauze", "Labouheyre",
15761f28255Scgd 	0
15861f28255Scgd };
15961f28255Scgd 
1609b92b189Sdholland static const char *const shkgeneral[] = {
16161f28255Scgd 	/* Suriname */
16261f28255Scgd 	"Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi",
16361f28255Scgd 	"Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo",
16461f28255Scgd 	"Akalapi", "Sipaliwini",
16561f28255Scgd 	/* Greenland */
16661f28255Scgd 	"Annootok", "Upernavik", "Angmagssalik",
16761f28255Scgd 	/* N. Canada */
16861f28255Scgd 	"Aklavik", "Inuvik", "Tuktoyaktuk",
16961f28255Scgd 	"Chicoutimi", "Ouiatchouane", "Chibougamau",
17061f28255Scgd 	"Matagami", "Kipawa", "Kinojevis",
17161f28255Scgd 	"Abitibi", "Maganasipi",
17261f28255Scgd 	/* Iceland */
17361f28255Scgd 	"Akureyri", "Kopasker", "Budereyri", "Akranes", "Bordeyri",
17461f28255Scgd 	"Holmavik",
17561f28255Scgd 	0
17661f28255Scgd };
17761f28255Scgd 
1789b92b189Sdholland static const struct shk_nx {
17961f28255Scgd 	char            x;
180ab8b6343Sjsm 	const char          *const *xn;
18161f28255Scgd }               shk_nx[] = {
1823ea4a95cSchristos 	{
1833ea4a95cSchristos 		POTION_SYM, shkliquors
1843ea4a95cSchristos 	},
1853ea4a95cSchristos 	{
1863ea4a95cSchristos 		SCROLL_SYM, shkbooks
1873ea4a95cSchristos 	},
1883ea4a95cSchristos 	{
1893ea4a95cSchristos 		ARMOR_SYM, shkarmors
1903ea4a95cSchristos 	},
1913ea4a95cSchristos 	{
1923ea4a95cSchristos 		WAND_SYM, shkwands
1933ea4a95cSchristos 	},
1943ea4a95cSchristos 	{
1953ea4a95cSchristos 		RING_SYM, shkrings
1963ea4a95cSchristos 	},
1973ea4a95cSchristos 	{
1983ea4a95cSchristos 		FOOD_SYM, shkfoods
1993ea4a95cSchristos 	},
2003ea4a95cSchristos 	{
2013ea4a95cSchristos 		WEAPON_SYM, shkweapons
2023ea4a95cSchristos 	},
2033ea4a95cSchristos 	{
2043ea4a95cSchristos 		0, shkgeneral
2053ea4a95cSchristos 	}
20661f28255Scgd };
20761f28255Scgd 
2083ea4a95cSchristos void
findname(char * nampt,int let_i)209*277bd075Sdholland findname(char *nampt, int let_i)
2103ea4a95cSchristos {
211ab8b6343Sjsm 	const struct shk_nx  *p = shk_nx;
212ab8b6343Sjsm 	const char          *const *q;
2133ea4a95cSchristos 	int             i;
214*277bd075Sdholland 	char let;
215*277bd075Sdholland 
216*277bd075Sdholland 	/* truncate to "char" width */
217*277bd075Sdholland 	let = let_i;
218*277bd075Sdholland 
2193ea4a95cSchristos 	while (p->x && p->x != let)
2203ea4a95cSchristos 		p++;
22161f28255Scgd 	q = p->xn;
2223ea4a95cSchristos 	for (i = 0; i < dlevel; i++)
2233ea4a95cSchristos 		if (!q[i]) {
22461f28255Scgd 			/* Not enough names, try general name */
2253ea4a95cSchristos 			if (let)
2263ea4a95cSchristos 				findname(nampt, 0);
2273ea4a95cSchristos 			else
2283ea4a95cSchristos 				(void) strcpy(nampt, "Dirk");
22961f28255Scgd 			return;
23061f28255Scgd 		}
23161f28255Scgd 	(void) strncpy(nampt, q[i], PL_NSIZ);
23261f28255Scgd 	nampt[PL_NSIZ - 1] = 0;
23361f28255Scgd }
234