ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.122 by root, Sun Nov 11 02:24:51 2012 UTC vs.
Revision 1.123 by root, Sun Nov 11 04:29:11 2012 UTC

1107} 1107}
1108 1108
1109 print "processing resources...\n" if $VERBOSE; 1109 print "processing resources...\n" if $VERBOSE;
1110 my $enc = JSON::XS->new->utf8->canonical->relaxed; 1110 my $enc = JSON::XS->new->utf8->canonical->relaxed;
1111 while (my ($k, $v) = each %RESOURCE) { 1111 while (my ($k, $v) = each %RESOURCE) {
1112
1113 if ($v->{meta} && $v->{meta}{datadir}) { 1112 if ($v->{meta} && $v->{meta}{datadir}) {
1114 delete $RESOURCE{$k}; 1113 delete $RESOURCE{$k};
1115 1114
1116 $k =~ s/^res\/// or die "$k: datadir files must be in res/"; 1115 $k =~ s/^res\/// or die "$k: datadir files must be in res/";
1117 1116
1135 1134
1136 make_hash $k, $v->{data}, $v->{hash}, 6; # 6 for the benefit of existing clients 1135 make_hash $k, $v->{data}, $v->{hash}, 6; # 6 for the benefit of existing clients
1137 } 1136 }
1138 } 1137 }
1139 1138
1139 printf "writing facedata...\n" if $VERBOSE;
1140
1141 {
1142 open my $fh, ">:perlio", "$DATADIR/facedata~"
1143 or die "$DATADIR/facedata~: $!";
1144
1145 print $fh "FACEDATA";
1146 my $fofs = 8;
1147
1148 my $put = sub {
1149 my $len = length $_[0];
1150 my $ofs = $fofs;
1151
1152 print $fh $_[0];
1153 $fofs += $len;
1154
1155 ($len, $ofs)
1156 };
1157
1158 for (values %FACEINFO) {
1159 ($_->{size32}, $_->{fofs32}) = $put->(delete $_->{data32});
1160 ($_->{size64}, $_->{fofs64}) = $put->(delete $_->{data64});
1161 }
1162
1163 for (values %RESOURCE) {
1164 ($_->{size}, $_->{fofs}) = $put->(delete $_->{data});
1165 }
1166
1167 close $fh;
1168 }
1169
1140 printf "writing facedata (%d faces, %d anims, %d resources)...\n", 1170 printf "writing faceinfo (%d faces, %d anims, %d resources)...\n",
1141 scalar keys %FACEINFO, 1171 scalar keys %FACEINFO,
1142 scalar keys %ANIMINFO, 1172 scalar keys %ANIMINFO,
1143 scalar keys %RESOURCE 1173 scalar keys %RESOURCE
1144 if $VERBOSE; 1174 if $VERBOSE;
1145 1175
1146 open my $fh, ">:perlio", "$DATADIR/facedata~" 1176 open my $fh, ">:perlio", "$DATADIR/faceinfo~"
1147 or die "$DATADIR/facedata~: $!"; 1177 or die "$DATADIR/faceinfo~: $!";
1148 1178
1149 print $fh nfreeze { 1179 print $fh nfreeze {
1150 version => 2, 1180 version => 2,
1151 faceinfo => \%FACEINFO, 1181 faceinfo => \%FACEINFO,
1152 animinfo => \%ANIMINFO, 1182 animinfo => \%ANIMINFO,
1154 }; 1184 };
1155 } 1185 }
1156 1186
1157 print "committing files...\n" if $VERBOSE; 1187 print "committing files...\n" if $VERBOSE;
1158 1188
1159 for (qw(archetypes facedata treasures), @COMMIT) { 1189 for (qw(archetypes faceinfo facedata treasures), @COMMIT) {
1160 chmod 0644, "$DATADIR/$_~"; 1190 chmod 0644, "$DATADIR/$_~";
1161 rename "$DATADIR/$_~", "$DATADIR/$_" 1191 rename "$DATADIR/$_~", "$DATADIR/$_"
1162 or die "$DATADIR/$_: $!"; 1192 or die "$DATADIR/$_: $!";
1163 } 1193 }
1164 1194

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines