From 51224094165fbd9b31cd7ff9c46ef7e9a586fbe3 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Wed, 5 Mar 2003 04:39:47 +0000 Subject: [PATCH] Several things that break savefile compatibility - Version change from 3.4.x - timed_delay feature ignore in makedefs - several flags from iflags to flags - use offsets from mons array entries in save file rather than storing the ptr and calculating the distance from beginning of array --- include/display.h | 2 +- include/flag.h | 10 +++++----- include/patchlevel.h | 26 ++++++++++++++++++++------ src/allmain.c | 2 +- src/cmd.c | 6 +++--- src/hack.c | 6 +++--- src/mapglyph.c | 2 +- src/options.c | 24 ++++++++++++------------ src/pager.c | 2 +- src/pickup.c | 2 +- src/restore.c | 14 +++----------- src/save.c | 6 +----- util/makedefs.c | 11 ++--------- 13 files changed, 54 insertions(+), 59 deletions(-) diff --git a/include/display.h b/include/display.h index b94d308bf..67f86279e 100644 --- a/include/display.h +++ b/include/display.h @@ -313,7 +313,7 @@ /* The hero's glyph when seen as a monster. */ #define hero_glyph \ - monnum_to_glyph((Upolyd || !iflags.showrace) ? u.umonnum : \ + monnum_to_glyph((Upolyd || !flags.showrace) ? u.umonnum : \ (flags.female && urace.femalenum != NON_PM) ? urace.femalenum : \ urace.malenum) diff --git a/include/flag.h b/include/flag.h index badbd7df2..3c78743c8 100644 --- a/include/flag.h +++ b/include/flag.h @@ -146,6 +146,11 @@ struct flag { int initalign; /* starting alignment (index into aligns[]) */ int randomall; /* randomly assign everything not specified */ int pantheon; /* deity selection for priest character */ + /* Items which were in iflags in 3.4.x to preserve savefile compatibility */ + boolean lootabc; /* use "a/b/c" rather than "o/i/b" when looting */ + boolean showrace; /* show hero glyph by race rather than by role */ + boolean travelcmd; /* allow travel command */ + int runmode; /* update screen display during run moves */ }; /* @@ -257,11 +262,6 @@ struct instance_flags { boolean cmdassist; /* provide detailed assistance for some commands */ boolean obsolete; /* obsolete options can point at this, it isn't used */ - /* Items which belong in flags, but are here to allow save compatibility */ - boolean lootabc; /* use "a/b/c" rather than "o/i/b" when looting */ - boolean showrace; /* show hero glyph by race rather than by role */ - boolean travelcmd; /* allow travel command */ - int runmode; /* update screen display during run moves */ }; /* diff --git a/include/patchlevel.h b/include/patchlevel.h index f4f581889..ecab033d4 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -1,14 +1,14 @@ -/* SCCS Id: @(#)patchlevel.h 3.4 2003/02/19 */ +/* SCCS Id: @(#)patchlevel.h 3.4 2003/03/04 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ -/* NetHack 3.4.1 */ +/* NetHack 3.5.0 */ #define VERSION_MAJOR 3 -#define VERSION_MINOR 4 +#define VERSION_MINOR 5 /* * PATCHLEVEL is updated for each release. */ -#define PATCHLEVEL 1 +#define PATCHLEVEL 0 /* * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. @@ -24,7 +24,7 @@ #define COPYRIGHT_BANNER_C \ " See license for details." -#if 1 +#if 0 /* * If two successive patchlevels have compatible data files (fat chance), * defining this with the value of the older one will allow its bones and @@ -34,12 +34,26 @@ * PP = patch level, ee = edit level, L = literal suffix "L", * with all four numbers specified as two hexadecimal digits. */ -#define VERSION_COMPATIBILITY 0x03040000L +#define VERSION_COMPATIBILITY 0x03040100L #endif +/*****************************************************************************/ +/* Version 3.5.x */ + +/* + * NetHack 3.5.0, March NN, NNNN + * + */ + +/* Version 3.5 */ + /*****************************************************************************/ /* Version 3.4.x */ +/* Patch 2, March 17, 2003 + * Fix a few fatal errors + */ + /* Patch 1, February 22, 2003 * Fix a few fatal errors including one for reentering shops, one * involving land mines and boulders/statues, one for delayed diff --git a/src/allmain.c b/src/allmain.c index 81350f448..6e3070414 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -413,7 +413,7 @@ moveloop() if (vision_full_recalc) vision_recalc(0); /* vision! */ /* when running in non-tport mode, this gets done through domove() */ - if ((!flags.run || iflags.runmode == RUN_TPORT) && + if ((!flags.run || flags.runmode == RUN_TPORT) && (multi && (!flags.travel ? !(multi % 7) : !(moves % 7L)))) { if (flags.time && flags.run) flags.botl = 1; display_nhwindow(WIN_MAP, FALSE); diff --git a/src/cmd.c b/src/cmd.c index e778cf982..f04d5a8bb 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1840,7 +1840,7 @@ register char *cmd; multi = 0; return; case CMD_TRAVEL: - if (iflags.travelcmd) { + if (flags.travelcmd) { flags.travel = 1; flags.run = 8; flags.nopick = 1; @@ -2156,7 +2156,7 @@ click_to_cmd(x, y, mod) x -= u.ux; y -= u.uy; - if (iflags.travelcmd) { + if (flags.travelcmd) { if (abs(x) <= 1 && abs(y) <= 1 ) { x = sgn(x), y = sgn(y); } else { @@ -2382,7 +2382,7 @@ dotravel() static char cmd[2]; coord cc; - if (!iflags.travelcmd) return 0; + if (!flags.travelcmd) return 0; cmd[1]=0; cc.x = u.ux; cc.y = u.uy; diff --git a/src/hack.c b/src/hack.c index cc7c8ef38..594c523fa 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1377,13 +1377,13 @@ domove() nomovemsg = ""; } - if (flags.run && iflags.runmode != RUN_TPORT) { + if (flags.run && flags.runmode != RUN_TPORT) { /* display every step or every 7th step depending upon mode */ - if (iflags.runmode != RUN_LEAP || !(moves % 7L)) { + if (flags.runmode != RUN_LEAP || !(moves % 7L)) { if (flags.time) flags.botl = 1; curs_on_u(); delay_output(); - if (iflags.runmode == RUN_CRAWL) { + if (flags.runmode == RUN_CRAWL) { delay_output(); delay_output(); delay_output(); diff --git a/src/mapglyph.c b/src/mapglyph.c index e22af26e2..718dc7660 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -202,7 +202,7 @@ unsigned *ospecial; /* special case the hero for `showrace' option */ #ifdef TEXTCOLOR if (iflags.use_color && x == u.ux && y == u.uy && - iflags.showrace && !Upolyd) + flags.showrace && !Upolyd) color = HI_DOMESTIC; #endif } diff --git a/src/options.c b/src/options.c index 4f5fb28f2..8df297995 100644 --- a/src/options.c +++ b/src/options.c @@ -113,7 +113,7 @@ static struct Bool_Opt {"large_font", &iflags.obsolete, FALSE, SET_IN_FILE}, /* OBSOLETE */ {"legacy", &flags.legacy, TRUE, DISP_IN_GAME}, {"lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME}, - {"lootabc", &iflags.lootabc, FALSE, SET_IN_GAME}, + {"lootabc", &flags.lootabc, FALSE, SET_IN_GAME}, #ifdef MAC_GRAPHICS_ENV {"Macgraphics", &iflags.MACgraphics, TRUE, SET_IN_GAME}, #else @@ -165,7 +165,7 @@ static struct Bool_Opt #else {"showexp", (boolean *)0, FALSE, SET_IN_FILE}, #endif - {"showrace", &iflags.showrace, FALSE, SET_IN_GAME}, + {"showrace", &flags.showrace, FALSE, SET_IN_GAME}, #ifdef SCORE_ON_BOTL {"showscore", &flags.showscore, FALSE, SET_IN_GAME}, #else @@ -186,7 +186,7 @@ static struct Bool_Opt #endif {"tombstone",&flags.tombstone, TRUE, SET_IN_GAME}, {"toptenwin",&flags.toptenwin, FALSE, SET_IN_GAME}, - {"travel", &iflags.travelcmd, TRUE, SET_IN_GAME}, + {"travel", &flags.travelcmd, TRUE, SET_IN_GAME}, {"use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME}, /*WC*/ {"verbose", &flags.verbose, TRUE, SET_IN_GAME}, {(char *)0, (boolean *)0, FALSE, 0} @@ -489,7 +489,7 @@ initoptions() flags.end_own = FALSE; flags.end_top = 3; flags.end_around = 2; - iflags.runmode = RUN_LEAP; + flags.runmode = RUN_LEAP; iflags.msg_history = 20; #ifdef TTY_GRAPHICS iflags.prevmsg_window = 's'; @@ -1069,16 +1069,16 @@ boolean tinitial, tfrom_file; fullname = "runmode"; if (match_optname(opts, fullname, 4, TRUE)) { if (negated) { - iflags.runmode = RUN_TPORT; + flags.runmode = RUN_TPORT; } else if ((op = string_for_opt(opts, FALSE)) != 0) { if (!strncmpi(op, "teleport", strlen(op))) - iflags.runmode = RUN_TPORT; + flags.runmode = RUN_TPORT; else if (!strncmpi(op, "run", strlen(op))) - iflags.runmode = RUN_LEAP; + flags.runmode = RUN_LEAP; else if (!strncmpi(op, "walk", strlen(op))) - iflags.runmode = RUN_STEP; + flags.runmode = RUN_STEP; else if (!strncmpi(op, "crawl", strlen(op))) - iflags.runmode = RUN_CRAWL; + flags.runmode = RUN_CRAWL; else badoption(opts); } @@ -2133,7 +2133,7 @@ goodfruit: vision_full_recalc = 1; /* delayed recalc */ } else if ((boolopt[i].addr) == &iflags.use_inverse || - (boolopt[i].addr) == &iflags.showrace || + (boolopt[i].addr) == &flags.showrace || (boolopt[i].addr) == &iflags.hilite_pet) { need_redraw = TRUE; } @@ -2550,7 +2550,7 @@ boolean setinitial,setfromfile; } end_menu(tmpwin, "Select run/travel display mode:"); if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { - iflags.runmode = mode_pick->item.a_int - 1; + flags.runmode = mode_pick->item.a_int - 1; free((genericptr_t)mode_pick); } destroy_nhwindow(tmpwin); @@ -2783,7 +2783,7 @@ char *buf; else if (!strcmp(optname, "role")) Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m)); else if (!strcmp(optname, "runmode")) - Sprintf(buf, "%s", runmodes[iflags.runmode]); + Sprintf(buf, "%s", runmodes[flags.runmode]); else if (!strcmp(optname, "scores")) { Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around, flags.end_own ? "/own" : ""); diff --git a/src/pager.c b/src/pager.c index b95546826..58d5f0a05 100644 --- a/src/pager.c +++ b/src/pager.c @@ -577,7 +577,7 @@ do_look(quick) symbol; firstmatch is assumed to already be set for '@' */ if ((from_screen ? (sym == monsyms[S_HUMAN] && cc.x == u.ux && cc.y == u.uy) : - (sym == def_monsyms[S_HUMAN] && !iflags.showrace)) && + (sym == def_monsyms[S_HUMAN] && !flags.showrace)) && !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd) found += append_str(out_str, "you"); /* tack on "or you" */ diff --git a/src/pickup.c b/src/pickup.c index b90a4853d..ae11c47af 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -2259,7 +2259,7 @@ boolean outokay, inokay; menu_item *pick_list; char buf[BUFSZ]; int n; - const char *menuselector = iflags.lootabc ? "abc" : "oib"; + const char *menuselector = flags.lootabc ? "abc" : "oib"; any.a_void = 0; win = create_nhwindow(NHW_MENU); diff --git a/src/restore.c b/src/restore.c index ea7096612..a9391fda5 100644 --- a/src/restore.c +++ b/src/restore.c @@ -251,13 +251,7 @@ boolean ghostly; { register struct monst *mtmp, *mtmp2 = 0; register struct monst *first = (struct monst *)0; - int xl; - struct permonst *monbegin; - boolean moved; - - /* get the original base address */ - mread(fd, (genericptr_t)&monbegin, sizeof(monbegin)); - moved = (monbegin != mons); + int xl, offset; while(1) { mread(fd, (genericptr_t) &xl, sizeof(xl)); @@ -271,10 +265,8 @@ boolean ghostly; add_id_mapping(mtmp->m_id, nid); mtmp->m_id = nid; } - if (moved && mtmp->data) { - int offset = mtmp->data - monbegin; /*(ptrdiff_t)*/ - mtmp->data = mons + offset; /* new permonst location */ - } + offset = mtmp->mnum; + mtmp->data = &mons[offset]; if(mtmp->minvent) { struct obj *obj; mtmp->minvent = restobjchn(fd, ghostly, FALSE); diff --git a/src/save.c b/src/save.c index 8fb4a55a1..ea53b22bd 100644 --- a/src/save.c +++ b/src/save.c @@ -274,7 +274,6 @@ savegamestate(fd, mode) register int fd, mode; { int uid; - #ifdef MFLOPPY count_only = (mode & COUNT_SAVE); #endif @@ -875,14 +874,11 @@ register struct monst *mtmp; register struct monst *mtmp2; unsigned int xl; int minusone = -1; - struct permonst *monbegin = &mons[0]; - - if (perform_bwrite(mode)) - bwrite(fd, (genericptr_t) &monbegin, sizeof(monbegin)); while (mtmp) { mtmp2 = mtmp->nmon; if (perform_bwrite(mode)) { + mtmp->mnum = monsndx(mtmp->data); xl = mtmp->mxlth + mtmp->mnamelth; bwrite(fd, (genericptr_t) &xl, sizeof(int)); bwrite(fd, (genericptr_t) mtmp, xl + sizeof(struct monst)); diff --git a/util/makedefs.c b/util/makedefs.c index 79cad1637..af6fe1669 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -407,16 +407,9 @@ do_rumors() } /* - * 3.4.1: way back in 3.2.1 `flags.nap' became unconditional but - * TIMED_DELAY was erroneously left in VERSION_FEATURES and has - * been there up through 3.4.0. Simply removing it now would - * break save file compatibility with 3.4.0 files, so we will - * explicitly mask it out during version checks. - * This should go away in the next version update. + * Use this to explicitly mask out features during version checks. */ -#define IGNORED_FEATURES ( 0L \ - | (1L << 23) /* TIMED_DELAY */ \ - ) +#define IGNORED_FEATURES ( 0L ) static void make_version() -- 2.40.0