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.80 by root, Tue Feb 6 22:08:14 2007 UTC vs.
Revision 1.82 by root, Tue Feb 6 23:53:26 2007 UTC

199 while (my ($k, $v) = each %attack_mask) { 199 while (my ($k, $v) = each %attack_mask) {
200 $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; 200 $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v;
201 } 201 }
202} 202}
203 203
204my %MATERIAL = reverse
205 paper => 1,
206 iron => 2,
207 glass => 4,
208 leather => 8,
209 wood => 16,
210 organic => 32,
211 stone => 64,
212 cloth => 128,
213 adamant => 256,
214 liquid => 512,
215 tin => 1024,
216 bone => 2048,
217 ice => 4096,
218;
219
204# object as in "Object xxx", i.e. archetypes 220# object as in "Object xxx", i.e. archetypes
205sub normalize_object($) { 221sub normalize_object($) {
206 my ($ob) = @_; 222 my ($ob) = @_;
223
224 # convert material bitset to materialname, if possible
225 if (exists $ob->{material}) {
226 if (!$ob->{material}) {
227 delete $ob->{material};
228 } elsif (exists $ob->{materialname}) {
229 if ($MATERIAL{$ob->{material}} eq $ob->{materialname}) {
230 delete $ob->{material};
231 } else {
232 warn "object $ob->{_name} has both materialname ($ob->{materialname}) and material ($ob->{material}) set.\n";
233 delete $ob->{material}; # assume materilname is more specific and nuke material
234 }
235 } else {
236 if (my $name = $MATERIAL{$ob->{material}}) {
237 delete $ob->{material};
238 $ob->{materialname} = $name;
239 }
240 }
241 }
207 242
208 # nuke outdated or never supported fields 243 # nuke outdated or never supported fields
209 delete @$ob{qw( 244 delete @$ob{qw(
210 can_knockback can_parry can_impale can_cut can_dam_armour 245 can_knockback can_parry can_impale can_cut can_dam_armour
211 can_apply pass_thru can_pass_thru 246 can_apply pass_thru can_pass_thru
421 push @{ $arc{anim} }, $_; 456 push @{ $arc{anim} }, $_;
422 } 457 }
423 } elsif (/^(\S+)\s*(.*)$/) { 458 } elsif (/^(\S+)\s*(.*)$/) {
424 $arc{lc $1} = $2; 459 $arc{lc $1} = $2;
425 } elsif (/^\s*#/) { 460 } elsif (/^\s*#/) {
426 $arc{_comment} .= $_; 461 $arc{_comment} .= "$_\n";
427 462
428 } elsif (/^\s*$/) { 463 } elsif (/^\s*$/) {
429 # 464 #
430 } else { 465 } else {
431 warn "$path: unparsable line '$_' in arch $arc{_name}"; 466 warn "$path: unparsable line '$_' in arch $arc{_name}";
437 472
438 while (<$fh>) { 473 while (<$fh>) {
439 s/\s+$//; 474 s/\s+$//;
440 if (/^more$/i) { 475 if (/^more$/i) {
441 $more = $prev; 476 $more = $prev;
442 } elsif (/^\s*#/) {
443 $comment .= $_;
444 } elsif (/^object (\S+)$/i) { 477 } elsif (/^object (\S+)$/i) {
445 my $name = $1; 478 my $name = $1;
446 my $arc = attr_thaw normalize_object $parse_block->(_name => $name, _comment => $comment); 479 my $arc = attr_thaw normalize_object $parse_block->(_name => $name, _comment => $comment);
480 undef $comment;
447 delete $arc{_comment} unless length $arc{_comment}; 481 delete $arc{_comment} unless length $arc{_comment};
448 $arc->{_atype} = 'object'; 482 $arc->{_atype} = 'object';
449 483
450 if ($more) { 484 if ($more) {
451 $more->{more} = $arc; 485 $more->{more} = $arc;
455 $prev = $arc; 489 $prev = $arc;
456 $more = undef; 490 $more = undef;
457 } elsif (/^arch (\S+)$/i) { 491 } elsif (/^arch (\S+)$/i) {
458 my $name = $1; 492 my $name = $1;
459 my $arc = attr_thaw normalize_arch $parse_block->(_name => $name, _comment => $comment); 493 my $arc = attr_thaw normalize_arch $parse_block->(_name => $name, _comment => $comment);
494 undef $comment;
460 delete $arc{_comment} unless length $arc{_comment}; 495 delete $arc{_comment} unless length $arc{_comment};
461 $arc->{_atype} = 'arch'; 496 $arc->{_atype} = 'arch';
462 497
463 if ($more) { 498 if ($more) {
464 $more->{more} = $arc; 499 $more->{more} = $arc;
474 push @{$toplevel->{lev_array}}, $_+0; 509 push @{$toplevel->{lev_array}}, $_+0;
475 } 510 }
476 } else { 511 } else {
477 $toplevel->{$1} = $2; 512 $toplevel->{$1} = $2;
478 } 513 }
514 } elsif (/^\s*#/) {
515 $comment .= "$_\n";
479 } elsif (/^\s*($|#)/) { 516 } elsif (/^\s*($|#)/) {
480 # 517 #
481 } else { 518 } else {
482 die "$path: unparseable top-level line '$_'"; 519 die "$path: unparseable top-level line '$_'";
483 } 520 }
503 if (exists $a{attack_movement_bits_0_3} or exists $a{attack_movement_bits_4_7}) { 540 if (exists $a{attack_movement_bits_0_3} or exists $a{attack_movement_bits_4_7}) {
504 $a{attack_movement} = (delete $a{attack_movement_bits_0_3}) 541 $a{attack_movement} = (delete $a{attack_movement_bits_0_3})
505 | (delete $a{attack_movement_bits_4_7}); 542 | (delete $a{attack_movement_bits_4_7});
506 } 543 }
507 544
545 if (my $comment = delete $a{_comment}) {
546 if ($comment =~ /[^\n\s#]/) {
547 $str .= $comment;
548 }
549 }
550
508 $str .= ((exists $a{_atype}) ? $a{_atype} : 'arch'). " $a{_name}\n"; 551 $str .= ((exists $a{_atype}) ? $a{_atype} : 'arch'). " $a{_name}\n";
509 552
510 my $inv = delete $a{inventory}; 553 my $inv = delete $a{inventory};
511 my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some 554 my $more = delete $a{more}; # arches do not support 'more', but old maps can contain some
512 my $anim = delete $a{anim}; 555 my $anim = delete $a{anim};
513 556
514 my @kv; 557 my @kv;
515 558
571 if $anim; 614 if $anim;
572 } 615 }
573 616
574 $str .= "end\n"; 617 $str .= "end\n";
575 618
576 if (($a{_atype} eq 'object') && $more) { 619 if ($a{_atype} eq 'object') {
620 if ($more) {
577 $str .= "\nmore\n"; 621 $str .= "more\n";
578 $append->($more) if $more; 622 $append->($more) if $more;
623 } else {
624 $str .= "\n";
625 }
579 } 626 }
580 }; 627 };
581 628
582 for (@$arch) { 629 for (@$arch) {
583 $append->($_); 630 $append->($_);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines