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.32 by root, Thu Feb 23 15:10:08 2006 UTC vs.
Revision 1.35 by root, Sun Mar 12 16:23:56 2006 UTC

13use base 'Exporter'; 13use base 'Exporter';
14 14
15use Carp (); 15use Carp ();
16use File::Spec; 16use File::Spec;
17use List::Util qw(min max); 17use List::Util qw(min max);
18use Storable;
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 =
22 qw(read_pak read_arch %ARCH TILESIZE $TILE %FACE editor_archs arch_extents); 23 qw(read_pak read_arch %ARCH TILESIZE $TILE %FACE editor_archs arch_extents);
44sub MOVE_FLY_HIGH (){ 0x4 } 45sub MOVE_FLY_HIGH (){ 0x4 }
45sub MOVE_FLYING (){ 0x6 } 46sub MOVE_FLYING (){ 0x6 }
46sub MOVE_SWIM (){ 0x8 } 47sub MOVE_SWIM (){ 0x8 }
47sub MOVE_ALL (){ 0xf } 48sub MOVE_ALL (){ 0xf }
48 49
49BEGIN {
50 if ($^O eq "MSWin32") {
51 eval "use FreezeThaw qw(freeze thaw)";
52 } else {
53 eval "use Storable qw(freeze thaw)";
54 }
55}
56
57sub load_ref($) { 50sub load_ref($) {
58 my ($path) = @_; 51 my ($path) = @_;
59
60 die if $^O eq "MSWin32"; #d#
61 52
62 open my $fh, "<", $path 53 open my $fh, "<", $path
63 or die "$path: $!"; 54 or die "$path: $!";
64 binmode $fh; 55 binmode $fh;
65 local $/; 56 local $/;
66 thaw <$fh> 57
58 Storable::thaw <$fh>
67} 59}
68 60
69sub save_ref($$) { 61sub save_ref($$) {
70 my ($ref, $path) = @_; 62 my ($ref, $path) = @_;
71 63
72 open my $fh, ">", "$path~" 64 open my $fh, ">", "$path~"
73 or die "$path~: $!"; 65 or die "$path~: $!";
74 binmode $fh; 66 binmode $fh;
75 print $fh freeze $ref; 67 print $fh Storable::freeze $ref;
76 close $fh; 68 close $fh;
77 rename "$path~", $path 69 rename "$path~", $path
78 or die "$path: $!"; 70 or die "$path: $!";
79} 71}
80 72
331 type: 323 type:
332 for (@Crossfire::Data::ATTR0) { 324 for (@Crossfire::Data::ATTR0) {
333 my $req = $_->{required} 325 my $req = $_->{required}
334 or die "internal error: ATTR0 without 'required'"; 326 or die "internal error: ATTR0 without 'required'";
335 327
328 keys %$req;
336 while (my ($k, $v) = each %$req) { 329 while (my ($k, $v) = each %$req) {
337 next type 330 next type
338 unless $arch->{$k} == $v; 331 unless $arch->{$k} == $v;
339 } 332 }
340 333

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines