… | |
… | |
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 FreezeThaw qw(freeze thaw)"; |
|
|
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 | |
|
|
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 | |
69 | sub save_ref($$) { |
61 | sub 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 | |