Changeset 42

Show
Ignore:
Timestamp:
04/11/07 12:18:01 (2 years ago)
Author:
ajps
Message:

Split random name generation out from randart.c into randname.c (with slight rewrite), and we now use this code for both randarts and scroll names. This goes most of the way towards #36.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/Makefile.inc

    r41 r42  
    3333  obj-info \ 
    3434  randart \ 
     35  randname \ 
    3536  save \ 
    3637  spells1 \ 
  • trunk/src/object1.c

    r11 r42  
    1010 
    1111#include "angband.h" 
     12#include "randname.h" 
    1213 
    1314 
     
    1718#define MAX_TITLES     50       /* Used with scrolls (min 48) */ 
    1819#define MAX_SYLLABLES 158       /* Used with scrolls (see below) */ 
    19  
    20  
    21 /* 
    22  * Syllables for scrolls (must be 1-4 letters each). 
    23  */ 
    24  
    25 static cptr syllables[MAX_SYLLABLES] = 
    26 { 
    27         "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", 
    28         "arg", "arze", "ash", "aus", "ban", "bar", "bat", "bek", 
    29         "bie", "bin", "bit", "bjor", "blu", "bot", "bu", 
    30         "byt", "comp", "con", "cos", "cre", "dalf", "dan", 
    31         "den", "der", "doe", "dok", "eep", "el", "eng", "er", "ere", "erk", 
    32         "esh", "evs", "fa", "fid", "flit", "for", "fri", "fu", "gan", 
    33         "gar", "glen", "gop", "gre", "ha", "he", "hyd", "i", 
    34         "ing", "ion", "ip", "ish", "it", "ite", "iv", "jo", 
    35         "kho", "kli", "klis", "la", "lech", "man", "mar", 
    36         "me", "mi", "mic", "mik", "mon", "mung", "mur", "nag", "nej", 
    37         "nelg", "nep", "ner", "nes", "nis", "nih", "nin", "o", 
    38         "od", "ood", "org", "orn", "ox", "oxy", "pay", "pet", 
    39         "ple", "plu", "po", "pot", "prok", "re", "rea", "rhov", 
    40         "ri", "ro", "rog", "rok", "rol", "sa", "san", "sat", 
    41         "see", "sef", "seh", "shu", "ski", "sna", "sne", "snik", 
    42         "sno", "so", "sol", "sri", "sta", "sun", "ta", "tab", 
    43         "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u", 
    44         "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", 
    45         "vom", "wah", "wed", "werg", "wex", "whon", "wun", "x", 
    46         "yerg", "yp", "zun", "tri", "blaa" 
    47 }; 
    4820 
    4921 
     
    158130 * Scroll titles are always between 6 and 14 letters long.  This is 
    159131 * ensured because every title is composed of whole words, where every 
    160  * word is from 1 to 8 letters long (one or two syllables of 1 to 4 
    161  * letters each), and that no scroll is finished until it attempts to 
    162  * grow beyond 15 letters.  The first time this can happen is when the 
    163  * current title has 6 letters and the new word has 8 letters, which 
    164  * would result in a 6 letter scroll title. 
    165  * 
    166  * Duplicate titles are avoided by requiring that no two scrolls share 
    167  * the same first four letters (not the most efficient method, and not 
    168  * the least efficient method, but it will always work). 
     132 * word is from 2 to 8 letters long, and that no scroll is finished 
     133 * until it attempts to grow beyond 15 letters.  The first time this 
     134 * can happen is when the current title has 6 letters and the new word 
     135 * has 8 letters, which would result in a 6 letter scroll title. 
    169136 * 
    170137 * Hack -- make sure everything stays the same for each saved game 
     
    177144        int i, j; 
    178145 
    179  
    180146        /* Hack -- Use the "simple" RNG */ 
    181147        Rand_quick = TRUE; 
     
    183149        /* Hack -- Induce consistant flavors */ 
    184150        Rand_value = seed_flavor; 
    185  
    186151 
    187152        flavor_assign_fixed(); 
     
    199164        for (i = 0; i < MAX_TITLES; i++) 
    200165        { 
    201                 /* Get a new title */ 
    202                 while (TRUE) 
    203                 { 
    204                         char buf[80]; 
    205  
    206                         bool okay; 
    207  
    208                         /* Start a new title */ 
    209                         buf[0] = '\0'; 
    210  
    211                         /* Collect words until done */ 
    212                         while (1) 
     166                char buf[24]; 
     167                char *end = buf; 
     168                int titlelen = 0; 
     169                int wordlen; 
     170                bool okay = TRUE; 
     171 
     172                wordlen = make_word(RANDNAME_SCROLL, 2, 8, end, 24); 
     173                while (titlelen + wordlen < 15) 
     174                { 
     175                        end[wordlen] = ' '; 
     176                        titlelen += wordlen + 1; 
     177                        end += wordlen + 1; 
     178                        wordlen = make_word(RANDNAME_SCROLL, 2, 8, end, 24 - titlelen); 
     179                } 
     180                buf[titlelen - 1] = '\0'; 
     181           
     182                /* Check the scroll name hasn't already been generated */ 
     183                for (j = 0; j < i; j++) 
     184                { 
     185                        if (streq(buf, scroll_adj[j])) 
    213186                        { 
    214                                 int q, s; 
    215  
    216                                 char tmp[80]; 
    217  
    218                                 /* Start a new word */ 
    219                                 tmp[0] = '\0'; 
    220  
    221                                 /* Choose one or two syllables */ 
    222                                 s = ((rand_int(100) < 30) ? 1 : 2); 
    223  
    224                                 /* Add a one or two syllable word */ 
    225                                 for (q = 0; q < s; q++) 
    226                                 { 
    227                                         /* Add the syllable */ 
    228                                         my_strcat(tmp, syllables[rand_int(MAX_SYLLABLES)], sizeof(tmp)); 
    229                                 } 
    230  
    231                                 /* Stop before getting too long */ 
    232                                 if (strlen(buf) + 1 + strlen(tmp) > 15) break; 
    233  
    234                                 /* Add a space */ 
    235                                 my_strcat(buf, " ", sizeof(buf)); 
    236  
    237                                 /* Add the word */ 
    238                                 my_strcat(buf, tmp, sizeof(buf)); 
    239                         } 
    240  
    241                         /* Save the title */ 
    242                         my_strcpy(scroll_adj[i], buf+1, sizeof(scroll_adj[0])); 
    243  
    244                         /* Assume okay */ 
    245                         okay = TRUE; 
    246  
    247                         /* Check for "duplicate" scroll titles */ 
    248                         for (j = 0; j < i; j++) 
    249                         { 
    250                                 cptr hack1 = scroll_adj[j]; 
    251                                 cptr hack2 = scroll_adj[i]; 
    252  
    253                                 /* Compare first four characters */ 
    254                                 if (*hack1++ != *hack2++) continue; 
    255                                 if (*hack1++ != *hack2++) continue; 
    256                                 if (*hack1++ != *hack2++) continue; 
    257                                 if (*hack1++ != *hack2++) continue; 
    258  
    259                                 /* Not okay */ 
    260187                                okay = FALSE; 
    261  
    262                                 /* Stop looking */ 
    263188                                break; 
    264189                        } 
    265  
    266                         /* Break when done */ 
    267                         if (okay) break; 
    268                 } 
    269         } 
    270  
     190                } 
     191           
     192                if (okay) 
     193                { 
     194                        my_strcpy(scroll_adj[i], buf, sizeof(scroll_adj[0])); 
     195                } 
     196                else 
     197                { 
     198                        /* Have another go at making a name */ 
     199                        i--; 
     200                } 
     201        } 
    271202 
    272203        /* Hack -- Use the "complex" RNG */ 
  • trunk/src/randart.c

    r1 r42  
    1313 
    1414#include "init.h" 
     15#include "randname.h" 
    1516 
    1617/* 
    1718 * Random artifact generator (randart) by Greg Wooledge. 
    18  * 
    19  * The external "names.txt" file was sucked into this file for simplicity. 
    2019 */ 
    2120 
    2221#ifdef GJW_RANDART 
    2322 
    24 static cptr names_list = 
    25 "adanedhel\n" 
    26 "adurant\n" 
    27 "aeglos\n" 
    28 "aegnor\n" 
    29 "aelin\n" 
    30 "aeluin\n" 
    31 "aerandir\n" 
    32 "aerin\n" 
    33 "agarwaen\n" 
    34 "aglareb\n" 
    35 "aglarond\n" 
    36 "aglon\n" 
    37 "ainulindale\n" 
    38 "ainur\n" 
    39 "alcarinque\n" 
    40 "aldaron\n" 
    41 "aldudenie\n" 
    42 "almaren\n" 
    43 "alqualonde\n" 
    44 "aman\n" 
    45 "amandil\n" 
    46 "amarie\n" 
    47 "amarth\n" 
    48 "amlach\n" 
    49 "amon\n" 
    50 "amras\n" 
    51 "amrod\n" 
    52 "anach\n" 
    53 "anar\n" 
    54 "anarion\n" 
    55 "ancalagon\n" 
    56 "ancalimon\n" 
    57 "anarrima\n" 
    58 "andor\n" 
    59 "andram\n" 
    60 "androth\n" 
    61 "anduin\n" 
    62 "andunie\n" 
    63 "anfauglir\n" 
    64 "anfauglith\n" 
    65 "angainor\n" 
    66 "angband\n" 
    67 "anghabar\n" 
    68 "anglachel\n" 
    69 "angrenost\n" 
    70 "angrim\n" 
    71 "angrist\n" 
    72 "angrod\n" 
    73 "anguirel\n" 
    74 "annael\n" 
    75 "annatar\n" 
    76 "annon\n" 
    77 "annuminas\n" 
    78 "apanonar\n" 
    79 "aradan\n" 
    80 "aragorn\n" 
    81 "araman\n" 
    82 "aranel\n" 
    83 "aranruth\n" 
    84 "aranwe\n" 
    85 "aras\n" 
    86 "aratan\n" 
    87 "aratar\n" 
    88 "arathorn\n" 
    89 "arda\n" 
    90 "ard-galen\n" 
    91 "aredhel\n" 
    92 "ar-feiniel\n" 
    93 "argonath\n" 
    94 "arien\n" 
    95 "armenelos\n" 
    96 "arminas\n" 
    97 "arnor\n" 
    98 "aros\n" 
    99 "arossiach\n" 
    100 "arthad\n" 
    101 "arvernien\n" 
    102 "arwen\n" 
    103 "ascar\n" 
    104 "astaldo\n" 
    105 "atalante\n" 
    106 "atanamir\n" 
    107 "atanatari\n" 
    108 "atani\n" 
    109 "aule\n" 
    110 "avallone\n" 
    111 "avari\n" 
    112 "avathar\n" 
    113 "balan\n" 
    114 "balar\n" 
    115 "balrog\n" 
    116 "barad\n" 
    117 "baragund\n" 
    118 "barahir\n" 
    119 "baran\n" 
    120 "baranduin\n" 
    121 "bar\n" 
    122 "bauglir\n" 
    123 "beleg\n" 
    124 "belegaer\n" 
    125 "belegost\n" 
    126 "belegund\n" 
    127 "beleriand\n" 
    128 "belfalas\n" 
    129 "belthil\n" 
    130 "belthronding\n" 
    131 "beor\n" 
    132 "beraid\n" 
    133 "bereg\n" 
    134 "beren\n" 
    135 "boromir\n" 
    136 "boron\n" 
    137 "bragollach\n" 
    138 "brandir\n" 
    139 "bregolas\n" 
    140 "bregor\n" 
    141 "brethil\n" 
    142 "brilthor\n" 
    143 "brithiach\n" 
    144 "brithombar\n" 
    145 "brithon\n" 
    146 "cabed\n" 
    147 "calacirya\n" 
    148 "calaquendi\n" 
    149 "calenardhon\n" 
    150 "calion\n" 
    151 "camlost\n" 
    152 "caragdur\n" 
    153 "caranthir\n" 
    154 "carcharoth\n" 
    155 "cardolan\n" 
    156 "carnil\n" 
    157 "celeborn\n" 
    158 "celebrant\n" 
    159 "celebrimbor\n" 
    160 "celebrindal\n" 
    161 "celebros\n" 
    162 "celegorm\n" 
    163 "celon\n" 
    164 "cirdan\n" 
    165 "cirith\n" 
    166 "cirth\n" 
    167 "ciryatan\n" 
    168 "ciryon\n" 
    169 "coimas\n" 
    170 "corollaire\n" 
    171 "crissaegrim\n" 
    172 "cuarthal\n" 
    173 "cuivienen\n" 
    174 "culurien\n" 
    175 "curufin\n" 
    176 "curufinwe\n" 
    177 "curunir\n" 
    178 "cuthalion\n" 
    179 "daedeloth\n" 
    180 "daeron\n" 
    181 "dagnir\n" 
    182 "dagor\n" 
    183 "dagorlad\n" 
    184 "dairuin\n" 
    185 "danwedh\n" 
    186 "delduwath\n" 
    187 "denethor\n" 
    188 "dimbar\n" 
    189 "dimrost\n" 
    190 "dinen\n" 
    191 "dior\n" 
    192 "dirnen\n" 
    193 "dolmed\n" 
    194 "doriath\n" 
    195 "dorlas\n" 
    196 "dorthonion\n" 
    197 "draugluin\n" 
    198 "drengist\n" 
    199 "duath\n" 
    200 "duinath\n" 
    201 "duilwen\n" 
    202 "dunedain\n" 
    203 "dungortheb\n" 
    204 "earendil\n" 
    205 "earendur\n" 
    206 "earnil\n" 
    207 "earnur\n" 
    208 "earrame\n" 
    209 "earwen\n" 
    210 "echor\n" 
    211 "echoriath\n" 
    212 "ecthelion\n" 
    213 "edain\n" 
    214 "edrahil\n" 
    215 "eglador\n" 
    216 "eglarest\n" 
    217 "eglath\n" 
    218 "eilinel\n" 
    219 "eithel\n" 
    220 "ekkaia\n" 
    221 "elbereth\n" 
    222 "eldalie\n" 
    223 "eldalieva\n" 
    224 "eldamar\n" 
    225 "eldar\n" 
    226 "eledhwen\n" 
    227 "elemmire\n" 
    228 "elende\n" 
    229 "elendil\n" 
    230 "elendur\n" 
    231 "elenna\n" 
    232 "elentari\n" 
    233 "elenwe\n" 
    234 "elerrina\n" 
    235 "elleth\n" 
    236 "elmoth\n" 
    237 "elostirion\n" 
    238 "elrond\n" 
    239 "elros\n" 
    240 "elu\n" 
    241 "eluchil\n" 
    242 "elured\n" 
    243 "elurin\n" 
    244 "elwe\n" 
    245 "elwing\n" 
    246 "emeldir\n" 
    247 "endor\n" 
    248 "engrin\n" 
    249 "engwar\n" 
    250 "eol\n" 
    251 "eonwe\n" 
    252 "ephel\n" 
    253 "erchamion\n" 
    254 "ereb\n" 
    255 "ered\n" 
    256 "erech\n" 
    257 "eregion\n" 
    258 "ereinion\n" 
    259 "erellont\n" 
    260 "eressea\n" 
    261 "eriador\n" 
    262 "eru\n" 
    263 "esgalduin\n" 
    264 "este\n" 
    265 "estel\n" 
    266 "estolad\n" 
    267 "ethir\n" 
    268 "ezellohar\n" 
    269 "faelivrin\n" 
    270 "falas\n" 
    271 "falathar\n" 
    272 "falathrim\n" 
    273 "falmari\n" 
    274 "faroth\n" 
    275 "fauglith\n" 
    276 "feanor\n" 
    277 "feanturi\n" 
    278 "felagund\n" 
    279 "finarfin\n" 
    280 "finduilas\n" 
    281 "fingolfin\n" 
    282 "fingon\n" 
    283 "finwe\n" 
    284 "firimar\n" 
    285 "formenos\n" 
    286 "fornost\n" 
    287 "frodo\n" 
    288 "fuin\n" 
    289 "fuinur\n" 
    290 "gabilgathol\n" 
    291 "galad\n" 
    292 "galadriel\n" 
    293 "galathilion\n" 
    294 "galdor\n" 
    295 "galen\n" 
    296 "galvorn\n" 
    297 "gandalf\n" 
    298 "gaurhoth\n" 
    299 "gelion\n" 
    300 "gelmir\n" 
    301 "gelydh\n" 
    302 "gil\n" 
    303 "gildor\n" 
    304 "giliath\n" 
    305 "ginglith\n" 
    306 "girith\n" 
    307 "glaurung\n" 
    308 "glingal\n" 
    309 "glirhuin\n" 
    310 "gloredhel\n" 
    311 "glorfindel\n" 
    312 "golodhrim\n" 
    313 "gondolin\n" 
    314 "gondor\n" 
    315 "gonnhirrim\n" 
    316 "gorgoroth\n" 
    317 "gorlim\n" 
    318 "gorthaur\n" 
    319 "gorthol\n" 
    320 "gothmog\n" 
    321 "guilin\n" 
    322 "guinar\n" 
    323 "guldur\n" 
    324 "gundor\n" 
    325 "gurthang\n" 
    326 "gwaith\n" 
    327 "gwareth\n" 
    328 "gwindor\n" 
    329 "hadhodrond\n" 
    330 "hador\n" 
    331 "haladin\n" 
    332 "haldad\n" 
    333 "haldan\n" 
    334 "haldar\n" 
    335 "haldir\n" 
    336 "haleth\n" 
    337 "halmir\n" 
    338 "handir\n" 
    339 "harad\n" 
    340 "hareth\n" 
    341 "hathaldir\n" 
    342 "hathol\n" 
    343 "haudh\n" 
    344 "helcar\n" 
    345 "helcaraxe\n" 
    346 "helevorn\n" 
    347 "helluin\n" 
    348 "herumor\n" 
    349 "herunumen\n" 
    350 "hildorien\n" 
    351 "himlad\n" 
    352 "himring\n" 
    353 "hirilorn\n" 
    354 "hisilome\n" 
    355 "hithaeglir\n" 
    356 "hithlum\n" 
    357 "hollin\n" 
    358 "huan\n" 
    359 "hunthor\n" 
    360 "huor\n" 
    361 "hurin\n" 
    362 "hyarmendacil\n" 
    363 "hyarmentir\n" 
    364 "iant\n" 
    365 "iaur\n" 
    366 "ibun\n" 
    367 "idril\n" 
    368 "illuin\n" 
    369 "ilmare\n" 
    370 "ilmen\n" 
    371 "iluvatar\n" 
    372 "imlach\n" 
    373 "imladris\n" 
    374 "indis\n" 
    375 "ingwe\n" 
    376 "irmo\n" 
    377 "isil\n" 
    378 "isildur\n" 
    379 "istari\n" 
    380 "ithil\n" 
    381 "ivrin\n" 
    382 "kelvar\n" 
    383 "kementari\n" 
    384 "ladros\n" 
    385 "laiquendi\n" 
    386 "lalaith\n" 
    387 "lamath\n" 
    388 "lammoth\n" 
    389 "lanthir\n" 
    390 "laurelin\n" 
    391 "leithian\n" 
    392 "legolin\n" 
    393 "lembas\n" 
    394 "lenwe\n" 
    395 "linaewen\n" 
    396 "lindon\n" 
    397 "lindorie\n" 
    398 "loeg\n" 
    399 "lomelindi\n" 
    400 "lomin\n" 
    401 "lomion\n" 
    402 "lorellin\n" 
    403 "lorien\n" 
    404 "lorindol\n" 
    405 "losgar\n" 
    406 "lothlann\n" 
    407 "lothlorien\n" 
    408 "luin\n" 
    409 "luinil\n" 
    410 "lumbar\n" 
    411 "luthien\n" 
    412 "mablung\n" 
    413 "maedhros\n" 
    414 "maeglin\n" 
    415 "maglor\n" 
    416 "magor\n" 
    417 "mahanaxar\n" 
    418 "mahtan\n" 
    419 "maiar\n" 
    420 "malduin\n" 
    421 "malinalda\n" 
    422 "mandos\n" 
    423 "manwe\n" 
    424 "mardil\n" 
    425 "melian\n" 
    426 "melkor\n" 
    427 "menegroth\n" 
    428 "meneldil\n" 
    429 "menelmacar\n" 
    430 "meneltarma\n" 
    431 "minas\n" 
    432 "minastir\n" 
    433 "mindeb\n" 
    434 "mindolluin\n" 
    435 "mindon\n" 
    436 "minyatur\n" 
    437 "mirdain\n" 
    438 "miriel\n" 
    439 "mithlond\n" 
    440 "mithrandir\n" 
    441 "mithrim\n" 
    442 "mordor\n" 
    443 "morgoth\n" 
    444 "morgul\n" 
    445 "moria\n" 
    446 "moriquendi\n" 
    447 "mormegil\n" 
    448 "morwen\n" 
    449 "nahar\n" 
    450 "naeramarth\n" 
    451 "namo\n" 
    452 "nandor\n" 
    453 "nargothrond\n" 
    454 "narog\n" 
    455 "narsil\n" 
    456 "narsilion\n" 
    457 "narya\n" 
    458 "nauglamir\n" 
    459 "naugrim\n" 
    460 "ndengin\n" 
    461 "neithan\n" 
    462 "neldoreth\n" 
    463 "nenar\n" 
    464 "nenning\n" 
    465 "nenuial\n" 
    466 "nenya\n" 
    467 "nerdanel\n" 
    468 "nessa\n" 
    469 "nevrast\n" 
    470 "nibin\n" 
    471 "nienna\n" 
    472 "nienor\n" 
    473 "nimbrethil\n" 
    474 "nimloth\n" 
    475 "nimphelos\n" 
    476 "nimrais\n" 
    477 "nimras\n" 
    478 "ningloron\n" 
    479 "niniel\n" 
    480 "ninniach\n" 
    481 "ninquelote\n" 
    482 "niphredil\n" 
    483 "nirnaeth\n" 
    484 "nivrim\n" 
    485 "noegyth\n" 
    486 "nogrod\n" 
    487 "noldolante\n" 
    488 "noldor\n" 
    489 "numenor\n" 
    490 "nurtale\n" 
    491 "obel\n" 
    492 "ohtar\n" 
    493 "oiolosse\n" 
    494 "oiomure\n" 
    495 "olorin\n" 
    496 "olvar\n" 
    497 "olwe\n" 
    498 "ondolinde\n" 
    499 "orfalch\n" 
    500 "ormal\n" 
    501 "orocarni\n" 
    502 "orodreth\n" 
    503 "orodruin\n" 
    504 "orome\n" 
    505 "oromet\n" 
    506 "orthanc\n" 
    507 "osgiliath\n" 
    508 "osse\n" 
    509 "ossiriand\n" 
    510 "palantir\n" 
    511 "pelargir\n" 
    512 "pelori\n" 
    513 "periannath\n" 
    514 "quendi\n" 
    515 "quenta\n" 
    516 "quenya\n" 
    517 "radagast\n" 
    518 "radhruin\n" 
    519 "ragnor\n" 
    520 "ramdal\n" 
    521 "rana\n" 
    522 "rathloriel\n" 
    523 "rauros\n" 
    524 "region\n" 
    525 "rerir\n" 
    526 "rhovanion\n" 
    527 "rhudaur\n" 
    528 "rhun\n" 
    529 "rhunen\n" 
    530 "rian\n" 
    531 "ringil\n" 
    532 "ringwil\n" 
    533 "romenna\n" 
    534 "rudh\n" 
    535 "rumil\n" 
    536 "saeros\n" 
    537 "salmar\n" 
    538 "saruman\n" 
    539 "sauron\n" 
    540 "serech\n" 
    541 "seregon\n" 
    542 "serinde\n" 
    543 "shelob\n" 
    544 "silmarien\n" 
    545 "silmaril\n" 
    546 "silpion\n" 
    547 "sindar\n" 
    548 "singollo\n" 
    549 "sirion\n" 
    550 "soronume\n" 
    551 "sul\n" 
    552 "sulimo\n" 
    553 "talath\n" 
    554 "taniquetil\n" 
    555 "tar\n" 
    556 "taras\n" 
    557 "tarn\n" 
    558 "tathren\n" 
    559 "taur\n" 
    560 "tauron\n" 
    561 "teiglin\n" 
    562 "telchar\n" 
    563 "telemnar\n" 
    564 "teleri\n" 
    565 "telperion\n" 
    566 "telumendil\n" 
    567 "thalion\n" 
    568 "thalos\n" 
    569 "thangorodrim\n" 
    570 "thargelion\n" 
    571 "thingol\n" 
    572 "thoronath\n" 
    573 "thorondor\n" 
    574 "thranduil\n" 
    575 "thuringwethil\n" 
    576 "tilion\n" 
    577 "tintalle\n" 
    578 "tinuviel\n" 
    579 "tirion\n" 
    580 "tirith\n" 
    581 "tol\n" 
    582 "tulkas\n" 
    583 "tumhalad\n" 
    584 "tumladen\n" 
    585 "tuna\n" 
    586 "tuor\n" 
    587 "turambar\n" 
    588 "turgon\n" 
    589 "turin\n" 
    590 "uial\n" 
    591 "uilos\n" 
    592 "uinen\n" 
    593 "ulairi\n" 
    594 "ulmo\n" 
    595 "ulumuri\n" 
    596 "umanyar\n" 
    597 "umarth\n" 
    598 "umbar\n" 
    599 "ungoliant\n" 
    600 "urthel\n" 
    601 "uruloki\n" 
    602 "utumno\n" 
    603 "vaire\n" 
    604 "valacirca\n" 
    605 "valandil\n" 
    606 "valaquenta\n" 
    607 "valar\n" 
    608 "valaraukar\n" 
    609 "valaroma\n" 
    610 "valier\n" 
    611 "valimar\n" 
    612 "valinor\n" 
    613 "valinoreva\n" 
    614 "valmar\n" 
    615 "vana\n" 
    616 "vanyar\n" 
    617 "varda\n" 
    618 "vasa\n" 
    619 "vilya\n" 
    620 "vingilot\n" 
    621 "vinyamar\n" 
    622 "voronwe\n" 
    623 "wethrin\n" 
    624 "wilwarin\n" 
    625 "yavanna\n" 
    626 ; 
    627  
    62823#define MAX_TRIES 200 
     24 
     25/* Random name parameters */ 
    62926#define BUFLEN 1024 
    630  
    63127#define MIN_NAME_LEN 5 
    63228#define MAX_NAME_LEN 9 
    633 #define S_WORD 26 
    634 #define E_WORD S_WORD 
    63529 
    63630#define sign(x) ((x) > 0 ? 1 : ((x) < 0 ? -1 : 0)) 
    637  
    638  
    639 static unsigned short lprobs[S_WORD+1][S_WORD+1][S_WORD+1]; 
    640 static unsigned short ltotal[S_WORD+1][S_WORD+1]; 
    64131 
    64232/* 
     
    64939static int randart_verbose = 0; 
    65040 
    651  
    65241/* 
    653  * Use W. Sheldon Simms' random name generator.  This function builds 
    654  * probability tables which are used later on for letter selection.  It 
    655  * relies on the ASCII character set. 
    656  */ 
    657 static void build_prob(cptr learn) 
    658 
    659         int c_prev, c_cur, c_next; 
    660  
    661         /* Build raw frequencies */ 
    662         do 
    663         { 
    664                 c_prev = c_cur = S_WORD; 
    665  
    666                 do 
    667                 { 
    668                         c_next = *learn++; 
    669                 } while (!isalpha((unsigned char)c_next) && (c_next != '\0')); 
    670  
    671                 if (c_next == '\0') break; 
    672  
    673                 do 
    674                 { 
    675                         c_next = A2I(tolower((unsigned char)c_next)); 
    676                         lprobs[c_prev][c_cur][c_next]++; 
    677                         ltotal[c_prev][c_cur]++; 
    678                         c_prev = c_cur; 
    679                         c_cur = c_next; 
    680                         c_next = *learn++; 
    681                 } while (isalpha((unsigned char)c_next)); 
    682  
    683                 lprobs[c_prev][c_cur][E_WORD]++; 
    684                 ltotal[c_prev][c_cur]++; 
    685         } 
    686         while (c_next != '\0'); 
    687 
    688  
    689  
    690 /* 
    691  * Use W. Sheldon Simms' random name generator.  Generate a random word using 
    692  * the probability tables we built earlier.  Relies on the ASCII character 
    693  * set.  Relies on European vowels (a, e, i, o, u).  The generated name should 
    694  * be copied/used before calling this function again. 
    695  */ 
    696 static char *make_word(void) 
    697 
    698         static char word_buf[90]; 
    699         int r, totalfreq; 
    700         int tries, lnum, vow; 
    701         int c_prev, c_cur, c_next; 
    702         char *cp; 
    703  
    704 startover: 
    705         vow = 0; 
    706         lnum = 0; 
    707         tries = 0; 
    708         cp = word_buf; 
    709         c_prev = c_cur = S_WORD; 
    710  
    711         while (1) 
    712         { 
    713             getletter: 
    714                 c_next = 0; 
    715                 r = rand_int(ltotal[c_prev][c_cur]); 
    716                 totalfreq = lprobs[c_prev][c_cur][c_next]; 
    717  
    718                 while (totalfreq <= r) 
    719                 { 
    720                         c_next++; 
    721                         totalfreq += lprobs[c_prev][c_cur][c_next]; 
    722                 } 
    723  
    724                 if (c_next == E_WORD) 
    725                 { 
    726                         if ((lnum < MIN_NAME_LEN) || vow == 0) 
    727                         { 
    728                                 tries++; 
    729                                 if (tries < 10) goto getletter; 
    730                                 goto startover; 
    731                         } 
    732                         *cp = '\0'; 
    733                         break; 
    734                 } 
    735  
    736                 if (lnum >= MAX_NAME_LEN) goto startover; 
    737  
    738                 *cp = I2A(c_next); 
    739  
    740                 if (is_a_vowel(*cp)) vow++; 
    741  
    742                 cp++; 
    743                 lnum++; 
    744                 c_prev = c_cur; 
    745                 c_cur = c_next; 
    746         } 
    747  
    748         word_buf[0] = toupper((unsigned char)word_buf[0]); 
    749  
    750         return (word_buf); 
    751 
    752  
    753  
    754 /* 
    755  * Use W. Sheldon Simms' random name generator. 
     42 * Use W. Sheldon Simms' random name generator from randname.c 
    75643 */ 
    75744static errr init_names(void) 
     
    76653        cptr *names; 
    76754 
    768  
    769         build_prob(names_list); 
    770  
    77155        /* Allocate the "names" array */ 
    77256        /* ToDo: Make sure the memory is freed correctly in case of errors */ 
     
    77559        for (i = 0; i < z_info->a_max; i++) 
    77660        { 
    777                 char *word = make_word(); 
     61                char word[MAX_NAME_LEN + 1]; 
     62                make_word(RANDNAME_TOLKIEN, MIN_NAME_LEN, MAX_NAME_LEN, word, sizeof word); 
     63                word[0] = toupper((unsigned char) word[0]); 
    77864 
    77965                if (rand_int(3) == 0)