X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FNDWeb%2FScans.pm;fp=lib%2FNDWeb%2FScans.pm;h=f2661498c9d585fb638a291a9dd25372c915f2d4;hb=33a44a03fa129739264f7ccd983e38c96c11a677;hp=cfec2fd5ce4e7eb44441d3f77427a2d223619ffa;hpb=a482ae605a2ecb265854e6a02672524bbae2ae7a;p=ndwebbie.git
diff --git a/lib/NDWeb/Scans.pm b/lib/NDWeb/Scans.pm
index cfec2fd..f266149 100644
--- a/lib/NDWeb/Scans.pm
+++ b/lib/NDWeb/Scans.pm
@@ -33,13 +33,16 @@ sub parseMilScan ($) {
my @fleets;
while ($file =~ m{
([^<]+) | }g) {
- push @fleets, {name => $1, ships => []};
+ push @fleets, {name => $1, mission => 'Military', ships => []};
}
+ push @fleets, {name => 'Military', mission => 'Full fleet', ships => []};
+ my $total = 0;
while ($file =~ m{([^<]+) | (.+?)
}g) {
my $ship = $1;
next if $ship eq 'Total Ships';
my $amounts = $2;
+ my $tot_amount = 0;
my $i = 0;
while ($amounts =~ m{([\d,]+) | }g) {
my $fleet = $fleets[$i];
@@ -48,11 +51,18 @@ sub parseMilScan ($) {
if ($ship eq 'Total Visible Ships') {
$fleet->{amount} = $amount;
} elsif ($amount > 0) {
+ $tot_amount += $amount;
+ $total += $amount;
push @{$fleet->{ships}}, {ship => $ship, amount => $amount};
}
++$i;
}
+
+ if ($tot_amount > 0) {
+ push @{$fleets[4]->{ships}}, {ship => $ship, amount => $tot_amount};
+ }
}
+ $fleets[4]->{amount} = $total;
return @fleets;
}
@@ -70,8 +80,8 @@ sub doMilScan ($$$) {
my @fleets = parseMilScan($file);
for my $fleet (@fleets) {
- next if $fleet->{amount} == 0;
- $addfleet->execute($fleet->{name},$scan->{type},$scan->{pid}
+ next if $fleet->{amount} == 0 && $fleet->{mission} eq 'Military';
+ $addfleet->execute($fleet->{name},$fleet->{mission},$scan->{pid}
,$scan->{tick}, $fleet->{amount});
my ($id) = $addfleet->fetchrow_array;
$fleetscan->execute($id,$scan->{id}) or die $dbh->errstr;