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.23 by root, Thu Feb 23 02:52:51 2006 UTC vs.
Revision 1.26 by root, Thu Feb 23 05:23:01 2006 UTC

25our $LIB = $ENV{CROSSFIRE_LIBDIR} 25our $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
28sub TILESIZE (){ 32 } 28sub TILESIZE (){ 32 }
29 29
30our $CACHEDIR; 30our $VARDIR;
31our %ARCH; 31our %ARCH;
32our %FACE; 32our %FACE;
33our $TILE; 33our $TILE;
34 34
35our %FIELD_MULTILINE = ( 35our %FIELD_MULTILINE = (
113sub read_pak($;$) { 113sub 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
138sub read_arch($;$) { 139sub 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
270sub 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
281Returns a hashref describing the object and its attributes. It can contain 276Returns 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
379sub 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
386init $CACHEDIR; 390init $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/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines