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