… | |
… | |
11 | use strict; |
11 | use strict; |
12 | |
12 | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use Storable; |
|
|
17 | use File::Spec; |
16 | use File::Spec; |
18 | use List::Util qw(min max); |
17 | use 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 | |
… | |
… | |
45 | sub MOVE_FLY_HIGH (){ 0x4 } |
44 | sub MOVE_FLY_HIGH (){ 0x4 } |
46 | sub MOVE_FLYING (){ 0x6 } |
45 | sub MOVE_FLYING (){ 0x6 } |
47 | sub MOVE_SWIM (){ 0x8 } |
46 | sub MOVE_SWIM (){ 0x8 } |
48 | sub MOVE_ALL (){ 0xf } |
47 | sub MOVE_ALL (){ 0xf } |
49 | |
48 | |
|
|
49 | BEGIN { |
|
|
50 | if ($^O eq "MSWin32") { |
|
|
51 | eval "use FreezeThaw qw(freeze thaw)"; |
|
|
52 | } else { |
|
|
53 | eval "use Storable qw(freeze thaw)"; |
|
|
54 | } |
|
|
55 | } |
|
|
56 | |
50 | sub load_ref($) { |
57 | sub 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 | |
59 | sub save_ref($$) { |
66 | sub 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 | |