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.6 by root, Sun Mar 11 02:12:45 2007 UTC vs.
Revision 1.12 by root, Mon Mar 12 17:26:41 2007 UTC

81 81
82{ 82{
83 our %PNG32; 83 our %PNG32;
84 our %FACEINFO; 84 our %FACEINFO;
85 our @ARC; 85 our @ARC;
86 our $TRS;
86 our $NFILE; 87 our $NFILE;
87 our %ANIM; 88 our %ANIM;
89 our $SMOOTH;
88 90
89 our (@png, @trs, @arc); # files we are interested in 91 our (@png, @trs, @arc); # files we are interested in
90 92
91 sub commit_png { 93 sub commit_png {
92 my ($name, $data) = @_; 94 my ($name, $data) = @_;
154 (map { 156 (map {
155 ( 157 (
156 "(", 158 "(",
157 "+clone", 159 "+clone",
158 -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T), 160 -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T),
161 "+repage",
159 -write => "png:$_->[2]~", 162 -write => "png:$_->[2]~",
160 "+delete", 163 "+delete",
161 ")", 164 ")",
162 ) 165 )
163 } @todo), 166 } @todo),
201 204
202 my $arc = read_arch "$dir/$file"; 205 my $arc = read_arch "$dir/$file";
203 for my $o (values %$arc) { 206 for my $o (values %$arc) {
204 push @ARC, $o; 207 push @ARC, $o;
205 208
209 $o->{editor_folder} = $dir;
210
206 my $visibility = delete $o->{visibility}; 211 my $visibility = delete $o->{visibility};
207 my $magicmap = delete $o->{magicmap}; 212 my $magicmap = delete $o->{magicmap};
208 213
209 # find upper left corner :/ 214 # find upper left corner :/
210 # omg, this is sooo broken 215 # omg, this is sooo broken
218 my $x = $o->{x} - $dx; 223 my $x = $o->{x} - $dx;
219 my $y = $o->{y} - $dy; 224 my $y = $o->{y} - $dy;
220 225
221 my $ext = $x|$y ? "+$x+$y" : ""; 226 my $ext = $x|$y ? "+$x+$y" : "";
222 227
223 $o->{face} .= $ext; 228 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/;
224 229
225 my $visibility = delete $o->{visibility} if exists $o->{visibility}; 230 my $visibility = delete $o->{visibility} if exists $o->{visibility};
226 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 231 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
227 232
228 my $anim = delete $o->{anim}; 233 my $anim = delete $o->{anim};
229 234
230 if ($anim) { 235 if ($anim) {
231 $o->{animation} = "$o->{_name}$ext"; 236 $o->{animation} = "$o->{_name}";
232 237
233 for (@$anim) { 238 for (@$anim) {
234 $_ .= $ext unless /^facings\s/; 239 $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/;
235 } 240 }
236 241
237 $ANIM{"$o->{_name}$ext"} = 242 $ANIM{"$o->{_name}$ext"} =
238 join "", map "$_\n", 243 join "", map "$_\n",
239 "anim $o->{_name}$ext", 244 "anim $o->{_name}",
240 @$anim, 245 @$anim,
241 "mina"; 246 "mina";
242 } 247 }
243 248
244 for my $face ($o->{face} || (), @{$anim || []}) { 249 for my $face ($o->{face} || (), @{$anim || []}) {
245 next if /^facings\s/; 250 next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/;
246 251
247 my $info = $FACEINFO{$face} ||= {}; 252 my $info = $FACEINFO{$face} ||= {};
248 253
249 $info->{visibility} = $visibility if defined $visibility; 254 $info->{visibility} = $visibility if defined $visibility;
250 $info->{magicmap} = $magicmap if defined $magicmap; 255 $info->{magicmap} = $magicmap if defined $magicmap;
256 }
257
258 if (my $smooth = delete $o->{smoothface}) {
259 $SMOOTH .= "$smooth\n";
251 } 260 }
252 } 261 }
253 } 262 }
254 } 263 }
255 } 264 }
256 265
257 sub process_trs { 266 sub process_trs {
258 while (@trs) { 267 while (@trs) {
259 my ($dir, $file) = @{pop @trs}; 268 my ($dir, $file) = @{pop @trs};
269 my $path = "$dir/$file";
270
271 my $trs;
272 if (0 > aio_load $path, $trs) {
273 warn "$path: $!, skipping.\n";
274 next;
275 }
276
277 $TRS .= $trs;
260 } 278 }
261 } 279 }
262 280
263 sub find_files; 281 sub find_files;
264 sub find_files { 282 sub find_files {
311 } 329 }
312 330
313 { 331 {
314 open my $fh, ">:utf8", "$DATADIR/archetypes~" 332 open my $fh, ">:utf8", "$DATADIR/archetypes~"
315 or die "$DATADIR/archetypes~: $!"; 333 or die "$DATADIR/archetypes~: $!";
334 substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC;
316 print $fh Crossfire::archlist_to_string \@ARC; 335 print $fh Crossfire::archlist_to_string \@ARC;
336 }
337
338 {
339 open my $fh, ">:utf8", "$DATADIR/smooth~"
340 or die "$DATADIR/smooth~: $!";
341 print $fh $SMOOTH;
342 }
343
344 {
345 open my $fh, ">:utf8", "$DATADIR/treasures~"
346 or die "$DATADIR/treasures~: $!";
347 print $fh $TRS;
317 } 348 }
318 349
319 { 350 {
320 while (my ($k, $v) = each %FACEINFO) { 351 while (my ($k, $v) = each %FACEINFO) {
321 $v->{data32} ||= delete $PNG32{$k}; 352 $v->{data32} ||= delete $PNG32{$k};
322 } 353 }
323 354
324 while (my ($k, $v) = each %FACEINFO) { 355 while (my ($k, $v) = each %FACEINFO) {
325 exists $v->{data32} or warn "$k: face has no png32. this will crash the server.\n"; 356 length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n";
326 357
327 $v->{chksum32} = Digest::MD5::md5 $v->{data32}; 358 $v->{chksum32} = Digest::MD5::md5 $v->{data32};
328 } 359 }
329 360
330 open my $fh, ">:perlio", "$DATADIR/faces~" 361 open my $fh, ">:perlio", "$DATADIR/faces~"
331 or die "$DATADIR/faces~: $!"; 362 or die "$DATADIR/faces~: $!";
332 363
333 print $fh Storable::nfreeze \%FACEINFO; 364 print $fh Storable::nfreeze \%FACEINFO;
334
335 #use PApp::Util; warn PApp::Util::dumpval \%FACEINFO;
336 } 365 }
337 366
338 for (qw(archetypes faces animations)) { 367 for (qw(archetypes faces animations treasures smooth)) {
339 chmod 0644, "$DATADIR/$_~"; 368 chmod 0644, "$DATADIR/$_~";
340 rename "$DATADIR/$_~", "$DATADIR/$_"; 369 rename "$DATADIR/$_~", "$DATADIR/$_";
341 } 370 }
342
343 die "--install-arch not fully implemented\n";
344 } 371 }
345} 372}
346 373
347Getopt::Long::Configure ("bundling", "no_ignore_case"); 374Getopt::Long::Configure ("bundling", "no_ignore_case");
348GetOptions ( 375GetOptions (

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines