Tutorial: backup and restore struct you

This commit is contained in:
Pasi Kallinen
2023-04-09 18:15:31 +03:00
parent 79bdab1f03
commit cb73cbedb7
+3
View File
@@ -1580,6 +1580,7 @@ nhl_gamestate(lua_State *L)
static struct obj *invent = NULL; static struct obj *invent = NULL;
static long moves = 0; static long moves = 0;
static boolean stored = FALSE; static boolean stored = FALSE;
static struct you ubak;
if (reststate && stored) { if (reststate && stored) {
/* restore game state */ /* restore game state */
@@ -1596,6 +1597,7 @@ nhl_gamestate(lua_State *L)
if (wornmask) if (wornmask)
setworn(otmp, wornmask); setworn(otmp, wornmask);
} }
u = ubak;
init_uhunger(); init_uhunger();
stored = FALSE; stored = FALSE;
} else { } else {
@@ -1611,6 +1613,7 @@ nhl_gamestate(lua_State *L)
} }
gl.lastinvnr = 51; gl.lastinvnr = 51;
moves = gm.moves; moves = gm.moves;
ubak = u;
stored = TRUE; stored = TRUE;
} }
update_inventory(); update_inventory();