11 $p =~ s/(?:\.jpg|\.png|\.tga)$//gi;
16 my $find_texture_names = grep { /^-t$/ } @ARGV;
17 my $dump_shaders = grep { /^-d$/ } @ARGV;
18 my @match = grep { !/^-/ } @ARGV;
33 my @line = map { s/"//g; $_; } split /\s+/, $_;
37 # allow trailing } token
38 my $brace_index = [grep { $line[$_] eq "}" } 0..@line-1]->[0];
39 if(defined $brace_index)
41 @nextline = splice @line, $brace_index || 1;
44 # allow initial { token
45 if(@line >= 2 && $line[0] eq '{')
47 @nextline = splice @line, 1;
50 $shadertext .= "@line\n";
54 die "{ line without shader name"
55 unless defined $curshader;
56 die "{ line in level $level"
60 elsif($line[0] eq '}')
62 die "} line contains other stuff"
64 die "} line without shader name"
65 unless defined $curshader;
66 die "{ line in level $level"
73 if(!@match || grep { $_ eq $curshader } @match)
75 printf "%s %s\n", Digest::MD5::md5_hex($shadertext), $curshader;
77 if($find_texture_names)
79 # find out possibly loaded textures
80 my @maps = ($shadertext =~ /^(?:clampmap|map|q3r_lightimage|q3r_editorimage) ([^\$].*)$/gim);
81 for($shadertext =~ /^animmap \S+ (.*)$/gim)
83 push @maps, split / /, $_;
85 for($shadertext =~ /^skyparms (.*)$/gim)
90 push @maps, "$_"."_lf";
91 push @maps, "$_"."_ft";
92 push @maps, "$_"."_rt";
93 push @maps, "$_"."_bk";
94 push @maps, "$_"."_up";
95 push @maps, "$_"."_dn";
100 printf "* %s %s\n", $_, $curshader
101 for map { normalize_path $_ } @maps;
106 print "| $_\n" for split /\n/, $shadertext;
115 die "shader name already set"
116 if defined $curshader;
117 $curshader = normalize_path $line[0];
131 die "missing } line";