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.30 by root, Thu Feb 23 14:54:44 2006 UTC vs.
Revision 1.33 by root, Thu Feb 23 15:47:50 2006 UTC

46sub MOVE_SWIM (){ 0x8 } 46sub MOVE_SWIM (){ 0x8 }
47sub MOVE_ALL (){ 0xf } 47sub MOVE_ALL (){ 0xf }
48 48
49BEGIN { 49BEGIN {
50 if ($^O eq "MSWin32") { 50 if ($^O eq "MSWin32") {
51 eval "use FreezeThaw qw(freeze thaw)"; 51 eval "use Data::Dumper";
52 } else { 52 } else {
53 eval "use Storable qw(freeze thaw)"; 53 eval "use Storable qw(freeze thaw)";
54 } 54 }
55} 55}
56 56
57sub load_ref($) { 57sub load_ref($) {
58 my ($path) = @_; 58 my ($path) = @_;
59 59
60 open my $fh, "<:raw", "$path~" 60 open my $fh, "<", $path
61 or die "$path~: $!"; 61 or die "$path: $!";
62 binmode $fh;
62 local $/; 63 local $/;
63 thaw <$fh> 64
65 $^O eq "MSWin32" ? eval <$fh> : thaw (<$fh>)
64} 66}
65 67
66sub save_ref($$) { 68sub save_ref($$) {
67 my ($ref, $path) = @_; 69 my ($ref, $path) = @_;
68 70
69 open my $fh, ">:raw", "$path~" 71 open my $fh, ">", "$path~"
70 or die "$path~: $!"; 72 or die "$path~: $!";
71 my $ref = freeze $ref; 73 binmode $fh;
72 print $fh $ref; 74 print $fh $^O eq "MSWin32"
75 ? Data::Dumper->new ([$ref])->Deepcopy (1)->Purity (1)->Terse (1)->Indent (0)->Dump
76 : freeze ($ref);
73 close $fh; 77 close $fh;
74 rename "$path~", $path 78 rename "$path~", $path
75 or die "$path: $!"; 79 or die "$path: $!";
76} 80}
77 81
146 && -M $cache < -M $path 150 && -M $cache < -M $path
147 && load_ref $cache 151 && load_ref $cache
148 } or do { 152 } or do {
149 my %pak; 153 my %pak;
150 154
151 open my $fh, "<:raw", $path 155 open my $fh, "<", $path
152 or Carp::croak "$_[0]: $!"; 156 or Carp::croak "$_[0]: $!";
157 binmode $fh;
153 while (<$fh>) { 158 while (<$fh>) {
154 my ($type, $id, $len, $path) = split; 159 my ($type, $id, $len, $path) = split;
155 $path =~ s/.*\///; 160 $path =~ s/.*\///;
156 read $fh, $pak{$path}, $len; 161 read $fh, $pak{$path}, $len;
157 } 162 }
172 && load_ref $cache 177 && load_ref $cache
173 } or do { 178 } or do {
174 my %arc; 179 my %arc;
175 my ($more, $prev); 180 my ($more, $prev);
176 181
177 open my $fh, "<:raw", $path 182 open my $fh, "<", $path
178 or Carp::croak "$path: $!"; 183 or Carp::croak "$path: $!";
184
185 binmode $fh;
179 186
180 my $parse_block; $parse_block = sub { 187 my $parse_block; $parse_block = sub {
181 my %arc = @_; 188 my %arc = @_;
182 189
183 while (<$fh>) { 190 while (<$fh>) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines