-sub getScan {
- my ($msg, $command) = @_;
-
- my ($t, $x, $y, $z, $type, $tick);
- if (defined $msg && $msg =~ /^([pdunja]) (\d+)\D+(\d+)\D+(\d+)(?: (\d+))?/){
- $t = $1;
- $type =$scantypes[$scanid{$1}-1];
- ($x,$y,$z) = ($2,$3,$4);
- $tick = $5;
- }else{
- $ND::server->command("notice $ND::nick syntax: $command type X:Y:Z [tick]"
- . " | type is the first character in the scan name, like p for planet scan."
- . " Specify a tick if you want scans older than the specified tick."
- );
- return;
- }
-
- if (my $user = member){
- my $scan = $ND::DBH->selectrow_hashref(q{
-SELECT id, scan_id, tick FROM scans
-WHERE type = $1 AND planet = planetid($2,$3,$4,0) AND COALESCE(tick < $5,TRUE)
-ORDER BY tick DESC LIMIT 1
- },undef,$type,$x,$y,$z,$tick);
- unless ($scan->{id}){
- $ND::server->command("notice $ND::nick No such scan");
- }
- my $text = '|';
- if ($t =~ /[uja]/){
- my $fid = $ND::DBH->selectrow_array(q{
-SELECT fid FROM fleet_scans WHERE id = $1
- },undef,$scan->{id});
- my $ships = $ND::DBH->prepare(q{
-SELECT ship,amount FROM fleet_ships WHERE fid = $1 ORDER BY num
- });
- $ships->execute($fid);
- while (my $ship = $ships->fetchrow_hashref){
- $text .= " $ship->{ship} $ship->{amount} |"
- }
- }else{
- $text = "http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}";
- }
- $ND::server->command("notice $ND::nick $ND::B$type$ND::O scan of $x:$y:$z "
- . "($scan->{scan_id} pt: $ND::B$scan->{tick}$ND::O) $text");
- }
-}