loose objects at game end

Some post-3.4.3 code to clean up thrown or kicked objects which were
in transit at the end of a game didn't work correctly for kicked objects,
leading to an "obj not free" panic if you kicked an object at some point
and didn't kick anything else before the game was over.  Unlike thrownobj,
kickobj wasn't being cleared after use.
This commit is contained in:
nethack.rankin
2008-09-04 20:47:04 +00:00
parent 1179bb964c
commit 426894d813
2 changed files with 24 additions and 9 deletions
+20 -5
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)dokick.c 3.5 2007/05/16 */ /* SCCS Id: @(#)dokick.c 3.5 2008/09/04 */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -18,6 +18,7 @@ extern boolean notonhead; /* for long worms */
STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P)); STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P));
STATIC_DCL void FDECL(kick_monster, (XCHAR_P, XCHAR_P)); STATIC_DCL void FDECL(kick_monster, (XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(kick_object, (XCHAR_P, XCHAR_P)); STATIC_DCL int FDECL(kick_object, (XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(really_kick_object, (XCHAR_P,XCHAR_P));
STATIC_DCL char *FDECL(kickstr, (char *)); STATIC_DCL char *FDECL(kickstr, (char *));
STATIC_DCL void FDECL(otransit_msg, (struct obj *, BOOLEAN_P, long)); STATIC_DCL void FDECL(otransit_msg, (struct obj *, BOOLEAN_P, long));
STATIC_DCL void FDECL(drop_to, (coord *,SCHAR_P)); STATIC_DCL void FDECL(drop_to, (coord *,SCHAR_P));
@@ -397,9 +398,27 @@ struct obj *obj;
} }
} }
/* jacket around really_kick_object */
STATIC_OVL int STATIC_OVL int
kick_object(x, y) kick_object(x, y)
xchar x, y; xchar x, y;
{
int res = 0;
/* if a pile, the "top" object gets kicked */
kickobj = level.objects[x][y];
if (kickobj) {
/* kick the object; if doing is fatal, done() will clean up kickobj */
res = really_kick_object(x, y);
kickobj = (struct obj *)0;
}
return res;
}
/* guts of kick_object */
STATIC_OVL int
really_kick_object(x, y)
xchar x, y;
{ {
int range; int range;
struct monst *mon, *shkp = 0; struct monst *mon, *shkp = 0;
@@ -407,9 +426,6 @@ xchar x, y;
char bhitroom; char bhitroom;
boolean costly, isgold, slide = FALSE; boolean costly, isgold, slide = FALSE;
/* if a pile, the "top" object gets kicked */
kickobj = level.objects[x][y];
/* kickobj should always be set due to conditions of call */ /* kickobj should always be set due to conditions of call */
if(!kickobj || kickobj->otyp == BOULDER if(!kickobj || kickobj->otyp == BOULDER
|| kickobj == uball || kickobj == uchain) || kickobj == uball || kickobj == uchain)
@@ -810,7 +826,6 @@ dokick()
return 1; return 1;
} }
kickobj = (struct obj *)0;
if (OBJ_AT(x, y) && if (OBJ_AT(x, y) &&
(!Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) (!Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)
|| sobj_at(BOULDER,x,y))) { || sobj_at(BOULDER,x,y))) {
+4 -4
View File
@@ -710,10 +710,10 @@ die:
/* might have been killed while using a disposable item, so make sure /* might have been killed while using a disposable item, so make sure
it's gone prior to inventory disclosure and creation of bones data */ it's gone prior to inventory disclosure and creation of bones data */
inven_inuse(TRUE); inven_inuse(TRUE);
/* not on object lists; if an active light source, would cause big /* maybe not on object lists; if an active light source, would cause
trouble (`obj_is_local' panic) for savebones() -> savelev() */ big trouble (`obj_is_local' panic) for savebones() -> savelev() */
if (thrownobj) dealloc_obj(thrownobj); if (thrownobj && thrownobj->where == OBJ_FREE) dealloc_obj(thrownobj);
if (kickobj) dealloc_obj(kickobj); if (kickobj && kickobj->where == OBJ_FREE) dealloc_obj(kickobj);
/* Sometimes you die on the first move. Life's not fair. /* Sometimes you die on the first move. Life's not fair.
* On those rare occasions you get hosed immediately, go out * On those rare occasions you get hosed immediately, go out