From 35493a3545fb1f3f79cc84e2e213e92a4052ce29 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Mon, 21 Jul 2008 00:03:41 +0000 Subject: [PATCH] current_fruit (trunk only) 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 | 1 + include/decl.h | 3 +-- include/patchlevel.h | 4 ++-- src/decl.c | 3 +-- src/eat.c | 6 +++--- src/mkobj.c | 4 ++-- src/objnam.c | 4 ++-- src/options.c | 13 ++++++------- src/pager.c | 4 ++-- src/restore.c | 3 +-- src/save.c | 3 +-- 11 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/context.h b/include/context.h index 40ff77c70..13d40fe40 100644 --- a/include/context.h +++ b/include/context.h @@ -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 */ diff --git a/include/decl.h b/include/decl.h index 71c0bd73f..9a514306a 100644 --- a/include/decl.h +++ b/include/decl.h @@ -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]; diff --git a/include/patchlevel.h b/include/patchlevel.h index 5489fb68c..b85553b30 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -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" diff --git a/src/decl.c b/src/decl.c index 21ce6d18c..758cca74e 100644 --- a/src/decl.c +++ b/src/decl.c @@ -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; diff --git a/src/eat.c b/src/eat.c index 3f683fce7..a1191ef2e 100644 --- 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)); diff --git a/src/mkobj.c b/src/mkobj.c index 43bd9edc2..90460600f 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -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); diff --git a/src/objnam.c b/src/objnam.c index 44e24608b..e0a291d76 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -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 diff --git a/src/options.c b/src/options.c index d9ae04f3a..e4fe0d9bc 100644 --- a/src/options.c +++ b/src/options.c @@ -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; } diff --git a/src/pager.c b/src/pager.c index cfc9c33bc..0466ca2cd 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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); } diff --git a/src/restore.c b/src/restore.c index dede19485..b8d4cba70 100644 --- a/src/restore.c +++ b/src/restore.c @@ -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) ¤t_fruit, sizeof current_fruit); freefruitchn(ffruit); /* clean up fruit(s) made by initoptions() */ ffruit = loadfruitchn(fd); diff --git a/src/save.c b/src/save.c index 6d03ef372..8e5a09f65 100644 --- a/src/save.c +++ b/src/save.c @@ -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) ¤t_fruit, sizeof current_fruit); savefruitchn(fd, mode); savenames(fd, mode); save_waterlevel(fd, mode); -- 2.40.0