Deliantra
view release on metacpan or search on metacpan
Deliantra/Map.pm view on Meta::CPAN
for (@{$self->{map}}) {
@$_ = @$_[0 .. $height - 1];
}
}
sub as_archlist {
my ($self) = @_;
# wing map so we have no extra-map arches
$self->resize ($self->{width}, $self->{height});
my @arch;
for my $x (0 .. $self->{width} - 1) {
my $ass = $self->{map}[$x];
for my $y (0 .. $self->{height} - 1) {
for my $a (@{ $ass->[$y] || [] }) {
next if $a->{_virtual};
# note: big faces _may_ span map boundaries
my %a = %$a;
delete $a{x};
delete $a{y};
$a{x} = $x if $x;
$a{y} = $y if $y;
push @arch, \%a;
}
}
}
# now assemble meta info
if ($self->{info}) {
my %meta = %{$self->{info}};
$meta{width} = $self->{width};
$meta{height} = $self->{height};
unshift @arch, Deliantra::normalize_arch \%meta;
}
\@arch
}
sub as_mapstring {
my ($self) = @_;
my $arch = $self->as_archlist;
Deliantra::archlist_to_string ($arch)
}
sub write_file {
my ($self, $path) = @_;
open my $fh, ">:raw:utf8", "$path~" or Carp::croak "$path~: $!";
print $fh $self->as_mapstring or Carp::croak "$path~: $!";
close $fh or Carp::croak "$path~: $!";
if (stat $path) {
chmod +(stat _)[2] & 0777, "$path~";
chown +(stat _)[4,5], "$path~";
}
rename "$path~", $path;
}
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
Robin Redeker <elmex@ta-sa.org>
http://www.ta-sa.org/
=cut
1
( run in 0.430 second using v1.01-cache-2.11-cpan-71847e10f99 )