From 7de537a1d37af1e1786b49cefa4743bc6c791af4 Mon Sep 17 00:00:00 2001
From: Znote <stefan_brannfjell@live.no>
Date: Mon, 11 Nov 2019 21:50:39 +0100
Subject: [PATCH] Fix #354 - Highscores warning if it tries to display a
 vocation group without any players in it.

---
 highscores.php | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/highscores.php b/highscores.php
index 7e495f4..45da46c 100644
--- a/highscores.php
+++ b/highscores.php
@@ -96,7 +96,7 @@ if ($vocGroups) {
 
 		<select name="page">
 			<?php
-			$pages = ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($vocGroup[$type]) / $highscore['rowsPerPage'])));
+			$pages = ($vocGroup[$type] !== false) ? ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($vocGroup[$type]) / $highscore['rowsPerPage']))) : 1;
 			for ($i = 0; $i < $pages; $i++) {
 				$x = $i + 1;
 				if ($x == $page) echo "<option value='".$x."' selected>Page: ".$x."</option>";
@@ -120,15 +120,14 @@ if ($vocGroups) {
 		</tr>
 
 		<?php
-		for ($i = 0; $i < count($vocGroup[$type]); $i++) {
-
-			if ($vocGroup[$type] === false) {
-				?>
-				<tr>
-					<td colspan="5">Nothing to show here yet.</td>
-				</tr>
-				<?php
-			} else {
+		if ($vocGroup[$type] === false) {
+			?>
+			<tr>
+				<td colspan="5">Nothing to show here yet.</td>
+			</tr>
+			<?php
+		} else {
+			for ($i = 0; $i < count($vocGroup[$type]); $i++) {
 				if (pageCheck($i, $page, $rowsPerPage)) {
 					$flag = ($loadFlags === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $vocGroup[$type][$i]['flag'] . '.png">  ' : '';
 					?>
@@ -145,7 +144,6 @@ if ($vocGroups) {
 					<?php
 				}
 			}
-
 		}
 		?>
 	</table>