… | |
… | |
12 | |
12 | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Storable; |
15 | use Storable; |
16 | |
16 | |
17 | our @EXPORT = qw(read_pak read_arch arch2map $ARCH TILESIZE editor_archs arch2pickmap arch_extends); |
17 | #XXX: The map_* procedures scream for a map-object |
|
|
18 | |
|
|
19 | our @EXPORT = |
|
|
20 | qw(read_pak read_arch arch2map $ARCH TILESIZE editor_archs |
|
|
21 | arch2pickmap arch_extends |
|
|
22 | map_get_tile_stack map_push_tile_stack map_pop_tile_stack |
|
|
23 | ); |
18 | |
24 | |
19 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
25 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
20 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
26 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
21 | |
27 | |
22 | sub TILESIZE (){ 32 } |
28 | sub TILESIZE (){ 32 } |
… | |
… | |
124 | |
130 | |
125 | \%arc |
131 | \%arc |
126 | } |
132 | } |
127 | } |
133 | } |
128 | |
134 | |
|
|
135 | # returns the arch/object stack from a tile on a map |
|
|
136 | sub map_get_tile_stack { |
|
|
137 | my ($map, $x, $y) = @_; |
|
|
138 | my $as; |
|
|
139 | |
|
|
140 | if ($x > 0 || $x < $map->{width} |
|
|
141 | || $y > 0 || $y < $map->{height}) { |
|
|
142 | |
|
|
143 | $as = $map->{map}{map}[$x][$y] || []; |
|
|
144 | } |
|
|
145 | |
|
|
146 | return $as; |
|
|
147 | } |
|
|
148 | |
|
|
149 | # pop the topmost arch/object from the stack of a tile on a map |
|
|
150 | sub map_pop_tile_stack { |
|
|
151 | my ($map, $x, $y) = @_; |
|
|
152 | |
|
|
153 | if ($x > 0 || $x < $map->{width} |
|
|
154 | || $y > 0 || $y < $map->{height}) { |
|
|
155 | |
|
|
156 | pop @{$map->{map}{map}[$x][$y]}; |
|
|
157 | } |
|
|
158 | } |
|
|
159 | |
|
|
160 | # pushes the arch/object on the stack of a tile on a map |
|
|
161 | sub map_push_tile_stack { |
|
|
162 | my ($map, $x, $y, $arch) = @_; |
|
|
163 | |
|
|
164 | if ($x > 0 || $x < $map->{width} |
|
|
165 | || $y > 0 || $y < $map->{height}) { |
|
|
166 | |
|
|
167 | push @{$map->{map}{map}[$x][$y]}, $arch; |
|
|
168 | } |
|
|
169 | } |
|
|
170 | |
|
|
171 | |
129 | # put all archs into a hash with editor_face as it's key |
172 | # put all archs into a hash with editor_face as it's key |
130 | # NOTE: the arrays in the hash values are references to |
173 | # NOTE: the arrays in the hash values are references to |
131 | # the archs from $ARCH |
174 | # the archs from $ARCH |
132 | sub editor_archs { |
175 | sub editor_archs { |
133 | my %paths; |
176 | my %paths; |