X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=pctb%2Fcommod-results-processor;h=b604419db6cf7c3e43531fda9350fbd0eb9affea;hp=32763293ac705f6128cd88a7312000ce296501ae;hb=12b118fd416fb96309d9e4ef65336e08441594c1;hpb=2d4936689fb9f77e34412dd4169e025a6e364477 diff --git a/pctb/commod-results-processor b/pctb/commod-results-processor index 3276329..b604419 100755 --- a/pctb/commod-results-processor +++ b/pctb/commod-results-processor @@ -218,7 +218,7 @@ sub main__tsv () { our (%commodmap); -our ($pctb) = $ENV{'YPPSC_PCTB_PCTB'}; die unless $pctb; +our ($pctb) = $ENV{'YPPSC_PCTB_PCTB'}; our ($ua)= LWP::UserAgent->new; @@ -235,6 +235,7 @@ sub load_commodmap() { } sub refresh_commodmap() { + die unless $pctb; my $resp= $ua->get("$pctb/commodmap.php?version=2"); die $resp->status_line unless $resp->is_success; @@ -331,6 +332,16 @@ sub bs_gen_md ($$) { sub writeint { return pack 'v*', @_; } +our (%stalltypetoabbrevmap)= qw( + Apothecary A + Distilling D + Furnishing F + Ironworking I + Shipbuilding S + Tailoring T + Weaving W + ); + sub genmarketdata () { our $version= '005b'; @@ -355,7 +366,18 @@ sub genmarketdata () { my $ot= sprintf("$version\n". "%d\n", scalar(@stallmap)); - foreach $stall (@stallmap) { $ot .= "$stall\n"; } + foreach $stall (@stallmap) { + my $st= $stall; + if ($st =~ m/^(\S+)\'s (\S+) Stall$/) { + my $stkind= $stalltypetoabbrevmap{$2}; + if (defined $stkind) { + $st= "$1^$stkind"; + } else { + warn "unknown stall type $2 in $st\n"; + } + } + $ot .= "$st\n"; + } return $ot.$ob; } @@ -365,6 +387,7 @@ sub main__genmarketdata () { } sub main__upload () { + die unless $pctb; my $o= genmarketdata(); my $url= "$pctb/upload.php"; $url= "http://www.chiark.greenend.org.uk/ucgi/~ijackson/check/upload.php";