… | |
… | |
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 = |
… | |
… | |
269 | sub init($) { |
270 | sub init($) { |
270 | my ($cachedir) = @_; |
271 | my ($cachedir) = @_; |
271 | |
272 | |
272 | return if %ARCH; |
273 | return if %ARCH; |
273 | |
274 | |
|
|
275 | mkdir 0777, $cachedir; |
274 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
276 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
275 | } |
277 | } |
276 | |
278 | |
277 | =item $data = arch_attr $arch |
279 | =item $type = arch_attr $arch |
278 | |
280 | |
279 | Returns a hashref describing the object and its attributes. It can contain |
281 | Returns a hashref describing the object and its attributes. It can contain |
280 | the following keys: |
282 | the following keys: |
281 | |
283 | |
282 | name the name, suitable for display purposes |
284 | name the name, suitable for display purposes |
283 | ignore |
285 | ignore |
284 | attr |
286 | attr |
285 | desc |
287 | desc |
286 | use |
288 | use |
287 | section => [name => \%attr, name => \%attr] |
289 | section => [name => \%attr, name => \%attr] |
|
|
290 | import |
288 | |
291 | |
289 | =cut |
292 | =cut |
290 | |
293 | |
291 | sub arch_attr($) { |
294 | sub arch_attr($) { |
292 | my ($arch) = @_; |
295 | my ($arch) = @_; |
293 | |
296 | |
294 | require Crossfire::Data; |
297 | require Crossfire::Data; |
295 | |
298 | |
296 | my %attr; |
299 | my $attr; |
297 | |
300 | |
298 | if ($arch->{type} > 0) { |
301 | if ($arch->{type} > 0) { |
299 | %attr = %{ $Crossfire::Data::ATTR{$arch->{type}+0} || {} }; |
302 | $attr = $Crossfire::Data::ATTR{$arch->{type}+0}; |
300 | } else { |
303 | } else { |
301 | die; |
304 | $attr = $Crossfire::Data::TYPE{Misc}; |
302 | } |
|
|
303 | |
305 | |
304 | use PApp::Util; |
306 | type: |
305 | warn PApp::Util::dumpval \%attr; |
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; |
306 | } |
321 | } |
307 | |
322 | |
308 | sub arch_edit_sections { |
323 | sub arch_edit_sections { |
309 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
324 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
310 | # edit_type = 0; |
325 | # edit_type = 0; |
… | |
… | |
364 | # return(edit_type); |
379 | # return(edit_type); |
365 | # |
380 | # |
366 | # |
381 | # |
367 | } |
382 | } |
368 | |
383 | |
369 | $CACHEDIR ||= "$ENV{HOME}/.crossfire"; |
384 | $CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir; |
370 | |
385 | |
371 | init $CACHEDIR; |
386 | init $CACHEDIR; |
372 | |
387 | |
373 | =head1 AUTHOR |
388 | =head1 AUTHOR |
374 | |
389 | |