From 7c05c92eed991cb11edb04c62a114a66f301d7ef Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Wed, 21 Oct 2009 03:05:53 +0000 Subject: [PATCH] dungeon_overview adjustment The dungeon_overview bits in the rm structure were being clobbered by a run-length encoding save/restore because they weren't taken into consideration. This patch pulls that data out of the rm structure completely. It also adjusts the run-length encoding checks to take the candig bit into consideration and adds a comment to rm.h reminding people to make run-length encoding adjustments in save.c for any new bits that get added. --- include/patchlevel.h | 2 +- include/rm.h | 12 +++++++----- src/bones.c | 2 +- src/decl.c | 5 +++++ src/display.c | 6 +++--- src/dungeon.c | 6 +++--- src/lock.c | 8 ++++---- src/read.c | 2 +- src/restore.c | 3 +++ src/save.c | 7 +++++-- 10 files changed, 33 insertions(+), 20 deletions(-) diff --git a/include/patchlevel.h b/include/patchlevel.h index 2f18517c9..b7f6452e0 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -14,7 +14,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 43 +#define EDITLEVEL 44 #define COPYRIGHT_BANNER_A \ "NetHack, Copyright 1985-2009" diff --git a/include/rm.h b/include/rm.h index 2b358cfb6..4965f035c 100644 --- a/include/rm.h +++ b/include/rm.h @@ -376,6 +376,9 @@ extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */ * The structure describing a coordinate position. * Before adding fields, remember that this will significantly affect * the size of temporary files and save files. + * + * Also remember that the run-length encoding for some ports in save.c + * must be updated to consider the field. */ struct rm { int glyph; /* what the hero thinks is there */ @@ -389,11 +392,6 @@ struct rm { Bitfield(roomno,6); /* room # for special rooms */ Bitfield(edge,1); /* marks boundaries for special rooms*/ Bitfield(candig,1); /* Exception to Can_dig_down; was a trapdoor */ - -#ifdef DUNGEON_OVERVIEW - Bitfield(styp, 6); /* last seen/touched dungeon typ */ - /* 2 free bits */ -#endif /* DUNGEON_OVERVIEW */ }; /* @@ -541,6 +539,10 @@ typedef struct } dlevel_t; +#ifdef DUNGEON_OVERVIEW +extern schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */ +#endif /* DUNGEON_OVERVIEW */ + extern dlevel_t level; /* structure describing the current level */ /* diff --git a/src/bones.c b/src/bones.c index fc426a328..f17a5efb7 100644 --- a/src/bones.c +++ b/src/bones.c @@ -402,7 +402,7 @@ struct obj *corpse; levl[x][y].waslit = 0; levl[x][y].glyph = cmap_to_glyph(S_stone); #ifdef DUNGEON_OVERVIEW - levl[x][y].styp = 0; + lastseentyp[x][y] = 0; #endif } diff --git a/src/decl.c b/src/decl.c index 7edcabac8..0caf1aea1 100644 --- a/src/decl.c +++ b/src/decl.c @@ -142,6 +142,11 @@ NEARDATA struct instance_flags iflags = DUMMY; NEARDATA struct you u = DUMMY; NEARDATA time_t ubirthday = DUMMY; + +#ifdef DUNGEON_OVERVIEW +schar lastseentyp[COLNO][ROWNO] = {DUMMY}; /* last seen/touched dungeon typ */ +#endif /* DUNGEON_OVERVIEW */ + NEARDATA struct obj *invent = (struct obj *)0, *uwep = (struct obj *)0, *uarm = (struct obj *)0, *uswapwep = (struct obj *)0, diff --git a/src/display.c b/src/display.c index ce9b80447..3c779e8f6 100644 --- a/src/display.c +++ b/src/display.c @@ -135,7 +135,7 @@ STATIC_DCL void FDECL(t_warn, (struct rm *)); STATIC_DCL int FDECL(wall_angle, (struct rm *)); #ifdef DUNGEON_OVERVIEW -# define remember_topology(levp) ((levp)->styp = (levp)->typ) +# define remember_topology(x,y) (lastseentyp[x][y] = levl[x][y].typ) #else # define remember_topology(levp) /*empty*/ #endif @@ -193,7 +193,7 @@ magic_map_background(x, y, show) lev->glyph = glyph; if (show) show_glyph(x,y, glyph); - remember_topology(lev); /* DUNGEON_OVERVIEW */ + remember_topology(x,y); /* DUNGEON_OVERVIEW */ } /* @@ -350,7 +350,7 @@ unmap_object(x, y) else \ map_background(x,y,show); \ \ - remember_topology(&levl[x][y]); /* DUNGEON_OVERVIEW */ \ + remember_topology(x,y); /* DUNGEON_OVERVIEW */ \ } void diff --git a/src/dungeon.c b/src/dungeon.c index 13bf91ffd..3f9919b3f 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2144,15 +2144,15 @@ recalc_mapseen() * (vision-related styp update done in loop below) */ if (!Levitation) - levl[u.ux][u.uy].styp = levl[u.ux][u.uy].typ; + lastseentyp[u.ux][u.uy] = levl[u.ux][u.uy].typ; for (x = 0; x < COLNO; x++) { for (y = 0; y < ROWNO; y++) { /* update styp from viz_array */ if (viz_array[y][x] & IN_SIGHT) - levl[x][y].styp = levl[x][y].typ; + lastseentyp[x][y] = levl[x][y].typ; - switch (levl[x][y].styp) { + switch (lastseentyp[x][y]) { /* case ICE: mptr->feat.ice = 1; diff --git a/src/lock.c b/src/lock.c index 569ace1a7..e456cdf56 100644 --- a/src/lock.c +++ b/src/lock.c @@ -567,13 +567,13 @@ doopen() /* try to open a door */ if (Blind) { int oldglyph = door->glyph; #ifdef DUNGEON_OVERVIEW - schar oldstyp = door->styp; + schar oldlastseentyp = lastseentyp[cc.x][cc.y]; #endif feel_location(cc.x, cc.y); if (door->glyph != oldglyph #ifdef DUNGEON_OVERVIEW - || door->styp != oldstyp + || lastseentyp[cc.x][cc.y] != oldlastseentyp #endif ) res = 1; /* learned something */ } @@ -695,13 +695,13 @@ doclose() /* try to close a door */ if (Blind) { int oldglyph = door->glyph; #ifdef DUNGEON_OVERVIEW - schar oldstyp = door->styp; + schar oldlastseentyp = lastseentyp[x][y]; #endif feel_location(x, y); if (door->glyph != oldglyph #ifdef DUNGEON_OVERVIEW - || door->styp != oldstyp + || lastseentyp[x][y] != oldlastseentyp #endif ) res = 1; /* learned something */ } diff --git a/src/read.c b/src/read.c index a730c95f8..7f77042c8 100644 --- a/src/read.c +++ b/src/read.c @@ -573,7 +573,7 @@ forget_map(howmuch) levl[zx][zy].waslit = 0; levl[zx][zy].glyph = cmap_to_glyph(S_stone); #ifdef DUNGEON_OVERVIEW - levl[zx][zy].styp = STONE; + lastseentyp[zx][zy] = STONE; #endif } } diff --git a/src/restore.c b/src/restore.c index e369eb6bd..197d293ff 100644 --- a/src/restore.c +++ b/src/restore.c @@ -999,6 +999,9 @@ boolean ghostly; trickery(trickbuf); } rest_levl(fd, (boolean)((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); +#ifdef DUNGEON_OVERVIEW + mread(fd, (genericptr_t)lastseentyp, sizeof(lastseentyp)); +#endif mread(fd, (genericptr_t)&omoves, sizeof(omoves)); elapsed = monstermoves - omoves; mread(fd, (genericptr_t)&upstair, sizeof(stairway)); diff --git a/src/save.c b/src/save.c index 3a1d32cc3..d0c3dad53 100644 --- a/src/save.c +++ b/src/save.c @@ -514,7 +514,9 @@ int mode; bwrite(fd,(genericptr_t) &lev,sizeof(lev)); #endif savelevl(fd, (boolean)((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); - +#ifdef DUNGEON_OVERVIEW + bwrite(fd,(genericptr_t) lastseentyp,sizeof(lastseentyp)); +#endif bwrite(fd,(genericptr_t) &monstermoves,sizeof(monstermoves)); bwrite(fd,(genericptr_t) &upstair,sizeof(stairway)); bwrite(fd,(genericptr_t) &dnstair,sizeof(stairway)); @@ -579,7 +581,8 @@ boolean rlecomp; && prm->lit == rgrm->lit && prm->waslit == rgrm->waslit && prm->roomno == rgrm->roomno - && prm->edge == rgrm->edge) { + && prm->edge == rgrm->edge + && prm->candig == rgrm->candig) { match++; if (match > 254) { match = 254; /* undo this match */