]> granicus.if.org Git - nethack/commit
Make sure xstart and ystart are always zero when not in_mklev
authorcopperwater <aosdict@gmail.com>
Wed, 6 Apr 2022 12:00:34 +0000 (08:00 -0400)
committerPatR <rankin@nethack.org>
Fri, 8 Apr 2022 17:05:43 +0000 (10:05 -0700)
commit99715e005fb45fe036041b7f7721068d421e0d1c
treec9f85bbf372e211246d538e2d90683a15757597e
parent835a4e78f5aa8000686735dc8bc082e97cbc3c6f
Make sure xstart and ystart are always zero when not in_mklev

Running #wizloadlua to run Lua scripts that use coordinates in any way
would work differently if you were on certain levels for the first time
versus leaving and returning to them. This is because various bits of
level creation routines can leave xstart and ystart set to non-zero
values, which are then zeroed at some point when leaving and returning
to the level.

Since xstart and ystart are only relevant to level creation and lua
commands, this fixes the problem by zeroing them after leaving mklev
routines. (Saving them with the level doesn't work because xstart and
ystart are relative to the last used des.map, of which there could be
multiple, e.g. in Asmodeus's level or if two map-based themed rooms
happen to generate. I can envision a more complex solution in which
every des.map used in the level can be associated with an identifier,
whose xstart and ystart are saved for use by later post-level-creation
lua scripts, but currently I just want to make them consistent between
level visits.)
src/mklev.c