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.25 by root, Fri Apr 13 05:08:51 2007 UTC vs.
Revision 1.29 by root, Wed Apr 18 09:38:58 2007 UTC

68} 68}
69 69
70sub inst_maps($) { 70sub inst_maps($) {
71 my (undef, $path) = @_; 71 my (undef, $path) = @_;
72 72
73 print "installing '$path' to '$DATADIR/maps'\n"; 73 print "\nInstalling '$path' to '$DATADIR/maps'\n\n";
74 74
75 if (!-f "$path/regions") { 75 if (!-f "$path/regions") {
76 warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; 76 warn "'$path' does not look like a maps directory ('regions' file is missing).\n";
77 exit 1 unless $FORCE; 77 exit 1 unless $FORCE;
78 } 78 }
84} 84}
85 85
86{ 86{
87 our %ANIMINFO; 87 our %ANIMINFO;
88 our %FACEINFO; 88 our %FACEINFO;
89 our @ARC; 89 our %ARC;
90 our $TRS; 90 our $TRS;
91 our $NFILE; 91 our $NFILE;
92 92
93 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 93 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
94 94
255 my $arc; 255 my $arc;
256 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ 256 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/
257 257
258 my $arc = read_arch "$dir/$file"; 258 my $arc = read_arch "$dir/$file";
259 for my $o (values %$arc) { 259 for my $o (values %$arc) {
260 push @ARC, $o; 260 $ARC{$o->{_name}} = $o;
261 261
262 $o->{editor_folder} = $dir; 262 $o->{editor_folder} = $dir;
263 263
264 my $visibility = delete $o->{visibility}; 264 my $visibility = delete $o->{visibility};
265 my $magicmap = delete $o->{magicmap}; 265 my $magicmap = delete $o->{magicmap};
276 my $x = $o->{x} - $dx; 276 my $x = $o->{x} - $dx;
277 my $y = $o->{y} - $dy; 277 my $y = $o->{y} - $dy;
278 278
279 my $ext = $x|$y ? "+$x+$y" : ""; 279 my $ext = $x|$y ? "+$x+$y" : "";
280 280
281 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/; 281 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
282 282
283 my $visibility = delete $o->{visibility} if exists $o->{visibility}; 283 my $visibility = delete $o->{visibility} if exists $o->{visibility};
284 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 284 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
285 285
286 my $anim = delete $o->{anim}; 286 my $anim = delete $o->{anim};
372 } 372 }
373 373
374 sub inst_arch($) { 374 sub inst_arch($) {
375 my (undef, $path) = @_; 375 my (undef, $path) = @_;
376 376
377 print "\n",
377 print "installing '$path' to '$DATADIR'\n", 378 "Installing '$path' to '$DATADIR'\n",
379 "\n",
378 "(this can take a long time if you run this\n", 380 "This can take a long time if you run this\n",
379 "for the first time or do not use --cache).\n"; 381 "for the first time or do not use --cache.\n",
382 "\n",
383 "Unless you run verbosely, all following warning\n",
384 "or error messages indicate serious problems.\n",
385 "\n";
380 386
381 if (!-d "$path/treasures") { 387 if (!-d "$path/treasures") {
382 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; 388 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n";
383 exit 1 unless $FORCE; 389 exit 1 unless $FORCE;
384 } 390 }
392 (async \&process_trs), (async \&process_trs), 398 (async \&process_trs), (async \&process_trs),
393 (async \&process_arc), (async \&process_arc), 399 (async \&process_arc), (async \&process_arc),
394 ); 400 );
395 401
396 { 402 {
403 # remove path prefix from editor_folder
404 substr $_->{editor_folder}, 0, 1 + length $path, ""
405 for values %ARC;
406
407 # resolve inherit
408 while () {
409 my $progress;
410 my $loop;
411
412 for my $o (values %ARC) {
413 if (my $other = $o->{inherit}) {
414 if (my $s = $ARC{$other}) {
415 if ($s->{inherit}) {
416 $loop = $s;
417 } else {
418 delete $o->{inherit};
419 %$o = ( %$s, %$o );
420 ++$progress;
421 }
422 } else {
423 warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n";
424 delete $ARC{$o->{_name}};
425 }
426 }
427 }
428
429 unless ($progress) {
430 die "inheritance loop detected starting at archetype '$loop->{_name}', aborting.\n"
431 if $loop;
432
433 last;
434 }
435 }
436
397 open my $fh, ">:utf8", "$DATADIR/archetypes~" 437 open my $fh, ">:utf8", "$DATADIR/archetypes~"
398 or die "$DATADIR/archetypes~: $!"; 438 or die "$DATADIR/archetypes~: $!";
399 substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; 439 print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } values %ARC];
400 print $fh Crossfire::archlist_to_string \@ARC;
401 } 440 }
402 441
403 { 442 {
404 open my $fh, ">:utf8", "$DATADIR/treasures~" 443 open my $fh, ">:utf8", "$DATADIR/treasures~"
405 or die "$DATADIR/treasures~: $!"; 444 or die "$DATADIR/treasures~: $!";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines