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.31 by root, Thu Feb 23 15:01:43 2006 UTC vs.
Revision 1.34 by root, Fri Feb 24 11:50:36 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 52
60 open my $fh, "<", $path 53 open my $fh, "<", $path
61 or die "$path: $!"; 54 or die "$path: $!";
62 binmode $fh; 55 binmode $fh;
63 local $/; 56 local $/;
64 thaw <$fh> 57
58 Storable::thaw <$fh>
65} 59}
66 60
67sub save_ref($$) { 61sub save_ref($$) {
68 my ($ref, $path) = @_; 62 my ($ref, $path) = @_;
69 63
70 open my $fh, ">", "$path~" 64 open my $fh, ">", "$path~"
71 or die "$path~: $!"; 65 or die "$path~: $!";
72 binmode $fh; 66 binmode $fh;
73 print $fh freeze $ref; 67 print $fh Storable::freeze $ref;
74 close $fh; 68 close $fh;
75 rename "$path~", $path 69 rename "$path~", $path
76 or die "$path: $!"; 70 or die "$path: $!";
77} 71}
78 72

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines