diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index b27a09fe3e..d93b3467a9 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -110,24 +110,21 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i Swap(x, y); } - /* Limit our sizes to 4 bits */ - platforms = min(15, platforms); - length = min(15, length); - x = min(15, x); - y = min(15, y); if (centred) { x -= platforms / 2; y -= length / 2; + x = Clamp(x, -8, 7); + y = Clamp(x, -8, 7); SB(retval, 0, 4, y & 0xF); SB(retval, 4, 4, x & 0xF); } else { - SB(retval, 0, 4, y); - SB(retval, 4, 4, length - y - 1); - SB(retval, 8, 4, x); - SB(retval, 12, 4, platforms - x - 1); + SB(retval, 0, 4, min(15, y)); + SB(retval, 4, 4, min(15, length - y - 1)); + SB(retval, 8, 4, min(15, x)); + SB(retval, 12, 4, min(15, platforms - x - 1)); } - SB(retval, 16, 4, length); - SB(retval, 20, 4, platforms); + SB(retval, 16, 4, min(15, length)); + SB(retval, 20, 4, min(15, platforms)); SB(retval, 24, 4, tile); return retval; diff --git a/src/settings.cpp b/src/settings.cpp index 68e52fec6c..dc7ae6e5bf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1071,13 +1071,15 @@ static bool CheckFreeformEdges(int32 p1) if (p1 != 0) { Ship *s; FOR_ALL_SHIPS(s) { + /* Check if there is a ship on the northern border. */ if (TileX(s->tile) == 0 || TileY(s->tile) == 0) { ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR); return false; } } - Station *st; - FOR_ALL_STATIONS(st) { + BaseStation *st; + FOR_ALL_BASE_STATIONS(st) { + /* Check if there is a buoy on the northern border. */ if (TileX(st->xy) == 0 || TileY(st->xy) == 0) { ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR); return false; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index c2a8909a63..76b89e2cc4 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -73,6 +73,7 @@ private: Town *town; ///< Town being displayed. int sel_index; ///< Currently selected town action, \c 0 to \c TACT_COUNT-1, \c -1 means no action selected. Scrollbar *vscroll; + uint displayed_actions_on_previous_painting; ///< Actions that were available on the previous call to OnPaint() /** * Get the position of the Nth set bit. @@ -96,7 +97,7 @@ private: } public: - TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) : Window(), sel_index(-1) + TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) : Window(), sel_index(-1), displayed_actions_on_previous_painting(0) { this->town = Town::Get(window_number); this->InitNested(desc, window_number); @@ -108,6 +109,8 @@ public: { int numact; uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town); + if (buttons != displayed_actions_on_previous_painting) this->SetDirty(); + displayed_actions_on_previous_painting = buttons; this->vscroll->SetCount(numact + 1); diff --git a/src/window.cpp b/src/window.cpp index fdf8811170..b45e844435 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1392,6 +1392,7 @@ static void DecreaseWindowCounters() NWidgetScrollbar *sb = static_cast(nwid); if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) { sb->disp_flags &= ~(ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN); + w->scrolling_scrollbar = -1; sb->SetDirty(w); } }