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.45 by root, Thu Mar 16 01:13:02 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}
265 my ($a) = @_; 263 my ($a) = @_;
266 264
267 my $o = $ARCH{$a->{_name}} 265 my $o = $ARCH{$a->{_name}}
268 or return; 266 or return;
269 267
270 my $face = $FACE{$a->{face} || $o->{face}} 268 my $face = $FACE{$a->{face} || $o->{face} || "blank.111"}
271 or (warn "no face data found for arch '$a->{_name}'"), return; 269 or (warn "no face data found for arch '$a->{_name}'"), return;
272 270
273 if ($face->{w} > 1 || $face->{h} > 1) { 271 if ($face->{w} > 1 || $face->{h} > 1) {
274 # bigface 272 # bigface
275 return (0, 0, $face->{w} - 1, $face->{h} - 1); 273 return (0, 0, $face->{w} - 1, $face->{h} - 1);
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 for (@$attr) {
356 my ($k, $v) = @$_;
357 push @attr_order, $k;
358 $section{$name}{$k} ||= $v;
334 } 359 }
360 }
335 } 361 }
336 362
337 $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->{$_} && !$ignore{$_}
370 ? [$_ => delete $attr->{$_}] : (),
371 @attr_order
372 ]
373 },
374
375 exists $section{$_} ? [$_ => delete $section{$_}] : (),
376 @section_order
377 ];
378
379 $attr
338} 380}
339 381
340sub arch_edit_sections { 382sub arch_edit_sections {
341# if (edit_type == IGUIConstants.TILE_EDIT_NONE) 383# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
342# edit_type = 0; 384# edit_type = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines