bubble/cloud save/restore overhaul
The air bubbles on the Plane of Water and the clouds on the Plane of Air were being saved and restored as part of the current level's state (which is the 'u' struct and invent and such) rather than with the current level itself. That was ok for normal play, but for wizard mode's ^V allowing you to return to a previously visited endgame level after moving to a different one it meant a new set of bubbles for Water and new set of clouds for Air. Even that was ok since it only applied to wizard mode, but using #wizmakemap to recreate Water or Air while you were on it added a new set of bubbles or clouds to the existing ones. If repeated, eventually there wouldn't be much water or air left. Instead of just adding a hack to #wizmakemap, change save/restore to keep the bubbles/clouds with the level rather than with the state. That wasn't trivial and now I know why the old odd arrangement was chosen. Saving hides u.uz by zeroing it out for levels that the hero isn't on and it is zero during restore so simple checks for whether a given level is water or air won't work. This also adds another non-file/non-debugpline() use of DEBUGFILES: DEBUGFILES=seethru nethack -D will make water and clouds be transparent instead of opaque. It also makes fumaroles and other light-blocking gas clouds be transparent which wasn't really intended, but avoiding it would be extra work that doesn't accomplish much. Increments EDITLEVEL for the third time this week....
This commit is contained in:
26
src/do.c
26
src/do.c
@@ -1444,22 +1444,6 @@ goto_level(
|
||||
nhfp->mode = cant_go_back ? FREEING : (WRITING | FREEING);
|
||||
savelev(nhfp, ledger_no(&u.uz));
|
||||
nhfp->mode = save_mode;
|
||||
/* air bubbles and clouds are saved in game-state rather than with the
|
||||
level they're used on; in normal play, you can't leave and return
|
||||
to any endgame level--bubbles aren't needed once you move to the
|
||||
next level so used to be discarded when the next special level was
|
||||
loaded; but in wizard mode you can leave and return, and since they
|
||||
aren't saved with the level and restored upon return (new ones are
|
||||
created instead), we need to discard them to avoid a memory leak;
|
||||
so bubbles are now discarded as we leave the level they're used on */
|
||||
if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) {
|
||||
NHFILE tmpnhfp;
|
||||
|
||||
zero_nhfile(&tmpnhfp);
|
||||
tmpnhfp.fd = -1;
|
||||
tmpnhfp.mode = FREEING;
|
||||
save_waterlevel(&tmpnhfp);
|
||||
}
|
||||
close_nhfile(nhfp);
|
||||
if (cant_go_back) {
|
||||
/* discard unreachable levels; keep #0 */
|
||||
@@ -1517,16 +1501,6 @@ goto_level(
|
||||
reseed_random(rn2_on_display_rng);
|
||||
minit(); /* ZEROCOMP */
|
||||
getlev(nhfp, g.hackpid, new_ledger);
|
||||
/* when in wizard mode, it is possible to leave from and return to
|
||||
any level in the endgame; above, we discarded bubble/cloud info
|
||||
when leaving Plane of Water or Air so recreate some now */
|
||||
if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) {
|
||||
NHFILE tmpnhfp;
|
||||
|
||||
zero_nhfile(&tmpnhfp);
|
||||
tmpnhfp.fd = -1;
|
||||
restore_waterlevel(&tmpnhfp);
|
||||
}
|
||||
close_nhfile(nhfp);
|
||||
oinit(); /* reassign level dependent obj probabilities */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user