From: Michael Andreen Date: Sun, 17 Aug 2008 20:22:01 +0000 (+0200) Subject: Bugfix, avg attack and def points are 0, keep it at minimum 1 to avoid division by... X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=0bf0cd98e5e467bd8608a478b204d7e2ae0fcaa6 Bugfix, avg attack and def points are 0, keep it at minimum 1 to avoid division by zero --- 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