]> granicus.if.org Git - nethack/commitdiff
tin details (trunk only)
authornethack.allison <nethack.allison>
Thu, 12 Jan 2006 03:23:05 +0000 (03:23 +0000)
committernethack.allison <nethack.allison>
Thu, 12 Jan 2006 03:23:05 +0000 (03:23 +0000)
Reveal more tin details at end of game disclosure.

b - an uncursed carrot
c - an uncursed tin of broiled kobold meat
d - an uncursed tin of stir fried fox meat
e - 4 uncursed tripe rations
f - 4 uncursed food rations
g - an uncursed cream pie
n - 4 uncursed tins of spinach
o - 3 uncursed tins of pureed newt meat
p - an uncursed homemade tin of fox meat

Note that in the case of homemade and rotten
it sounded better to have the term before the
word tin, rather than after:
homemade tins of newt meat
rather than:
tins of homemade newt meat

The wishing code should probably be
changed to reflect this so people can wish for
a "homemade tin of newt". As it stands, they must
wish for a "tin of homemade newt" which differs
from the final display. That is not included.

include/extern.h
src/eat.c
src/end.c
src/objnam.c

index 8a96ca27c14ba42694181a95fb82ebfc6dab209e..793915ba0f64ebbfee238455092f8183d5852f44 100644 (file)
@@ -577,6 +577,7 @@ E void FDECL(consume_oeaten, (struct obj *,int));
 E boolean FDECL(maybe_finished_meal, (BOOLEAN_P));
 E void FDECL(set_tin_variety, (struct obj *,int));
 E int FDECL(tin_variety_txt, (char *,int *));
+E void FDECL(tin_details, (struct obj *,int,char *));
 E boolean FDECL(Popeye, (int));
 
 /* ### end.c ### */
index 2d7f6818ddc7aa80a3f1b1ec9b4bcd046faeffb2..86ea00471dd77d1a82683178cd5c5c1fbcc8711d 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)eat.c      3.5     2005/12/09      */
+/*     SCCS Id: @(#)eat.c      3.5     2006/01/11      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -43,7 +43,7 @@ STATIC_DCL int FDECL(bounded_increase, (int,int,int));
 STATIC_DCL void FDECL(accessory_has_effect, (struct obj *));
 STATIC_DCL void FDECL(eataccessory, (struct obj *));
 STATIC_DCL const char *FDECL(foodword, (struct obj *));
-STATIC_DCL int FDECL(tin_variety, (struct obj *));
+STATIC_DCL int FDECL(tin_variety, (struct obj *,BOOLEAN_P));
 STATIC_DCL boolean FDECL(maybe_cannibal, (int,BOOLEAN_P));
 
 char msgbuf[BUFSZ];
@@ -1159,6 +1159,43 @@ int *tinvariety;
        return 0;
 }
 
+/*
+ * This assumes that buf already contains the word "tin",
+ * as is the case with caller xname().
+ */
+void
+tin_details(obj, mnum, buf)
+struct obj *obj;
+int mnum;
+char *buf;
+{
+       char buf2[BUFSZ];
+       if (obj && buf) {
+           if(obj->spe > 0)
+               Strcat(buf, " of spinach");
+           else if (mnum == NON_PM)
+               Strcpy(buf, "empty tin");
+           else {
+               if (obj->cknown && obj->spe < 0) {
+                   int r = tin_variety(obj, TRUE);
+                   if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
+                       /* put these before the word tin */
+                       Sprintf(buf2,"%s %s of ", tintxts[r].txt, buf);
+                       Strcpy(buf, buf2);
+                   } else {
+                       Sprintf(eos(buf), " of %s ", tintxts[r].txt);
+                   }
+               } else {
+                   Strcpy(eos(buf), " of ");
+               }
+               if (vegetarian(&mons[mnum]))
+                   Sprintf(eos(buf), "%s", mons[mnum].mname);
+               else
+                   Sprintf(eos(buf), "%s meat", mons[mnum].mname);
+           }
+       }
+}
+
 void
 set_tin_variety(obj, forcetype)
 struct obj *obj;
@@ -1174,7 +1211,7 @@ int forcetype;
                obj->spe = 1;           /* spinach */
                return;
        } else if (forcetype == HEALTHY_TIN) {
-               r = tin_variety(obj);
+               r = tin_variety(obj, FALSE);
                if (r < 0 || r >= TTSZ) r = ROTTEN_TIN; /* shouldn't happen */
                while ((r == ROTTEN_TIN && !obj->cursed) || !tintxts[r].fodder)
                    r = rn2(TTSZ-1);
@@ -1190,8 +1227,9 @@ int forcetype;
 }
 
 STATIC_OVL int
-tin_variety(obj)
+tin_variety(obj, disp)
 struct obj *obj;
+boolean disp;          /* we're just displaying so leave things alone */
 {
        register int r;
 
@@ -1205,7 +1243,7 @@ struct obj *obj;
        } else 
                r = rn2(TTSZ-1);
 
-       if (r == HOMEMADE_TIN &&
+       if (!disp && r == HOMEMADE_TIN &&
                 !obj->blessed && !rn2(7))
                r = ROTTEN_TIN;                 /* some homemade tins go bad */ 
 
@@ -1248,7 +1286,7 @@ opentin()         /* called during each move whilst opening a tin */
                costly_tin(COST_OPEN);
                goto use_me;
            }
-           r = tin_variety(context.tin.tin);
+           r = tin_variety(context.tin.tin, FALSE);
            which = 0;  /* 0=>plural, 1=>as-is, 2=>"the" prefix */
            if ((mnum == PM_COCKATRICE || mnum == PM_CHICKATRICE) &&
                    (Stone_resistance || Hallucination)) {
index cb1dbc2363d7ea96f4aca8453bc93a36391a565a..a31761604ffc1352411c8d47dcc5cff4f8d8ba5a 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -383,6 +383,8 @@ boolean taken;
                            obj->known = obj->bknown = obj->dknown = obj->rknown = 1;
                            if (Is_container(obj) || obj->otyp == STATUE)
                                obj->cknown = obj->lknown = 1;
+                           if (obj->otyp == TIN)
+                               obj->cknown = 1;
                        }
                        (void) display_inventory((char *)0, TRUE);
                        container_contents(invent, TRUE, TRUE);
index caede5d1a30c494795c62824d887ec7776201c7c..ffae54960670658f0d8d2a056d15984d40f605b9 100644 (file)
@@ -341,16 +341,8 @@ register struct obj *obj;
                }
 
                Strcpy(buf, actualn);
-               if (typ == TIN && obj->known) {
-                   if(obj->spe > 0)
-                       Strcat(buf, " of spinach");
-                   else if (omndx == NON_PM)
-                       Strcpy(buf, "empty tin");
-                   else if (vegetarian(&mons[omndx]))
-                       Sprintf(eos(buf), " of %s", mons[omndx].mname);
-                   else
-                       Sprintf(eos(buf), " of %s meat", mons[omndx].mname);
-               }
+               if (typ == TIN && obj->known)
+                       tin_details(obj, omndx, buf);
                break;
            case COIN_CLASS:
            case CHAIN_CLASS: