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.121 by root, Mon Oct 29 22:50:10 2012 UTC vs.
Revision 1.123 by root, Sun Nov 11 04:29:11 2012 UTC

805 } 805 }
806 } 806 }
807 807
808 substr $dir, 0, 1 + length $PATH, ""; 808 substr $dir, 0, 1 + length $PATH, "";
809 809
810 $RESOURCE{"$dir/$file"} = { 810 my %info = (
811 type => (exists $meta->{type} ? delete $meta->{type} : $type), 811 type => (exists $meta->{type} ? delete $meta->{type} : $type),
812 data => $data, 812 data => $data,
813 %$meta ? (meta => $meta) : (), 813 %$meta ? (meta => $meta) : (),
814 }; 814 );
815
816 $RESOURCE{"$dir/$file"} = \%info;
815 } 817 }
816 818
817 sub process_any { 819 sub process_any {
818 while (my ($func, @args) = @{ $c_any->get }) { 820 while (my ($func, @args) = @{ $c_any->get }) {
819 $func->(@args); 821 $func->(@args);
1105} 1107}
1106 1108
1107 print "processing resources...\n" if $VERBOSE; 1109 print "processing resources...\n" if $VERBOSE;
1108 my $enc = JSON::XS->new->utf8->canonical->relaxed; 1110 my $enc = JSON::XS->new->utf8->canonical->relaxed;
1109 while (my ($k, $v) = each %RESOURCE) { 1111 while (my ($k, $v) = each %RESOURCE) {
1110
1111 if ($v->{meta} && $v->{meta}{datadir}) { 1112 if ($v->{meta} && $v->{meta}{datadir}) {
1112 delete $RESOURCE{$k}; 1113 delete $RESOURCE{$k};
1113 1114
1114 $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/";
1115 1116
1133 1134
1134 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
1135 } 1136 }
1136 } 1137 }
1137 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
1138 printf "writing facedata (%d faces, %d anims, %d resources)...\n", 1170 printf "writing faceinfo (%d faces, %d anims, %d resources)...\n",
1139 scalar keys %FACEINFO, 1171 scalar keys %FACEINFO,
1140 scalar keys %ANIMINFO, 1172 scalar keys %ANIMINFO,
1141 scalar keys %RESOURCE 1173 scalar keys %RESOURCE
1142 if $VERBOSE; 1174 if $VERBOSE;
1143 1175
1144 open my $fh, ">:perlio", "$DATADIR/facedata~" 1176 open my $fh, ">:perlio", "$DATADIR/faceinfo~"
1145 or die "$DATADIR/facedata~: $!"; 1177 or die "$DATADIR/faceinfo~: $!";
1146 1178
1147 print $fh nfreeze { 1179 print $fh nfreeze {
1148 version => 2, 1180 version => 2,
1149 faceinfo => \%FACEINFO, 1181 faceinfo => \%FACEINFO,
1150 animinfo => \%ANIMINFO, 1182 animinfo => \%ANIMINFO,
1152 }; 1184 };
1153 } 1185 }
1154 1186
1155 print "committing files...\n" if $VERBOSE; 1187 print "committing files...\n" if $VERBOSE;
1156 1188
1157 for (qw(archetypes facedata treasures), @COMMIT) { 1189 for (qw(archetypes faceinfo facedata treasures), @COMMIT) {
1158 chmod 0644, "$DATADIR/$_~"; 1190 chmod 0644, "$DATADIR/$_~";
1159 rename "$DATADIR/$_~", "$DATADIR/$_" 1191 rename "$DATADIR/$_~", "$DATADIR/$_"
1160 or die "$DATADIR/$_: $!"; 1192 or die "$DATADIR/$_: $!";
1161 } 1193 }
1162 1194

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines