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:
@@ -1675,6 +1675,7 @@ E int FDECL(l_selection_register, (lua_State *));
|
||||
|
||||
/* ### nhlobj.c ### */
|
||||
#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET)
|
||||
E void FDECL(nhl_push_obj, (lua_State *, struct obj *));
|
||||
E int FDECL(l_obj_register, (lua_State *));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ struct obj {
|
||||
unsigned oeaten; /* nutrition left in food, if partly eaten */
|
||||
long age; /* creation date */
|
||||
long owornmask;
|
||||
unsigned lua_ref_cnt; /* # of lua script references for this object */
|
||||
struct oextra *oextra; /* pointer to oextra struct */
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* Incrementing EDITLEVEL can be used to force invalidation of old bones
|
||||
* and save files.
|
||||
*/
|
||||
#define EDITLEVEL 5
|
||||
#define EDITLEVEL 6
|
||||
|
||||
#define COPYRIGHT_BANNER_A "NetHack, Copyright 1985-2019"
|
||||
#define COPYRIGHT_BANNER_B \
|
||||
|
||||
Reference in New Issue
Block a user