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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines