DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.88k stars 479 forks source link

Saving game and returning to title menu triggers world/map load events #3083

Open myk002 opened 1 year ago

myk002 commented 1 year ago

When I save a game and return to the title screen, I see the following sequence of events:

game state changed: SC_VIEWSCREEN_CHANGED
save or unload is imminent; time to persist state
game state changed: SC_MAP_UNLOADED
Loading script: dfhack-config/init/default.onMapUnload.init
Loading script: hack/init/onMapUnload.default.init
Loading script: dfhack-config/init/onMapUnload.init
game state changed: SC_WORLD_UNLOADED
Loading script: dfhack-config/init/default.onUnload.init
Loading script: hack/init/onUnload.default.init
Loading script: dfhack-config/init/onUnload.init
game state changed: SC_VIEWSCREEN_CHANGED

Which is all expected. However, they are immediately followed by this when the transition to the title screen happens:

world is loading; time to load persisted state
game state changed: SC_WORLD_LOADED
Loading script: dfhack-config/init/default.onLoad.init
Loading script: hack/init/onLoad.default.init
Loading script: dfhack-config/init/onLoad.init
game state changed: SC_MAP_LOADED
Loading script: dfhack-config/init/default.onMapLoad.init
Loading script: hack/init/onMapLoad.default.init
Loading script: dfhack-config/init/onMapLoad.init
Loading script: dfhack-config/init/onMapLoad.control-panel-new-fort.init
Loading script: dfhack-config/init/onMapLoad.control-panel-repeats.init
combine needs a loaded fortress map to work

game state changed: SC_VIEWSCREEN_CHANGED
game state changed: SC_MAP_UNLOADED
Loading script: dfhack-config/init/default.onMapUnload.init
Loading script: hack/init/onMapUnload.default.init
Loading script: dfhack-config/init/onMapUnload.init
game state changed: SC_WORLD_UNLOADED
Loading script: dfhack-config/init/default.onUnload.init
Loading script: hack/init/onUnload.default.init
Loading script: dfhack-config/init/onUnload.init

So it looks like we erroneously detect a world load event happening and follow it up immediately with another world unload.

ab9rf commented 1 year ago

relatedly, i'm seeing dfhack do a world-unloaded/world-loaded cycle in worldgen when a worldgen rejection occurs