]> granicus.if.org Git - nethack/commitdiff
Move some hard-coded string arrays into data files.
authorPasi Kallinen <paxed@alt.org>
Wed, 18 Mar 2015 20:05:10 +0000 (22:05 +0200)
committerPasi Kallinen <paxed@alt.org>
Wed, 18 Mar 2015 20:05:10 +0000 (22:05 +0200)
Random epitaphs, engravings and hallucinatory monsters now
live in text data files.

23 files changed:
dat/bogusmon.txt [new file with mode: 0644]
dat/engrave.txt [new file with mode: 0644]
dat/epitaph.txt [new file with mode: 0644]
doc/makedefs.6
include/extern.h
include/global.h
src/do_name.c
src/eat.c
src/engrave.c
src/explode.c
src/fountain.c
src/muse.c
src/pickup.c
src/potion.c
src/priest.c
src/rumors.c
src/sounds.c
src/timeout.c
src/trap.c
src/zap.c
sys/unix/Makefile.dat
sys/unix/Makefile.top
util/makedefs.c

diff --git a/dat/bogusmon.txt b/dat/bogusmon.txt
new file mode 100644 (file)
index 0000000..8c7aba4
--- /dev/null
@@ -0,0 +1,177 @@
+# Hallucinatory monsters
+#
+#
+# prefix codes:
+# dash          -  female, personal name
+# underscore    _  female, general name
+# plus          +  male, personal name
+# vertical bar  |  male, general name
+# equals        =  gender not specified, personal name
+
+# misc.
+jumbo shrimp
+giant pigmy
+gnu
+killer penguin
+giant cockroach
+giant slug
+maggot
+pterodactyl
+tyrannosaurus rex
+basilisk
+beholder
+nightmare
+efreeti
+marid
+rot grub
+bookworm
+master lichen
+shadow
+hologram
+jester
+attorney
+sleazoid
+killer tomato
+amazon
+robot
+battlemech
+rhinovirus
+harpy
+lion-dog
+rat-ant
+Y2K bug
+
+# Quendor (Zork, &c.)
+grue
+Christmas-tree monster
+luck sucker
+paskald
+brogmoid
+dornbeast
+
+# Moria
+Ancient Multi-Hued Dragon
++Evil Iggy
+
+# Rogue
+emu
+kestrel
+xeroc
+venus flytrap
+
+# Wizardry
+creeping coins
+
+# Greek legend
+hydra
+siren
+
+# Monty Python
+killer bunny
+
+# The Princess Bride
+rodent of unusual size
+
+# Wallace & Gromit
+were-rabbit
+
+# "Only you can prevent forest fires!
++Smokey Bear
+
+# Discworld
+Luggage
+
+# Lord of the Rings
+Ent
+
+# Xanth
+tangle tree
+nickelpede
+wiggle
+
+# Lewis Carroll
+white rabbit
+snark
+
+# Dr. Dolittle
+pushmi-pullyu
+
+# The Smurfs
+smurf
+
+# Star Trek
+tribble
+Klingon
+Borg
+
+# Star Wars
+Ewok
+
+# Tonari no Totoro
+Totoro
+
+# Nausicaa
+ohmu
+
+# Sailor Moon
+youma
+
+# Pokemon (Meowth)
+nyaasu
+
+# monster movies
+-Godzilla
++King Kong
+
+# old L of SH
+earthquake beast
+
+# Robotech
+Invid
+
+# The Terminator
+Terminator
+
+# Bubblegum Crisis
+boomer
+
+# Dr. Who ("Exterminate!")
+Dalek
+
+# HGttG
+microscopic space fleet
+Ravenous Bugblatter Beast of Traal
+
+# TMNT
+teenage mutant ninja turtle
+
+# Usagi Yojimbo
+samurai rabbit
+
+# Cerebus
+aardvark
+
+# Little Shop of Horrors
+=Audrey II
+
+# 50's rock 'n' roll
+witch doctor
+one-eyed one-horned flying purple people eater
+
+# saccharine kiddy TV
++Barney the dinosaur
+
+# Angband
++Morgoth
+
+# Babylon 5
+Vorlon
+
+# King Arthur
+questing beast
+
+# Movie
+Predator
+
+# common pest
+mother-in-law
diff --git a/dat/engrave.txt b/dat/engrave.txt
new file mode 100644 (file)
index 0000000..6827c8a
--- /dev/null
@@ -0,0 +1,45 @@
+# Random engravings on the floor
+#
+Elbereth
+# trap engravings
+Vlad was here
+ad aerarium
+
+# take-offs and other famous engravings
+Owlbreath
+Galadriel
+Kilroy was here
+
+# Journey to the Center of the Earth
+A.S. ->
+<- A.S.
+# Adventure
+You won't get it up the steps
+# Inferno
+Lasciate ogni speranza o voi ch'entrate.
+# Prisoner
+Well Come
+# So Long...
+We apologize for the inconvenience.
+# Thriller
+See you next Wednesday
+# Smokey Stover
+notary sojak
+
+For a good time call 8?7-5309
+# Various zoos around the world
+Please don't feed the animals.
+# A palindrome
+Madam, in Eden, I'm Adam.
+# Siskel & Ebert
+Two thumbs up!
+# The First C Program
+Hello, World!
+^?MAIL
+# AOL
+You've got mail!
+^.
+# Clueless
+As if!
+# 200x incarnation of Dr.Who
+BAD WOLF
diff --git a/dat/epitaph.txt b/dat/epitaph.txt
new file mode 100644 (file)
index 0000000..79019ea
--- /dev/null
@@ -0,0 +1,32 @@
+# Epitaphs for random headstones
+#
+#
+Rest in peace
+R.I.P.
+Rest In Pieces
+Note -- there are NO valuable items in this grave
+1994-1995. The Longest-Lived Hacker Ever
+The Grave of the Unknown Hacker
+We weren't sure who this was, but we buried him here anyway
+Sparky -- he was a very good dog
+Beware of Electric Third Rail
+Made in Taiwan
+Og friend. Og good dude. Og died. Og now food
+Beetlejuice Beetlejuice Beetlejuice
+Look out below!
+Please don't dig me up. I'm perfectly happy down here. -- Resident
+Postman, please note forwarding address: Gehennom, Asmodeus's Fortress, fifth lemure on the left
+Mary had a little lamb/Its fleece was white as snow/When Mary was in trouble/The lamb was first to go
+Be careful, or this could happen to you!
+Soon you'll join this fellow in hell! -- the Wizard of Yendor
+Caution! This grave contains toxic waste
+Sum quod eris
+Here lies an Atheist, all dressed up and no place to go
+Here lies Ezekiel, age 102.  The good die young.
+Here lies my wife: Here let her lie! Now she's at rest and so am I.
+Here lies Johnny Yeast. Pardon me for not rising.
+He always lied while on the earth and now he's lying in it
+I made an ash of myself
+Soon ripe. Soon rotten. Soon gone. But not forgotten.
+Here lies the body of Jonathan Blake. Stepped on the gas instead of the brake.
+Go away!
index 7b850108c5e36f6e361f9769eec96f00048645aa..61bd7c74195025adef6e6d2ef5792c5f7fc1316a 100644 (file)
@@ -105,6 +105,15 @@ Generate the
 file.
 .br
 .TP
+.B -s
+Generate the
+.I bogusmon
+,
+.I engrave
+and
+.IR epitaph files.
+.br
+.TP
 .B -h
 Generate the
 .B oracles
index fc39528040beafa7656916dbd7b526f1a32180f5..23d10d32488c33408fda1cc2f3d6103a0c7b3ad2 100644 (file)
@@ -387,7 +387,7 @@ E char *FDECL(Adjmonnam, (struct monst *,const char *));
 E char *FDECL(Amonnam, (struct monst *));
 E char *FDECL(a_monnam, (struct monst *));
 E char *FDECL(distant_monnam, (struct monst *,int,char *));
-E const char *NDECL(rndmonnam);
+E char *FDECL(rndmonnam, (char *));
 E const char *FDECL(hcolor, (const char *));
 E const char *NDECL(rndcolor);
 E const char *NDECL(roguename);
@@ -1174,7 +1174,7 @@ E struct obj *FDECL(mkobj_at, (CHAR_P,int,int,BOOLEAN_P));
 E struct obj *FDECL(mksobj_at, (int,int,int,BOOLEAN_P,BOOLEAN_P));
 E struct obj *FDECL(mkobj, (CHAR_P,BOOLEAN_P));
 E int NDECL(rndmonnum);
-E boolean FDECL(bogon_is_pname, (const char *));
+E boolean FDECL(bogon_is_pname, (CHAR_P));
 E struct obj *FDECL(splitobj, (struct obj *,long));
 E void FDECL(replace_object, (struct obj *,struct obj *));
 E void FDECL(bill_dummy_object, (struct obj *));
@@ -1931,6 +1931,7 @@ E const char *NDECL(Goodbye);
 /* ### rumors.c ### */
 
 E char *FDECL(getrumor, (int,char *, BOOLEAN_P));
+E char *FDECL(get_rnd_text, (const char *, char *));
 E void FDECL(outrumor, (int,int));
 E void FDECL(outoracle, (BOOLEAN_P, BOOLEAN_P));
 E void FDECL(save_oracles, (int,int));
index 6179409bb7806203cb43c5534c6c64689413c6b2..a67066d64d0684e211ef04055353ccf47e16e156 100644 (file)
@@ -30,6 +30,9 @@
 #define OPTIONFILE    "opthelp" /* file explaining runtime options */
 #define OPTIONS_USED  "options" /* compile-time options, for #version */
 #define SYMBOLS       "symbols" /* replacement symbol sets */
+#define EPITAPHFILE   "epitaph"        /* random epitaphs on graves */
+#define ENGRAVEFILE   "engrave" /* random engravings on the floor */
+#define BOGUSMONFILE  "bogusmon" /* hallucinatory monsters */
 #define LEV_EXT ".lev"         /* extension for special level files */
 
 
index 47012d3f3c190c511d9b16353c42469284b65314..0f837c9d49080f2e2ed3a316226f711f27de091d 100644 (file)
@@ -809,10 +809,10 @@ boolean called;
        /* Put the actual monster name or type into the buffer now */
        /* Be sure to remember whether the buffer starts with a name */
        if (do_hallu) {
-           const char *rname = rndmonnam();
-
+           char rnamecode;
+           char *rname = rndmonnam(&rnamecode);
            Strcat(buf, rname);
-           name_at_start = bogon_is_pname(rname);
+           name_at_start = bogon_is_pname(rnamecode);
        } else if (has_mname(mtmp)) {
            char *name = MNAME(mtmp);
 
@@ -1006,113 +1006,44 @@ char *outbuf;
     return outbuf;
 }
 
-/*
- *  Name prefix codes (same as shknam.c):
- *     dash          -  female, personal name
- *     underscore    _  female, general name
- *     plus          +  male, personal name
- *     vertical bar  |  male, general name
- *     equals        =  gender not specified, personal name
- */
-
-static const char * const bogusmons[] = {
-       "jumbo shrimp", "giant pigmy", "gnu", "killer penguin",
-       "giant cockroach", "giant slug", "maggot", "pterodactyl",
-       "tyrannosaurus rex", "basilisk", "beholder", "nightmare",
-       "efreeti", "marid", "rot grub", "bookworm", "master lichen",
-       "shadow", "hologram", "jester", "attorney", "sleazoid",
-       "killer tomato", "amazon", "robot", "battlemech",
-       "rhinovirus", "harpy", "lion-dog", "rat-ant", "Y2K bug",
-                                               /* misc. */
-       "grue", "Christmas-tree monster", "luck sucker", "paskald",
-       "brogmoid", "dornbeast",                /* Quendor (Zork, &c.) */
-       "Ancient Multi-Hued Dragon", "+Evil Iggy",
-                                               /* Moria */
-       "emu", "kestrel", "xeroc", "venus flytrap",
-                                               /* Rogue */
-       "creeping coins",                       /* Wizardry */
-       "hydra", "siren",                       /* Greek legend */
-       "killer bunny",                         /* Monty Python */
-       "rodent of unusual size",               /* The Princess Bride */
-       "were-rabbit",                          /* Wallace & Gromit */
-       "+Smokey Bear",         /* "Only you can prevent forest fires!" */
-       "Luggage",                              /* Discworld */
-       "Ent",                                  /* Lord of the Rings */
-       "tangle tree", "nickelpede", "wiggle",  /* Xanth */
-       "white rabbit", "snark",                /* Lewis Carroll */
-       "pushmi-pullyu",                        /* Dr. Dolittle */
-       "smurf",                                /* The Smurfs */
-       "tribble", "Klingon", "Borg",           /* Star Trek */
-       "Ewok",                                 /* Star Wars */
-       "Totoro",                               /* Tonari no Totoro */
-       "ohmu",                                 /* Nausicaa */
-       "youma",                                /* Sailor Moon */
-       "nyaasu",                               /* Pokemon (Meowth) */
-       "-Godzilla", "+King Kong",              /* monster movies */
-       "earthquake beast",                     /* old L of SH */
-       "Invid",                                /* Robotech */
-       "Terminator",                           /* The Terminator */
-       "boomer",                               /* Bubblegum Crisis */
-       "Dalek",                                /* Dr. Who ("Exterminate!") */
-       "microscopic space fleet", "Ravenous Bugblatter Beast of Traal",
-                                               /* HGttG */
-       "teenage mutant ninja turtle",          /* TMNT */
-       "samurai rabbit",                       /* Usagi Yojimbo */
-       "aardvark",                             /* Cerebus */
-       "=Audrey II",                           /* Little Shop of Horrors */
-       "witch doctor", "one-eyed one-horned flying purple people eater",
-                                               /* 50's rock 'n' roll */
-       "+Barney the dinosaur",                 /* saccharine kiddy TV */
-       "+Morgoth",                             /* Angband */
-       "Vorlon",                               /* Babylon 5 */
-       "questing beast",                       /* King Arthur */
-       "Predator",                             /* Movie */
-       "mother-in-law"                         /* common pest */
-};
-
-
+#define BOGUSMONSIZE 100  /* arbitrary */
 /* return a random monster name, for hallucination */
-const char *
-rndmonnam()
+char *
+rndmonnam(code)
+char *code;
 {
-       const char *mname;
+       static char buf[BUFSZ];
+       char *mname = buf;
        int name;
 
+       if (code) *code = '\0';
+
        do {
-           name = rn1(SPECIAL_PM + SIZE(bogusmons) - LOW_PM, LOW_PM);
+           name = rn1(SPECIAL_PM + BOGUSMONSIZE - LOW_PM, LOW_PM);
        } while (name < SPECIAL_PM &&
            (type_is_pname(&mons[name]) || (mons[name].geno & G_NOGEN)));
 
        if (name >= SPECIAL_PM) {
-           mname = bogusmons[name - SPECIAL_PM];
+           get_rnd_text(BOGUSMONFILE, buf);
            /* strip prefix if present */
-           if (!letter(*mname)) ++mname;
+           if (!letter(*mname)) {
+               if (code) *code = *mname;
+               ++mname;
+           }
        } else {
-           mname = mons[name].mname;
+           Strcpy(buf, mons[name].mname);
        }
        return mname;
 }
+#undef BOGUSMONSIZE
 
 /* scan bogusmons to check whether this name is in the list and has a prefix */
 boolean
-bogon_is_pname(mname)
-const char *mname;
+bogon_is_pname(code)
+char code;
 {
-       const char *bname;
-       int name;
-
-       if (!mname || !*mname) return FALSE;
-       if (!strncmpi(mname, "the ", 4)) mname += 4;
-       /* scan the bogusmons[] list; case sensitive here */
-       for (name = 0; name < SIZE(bogusmons); name++) {
-           bname = bogusmons[name];
-           /* we can skip all ordinary entries */
-           if (letter(*bname)) continue;
-           /* starts with a classification code; does rest of name match? */
-           if (!strcmp(mname, bname + 1))
-               return index("-+=", *bname) ? TRUE : FALSE;
-       }
-       return FALSE;
+    if (!code) return FALSE;
+    return index("-+=", code) ? TRUE : FALSE;
 }
 
 const char *
index 983f6bcec64c05813aab961cc340b0bcbf3c7473..a5b413772708233dac14e1ab346abc43fdc11ec8 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1252,7 +1252,7 @@ const char *mesg;
            what = "chicken";
            which = 1;  /* suppress pluralization */
        } else if (Hallucination) {
-           what = rndmonnam();
+           what = rndmonnam(NULL);
        } else {
            what = mons[mnum].mname;
            if (the_unique_pm(&mons[mnum])) which = 2;
index ebfcd08297a11c59f1e9ba3d419fad7b29d1c6af..5a8aa38f33b14d21c5c51ba48c07bb9af2480999 100644 (file)
@@ -9,33 +9,6 @@
 
 STATIC_VAR NEARDATA struct engr *head_engr;
 
-/* random engravings */
-static const char *random_mesg[] = {
-       "Elbereth",
-       /* trap engravings */
-       "Vlad was here", "ad aerarium",
-       /* take-offs and other famous engravings */
-       "Owlbreath", "Galadriel",
-       "Kilroy was here",
-       "A.S. ->", "<- A.S.", /* Journey to the Center of the Earth */
-       "You won't get it up the steps", /* Adventure */
-       "Lasciate ogni speranza o voi ch'entrate.", /* Inferno */
-       "Well Come", /* Prisoner */
-       "We apologize for the inconvenience.", /* So Long... */
-       "See you next Wednesday", /* Thriller */
-       "notary sojak", /* Smokey Stover */
-       "For a good time call 8?7-5309",
-       "Please don't feed the animals.", /* Various zoos around the world */
-       "Madam, in Eden, I'm Adam.", /* A palindrome */
-       "Two thumbs up!", /* Siskel & Ebert */
-       "Hello, World!", /* The First C Program */
-#ifdef MAIL
-       "You've got mail!", /* AOL */
-#endif
-       "As if!", /* Clueless */
-       "BAD WOLF", /* 200x incarnation of Dr.Who */
-};
-
 char *
 random_engraving(outbuf)
 char *outbuf;
@@ -44,8 +17,10 @@ char *outbuf;
 
        /* a random engraving may come from the "rumors" file,
           or from the list above */
-       if (!rn2(4) || !(rumor = getrumor(0, outbuf, TRUE)) || !*rumor)
-           Strcpy(outbuf, random_mesg[rn2(SIZE(random_mesg))]);
+       if (!rn2(4) || !(rumor = getrumor(0, outbuf, TRUE)) || !*rumor) {
+           char buf[BUFSZ];
+           Strcpy(outbuf, get_rnd_text(ENGRAVEFILE, buf));
+       }
 
        wipeout_text(outbuf, (int)(strlen(outbuf) / 4), 0);
        return outbuf;
@@ -1232,39 +1207,6 @@ struct engr *ep;
 }
 
 
-/* Epitaphs for random headstones */
-static const char *epitaphs[] = {
-       "Rest in peace",
-       "R.I.P.",
-       "Rest In Pieces",
-       "Note -- there are NO valuable items in this grave",
-       "1994-1995. The Longest-Lived Hacker Ever",
-       "The Grave of the Unknown Hacker",
-       "We weren't sure who this was, but we buried him here anyway",
-       "Sparky -- he was a very good dog",
-       "Beware of Electric Third Rail",
-       "Made in Taiwan",
-       "Og friend. Og good dude. Og died. Og now food",
-       "Beetlejuice Beetlejuice Beetlejuice",
-       "Look out below!",
-       "Please don't dig me up. I'm perfectly happy down here. -- Resident",
-       "Postman, please note forwarding address: Gehennom, Asmodeus's Fortress, fifth lemure on the left",
-       "Mary had a little lamb/Its fleece was white as snow/When Mary was in trouble/The lamb was first to go",
-       "Be careful, or this could happen to you!",
-       "Soon you'll join this fellow in hell! -- the Wizard of Yendor",
-       "Caution! This grave contains toxic waste",
-       "Sum quod eris",
-       "Here lies an Atheist, all dressed up and no place to go",
-       "Here lies Ezekiel, age 102.  The good die young.",
-       "Here lies my wife: Here let her lie! Now she's at rest and so am I.",
-       "Here lies Johnny Yeast. Pardon me for not rising.",
-       "He always lied while on the earth and now he's lying in it",
-       "I made an ash of myself",
-       "Soon ripe. Soon rotten. Soon gone. But not forgotten.",
-       "Here lies the body of Jonathan Blake. Stepped on the gas instead of the brake.",
-       "Go away!"
-};
-
 /* Create a headstone at the given location.
  * The caller is responsible for newsym(x, y).
  */
@@ -1280,9 +1222,12 @@ const char *str;
        levl[x][y].typ = GRAVE;
 
        /* Engrave the headstone */
-       if (!str) str = epitaphs[rn2(SIZE(epitaphs))];
        del_engr_at(x, y);
-       make_engr_at(x, y, str, 0L, HEADSTONE);
+       if (str) make_engr_at(x, y, str, 0L, HEADSTONE);
+       else {
+           char buf[BUFSZ];
+           make_engr_at(x, y, get_rnd_text(EPITAPHFILE, buf), 0L, HEADSTONE);
+       }
        return;
 }
 
index 65dbe82a544ecb3180660c9b8e800c33d888f2c2..905b7b94bc7ffe09778fe4b1453a689561809121 100644 (file)
@@ -283,7 +283,7 @@ int expltype;
                       so avoid any which begins with a capital letter) */
                    do {
                        Sprintf(hallu_buf, "%s explosion",
-                               s_suffix(rndmonnam())); 
+                               s_suffix(rndmonnam(NULL)));
                    } while (*hallu_buf != lowc(*hallu_buf));
                    str = hallu_buf;
                }
@@ -365,7 +365,7 @@ int expltype;
                    if (do_hallu) {     /* (see explanation above) */
                        do {
                            Sprintf(hallu_buf, "%s explosion",
-                                   s_suffix(rndmonnam())); 
+                                   s_suffix(rndmonnam(NULL)));
                        } while (*hallu_buf != lowc(*hallu_buf));
                        str = hallu_buf;
                    }
index e87748e0ad3aceb105ae217bf3adb8eb47b76859..88fb6e2a4ba6f6e56d9c7e4fd14cf0824860a8c1 100644 (file)
@@ -39,7 +39,7 @@ dowatersnakes() /* Fountain of snakes! */
     if (!(mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) {
        if (!Blind)
            pline("An endless stream of %s pours forth!",
-                 Hallucination ? makeplural(rndmonnam()) : "snakes");
+                 Hallucination ? makeplural(rndmonnam(NULL)) : "snakes");
        else
            You_hear("%s hissing!", something);
        while(num-- > 0)
index 855a918879926174da1327c2db7f525ca088613c..9ea9c1d143ec2cdd10c56f5c5f38c7b4e3d8a492 100644 (file)
@@ -88,7 +88,7 @@ struct obj *obj;
                        if (vis) {
                            pline("As %s opens the bottle, an enormous %s emerges!",
                               mon_nam(mon),
-                              Hallucination ? rndmonnam() : (const char *)"ghost");
+                              Hallucination ? rndmonnam(NULL) : (const char *)"ghost");
                            pline("%s is frightened to death, and unable to move.",
                                    Monnam(mon));
                        }
index 3eba9874fa7467a180ca9e37e970ccc324bba0e2..1d78dea7656a6b316781f7b4f613d8a049476575 100644 (file)
@@ -2040,7 +2040,7 @@ struct obj *box;
            (void) add_to_container(box, deadcat);
        }
        pline_The("%s inside the box is dead!",
-           Hallucination ? rndmonnam() : "housecat");
+           Hallucination ? rndmonnam(NULL) : "housecat");
     }
     box->owt = weight(box);
     return;
index d4bfcdad388b63844e9b076733a250b9e5220f5c..0af0191814c27049bb1ff5fa2532c2b7359b80f5 100644 (file)
@@ -371,7 +371,7 @@ ghost_from_bottle()
                return;
        }
        pline("As you open the bottle, an enormous %s emerges!",
-               Hallucination ? rndmonnam() : (const char *)"ghost");
+               Hallucination ? rndmonnam(NULL) : (const char *)"ghost");
        if(flags.verbose)
            You("are frightened to death, and unable to move.");
        nomul(-3);
index 1ef7ea286a130e731229212e21630881b3c2b4eb..a28f2b8d4658bc34f1d0d4f88a7be074154bb934 100644 (file)
@@ -284,13 +284,14 @@ char *pname;              /* caller-supplied output buffer */
     boolean do_hallu = Hallucination,
            aligned_priest = mon->data == &mons[PM_ALIGNED_PRIEST],
            high_priest = mon->data == &mons[PM_HIGH_PRIEST];
-    const char *what = do_hallu ? rndmonnam() : mon->data->mname;
+    char whatcode = '\0';
+    const char *what = do_hallu ? rndmonnam(&whatcode) : mon->data->mname;
 
     if (!mon->ispriest && !mon->isminion)      /* should never happen...  */
        return strcpy(pname, what);             /* caller must be confused */
 
     *pname = '\0';
-    if (!do_hallu || !bogon_is_pname(what)) Strcat(pname, "the ");
+    if (!do_hallu || !bogon_is_pname(whatcode)) Strcat(pname, "the ");
     if (mon->minvis) Strcat(pname, "invisible ");
     if (mon->isminion && EMIN(mon)->renegade)
        Strcat(pname, "renegade ");
index 081b81d8d6b638c24c038ded20a8a7bbbb5ce5fb..4bcb5c1774d015e4a6514ddf15a46975726c8547 100644 (file)
@@ -266,6 +266,46 @@ rumor_check()
        }
 }
 
+
+/* Gets a random line of text from file 'fname', and returns it. */
+char *
+get_rnd_text(fname, buf)
+const char *fname;
+char *buf;
+{
+    dlb *fh;
+
+    buf[0] = '\0';
+
+    fh = dlb_fopen(fname, "r");
+
+    if (fh) {
+       /* TODO: cache sizetxt, starttxt, endtxt. maybe cache file contents? */
+       long sizetxt = 0, starttxt = 0, endtxt = 0, tidbit = 0;
+       char *endp, line[BUFSZ], xbuf[BUFSZ];
+       (void) dlb_fgets(line, sizeof line, fh); /* skip "don't edit" comment */
+
+       (void) dlb_fseek(fh, 0L, SEEK_CUR);
+       starttxt = dlb_ftell(fh);
+       (void) dlb_fseek(fh, 0L, SEEK_END);
+       endtxt = dlb_ftell(fh);
+       sizetxt = endtxt - starttxt;
+       tidbit = Rand() % sizetxt;
+
+       (void) dlb_fseek(fh, starttxt + tidbit, SEEK_SET);
+       (void) dlb_fgets(line, sizeof line, fh);
+       if (!dlb_fgets(line, sizeof line, fh)) {
+          (void) dlb_fseek(fh, starttxt, SEEK_SET);
+          (void) dlb_fgets(line, sizeof line, fh);
+       }
+       if ((endp = index(line, '\n')) != 0) *endp = 0;
+       Strcat(buf, xcrypt(line, xbuf));
+       (void) dlb_fclose(fh);
+    } else impossible("Can't open file %s!", fname);
+    return buf;
+}
+
+
 void
 outrumor(truth, mechanism)
 int truth; /* 1=true, -1=false, 0=either */
index 3b2ee2f5693bbb2a61e2cae67ef2a120431c5694..6204847e83c0b927e5dcdfdf98e3c4f7dfacbdd5 100644 (file)
@@ -1006,7 +1006,7 @@ dochat()
       if (!Blind) {
        if (Hallucination) {
          /* if you're hallucinating, you can't tell it's a statue */
-         pline_The("%s seems not to notice you.", rndmonnam());
+         pline_The("%s seems not to notice you.", rndmonnam(NULL));
        }
        else {
          pline_The("statue seems not to notice you.");
index 481b16ae741f4535ccb08c6bdbd7143a4eb521ca..e47d863fba26ea1dbf38090e71b7323b23d6a5e3 100644 (file)
@@ -164,7 +164,7 @@ slime_dialogue()
                    if (!Blind) /* [what if you're already green?] */
                        pline(buf, hcolor(NH_GREEN));
                } else
-                   pline(buf, an(Hallucination ? rndmonnam() : "green slime"));
+                   pline(buf, an(Hallucination ? rndmonnam(NULL) : "green slime"));
            } else
                pline1(buf);
        }
index bc8f0c7466895006f31164a0c5679a889b58b78d..beb24ad9acb2cf06dd8ea2eb4334266e7d19e5c5 100644 (file)
@@ -621,7 +621,7 @@ int *fail_reason;
                            "statue");
            pline("%s %s!", upstart(statuename), comes_to_life);
        } else if (Hallucination) {    /* They don't know it's a statue */
-           pline_The("%s suddenly seems more animated.", rndmonnam());
+           pline_The("%s suddenly seems more animated.", rndmonnam(NULL));
        } else if (cause == ANIMATE_SHATTER) {
            if (cansee(x, y))
                Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
index 5f39fc30e80d14758f59d242c47a39fab91b4244..3134c8b889a7f08a41fc263cb70c1edb289fc9b8 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1799,7 +1799,7 @@ struct obj *obj, *otmp;
                    if (break_statue(obj)) {
                        if (cansee(obj->ox, obj->oy)) {
                            if (Hallucination)
-                               pline_The("%s shatters.", rndmonnam());
+                               pline_The("%s shatters.", rndmonnam(NULL));
                            else 
                                pline_The("statue shatters.");
                        } else
index ad9cb6e2d223e0cccbb500be04dca7711016f88c..17c543897d6d866462a48261fbe7e0904410e5ff 100644 (file)
@@ -9,7 +9,7 @@ NHSROOT=..
 # SHELL=E:/GEMINI2/MUPFEL.TTP
 # UUDECODE=uudecode
 
-VARDAT = data rumors quest.dat oracles options
+VARDAT = bogusmon data engrave epitaph rumors quest.dat oracles options
 
 all:   $(VARDAT) spec_levs quest_levs dungeon
 
@@ -98,6 +98,15 @@ quest.dat:   quest.txt ../util/makedefs
 oracles:       oracles.txt ../util/makedefs
        ../util/makedefs -h
 
+engrave:       engrave.txt ../util/makedefs
+       ../util/makedefs -s
+
+epitaph:       epitaph.txt ../util/makedefs
+       ../util/makedefs -s
+
+bogusmon:      bogusmon.txt ../util/makedefs
+       ../util/makedefs -s
+
 # note: 'options' should have already been made when include/date.h was created
 options:       ../util/makedefs
        ../util/makedefs -v
index f9e474a5b78a209bd79cbab0a9668f771e7dc10d..77cd28fa1bf01d753e8692d9e0a6e436b447fea8 100644 (file)
@@ -56,7 +56,7 @@ VARDIR  = $(HACKDIR)
 # for Gnome
 # VARDATND = x11tiles pet_mark.xbm rip.xpm mapbg.xpm
 
-VARDATD = data oracles options quest.dat rumors
+VARDATD = bogusmon data engrave epitaph oracles options quest.dat rumors
 VARDAT = $(VARDATD) $(VARDATND)
 
 # Some versions of make use the SHELL environment variable as the shell
@@ -109,6 +109,15 @@ manpages:
 data: $(GAME)
        ( cd dat ; $(MAKE) data )
 
+engrave: $(GAME)
+       ( cd dat ; $(MAKE) engrave )
+
+bogusmon: $(GAME)
+       ( cd dat ; $(MAKE) bogusmon )
+
+epitaph: $(GAME)
+       ( cd dat ; $(MAKE) epitaph )
+
 rumors: $(GAME)
        ( cd dat ; $(MAKE) rumors )
 
index f4ca9febbf5643525718887bc5c36d08c85a1356..8555178e1f4a09927bf6cb98fc7af936870da54b 100644 (file)
@@ -169,6 +169,7 @@ static char *FDECL(bannerc_string, (char *,const char *));
 static char *FDECL(xcrypt, (const char *));
 static unsigned long FDECL(read_rumors_file,
                           (const char *,int *,long *,unsigned long));
+static void FDECL(do_rnd_access_file, (const char *));
 static boolean FDECL(d_filter, (char *));
 static boolean FDECL(h_filter, (char *));
 static boolean FDECL(ranged_attk,(struct permonst*));
@@ -213,7 +214,7 @@ extern unsigned _stklen = STKSIZ;
 int
 main(void)
 {
-    const char *def_options = "odemvpqrhz";
+    const char *def_options = "odemvpqrshz";
     char buf[100];
     int len;
 
@@ -329,6 +330,11 @@ char       *options;
                case 'r':
                case 'R':       do_rumors();
                                break;
+               case 's':
+               case 'S':       do_rnd_access_file(EPITAPHFILE);
+                               do_rnd_access_file(ENGRAVEFILE);
+                               do_rnd_access_file(BOGUSMONFILE);
+                               break;
                case 'h':
                case 'H':       do_oracles();
                                break;
@@ -870,6 +876,44 @@ unsigned long old_rumor_offset;
     return rumor_offset;
 }
 
+
+void
+do_rnd_access_file(fname)
+const char *fname;
+{
+    Sprintf(filename, DATA_IN_TEMPLATE, fname);
+    Strcat(filename, ".txt");
+    if (!(ifp = fopen(filename, RDTMODE))) {
+       perror(filename);
+       exit(EXIT_FAILURE);
+    }
+    filename[0]='\0';
+#ifdef FILE_PREFIX
+    Strcat(filename, file_prefix);
+#endif
+    Sprintf(eos(filename), DATA_TEMPLATE, fname);
+    if (!(ofp = fopen(filename, WRTMODE))) {
+       perror(filename);
+       exit(EXIT_FAILURE);
+    }
+    Fprintf(ofp,"%s",Dont_Edit_Data);
+
+    tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE);
+    grep0(ifp, tfp);
+    ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE);
+
+    while (fgets(in_line, sizeof in_line, ifp) != 0) {
+       if (in_line[0] == '#') continue; /* discard comments */
+       if (in_line[0] == '\n') continue; /* and empty lines */
+       (void) fputs(xcrypt(in_line), ofp);
+    }
+    Fclose(ifp);
+    Fclose(ofp);
+
+    delete_file(DATA_TEMPLATE, "grep.tmp");
+    return;
+}
+
 void
 do_rumors()
 {