]> granicus.if.org Git - nethack/commitdiff
current_fruit (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 21 Jul 2008 00:03:41 +0000 (00:03 +0000)
committernethack.rankin <nethack.rankin>
Mon, 21 Jul 2008 00:03:41 +0000 (00:03 +0000)
     I almost abandoned this when Michael beat me to it, but besides
handling the fruit rename bug it also moves `current_fruit' into the
context structure to eliminate separate save/restore for that.

include/context.h
include/decl.h
include/patchlevel.h
src/decl.c
src/eat.c
src/mkobj.c
src/objnam.c
src/options.c
src/pager.c
src/restore.c
src/save.c

index 40ff77c70647fd0c2ce404e9515d2beaee4a0373..13d40fe40621a92b1def8b56da29c22e4ab2b587 100644 (file)
@@ -79,6 +79,7 @@ struct context_info {
                                /* 3: FH, 4: ff+, 5: ff-, 6: FF+, 7: FF- */
                                /* 8: travel */
        unsigned startingpet_mid;
+       int      current_fruit; /* fruit->fid corresponding to pl_fruit[] */
        int      warnlevel;
        int      rndencode;     /* randomized escape sequence introducer */
        long next_attrib_check; /* next attribute check */
index 71c0bd73fd3e964c26b0a0cc4aedbd4db8f010bb..9a514306a71f68d8aead681465e99f93e1832f6a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)decl.h     3.5     2008/01/30      */
+/*     SCCS Id: @(#)decl.h     3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -131,7 +131,6 @@ E NEARDATA char pl_character[PL_CSIZ];
 E NEARDATA char pl_race;               /* character's race */
 
 E NEARDATA char pl_fruit[PL_FSIZ];
-E NEARDATA int current_fruit;
 E NEARDATA struct fruit *ffruit;
 
 E NEARDATA char tune[6];
index 5489fb68c2365720f36c0dc4a326f154ecb77513..b85553b305bbbc5a049ee1e35372ff2126806adb 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)patchlevel.h       3.5     2007/04/01      */
+/*     SCCS Id: @(#)patchlevel.h       3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      40
+#define EDITLEVEL      41
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2007"
index 21ce6d18cba188a6dafb073c72871ddbdfe61217..758cca74ee599fbef235b972fb267fdf422a86a3 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)decl.c     3.5     2008/01/30      */
+/*     SCCS Id: @(#)decl.c     3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -55,7 +55,6 @@ NEARDATA char pl_character[PL_CSIZ] = DUMMY;
 NEARDATA char pl_race = '\0';
 
 NEARDATA char pl_fruit[PL_FSIZ] = DUMMY;
-NEARDATA int current_fruit = 0;
 NEARDATA struct fruit *ffruit = (struct fruit *)0;
 
 NEARDATA char tune[6] = DUMMY;
index 3f683fce711e360f1e8435129fc21761dcce5662..a1191ef2ec5b2f76a4c01ef5a2bc461b93173f7d 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)eat.c      3.5     2008/05/26      */
+/*     SCCS Id: @(#)eat.c      3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1747,8 +1747,8 @@ struct obj *otmp;
                }
                /* Fall through otherwise */
            default:
-               if (otmp->otyp==SLIME_MOLD && !otmp->cursed
-                       && otmp->spe == current_fruit)
+               if (otmp->otyp == SLIME_MOLD && !otmp->cursed &&
+                       otmp->spe == context.current_fruit)
                    pline("My, that was a %s %s!",
                          Hallucination ? "primo" : "yummy",
                          singular(otmp, xname));
index 43bd9edc236b23bbb0230680bafa80493dbf92d3..90460600f76ab917a394189c9d98660e79f62baf 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkobj.c    3.5     2007/11/10      */
+/*     SCCS Id: @(#)mkobj.c    3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -675,7 +675,7 @@ boolean artif;
                blessorcurse(otmp, 10);
                break;
            case SLIME_MOLD:
-               otmp->spe = current_fruit;
+               otmp->spe = context.current_fruit;
                break;
            case KELP_FROND:
                otmp->quan = (long) rnd(2);
index 44e24608b01444fe013c9ea9c63a78fc4e422aea..e0a291d76090e7cf15f2b86be9ac4bb4ae68e962 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)objnam.c   3.5     2008/01/23      */
+/*     SCCS Id: @(#)objnam.c   3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2184,7 +2184,7 @@ struct obj *no_wish;
        int islit, unlabeled, ishistoric, isdiluted, trapped;
        int tmp, tinv, tvariety;
        struct fruit *f;
-       int ftype = current_fruit;
+       int ftype = context.current_fruit;
        char fruitbuf[BUFSZ];
        /* Fruits may not mess up the ability to wish for real objects (since
         * you can leave a fruit in a bones file and it will be added to
index d9ae04f3a202e2cf2e18f7d6984822bacc994b38..e4fe0d9bcadf4b0bc1d2516d723e419cee9f878e 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)options.c  3.5     2008/02/19      */
+/*     SCCS Id: @(#)options.c  3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -4106,13 +4106,12 @@ char *str;
                lastf = f;
                if(f->fid > highest_fruit_id) highest_fruit_id = f->fid;
                if (!strncmp(str, f->fname, PL_FSIZ-1) ||
-                           (*altname && !strcmp(altname, f->fname))) {
-                       highest_fruit_id = f->fid;
+                           (*altname && !strcmp(altname, f->fname)))
                        goto nonew;
-               }
        }
        /* if adding another fruit would overflow spe, use a random
-          fruit instead... we've got a lot to choose from. */
+          fruit instead... we've got a lot to choose from.
+          current_fruit remains as is. */
        if (highest_fruit_id >= 127) return rnd(127);
        highest_fruit_id++;
        f = newfruit();
@@ -4121,8 +4120,8 @@ char *str;
        copynchars(f->fname, *altname ? altname : str, PL_FSIZ-1);
        f->fid = highest_fruit_id;
        f->nextf = 0;
-nonew:
-       if (user_specified) current_fruit = highest_fruit_id;
+ nonew:
+       if (user_specified) context.current_fruit = f->fid;
        return f->fid;
 }
 
index cfc9c33bc8830fa203483903b179c29509cf024c..0466ca2cdd1412dd5e41781451471e1d32bb7680 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pager.c    3.5     2008/03/19      */
+/*     SCCS Id: @(#)pager.c    3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -221,7 +221,7 @@ lookat(x, y, buf, monbuf)
                if (otmp->oclass == COIN_CLASS)
                    otmp->quan = 2L; /* to force pluralization */
                else if (otmp->otyp == SLIME_MOLD)
-                   otmp->spe = current_fruit;  /* give the fruit a type */
+                   otmp->spe = context.current_fruit;  /* give it a type */
                Strcpy(buf, distant_name(otmp, xname));
                dealloc_obj(otmp);
            }
index dede194856ef814a9fda44a911835c8215fb27db..b8d4cba70b5a8f9321f8ce963c9722960cf08c41 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)restore.c  3.5     2007/04/21      */
+/*     SCCS Id: @(#)restore.c  3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -658,7 +658,6 @@ unsigned int *stuckid, *steedid;    /* STEED */
        mread(fd, (genericptr_t) pl_character, sizeof pl_character);
 
        mread(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
-       mread(fd, (genericptr_t) &current_fruit, sizeof current_fruit);
        freefruitchn(ffruit);   /* clean up fruit(s) made by initoptions() */
        ffruit = loadfruitchn(fd);
 
index 6d03ef372c609836ede35710ced74d818a81e53b..8e5a09f65ab502c56ff642cc59013e96bda3ea0f 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)save.c     3.5     2007/01/08      */
+/*     SCCS Id: @(#)save.c     3.5     2008/07/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -357,7 +357,6 @@ register int fd, mode;
 #endif
        bwrite(fd, (genericptr_t) pl_character, sizeof pl_character);
        bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
-       bwrite(fd, (genericptr_t) &current_fruit, sizeof current_fruit);
        savefruitchn(fd, mode);
        savenames(fd, mode);
        save_waterlevel(fd, mode);