X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FScans.pm;h=06ae96f960e93bfd352d1ee0cf142a9ef8353c03;hb=06eb99af20cebc85b1f609becb125b4dc32bf8ff;hp=31eea44fb9f940800b58132568c4d9cfc673f0a2;hpb=ae37bc6b64270f8c65298a36fce1f4bad761231f;p=NDIRC.git
diff --git a/Commands/Scans.pm b/Commands/Scans.pm
index 31eea44..06ae96f 100644
--- a/Commands/Scans.pm
+++ b/Commands/Scans.pm
@@ -52,8 +52,11 @@ sub gs
$typeid = $scanid{$typeid};
my $type = $scantypes[$typeid-1];
- my $planet = $c->model->selectrow_array(q{SELECT planetid($1,$2,$3,tick())}
- ,undef,$x,$y,$z);
+ my ($planet,$dists,$tick) = $c->model->selectrow_array(q{
+SELECT pid,distorters,tick
+FROM current_planet_stats LEFT JOIN current_development_scans USING (pid)
+WHERE x = $1 AND y = $2 AND z = $3
+ },undef,$x,$y,$z);
unless ($planet){
$c->reply("There is no planet with coords $x:$y:$z, try again after the tick.");
return;
@@ -70,10 +73,10 @@ sub gs
}else{
my $req = $c->model->prepare(q{
SELECT * FROM scan_requests
-WHERE uid = (SELECT uid FROM users WHERE hostmask ILIKE $1)
+WHERE uid = $1
AND pid = $2 AND type = $3 AND NOT sent
});
- $req->execute($c->host,$planet,$type);
+ $req->execute($c->uid,$planet,$type);
my $id;
if(my $scan = $req->fetchrow_hashref){
@@ -86,16 +89,22 @@ WHERE id = $2
}else{
$req = $c->model->prepare(q{
INSERT INTO scan_requests (uid,nick,pid,type)
-VALUES((SELECT uid FROM users WHERE hostmask ILIKE $1),$2,$3,$4) RETURNING (id)
+VALUES($1,$2,$3,$4) RETURNING (id)
});
- $req->execute($c->host,$c->nick,$planet,$type);
+ $req->execute($c->uid,$c->nick,$planet,$type);
$id = $req->fetchrow;
}
if ($id){
- $c->message("msg $ND::scanchan"
+
+ if (defined $dists){
+ $dists = "$dists dists PT$tick"
+ }else{
+ $dists = "DISTS UNKNOWN, ADD DEVSCAN"
+ }
+ $c->message(privmsg => $c->disp->targets->{scan}
,"$id http://game.planetarion.com/waves.pl?id=$typeid&x=$x&y=$y&z=$z"
- . " ($x:$y:$z $type) | <".$c->nick."> $msg"
+ . " ($x:$y:$z $type - $dists) | <".$c->nick."> $msg"
);
$c->reply("sent request ($x:$y:$z $type)");
}else{
@@ -198,9 +207,9 @@ sub anon
my ($self, $c, $msg) = @_;
my ($target,$mess) = $msg =~ /^(\S+) (.*)$/ or die 'ARGS';
- $c->message("msg $target", "$mess (reply with /msg "
+ $c->message(privmsg => $target, "$mess (reply with /msg "
.$c->channel.")");
- $c->message("msg ".$c->channel, "$target << $mess");
+ $c->message(privmsg => $c->channel, "$target << $mess");
}
sub addscan
@@ -217,7 +226,7 @@ WHERE groupscan = $1 AND scan_id = LOWER($2) AND tick >= tick() - 168
INSERT INTO scans (scan_id,tick,groupscan,uid) VALUES (LOWER($1),tick(),$2,COALESCE($3,-1))
});
my $user = $dbh->selectrow_hashref(q{SELECT uid,username, scan_points, tick()
- FROM users WHERE hostmask ILIKE ? },undef,$c->host);
+ FROM users WHERE uid = ? },undef,$c->uid);
my $groupscans = 0;
my $scans = 0;
eval {