diff --git a/library/include/df/custom/coord.methods.inc b/library/include/df/custom/coord.methods.inc index 6814be3c2..aa6eda484 100644 --- a/library/include/df/custom/coord.methods.inc +++ b/library/include/df/custom/coord.methods.inc @@ -3,7 +3,7 @@ coord(uint16_t _x, uint16_t _y, uint16_t _z) : x(_x), y(_y), z(_z) {} operator coord2d() const { return coord2d(x,y); } -bool isValid() const { return x != -30000; } +bool isValid() const { return x >= 0; } void clear() { x = y = z = -30000; } bool operator==(const coord &other) const diff --git a/library/include/df/custom/coord2d.methods.inc b/library/include/df/custom/coord2d.methods.inc index 202192bb8..512149ce3 100644 --- a/library/include/df/custom/coord2d.methods.inc +++ b/library/include/df/custom/coord2d.methods.inc @@ -1,6 +1,6 @@ coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {} -bool isValid() const { return x != -30000; } +bool isValid() const { return x >= 0; } void clear() { x = y = -30000; } bool operator==(const coord2d &other) const diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index e2cb7069b..b931b2ff4 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -321,7 +321,7 @@ end function pos2xyz(pos) if pos then local x = pos.x - if x and x ~= -30000 then + if x and x >= 0 then return x, pos.y, pos.z end end @@ -346,7 +346,7 @@ end function pos2xy(pos) if pos then local x = pos.x - if x and x ~= -30000 then + if x and x >= 0 then return x, pos.y end end diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 35631dfc6..c661cf254 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -649,7 +649,7 @@ bool Gui::item_details_hotkey(df::viewscreen *top) static bool has_cursor() { - return df::global::cursor && df::global::cursor->x != -30000; + return Gui::getCursorPos().isValid(); } bool Gui::cursor_hotkey(df::viewscreen *top) @@ -1720,7 +1720,7 @@ bool Gui::autoDFAnnouncement(df::report_init r, string message) // Check if the announcement will actually be announced if (*gamemode == game_mode::ADVENTURE) { - if (r.pos.x != -30000 && + if (r.pos.x >= 0 && r.type != announcement_type::CREATURE_SOUND && r.type != announcement_type::REGULAR_CONVERSATION && r.type != announcement_type::CONFLICT_CONVERSATION && @@ -2151,7 +2151,7 @@ bool Gui::getDesignationCoords (int32_t &x, int32_t &y, int32_t &z) x = selection_rect->start_x; y = selection_rect->start_y; z = selection_rect->start_z; - return (x == -30000) ? false : true; + return (x >= 0) ? false : true; } bool Gui::setDesignationCoords (const int32_t x, const int32_t y, const int32_t z) diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp index c21f5c31b..aed6fa0ea 100644 --- a/plugins/autodump.cpp +++ b/plugins/autodump.cpp @@ -281,12 +281,12 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector & parame MapCache MC; int dumped_total = 0; - DFCoord pos_cursor; + df::coord pos_cursor; if(!destroy || here) { - pos_cursor = Gui::getMousePos(); + pos_cursor = Gui::getCursorPos(); if (!pos_cursor.isValid()) { - out.printerr("Mouse cursor must be over a suitable map tile.\n"); + out.printerr("Keyboard cursor must be over a suitable map tile.\n"); return CR_FAILURE; } }