revisit shop_keeper() readiness

During a restore from a savefiles is not the only
time that levels are processed by getlev() in NetHack.
They are read back in as the hero moves up and down
between levels and dungeons.

The previous fix checked for program_state.beyond_savefile_load,
but once set, that remains static through level changes.

It would be better to check the status of the level
being read, because those operations do placements as well.

Add the following:
    struct levelstatus level_status;
    level_status.making   - in the midst of makelevel processing
    level_status.loading  - in the midst of loading a level via getlev()
    level_status.ready    - the level is fully ready

    (all 3 of the above status settings are mutually exclusive)

    level_status.shkready - the level processing is far enough
                            along to allow shop keeper tests and actions

This also relocates the find_lev_obj() call in getlev() down several
lines, so that it falls after any set_residency() calls, so that it
has a better chance of carrying out what it was intending to do with
the shop_keeper() checks made by its subfunctions.
This commit is contained in:
nhmall
2026-05-31 13:26:34 -04:00
parent f72554a238
commit 055caaffbf
9 changed files with 58 additions and 10 deletions
+4
View File
@@ -46,6 +46,10 @@ replace the hashtable used for parsing glyphnames with sorted indices and
of pr #1548 by ingpaschke)
for SELECTSAVE, allow utd flags for uptodate() to be passed down through
the small set of callers that eventually call uptodate()
avoid calling costly_spot(), costly_adjacent(), find_byowner(), which
all rely on shop_keeper() under the hood, in the midst of the level
loading process before all the required data structures have
been finalized
Platform- and/or Interface-Specific Fixes