… | |
… | |
162 | # this was the most horrible thing to decode. still not everything is decoded correctly(?) |
162 | # this was the most horrible thing to decode. still not everything is decoded correctly(?) |
163 | sub dec_TREE { |
163 | sub dec_TREE { |
164 | my @r; |
164 | my @r; |
165 | while (length $data) { |
165 | while (length $data) { |
166 | my $type = dec_U8; |
166 | my $type = dec_U8; |
|
|
167 | my $add = $type < 128; |
167 | |
168 | |
|
|
169 | $type &= 127; |
|
|
170 | |
168 | if ($type == 255) { |
171 | if ($type == 127) { |
|
|
172 | dec_U8; # unused?? *sigh* |
169 | push @r, [add_child => dec_I32]; |
173 | push @r, [add_node => dec_I32]; |
170 | |
174 | |
|
|
175 | } elsif ($type == 126) { |
|
|
176 | push @r, [set_node => dec_I32]; |
|
|
177 | |
|
|
178 | } elsif ($type == 125) { |
|
|
179 | push @r, [set_current => dec_I32]; |
|
|
180 | |
|
|
181 | } elsif ($type == 34) { |
|
|
182 | push @r, [score => dec_U8, dec_score1000]; |
|
|
183 | |
171 | } elsif ($type == 254) { |
184 | } elsif ($type == 25) { |
172 | push @r, ["done"]; |
185 | push @r, [result => dec_result]; |
173 | |
186 | |
174 | } elsif ($type == 253) { |
187 | } elsif ($type == 23) { |
175 | push @r, ["type253"]; |
188 | push @r, [mark => $add, MARK_GRAYED, dec_U8, dec_U8]; |
176 | # ???? |
|
|
177 | |
189 | |
178 | } elsif ($type == 252) { # even less clear |
190 | } elsif ($type == 22) { |
|
|
191 | push @r, [mark => $add, (&dec_U8 ? MARK_SMALL_W : MARK_SMALL_B), dec_U8, dec_U8]; |
|
|
192 | |
|
|
193 | } elsif ($type == 21) { |
|
|
194 | push @r, [mark => $add, MARK_CIRCLE, dec_U8, dec_U8]; |
|
|
195 | |
|
|
196 | } elsif ($type == 17) { |
|
|
197 | push @r, [set_timer => (dec_U8, dec_U32, dec_time)[0,2,1]]; |
|
|
198 | |
|
|
199 | } elsif ($type == 16) { |
|
|
200 | push @r, [set_stone => $add, dec_U8, dec_U8, dec_U8]; |
|
|
201 | |
|
|
202 | } elsif ($type == 14) { |
|
|
203 | push @r, [move => $add, dec_U8, dec_U8, dec_U8]; |
|
|
204 | |
|
|
205 | } elsif (($type >= 4 && $type <= 9) |
|
|
206 | || ($type >= 11 && $type <= 13) |
|
|
207 | || $type == 24) { |
|
|
208 | |
179 | push @r, ["more"]; |
209 | push @r, [({ |
|
|
210 | 4 => "date", |
|
|
211 | 5 => "unknown_comment5", |
|
|
212 | 6 => "unknown_comment6", |
|
|
213 | 7 => "unknown_comment7", |
|
|
214 | 8 => "unknown_comment8", |
|
|
215 | 9 => "copyright", #? |
|
|
216 | 11 => "unknown_comment11", |
|
|
217 | 12 => "unknown_comment12", |
|
|
218 | 13 => "unknown_comment13", |
|
|
219 | 24 => "comment", |
|
|
220 | })->{$type} => dec_STRING]; |
180 | |
221 | |
|
|
222 | } elsif ($type == 3) { |
|
|
223 | push @r, [rank => dec_U8, dec_U32]; |
|
|
224 | |
|
|
225 | } elsif ($type == 2) { |
|
|
226 | push @r, [player => dec_U8, dec_STRING]; |
|
|
227 | |
181 | } elsif ($type == 10) { |
228 | } elsif ($type == 0) { |
182 | # as usual, wms finds yet another way to duplicate code... oh well, what a mess. |
229 | # as usual, wms finds yet another way to duplicate code... oh well, what a mess. |
183 | # (no wonder he is so keen on keeping it secret...) |
230 | # (no wonder he is so keen on keeping it a secret...) |
184 | |
231 | |
185 | push @r, [rules => dec_rules]; |
232 | push @r, [rules => dec_rules]; |
186 | |
233 | |
187 | } elsif ($type == 9 || $type == 22 || $type == 25 || $type == 31 || $type == 32) { |
234 | # OLD |
188 | push @r, [({ |
|
|
189 | 9 => "comment", |
|
|
190 | 22 => "unknown_comment22", |
|
|
191 | 25 => "copyright", #? |
|
|
192 | 31 => "date", |
|
|
193 | 32 => "unknown_comment32", |
|
|
194 | })->{$type} => dec_STRING]; |
|
|
195 | |
235 | |
196 | } elsif ($type == 11 || $type == 12) { |
|
|
197 | push @r, [player => $type - 11, dec_STRING]; |
|
|
198 | |
|
|
199 | } elsif ($type == 13 || $type == 14) { |
|
|
200 | push @r, [rank => $type - 13, dec_U32]; |
|
|
201 | |
|
|
202 | } elsif ($type == 15 || $type == 16) { |
|
|
203 | push @r, [set_timer => $type - 15, dec_time, dec_U16]; |
|
|
204 | |
|
|
205 | } elsif ($type == 17 || $type == 18) { |
|
|
206 | push @r, [score => $type - 17, dec_score16]; |
|
|
207 | |
|
|
208 | } elsif ($type == 19) { |
236 | } elsif (1) { |
209 | push @r, [result => dec_result]; # not certain |
237 | print STDERR KGS::Listener::Debug::dumpval(\@r); |
|
|
238 | open XTYPE, "|xtype"; print XTYPE $data; close XTYPE; |
|
|
239 | die "unknown type $type"; |
210 | |
240 | |
211 | } elsif ($type == 30) { |
241 | } elsif ($type == 30) { |
212 | push @r, [active_player => dec_U8]; |
242 | push @r, [active_player => dec_U8]; |
213 | |
243 | |
214 | } elsif ($type == 0) { # label(?) |
244 | } elsif ($type == 0) { # label(?) |