From 1ed40dcd011e38d29b3d773d8d9205c559cd4af6 Mon Sep 17 00:00:00 2001
From: terencehill <piuntn@gmail.com>
Date: Sun, 11 Jul 2021 21:00:48 +0200
Subject: [PATCH] Fix #2611 "Continuous div by 0 error spam while scoreboard is
 displayed"

---
 qcsrc/client/hud/panel/scoreboard.qc | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc
index 4a815424d..3ab5b6c03 100644
--- a/qcsrc/client/hud/panel/scoreboard.qc
+++ b/qcsrc/client/hud/panel/scoreboard.qc
@@ -2154,12 +2154,15 @@ void Scoreboard_Draw()
 			scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - scoreboard_top));
 	}
 
-	if (scoreboard_fade_alpha == 1)
+	if (rankings_cnt)
 	{
-		if (scoreboard_bottom > 0.95 * vid_conheight)
-			rankings_rows = max(1, rankings_rows - 1);
-		else if (scoreboard_bottom + 1.25 * hud_fontsize.y < 0.95 * vid_conheight)
-			rankings_rows = min(ceil(RANKINGS_RECEIVED_CNT / rankings_columns), rankings_rows + 1);
+		if (scoreboard_fade_alpha == 1)
+		{
+			if (scoreboard_bottom > 0.95 * vid_conheight)
+				rankings_rows = max(1, rankings_rows - 1);
+			else if (scoreboard_bottom + 1.25 * hud_fontsize.y < 0.95 * vid_conheight)
+				rankings_rows = min(ceil(RANKINGS_RECEIVED_CNT / rankings_columns), rankings_rows + 1);
+		}
+		rankings_cnt = rankings_rows * rankings_columns;
 	}
-	rankings_cnt = rankings_rows * rankings_columns;
 }
-- 
2.39.5