diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 2290110a8..111ea94c7 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -998,16 +998,29 @@ bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t bool Gui::getMousePos (int32_t & x, int32_t & y) { - x = gps->mouse_x; - y = gps->mouse_y; + if (gps) { + x = gps->mouse_x; + y = gps->mouse_y; + } + else { + x = -1; + y = -1; + } return (x == -1) ? false : true; } bool Gui::getWindowSize (int32_t &width, int32_t &height) { - width = gps->dimx; - height = gps->dimy; - return true; + if (gps) { + width = gps->dimx; + height = gps->dimy; + return true; + } + else { + width = 80; + height = 25; + return false; + } } bool Gui::getMenuWidth(uint8_t &menu_width, uint8_t &area_map_width) diff --git a/library/modules/Windows.cpp b/library/modules/Windows.cpp index e069d964e..218b6f7e0 100644 --- a/library/modules/Windows.cpp +++ b/library/modules/Windows.cpp @@ -34,10 +34,12 @@ distribution. #include "modules/Windows.h" using namespace DFHack; +using df::global::gps; Windows::df_screentile *Windows::getScreenBuffer() { - return (df_screentile *) df::global::gps->screen; + if (!gps) return NULL; + return (df_screentile *) gps->screen; } Windows::df_window::df_window(int x, int y, unsigned int width, unsigned int height) @@ -79,7 +81,7 @@ bool Windows::df_window::unlock (painter * painter) return false; } -Windows::top_level_window::top_level_window(): df_window(0,0,df::global::gps->dimx,df::global::gps->dimy) +Windows::top_level_window::top_level_window() : df_window(0,0,gps ? gps->dimx : 80,gps ? gps->dimy : 25) { buffer = 0; }