fix issue #509 - shop 'glob' pricing segfault

A recent change made it possible for a glob to have its dknown flag
cleared and that exposed globby_bill_fixup() passing Null shopkeeper
to get_cost(), triggering a crash.

Make the routine that clears dknown/known/bknown/&c also be the
routine used to initialize those flags for a new object so that it
is the place that handles various special cases.  That hides the
shop bug again.

But also fix the shop bug even though it won't be triggered.

Fixes #509
This commit is contained in:
PatR
2021-05-12 16:13:40 -07:00
parent 25b1baed84
commit b630d5e038
5 changed files with 37 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 extern.h $NHDT-Date: 1620348705 2021/05/07 00:51:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.969 $ */
/* NetHack 3.7 extern.h $NHDT-Date: 1620861202 2021/05/12 23:13:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.970 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1014,7 +1014,6 @@ extern int ggetobj(const char *, int(*)(struct obj *), int, boolean,
unsigned *);
extern int askchain(struct obj **, const char *, int, int(*)(struct obj *),
int(*)(struct obj *), int, const char *);
extern void unknow_object(struct obj *);
extern void set_cknown_lknown(struct obj *);
extern void fully_identify_obj(struct obj *);
extern int identify(struct obj *);
@@ -1308,6 +1307,7 @@ extern void replace_object(struct obj *, struct obj *);
extern struct obj *unknwn_contnr_contents(struct obj *);
extern void bill_dummy_object(struct obj *);
extern void costly_alteration(struct obj *, int);
extern void unknow_object(struct obj *);
extern struct obj *mksobj(int, boolean, boolean);
extern int bcsign(struct obj *);
extern int weight(struct obj *);