From 82aaa289efda8fb7ae3f48a61f432324f9daa192 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 3 Sep 2022 10:45:24 -0700 Subject: [PATCH] discarding migrating objects when entering endgame Avoid potential impossible "obfree: deleting worn object" warnings when entering the endgame. The code to get rid of items migrating to non-endgame levels passes those items to obfree(). It needs to clear obj->owornmask first because that's used for migration flags (undelivered orctown loot has a non-zero value). --- src/dog.c | 6 ++++-- src/dokick.c | 7 ++++--- src/mkmaze.c | 11 ++++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/dog.c b/src/dog.c index 3260ef15c..12b39409f 100644 --- a/src/dog.c +++ b/src/dog.c @@ -886,13 +886,15 @@ discard_migrations(void) *oprev = otmp->nobj; /* remove otmp from migrating_objs */ otmp->nobj = 0; otmp->where = OBJ_FREE; + otmp->owornmask = 0L; /* overloaded for destination usage; + * obfree() will complain if nonzero */ obfree(otmp, (struct obj *) 0); /* releases any contents too */ } } } -/* return quality of food; the lower the better */ -/* fungi will eat even tainted food */ +/* returns the quality of an item of food; the lower the better; + fungi and ghouls will eat even tainted food */ int dogfood(struct monst *mon, struct obj *obj) { diff --git a/src/dokick.c b/src/dokick.c index 4f1b8797a..05abe7df7 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1433,9 +1433,10 @@ drop_to(coord *cc, schar loc, coordxy x, coordxy y) /* player or missile impacts location, causing objects to fall down */ void -impact_drop(struct obj *missile, /* caused impact, won't drop itself */ - coordxy x, coordxy y, /* location affected */ - xint16 dlev) /* if !0 send to dlev near player */ +impact_drop( + struct obj *missile, /* caused impact, won't drop itself */ + coordxy x, coordxy y, /* location affected */ + xint16 dlev) /* if !0 send to dlev near player */ { schar toloc; register struct obj *obj, *obj2; diff --git a/src/mkmaze.c b/src/mkmaze.c index 8c8ca9f50..e283ea24d 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -18,7 +18,7 @@ static boolean put_lregion_here(coordxy, coordxy, coordxy, coordxy, coordxy, static void baalz_fixup(void); static void setup_waterlevel(void); static void unsetup_waterlevel(void); -static void check_ransacked(char *); +static void check_ransacked(const char *); static void migr_booty_item(int, const char *); static void migrate_orc(struct monst *, unsigned long); static void shiny_orc_stuff(struct monst *); @@ -228,8 +228,8 @@ fix_wall_spines(coordxy x1, coordxy y1, coordxy x2, coordxy y2) /* set the locations TRUE if rock or wall or out of bounds */ loc_f = within_bounded_area(x, y, /* for baalz insect */ - g.bughack.inarea.x1, g.bughack.inarea.y1, - g.bughack.inarea.x2, g.bughack.inarea.y2) + g.bughack.inarea.x1, g.bughack.inarea.y1, + g.bughack.inarea.x2, g.bughack.inarea.y2) ? iswall : iswall_or_stone; locale[0][0] = (*loc_f)(x - 1, y - 1); @@ -631,7 +631,7 @@ fixup_special(void) } static void -check_ransacked(char * s) +check_ransacked(const char *s) { /* this kludge only works as long as orctown is minetn-1 */ g.ransacked = (u.uz.dnum == mines_dnum && !strcmp(s, "minetn-1")); @@ -641,7 +641,7 @@ check_ransacked(char * s) static const char *const orcfruit[] = { "paddle cactus", "dwarven root" }; static void -migrate_orc(struct monst* mtmp, unsigned long mflags) +migrate_orc(struct monst *mtmp, unsigned long mflags) { int nlev, max_depth, cur_depth; d_level dest; @@ -702,6 +702,7 @@ shiny_orc_stuff(struct monst* mtmp) add_to_minv(mtmp, otmp); } } + static void migr_booty_item(int otyp, const char* gang) {