From: Pasi Kallinen Date: Wed, 18 Mar 2015 20:05:10 +0000 (+0200) Subject: Move some hard-coded string arrays into data files. X-Git-Tag: NetHack-3.6.0_RC01~588 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=debdf7ca48fc7b9c8b7b3698147d05312a605092;p=nethack Move some hard-coded string arrays into data files. Random epitaphs, engravings and hallucinatory monsters now live in text data files. --- diff --git a/dat/bogusmon.txt b/dat/bogusmon.txt new file mode 100644 index 000000000..8c7aba45b --- /dev/null +++ b/dat/bogusmon.txt @@ -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 index 000000000..6827c8a9a --- /dev/null +++ b/dat/engrave.txt @@ -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 index 000000000..79019ea45 --- /dev/null +++ b/dat/epitaph.txt @@ -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! diff --git a/doc/makedefs.6 b/doc/makedefs.6 index 7b850108c..61bd7c741 100644 --- a/doc/makedefs.6 +++ b/doc/makedefs.6 @@ -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 diff --git a/include/extern.h b/include/extern.h index fc3952804..23d10d324 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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)); diff --git a/include/global.h b/include/global.h index 6179409bb..a67066d64 100644 --- a/include/global.h +++ b/include/global.h @@ -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 */ diff --git a/src/do_name.c b/src/do_name.c index 47012d3f3..0f837c9d4 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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 * diff --git a/src/eat.c b/src/eat.c index 983f6bcec..a5b413772 100644 --- 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; diff --git a/src/engrave.c b/src/engrave.c index ebfcd0829..5a8aa38f3 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -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; } diff --git a/src/explode.c b/src/explode.c index 65dbe82a5..905b7b94b 100644 --- a/src/explode.c +++ b/src/explode.c @@ -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; } diff --git a/src/fountain.c b/src/fountain.c index e87748e0a..88fb6e2a4 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -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) diff --git a/src/muse.c b/src/muse.c index 855a91887..9ea9c1d14 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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)); } diff --git a/src/pickup.c b/src/pickup.c index 3eba9874f..1d78dea76 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -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; diff --git a/src/potion.c b/src/potion.c index d4bfcdad3..0af019181 100644 --- a/src/potion.c +++ b/src/potion.c @@ -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); diff --git a/src/priest.c b/src/priest.c index 1ef7ea286..a28f2b8d4 100644 --- a/src/priest.c +++ b/src/priest.c @@ -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 "); diff --git a/src/rumors.c b/src/rumors.c index 081b81d8d..4bcb5c177 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -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 */ diff --git a/src/sounds.c b/src/sounds.c index 3b2ee2f56..6204847e8 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -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."); diff --git a/src/timeout.c b/src/timeout.c index 481b16ae7..e47d863fb 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -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); } diff --git a/src/trap.c b/src/trap.c index bc8f0c746..beb24ad9a 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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), diff --git a/src/zap.c b/src/zap.c index 5f39fc30e..3134c8b88 100644 --- 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 diff --git a/sys/unix/Makefile.dat b/sys/unix/Makefile.dat index ad9cb6e2d..17c543897 100644 --- a/sys/unix/Makefile.dat +++ b/sys/unix/Makefile.dat @@ -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 diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index f9e474a5b..77cd28fa1 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -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 ) diff --git a/util/makedefs.c b/util/makedefs.c index f4ca9febb..8555178e1 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -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() {