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.13 by root, Thu Feb 9 20:54:42 2006 UTC vs.
Revision 1.14 by root, Sat Feb 11 16:17:14 2006 UTC

29sub TILESIZE (){ 32 } 29sub TILESIZE (){ 32 }
30 30
31our $ARCH; 31our $ARCH;
32 32
33our %FIELD_MULTILINE = ( 33our %FIELD_MULTILINE = (
34 msg => "endmsg", 34 msg => "endmsg",
35 lore => "endlore",
35); 36);
36 37
37# not used yet, maybe alphabetical is ok 38# not used yet, maybe alphabetical is ok
38our @FIELD_ORDER = (qw(name name_pl)); 39our @FIELD_ORDER = (qw(name name_pl));
39 40
40# not used yet, AND NOT CHECKED, should also be BY TYPE 41sub MOVE_WALK (){ 0x1 }
41our %FIELD_NORMALIZE = ( 42sub MOVE_FLY_LOW (){ 0x2 }
43sub MOVE_FLY_HIGH (){ 0x4 }
44sub MOVE_FLYING (){ 0x6 }
45sub MOVE_SWIM (){ 0x8 }
46sub MOVE_ALL (){ 0xf }
47
48sub normalize_arch($) {
49 my ($ob) = @_;
50
51 my $arch = $ARCH->{$ob->{_name}}
52 or (warn "$ob->{_name}: no such archetype", return $ob);
53
54 delete $ob->{$_} for qw(can_knockback can_parry can_impale can_cut can_dam_armour can_apply);
55
56 if ($arch->{type} == 22) { # map
57 my %normalize = (
42 "enter_x" => "hp", 58 "enter_x" => "hp",
43 "enter_y" => "sp", 59 "enter_y" => "sp",
44); 60 "width" => "x",
61 "height" => "y",
62 "reset_timeout" => "weight",
63 "swap_time" => "value",
64 "difficulty" => "level",
65 "darkness" => "invisible",
66 "fixed_resettime" => "stand_still",
67 );
68
69 while (my ($k2, $k1) = each %normalize) {
70 if (defined (my $v = delete $ob->{$k1})) {
71 $ob->{$k2} = $v;
72 }
73 }
74 }
75
76 if (defined (my $v = delete $ob->{no_pass})) {
77 $ob->{move_block} = $v ? MOVE_ALL : 0;
78 }
79 if (defined (my $v = delete $ob->{walk_on})) {
80 $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK
81 : $ob->{move_on} & ~MOVE_WALK;
82 }
83 if (defined (my $v = delete $ob->{walk_off})) {
84 $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK
85 : $ob->{move_off} & ~MOVE_WALK;
86 }
87 if (defined (my $v = delete $ob->{fly_on})) {
88 $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW
89 : $ob->{move_on} & ~MOVE_FLY_LOW;
90 }
91 if (defined (my $v = delete $ob->{fly_off})) {
92 $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW
93 : $ob->{move_off} & ~MOVE_FLY_LOW;
94 }
95 if (defined (my $v = delete $ob->{flying})) {
96 $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW
97 : $ob->{move_type} & ~MOVE_FLY_LOW;
98 }
99
100 # if value matches archetype default, delete
101 while (my ($k, $v) = each %$ob) {
102 if (exists $arch->{$k} and $arch->{$k} eq $v) {
103 delete $ob->{$k};
104 }
105 }
106
107 $ob
108}
45 109
46sub read_pak($;$) { 110sub read_pak($;$) {
47 my ($path, $cache) = @_; 111 my ($path, $cache) = @_;
48 112
49 eval { 113 eval {
88 while (<$fh>) { 152 while (<$fh>) {
89 s/\s+$//; 153 s/\s+$//;
90 if (/^end$/i) { 154 if (/^end$/i) {
91 last; 155 last;
92 } elsif (/^arch (\S+)$/) { 156 } elsif (/^arch (\S+)$/) {
93 push @{ $arc{inventory} }, $parse_block->(_name => $1); 157 push @{ $arc{inventory} }, normalize_arch $parse_block->(_name => $1);
94 } elsif (/^lore$/) { 158 } elsif (/^lore$/) {
95 while (<$fh>) { 159 while (<$fh>) {
96 last if /^endlore\s*$/i; 160 last if /^endlore\s*$/i;
97 $arc{lore} .= $_; 161 $arc{lore} .= $_;
98 } 162 }
127 $arc{$name} = $arc; 191 $arc{$name} = $arc;
128 } 192 }
129 $prev = $arc; 193 $prev = $arc;
130 $more = undef; 194 $more = undef;
131 } elsif (/^arch (\S+)$/i) { 195 } elsif (/^arch (\S+)$/i) {
132 push @{ $arc{arch} }, $parse_block->(_name => $1); 196 push @{ $arc{arch} }, normalize_arch $parse_block->(_name => $1);
133 } elsif (/^\s*($|#)/) { 197 } elsif (/^\s*($|#)/) {
134 # 198 #
135 } else { 199 } else {
136 warn "$path: unparseable top-level line '$_'"; 200 warn "$path: unparseable top-level line '$_'";
137 } 201 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines