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).
This commit is contained in:
PatR
2022-09-03 10:45:24 -07:00
parent f5a9901db1
commit 82aaa289ef
3 changed files with 14 additions and 10 deletions
+4 -2
View File
@@ -886,13 +886,15 @@ discard_migrations(void)
*oprev = otmp->nobj; /* remove otmp from migrating_objs */ *oprev = otmp->nobj; /* remove otmp from migrating_objs */
otmp->nobj = 0; otmp->nobj = 0;
otmp->where = OBJ_FREE; 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 */ obfree(otmp, (struct obj *) 0); /* releases any contents too */
} }
} }
} }
/* return quality of food; the lower the better */ /* returns the quality of an item of food; the lower the better;
/* fungi will eat even tainted food */ fungi and ghouls will eat even tainted food */
int int
dogfood(struct monst *mon, struct obj *obj) dogfood(struct monst *mon, struct obj *obj)
{ {
+4 -3
View File
@@ -1433,9 +1433,10 @@ drop_to(coord *cc, schar loc, coordxy x, coordxy y)
/* player or missile impacts location, causing objects to fall down */ /* player or missile impacts location, causing objects to fall down */
void void
impact_drop(struct obj *missile, /* caused impact, won't drop itself */ impact_drop(
coordxy x, coordxy y, /* location affected */ struct obj *missile, /* caused impact, won't drop itself */
xint16 dlev) /* if !0 send to dlev near player */ coordxy x, coordxy y, /* location affected */
xint16 dlev) /* if !0 send to dlev near player */
{ {
schar toloc; schar toloc;
register struct obj *obj, *obj2; register struct obj *obj, *obj2;
+6 -5
View File
@@ -18,7 +18,7 @@ static boolean put_lregion_here(coordxy, coordxy, coordxy, coordxy, coordxy,
static void baalz_fixup(void); static void baalz_fixup(void);
static void setup_waterlevel(void); static void setup_waterlevel(void);
static void unsetup_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 migr_booty_item(int, const char *);
static void migrate_orc(struct monst *, unsigned long); static void migrate_orc(struct monst *, unsigned long);
static void shiny_orc_stuff(struct monst *); 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 */ /* set the locations TRUE if rock or wall or out of bounds */
loc_f = within_bounded_area(x, y, /* for baalz insect */ loc_f = within_bounded_area(x, y, /* for baalz insect */
g.bughack.inarea.x1, g.bughack.inarea.y1, g.bughack.inarea.x1, g.bughack.inarea.y1,
g.bughack.inarea.x2, g.bughack.inarea.y2) g.bughack.inarea.x2, g.bughack.inarea.y2)
? iswall ? iswall
: iswall_or_stone; : iswall_or_stone;
locale[0][0] = (*loc_f)(x - 1, y - 1); locale[0][0] = (*loc_f)(x - 1, y - 1);
@@ -631,7 +631,7 @@ fixup_special(void)
} }
static void static void
check_ransacked(char * s) check_ransacked(const char *s)
{ {
/* this kludge only works as long as orctown is minetn-1 */ /* this kludge only works as long as orctown is minetn-1 */
g.ransacked = (u.uz.dnum == mines_dnum && !strcmp(s, "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 const char *const orcfruit[] = { "paddle cactus", "dwarven root" };
static void static void
migrate_orc(struct monst* mtmp, unsigned long mflags) migrate_orc(struct monst *mtmp, unsigned long mflags)
{ {
int nlev, max_depth, cur_depth; int nlev, max_depth, cur_depth;
d_level dest; d_level dest;
@@ -702,6 +702,7 @@ shiny_orc_stuff(struct monst* mtmp)
add_to_minv(mtmp, otmp); add_to_minv(mtmp, otmp);
} }
} }
static void static void
migr_booty_item(int otyp, const char* gang) migr_booty_item(int otyp, const char* gang)
{ {