From 7c536cd4f0fedf04e23fff552223e4d770713284 Mon Sep 17 00:00:00 2001 From: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Date: Thu, 6 Mar 2025 16:31:35 +0100 Subject: [PATCH] Fixes runtimes in fit_viewport when user has the game minimized (#89802) ## About The Pull Request Winget returns 0x0 size when the window is minimized, and it can be set to 0x0 via external tools as well. In this case we should just abort fit_viewport to prevent runtimes. ## Changelog Not player facing --- code/modules/client/verbs/ooc.dm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/modules/client/verbs/ooc.dm b/code/modules/client/verbs/ooc.dm index 3fc6b0fa70c..6e3a6e44944 100644 --- a/code/modules/client/verbs/ooc.dm +++ b/code/modules/client/verbs/ooc.dm @@ -360,6 +360,13 @@ ADMIN_VERB(reset_ooc_color, R_FUN, "Reset Player OOC Color", "Returns player OOC var/list/map_size = splittext(sizes["mapwindow.size"], "x") + var/split_size = splittext(sizes["mainwindow.split.size"], "x") + var/split_width = text2num(split_size[1]) + + // Window is minimized, we can't get proper data so return to avoid division by 0 + if (!split_width) + return + // Gets the type of zoom we're currently using from our view datum // If it's 0 we do our pixel calculations based off the size of the mapwindow // If it's not, we already know how big we want our window to be, since zoom is the exact pixel ratio of the map @@ -381,9 +388,6 @@ ADMIN_VERB(reset_ooc_color, R_FUN, "Reset Player OOC Color", "Returns player OOC // Nothing to do return - var/split_size = splittext(sizes["mainwindow.split.size"], "x") - var/split_width = text2num(split_size[1]) - // Avoid auto-resizing the statpanel and chat into nothing. desired_width = min(desired_width, split_width - 300)