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.21 by root, Thu Feb 23 01:55:29 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
123 open my $fh, "<:raw", $path 124 open my $fh, "<:raw", $path
124 or Carp::croak "$_[0]: $!"; 125 or Carp::croak "$_[0]: $!";
126 my ($type, $id, $len, $path) = split; 127 my ($type, $id, $len, $path) = split;
127 $path =~ s/.*\///; 128 $path =~ s/.*\///;
128 read $fh, $pak{$path}, $len; 129 read $fh, $pak{$path}, $len;
129 } 130 }
130 131
131 Storable::nstore \%pak, $cache 132 Storable::nstore (\%pak, $cache)
132 if defined $cache; 133 if defined $cache;
133 134
134 \%pak 135 \%pak
135 } 136 }
136} 137}
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);
148 150
149 open my $fh, "<:raw", $path 151 open my $fh, "<:raw", $path
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 *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst";
276} 272}
277 273
278=item $type = arch_attr $arch 274=item $type = arch_attr $arch
279 275
280Returns a hashref describing the object and its attributes. It can contain 276Returns a hashref describing the object and its attributes. It can contain
378# return(edit_type); 374# return(edit_type);
379# 375#
380# 376#
381} 377}
382 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
383$CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir; 388$VARDIR ||= $ENV{HOME} ? "$ENV{HOME}/crossfire" : File::Spec->tmpdir;
384 389
385init $CACHEDIR; 390init $VARDIR;
386 391
387=head1 AUTHOR 392=head1 AUTHOR
388 393
389 Marc Lehmann <schmorp@schmorp.de> 394 Marc Lehmann <schmorp@schmorp.de>
390 http://home.schmorp.de/ 395 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines