From 5291c3ddc33295ef8a5ba83c972b30c7acecdd4f Mon Sep 17 00:00:00 2001 From: tyger07 <6035184+tyger07@users.noreply.github.com> Date: Mon, 12 Apr 2021 02:47:19 -0700 Subject: [PATCH] Update maps-played.php --- common/maps/maps-played.php | 43 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/common/maps/maps-played.php b/common/maps/maps-played.php index 86e22cc..09cda91 100644 --- a/common/maps/maps-played.php +++ b/common/maps/maps-played.php @@ -29,7 +29,7 @@ AND `Gamemode` != '' GROUP BY `MapName` ORDER BY number DESC - LIMIT 20 + LIMIT 25 "; $result = @mysqli_query($BF4stats, $query); } @@ -53,7 +53,7 @@ AND `Gamemode` != '' GROUP BY `MapName` ORDER BY number DESC - LIMIT 20 + LIMIT 25 "; $result = @mysqli_query($BF4stats, $query); } @@ -89,10 +89,16 @@ $total_rounds = $row['total']; $fraction = round(($number / $total_rounds * 100), 0); $degrees = 360 * ($number / $total_rounds); + // avoid zero degree bug if($degrees < 1) { $degrees = 1; } + // prevent zero degree bug hacky fix from causing a greater than 360 bug + if(($previous_end + $degrees) > 360) + { + $previous_end = 360 - $degrees; + } $wedge_color = imagecolorallocate($base, 0, abs(-220 + ($loop_count * $color_steps + 20)), abs(-220 + ($loop_count * $color_steps + 20))); // convert map to friendly name // first find if this map name is even in the map array @@ -109,48 +115,45 @@ imagestring($base, 1, 467, $legend_y_position, $MapName, $faded); if($num_rows > 1) { - if(strlen((string)$fraction) < 2) + if(strlen((string)$fraction) == 1) { imagestring($base, 1, 439, $legend_y_position, " " . $fraction . "%", $faded); } - else + elseif(strlen((string)$fraction) == 2) { imagestring($base, 1, 439, $legend_y_position, $fraction . "%", $faded); } + else + { + imagestring($base, 1, 434, $legend_y_position, $fraction . "%", $faded); + } } else { - imagestring($base, 1, 433, $legend_y_position, $fraction . "%", $faded); + imagestring($base, 1, 434, $legend_y_position, $fraction . "%", $faded); } imagefilledarc($base, 300, 150, 200, 200, $previous_end - 90, $degrees + $previous_end - 90, $wedge_color, IMG_ARC_PIE); imagefilledarc($base, 300, 150, 200, 200, $previous_end - 90, $degrees + $previous_end - 90, $dark, IMG_ARC_EDGED | IMG_ARC_NOFILL); $legend_y_position += 10; $loop_count++; $previous_end += $degrees; - if($previous_end > 360) - { - $previous_end = 359; - } } if($running_total < $total_rounds) { $fraction = round((100 - ($running_total / $total_rounds * 100)), 0); imagefilledrectangle($base, 457, $legend_y_position + 1, 462, $legend_y_position + 6, $lighttransparent); - imagestring($base, 1, 467, $legend_y_position, "Other", $faded); - if($num_rows > 1) + imagestring($base, 1, 467, $legend_y_position, "Other Maps", $faded); + if(strlen((string)$fraction) == 1) { - if(strlen((string)$fraction) < 2) - { - imagestring($base, 1, 439, $legend_y_position, " " . $fraction . "%", $faded); - } - else - { - imagestring($base, 1, 439, $legend_y_position, $fraction . "%", $faded); - } + imagestring($base, 1, 439, $legend_y_position, " " . $fraction . "%", $faded); + } + elseif(strlen((string)$fraction) == 2) + { + imagestring($base, 1, 439, $legend_y_position, $fraction . "%", $faded); } else { - imagestring($base, 1, 433, $legend_y_position, $fraction . "%", $faded); + imagestring($base, 1, 434, $legend_y_position, $fraction . "%", $faded); } } imagestring($base, 2, 250, 15, 'Maps Played Most', $faded);