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.56 by root, Thu Mar 23 07:33:16 2006 UTC vs.
Revision 1.61 by root, Mon Mar 27 17:38:18 2006 UTC

36our %FIELD_MULTILINE = ( 36our %FIELD_MULTILINE = (
37 msg => "endmsg", 37 msg => "endmsg",
38 lore => "endlore", 38 lore => "endlore",
39 maplore => "endmaplore", 39 maplore => "endmaplore",
40); 40);
41
42# movement bit type, PITA
43our %FIELD_MOVEMENT = map +($_ => undef),
44 qw(move_type move_block move_allow move_on move_off move_slow);
41 45
42# same as in server save routine, to (hopefully) be compatible 46# same as in server save routine, to (hopefully) be compatible
43# to the other editors. 47# to the other editors.
44our @FIELD_ORDER_MAP = (qw( 48our @FIELD_ORDER_MAP = (qw(
45 name swap_time reset_timeout fixed_resettime difficulty region 49 name swap_time reset_timeout fixed_resettime difficulty region
49 outdoor temp pressure humid windspeed winddir sky nosmooth 53 outdoor temp pressure humid windspeed winddir sky nosmooth
50 tile_path_1 tile_path_2 tile_path_3 tile_path_4 54 tile_path_1 tile_path_2 tile_path_3 tile_path_4
51)); 55));
52 56
53our @FIELD_ORDER = (qw( 57our @FIELD_ORDER = (qw(
58 elevation
59
54 name name_pl custom_name title race 60 name name_pl custom_name title race
55 slaying skill msg lore other_arch face 61 slaying skill msg lore other_arch face
56 #todo-events 62 #todo-events
57 animation is_animated 63 animation is_animated
58 Str Dex Con Wis Pow Cha Int 64 str dex con wis pow cha int
59 hp maxhp sp maxsp grace maxgrace 65 hp maxhp sp maxsp grace maxgrace
60 exp perm_exp expmul 66 exp perm_exp expmul
61 food dam luck wc ac x y speed speed_left move_state attack_movement 67 food dam luck wc ac x y speed speed_left move_state attack_movement
62 nrof level direction type subtype 68 nrof level direction type subtype attacktype
63 69
64 resist_physical resist_magic resist_fire resist_electricity 70 resist_physical resist_magic resist_fire resist_electricity
65 resist_cold resist_confusion resist_acid resist_drain 71 resist_cold resist_confusion resist_acid resist_drain
66 resist_weaponmagic resist_ghosthit resist_poison resist_slow 72 resist_weaponmagic resist_ghosthit resist_poison resist_slow
67 resist_paralyze resist_turn_undead resist_fear resist_cancellation 73 resist_paralyze resist_turn_undead resist_fear resist_cancellation
102sub MOVE_FLY_LOW (){ 0x02 } 108sub MOVE_FLY_LOW (){ 0x02 }
103sub MOVE_FLY_HIGH (){ 0x04 } 109sub MOVE_FLY_HIGH (){ 0x04 }
104sub MOVE_FLYING (){ 0x06 } 110sub MOVE_FLYING (){ 0x06 }
105sub MOVE_SWIM (){ 0x08 } 111sub MOVE_SWIM (){ 0x08 }
106sub MOVE_BOAT (){ 0x10 } 112sub MOVE_BOAT (){ 0x10 }
113sub MOVE_KNOWN (){ 0x1f } # all of above
107sub MOVE_ALL (){ 0xff } 114sub MOVE_ALLBIT (){ 0x10000 }
115sub MOVE_ALL (){ 0x1001f } # very special value, more PITA
108 116
109sub load_ref($) { 117sub load_ref($) {
110 my ($path) = @_; 118 my ($path) = @_;
111 119
112 open my $fh, "<", $path 120 open my $fh, "<", $path
135 delete $ob->{$_} for qw( 143 delete $ob->{$_} for qw(
136 can_knockback can_parry can_impale can_cut can_dam_armour 144 can_knockback can_parry can_impale can_cut can_dam_armour
137 can_apply pass_thru can_pass_thru 145 can_apply pass_thru can_pass_thru
138 ); 146 );
139 147
140 for my $attr (qw(move_type move_block move_allow move_on move_off move_slow)) { 148 for my $attr (keys %FIELD_MOVEMENT) {
141 next unless exists $ob->{$attr}; 149 next unless exists $ob->{$attr};
150
151 $ob->{$attr} = MOVE_ALL if $ob->{$attr} == 255; #d# compatibility
152
142 next if $ob->{$attr} =~ /^\d+$/; 153 next if $ob->{$attr} =~ /^\d+$/;
143 154
144 my $flags = 0; 155 my $flags = 0;
145 156
146 # assume list 157 # assume list
228 if (exists $arch->{$k} and $arch->{$k} eq $v) { 239 if (exists $arch->{$k} and $arch->{$k} eq $v) {
229 next if $k eq "_name"; 240 next if $k eq "_name";
230 delete $ob->{$k}; 241 delete $ob->{$k};
231 } 242 }
232 } 243 }
244 }
245
246 # a speciality for the editor
247 if (exists $ob->{attack_movement}) {
248 my $am = delete $ob->{attack_movement};
249 $ob->{attack_movement_bits_0_3} = $am & 15;
250 $ob->{attack_movement_bits_4_7} = $am & 240;
233 } 251 }
234 252
235 $ob 253 $ob
236} 254}
237 255
309 } 327 }
310 $prev = $arc; 328 $prev = $arc;
311 $more = undef; 329 $more = undef;
312 } elsif (/^arch (\S+)$/i) { 330 } elsif (/^arch (\S+)$/i) {
313 my $name = $1; 331 my $name = $1;
314 my $arc = normalize_object $parse_block->(_name => $name); 332 my $arc = normalize_arch $parse_block->(_name => $name);
315 333
316 if ($more) { 334 if ($more) {
317 $more->{more} = $arc; 335 $more->{more} = $arc;
318 } else { 336 } else {
319 push @{ $arc{arch} }, $arc; 337 push @{ $arc{arch} }, $arc;
413 my $type = $obj->{type} || $arch->{type}; 431 my $type = $obj->{type} || $arch->{type};
414 432
415 if ($type > 0) { 433 if ($type > 0) {
416 $root = $Crossfire::Data::ATTR{$type}; 434 $root = $Crossfire::Data::ATTR{$type};
417 } else { 435 } else {
436 my %a = (%$arch, %$obj);
437
438 if ($a{is_floor} && !$a{alive}) {
439 $root = $Crossfire::Data::TYPE{Floor};
440 } elsif (!$a{is_floor} && $a{alive} && !$a{tear_down}) {
441 $root = $Crossfire::Data::TYPE{"Monster & NPC"};
442 } elsif (!$a{is_floor} && !$a{alive} && $a{move_block}) {
443 $root = $Crossfire::Data::TYPE{Wall};
444 } elsif (!$a{is_floor} && $a{alive} && $a{tear_down}) {
445 $root = $Crossfire::Data::TYPE{"Weak Wall"};
446 } else {
418 $root = $Crossfire::Data::TYPE{Misc}; 447 $root = $Crossfire::Data::TYPE{Misc};
419
420 type:
421 for (@Crossfire::Data::ATTR0) {
422 my $req = $_->{required}
423 or die "internal error: ATTR0 without 'required'";
424
425 keys %$req;
426 while (my ($k, $v) = each %$req) {
427 next type
428 unless $obj->{$k} == $v || $arch->{$k} == $v;
429 }
430
431 $root = $_;
432 } 448 }
433 } 449 }
434 450
435 my @import = ($root); 451 my @import = ($root);
436 452
610 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", sub { 626 cache_file "$LIB/crossfire.0", "$VARDIR/tilecache.pst", sub {
611 $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png" 627 $TILE = new_from_file Gtk2::Gdk::Pixbuf "$VARDIR/tilecache.png"
612 or die "$VARDIR/tilecache.png: $!"; 628 or die "$VARDIR/tilecache.png: $!";
613 *FACE = $_[0]; 629 *FACE = $_[0];
614 }, sub { 630 }, sub {
615 require File::Temp;
616
617 my $tile = read_pak "$LIB/crossfire.0"; 631 my $tile = read_pak "$LIB/crossfire.0";
618 632
619 my %cache; 633 my %cache;
620 634
621 my $idx = 0; 635 my $idx = 0;
622 636
623 for my $name (sort keys %$tile) { 637 for my $name (sort keys %$tile) {
624 my ($fh, $filename) = File::Temp::tempfile (); 638 my $pb = new Gtk2::Gdk::PixbufLoader;
625 print $fh $tile->{$name}; 639 $pb->write ($tile->{$name});
626 close $fh; 640 $pb->close;
627 my $pb = new_from_file Gtk2::Gdk::Pixbuf $filename; 641 my $pb = $pb->get_pixbuf;
628 unlink $filename;
629 642
630 my $tile = $cache{$name} = { 643 my $tile = $cache{$name} = {
631 pb => $pb, 644 pb => $pb,
632 idx => $idx, 645 idx => $idx,
633 w => int $pb->get_width / TILESIZE, 646 w => int $pb->get_width / TILESIZE,
651 $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64); 664 $pb, ($idx % 64) * TILESIZE, TILESIZE * int $idx / 64);
652 } 665 }
653 } 666 }
654 } 667 }
655 668
656 $pb->save ("$VARDIR/tilecache.png", "png"); 669 $pb->save ("$VARDIR/tilecache.png", "png", compression => 1);
657 670
658 \%cache 671 \%cache
659 }; 672 };
660} 673}
661 674

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines