diff --git a/library/Core.cpp b/library/Core.cpp index 6cc47292f..01964139c 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -61,6 +61,8 @@ using namespace DFHack; #include "df/world_data.h" #include "df/interfacest.h" #include "df/viewscreen_dwarfmodest.h" +#include "df/viewscreen_loadgamest.h" +#include "df/viewscreen_savegamest.h" #include #include @@ -1268,10 +1270,23 @@ void Core::doUpdate(color_ostream &out, bool first_update) if (first_update) onStateChange(out, SC_CORE_INITIALIZED); + // find the current viewscreen + df::viewscreen *screen = NULL; + if (df::global::gview) + { + screen = &df::global::gview->view; + while (screen->child) + screen = screen->child; + } + + bool is_load_save = + strict_virtual_cast(screen) || + strict_virtual_cast(screen); + // detect if the game was loaded or unloaded in the meantime void *new_wdata = NULL; void *new_mapdata = NULL; - if (df::global::world) + if (df::global::world && !is_load_save) { df::world_data *wdata = df::global::world->world_data; // when the game is unloaded, world_data isn't deleted, but its contents are @@ -1313,16 +1328,10 @@ void Core::doUpdate(color_ostream &out, bool first_update) } // detect if the viewscreen changed - if (df::global::gview) + if (screen != top_viewscreen) { - df::viewscreen *screen = &df::global::gview->view; - while (screen->child) - screen = screen->child; - if (screen != top_viewscreen) - { - top_viewscreen = screen; - onStateChange(out, SC_VIEWSCREEN_CHANGED); - } + top_viewscreen = screen; + onStateChange(out, SC_VIEWSCREEN_CHANGED); } if (df::global::pause_state) diff --git a/library/xml b/library/xml index ac936b06b..cb4c883d4 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit ac936b06bd0a69c84c4e0a94a4f22b3b1402b23b +Subproject commit cb4c883d4f4f46fc9b4856d7e91f55e1b39b56c5