X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Scans.pm;h=2bd67957a37c64f420db94c0fc7051945d5cb3d8;hb=df43148278c85c28726accbec2421688260661b7;hp=b2621e8d332da3b3332fe9abf8e04ead03357dff;hpb=491db8f0abea3c779a1ecdc64f22ed233bc9546b;p=NDIRC.git diff --git a/Scans.pm b/Scans.pm index b2621e8..2bd6795 100644 --- a/Scans.pm +++ b/Scans.pm @@ -25,7 +25,7 @@ require Exporter; our @ISA = qw/Exporter/; -our @EXPORT = qw/addScan addScanGroup sendScan reqScan scanReqs getScan/; +our @EXPORT = qw/addScan addScanGroup/; sub addScan { my ($id,$verbose) = @_; @@ -68,110 +68,7 @@ sub addScanGroup { } } -sub sendScan { - my ($msg, $command) = @_; - my ($target,$mess); - if (defined $msg && $msg =~ /^(\S+) (.*)$/){ - $target = $1; - $mess = $2; - }else{ - $ND::server->command("notice $ND::nick syntax: $command nick message"); - return; - } - if (scanner()){ - $ND::server->command("msg $target ".chr(2).$mess.chr(3)."4 (reply with /msg $ND::scanchan)"); - $ND::server->command("msg $ND::target ${ND::C}3$target << $mess"); - } -} - - -our %scantypes; -{ - my $i = 1; - %scantypes = map {$_ => $i++} @scantypes; -} - -sub scanReqs { - my ($msg, $command) = @_; - - if (scanner()){ - - my @notype; - if ($msg && $msg =~ /-([pdunja]+)/){ - for (split //, $1){ - push @notype, $scantypes[$scanid{$_}-1]; - } - } - - my $reqs = $ND::DBH->prepare(q{SELECT min(sr.id) AS id, x,y,z,type - FROM scan_requests sr - JOIN current_planet_stats p ON p.id = sr.planet - WHERE sr.time > NOW() - '30 min'::INTERVAL - AND NOT EXISTS (SELECT scan_id FROM scans - WHERE planet = sr.planet - AND type = sr.type - AND tick >= sr.tick - ) - AND type <> ALL($1) - GROUP BY x,y,z,type - ORDER BY id - }); - $reqs->execute(\@notype); - my $text = ''; - while (my $req = $reqs->fetchrow_hashref){ - $text .= "$ND::B$req->{id}$ND::O http://game.planetarion.com/waves.pl?id=$scantypes{$req->{type}}&x=$req->{x}&y=$req->{y}&z=$req->{z} " - } - - $text = 'No unhandled requests.' unless $text; - $ND::server->command("notice $ND::nick $text"); - } -} - -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"); - } -} 1;