X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fscans.pl;h=bedd3df5cdf33e05d2b7108845680323d78d77dc;hb=635211f6d29f02fb994fff49684cf6c39b50b598;hp=e9795f7eba5e87e49b131481289fdc9671494fa4;hpb=41646fbe70b05d4a96addcbdc71c2cc3b7bd8aa2;p=ndwebbie.git diff --git a/scripts/scans.pl b/scripts/scans.pl index e9795f7..bedd3df 100755 --- a/scripts/scans.pl +++ b/scripts/scans.pl @@ -97,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 = ""; @@ -109,15 +114,21 @@ while (my $scan = $newscans->fetchrow_hashref){ #TODO: something about planet being closed? } if ($type eq 'Planet'){ - $file =~ s/(\d),(\d)/$1$2/g; while($file =~ m/"center">(Metal|Crystal|Eonium)\D+(\d+)\D+([\d,]+)/g){ - my ($roids,$res) = ($2,$3); + my ($type,$roids,$res) = ($1,$2,$3); $roids =~ s/,//g; $addpdata->execute($planet,$tick,$scan->{id} - ,'roid',$1, $roids) or die $dbh->errstr; + ,'roid',$type, $roids) or die $dbh->errstr; $res =~ s/,//g; $addpdata->execute($planet,$tick,$scan->{id} - ,'resource',$1, $res) or die $dbh->errstr; + ,'resource',$type, $res) or die $dbh->errstr; + } + if($file =~ m{Security\ Guards .+? "center">(\d+) + .+? "center">(\d+)}sx){ + $addpdata->execute($planet,$tick,$scan->{id} + ,'planet','Agents', $1) or die $dbh->errstr; + $addpdata->execute($planet,$tick,$scan->{id} + ,'planet','Security Guards', $2) or die $dbh->errstr; } if($file =~ m{([A-Z][a-z]+)([A-Z][a-z]+)([A-Z][a-z]+)}){ $addpdata->execute($planet,$tick,$scan->{id}