… | |
… | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use File::Spec; |
16 | use File::Spec; |
17 | use List::Util qw(min max); |
17 | use List::Util qw(min max); |
|
|
18 | use 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 | |
21 | our @EXPORT = |
22 | our @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); |
… | |
… | |
44 | sub MOVE_FLY_HIGH (){ 0x4 } |
45 | sub MOVE_FLY_HIGH (){ 0x4 } |
45 | sub MOVE_FLYING (){ 0x6 } |
46 | sub MOVE_FLYING (){ 0x6 } |
46 | sub MOVE_SWIM (){ 0x8 } |
47 | sub MOVE_SWIM (){ 0x8 } |
47 | sub MOVE_ALL (){ 0xf } |
48 | sub MOVE_ALL (){ 0xf } |
48 | |
49 | |
49 | BEGIN { |
|
|
50 | if ($^O eq "MSWin32") { |
|
|
51 | eval "use Data::Dumper"; |
|
|
52 | } else { |
|
|
53 | eval "use Storable qw(freeze thaw)"; |
|
|
54 | } |
|
|
55 | } |
|
|
56 | |
|
|
57 | sub load_ref($) { |
50 | sub 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 | |
57 | |
65 | $^O eq "MSWin32" ? eval <$fh> : thaw (<$fh>) |
58 | Storable::thaw <$fh> |
66 | } |
59 | } |
67 | |
60 | |
68 | sub save_ref($$) { |
61 | sub save_ref($$) { |
69 | my ($ref, $path) = @_; |
62 | my ($ref, $path) = @_; |
70 | |
63 | |
71 | open my $fh, ">", "$path~" |
64 | open my $fh, ">", "$path~" |
72 | or die "$path~: $!"; |
65 | or die "$path~: $!"; |
73 | binmode $fh; |
66 | binmode $fh; |
74 | print $fh $^O eq "MSWin32" |
67 | print $fh Storable::freeze $ref; |
75 | ? Data::Dumper->new ([$ref])->Deepcopy (1)->Purity (1)->Terse (1)->Indent (0)->Dump |
|
|
76 | : freeze ($ref); |
|
|
77 | close $fh; |
68 | close $fh; |
78 | rename "$path~", $path |
69 | rename "$path~", $path |
79 | or die "$path: $!"; |
70 | or die "$path: $!"; |
80 | } |
71 | } |
81 | |
72 | |