| 1 |
elmex |
1.1 |
#!/opt/perl/bin/perl |
| 2 |
|
|
# |
| 3 |
|
|
# this script converts the old face names to the new ones and checks whether |
| 4 |
|
|
# the face can be found in the list of image filenames. |
| 5 |
|
|
# |
| 6 |
|
|
# First make a list of filenames: |
| 7 |
|
|
# find cf.schmorp.de/arch/ -name "*.png" -print > /tmp/face.filenames |
| 8 |
|
|
# |
| 9 |
|
|
# Second make a json file with the uuid->face mapping: |
| 10 |
|
|
# cd /var/crossfire/ |
| 11 |
|
|
# grep_for_uuid_faces > /tmp/face.json |
| 12 |
|
|
# |
| 13 |
|
|
# Third call this to convert the facenames in the face.json: |
| 14 |
|
|
# json_conv_old_faces /tmp/face.json /tmp/face.filenames > /tmp/newface.json |
| 15 |
|
|
# |
| 16 |
|
|
# finished. |
| 17 |
|
|
# |
| 18 |
|
|
use strict; |
| 19 |
|
|
use JSON::Syck; |
| 20 |
|
|
|
| 21 |
|
|
open J, $ARGV[0] or die "$!"; |
| 22 |
|
|
open F, $ARGV[1] or die "$!"; |
| 23 |
|
|
|
| 24 |
|
|
my $h = JSON::Syck::Load (do { local $/; <J> }); |
| 25 |
|
|
my @files = split /\r?\n/, do { local $/; <F> }; |
| 26 |
|
|
|
| 27 |
|
|
my %faces; |
| 28 |
|
|
$faces{$_} = 1 for (values %$h); |
| 29 |
|
|
|
| 30 |
|
|
my %filenames; |
| 31 |
|
|
my %collided; |
| 32 |
|
|
|
| 33 |
|
|
for (@files) { |
| 34 |
|
|
next if /\.xvpics/; |
| 35 |
|
|
s/^.*\/([^\/]*)$/\1/; |
| 36 |
|
|
if ($filenames{$_}) { |
| 37 |
|
|
warn "filename collision in $_\n" if $filenames{$_}; |
| 38 |
|
|
$collided{$_} = 1; |
| 39 |
|
|
} |
| 40 |
|
|
$filenames{$_} = 1; |
| 41 |
|
|
} |
| 42 |
|
|
|
| 43 |
|
|
my $first = 1; |
| 44 |
|
|
print "{"; |
| 45 |
|
|
for my $k (keys %$h) { |
| 46 |
|
|
|
| 47 |
|
|
local $_ = $h->{$k}; |
| 48 |
|
|
|
| 49 |
|
|
my $fn; |
| 50 |
elmex |
1.2 |
if (/\.x..$/) { $fn = $_ } |
| 51 |
elmex |
1.1 |
elsif (s/(sparkling|(?:ice|fire|acid)born).(\d)\2\2$/\1.x1\2/) { $fn = $_ } |
| 52 |
|
|
elsif (s/\.\d(..)$/.x\1/) { $fn = $_ } |
| 53 |
|
|
else { die "error in face for $k: $_" } |
| 54 |
|
|
|
| 55 |
|
|
my $file = $fn; |
| 56 |
|
|
$file =~ s/^(.*)\.(x..)$/\1.base.\2.png/; |
| 57 |
|
|
|
| 58 |
|
|
if ($filenames{$file}) { |
| 59 |
|
|
if ($collided{$file}) { |
| 60 |
|
|
warn "face $fn -> $file has colliding filenames\n"; |
| 61 |
|
|
} |
| 62 |
|
|
print "," unless $first; |
| 63 |
|
|
$first = 0; |
| 64 |
|
|
print "\n\"$k\":\"$fn\""; |
| 65 |
|
|
} else { |
| 66 |
|
|
warn "no such face: $_ -> $fn\n"; |
| 67 |
|
|
} |
| 68 |
|
|
} |
| 69 |
|
|
print "\n}\n"; |