]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - effectinfo-addcomments.pl
Transifex autosync
[xonotic/xonotic-data.pk3dir.git] / effectinfo-addcomments.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $out = "";
7 my %found;
8
9 open my $fh, '<', 'effectinfo.txt';
10 while(<$fh>)
11 {
12         chomp;
13
14         next if /^\/\/ used in /;
15         next if /^\/\/ used nowhere in code$/;
16
17         if(/^effect\s+([^\s\/]+)\s*(?:\/\/.*)?$/i)
18         {
19                 if(!$found{$1})
20                 {
21                         print STDERR "Handling $1...\n";
22                         $found{$1} = 1;
23                         my $search = $1;
24                         my $search2 =
25                                 $1 eq 'TR_BLOOD' ? 'MF_GIB' :
26                                 $1 eq 'TR_SLIGHTBLOOD' ? 'MF_ZOMGIB' :
27                                 $1 eq 'TR_WIZSPIKE' ? 'MF_TRACER' :
28                                 $1 eq 'TR_KNIGHTSPIKE' ? 'MF_TRACER2' :
29                                 $1 eq 'TR_ROCKET' ? 'MF_ROCKET' :
30                                 $1 eq 'TR_GRENADE' ? 'MF_GRENADE' :
31                                 $1 eq 'TR_VORESPIKE' ? 'MF_TRACER3' :
32                                 $1;
33                         local $ENV{effectre} =
34                                 $search eq lc $search
35                                         ? "\"$search\"|\"$search2\""
36                                         : "\"$search\"|\\<" . lc($search) . "\\>|\\<" . $search . "\\>|"
37                                         . "\"$search2\"|\\<" . lc($search2) . "\\>|\\<" . $search2 . "\\>";
38                         print "$ENV{effectre}\n";
39                         my $occurrences = `grep -E "\$effectre" qcsrc/server/*.qc qcsrc/client/*.qc`;
40                         $occurrences =~ s/\r/\n/g;
41                         $occurrences =~ s/;//g;
42                         my $found = 0;
43                         for(split /\n/, $occurrences)
44                         {
45                                 next if $_ eq '';
46                                 next if /^qcsrc\/server\/gamecommand\.qc:/; # list of quake effects is there
47                                 next if /^qcsrc\/client\/csqc_builtins\.qc:/; # list of quake effects is there
48                                 next if /^qcsrc\/client\/csqc_constants\.qc:/; # list of quake effects is there
49                                 $out .= "// used in $_\n";
50                                 $found = 1;
51                         }
52                         if(!$found)
53                         {
54                                 $out .= "// used nowhere in code\n";
55                         }
56                 }
57         }
58
59         $out .= "$_\n";
60 }
61 close $fh;
62
63 open $fh, '>', 'effectinfo.txt';
64 print $fh $out;
65 close $fh;