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.35 by root, Sun Mar 12 16:23:56 2006 UTC vs.
Revision 1.36 by root, Sun Mar 12 23:21:11 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'";
329 while (my ($k, $v) = each %$req) { 327 while (my ($k, $v) = each %$req) {
330 next type 328 next type
331 unless $arch->{$k} == $v; 329 unless $arch->{$k} == $v;
332 } 330 }
333 331
334 $attr = $_; 332 $root = $_;
333 }
334 }
335
336 my $attr = { };
337
338 my @import = $root || \%Crossfire::Data::DEFAULT_ATTR;
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 for (@$attr) {
356 my ($k, $v) = @$_;
357 push @attr_order, $k;
358 $section{$name}{$k} ||= $v;
335 } 359 }
360 }
336 } 361 }
337 362
338 $attr || \%Crossfire::Data::DEFAULT_ATTR; 363 $attr->{section} = [
364 map !exists $section{$_} ? () : do {
365 my $attr = delete $section{$_};
366
367 [
368 $_,
369 map exists $attr->{$_} ? [$_ => delete $attr->{$_}] : (),
370 @attr_order
371 ]
372 },
373
374 exists $section{$_} ? [$_ => delete $section{$_}] : (),
375 @section_order
376 ];
377
378 use PApp::Util;
379 warn PApp::Util::dumpval $attr;
380
381 $attr
339} 382}
340 383
341sub arch_edit_sections { 384sub arch_edit_sections {
342# if (edit_type == IGUIConstants.TILE_EDIT_NONE) 385# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
343# edit_type = 0; 386# edit_type = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines