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.15 by root, Sun Feb 12 04:50:24 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";
270} 277}
271 278
272$CACHEDIR ||= "$ENV{HOME}/.crossfire"; 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;
321}
322
323sub arch_edit_sections {
324# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
325# edit_type = 0;
326# else if (edit_type != 0) {
327# // all flags from 'check_type' must be unset in this arch because they get recalculated now
328# edit_type &= ~check_type;
329# }
330#
331# }
332# if ((check_type & IGUIConstants.TILE_EDIT_MONSTER) != 0 &&
333# getAttributeValue("alive", defarch) == 1 &&
334# (getAttributeValue("monster", defarch) == 1 ||
335# getAttributeValue("generator", defarch) == 1)) {
336# // Monster: monsters/npcs/generators
337# edit_type |= IGUIConstants.TILE_EDIT_MONSTER;
338# }
339# if ((check_type & IGUIConstants.TILE_EDIT_WALL) != 0 &&
340# arch_type == 0 && getAttributeValue("no_pass", defarch) == 1) {
341# // Walls
342# edit_type |= IGUIConstants.TILE_EDIT_WALL;
343# }
344# if ((check_type & IGUIConstants.TILE_EDIT_CONNECTED) != 0 &&
345# getAttributeValue("connected", defarch) != 0) {
346# // Connected Objects
347# edit_type |= IGUIConstants.TILE_EDIT_CONNECTED;
348# }
349# if ((check_type & IGUIConstants.TILE_EDIT_EXIT) != 0 &&
350# arch_type == 66 || arch_type == 41 || arch_type == 95) {
351# // Exit: teleporter/exit/trapdoors
352# edit_type |= IGUIConstants.TILE_EDIT_EXIT;
353# }
354# if ((check_type & IGUIConstants.TILE_EDIT_TREASURE) != 0 &&
355# getAttributeValue("no_pick", defarch) == 0 && (arch_type == 4 ||
356# arch_type == 5 || arch_type == 36 || arch_type == 60 ||
357# arch_type == 85 || arch_type == 111 || arch_type == 123 ||
358# arch_type == 124 || arch_type == 130)) {
359# // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls
360# edit_type |= IGUIConstants.TILE_EDIT_TREASURE;
361# }
362# if ((check_type & IGUIConstants.TILE_EDIT_DOOR) != 0 &&
363# arch_type == 20 || arch_type == 23 || arch_type == 26 ||
364# arch_type == 91 || arch_type == 21 || arch_type == 24) {
365# // Door: door/special door/gates + keys
366# edit_type |= IGUIConstants.TILE_EDIT_DOOR;
367# }
368# if ((check_type & IGUIConstants.TILE_EDIT_EQUIP) != 0 &&
369# getAttributeValue("no_pick", defarch) == 0 && ((arch_type >= 13 &&
370# arch_type <= 16) || arch_type == 33 || arch_type == 34 ||
371# arch_type == 35 || arch_type == 39 || arch_type == 70 ||
372# arch_type == 87 || arch_type == 99 || arch_type == 100 ||
373# arch_type == 104 || arch_type == 109 || arch_type == 113 ||
374# arch_type == 122 || arch_type == 3)) {
375# // Equipment: weapons/armour/wands/rods
376# edit_type |= IGUIConstants.TILE_EDIT_EQUIP;
377# }
378#
379# return(edit_type);
380#
381#
382}
383
384$CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir;
273 385
274init $CACHEDIR; 386init $CACHEDIR;
275 387
276=head1 AUTHOR 388=head1 AUTHOR
277 389

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines