]> ruin.nu Git - ndwebbie.git/blobdiff - ND/Web/Pages/Calls.pm
gal rankings and fixed a bug with gal graph caching
[ndwebbie.git] / ND / Web / Pages / Calls.pm
index 526d4903327b4e59d6100251c1330423aefa7355..6cb626a13c2e5e70d459159538f90e7ca42a7454 100644 (file)
@@ -40,7 +40,7 @@ sub render_body {
        my $call;
        if (defined param('call') && param('call') =~ /^(\d+)$/){
                my $query = $DBH->prepare(q{
-                       SELECT c.id, coords(p.x,p.y,p.z), c.landing_tick, c.info, covered, open, dc.username AS dc, u.defense_points,c.member
+                       SELECT c.id, coords(p.x,p.y,p.z), c.landing_tick, c.info, covered, open, dc.username AS dc, u.defense_points,c.member,u.planet
                        FROM calls c 
                        JOIN users u ON c.member = u.uid
                        LEFT OUTER JOIN users dc ON c.dc = dc.uid
@@ -144,13 +144,13 @@ sub render_body {
                my $ships = $DBH->prepare('SELECT ship,amount FROM fleet_ships WHERE fleet = ?');
                $fleets->execute($call->{member},$call->{landing_tick},$call->{landing_tick});
                my @fleets;
-               my $i = 0;
                while (my $fleet = $fleets->fetchrow_hashref){
                        if ($fleet->{back} == $call->{landing_tick}){
                                $fleet->{Fleetcatch} = 1;
                        }
                        $ships->execute($fleet->{id});
                        my @ships;
+                       my $i = 0;
                        while (my $ship = $ships->fetchrow_hashref){
                                $i++;
                                $ship->{ODD} = $i % 2;
@@ -161,6 +161,27 @@ sub render_body {
                }
                $BODY->param(Fleets => \@fleets);
 
+
+               $fleets = $DBH->prepare(q{
+                       SELECT username, id,back - (landing_tick + eta - 1) AS recalled FROM fleets f JOIN users u USING (uid) WHERE target = $1 and landing_tick = $2
+                       });
+               $fleets->execute($call->{planet},$call->{landing_tick}) or $ND::ERROR .= p $DBH->errstr;
+               my @defenders;
+               while (my $fleet = $fleets->fetchrow_hashref){
+                       $ships->execute($fleet->{id});
+                       my @ships;
+                       my $i = 0;
+                       while (my $ship = $ships->fetchrow_hashref){
+                               $i++;
+                               $ship->{ODD} = $i % 2;
+                               push @ships,$ship;
+                       }
+                       $fleet->{Ships} = \@ships;
+                       delete $fleet->{id};
+                       push @defenders, $fleet;
+               }
+               $BODY->param(Defenders => \@defenders);
+
                my $attackers = $DBH->prepare(q{
                        SELECT coords(p.x,p.y,p.z), p.planet_status, p.race,i.eta,i.amount,i.fleet,i.shiptype,p.relationship,p.alliance,i.id
                        FROM incomings i
@@ -169,7 +190,7 @@ sub render_body {
                        ORDER BY p.x,p.y,p.z});
                $attackers->execute($call->{id});
                my @attackers;
-               $i = 0;
+               my $i = 0;
                while(my $attacker = $attackers->fetchrow_hashref){
                        $i++;
                        $attacker->{ODD} = $i % 2;
@@ -224,6 +245,7 @@ sub render_body {
                                push @calls,{};
                                $i = 0;
                        }
+                       $call->{attackers} =~ s{(\d+:\d+:\d+)}{<a href="/check?coords=$1">$1</a>}g;
                        $call->{dc} = 'Hostile' unless defined $call->{dc};
                        $i++;
                        $call->{ODD} = $i % 2;