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