#!/opt/bin/perl # mark all apartments as per_player # and remove the unique bit from the exits leading to it use File::Find; use Crossfire; use Crossfire::Map; Crossfire::load_archetypes; *name = *File::Find::name; *dir = *File::Find::dir; sub wanted { my $file = $_; -f $file or return; system "grep -q '^unique 1' \Q$file" and next; open my $fh, "<$file" or return; <$fh> =~ /^arch map/ or return; my $map = new_from_file Crossfire::Map $file or return; my $changed = 0; for my $o (map @$_, grep $_, map @$_, grep $_, @{$map->{map} || []}) { if ( ($o->{type} == 41 or !$o->{type} && $Crossfire::ARCH{$o->{_name}}{type} == 41) || ($o->{type} == 66 or !$o->{type} && $Crossfire::ARCH{$o->{_name}}{type} == 66) ) { if (delete $o->{unique}) { $changed = 1; my $path = $o->{slaying}; $path = "$dir/$path" unless $path =~ /^\//; my $map = new_from_file Crossfire::Map "./$path" or die "$path: $!"; $map->{info}{per_player} = 1; $map->write_file ("./$path"); warn "$o->{_name} $o->{slaying} $path\n";#d# } } } $map->write_file ($file) if $changed; } find { no_chdir => 1, wanted => \&wanted }, ".";