]> ruin.nu Git - ndwebbie.git/commitdiff
Bugfix, avg attack and def points are 0, keep it at minimum 1 to avoid division by...
authorMichael Andreen <harv@ruin.nu>
Sun, 17 Aug 2008 20:22:01 +0000 (22:22 +0200)
committerMichael Andreen <harv@ruin.nu>
Sun, 17 Aug 2008 20:22:01 +0000 (22:22 +0200)
lib/NDWeb/Controller/Calls.pm

index cbb78da89284aefc63a5e27bc4e8440930a6f254..d3a44e301eb3c1c0418975ed588c71e6d92f87df 100644 (file)
@@ -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