]> ruin.nu Git - ndwebbie.git/blobdiff - scripts/scans.pl
Let officers see all members
[ndwebbie.git] / scripts / scans.pl
index bc9de5716eb5e0b1b9a4d0db21e7ac4398ea6211..03d560d21f91bda24f4978d470dc30908496d0b2 100755 (executable)
@@ -65,6 +65,9 @@ my $emptyscans = $dbh->prepare('SELECT scan_id,tick,"type"::integer,tick() FROM
 my $update = $dbh->prepare('UPDATE scans SET tick = ?, "type" = ?, scan = ? , planet = ? WHERE scan_id = ? AND tick = ?');
 $addScan = $dbh->prepare('INSERT INTO scans (tick,scan_id,"type",scan,planet) VALUES($1,$2,$3,$4,$5)') or die $dbh->errstr;
 my $findplanet = $dbh->prepare('SELECT planetid(?,?,?,?)');
+
+my $oldcoords = $dbh->prepare(q{SELECT x,y,z FROM planet_stats 
+       WHERE id = ? AND tick = ?});
 my $delscan = $dbh->prepare('DELETE FROM scans WHERE scan_id = ? AND tick = ?');
 unless ($emptyscans->execute){
        my $cleanup = $dbh->prepare('UPDATE scans SET "type" = \'-1\' WHERE planet is NULL');
@@ -108,7 +111,7 @@ HTML
                        my $f = $dbh->prepare("UPDATE covop_targets SET metal = ?, crystal = ?, eonium = ? WHERE planet = ?");
                        if ($f->execute($2,$4,$6,$planet) < 1){
                                $f = $dbh->prepare("INSERT INTO covop_targets (planet,metal, crystal, eonium) VALUES(?,?,?,?)");
-                               $f->execute($planet,$4,$5,$6);
+                               $f->execute($planet,$2,$4,$6);
                        }
                }elsif ($type eq 'Jumpgate'){
                        $scantext .= <<HTML
@@ -148,12 +151,13 @@ HTML
                                my $t = $2;
                                my $text = $cgi->escapeHTML($3);
                                my $class = '';
+                               my ($x,$y,$z) = $dbh->selectrow_array($oldcoords,undef,$planet,$t);
 
                                if($news eq 'Launch' && $text =~ m/(?:[^<]*) fleet has been launched, heading for (\d+):(\d+):(\d+), on a mission to (Attack|Defend). Arrival tick: (\d+)/g){
 
                                        my $eta = $5 - $t;
                                        my $mission = $4;
-                                       $mission = 'AllyDef' if $eta == 7 && $x != $1;
+                                       $mission = 'AllyDef' if $eta == 6 && $x != $1;
                                        $f->execute($t,$eta,$1,$2,$3,$x,$y,$z,-1,$mission) or print $dbh->errstr;
                                        $class = qq{ class="$mission"};
                                }elsif($news eq 'Incoming' && $text =~ m/We have detected an open jumpgate from (?:[^<]*), located at (\d+):(\d+):(\d+). The fleet will approach our system in tick (\d+) and appears to have roughly (\d+) ships/g){