X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND%2FWeb%2FPages%2FCalls.pm;h=ddddc7bc78a41527c4c2b8acb00febe73f02cd4e;hb=7feae62d9dd8c44d84ccb0fb8e75b901a88c4433;hp=c9a51f7acf00479ac2ac0ba3a876ca56c0186584;hpb=29770a0a20d4343051560f7d4f2ddca6ceadc0e1;p=ndwebbie.git diff --git a/ND/Web/Pages/Calls.pm b/ND/Web/Pages/Calls.pm index c9a51f7..ddddc7b 100644 --- a/ND/Web/Pages/Calls.pm +++ b/ND/Web/Pages/Calls.pm @@ -126,7 +126,7 @@ sub render_body { $BODY->param(DefensePoints => $call->{defense_points}); $BODY->param(LandingTick => $call->{landing_tick}); $BODY->param(ETA => $call->{landing_tick}-$self->{TICK}); - $BODY->param(Info => $call->{info}); + $BODY->param(Info => escapeHTML $call->{info}); $BODY->param(DC => $call->{dc}); if ($call->{covered}){ $BODY->param(Cover => 'Uncover'); @@ -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; @@ -163,15 +163,14 @@ sub render_body { $fleets = $DBH->prepare(q{ - SELECT username, id FROM fleets f JOIN users u USING (uid) WHERE target = $1 and landing_tick = $2 - AND back = landing_tick + eta - 1 + 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; - $i = 0; 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; @@ -191,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; @@ -214,20 +213,25 @@ sub render_body { my ($maxpoints) = $DBH->selectrow_array($pointlimits,undef,'DEFMAX'); my $query = $DBH->prepare(qq{ - SELECT c.id, coords(p.x,p.y,p.z), u.defense_points, c.landing_tick, c.dc, - TRIM('/' FROM concat(p2.race||' /')) AS race, TRIM('/' FROM concat(i.amount||' /')) AS amount, - TRIM('/' FROM concat(i.eta||' /')) AS eta, TRIM('/' FROM concat(i.shiptype||' /')) AS shiptype, - TRIM('/' FROM concat(c.landing_tick - tick() ||' /')) AS curreta, - TRIM('/' FROM concat(p2.alliance ||' /')) AS alliance, - TRIM('/' FROM concat(coords(p2.x,p2.y,p2.z) ||' /')) AS attackers + SELECT id,coords(x,y,z),defense_points,landing_tick,dc,curreta,fleets, + TRIM('/' FROM concat(DISTINCT race||' /')) AS race, TRIM('/' FROM concat(amount||' /')) AS amount, + TRIM('/' FROM concat(DISTINCT eta||' /')) AS eta, TRIM('/' FROM concat(DISTINCT shiptype||' /')) AS shiptype, + TRIM('/' FROM concat(DISTINCT alliance ||' /')) AS alliance, + TRIM('/' FROM concat(coords||' /')) AS attackers + FROM (SELECT c.id, p.x,p.y,p.z, u.defense_points, c.landing_tick, dc.username AS dc, + (c.landing_tick - tick()) AS curreta,p2.race, i.amount, i.eta, i.shiptype, p2.alliance, + coords(p2.x,p2.y,p2.z), COUNT(DISTINCT f.id) AS fleets FROM calls c JOIN incomings i ON i.call = c.id JOIN users u ON c.member = u.uid JOIN current_planet_stats p ON u.planet = p.id JOIN current_planet_stats p2 ON i.sender = p2.id + LEFT OUTER JOIN users dc ON c.dc = dc.uid + LEFT OUTER JOIN fleets f ON f.target = u.planet AND f.landing_tick = c.landing_tick AND f.back = f.landing_tick + f.eta - 1 WHERE $where - GROUP BY c.id, p.x,p.y,p.z, u.username, c.landing_tick, c.info,u.defense_points,c.dc - ORDER BY c.landing_tick DESC + GROUP BY c.id, p.x,p.y,p.z, c.landing_tick, u.defense_points,dc.username,p2.race,i.amount,i.eta,i.shiptype,p2.alliance,p2.x,p2.y,p2.z) a + GROUP BY id, x,y,z,landing_tick, defense_points,dc,curreta,fleets + ORDER BY landing_tick DESC })or $error .= $DBH->errstr; $query->execute or $error .= $DBH->errstr; my @calls; @@ -246,7 +250,8 @@ sub render_body { push @calls,{}; $i = 0; } - $call->{dc} = 'Hostile' unless defined $call->{dc}; + $call->{attackers} =~ s{(\d+:\d+:\d+)}{$1}g; + $call->{dcstyle} = 'Hostile' unless defined $call->{dc}; $i++; $call->{ODD} = $i % 2; $call->{shiptype} = escapeHTML($call->{shiptype});