summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeterN <peter1138@openttd.org>2021-05-02 10:21:27 +0100
committerGitHub <noreply@github.com>2021-05-02 10:21:27 +0100
commit256dbee25597f4da8726063084f94eb821babf14 (patch)
tree7d9293d36f49454228043f14943fff2dc529f5fc
parent18fb1c386689f12d2a7e767d9372020c0a8d9fea (diff)
downloadopenttd-256dbee25597f4da8726063084f94eb821babf14.tar.xz
Fix: Crash when extra viewport height is zero with sign in view. (#9175)
If a viewport sign straddles the top of a viewport, a crash will occur if the viewport height is zero. This is resolved by simply not attempting to draw the viewport in this situation, consistent with other widgets.
-rw-r--r--src/widget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 68bc43d78..5c1c0ae8f 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -2029,6 +2029,8 @@ void NWidgetViewport::SetupSmallestSize(Window *w, bool init_array)
void NWidgetViewport::Draw(const Window *w)
{
+ if (this->current_x == 0 || this->current_y == 0) return;
+
if (this->disp_flags & ND_NO_TRANSPARENCY) {
TransparencyOptionBits to_backup = _transparency_opt;
_transparency_opt &= (1 << TO_SIGNS) | (1 << TO_LOADING); // Disable all transparency, except textual stuff