5 open CM, "#commodmap#.tsv" or die $!;
10 m/^(\S.*\S)\t(\d+)$/ or die;
15 %stallkinds= qw(A Apothecary
25 $!=0; my $l= <STDIN>; die $! unless defined $l;
26 die $! if STDIN->error;
28 print "GOT FOR $w LINE [$l]\n"
36 my $t= tell STDIN; $t>=0 or die $!;
37 my $r= read STDIN,$b,2; die $! if STDIN->error;
39 my $v= scalar unpack "v", $b;
40 printf "GOT AT 0x%x INT FOR %s VALUE %d 0x%x\n", $t, $w, $v, $v
46 my ($what,$ary,$ix) = @_;
48 return $got if defined $got;
53 printf "# Version: \"%s\"\n", getline("version");
54 $nstalls= getline("nstalls")+0;
56 while (@stalls < $nstalls) {
57 $_= getline("stall name ".(@stalls+1));
60 $sk= $stallkinds{$kind};
61 die "kind $kind in $_ ?" unless defined $sk;
66 unshift @stalls, undef;
70 foreach $bs qw(Buy Sell) {
71 $alloffers_want= getint("Buy ncommods");
73 while ($alloffers_done < $alloffers_want) {
74 $commodix= getint("Buy $alloffers_done/$alloffers_want commodix");
75 $offers= getint("Buy $commodnum offers");
76 for ($offernum=0; $offernum<$offers; $offernum++) {
77 $stallix= getint("Buy $commodnum $offernum stallix");
78 $price= getint("Buy $commodnum $offernum price");
79 $qty= getint("Buy $commodnum $offernum qty");
82 inmap('commod',@commodmap,$commodix),
83 inmap('stall',@stalls,$stallix)) or die $!;
84 if ($bs eq 'Sell') { print "\t\t" or die $!; }
85 printf("\t%d\t%d", $price, $qty) or die $!;
86 if ($bs eq 'Buy') { print "\t\t" or die $!; }
89 die if $alloffers_done > $alloffers_want;
95 STDIN->error and die $!;