From 0bf0cd98e5e467bd8608a478b204d7e2ae0fcaa6 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sun, 17 Aug 2008 22:22:01 +0200 Subject: [PATCH] Bugfix, avg attack and def points are 0, keep it at minimum 1 to avoid division by zero --- lib/NDWeb/Controller/Calls.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/NDWeb/Controller/Calls.pm b/lib/NDWeb/Controller/Calls.pm index cbb78da..d3a44e3 100644 --- a/lib/NDWeb/Controller/Calls.pm +++ b/lib/NDWeb/Controller/Calls.pm @@ -54,7 +54,8 @@ sub list : Local { my $query = $dbh->prepare(qq{ SELECT id,coords(x,y,z),planet,landing_tick,dc,curreta,fleets - ,(0.2*(attack_points/a.attack)+ 0.4*(defense_points/a.defense) + ,(0.2*(attack_points/GREATEST(a.attack,1)) + + 0.4*(defense_points/GREATEST(a.defense,1)) + 0.2*(c.size/a.size) + 0.05*(c.score/a.score) + 0.15*(c.value/a.value))::Numeric(3,2) AS defprio ,array_accum(COALESCE(race::text,'')) AS race -- 2.39.2