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.21 by root, Thu Feb 23 01:55:29 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;
267 return if %ARCH; 273 return if %ARCH;
268 274
269 *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst"; 275 *ARCH = read_arch "$LIB/archetypes", "$cachedir/archetypes.pst";
270} 276}
271 277
272$CACHEDIR ||= "$ENV{HOME}/.crossfire"; 278=item $type = arch_attr $arch
279
280Returns a hashref describing the object and its attributes. It can contain
281the following keys:
282
283 name the name, suitable for display purposes
284 ignore
285 attr
286 desc
287 use
288 section => [name => \%attr, name => \%attr]
289 import
290
291=cut
292
293sub arch_attr($) {
294 my ($arch) = @_;
295
296 require Crossfire::Data;
297
298 my $attr;
299
300 if ($arch->{type} > 0) {
301 $attr = $Crossfire::Data::ATTR{$arch->{type}+0};
302 } else {
303 $attr = $Crossfire::Data::TYPE{Misc};
304
305 type:
306 for (@Crossfire::Data::ATTR0) {
307 my $req = $_->{required}
308 or die "internal error: ATTR0 without 'required'";
309
310 while (my ($k, $v) = each %$req) {
311 next type
312 unless $arch->{$k} == $v;
313 }
314
315 $attr = $_;
316 }
317 }
318
319 $attr || \%Crossfire::Data::DEFAULT_ATTR;
320}
321
322sub arch_edit_sections {
323# if (edit_type == IGUIConstants.TILE_EDIT_NONE)
324# edit_type = 0;
325# else if (edit_type != 0) {
326# // all flags from 'check_type' must be unset in this arch because they get recalculated now
327# edit_type &= ~check_type;
328# }
329#
330# }
331# if ((check_type & IGUIConstants.TILE_EDIT_MONSTER) != 0 &&
332# getAttributeValue("alive", defarch) == 1 &&
333# (getAttributeValue("monster", defarch) == 1 ||
334# getAttributeValue("generator", defarch) == 1)) {
335# // Monster: monsters/npcs/generators
336# edit_type |= IGUIConstants.TILE_EDIT_MONSTER;
337# }
338# if ((check_type & IGUIConstants.TILE_EDIT_WALL) != 0 &&
339# arch_type == 0 && getAttributeValue("no_pass", defarch) == 1) {
340# // Walls
341# edit_type |= IGUIConstants.TILE_EDIT_WALL;
342# }
343# if ((check_type & IGUIConstants.TILE_EDIT_CONNECTED) != 0 &&
344# getAttributeValue("connected", defarch) != 0) {
345# // Connected Objects
346# edit_type |= IGUIConstants.TILE_EDIT_CONNECTED;
347# }
348# if ((check_type & IGUIConstants.TILE_EDIT_EXIT) != 0 &&
349# arch_type == 66 || arch_type == 41 || arch_type == 95) {
350# // Exit: teleporter/exit/trapdoors
351# edit_type |= IGUIConstants.TILE_EDIT_EXIT;
352# }
353# if ((check_type & IGUIConstants.TILE_EDIT_TREASURE) != 0 &&
354# getAttributeValue("no_pick", defarch) == 0 && (arch_type == 4 ||
355# arch_type == 5 || arch_type == 36 || arch_type == 60 ||
356# arch_type == 85 || arch_type == 111 || arch_type == 123 ||
357# arch_type == 124 || arch_type == 130)) {
358# // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls
359# edit_type |= IGUIConstants.TILE_EDIT_TREASURE;
360# }
361# if ((check_type & IGUIConstants.TILE_EDIT_DOOR) != 0 &&
362# arch_type == 20 || arch_type == 23 || arch_type == 26 ||
363# arch_type == 91 || arch_type == 21 || arch_type == 24) {
364# // Door: door/special door/gates + keys
365# edit_type |= IGUIConstants.TILE_EDIT_DOOR;
366# }
367# if ((check_type & IGUIConstants.TILE_EDIT_EQUIP) != 0 &&
368# getAttributeValue("no_pick", defarch) == 0 && ((arch_type >= 13 &&
369# arch_type <= 16) || arch_type == 33 || arch_type == 34 ||
370# arch_type == 35 || arch_type == 39 || arch_type == 70 ||
371# arch_type == 87 || arch_type == 99 || arch_type == 100 ||
372# arch_type == 104 || arch_type == 109 || arch_type == 113 ||
373# arch_type == 122 || arch_type == 3)) {
374# // Equipment: weapons/armour/wands/rods
375# edit_type |= IGUIConstants.TILE_EDIT_EQUIP;
376# }
377#
378# return(edit_type);
379#
380#
381}
382
383$CACHEDIR ||= $ENV{HOME} ? "$ENV{HOME}/.crossfire" : File::Spec->tmpdir;
273 384
274init $CACHEDIR; 385init $CACHEDIR;
275 386
276=head1 AUTHOR 387=head1 AUTHOR
277 388

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines