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