Add lua object references
Whenever a lua script references a core struct obj, increment a counter in the obj struct. Core code will not free the obj, if there are any lua references pointing to it, just makes it free-floating. When lua script ends, the lua gc will free the free-floating objects. Also exposes u.inventory to lua. Breaks save and bones compat.
This commit is contained in:
@@ -201,6 +201,7 @@ struct obj *otmp;
|
||||
if (nhfp->structlevel)
|
||||
mread(nhfp->fd, (genericptr_t) otmp, sizeof(struct obj));
|
||||
|
||||
otmp->lua_ref_cnt = 0;
|
||||
/* next object pointers are invalid; otmp->cobj needs to be left
|
||||
as is--being non-null is key to restoring container contents */
|
||||
otmp->nobj = otmp->nexthere = (struct obj *) 0;
|
||||
|
||||
Reference in New Issue
Block a user