… | |
… | |
12 | |
12 | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use Storable; |
16 | use Storable; |
|
|
17 | use File::Spec; |
17 | use List::Util qw(min max); |
18 | use List::Util qw(min max); |
18 | |
19 | |
19 | #XXX: The map_* procedures scream for a map-object |
20 | #XXX: The map_* procedures scream for a map-object |
20 | |
21 | |
21 | our @EXPORT = |
22 | our @EXPORT = |
… | |
… | |
224 | } |
225 | } |
225 | |
226 | |
226 | \%paths |
227 | \%paths |
227 | } |
228 | } |
228 | |
229 | |
|
|
230 | =item ($minx, $miny, $maxx, $maxy) = arch_extents $arch |
|
|
231 | |
229 | # arch_extents determines the extents of a given arch |
232 | arch_extents determines the extents of the given arch's face(s), linked |
230 | # bigfaces, linked faces and single faces are handled here |
233 | faces and single faces are handled here it returns (minx, miny, maxx, |
231 | # it returns (minx, miny, maxx, maxy) |
234 | maxy) |
|
|
235 | |
|
|
236 | =cut |
|
|
237 | |
232 | sub arch_extents { |
238 | sub arch_extents { |
233 | my ($a) = @_; |
239 | my ($a) = @_; |
234 | |
240 | |
235 | my $o = $ARCH{$a->{_name}} |
241 | my $o = $ARCH{$a->{_name}} |
236 | or return; |
242 | or return; |
… | |
… | |
264 | sub init($) { |
270 | sub init($) { |
265 | my ($cachedir) = @_; |
271 | my ($cachedir) = @_; |
266 | |
272 | |
267 | return if %ARCH; |
273 | return if %ARCH; |
268 | |
274 | |
|
|
275 | mkdir 0777, $cachedir; |
269 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
276 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
|
|
277 | } |
|
|
278 | |
|
|
279 | =item $type = arch_attr $arch |
|
|
280 | |
|
|
281 | Returns a hashref describing the object and its attributes. It can contain |
|
|
282 | the following keys: |
|
|
283 | |
|
|
284 | name the name, suitable for display purposes |
|
|
285 | ignore |
|
|
286 | attr |
|
|
287 | desc |
|
|
288 | use |
|
|
289 | section => [name => \%attr, name => \%attr] |
|
|
290 | import |
|
|
291 | |
|
|
292 | =cut |
|
|
293 | |
|
|
294 | sub arch_attr($) { |
|
|
295 | my ($arch) = @_; |
|
|
296 | |
|
|
297 | require Crossfire::Data; |
|
|
298 | |
|
|
299 | my $attr; |
|
|
300 | |
|
|
301 | if ($arch->{type} > 0) { |
|
|
302 | $attr = $Crossfire::Data::ATTR{$arch->{type}+0}; |
|
|
303 | } else { |
|
|
304 | $attr = $Crossfire::Data::TYPE{Misc}; |
|
|
305 | |
|
|
306 | type: |
|
|
307 | for (@Crossfire::Data::ATTR0) { |
|
|
308 | my $req = $_->{required} |
|
|
309 | or die "internal error: ATTR0 without 'required'"; |
|
|
310 | |
|
|
311 | while (my ($k, $v) = each %$req) { |
|
|
312 | next type |
|
|
313 | unless $arch->{$k} == $v; |
|
|
314 | } |
|
|
315 | |
|
|
316 | $attr = $_; |
|
|
317 | } |
|
|
318 | } |
|
|
319 | |
|
|
320 | $attr || \%Crossfire::Data::DEFAULT_ATTR; |
270 | } |
321 | } |
271 | |
322 | |
272 | sub arch_edit_sections { |
323 | sub arch_edit_sections { |
273 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
324 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
274 | # edit_type = 0; |
325 | # edit_type = 0; |
… | |
… | |
328 | # return(edit_type); |
379 | # return(edit_type); |
329 | # |
380 | # |
330 | # |
381 | # |
331 | } |
382 | } |
332 | |
383 | |
333 | $CACHEDIR ||= "$ENV{HOME}/.crossfire"; |
384 | $CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir; |
334 | |
385 | |
335 | init $CACHEDIR; |
386 | init $CACHEDIR; |
336 | |
387 | |
337 | =head1 AUTHOR |
388 | =head1 AUTHOR |
338 | |
389 | |