fix #H7156 - perm_invent

Bug report #H7156 listed three items, all relating to perm_invent:
1) it shouldn't persist across save/restore since restore might be
   on a system which doesn't have enough room to display it (report
   actually complained that config file setting was ignored when
   restoring old games, which is an expected side-effect for options
   that persist across save/restore);
2) permanent inventory wasn't updated when using scroll of charging;
3) attempts to update permanent inventory during restore could lead
   to crash if it tries to access shop cost for unpaid items.
Items (2) and (3) have already been fixed.  This fixes (1).

Replace 'flags.perm_invent' with a dummy flag, preserving save files
while removing it from flags.  Add 'iflags.perm_invent' to hold the
value of the perm_invent option.

The win32 files that are updated here haven't been tested.  Whichever
branch contains the curses interface needs to be updated; ditto for
any other pending/potential interfaces which support perm_invent.
This commit is contained in:
PatR
2018-09-14 17:34:33 -07:00
parent 2c231f57bd
commit 3eded06669
12 changed files with 27 additions and 21 deletions

View File

@@ -2511,7 +2511,7 @@ long *out_cnt;
if (lets && !*lets)
lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */
if (flags.perm_invent && (lets || xtra_choice)) {
if (iflags.perm_invent && (lets || xtra_choice)) {
/* partial inventory in perm_invent setting; don't operate on
full inventory window, use an alternate one instead; create
the first time needed and keep it for re-use as needed later */
@@ -2536,7 +2536,7 @@ long *out_cnt;
* more than 1; for the last one, we don't need a precise number.
* For perm_invent update we force 'more than 1'.
*/
n = (flags.perm_invent && !lets && !want_reply) ? 2
n = (iflags.perm_invent && !lets && !want_reply) ? 2
: lets ? (int) strlen(lets)
: !invent ? 0 : !invent->nobj ? 1 : 2;
/* for xtra_choice, there's another 'item' not included in initial 'n';
@@ -2670,7 +2670,7 @@ nextclass:
nothing has been listed (because there isn't anyhing to list;
recognized via any.a_char still being zero; the n==0 case above
gets skipped for perm_invent), put something into the menu */
if (flags.perm_invent && !lets && !any.a_char) {
if (iflags.perm_invent && !lets && !any.a_char) {
any = zeroany;
add_menu(win, NO_GLYPH, &any, 0, 0, 0,
not_carrying_anything, MENU_UNSELECTED);