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.47 by root, Thu Mar 16 01:42:22 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);
307 import 305 import
308 306
309=cut 307=cut
310 308
311sub arch_attr($) { 309sub arch_attr($) {
312 my ($arch) = @_; 310 my ($obj) = @_;
313 311
314 require Crossfire::Data; 312 require Crossfire::Data;
315 313
316 my $attr; 314 my $root;
315
316 my $arch = $ARCH{ $obj->{_name} };
317 my $type = $obj->{type} || $arch->{type};
317 318
318 if ($arch->{type} > 0) { 319 if ($type > 0) {
319 $attr = $Crossfire::Data::ATTR{$arch->{type}+0}; 320 $root = $Crossfire::Data::ATTR{$type};
320 } else { 321 } else {
321 $attr = $Crossfire::Data::TYPE{Misc}; 322 $root = $Crossfire::Data::TYPE{Misc};
322 323
323 type: 324 type:
324 for (@Crossfire::Data::ATTR0) { 325 for (@Crossfire::Data::ATTR0) {
325 my $req = $_->{required} 326 my $req = $_->{required}
326 or die "internal error: ATTR0 without 'required'"; 327 or die "internal error: ATTR0 without 'required'";
327 328
329 keys %$req;
328 while (my ($k, $v) = each %$req) { 330 while (my ($k, $v) = each %$req) {
329 next type 331 next type
330 unless $arch->{$k} == $v; 332 unless $obj->{$k} eq $v || $arch->{$k} eq $v;
331 } 333 }
332 334
333 $attr = $_; 335 $root = $_;
334 } 336 }
337 }
338
339 my $attr = { };
340
341 my @import = ($root);
335 } 342
336
337 $attr || \%Crossfire::Data::DEFAULT_ATTR; 343 unshift @import, \%Crossfire::Data::DEFAULT_ATTR
344 unless $type == 116;
345
346 my (%ignore);
347 my (@section_order, %section, @attr_order);
348
349 while (my $type = shift @import) {
350 push @import, @{$type->{import} || []};
351
352 $attr->{$_} ||= $type->{$_}
353 for qw(name desc use);
354
355 for (@{$type->{ignore} || []}) {
356 $ignore{$_}++ for ref $_ ? @$_ : $_;
357 }
358
359 for ([general => ($type->{attr} || [])], @{$type->{section} || []}) {
360 my ($name, $attr) = @$_;
361 push @section_order, $name;
362 for (@$attr) {
363 my ($k, $v) = @$_;
364 push @attr_order, $k;
365 $section{$name}{$k} ||= $v;
366 }
367 }
368 }
369
370 $attr->{section} = [
371 map !exists $section{$_} ? () : do {
372 my $attr = delete $section{$_};
373
374 [
375 $_,
376 map exists $attr->{$_} && !$ignore{$_}
377 ? [$_ => delete $attr->{$_}] : (),
378 @attr_order
379 ]
380 },
381
382 exists $section{$_} ? [$_ => delete $section{$_}] : (),
383 @section_order
384 ];
385
386 $attr
338} 387}
339 388
340sub arch_edit_sections { 389sub arch_edit_sections {
341# if (edit_type == IGUIConstants.TILE_EDIT_NONE) 390# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
342# edit_type = 0; 391# edit_type = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines