… | |
… | |
25 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
25 | our $LIB = $ENV{CROSSFIRE_LIBDIR} |
26 | or Carp::croak "\$CROSSFIRE_LIBDIR must be set\n"; |
26 | or Carp::croak "\$CROSSFIRE_LIBDIR must be set\n"; |
27 | |
27 | |
28 | sub TILESIZE (){ 32 } |
28 | sub TILESIZE (){ 32 } |
29 | |
29 | |
30 | our $CACHEDIR; |
30 | our $VARDIR; |
31 | our %ARCH; |
31 | our %ARCH; |
32 | our %FACE; |
32 | our %FACE; |
33 | our $TILE; |
33 | our $TILE; |
34 | |
34 | |
35 | our %FIELD_MULTILINE = ( |
35 | our %FIELD_MULTILINE = ( |
… | |
… | |
113 | sub read_pak($;$) { |
113 | sub read_pak($;$) { |
114 | my ($path, $cache) = @_; |
114 | my ($path, $cache) = @_; |
115 | |
115 | |
116 | eval { |
116 | eval { |
117 | defined $cache |
117 | defined $cache |
|
|
118 | && -e $cache |
118 | && -M $cache < -M $path |
119 | && -M $cache < -M $path |
119 | && Storable::retrieve ($cache) |
120 | && Storable::retrieve ($cache) |
120 | } or do { |
121 | } or do { |
121 | my %pak; |
122 | my %pak; |
122 | |
123 | |
… | |
… | |
138 | sub read_arch($;$) { |
139 | sub read_arch($;$) { |
139 | my ($path, $cache) = @_; |
140 | my ($path, $cache) = @_; |
140 | |
141 | |
141 | eval { |
142 | eval { |
142 | defined $cache |
143 | defined $cache |
|
|
144 | && -e $cache |
143 | && -M $cache < -M $path |
145 | && -M $cache < -M $path |
144 | && Storable::retrieve ($cache) |
146 | && Storable::retrieve ($cache) |
145 | } or do { |
147 | } or do { |
146 | my %arc; |
148 | my %arc; |
147 | my ($more, $prev); |
149 | my ($more, $prev); |
… | |
… | |
204 | } |
206 | } |
205 | } |
207 | } |
206 | |
208 | |
207 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
209 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
208 | |
210 | |
|
|
211 | warn "hoi\n";#d# |
209 | Storable::nstore (\%arc, $cache) |
212 | Storable::nstore (\%arc, $cache) |
210 | if defined $cache; |
213 | if defined $cache; |
|
|
214 | warn "hox\n";#d# |
211 | |
215 | |
212 | \%arc |
216 | \%arc |
213 | } |
217 | } |
214 | } |
218 | } |
215 | |
219 | |
… | |
… | |
263 | |
267 | |
264 | } else { |
268 | } else { |
265 | # single face |
269 | # single face |
266 | return (0, 0, 0, 0); |
270 | return (0, 0, 0, 0); |
267 | } |
271 | } |
268 | } |
|
|
269 | |
|
|
270 | sub init($) { |
|
|
271 | my ($cachedir) = @_; |
|
|
272 | |
|
|
273 | return if %ARCH; |
|
|
274 | |
|
|
275 | mkdir $cachedir, 0777; |
|
|
276 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
|
|
277 | } |
272 | } |
278 | |
273 | |
279 | =item $type = arch_attr $arch |
274 | =item $type = arch_attr $arch |
280 | |
275 | |
281 | Returns a hashref describing the object and its attributes. It can contain |
276 | Returns a hashref describing the object and its attributes. It can contain |
… | |
… | |
379 | # return(edit_type); |
374 | # return(edit_type); |
380 | # |
375 | # |
381 | # |
376 | # |
382 | } |
377 | } |
383 | |
378 | |
|
|
379 | sub init($) { |
|
|
380 | my ($cachedir) = @_; |
|
|
381 | |
|
|
382 | return if %ARCH; |
|
|
383 | |
|
|
384 | mkdir $cachedir, 0777; |
|
|
385 | *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; |
|
|
386 | } |
|
|
387 | |
384 | $CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir; |
388 | $VARDIR ||= $ENV{HOME} ? "$ENV{HOME}/crossfire" : File::Spec->tmpdir; |
385 | |
389 | |
386 | init $CACHEDIR; |
390 | init $VARDIR; |
387 | |
391 | |
388 | =head1 AUTHOR |
392 | =head1 AUTHOR |
389 | |
393 | |
390 | Marc Lehmann <schmorp@schmorp.de> |
394 | Marc Lehmann <schmorp@schmorp.de> |
391 | http://home.schmorp.de/ |
395 | http://home.schmorp.de/ |