X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fscans.pl;h=30bd8bebe5afa165b3f33a8eab1267c520f1c721;hb=5d49b3579d2ad39f6ae9bc2dba37ebbf0334e0da;hp=32e406e66d1174eaff1ab1aa6ff3b0a455ff041e;hpb=94861be42591f9ce23b1632cbd6532d7914ff41e;p=ndwebbie.git diff --git a/scripts/scans.pl b/scripts/scans.pl index 32e406e..30bd8be 100755 --- a/scripts/scans.pl +++ b/scripts/scans.pl @@ -26,7 +26,7 @@ use CGI; use DBI; use DBD::Pg qw(:pg_types); use LWP::Simple; -use lib qw{/var/www/ndawn/}; +use lib qw{/var/www/ndawn/lib/}; use ND::DB; our $dbh = ND::DB::DB(); @@ -78,6 +78,8 @@ my $addpdata = $dbh->prepare(q{INSERT INTO planet_data (id,tick,scan,rid,amount) $dbh->begin_work or die 'No transaction'; $newscans->execute or die $dbh->errstr; $dbh->pg_savepoint('scans') or die "No savepoint"; + +my %production = (None => 0, Low => 35, Medium => 65, High => 100); while (my $scan = $newscans->fetchrow_hashref){ my $file = get("http://game.planetarion.com/showscan.pl?scan_id=$scan->{scan_id}"); next unless defined $file; @@ -106,14 +108,32 @@ while (my $scan = $newscans->fetchrow_hashref){ } if ($type eq 'Planet'){ $file =~ s/(\d),(\d)/$1$2/g; - while($file =~ m/"left">(Metal|Crystal|Eonium)\D+(\d+)\D+(\d+)/g){ + while($file =~ m/"center">(Metal|Crystal|Eonium)\D+(\d+)\D+([\d,]+)/g){ + my ($roids,$res) = ($2,$3); + $roids =~ s/,//g; + $addpdata->execute($planet,$tick,$scan->{id} + ,'roid',$1, $roids) or die $dbh->errstr; + $res =~ s/,//g; + $addpdata->execute($planet,$tick,$scan->{id} + ,'resource',$1, $res) or die $dbh->errstr; + } + if($file =~ m{