]> ruin.nu Git - ndwebbie.git/blobdiff - scripts/parseplanets.pl
Use new race infrastructure for members stats
[ndwebbie.git] / scripts / parseplanets.pl
index a01377f1aa86df741ef15f35218852314310d872..bf5f2dc75c38998c87e642f5ec6bca2361a72232 100755 (executable)
@@ -22,11 +22,10 @@ q{
 
 use strict;
 use warnings;
+use local::lib;
 use DBI;
 use DBD::Pg qw(:pg_types);
 
-use LWP::Simple;
-
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 
@@ -45,11 +44,11 @@ $dumps->execute($tick);
 if (@_ = $dumps->fetchrow){
        $_ = $_[0];
        $hour = (gmtime($_[1]))[2];
-       my $planetid = $dbh->prepare(q{SELECT find_planet_id($1,$2,$3)});
-       while (m/(\d+)\t(\d+)\t(\d+)\t\"(.*)\"\t\"(.*)\"\t(Ter|Cat|Zik|Xan|Etd)\t(\d+)\t(\d+)\t(\d+)\t(\d+)/g){
-               $planetid->execute($5,$4,$6);
+       my $planetid = $dbh->prepare(q{SELECT find_planet_id($1,$2,$3,$4)});
+       while (m/(\w+)\t(\d+)\t(\d+)\t(\d+)\t\"(.*)\"\t\"(.*)\"\t(\w+)\t(\d+)\t(\d+)\t(\d+)\t(\d+)/g){
+               $planetid->execute($1,$6,$5,$7);
                my @id = $planetid->fetchrow;
-               push @planets,[$tick,$id[0],$1,$2,$3,$7,$8,$9,$10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
+               push @planets,[$tick,$id[0],$2,$3,$4,$8,$9,$10,$11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
        }
 }
 
@@ -85,6 +84,7 @@ while (my @planet = $findplanets->fetchrow){
 }
 my $intel = $dbh->prepare(q{INSERT INTO forum_posts (ftid,uid,message) VALUES(
                (SELECT ftid FROM planets WHERE pid = $2),$1,$3)});
+$dbh->do(q{DELETE FROM planet_stats WHERE tick = $1},undef,$tick);
 for my $planet (@planets) {
        #print "$planet->[1]\n";
        my $oldPlanet = $oldStats{$planet->[1]};