From a5b8144dd1248dd68c56574cf9e58ad13881ab81 Mon Sep 17 00:00:00 2001 From: arromdee Date: Sun, 3 Mar 2002 05:01:09 +0000 Subject: [PATCH] wizkit messages for gold This prevents wizkit items that aren't objects from having their names printed on the screen if they are gold pieces, traps, or similar. (Note that the only one of those that actually works is gold. For some reason if you put "a hole" (for instance) in the wizkit, the hole will not get created, even though it will, even on the stairs, if the wizard wishes for it in-game.) --- include/extern.h | 2 +- src/files.c | 2 +- src/objnam.c | 41 +++++++++++++++++++++++++++-------------- src/zap.c | 4 ++-- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/extern.h b/include/extern.h index e09f4aeea..c1873100c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1331,7 +1331,7 @@ E char *FDECL(yname, (struct obj *)); E char *FDECL(Yname2, (struct obj *)); E char *FDECL(makeplural, (const char *)); E char *FDECL(makesingular, (const char *)); -E struct obj *FDECL(readobjnam, (char *,struct obj *)); +E struct obj *FDECL(readobjnam, (char *,struct obj *,BOOLEAN_P)); E int FDECL(rnd_class, (int,int)); E const char *FDECL(cloak_simple_name, (struct obj *)); diff --git a/src/files.c b/src/files.c index 615062a03..79e3a3907 100644 --- a/src/files.c +++ b/src/files.c @@ -1676,7 +1676,7 @@ read_wizkit() while (fgets(buf, 4*BUFSZ, fp)) { if ((ep = index(buf, '\n'))) *ep = '\0'; if (buf[0]) { - otmp = readobjnam(buf, (struct obj *)0); + otmp = readobjnam(buf, (struct obj *)0, FALSE); if (otmp) { if (otmp != &zeroobj) otmp = addinv(otmp); diff --git a/src/objnam.c b/src/objnam.c index c35379883..bf5cb3976 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1602,9 +1602,10 @@ struct alt_spellings { * return null. */ struct obj * -readobjnam(bp, no_wish) +readobjnam(bp, no_wish, noisy) register char *bp; struct obj *no_wish; +boolean noisy; { register char *p; register int i; @@ -1944,7 +1945,8 @@ struct obj *no_wish; ) cnt=5000; if (cnt < 1) cnt=1; #ifndef GOLDOBJ - pline("%d gold piece%s.", cnt, plur(cnt)); + if (noisy) + pline("%d gold piece%s.", cnt, plur(cnt)); u.ugold += cnt; flags.botl=1; return (&zeroobj); @@ -2162,7 +2164,8 @@ srch: if((trap == TRAPDOOR || trap == HOLE) && !Can_fall_thru(&u.uz)) trap = ROCKTRAP; (void) maketrap(u.ux, u.uy, trap); - pline("%s.", An(tname)); + if (noisy) + pline("%s.", An(tname)); return(&zeroobj); } } @@ -2173,14 +2176,16 @@ srch: level.flags.nfountains++; if(!strncmpi(bp, "magic ", 6)) levl[u.ux][u.uy].blessedftn = 1; - pline("A %sfountain.", + if (noisy) + pline("A %sfountain.", levl[u.ux][u.uy].blessedftn ? "magic " : ""); newsym(u.ux, u.uy); return(&zeroobj); } if(!BSTRCMP(bp, p-6, "throne")) { levl[u.ux][u.uy].typ = THRONE; - pline("A throne."); + if (noisy) + pline("A throne."); newsym(u.ux, u.uy); return(&zeroobj); } @@ -2188,7 +2193,8 @@ srch: if(!BSTRCMP(bp, p-4, "sink")) { levl[u.ux][u.uy].typ = SINK; level.flags.nsinks++; - pline("A sink."); + if (noisy) + pline("A sink."); newsym(u.ux, u.uy); return &zeroobj; } @@ -2196,7 +2202,8 @@ srch: if(!BSTRCMP(bp, p-4, "pool")) { levl[u.ux][u.uy].typ = POOL; del_engr_at(u.ux, u.uy); - pline("A pool."); + if (noisy) + pline("A pool."); /* Must manually make kelp! */ water_damage(level.objects[u.ux][u.uy], FALSE, TRUE); newsym(u.ux, u.uy); @@ -2205,7 +2212,8 @@ srch: if (!BSTRCMP(bp, p-4, "lava")) { /* also matches "molten lava" */ levl[u.ux][u.uy].typ = LAVAPOOL; del_engr_at(u.ux, u.uy); - pline("A pool of molten lava."); + if (noisy) + pline("A pool of molten lava."); if (!(Levitation || Flying)) (void) lava_effects(); newsym(u.ux, u.uy); return &zeroobj; @@ -2226,21 +2234,24 @@ srch: else /* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */ al = (!rn2(6)) ? A_NONE : rn2((int)A_LAWFUL+2) - 1; levl[u.ux][u.uy].altarmask = Align2amask( al ); - pline("%s altar.", An(align_str(al))); + if (noisy) + pline("%s altar.", An(align_str(al))); newsym(u.ux, u.uy); return(&zeroobj); } if(!BSTRCMP(bp, p-5, "grave") || !BSTRCMP(bp, p-9, "headstone")) { make_grave(u.ux, u.uy, (char *) 0); - pline("A grave."); + if (noisy) + pline("A grave."); newsym(u.ux, u.uy); return(&zeroobj); } if(!BSTRCMP(bp, p-4, "tree")) { levl[u.ux][u.uy].typ = TREE; - pline("A tree."); + if (noisy) + pline("A tree."); newsym(u.ux, u.uy); block_point(u.ux, u.uy); return &zeroobj; @@ -2248,7 +2259,8 @@ srch: if(!BSTRCMP(bp, p-4, "bars")) { levl[u.ux][u.uy].typ = IRONBARS; - pline("Iron bars."); + if (noisy) + pline("Iron bars."); newsym(u.ux, u.uy); return &zeroobj; } @@ -2543,8 +2555,9 @@ typfnd: artifact_exists(otmp, ONAME(otmp), FALSE); obfree(otmp, (struct obj *) 0); otmp = &zeroobj; - pline( - "For a moment, you feel %s in your %s, but it disappears!", + if (noisy) + pline( + "For a moment, you feel %s in your %s, but it disappears!", something, makeplural(body_part(HAND))); } diff --git a/src/zap.c b/src/zap.c index 0ed75f3d6..b7a390999 100644 --- a/src/zap.c +++ b/src/zap.c @@ -4035,12 +4035,12 @@ retry: * has been denied. Wishing for "nothing" requires a separate * value to remain distinct. */ - otmp = readobjnam(buf, ¬hing); + otmp = readobjnam(buf, ¬hing, TRUE); if (!otmp) { pline("Nothing fitting that description exists in the game."); if (++tries < 5) goto retry; pline(thats_enough_tries); - otmp = readobjnam((char *)0, (struct obj *)0); + otmp = readobjnam((char *)0, (struct obj *)0, TRUE); if (!otmp) return; /* for safety; should never happen */ } else if (otmp == ¬hing) { /* explicitly wished for "nothing", presumeably attempting