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,
+ SELECT c.id, coords(p.x,p.y,p.z), u.defense_points, c.landing_tick, dc.username AS 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,
(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
+ TRIM('/' FROM concat(coords(p2.x,p2.y,p2.z) ||' /')) AS attackers,
+ 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
+ GROUP BY c.id, p.x,p.y,p.z, u.username, c.landing_tick, c.info,u.defense_points,dc.username
ORDER BY c.landing_tick DESC
})or $error .= $DBH->errstr;
$query->execute or $error .= $DBH->errstr;
$i = 0;
}
$call->{attackers} =~ s{(\d+:\d+:\d+)}{<a href="/check?coords=$1">$1</a>}g;
- $call->{dc} = 'Hostile' unless defined $call->{dc};
+ $call->{dcstyle} = 'Hostile' unless defined $call->{dc};
$i++;
$call->{ODD} = $i % 2;
$call->{shiptype} = escapeHTML($call->{shiptype});
</fieldset>
<TMPL_ELSE>
<table>
- <tr><th>Call</th><th>Member (def points)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>Current eta</th><th>Inital eta</th><th>Alliance</th><th>Attackers</th></tr>
+ <tr><th>Call</th><th>DC</th><th>Def Fleets</th><th>Member (def points)</th><th>Landing tick</th><th>Races</th><th>Amount</th><th>Shiptypes</th><th>ETA</th><th>Alliance</th><th>Attackers</th></tr>
<TMPL_LOOP Calls>
<tr align="center" class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
- <td class="<TMPL_VAR NAME=DC>"><a href="/<TMPL_VAR NAME=PAGE>?call=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Id></a></td>
+ <td class="<TMPL_VAR NAME=DCSTYLE>"><a href="/<TMPL_VAR NAME=PAGE>?call=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Id></a></td>
+ <td><TMPL_VAR NAME=DC></td>
+ <td><TMPL_VAR NAME=Fleets></td>
<td class='<TMPL_VAR NAME=DefPrio>'><TMPL_IF Id><a href="/check?coords=<TMPL_VAR NAME=Coords>"><TMPL_VAR NAME=Coords> (<TMPL_VAR NAME=Defense_points>)</a><TMPL_ELSE>-New Day-</TMPL_IF></td>
<td><TMPL_VAR NAME=Landing_tick></td>
<td><TMPL_VAR NAME=Race></td>
<td><TMPL_VAR NAME=Amount></td>
<td><TMPL_VAR NAME=Shiptype></td>
- <td><TMPL_VAR NAME=Curreta></td>
- <td><TMPL_VAR NAME=Eta></td>
+ <td><TMPL_VAR NAME=Curreta> (<TMPL_VAR NAME=Eta>)</td>
<td><TMPL_VAR NAME=Alliance></td>
<td><TMPL_VAR NAME=Attackers></td>
</tr>