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.33 by root, Thu Feb 23 15:47:50 2006 UTC vs.
Revision 1.35 by root, Sun Mar 12 16:23:56 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 Data::Dumper";
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 57
65 $^O eq "MSWin32" ? eval <$fh> : thaw (<$fh>) 58 Storable::thaw <$fh>
66} 59}
67 60
68sub save_ref($$) { 61sub 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
332 type: 323 type:
333 for (@Crossfire::Data::ATTR0) { 324 for (@Crossfire::Data::ATTR0) {
334 my $req = $_->{required} 325 my $req = $_->{required}
335 or die "internal error: ATTR0 without 'required'"; 326 or die "internal error: ATTR0 without 'required'";
336 327
328 keys %$req;
337 while (my ($k, $v) = each %$req) { 329 while (my ($k, $v) = each %$req) {
338 next type 330 next type
339 unless $arch->{$k} == $v; 331 unless $arch->{$k} == $v;
340 } 332 }
341 333

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines