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.29 by root, Thu Feb 23 13:22:10 2006 UTC vs.
Revision 1.30 by root, Thu Feb 23 14:54:44 2006 UTC

11use strict; 11use strict;
12 12
13use base 'Exporter'; 13use base 'Exporter';
14 14
15use Carp (); 15use Carp ();
16use Storable;
17use File::Spec; 16use File::Spec;
18use List::Util qw(min max); 17use List::Util qw(min max);
19 18
20#XXX: The map_* procedures scream for a map-object 19#XXX: The map_* procedures scream for a map-object
21 20
45sub MOVE_FLY_HIGH (){ 0x4 } 44sub MOVE_FLY_HIGH (){ 0x4 }
46sub MOVE_FLYING (){ 0x6 } 45sub MOVE_FLYING (){ 0x6 }
47sub MOVE_SWIM (){ 0x8 } 46sub MOVE_SWIM (){ 0x8 }
48sub MOVE_ALL (){ 0xf } 47sub MOVE_ALL (){ 0xf }
49 48
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
50sub load_ref($) { 57sub load_ref($) {
51 my ($path) = @_; 58 my ($path) = @_;
52 59
53 open my $fh, "<:raw", "$path~" 60 open my $fh, "<:raw", "$path~"
54 or die "$path~: $!"; 61 or die "$path~: $!";
55 local $/; 62 local $/;
56 Storable::thaw <$fh> 63 thaw <$fh>
57} 64}
58 65
59sub save_ref($$) { 66sub save_ref($$) {
60 my ($ref, $path) = @_; 67 my ($ref, $path) = @_;
61 68
62 open my $fh, ">:raw", "$path~" 69 open my $fh, ">:raw", "$path~"
63 or die "$path~: $!"; 70 or die "$path~: $!";
64 print $fh Storable::nfreeze $ref; 71 my $ref = freeze $ref;
72 print $fh $ref;
65 close $fh; 73 close $fh;
66 rename "$path~", $path 74 rename "$path~", $path
67 or die "$path: $!"; 75 or die "$path: $!";
68} 76}
69 77

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines