]> ruin.nu Git - ndwebbie.git/blobdiff - ND/Web/Pages/Raids.pm
fix
[ndwebbie.git] / ND / Web / Pages / Raids.pm
index 15b8f68ec53afe5292c01e2cf510fb5efd43287a..65aa7e9a2ded6cce9f029d7f32947b62e8c6743e 100644 (file)
 
 package ND::Web::Pages::Raids;
 use strict;
-use warnings FATAL => 'all';
+use warnings;
 use ND::Include;
 use POSIX;
 use CGI qw/:standard/;
 use ND::Web::Include;
 
-our @ISA = qw/ND::Web::XMLPage/;
+use base qw/ND::Web::XMLPage/;
 
 $ND::Web::Page::PAGES{raids} = __PACKAGE__;
 
@@ -195,8 +195,8 @@ sub render_body {
                        $noingal = "AND NOT (x = $planet->{x} AND y = $planet->{y})";
                }
                $BODY->param(Message => parseMarkup($raid->{message}));
-               $BODY->param(LandingTick => parseMarkup($raid->{tick}));
-               my $targetquery = $DBH->prepare(qq{SELECT r.id, r.planet, size, score, value, coords(p.x,p.y,p.z), race, p.value - p.size*200 -coalesce(c.metal+c.crystal+c.eonium,0)/150 - coalesce(c.structures,(SELECT avg(structures) FROM covop_targets)::int)*1500 AS fleetvalue,(c.metal+c.crystal+c.eonium)/100 AS resvalue, comment
+               $BODY->param(LandingTick => $raid->{tick});
+               my $targetquery = $DBH->prepare(qq{SELECT r.id, r.planet, size, score, value, p.x,p.y,p.z, race, p.value - p.size*200 -coalesce(c.metal+c.crystal+c.eonium,0)/150 - coalesce(c.structures,(SELECT avg(structures) FROM covop_targets)::int)*1500 AS fleetvalue,(c.metal+c.crystal+c.eonium)/100 AS resvalue, comment
                        FROM current_planet_stats p 
                        JOIN raid_targets r ON p.id = r.planet 
                        LEFT OUTER JOIN covop_targets c ON p.id = c.planet
@@ -224,7 +224,7 @@ sub render_body {
                        $target{comment} = parseMarkup($target->{comment}) if ($target->{comment});
 
                        my $scans = $DBH->prepare(q{SELECT DISTINCT ON (type) type, tick, scan FROM scans 
-                               WHERE planet = ? AND type ~ 'Unit|Planet|Military|.* Analysis' AND tick + 24 > tick()
+                               WHERE planet = ? AND type ~ 'Unit|Planet|Military|.* Analysis' AND tick + 24 > tick() AND scan is not null
                                GROUP BY type, tick, scan ORDER BY type ,tick DESC});
                        $scans->execute($target->{planet});
                        my %scans;
@@ -237,7 +237,7 @@ sub render_body {
                                next unless exists $scans{$type};
                                my $scan = $scans{$type};
                                if ($self->{TICK} - $scan->{tick} > 5){
-                                       $scan->{scan} =~ s{<table( cellpadding="\d+")?>}{<table$1 class="old">};
+                                       $scan->{scan} =~ s{<table( cellpadding="\d+")?>}{<table class="old">};
                                }
                                if ($type eq 'Planet'){
                                        $target{PlanetScan} = $scan->{scan};
@@ -247,6 +247,12 @@ sub render_body {
                        }
                        $target{Scans} = \@scans;
 
+                       if ($planet){
+                               if ($planet->{x} == $target->{x}){
+                                       $target{style} = 'incluster';
+                               }
+                       }
+
                        my @roids;
                        my @claims;
                        my $size = $target{Size};
@@ -270,6 +276,8 @@ sub render_body {
 
                        push @targets,\%target;
                }
+               @targets = sort {$b->{Roids}[0]{XP} <=> $a->{Roids}[0]{XP} or $b->{Size} <=> $a->{Size}} @targets;
+
                $BODY->param(Targets => \@targets);
        }else{#list raids if we haven't chosen one yet
                my $query = $DBH->prepare(q{SELECT id,released_coords FROM raids WHERE open AND not removed AND