xref: /openbsd/games/hack/hack.shknam.c (revision 043fbe51)
1 /*	$OpenBSD: hack.shknam.c,v 1.8 2009/10/27 23:59:25 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
5  * Amsterdam
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * - Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * - Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * - Neither the name of the Stichting Centrum voor Wiskunde en
20  * Informatica, nor the names of its contributors may be used to endorse or
21  * promote products derived from this software without specific prior
22  * written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 /*
38  * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
39  * All rights reserved.
40  *
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  *    notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  *    notice, this list of conditions and the following disclaimer in the
48  *    documentation and/or other materials provided with the distribution.
49  * 3. The name of the author may not be used to endorse or promote products
50  *    derived from this software without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
55  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  */
63 
64 #include "hack.h"
65 
66 char *shkliquors[] = {
67 	/* Ukraine */
68 	"Njezjin", "Tsjernigof", "Gomel", "Ossipewsk", "Gorlowka",
69 	/* N. Russia */
70 	"Konosja", "Weliki Oestjoeg", "Syktywkar", "Sablja",
71 	"Narodnaja", "Kyzyl",
72 	/* Silezie */
73 	"Walbrzych", "Swidnica", "Klodzko", "Raciborz", "Gliwice",
74 	"Brzeg", "Krnov", "Hradec Kralove",
75 	/* Schweiz */
76 	"Leuk", "Brig", "Brienz", "Thun", "Sarnen", "Burglen", "Elm",
77 	"Flims", "Vals", "Schuls", "Zum Loch",
78 	0
79 };
80 
81 char *shkbooks[] = {
82 	/* Eire */
83 	"Skibbereen", "Kanturk", "Rath Luirc", "Ennistymon", "Lahinch",
84 	"Loughrea", "Croagh", "Maumakeogh", "Ballyjamesduff",
85 	"Kinnegad", "Lugnaquillia", "Enniscorthy", "Gweebarra",
86 	"Kittamagh", "Nenagh", "Sneem", "Ballingeary", "Kilgarvan",
87 	"Cahersiveen", "Glenbeigh", "Kilmihil", "Kiltamagh",
88 	"Droichead Atha", "Inniscrone", "Clonegal", "Lisnaskea",
89 	"Culdaff", "Dunfanaghy", "Inishbofin", "Kesh",
90 	0
91 };
92 
93 char *shkarmors[] = {
94 	/* Turquie */
95 	"Demirci", "Kalecik", "Boyabai", "Yildizeli", "Gaziantep",
96 	"Siirt", "Akhalataki", "Tirebolu", "Aksaray", "Ermenak",
97 	"Iskenderun", "Kadirli", "Siverek", "Pervari", "Malasgirt",
98 	"Bayburt", "Ayancik", "Zonguldak", "Balya", "Tefenni",
99 	"Artvin", "Kars", "Makharadze", "Malazgirt", "Midyat",
100 	"Birecik", "Kirikkale", "Alaca", "Polatli", "Nallihan",
101 	0
102 };
103 
104 char *shkwands[] = {
105 	/* Wales */
106 	"Yr Wyddgrug", "Trallwng", "Mallwyd", "Pontarfynach",
107 	"Rhaeader", "Llandrindod", "Llanfair-ym-muallt",
108 	"Y-Fenni", "Measteg", "Rhydaman", "Beddgelert",
109 	"Curig", "Llanrwst", "Llanerchymedd", "Caergybi",
110 	/* Scotland */
111 	"Nairn", "Turriff", "Inverurie", "Braemar", "Lochnagar",
112 	"Kerloch", "Beinn a Ghlo", "Drumnadrochit", "Morven",
113 	"Uist", "Storr", "Sgurr na Ciche", "Cannich", "Gairloch",
114 	"Kyleakin", "Dunvegan",
115 	0
116 };
117 
118 char *shkrings[] = {
119 	/* Hollandse familienamen */
120 	"Feyfer", "Flugi", "Gheel", "Havic", "Haynin", "Hoboken",
121 	"Imbyze", "Juyn", "Kinsky", "Massis", "Matray", "Moy",
122 	"Olycan", "Sadelin", "Svaving", "Tapper", "Terwen", "Wirix",
123 	"Ypey",
124 	/* Skandinaviske navne */
125 	"Rastegaisa", "Varjag Njarga", "Kautekeino", "Abisko",
126 	"Enontekis", "Rovaniemi", "Avasaksa", "Haparanda",
127 	"Lulea", "Gellivare", "Oeloe", "Kajaani", "Fauske",
128 	0
129 };
130 
131 char *shkfoods[] = {
132 	/* Indonesia */
133 	"Djasinga", "Tjibarusa", "Tjiwidej", "Pengalengan",
134 	"Bandjar", "Parbalingga", "Bojolali", "Sarangan",
135 	"Ngebel", "Djombang", "Ardjawinangun", "Berbek",
136 	"Papar", "Baliga", "Tjisolok", "Siboga", "Banjoewangi",
137 	"Trenggalek", "Karangkobar", "Njalindoeng", "Pasawahan",
138 	"Pameunpeuk", "Patjitan", "Kediri", "Pemboeang", "Tringanoe",
139 	"Makin", "Tipor", "Semai", "Berhala", "Tegal", "Samoe",
140 	0
141 };
142 
143 char *shkweapons[] = {
144 	/* Perigord */
145 	"Voulgezac", "Rouffiac", "Lerignac", "Touverac", "Guizengeard",
146 	"Melac", "Neuvicq", "Vanzac", "Picq", "Urignac", "Corignac",
147 	"Fleac", "Lonzac", "Vergt", "Queyssac", "Liorac", "Echourgnac",
148 	"Cazelon", "Eypau", "Carignan", "Monbazillac", "Jonzac",
149 	"Pons", "Jumilhac", "Fenouilledes", "Laguiolet", "Saujon",
150 	"Eymoutiers", "Eygurande", "Eauze", "Labouheyre",
151 	0
152 };
153 
154 char *shkgeneral[] = {
155 	/* Suriname */
156 	"Hebiwerie", "Possogroenoe", "Asidonhopo", "Manlobbi",
157 	"Adjama", "Pakka Pakka", "Kabalebo", "Wonotobo",
158 	"Akalapi", "Sipaliwini",
159 	/* Greenland */
160 	"Annootok", "Upernavik", "Angmagssalik",
161 	/* N. Canada */
162 	"Aklavik", "Inuvik", "Tuktoyaktuk",
163 	"Chicoutimi", "Ouiatchouane", "Chibougamau",
164 	"Matagami", "Kipawa", "Kinojevis",
165 	"Abitibi", "Maganasipi",
166 	/* Iceland */
167 	"Akureyri", "Kopasker", "Budereyri", "Akranes", "Bordeyri",
168 	"Holmavik",
169 	0
170 };
171 
172 struct shk_nx {
173 	char x;
174 	char **xn;
175 } shk_nx[] = {
176 	{ POTION_SYM,	shkliquors },
177 	{ SCROLL_SYM,	shkbooks },
178 	{ ARMOR_SYM,	shkarmors },
179 	{ WAND_SYM,	shkwands },
180 	{ RING_SYM,	shkrings },
181 	{ FOOD_SYM,	shkfoods },
182 	{ WEAPON_SYM,	shkweapons },
183 	{ 0,		shkgeneral }
184 };
185 
186 void
findname(char * nampt,size_t len,char let)187 findname(char *nampt, size_t len, char let)
188 {
189 	struct shk_nx *p = shk_nx;
190 	char **q;
191 	int i;
192 
193 	while(p->x && p->x != let) p++;
194 	q = p->xn;
195 	for(i=0; i<dlevel; i++) if(!q[i]){
196 		/* Not enough names, try general name */
197 		if(let) findname(nampt, len, 0);
198 		else {
199 			(void) strlcpy(nampt, "Dirk", len);
200 		}
201 		return;
202 	}
203 	(void) strncpy(nampt, q[i], len-1);
204 	nampt[len-1] = '\0';
205 }
206