… | |
… | |
10 | |
10 | |
11 | use strict; |
11 | use strict; |
12 | |
12 | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
|
|
15 | use Carp (); |
|
|
16 | use File::Spec; |
|
|
17 | use List::Util qw(min max); |
15 | use Storable; |
18 | use Storable; |
16 | |
19 | |
17 | our @EXPORT = qw(read_pak read_arch arch2map $ARCH TILESIZE editor_archs arch2pickmap arch_extends); |
20 | our @EXPORT = |
|
|
21 | qw(read_pak read_arch %ARCH TILESIZE $TILE %FACE editor_archs arch_extents); |
18 | |
22 | |
19 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
23 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
20 | or die "\$CROSSFIRE_LIBDIR must be set\n"; |
24 | or Carp::croak "\$CROSSFIRE_LIBDIR must be set\n"; |
21 | |
25 | |
22 | sub TILESIZE (){ 32 } |
26 | sub TILESIZE (){ 32 } |
23 | |
27 | |
|
|
28 | our $VARDIR; |
24 | our $ARCH; |
29 | our %ARCH; |
|
|
30 | our %FACE; |
|
|
31 | our $TILE; |
|
|
32 | |
|
|
33 | our %FIELD_MULTILINE = ( |
|
|
34 | msg => "endmsg", |
|
|
35 | lore => "endlore", |
|
|
36 | ); |
|
|
37 | |
|
|
38 | # not used yet, maybe alphabetical is ok |
|
|
39 | our @FIELD_ORDER = (qw(name name_pl)); |
|
|
40 | |
|
|
41 | sub MOVE_WALK (){ 0x1 } |
|
|
42 | sub MOVE_FLY_LOW (){ 0x2 } |
|
|
43 | sub MOVE_FLY_HIGH (){ 0x4 } |
|
|
44 | sub MOVE_FLYING (){ 0x6 } |
|
|
45 | sub MOVE_SWIM (){ 0x8 } |
|
|
46 | sub MOVE_ALL (){ 0xf } |
|
|
47 | |
|
|
48 | sub load_ref($) { |
|
|
49 | my ($path) = @_; |
|
|
50 | |
|
|
51 | open my $fh, "<", $path |
|
|
52 | or die "$path: $!"; |
|
|
53 | binmode $fh; |
|
|
54 | local $/; |
|
|
55 | |
|
|
56 | Storable::thaw <$fh> |
|
|
57 | } |
|
|
58 | |
|
|
59 | sub save_ref($$) { |
|
|
60 | my ($ref, $path) = @_; |
|
|
61 | |
|
|
62 | open my $fh, ">", "$path~" |
|
|
63 | or die "$path~: $!"; |
|
|
64 | binmode $fh; |
|
|
65 | print $fh Storable::freeze $ref; |
|
|
66 | close $fh; |
|
|
67 | rename "$path~", $path |
|
|
68 | or die "$path: $!"; |
|
|
69 | } |
|
|
70 | |
|
|
71 | sub normalize_arch($) { |
|
|
72 | my ($ob) = @_; |
|
|
73 | |
|
|
74 | my $arch = $ARCH{$ob->{_name}} |
|
|
75 | or (warn "$ob->{_name}: no such archetype", return $ob); |
|
|
76 | |
|
|
77 | delete $ob->{$_} for qw(can_knockback can_parry can_impale can_cut can_dam_armour can_apply); |
|
|
78 | |
|
|
79 | if ($arch->{type} == 22) { # map |
|
|
80 | my %normalize = ( |
|
|
81 | "enter_x" => "hp", |
|
|
82 | "enter_y" => "sp", |
|
|
83 | "width" => "x", |
|
|
84 | "height" => "y", |
|
|
85 | "reset_timeout" => "weight", |
|
|
86 | "swap_time" => "value", |
|
|
87 | "difficulty" => "level", |
|
|
88 | "darkness" => "invisible", |
|
|
89 | "fixed_resettime" => "stand_still", |
|
|
90 | ); |
|
|
91 | |
|
|
92 | while (my ($k2, $k1) = each %normalize) { |
|
|
93 | if (defined (my $v = delete $ob->{$k1})) { |
|
|
94 | $ob->{$k2} = $v; |
|
|
95 | } |
|
|
96 | } |
|
|
97 | } |
|
|
98 | |
|
|
99 | if (defined (my $v = delete $ob->{no_pass})) { |
|
|
100 | $ob->{move_block} = $v ? MOVE_ALL : 0; |
|
|
101 | } |
|
|
102 | if (defined (my $v = delete $ob->{walk_on})) { |
|
|
103 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_WALK |
|
|
104 | : $ob->{move_on} & ~MOVE_WALK; |
|
|
105 | } |
|
|
106 | if (defined (my $v = delete $ob->{walk_off})) { |
|
|
107 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_WALK |
|
|
108 | : $ob->{move_off} & ~MOVE_WALK; |
|
|
109 | } |
|
|
110 | if (defined (my $v = delete $ob->{fly_on})) { |
|
|
111 | $ob->{move_on} = $v ? $ob->{move_on} | MOVE_FLY_LOW |
|
|
112 | : $ob->{move_on} & ~MOVE_FLY_LOW; |
|
|
113 | } |
|
|
114 | if (defined (my $v = delete $ob->{fly_off})) { |
|
|
115 | $ob->{move_off} = $v ? $ob->{move_off} | MOVE_FLY_LOW |
|
|
116 | : $ob->{move_off} & ~MOVE_FLY_LOW; |
|
|
117 | } |
|
|
118 | if (defined (my $v = delete $ob->{flying})) { |
|
|
119 | $ob->{move_type} = $v ? $ob->{move_type} | MOVE_FLY_LOW |
|
|
120 | : $ob->{move_type} & ~MOVE_FLY_LOW; |
|
|
121 | } |
|
|
122 | |
|
|
123 | # if value matches archetype default, delete |
|
|
124 | while (my ($k, $v) = each %$ob) { |
|
|
125 | if (exists $arch->{$k} and $arch->{$k} eq $v) { |
|
|
126 | next if $k eq "_name"; |
|
|
127 | delete $ob->{$k}; |
|
|
128 | } |
|
|
129 | } |
|
|
130 | |
|
|
131 | $ob |
|
|
132 | } |
25 | |
133 | |
26 | sub read_pak($;$) { |
134 | sub read_pak($;$) { |
27 | my ($path, $cache) = @_; |
135 | my ($path, $cache) = @_; |
28 | |
136 | |
29 | eval { |
137 | eval { |
30 | defined $cache |
138 | defined $cache |
31 | && -M $cache < -M $path |
139 | && -M $cache < -M $path |
32 | && Storable::retrieve $cache |
140 | && load_ref $cache |
33 | } or do { |
141 | } or do { |
34 | my %pak; |
142 | my %pak; |
35 | |
143 | |
36 | open my $fh, "<:raw", $path |
144 | open my $fh, "<", $path |
37 | or die "$_[0]: $!"; |
145 | or Carp::croak "$_[0]: $!"; |
|
|
146 | binmode $fh; |
38 | while (<$fh>) { |
147 | while (<$fh>) { |
39 | my ($type, $id, $len, $path) = split; |
148 | my ($type, $id, $len, $path) = split; |
40 | $path =~ s/.*\///; |
149 | $path =~ s/.*\///; |
41 | read $fh, $pak{$path}, $len; |
150 | read $fh, $pak{$path}, $len; |
42 | } |
151 | } |
43 | |
152 | |
44 | Storable::nstore \%pak, $cache |
153 | save_ref \%pak, $cache |
45 | if defined $cache; |
154 | if defined $cache; |
46 | |
155 | |
47 | \%pak |
156 | \%pak |
48 | } |
157 | } |
49 | } |
158 | } |
… | |
… | |
52 | my ($path, $cache) = @_; |
161 | my ($path, $cache) = @_; |
53 | |
162 | |
54 | eval { |
163 | eval { |
55 | defined $cache |
164 | defined $cache |
56 | && -M $cache < -M $path |
165 | && -M $cache < -M $path |
57 | && Storable::retrieve $cache |
166 | && load_ref $cache |
58 | } or do { |
167 | } or do { |
59 | my %arc; |
168 | my %arc; |
60 | my ($more, $prev); |
169 | my ($more, $prev); |
61 | |
170 | |
62 | open my $fh, "<:raw", $path |
171 | open my $fh, "<", $path |
63 | or die "$path: $!"; |
172 | or Carp::croak "$path: $!"; |
|
|
173 | |
|
|
174 | binmode $fh; |
64 | |
175 | |
65 | my $parse_block; $parse_block = sub { |
176 | my $parse_block; $parse_block = sub { |
66 | my %arc = @_; |
177 | my %arc = @_; |
67 | |
178 | |
68 | while (<$fh>) { |
179 | while (<$fh>) { |
69 | s/\s+$//; |
180 | s/\s+$//; |
70 | if (/^end$/i) { |
181 | if (/^end$/i) { |
71 | last; |
182 | last; |
72 | } elsif (/^arch (\S+)$/) { |
183 | } elsif (/^arch (\S+)$/) { |
73 | push @{ $arc{inventory} }, $parse_block->(_name => $1); |
184 | push @{ $arc{inventory} }, normalize_arch $parse_block->(_name => $1); |
74 | } elsif (/^lore$/) { |
185 | } elsif (/^lore$/) { |
75 | while (<$fh>) { |
186 | while (<$fh>) { |
76 | last if /^endlore\s*$/i; |
187 | last if /^endlore\s*$/i; |
77 | $arc{lore} .= $_; |
188 | $arc{lore} .= $_; |
78 | } |
189 | } |
… | |
… | |
107 | $arc{$name} = $arc; |
218 | $arc{$name} = $arc; |
108 | } |
219 | } |
109 | $prev = $arc; |
220 | $prev = $arc; |
110 | $more = undef; |
221 | $more = undef; |
111 | } elsif (/^arch (\S+)$/i) { |
222 | } elsif (/^arch (\S+)$/i) { |
112 | push @{ $arc{arch} }, $parse_block->(_name => $1); |
223 | push @{ $arc{arch} }, normalize_arch $parse_block->(_name => $1); |
113 | } elsif (/^\s*($|#)/) { |
224 | } elsif (/^\s*($|#)/) { |
114 | # |
225 | # |
115 | } else { |
226 | } else { |
116 | warn "$path: unparseable top-level line '$_'"; |
227 | warn "$path: unparseable top-level line '$_'"; |
117 | } |
228 | } |
118 | } |
229 | } |
119 | |
230 | |
120 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
231 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
121 | |
232 | |
122 | Storable::nstore \%arc, $cache |
233 | save_ref \%arc, $cache |
123 | if defined $cache; |
234 | if defined $cache; |
124 | |
235 | |
125 | \%arc |
236 | \%arc |
126 | } |
237 | } |
127 | } |
238 | } |
… | |
… | |
130 | # NOTE: the arrays in the hash values are references to |
241 | # NOTE: the arrays in the hash values are references to |
131 | # the archs from $ARCH |
242 | # the archs from $ARCH |
132 | sub editor_archs { |
243 | sub editor_archs { |
133 | my %paths; |
244 | my %paths; |
134 | |
245 | |
135 | for (keys %$ARCH) { |
246 | for (keys %ARCH) { |
136 | my $arch = $ARCH->{$_}; |
247 | my $arch = $ARCH{$_}; |
137 | push @{$paths{$arch->{editor_folder}}}, \$arch; |
248 | push @{$paths{$arch->{editor_folder}}}, \$arch; |
138 | } |
249 | } |
139 | |
250 | |
140 | return \%paths; |
251 | \%paths |
141 | } |
252 | } |
142 | |
253 | |
143 | # arch_extends determines how the arch looks like on the map, |
254 | =item ($minx, $miny, $maxx, $maxy) = arch_extents $arch |
144 | # bigfaces, linked faces and single faces are handled here |
255 | |
145 | # it returns (<xoffset>, <yoffset>, <width>, <height>) |
256 | arch_extents determines the extents of the given arch's face(s), linked |
146 | # NOTE: non rectangular linked faces are not considered |
257 | faces and single faces are handled here it returns (minx, miny, maxx, |
|
|
258 | maxy) |
|
|
259 | |
|
|
260 | =cut |
|
|
261 | |
147 | sub arch_extends { |
262 | sub arch_extents { |
148 | my ($a) = @_; |
263 | my ($a) = @_; |
149 | |
264 | |
150 | my $TC = \%Crossfire::Tilecache::TILECACHE; |
265 | my $o = $ARCH{$a->{_name}} |
151 | |
|
|
152 | my $facename = |
|
|
153 | $a->{face} || $ARCH->{$a->{_name}}->{face} |
|
|
154 | or return (); |
266 | or return; |
155 | |
267 | |
156 | my $tile = $TC->{$facename} |
268 | my $face = $FACE{$a->{face} || $o->{face}} |
157 | or (warn "no gfx found for arch '$facename' in arch_size ()"), return; |
269 | or (warn "no face data found for arch '$a->{_name}'"), return; |
158 | |
270 | |
159 | if ($tile->{w} > 1 || $tile->{h} > 1) { |
271 | if ($face->{w} > 1 || $face->{h} > 1) { |
160 | # bigfaces |
272 | # bigface |
161 | return (0, 0, $tile->{w}, $tile->{h}); |
273 | return (0, 0, $face->{w} - 1, $face->{h} - 1); |
162 | |
274 | |
163 | } elsif ($a->{more}) { |
275 | } elsif ($o->{more}) { |
164 | # linked faces |
276 | # linked face |
165 | my ($miw, $mih, $maw, $mah) = (0, 0, 0, 0); |
277 | my ($minx, $miny, $maxx, $maxy) = ($o->{x}, $o->{y}) x 2; |
166 | do { |
|
|
167 | $miw > (0 + $a->{x}) and $miw = $a->{x}; |
|
|
168 | $mih > (0 + $a->{y}) and $mih = $a->{y}; |
|
|
169 | $maw < (0 + $a->{x}) and $maw = $a->{x}; |
|
|
170 | $mah < (0 + $a->{y}) and $mah = $a->{y}; |
|
|
171 | } while $a = $a->{more}; |
|
|
172 | |
278 | |
173 | return ($miw, $mih, ($maw - $miw) + 1, ($mah - $mih) + 1) |
279 | for (; $o; $o = $o->{more}) { |
|
|
280 | $minx = min $minx, $o->{x}; |
|
|
281 | $miny = min $miny, $o->{y}; |
|
|
282 | $maxx = max $maxx, $o->{x}; |
|
|
283 | $maxy = max $maxy, $o->{y}; |
|
|
284 | } |
|
|
285 | |
|
|
286 | return ($minx, $miny, $maxx, $maxy); |
174 | |
287 | |
175 | } else { |
288 | } else { |
176 | # single face |
289 | # single face |
177 | return (0, 0, 1, 1); |
290 | return (0, 0, 0, 0); |
178 | } |
291 | } |
179 | } |
292 | } |
180 | |
293 | |
181 | # arch2pickmap forms a list of archs to a pickmap |
294 | =item $type = arch_attr $arch |
182 | sub arch2pickmap { |
295 | |
|
|
296 | Returns a hashref describing the object and its attributes. It can contain |
|
|
297 | the following keys: |
|
|
298 | |
|
|
299 | name the name, suitable for display purposes |
|
|
300 | ignore |
|
|
301 | attr |
|
|
302 | desc |
|
|
303 | use |
|
|
304 | section => [name => \%attr, name => \%attr] |
|
|
305 | import |
|
|
306 | |
|
|
307 | =cut |
|
|
308 | |
|
|
309 | sub arch_attr($) { |
183 | my ($archs, $w) = @_; |
310 | my ($arch) = @_; |
184 | |
311 | |
185 | # sort archs alphabetiacally |
312 | require Crossfire::Data; |
186 | my $archs = [ sort { ${$a}->{_name} cmp ${$b}->{_name} } @$archs ]; |
|
|
187 | |
313 | |
188 | $w ||= 10; # default width |
314 | my $root; |
189 | my $num = @$archs; |
|
|
190 | my $map = { }; |
|
|
191 | # overall placement coords |
|
|
192 | my $x = 0; |
|
|
193 | my $y = 0; |
|
|
194 | |
315 | |
195 | my ($maxh, $maxw) = (0, 0); # maximum sizes, to set map width/height later |
316 | if ($arch->{type} > 0) { |
196 | my $drawn_archs = 1; # line-break counter |
317 | $root = $Crossfire::Data::ATTR{$arch->{type}+0}; |
197 | my $max_line_height = 1; |
318 | } else { |
|
|
319 | $root = $Crossfire::Data::TYPE{Misc}; |
198 | |
320 | |
199 | for (my $i = 0; $i < $num; $i++) { |
321 | type: |
|
|
322 | for (@Crossfire::Data::ATTR0) { |
|
|
323 | my $req = $_->{required} |
|
|
324 | or die "internal error: ATTR0 without 'required'"; |
200 | |
325 | |
201 | defined ${$archs->[$i]}->{face} or next; |
326 | keys %$req; |
202 | |
327 | while (my ($k, $v) = each %$req) { |
203 | # check whether this tile was already written (see below at (b)) |
328 | next type |
204 | unless (defined $map->{map}[$x][$y]) { |
329 | unless $arch->{$k} == $v; |
205 | |
|
|
206 | my ($xoffs, $yoffs, $arch_w, $arch_h) = arch_extends (${$archs->[$i]}); |
|
|
207 | |
|
|
208 | # these are special placement coords, for chained faces which |
|
|
209 | # have a special placement offset |
|
|
210 | my ($place_x, $place_y) = ($x, $y); |
|
|
211 | $xoffs < 0 and |
|
|
212 | $place_x += -$xoffs; |
|
|
213 | $yoffs < 0 and |
|
|
214 | $place_y += -$yoffs; |
|
|
215 | |
|
|
216 | # iterate over the tiles this arch takes |
|
|
217 | # NOTE: Chained archs are maybe not a rectangle, but i don't care |
|
|
218 | # much for that on pickmaps |
|
|
219 | |
|
|
220 | for (my $xi = 0; $xi < $arch_w; $xi++) { |
|
|
221 | for (my $yi = 0; $yi < $arch_h; $yi++) { |
|
|
222 | |
|
|
223 | my ($lx, $ly) = ($x + $xi, $y + $yi); |
|
|
224 | |
|
|
225 | if ($lx == $place_x and $ly == $place_y) { |
|
|
226 | push @{$map->{map}[$place_x][$place_y]}, my $a = ${$archs->[$i]}; |
|
|
227 | |
|
|
228 | } else { |
|
|
229 | |
|
|
230 | # (b): here we set occupied tiles, but without the arch |
|
|
231 | $map->{map}[$lx][$ly] = []; |
|
|
232 | } |
|
|
233 | } |
|
|
234 | } |
330 | } |
235 | $drawn_archs++; |
|
|
236 | |
331 | |
237 | $x += $arch_w - 1; |
332 | $root = $_; |
238 | $max_line_height < $arch_h |
333 | } |
239 | and $max_line_height = $arch_h; |
334 | } |
240 | |
335 | |
241 | } else { |
336 | my $attr = { }; |
|
|
337 | |
|
|
338 | my @import = $root || \%Crossfire::Data::DEFAULT_ATTR; |
|
|
339 | my (%ignore); |
|
|
340 | my (@section_order, %section, @attr_order); |
|
|
341 | |
|
|
342 | while (my $type = shift @import) { |
|
|
343 | push @import, @{$type->{import} || []}; |
|
|
344 | |
|
|
345 | $attr->{$_} ||= $type->{$_} |
|
|
346 | for qw(name desc use); |
|
|
347 | |
|
|
348 | for (@{$type->{ignore} || []}) { |
|
|
349 | $ignore{$_}++ for ref $_ ? @$_ : $_; |
|
|
350 | } |
|
|
351 | |
|
|
352 | for ([general => ($type->{attr} || {})], @{$type->{section} || []}) { |
|
|
353 | my ($name, $attr) = @$_; |
|
|
354 | push @section_order, $name; |
|
|
355 | for (@$attr) { |
|
|
356 | my ($k, $v) = @$_; |
|
|
357 | push @attr_order, $k; |
|
|
358 | $section{$name}{$k} ||= $v; |
|
|
359 | } |
|
|
360 | } |
|
|
361 | } |
|
|
362 | |
|
|
363 | $attr->{section} = [ |
|
|
364 | map !exists $section{$_} ? () : do { |
|
|
365 | my $attr = delete $section{$_}; |
|
|
366 | |
|
|
367 | [ |
|
|
368 | $_, |
|
|
369 | map exists $attr->{$_} && !ignore{$_} ? [$_ => delete $attr->{$_}] : (), |
|
|
370 | @attr_order |
|
|
371 | ] |
|
|
372 | }, |
242 | $i--; |
373 | |
|
|
374 | exists $section{$_} ? [$_ => delete $section{$_}] : (), |
|
|
375 | @section_order |
|
|
376 | ]; |
|
|
377 | |
|
|
378 | use PApp::Util; |
|
|
379 | warn PApp::Util::dumpval $attr; |
|
|
380 | |
|
|
381 | $attr |
|
|
382 | } |
|
|
383 | |
|
|
384 | sub arch_edit_sections { |
|
|
385 | # if (edit_type == IGUIConstants.TILE_EDIT_NONE) |
|
|
386 | # edit_type = 0; |
|
|
387 | # else if (edit_type != 0) { |
|
|
388 | # // all flags from 'check_type' must be unset in this arch because they get recalculated now |
|
|
389 | # edit_type &= ~check_type; |
243 | } |
390 | # } |
244 | |
391 | # |
245 | |
|
|
246 | $x++; |
|
|
247 | |
|
|
248 | if ($x > $w) { |
|
|
249 | |
|
|
250 | $y += $max_line_height; |
|
|
251 | $max_line_height = 1; |
|
|
252 | $x = 0; |
|
|
253 | } |
392 | # } |
254 | |
393 | # if ((check_type & IGUIConstants.TILE_EDIT_MONSTER) != 0 && |
255 | $maxw < ($x + 1) and $maxw = $x + 1; |
394 | # getAttributeValue("alive", defarch) == 1 && |
256 | $maxh < ($y + 1) and $maxh = $y + 1; |
395 | # (getAttributeValue("monster", defarch) == 1 || |
257 | } |
396 | # getAttributeValue("generator", defarch) == 1)) { |
258 | |
397 | # // Monster: monsters/npcs/generators |
259 | $map->{height} = $maxh; |
398 | # edit_type |= IGUIConstants.TILE_EDIT_MONSTER; |
260 | $map->{width} = $maxw; |
|
|
261 | |
|
|
262 | return $map; |
|
|
263 | } |
|
|
264 | |
|
|
265 | sub arch2map($;$) { |
|
|
266 | my ($mapa) = @_; |
|
|
267 | |
|
|
268 | my %meta; |
|
|
269 | |
|
|
270 | my ($mapx, $mapy); |
|
|
271 | |
|
|
272 | my $map; |
|
|
273 | |
|
|
274 | for (@{ $mapa->{arch} }) { |
|
|
275 | my ($x, $y) = (delete $_->{x}, delete $_->{y}); |
|
|
276 | |
|
|
277 | if ($_->{_name} eq "map") { |
|
|
278 | $meta{info} = $_; |
|
|
279 | |
|
|
280 | $mapx = $_->{width} || $x; |
|
|
281 | $mapy = $_->{height} || $y; |
|
|
282 | } else { |
|
|
283 | push @{ $map->[$x][$y] }, $_; |
|
|
284 | |
|
|
285 | # arch map is unreliable w.r.t. width and height |
|
|
286 | $mapx = $x + 1 if $mapx <= $x; |
|
|
287 | $mapy = $y + 1 if $mapy <= $y; |
|
|
288 | #$mapx = $a->{x} + 1, warn "$mapname: arch '$a->{_name}' outside map width at ($a->{x}|$a->{y})\n" if $mapx <= $a->{x}; |
|
|
289 | #$mapy = $a->{y} + 1, warn "$mapname: arch '$a->{_name}' outside map height at ($a->{x}|$a->{y})\n" if $mapy <= $a->{y}; |
|
|
290 | } |
399 | # } |
291 | } |
400 | # if ((check_type & IGUIConstants.TILE_EDIT_WALL) != 0 && |
292 | |
401 | # arch_type == 0 && getAttributeValue("no_pass", defarch) == 1) { |
293 | $meta{width} = $mapx; |
402 | # // Walls |
294 | $meta{height} = $mapy; |
403 | # edit_type |= IGUIConstants.TILE_EDIT_WALL; |
295 | $meta{map} = $map; |
404 | # } |
296 | |
405 | # if ((check_type & IGUIConstants.TILE_EDIT_CONNECTED) != 0 && |
297 | \%meta |
406 | # getAttributeValue("connected", defarch) != 0) { |
|
|
407 | # // Connected Objects |
|
|
408 | # edit_type |= IGUIConstants.TILE_EDIT_CONNECTED; |
|
|
409 | # } |
|
|
410 | # if ((check_type & IGUIConstants.TILE_EDIT_EXIT) != 0 && |
|
|
411 | # arch_type == 66 || arch_type == 41 || arch_type == 95) { |
|
|
412 | # // Exit: teleporter/exit/trapdoors |
|
|
413 | # edit_type |= IGUIConstants.TILE_EDIT_EXIT; |
|
|
414 | # } |
|
|
415 | # if ((check_type & IGUIConstants.TILE_EDIT_TREASURE) != 0 && |
|
|
416 | # getAttributeValue("no_pick", defarch) == 0 && (arch_type == 4 || |
|
|
417 | # arch_type == 5 || arch_type == 36 || arch_type == 60 || |
|
|
418 | # arch_type == 85 || arch_type == 111 || arch_type == 123 || |
|
|
419 | # arch_type == 124 || arch_type == 130)) { |
|
|
420 | # // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls |
|
|
421 | # edit_type |= IGUIConstants.TILE_EDIT_TREASURE; |
|
|
422 | # } |
|
|
423 | # if ((check_type & IGUIConstants.TILE_EDIT_DOOR) != 0 && |
|
|
424 | # arch_type == 20 || arch_type == 23 || arch_type == 26 || |
|
|
425 | # arch_type == 91 || arch_type == 21 || arch_type == 24) { |
|
|
426 | # // Door: door/special door/gates + keys |
|
|
427 | # edit_type |= IGUIConstants.TILE_EDIT_DOOR; |
|
|
428 | # } |
|
|
429 | # if ((check_type & IGUIConstants.TILE_EDIT_EQUIP) != 0 && |
|
|
430 | # getAttributeValue("no_pick", defarch) == 0 && ((arch_type >= 13 && |
|
|
431 | # arch_type <= 16) || arch_type == 33 || arch_type == 34 || |
|
|
432 | # arch_type == 35 || arch_type == 39 || arch_type == 70 || |
|
|
433 | # arch_type == 87 || arch_type == 99 || arch_type == 100 || |
|
|
434 | # arch_type == 104 || arch_type == 109 || arch_type == 113 || |
|
|
435 | # arch_type == 122 || arch_type == 3)) { |
|
|
436 | # // Equipment: weapons/armour/wands/rods |
|
|
437 | # edit_type |= IGUIConstants.TILE_EDIT_EQUIP; |
|
|
438 | # } |
|
|
439 | # |
|
|
440 | # return(edit_type); |
|
|
441 | # |
|
|
442 | # |
298 | } |
443 | } |
299 | |
444 | |
300 | sub init($) { |
445 | sub init($) { |
301 | my ($cachedir) = @_; |
446 | my ($cachedir) = @_; |
302 | |
447 | |
|
|
448 | return if %ARCH; |
|
|
449 | |
|
|
450 | mkdir $cachedir, 0777; |
303 | $ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
451 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
304 | } |
452 | } |
|
|
453 | |
|
|
454 | $VARDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir . "/crossfire"; |
|
|
455 | |
|
|
456 | init $VARDIR; |
305 | |
457 | |
306 | =head1 AUTHOR |
458 | =head1 AUTHOR |
307 | |
459 | |
308 | Marc Lehmann <schmorp@schmorp.de> |
460 | Marc Lehmann <schmorp@schmorp.de> |
309 | http://home.schmorp.de/ |
461 | http://home.schmorp.de/ |