X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=misc%2Ftools%2Fweapon-profiler-analyzer.pl;h=942cf0cf4903aa963bfb7fbc94eb98093418bebe;hp=f168983bee98641ddc7874c1f34ed0f09a397a10;hb=37e3d71e28441abac3bc00682559b0076fe8dde2;hpb=8b1a391dfa525224e562f50b45929dd9909e0d6d diff --git a/misc/tools/weapon-profiler-analyzer.pl b/misc/tools/weapon-profiler-analyzer.pl index f168983b..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') { @@ -318,7 +332,8 @@ sub out_html_cache($@) { # close out file select STDOUT; - close $out_html_cache_fh; + close $out_html_cache_fh + if defined $out_html_cache_fh; undef $out_html_cache_fh; } }
WeaponRating%s%s
%s%s
%s%s