diff --git a/src/nhlua.c b/src/nhlua.c index 3ed150392..11cc8d537 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -1652,6 +1652,7 @@ nhl_gamestate(lua_State *L) struct obj *otmp; int argc = lua_gettop(L); boolean reststate = (argc > 0) ? lua_toboolean(L, -1) : FALSE; + int otyp; debugpline4("gamestate: %d:%d (%c vs %c)", u.uz.dnum, u.uz.dlevel, reststate ? 'T' : 'F', gg.gmst_stored ? 't' : 'f'); @@ -1683,6 +1684,12 @@ nhl_gamestate(lua_State *L) assert(gg.gmst_mvitals != NULL); (void) memcpy((genericptr_t) &svm.mvitals, gg.gmst_mvitals, sizeof svm.mvitals); + /* clear user-given object type names */ + for (otyp = 0; otyp < NUM_OBJECTS; otyp++) + if (objects[otyp].oc_uname) { + free(objects[otyp].oc_uname); + objects[otyp].oc_uname = (char *) 0; + } /* some restored state would confuse the level change in progress */ u.uz = cur_uz, u.uz0 = cur_uz0; init_uhunger();