3 # This specific file is hereby placed in the public domain, or nearest
4 # equivalent in law, by me, Ian Jackson. 5th July 2009.
15 parse_pctb_commodmap();
17 our %stallkinds= qw(A Apothecary
27 $!=0; my $l= <STDIN>; die $! unless defined $l;
28 die $! if STDIN->error;
30 print "GOT FOR $w LINE [$l]\n"
38 my $t= tell STDIN; $t>=0 or die $!;
39 my $r= read STDIN,$b,2; die $! if STDIN->error;
41 my $v= scalar unpack "v", $b;
42 printf "GOT AT 0x%x INT FOR %s VALUE %d 0x%x\n", $t, $w, $v, $v
48 my ($what,$ary,$ix) = @_;
50 return $got if defined $got;
55 printf "# Version: \"%s\"\n", getline("version");
56 our $nstalls= getline("nstalls")+0;
59 while (@stalls < $nstalls) {
60 $_= getline("stall name ".(@stalls+1));
63 my $sk= $stallkinds{$kind};
64 die "kind $kind in $_ ?" unless defined $sk;
69 unshift @stalls, undef;
73 foreach my $bs qw(Buy Sell) {
74 my $alloffers_want= getint("Buy ncommods");
76 while ($alloffers_done < $alloffers_want) {
77 my $commodix= getint("Buy $alloffers_done/$alloffers_want commodix");
78 my $offers= getint("Buy $commodix offers");
80 for ($offernum=0; $offernum<$offers; $offernum++) {
81 my $stallix= getint("Buy $commodix $offernum stallix");
82 my $price= getint("Buy $commodix $offernum price");
83 my $qty= getint("Buy $commodix $offernum qty");
86 inmap('commod',@pctb_commodmap,$commodix),
87 inmap('stall',@stalls,$stallix)) or die $!;
88 if ($bs eq 'Sell') { print "\t\t" or die $!; }
89 printf("\t%d\t%d", $price, $qty) or die $!;
90 if ($bs eq 'Buy') { print "\t\t" or die $!; }
93 die if $alloffers_done > $alloffers_want;
98 my $r= read STDIN,$b,1;
99 STDIN->error and die $!;
108 #Version number (3 ascii digits) followed
109 #by LF (i.e. 0x0A). Current version is\
112 # 0000 30 30 35 0a 005.
114 ## of shops/stalls (in ascii) + LF
117 #list of shop names in ascii (without the
118 #possessive part and by specifying the \
119 #shop type in an abbreviated way which is
120 #mentioned below). The shop names are
121 #separated \ by line feeds (0x0A). To
122 #specify the shop type append the "^"
123 #character and then \ one of the
124 #following characters depending upon the
134 # 0000 4f 6c 64 20 49 72 6f 6e 73 69 Ol d Ironsi
135 # 0010 64 65 73 0a des.
137 ## of buy offers (in binary)
140 #commodIndex offerCount buy 0/5
141 # 0010 0a 00 01 00 Grog x 1
143 # 0010 01 00 1d 00 75 00 OI 29 qty 75
145 #commodIndex offerCount buy 1/5
146 # 0020 0b 00 01 00 Fine x 1
147 #[shopIndex val amt]... (all in binar\ y)
148 # 0020 01 00 33 00 e9 03 OI 51 qty 0x3e9
150 #commodIndex offerCount buy 2/5
151 # 0020 0c 00 01 00 Small shot x 1
154 # 0030 0f 00 e9 03 15 qty 0x3e9
156 #commodIndex offerCount buy 3/5
157 # 0030 0d 00 01 00 Medium shot x 1
159 # 0030 01 00 1c 00 e9 03 OI 28 qty 0x3e9
161 #commodIndex offerCount buy 4/5
162 # 0030 0e 00 Large shot
165 # 0040 01 00 26 00 e9 03 OI 38 0x3e9
168 ## of sell offers (in binary)
171 #commodIndex offerCount sell 0/4
172 # 0040 09 00 01 00 Swill x 1
175 # 0050 17 00 e8 03 23 0x3e8
176 #commodIndex offerCount sell 1/4
177 # 0050 0a 00 01 00 Grog x 1
179 # 0050 01 00 1e 00 73 03 OI 30 qty 0x373
180 #commodIndex offerCount sell 2/4
181 # 0050 0c 00 Small shot
184 # 0060 01 00 10 00 07 00 OI 16 qty 7
185 #commodIndex offerCount sell 3/4
186 # 0060 0d 00 01 00 Medium shot x 1
188 # 0060 01 00 1e 00 OI 30