Skip to content

Commit

Permalink
current_fruit (trunk only)
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Jul 21, 2008
1 parent 60b7b2c commit 35493a3
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 26 deletions.
1 change: 1 addition & 0 deletions include/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions include/decl.h
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions include/patchlevel.h
Original file line number Diff line number Diff line change
@@ -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. */

Expand All @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/decl.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/eat.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/mkobj.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/objnam.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/options.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/pager.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/restore.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/save.c
Original file line number Diff line number Diff line change
@@ -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. */

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 35493a3

Please sign in to comment.