distinguish global variables that get written to savefile
The g? structs had a mix of variables that were written to
the savefile, and those that were not.
For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.
This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.
Details:
gb.bases -> svb.bases
gb.bbubbles -> svb.bbubbles
gb.branches -> svb.branches
gc.context -> svc.context
gd.disco -> svd.disco
gd.dndest -> svd.dndest
gd.doors -> svd.doors
gd.doors_alloc -> svd.doors_alloc
gd.dungeon_topology -> svd.dungeon_topology
gd.dungeons -> svd.dungeons
ge.exclusion_zones -> sve.exclusion_zones
gh.hackpid -> svh.hackpid
gi.inv_pos -> svi.inv_pos
gk.killer -> svk.killer
gl.lastseentyp -> svl.lastseentyp
gl.level -> svl.level
gl.level_info -> svl.level_info
gm.mapseenchn -> svm.mapseenchn
gm.moves -> svm.moves
gm.mvitals -> svm.mvitals
gn.n_dgns -> svn.n_dgns
gn.n_regions -> svn.n_regions
gn.nroom -> svn.nroom
go.oracle_cnt -> svo.oracle_cnt
gp.pl_character -> svp.pl_character
gp.pl_fruit -> svp.pl_fruit
gp.plname -> svp.plname
gp.program_state -> svp.program_state
gq.quest_status -> svq.quest_status
gr.rooms -> svr.rooms
gs.sp_levchn -> svs.sp_levchn
gs.spl_book -> svs.spl_book
gt.timer_id -> svt.timer_id
gt.tune -> svt.tune
gu.updest -> svu.updest
gx.xmax -> svx.xmax
gx.xmin -> svx.xmin
gy.ymax -> svy.ymax
gy.ymin -> svy.ymin
Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
gf.ftrap, gl.light_base, gt.timer_base
This commit is contained in:
32
src/nhlua.c
32
src/nhlua.c
@@ -1091,8 +1091,8 @@ nhl_dnum_name(lua_State *L)
|
||||
if (argc == 1) {
|
||||
lua_Integer dnum = luaL_checkinteger(L, 1);
|
||||
|
||||
if (dnum >= 0 && dnum < gn.n_dgns)
|
||||
lua_pushstring(L, gd.dungeons[dnum].dname);
|
||||
if (dnum >= 0 && dnum < svn.n_dgns)
|
||||
lua_pushstring(L, svd.dungeons[dnum].dname);
|
||||
else
|
||||
lua_pushstring(L, "");
|
||||
} else
|
||||
@@ -1584,8 +1584,8 @@ nhl_gamestate(lua_State *L)
|
||||
d_level cur_uz = u.uz, cur_uz0 = u.uz0;
|
||||
|
||||
/* restore game state */
|
||||
gm.moves = gg.gmst_moves;
|
||||
pline("Resetting time to move #%ld.", gm.moves);
|
||||
svm.moves = gg.gmst_moves;
|
||||
pline("Resetting time to move #%ld.", svm.moves);
|
||||
gg.gmst_moves = 0L;
|
||||
|
||||
gl.lastinvnr = 51;
|
||||
@@ -1602,11 +1602,11 @@ nhl_gamestate(lua_State *L)
|
||||
assert(gg.gmst_ubak != NULL);
|
||||
(void) memcpy((genericptr_t) &u, gg.gmst_ubak, sizeof u);
|
||||
assert(gg.gmst_disco != NULL);
|
||||
(void) memcpy((genericptr_t) &gd.disco, gg.gmst_disco,
|
||||
sizeof gd.disco);
|
||||
(void) memcpy((genericptr_t) &svd.disco, gg.gmst_disco,
|
||||
sizeof svd.disco);
|
||||
assert(gg.gmst_mvitals != NULL);
|
||||
(void) memcpy((genericptr_t) &gm.mvitals, gg.gmst_mvitals,
|
||||
sizeof gm.mvitals);
|
||||
(void) memcpy((genericptr_t) &svm.mvitals, gg.gmst_mvitals,
|
||||
sizeof svm.mvitals);
|
||||
/* some restored state would confuse the level change in progress */
|
||||
u.uz = cur_uz, u.uz0 = cur_uz0;
|
||||
init_uhunger();
|
||||
@@ -1614,7 +1614,7 @@ nhl_gamestate(lua_State *L)
|
||||
gg.gmst_stored = FALSE;
|
||||
} else if (!reststate && !gg.gmst_stored) {
|
||||
/* store game state */
|
||||
gg.gmst_moves = gm.moves;
|
||||
gg.gmst_moves = svm.moves;
|
||||
while ((otmp = gi.invent) != NULL) {
|
||||
wornmask = otmp->owornmask;
|
||||
setnotworn(otmp);
|
||||
@@ -1626,12 +1626,12 @@ nhl_gamestate(lua_State *L)
|
||||
gl.lastinvnr = 51; /* next inv letter to try to use will be 'a' */
|
||||
gg.gmst_ubak = (genericptr_t) alloc(sizeof u);
|
||||
(void) memcpy(gg.gmst_ubak, (genericptr_t) &u, sizeof u);
|
||||
gg.gmst_disco = (genericptr_t) alloc(sizeof gd.disco);
|
||||
(void) memcpy(gg.gmst_disco, (genericptr_t) &gd.disco,
|
||||
sizeof gd.disco);
|
||||
gg.gmst_mvitals = (genericptr_t) alloc(sizeof gm.mvitals);
|
||||
(void) memcpy(gg.gmst_mvitals, (genericptr_t) &gm.mvitals,
|
||||
sizeof gm.mvitals);
|
||||
gg.gmst_disco = (genericptr_t) alloc(sizeof svd.disco);
|
||||
(void) memcpy(gg.gmst_disco, (genericptr_t) &svd.disco,
|
||||
sizeof svd.disco);
|
||||
gg.gmst_mvitals = (genericptr_t) alloc(sizeof svm.mvitals);
|
||||
(void) memcpy(gg.gmst_mvitals, (genericptr_t) &svm.mvitals,
|
||||
sizeof svm.mvitals);
|
||||
gg.gmst_stored = TRUE;
|
||||
} else {
|
||||
impossible("nhl_gamestate: inconsistent state (%s vs %s)",
|
||||
@@ -1840,7 +1840,7 @@ nhl_meta_u_index(lua_State *L)
|
||||
lua_pushstring(L, gu.urole.name.m);
|
||||
return 1;
|
||||
} else if (!strcmp(tkey, "moves")) {
|
||||
lua_pushinteger(L, gm.moves);
|
||||
lua_pushinteger(L, svm.moves);
|
||||
return 1;
|
||||
} else if (!strcmp(tkey, "uhave_amulet")) {
|
||||
lua_pushinteger(L, u.uhave.amulet);
|
||||
|
||||
Reference in New Issue
Block a user