File: effectinfo-addcomments.pl

package info (click to toggle)
nexuiz-data 2.5.2-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,294,288 kB
  • sloc: ansic: 10,523; perl: 6,845; sh: 2,188; java: 1,417; xml: 969; lisp: 519; ruby: 136; makefile: 125
file content (65 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (6)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl

use strict;
use warnings;

my $out = "";
my %found;

open my $fh, '<', 'effectinfo.txt';
while(<$fh>)
{
	chomp;

	next if /^\/\/ used in /;
	next if /^\/\/ used nowhere in code$/;

	if(/^effect\s+([^\s\/]+)\s*(?:\/\/.*)?$/i)
	{
		if(!$found{$1})
		{
			print STDERR "Handling $1...\n";
			$found{$1} = 1;
			my $search = $1;
			my $search2 =
				$1 eq 'TR_BLOOD' ? 'MF_GIB' :
				$1 eq 'TR_SLIGHTBLOOD' ? 'MF_ZOMGIB' :
				$1 eq 'TR_WIZSPIKE' ? 'MF_TRACER' :
				$1 eq 'TR_KNIGHTSPIKE' ? 'MF_TRACER2' :
				$1 eq 'TR_ROCKET' ? 'MF_ROCKET' :
				$1 eq 'TR_GRENADE' ? 'MF_GRENADE' :
				$1 eq 'TR_VORESPIKE' ? 'MF_TRACER3' :
				$1;
			local $ENV{effectre} =
				$search eq lc $search
					? "\"$search\"|\"$search2\""
					: "\"$search\"|\\<" . lc($search) . "\\>|\\<" . $search . "\\>|"
					. "\"$search2\"|\\<" . lc($search2) . "\\>|\\<" . $search2 . "\\>";
			print "$ENV{effectre}\n";
			my $occurrences = `grep -E "\$effectre" qcsrc/server/*.qc qcsrc/client/*.qc`;
			$occurrences =~ s/\r/\n/g;
			$occurrences =~ s/;//g;
			my $found = 0;
			for(split /\n/, $occurrences)
			{
				next if $_ eq '';
				next if /^qcsrc\/server\/gamecommand\.qc:/; # list of quake effects is there
				next if /^qcsrc\/client\/csqc_builtins\.qc:/; # list of quake effects is there
				next if /^qcsrc\/client\/csqc_constants\.qc:/; # list of quake effects is there
				$out .= "// used in $_\n";
				$found = 1;
			}
			if(!$found)
			{
				$out .= "// used nowhere in code\n";
			}
		}
	}

	$out .= "$_\n";
}
close $fh;

open $fh, '>', 'effectinfo.txt';
print $fh $out;
close $fh;