use Carp;
-our $VERSION = '1.00';
+our $VERSION = '1.01';
sub new {
my ($class, $format) = @_;
: $count."X[$count]$count/($value)";
}
else {
+ $value =~ s/=\d*//g; # hardcoded values
$value =~ s/^C(a)(\d+)/$1 . ($2 + 1)/e; # length prefix
}
$value;
elsif ($template =~ /^(?:[xX]\d*)*$/) {
next; # no values
}
+ elsif ($template =~ /=(\d+)?/) {
+ $res{$field} = $1;
+ next;
+ }
$res{$field} = shift @$data;
}
return \%res;
This behaviour is very similar to C<(C/a@x$length)>, except that it never reads
more than the given number of bytes.
+=item *
+
+Hardcoded values can be inserted using C<=$number> values.
+This can for example be useful to retain forwards-compatibility:
+
+ rows => ['C',
+ type => '=1', # nothing read
+ data => 'S',
+ ]
+
+ rows => ['C',
+ type => 'C',
+ data => 'S',
+ ]
+
=back
=head1 AUTHOR
$_->[13] = $_->[15]; # ctf
$_->[15] = 'domination';
} for @{ $FORMAT[9] }; # no multifood
- push @LEVELFORM, "object$_" => ['C',
+ push @LEVELFORM, "objects$_" => ['C',
+ type => "=$_",
map {$_ => 'C'} qw(x1 y1 x2 y2)
- ] for qw(lines boxes);
+ ] for 2, 3;
}
default {
die "Unsupported level version $version\n";
# add objects until terminator
$level->{objects} = [];
if ($version <= 91) {
- push @{ $level->{objects} }, { %$_, type => 2 } for map { $level->{$_} ? @{ $level->{$_} } : () } qw(objectlines);
- push @{ $level->{objects} }, { %$_, type => 3 } for map { $level->{$_} ? @{ $level->{$_} } : () } qw(objectboxes);
+ ref $_ eq 'ARRAY' and push @{ $level->{objects} }, @$_
+ for map { delete $level->{"objects$_"} } 2, 3;
$size += 1 + 4 * scalar @{ $level->{objects} };
}
else {