@@ -2831,33 +2831,31 @@ bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center, boo
28312831
28322832 unfollow ();
28332833
2834+ if (!Maps::isValidTilePos (x, y, z))
2835+ return false ;
2836+
28342837 auto dims = getDwarfmodeViewDims ();
28352838 int32_t w = dims.map_x2 - dims.map_x1 + 1 ;
28362839 int32_t h = dims.map_y2 - dims.map_y1 + 1 ;
28372840 int32_t new_win_x, new_win_y, new_win_z;
28382841 getViewCoords (new_win_x, new_win_y, new_win_z);
28392842
2840- if (Maps::isValidTilePos (x, y, z))
2841- {
2842- if (center)
2843- {
2844- new_win_x = x - w / 2 ;
2845- new_win_y = y - h / 2 ;
2846- }
2847- else // just bring it on screen
2848- {
2849- if (new_win_x > (x - 5 )) // equivalent to: "while (new_win_x > x - 5) new_win_x -= 10;"
2850- new_win_x -= (new_win_x - (x - 5 ) - 1 ) / 10 * 10 + 10 ;
2851- if (new_win_y > (y - 5 ))
2852- new_win_y -= (new_win_y - (y - 5 ) - 1 ) / 10 * 10 + 10 ;
2853- if (new_win_x < (x + 5 - w))
2854- new_win_x += ((x + 5 - w) - new_win_x - 1 ) / 10 * 10 + 10 ;
2855- if (new_win_y < (y + 5 - h))
2856- new_win_y += ((y + 5 - h) - new_win_y - 1 ) / 10 * 10 + 10 ;
2857- }
2858-
2859- new_win_z = z;
2860- }
2843+ if (center) {
2844+ new_win_x = x - w / 2 ;
2845+ new_win_y = y - h / 2 ;
2846+ } else {
2847+ // just bring it on screen
2848+ if (new_win_x > (x - 5 )) // equivalent to: "while (new_win_x > x - 5) new_win_x -= 10;"
2849+ new_win_x -= (new_win_x - (x - 5 ) - 1 ) / 10 * 10 + 10 ;
2850+ if (new_win_y > (y - 5 ))
2851+ new_win_y -= (new_win_y - (y - 5 ) - 1 ) / 10 * 10 + 10 ;
2852+ if (new_win_x < (x + 5 - w))
2853+ new_win_x += ((x + 5 - w) - new_win_x - 1 ) / 10 * 10 + 10 ;
2854+ if (new_win_y < (y + 5 - h))
2855+ new_win_y += ((y + 5 - h) - new_win_y - 1 ) / 10 * 10 + 10 ;
2856+ }
2857+
2858+ new_win_z = z;
28612859
28622860 *window_x = new_win_x;
28632861 *window_y = new_win_y;
0 commit comments