]> ruin.nu Git - ndwebbie.git/blobdiff - scripts/scans.pl
Don't show the Next link when we've reached the end
[ndwebbie.git] / scripts / scans.pl
index 30bd8bebe5afa165b3f33a8eab1267c520f1c721..5b9e74eaf3a535ae718326416688aa18260f960c 100755 (executable)
@@ -81,6 +81,8 @@ $dbh->pg_savepoint('scans') or die "No savepoint";
 
 my %production = (None => 0, Low => 35, Medium => 65, High => 100);
 while (my $scan = $newscans->fetchrow_hashref){
+       $dbh->pg_release('scans') or die "Couldn't save";
+       $dbh->pg_savepoint('scans') or die "Couldn't save";
        my $file = get("http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}");
        next unless defined $file;
        if ($file =~ /((?:\w| )*) (?:Scan|Probe) on (\d+):(\d+):(\d+) in tick (\d+)/){
@@ -95,11 +97,16 @@ while (my $scan = $newscans->fetchrow_hashref){
                        $dbh->pg_rollback_to('scans') or die "rollback didn't work";
                        $delscan->execute($scan->{id});
                        $addpoints->execute(-1,$scan->{uid}) if $scan->{uid} > 0;
-                       die "Duplicate scan: $scan->{id} http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}\n";
+                       warn "Duplicate scan: $scan->{id} http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}\n";
+                       next;
                }
                my ($planet) = $dbh->selectrow_array($findplanet,undef,$x,$y,$z,$tick);
                unless ($planet){
                        $dbh->pg_rollback_to('scans') or die "rollback didn't work";
+                       if ( $x == 0 && $y == 0 && $z == 0 ){
+                               $delscan->execute($scan->{id});
+                               $addpoints->execute(-1,$scan->{uid}) if $scan->{uid} > 0;
+                       }
                        next;
                }
                my $scantext = "";
@@ -192,8 +199,6 @@ while (my $scan = $newscans->fetchrow_hashref){
                        print "Something wrong with scan $scan->{id} type $type at tick $tick http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}";
                }
                $parsedscan->execute($tick,$type,$planet,$scan->{id}) or die $dbh->errstr;
-               $dbh->pg_release('scans') or die "Couldn't save";
-               $dbh->pg_savepoint('scans') or die "Couldn't save";
                #$dbh->rollback;
                };
                if ($@) {