Parse::Binary::Nested format values containing only x/X (ie ignored)
are detected and skipped during conversion. This allows for exact
specifications instead of having to append to previous (defined)
elements.
elsif ($template =~ /^Ca/) {
$data->[0] = unpack 'C/a', $data->[0];
}
elsif ($template =~ /^Ca/) {
$data->[0] = unpack 'C/a', $data->[0];
}
+ elsif ($template =~ /^(?:[xX]\d*)*$/) {
+ next; # no values
+ }
$res{$field} = shift @$data;
}
return \%res;
$res{$field} = shift @$data;
}
return \%res;
multifood => 'C',
timematch => 'C',
race => 'C',
multifood => 'C',
timematch => 'C',
race => 'C',
+ ctf => 'C',
+ reserved => 'x',
finish => [1,
type => 's',
message => 'Ca255',
finish => [1,
type => 's',
message => 'Ca255',
+ code => 'Ca255',
+ reserved=> 'x256',
],
hiname => 'a3',
levels => ['*', # levelcount->total actually
],
hiname => 'a3',
levels => ['*', # levelcount->total actually
given ($fileversion) {
when (153) { } # current @FORMAT
$FORMAT[7] = 'Ca64'; # no reserved space after description
given ($fileversion) {
when (153) { } # current @FORMAT
$FORMAT[7] = 'Ca64'; # no reserved space after description
- $FORMAT[15]->[-1] = 'Ca255'; # enddata
+ splice @{ $FORMAT[15] }, -2; # finish reserve
$FORMAT[-1]->[-1]->[0] = '32C'; # less objects
$FORMAT[-1]->[-1]->[0] = '32C'; # less objects
- when ($version == 96) {
- ref $_ and $_->[-1] = 'C' for @{ $FORMAT[11] }; # 9 moderefs
- }
- ref $_ and pop @$_ for @{ $FORMAT[11] }; # only 8 moderefs
+ ref $_ and pop @$_ for @{ $FORMAT[11] }; # 9 moderefs
+ when ($version == 96) { }
+ ref $_ and pop @$_ for @{ $FORMAT[11] }; # only 8 moderefs (no ctf)
splice @FORMAT, 6, 2 if $version <= 94; # earlier version without description
when (95) { }
splice @{ $FORMAT[7] }, 4, 2; # no race
splice @FORMAT, 6, 2 if $version <= 94; # earlier version without description
when (95) { }
splice @{ $FORMAT[7] }, 4, 2; # no race
) }
[qw/single peaworm tron deathmatch foodmatch multifood timematch race ctf/]
],
) }
[qw/single peaworm tron deathmatch foodmatch multifood timematch race ctf/]
],
sprite => ['C',
line => 'B8',
],
sprite => ['C',
line => 'B8',
],
use Test::More;
use Data::Dumper;
use Test::More;
use Data::Dumper;
use_ok('Parse::Binary::Nested');
use_ok('Parse::Binary::Nested');
+is_deeply(
+ Parse::Binary::Nested->new(
+ [ ignoreme => 'x2X', value => 'xC' ]
+ )->unpackf("\0\1\2"),
+ { value => 2 },
+ 'empty values'
+);
+