… | |
… | |
8 | |
8 | |
9 | our $VERSION = '0.1'; |
9 | our $VERSION = '0.1'; |
10 | |
10 | |
11 | use strict; |
11 | use strict; |
12 | |
12 | |
|
|
13 | use base 'Exporter'; |
|
|
14 | |
13 | use Storable; |
15 | use Storable; |
|
|
16 | |
|
|
17 | our @EXPORT = qw(read_pak read_arch arch2map $ARCH TILESIZE); |
14 | |
18 | |
15 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
19 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
16 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
20 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
17 | |
21 | |
18 | sub T (){ 32 } |
22 | sub TILESIZE (){ 32 } |
19 | |
23 | |
20 | our $ARCH; |
24 | our $ARCH; |
21 | our $TILE; |
|
|
22 | |
25 | |
23 | sub read_pak($;$) { |
26 | sub read_pak($;$) { |
24 | my ($path, $cache) = @_; |
27 | my ($path, $cache) = @_; |
25 | |
28 | |
26 | eval { |
29 | eval { |
… | |
… | |
131 | my ($mapx, $mapy); |
134 | my ($mapx, $mapy); |
132 | |
135 | |
133 | my $map; |
136 | my $map; |
134 | |
137 | |
135 | for (@{ $mapa->{arch} }) { |
138 | for (@{ $mapa->{arch} }) { |
136 | my ($x, $y) = ($_->{x}, $_->{y}); |
139 | my ($x, $y) = (delete $_->{x}, delete $_->{y}); |
137 | |
140 | |
138 | if ($_->{_name} eq "map") { |
141 | if ($_->{_name} eq "map") { |
139 | $meta{info} = $_; |
142 | $meta{info} = $_; |
140 | |
143 | |
141 | $mapx = $_->{width} || $x; |
144 | $mapx = $_->{width} || $x; |
… | |
… | |
151 | } |
154 | } |
152 | } |
155 | } |
153 | |
156 | |
154 | $meta{width} = $mapx; |
157 | $meta{width} = $mapx; |
155 | $meta{height} = $mapy; |
158 | $meta{height} = $mapy; |
|
|
159 | $meta{map} = $map; |
156 | |
160 | |
157 | \%meta |
161 | \%meta |
158 | } |
162 | } |
159 | |
163 | |
160 | sub init($) { |
164 | sub init($) { |
161 | my ($cachedir) = @_; |
165 | my ($cachedir) = @_; |
162 | |
166 | |
163 | $ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
167 | $ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
164 | $TILE = read_pak "$LIB/crossfire.0", "$cachedir/crossfire.0.pst"; |
|
|
165 | } |
168 | } |
166 | |
169 | |
167 | =head1 AUTHOR |
170 | =head1 AUTHOR |
168 | |
171 | |
169 | Marc Lehmann <schmorp@schmorp.de> |
172 | Marc Lehmann <schmorp@schmorp.de> |