X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fweapon-profiler-analyzer.pl;h=942cf0cf4903aa963bfb7fbc94eb98093418bebe;hb=a6584ad54d36700179ca5396fd3b383392731215;hp=1461d8e50c7b4c0c9f81d172363df5bb2197bc32;hpb=864c4b3126439d3d84992e1fe78678ab52dac05b;p=xonotic%2Fxonotic.git diff --git a/misc/tools/weapon-profiler-analyzer.pl b/misc/tools/weapon-profiler-analyzer.pl index 1461d8e5..942cf0cf 100755 --- a/misc/tools/weapon-profiler-analyzer.pl +++ b/misc/tools/weapon-profiler-analyzer.pl @@ -234,6 +234,20 @@ sub out_text($@) } } +sub html($) +{ + my ($s) = @_; + $s =~ s/[^-_A-Za-z0-9 ]/&#@{[ord $&]};/g; + return $s; +} + +sub nospace($) +{ + my ($s) = @_; + $s =~ s/ //g; + return $s; +} + sub out_html($@) { my ($event, @data) = @_; @@ -249,13 +263,13 @@ sub out_html($@) $map ||= 'any'; print "

For server $addr type $type map $map

\n"; print "\n"; - printf '', $stats->weaponid_to_model($_), $stats->weaponid_to_name($_) for @columns; + printf '', $stats->weaponid_to_model($_), html $stats->weaponid_to_name($_), html nospace $stats->weaponid_to_name($_) for @columns; print "\n"; } elsif($event eq 'startrow') { my ($row, $val) = @data; - printf '', $stats->weaponid_to_model($row), $stats->weaponid_to_name($row), defined $val ? sprintf("%8.5f", $val) : "N/A"; + printf '', $stats->weaponid_to_model($row), html $stats->weaponid_to_name($row), html nospace $stats->weaponid_to_name($row), defined $val ? sprintf("%8.5f", $val) : "N/A"; } elsif($event eq 'cell') { @@ -294,7 +308,40 @@ sub out_html($@) } } -my $out = $ENV{html} ? \&out_html : \&out_text; +my $out_html_cache_fh; +sub out_html_cache($@) +{ + my ($event, @data) = @_; + if($event eq 'startmatrix') + { + # open out file + my ($addr, $type, $map, @columns) = @data; + if(!defined $addr) + { + $type ||= ':any'; + $map ||= ':any'; + mkdir "$type"; + open $out_html_cache_fh, ">", "$type/$map" + or warn "open $type/$map: $!"; + select $out_html_cache_fh; + } + } + out_html($event, @data) + if defined $out_html_cache_fh; + if($event eq 'endmatrix') + { + # close out file + select STDOUT; + close $out_html_cache_fh + if defined $out_html_cache_fh; + undef $out_html_cache_fh; + } +} + +my $out = + $ENV{html_cache} ? \&out_html_cache : + $ENV{html} ? \&out_html : + \&out_text; LoadData(); $out->(start => ());
WeaponRating%s%s
%s%s
%s%s