);
my $offsetbase = 0xF080;
+ my @VARMODES = (
+ [qw'single single'],
+ [qw'multi peaworm tron deathmatch foodmatch multifood timematch'],
+ [qw'race race'],
+ [qw'ctf ctf'],
+ );
+
given ($version) {
when (97) {
# current @FORMAT
type => "=$_",
map {$_ => 'C'} qw(x1 y1 x2 y2)
] for 2, 3;
+ # peaworm/tron mode do not take multiplayer levels
+ splice @VARMODES, 1, 0, ['peaworm', splice @{ $VARMODES[1] }, 1, 2];
}
default {
die "Unsupported level version $version\n";
$data->{moderef}->{offset}->{single} == $offsetbase
or warn "First singleplayer level is not in front\n";
- my $slots = sum(
+ my $slots = sum(grep {defined}
$data->{moderef}->{end}->{single} > 0, # singleplayer slot if any levels
$data->{moderef}->{end}->{peaworm}, # one for each peaworm arena
$data->{moderef}->{end}->{tron}, # idem for tron
$data->{hinames} = [ unpack '(x2a3)*', substr($data->{leveldata}, -5 * $slots) ];
$data->{format} = '86s';
- my @VARMODES = (
- [qw'single single'],
- [qw'multi peaworm tron deathmatch foodmatch multifood timematch'],
- [qw'race race'],
- [qw'ctf ctf'],
- );
-
$data->{levels} = [];
for my $modes (@VARMODES) {
my $variant = shift @$modes;
: max(grep {defined} map { $data->{moderef}->{end}->{$_} } @$modes);
my @varform = @LEVELFORM;
- $varform[13]->[0] = $variant eq 'single' ? 1 : 4;
+ $varform[13]->[0] = $variant ~~ ['single', 'peaworm'] ? 1 : 4; # worms
unshift @varform, name => 'Z*' unless $variant eq 'single' or $version <= 91;
$varform[-3]->[0] = 1 if $variant eq 'race' and $version > 91;
$varform[-3]->[0] = 2 if $variant eq 'ctf';
);
my $startnr = 0;
- for my $variant (qw/single multi race ctf/) {
+ for my $variant (qw/single peaworm multi race ctf/) {
my $count = $data->{levelcount}->{$variant};
+ defined $count or next;
print "\n";
- printf '%s (%s)', ucfirst $variant, $count // 'invalid';
+ printf '%s (%s)', ucfirst $variant, $count;
$count or next;
print ":";
for (0 .. $count - 1) {
);
}
$startnr += $count;
- }
- continue {
+
print "\n";
printf("-- %-21s%4s: %s (%s)\n",
'(ending)',
$data->{finish}->{message} // '?',
) if $variant eq 'single';
}
+ print "\n";
}
__END__