--- deliantra/Deliantra/Deliantra.pm 2006/09/04 17:58:51 1.72 +++ deliantra/Deliantra/Deliantra.pm 2007/02/06 22:08:14 1.80 @@ -6,7 +6,7 @@ package Crossfire; -our $VERSION = '0.9'; +our $VERSION = '0.96'; use strict; @@ -35,7 +35,9 @@ our $LIB = $ENV{CROSSFIRE_LIBDIR}; -our $VARDIR = $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir . "/crossfire"; +our $VARDIR = $ENV{HOME} ? "$ENV{HOME}/.crossfire" + : $ENV{AppData} ? "$ENV{APPDATA}/crossfire" + : File::Spec->tmpdir . "/crossfire"; mkdir $VARDIR, 0777; @@ -195,7 +197,7 @@ my ($ob, $mask, $value) = @_; while (my ($k, $v) = each %attack_mask) { - $ob->{"resist_$k"} += $value if $mask & $v; + $ob->{"resist_$k"} = min 100, max -100, $ob->{"resist_$k"} + $value if $mask & $v; } } @@ -291,6 +293,9 @@ } } + # some archetypes had "+3" instead of the canonical "3", so fix + $ob->{dam} *= 1 if exists $ob->{dam}; + $ob } @@ -381,6 +386,7 @@ my %arc; my ($more, $prev); + my $comment; open my $fh, "<:raw:perlio:utf8", $path or Carp::croak "$path: $!"; @@ -394,8 +400,10 @@ s/\s+$//; if (/^end$/i) { last; + } elsif (/^arch (\S+)$/i) { push @{ $arc{inventory} }, attr_thaw normalize_arch $parse_block->(_name => $1); + } elsif (/^lore$/i) { while (<$fh>) { last if /^endlore\s*$/i; @@ -414,7 +422,10 @@ } } elsif (/^(\S+)\s*(.*)$/) { $arc{lc $1} = $2; - } elsif (/^\s*($|#)/) { + } elsif (/^\s*#/) { + $arc{_comment} .= $_; + + } elsif (/^\s*$/) { # } else { warn "$path: unparsable line '$_' in arch $arc{_name}"; @@ -428,9 +439,12 @@ s/\s+$//; if (/^more$/i) { $more = $prev; + } elsif (/^\s*#/) { + $comment .= $_; } elsif (/^object (\S+)$/i) { my $name = $1; - my $arc = attr_thaw normalize_object $parse_block->(_name => $name); + my $arc = attr_thaw normalize_object $parse_block->(_name => $name, _comment => $comment); + delete $arc{_comment} unless length $arc{_comment}; $arc->{_atype} = 'object'; if ($more) { @@ -442,7 +456,8 @@ $more = undef; } elsif (/^arch (\S+)$/i) { my $name = $1; - my $arc = attr_thaw normalize_arch $parse_block->(_name => $name); + my $arc = attr_thaw normalize_arch $parse_block->(_name => $name, _comment => $comment); + delete $arc{_comment} unless length $arc{_comment}; $arc->{_atype} = 'arch'; if ($more) { @@ -599,8 +614,11 @@ my $o = $ARCH{$a->{_name}} or return; - my $face = $FACE{$a->{face} || $o->{face} || "blank.111"} - or (warn "no face data found for arch '$a->{_name}'"), return; + my $face = $FACE{$a->{face} || $o->{face} || "blank.111"}; + unless ($face) { + $face = $FACE{"blank.x11"} + or (warn "no face data found for arch '$a->{_name}'"), return; + } if ($face->{w} > 1 || $face->{h} > 1) { # bigface