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.16 by root, Tue Feb 21 21:37:01 2006 UTC vs.
Revision 1.22 by root, Thu Feb 23 01:55:54 2006 UTC

12 12
13use base 'Exporter'; 13use base 'Exporter';
14 14
15use Carp (); 15use Carp ();
16use Storable; 16use Storable;
17use File::Spec;
17use List::Util qw(min max); 18use List::Util qw(min max);
18 19
19#XXX: The map_* procedures scream for a map-object 20#XXX: The map_* procedures scream for a map-object
20 21
21our @EXPORT = 22our @EXPORT =
224 } 225 }
225 226
226 \%paths 227 \%paths
227} 228}
228 229
230=item ($minx, $miny, $maxx, $maxy) = arch_extents $arch
231
229# arch_extents determines the extents of a given arch 232arch_extents determines the extents of the given arch's face(s), linked
230# bigfaces, linked faces and single faces are handled here 233faces and single faces are handled here it returns (minx, miny, maxx,
231# it returns (minx, miny, maxx, maxy) 234maxy)
235
236=cut
237
232sub arch_extents { 238sub arch_extents {
233 my ($a) = @_; 239 my ($a) = @_;
234 240
235 my $o = $ARCH{$a->{_name}} 241 my $o = $ARCH{$a->{_name}}
236 or return; 242 or return;
264sub init($) { 270sub init($) {
265 my ($cachedir) = @_; 271 my ($cachedir) = @_;
266 272
267 return if %ARCH; 273 return if %ARCH;
268 274
275 mkdir 0777, $cachedir;
269 *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; 276 *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst";
277}
278
279=item $type = arch_attr $arch
280
281Returns a hashref describing the object and its attributes. It can contain
282the following keys:
283
284 name the name, suitable for display purposes
285 ignore
286 attr
287 desc
288 use
289 section => [name => \%attr, name => \%attr]
290 import
291
292=cut
293
294sub arch_attr($) {
295 my ($arch) = @_;
296
297 require Crossfire::Data;
298
299 my $attr;
300
301 if ($arch->{type} > 0) {
302 $attr = $Crossfire::Data::ATTR{$arch->{type}+0};
303 } else {
304 $attr = $Crossfire::Data::TYPE{Misc};
305
306 type:
307 for (@Crossfire::Data::ATTR0) {
308 my $req = $_->{required}
309 or die "internal error: ATTR0 without 'required'";
310
311 while (my ($k, $v) = each %$req) {
312 next type
313 unless $arch->{$k} == $v;
314 }
315
316 $attr = $_;
317 }
318 }
319
320 $attr || \%Crossfire::Data::DEFAULT_ATTR;
270} 321}
271 322
272sub arch_edit_sections { 323sub arch_edit_sections {
273# if (edit_type == IGUIConstants.TILE_EDIT_NONE) 324# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
274# edit_type = 0; 325# edit_type = 0;
328# return(edit_type); 379# return(edit_type);
329# 380#
330# 381#
331} 382}
332 383
333$CACHEDIR ||= "$ENV{HOME}/.crossfire"; 384$CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir;
334 385
335init $CACHEDIR; 386init $CACHEDIR;
336 387
337=head1 AUTHOR 388=head1 AUTHOR
338 389

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines