ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra.pm (file contents):
Revision 1.34 by root, Fri Feb 24 11:50:36 2006 UTC vs.
Revision 1.43 by root, Mon Mar 13 03:30:37 2006 UTC

14 14
15use Carp (); 15use Carp ();
16use File::Spec; 16use File::Spec;
17use List::Util qw(min max); 17use List::Util qw(min max);
18use Storable; 18use Storable;
19
20#XXX: The map_* procedures scream for a map-object
21 19
22our @EXPORT = 20our @EXPORT =
23 qw(read_pak read_arch %ARCH TILESIZE $TILE %FACE editor_archs arch_extents); 21 qw(read_pak read_arch %ARCH TILESIZE $TILE %FACE editor_archs arch_extents);
24 22
25our $LIB = $ENV{CROSSFIRE_LIBDIR} 23our $LIB = $ENV{CROSSFIRE_LIBDIR}
311sub arch_attr($) { 309sub arch_attr($) {
312 my ($arch) = @_; 310 my ($arch) = @_;
313 311
314 require Crossfire::Data; 312 require Crossfire::Data;
315 313
316 my $attr; 314 my $root;
317 315
318 if ($arch->{type} > 0) { 316 if ($arch->{type} > 0) {
319 $attr = $Crossfire::Data::ATTR{$arch->{type}+0}; 317 $root = $Crossfire::Data::ATTR{$arch->{type}+0};
320 } else { 318 } else {
321 $attr = $Crossfire::Data::TYPE{Misc}; 319 $root = $Crossfire::Data::TYPE{Misc};
322 320
323 type: 321 type:
324 for (@Crossfire::Data::ATTR0) { 322 for (@Crossfire::Data::ATTR0) {
325 my $req = $_->{required} 323 my $req = $_->{required}
326 or die "internal error: ATTR0 without 'required'"; 324 or die "internal error: ATTR0 without 'required'";
327 325
326 keys %$req;
328 while (my ($k, $v) = each %$req) { 327 while (my ($k, $v) = each %$req) {
329 next type 328 next type
330 unless $arch->{$k} == $v; 329 unless $arch->{$k} == $v;
331 } 330 }
332 331
333 $attr = $_; 332 $root = $_;
333 }
334 }
335
336 my $attr = { };
337
338 my @import = (\%Crossfire::Data::DEFAULT_ATTR, $root);
339 my (%ignore);
340 my (@section_order, %section, @attr_order);
341
342 while (my $type = shift @import) {
343 push @import, @{$type->{import} || []};
344
345 $attr->{$_} ||= $type->{$_}
346 for qw(name desc use);
347
348 for (@{$type->{ignore} || []}) {
349 $ignore{$_}++ for ref $_ ? @$_ : $_;
350 }
351
352 for ([general => ($type->{attr} || [])], @{$type->{section} || []}) {
353 my ($name, $attr) = @$_;
354 push @section_order, $name;
355 warn "$name, $attr\n";#d#
356 for (@$attr) {
357 my ($k, $v) = @$_;
358 push @attr_order, $k;
359 $section{$name}{$k} ||= $v;
334 } 360 }
361 }
335 } 362 }
336 363
337 $attr || \%Crossfire::Data::DEFAULT_ATTR; 364 $attr->{section} = [
365 map !exists $section{$_} ? () : do {
366 my $attr = delete $section{$_};
367
368 [
369 $_,
370 map exists $attr->{$_} && !$ignore{$_}
371 ? [$_ => delete $attr->{$_}] : (),
372 @attr_order
373 ]
374 },
375
376 exists $section{$_} ? [$_ => delete $section{$_}] : (),
377 @section_order
378 ];
379
380 $attr
338} 381}
339 382
340sub arch_edit_sections { 383sub arch_edit_sections {
341# if (edit_type == IGUIConstants.TILE_EDIT_NONE) 384# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
342# edit_type = 0; 385# edit_type = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines