--- deliantra/server/utils/cfutil.in 2007/04/17 19:12:34 1.26 +++ deliantra/server/utils/cfutil.in 2007/04/18 07:59:03 1.27 @@ -86,7 +86,7 @@ { our %ANIMINFO; our %FACEINFO; - our @ARC; + our %ARC; our $TRS; our $NFILE; @@ -257,7 +257,7 @@ my $arc = read_arch "$dir/$file"; for my $o (values %$arc) { - push @ARC, $o; + $ARC{$o->{_name}} = $o; $o->{editor_folder} = $dir; @@ -374,9 +374,13 @@ sub inst_arch($) { my (undef, $path) = @_; - print "installing '$path' to '$DATADIR'\n", - "(this can take a long time if you run this\n", - "for the first time or do not use --cache).\n"; + print "Installing '$path' to '$DATADIR'\n", + "This can take a long time if you run this\n", + "for the first time or do not use --cache.\n", + "\n", + "Unless you run verbosely, all following warning\n", + "or error messages indicate serious problems.\n", + "\n"; if (!-d "$path/treasures") { warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; @@ -394,10 +398,43 @@ ); { + # remove path prefix from editor_folder + substr $_->{editor_folder}, 0, 1 + length $path, "" + for values %ARC; + + # resolve inherit + while () { + my $progress; + my $loop; + + for my $o (values %ARC) { + if (my $other = $o->{inherit}) { + if (my $s = $ARC{$other}) { + if ($s->{inherit}) { + $loop = $s; + } else { + delete $o->{inherit}; + %$o = ( %$s, %$o ); + ++$progress; + } + } else { + warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; + delete $ARC{$o->{_name}}; + } + } + } + + unless ($progress) { + die "inheritance loop detected starting at archetype '$loop->{_name}', aborting.\n" + if $loop; + + last; + } + } + open my $fh, ">:utf8", "$DATADIR/archetypes~" or die "$DATADIR/archetypes~: $!"; - substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; - print $fh Crossfire::archlist_to_string \@ARC; + print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } values %ARC]; } {