Tutorial: clear user-given obj type names

This commit is contained in:
Pasi Kallinen
2025-07-07 13:08:07 +03:00
parent 0da45c1e74
commit 079dca27f2

View File

@@ -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();