Rework object deletion
Make object deletion work similarly to monster deletion: it's marked for deletion (by setting the where-field to OBJ_DELETED and moved to specific deleted-objects chain), but they're actually freed at the beginning of turn. This may need some more tweaking, especially in places that iterate over object chains, but fuzzing did not find any obvious problems. Fix a case of accessing freed memory: a monster breathed at hero, destroying some items. The code stored the next item in the chain (a cloak), but a ring of levitation was destroyed, causing hero to plop down into lava, destroying the cloak. The item destruction code then tried to access the destroyed cloak object. Make the code check the object where-field - which will be different if the object was marked for deletion. Also removed an extra loop going through the whole object chain looking for the items to destroy.
This commit is contained in:
@@ -81,7 +81,8 @@ struct obj {
|
||||
#define OBJ_BURIED 6 /* object buried */
|
||||
#define OBJ_ONBILL 7 /* object on shk bill */
|
||||
#define OBJ_LUAFREE 8 /* object has been dealloc'd, but is ref'd by lua */
|
||||
#define NOBJ_STATES 9
|
||||
#define OBJ_DELETED 9 /* object is marked for deletion by dobjsfree() */
|
||||
#define NOBJ_STATES 10
|
||||
xint16 timed; /* # of fuses (timers) attached to this obj */
|
||||
|
||||
Bitfield(cursed, 1); /* uncursed when neither cursed nor blessed */
|
||||
|
||||
Reference in New Issue
Block a user