chiark / gitweb /
Make %commods more versatile by making srcs be in Srcs
authorIan Jackson <ian@liberator.(none)>
Fri, 21 Aug 2009 22:12:14 +0000 (23:12 +0100)
committerIan Jackson <ian@liberator.(none)>
Fri, 21 Aug 2009 22:12:14 +0000 (23:12 +0100)
yarrg/Commods.pm
yarrg/database-info-fetch

index c82fdfdbb156a0c3daebd1f4ce6d7e4fe0f36f83..f17a8ed289d6b4d9567df4e99ab8963428e89d52 100644 (file)
@@ -49,13 +49,17 @@ BEGIN {
 }
 
 our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources;
-our %commods; # eg $commods{'Fine black cloth'}= $sources;
 our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ];
 our %routes; # eg $routes{'Midnight'}{'Orca'}{'Tinga'}= $sources  NB abbrevs!
 our %route_mysteries; # eg $route_mysteries{'Midnight'}{'Norse'}= 3
 # $sources = 's[l]b';
 #       's' = Special Circumstances; 'l' = local ; B = with Bleach
 
+our %commods;
+# eg $commods{'Fine black cloth'}{Srcs}= $sources;
+# eg $commods{'Fine black cloth'}{Mass}= 700 [g]
+# eg $commods{'Fine black cloth'}{Volume}= 1000 [ml]
+
 our (%pctb_commodmap,@pctb_commodmap);
 
 my %colours; # eg $colours{'c'}{'black'}= $sources
@@ -116,7 +120,7 @@ sub parse_info1 ($$) {
     $ca= sub {
        my ($s,$ss) = @_;
 #print "ca($s)\n";
-       if ($s !~ m/\%(\w+)/) { $commods{ucfirst $s} .= $ss; return; }
+       if ($s !~ m/\%(\w+)/) { $commods{ucfirst $s}{Srcs} .= $ss; return; }
        die "unknown $&" unless defined $colours{$1};
        foreach my $c (keys %{ $colours{$1} }) {
            &$ca($`.$c.$', $ss .'%'. $colours{$1}{$c});
@@ -196,7 +200,7 @@ sub parse_info_serverside_ocean ($) {
 
 sub parse_pctb_commodmap () {
     undef %pctb_commodmap;
-    foreach my $commod (keys %commods) { $commods{$commod} =~ s/b//; }
+    foreach my $commod (keys %commods) { $commods{$commod}{Srcs} =~ s/b//; }
 
     my $c= new IO::File '_commodmap.tsv';
     if (!$c) { $!==&ENOENT or die $!; return 0; }
@@ -205,7 +209,7 @@ sub parse_pctb_commodmap () {
        m/^(\S.*\S)\t(\d+)\n$/ or die "$_";
        die if defined $pctb_commodmap{$1};  $pctb_commodmap{$1}= $2;
        die if defined $pctb_commodmap[$2];  $pctb_commodmap[$2]= $1;
-       $commods{$1} .= 'b';
+       $commods{$1}{Srcs} .= 'b';
     }
     $c->error and die $!;
     close $c or die $!;
index 1e789b88fcb389686675f07393e1d0fab7a48ac1..5e0576095a0b23ac7aa837a1d91ff72132f0c3c2 100755 (executable)
@@ -159,7 +159,7 @@ sub main__comparesources () {
                sub { });
     for_commods(sub {
                    my ($commod)= @_;
-                   my $srcs= $commods{$commod};
+                   my $srcs= $commods{$commod}{Srcs};
                    compare_sources_one($srcs, "commodity $commod");
                });
 }