summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/tiledef_lint
blob: 6410b7b85a6c517b760cf0563f39027d6fd119aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl -w

my %defs;

sub check_defs($$$@)
{
    my ($file, $symbol, $prefix, @ok) = @_;
    undef %defs;
    open IN, "<rltiles/tiledef-$file.h" or die "tiledefs must be generated\n";
    while (<IN>)
    {
        next unless /TILE${symbol}_($prefix[A-Z0-9_]+)/;
        # multi-tile enums receive _1 _2 _3 automatically.  Could cause problems
        # if we get such a name written manually.
        next if $1 =~ /[0-9]$/;
        $defs{$1} = 1;
    }
    close IN;

    delete $defs{$_} for @ok;

    return unless %defs;
    print "Unused $prefix$file tiles (TILE${symbol}_):\n";
    print "$_\n" for sort keys %defs;
}

check_defs 'player', 'P', 'MONS_', map {chomp;$_}`util/gather_tiles_mons`;
check_defs 'gui', 'G', '', map {chomp;$_}`util/gather_tiles_gui`;