Actually, it seems ok to bump the prey position on scale to 8... no view poking out
[voretournament/voretournament.git] / data / merge-settings-into-cfg.pl
1 #!/usr/bin/perl\r
2 \r
3 use strict;\r
4 use warnings;\r
5 \r
6 my ($in, $out) = @ARGV;\r
7 \r
8 my %changes = ();\r
9 while(<STDIN>)\r
10 {\r
11         chomp;\r
12         /^(?:seta?\s)?\s*(\S+)\s+(.*)/\r
13                 or next;\r
14         $changes{$1} = $2;\r
15 }\r
16 \r
17 my %changes_unapplied = %changes;\r
18 my $result = "";\r
19 open my $fh, "<", $in\r
20         or die "<$in: $!";\r
21 while(<$fh>)\r
22 {\r
23         chomp;\r
24         /^(seta?\s?\s*)(\S+)(\s+)(.*)/\r
25                 or do { $result .= "$_\n"; next; };\r
26         my $v = exists($changes{$2}) ? $changes{$2} : $4;\r
27         $result .= "$1$2$3$v\n";\r
28         delete $changes_unapplied{$2};\r
29 }\r
30 close $fh;\r
31 open $fh, ">", $out\r
32         or die ">$out: $!";\r
33 print $fh $result;\r
34 print $fh "set $_ $changes_unapplied{$_}\n" for keys %changes_unapplied;\r
35 close $fh;\r