ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/util/mark-apartments
Revision: 1.1
Committed: Fri Dec 29 15:55:30 2006 UTC (17 years, 5 months ago) by root
Branch: MAIN
CVS Tags: rel-2_2, rel-2_0, rel-2_1, HEAD
Log Message:
added mark-apartments, marsk apartments as per-player and removes unique flag from exits

File Contents

# Content
1 #!/opt/bin/perl
2
3 # mark all apartments as per_player
4 # and remove the unique bit from the exits leading to it
5
6 use File::Find;
7 use Crossfire;
8 use Crossfire::Map;
9
10 Crossfire::load_archetypes;
11
12 *name = *File::Find::name;
13 *dir = *File::Find::dir;
14
15 sub wanted {
16 my $file = $_;
17 -f $file or return;
18
19 system "grep -q '^unique 1' \Q$file"
20 and next;
21
22 open my $fh, "<$file" or return;
23 <$fh> =~ /^arch map/ or return;
24
25 my $map = new_from_file Crossfire::Map $file
26 or return;
27
28 my $changed = 0;
29 for my $o (map @$_, grep $_, map @$_, grep $_, @{$map->{map} || []}) {
30 if (
31 ($o->{type} == 41 or !$o->{type} && $Crossfire::ARCH{$o->{_name}}{type} == 41)
32 || ($o->{type} == 66 or !$o->{type} && $Crossfire::ARCH{$o->{_name}}{type} == 66)
33 ) {
34 if (delete $o->{unique}) {
35 $changed = 1;
36
37 my $path = $o->{slaying};
38 $path = "$dir/$path" unless $path =~ /^\//;
39
40 my $map = new_from_file Crossfire::Map "./$path"
41 or die "$path: $!";
42
43 $map->{info}{per_player} = 1;
44 $map->write_file ("./$path");
45
46 warn "$o->{_name} $o->{slaying} $path\n";#d#
47 }
48 }
49 }
50
51 $map->write_file ($file) if $changed;
52 }
53
54 find { no_chdir => 1, wanted => \&wanted }, ".";
55