… | |
… | |
167 | # "less" primitive types<![CDATA[ |
167 | # "less" primitive types<![CDATA[ |
168 | |
168 | |
169 | # this was the most horrible thing to decode. still not everything is decoded correctly(?) |
169 | # this was the most horrible thing to decode. still not everything is decoded correctly(?) |
170 | sub dec_TREE { |
170 | sub dec_TREE { |
171 | my @r; |
171 | my @r; |
|
|
172 | my $old_data = $data;#d# |
172 | while (length $data) { |
173 | while (length $data) { |
173 | my $type = dec_U8; |
174 | my $type = dec_U8; |
174 | my $add = $type < 128; |
175 | my $add = $type < 128; |
|
|
176 | |
|
|
177 | my $ofs = (length $old_data) - (length $data);#d# |
175 | |
178 | |
176 | $type &= 127; |
179 | $type &= 127; |
177 | |
180 | |
178 | if ($type == 127) { |
181 | if ($type == 127) { |
179 | dec_U8; # unused?? *sigh* |
182 | dec_U8; # unused?? *sigh* |
… | |
… | |
209 | |
212 | |
210 | } elsif ($type == 22) { |
213 | } elsif ($type == 22) { |
211 | push @r, [mark => $add, dec_U8() ? MARK_SMALL_W : MARK_SMALL_B, dec_U8, dec_U8]; |
214 | push @r, [mark => $add, dec_U8() ? MARK_SMALL_W : MARK_SMALL_B, dec_U8, dec_U8]; |
212 | |
215 | |
213 | } elsif ($type == 21) { |
216 | } elsif ($type == 21) { |
214 | push @r, [mark => $add, MARK_CIRCLE, dec_U8, dec_U8]; |
217 | push @r, [mark => $add, MARK_SQUARE, dec_U8, dec_U8]; |
215 | |
218 | |
216 | } elsif ($type == 20) { |
219 | } elsif ($type == 20) { |
217 | push @r, [mark => $add, MARK_SQUARE, dec_U8, dec_U8]; |
220 | push @r, [mark => $add, MARK_TRIANGLE, dec_U8, dec_U8]; |
218 | |
221 | |
219 | } elsif ($type == 19) { |
222 | } elsif ($type == 19) { |
220 | push @r, [mark => $add, MARK_TRIANGLE, dec_U8, dec_U8]; |
223 | push @r, [mark => $add, MARK_LABEL, dec_U8, dec_U8, dec_ZSTRING]; |
|
|
224 | #push @r, [unknown_18 => dec_U8, dec_U32, dec_U32, dec_U8, dec_U32, dec_U32, dec_U32]; |
|
|
225 | #push @r, [set_timer => (dec_U8, dec_U32, dec_time)[0,2,1]]; |
221 | |
226 | |
222 | } elsif ($type == 18) { |
227 | } elsif ($type == 18) { |
223 | push @r, [mark => $add, MARK_LABEL, dec_U8, dec_U8, dec_ZSTRING]; |
228 | push @r, [set_timer => (dec_U8, dec_U32, dec_time)[0,2,1]]; |
224 | |
229 | |
225 | } elsif ($type == 17) { |
230 | } elsif ($type == 17) { |
226 | push @r, [set_timer => (dec_U8, dec_U32, dec_time)[0,2,1]]; |
231 | push @r, [set_stone => dec_U8, dec_U8, dec_U8];#d#? |
227 | |
232 | |
228 | } elsif ($type == 16) { |
233 | # } elsif ($type == 16) { |
229 | push @r, [set_stone => dec_U8, dec_U8, dec_U8]; |
234 | # push @r, [set_stone => dec_U8, dec_U8, dec_U8];#o# |
|
|
235 | |
|
|
236 | } elsif ($type == 15) { |
|
|
237 | push @r, [mark => $add, MARK_CIRCLE, dec_U8, dec_U8];#d#? |
230 | |
238 | |
231 | } elsif ($type == 14) { |
239 | } elsif ($type == 14) { |
232 | push @r, [move => dec_U8, dec_U8, dec_U8]; |
240 | push @r, [move => dec_U8, dec_U8, dec_U8]; |
233 | |
241 | |
234 | } elsif (($type >= 4 && $type <= 9) |
242 | } elsif (($type >= 4 && $type <= 9) |
… | |
… | |
236 | || $type == 24) { |
244 | || $type == 24) { |
237 | |
245 | |
238 | push @r, [({ |
246 | push @r, [({ |
239 | 4 => "date", |
247 | 4 => "date", |
240 | 5 => "unknown_comment5", |
248 | 5 => "unknown_comment5", |
241 | 6 => "unknown_comment6", |
249 | 6 => "game_id", #?# |
242 | 7 => "unknown_comment7", |
250 | 7 => "unknown_comment7", |
243 | 8 => "unknown_comment8", |
251 | 8 => "unknown_comment8", |
244 | 9 => "copyright", #? |
252 | 9 => "copyright", #? |
245 | 11 => "unknown_comment11", |
253 | 11 => "unknown_comment11", |
246 | 12 => "unknown_comment12", |
254 | 12 => "unknown_comment12", |
… | |
… | |
252 | push @r, [rank => dec_U8, dec_U32]; |
260 | push @r, [rank => dec_U8, dec_U32]; |
253 | |
261 | |
254 | } elsif ($type == 2) { |
262 | } elsif ($type == 2) { |
255 | push @r, [player => dec_U8, dec_ZSTRING]; |
263 | push @r, [player => dec_U8, dec_ZSTRING]; |
256 | |
264 | |
|
|
265 | } elsif ($type == 1) { |
|
|
266 | push @r, [sgf_name => dec_ZSTRING]; |
|
|
267 | |
257 | } elsif ($type == 0) { |
268 | } elsif ($type == 0) { |
258 | # as usual, wms finds yet another way to duplicate code... oh well, what a mess. |
269 | # as usual, wms finds yet another way to duplicate code... oh well, what a mess. |
259 | # (no wonder he is so keen on keeping it a secret...) |
270 | # (no wonder he is so keen on keeping it a secret...) |
260 | |
271 | |
261 | push @r, [rules => dec_rules]; |
272 | push @r, [rules => dec_rules]; |
… | |
… | |
263 | # OLD |
274 | # OLD |
264 | |
275 | |
265 | } else { |
276 | } else { |
266 | require KGS::Listener::Debug; # hack |
277 | require KGS::Listener::Debug; # hack |
267 | print STDERR KGS::Listener::Debug::dumpval(\@r); |
278 | print STDERR KGS::Listener::Debug::dumpval(\@r); |
|
|
279 | printf "offset: 0x%04x\n", $ofs; |
268 | open XTYPE, "|xtype"; print XTYPE $data; close XTYPE; |
280 | open XTYPE, "|xtype"; print XTYPE $old_data; close XTYPE; |
269 | die "unknown tree type $type, PLEASE REPORT and include the game you wanted to watch. thx."; |
281 | #die "unknown tree type $type, PLEASE REPORT and include the game you wanted to watch. thx."; |
|
|
282 | warn "unknown tree type $type, PLEASE REPORT and include the game you wanted to watch. thx."; |
270 | |
283 | |
271 | } |
284 | } |
|
|
285 | |
|
|
286 | push @{$r[-1]}, offset => sprintf "0x%x", $ofs;#d# |
|
|
287 | |
272 | } |
288 | } |
|
|
289 | # print STDERR KGS::Listener::Debug::dumpval(\@r);#d# |
|
|
290 | # return [];#d# |
273 | \@r; |
291 | \@r; |
274 | } |
292 | } |
275 | |
293 | |
276 | sub enc_TREE { |
294 | sub enc_TREE { |
277 | for (@{$_[0]}) { |
295 | for (@{$_[0]}) { |