]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/weapon-profiler-analyzer.pl
Restore yet another weird path in SDL lib configs
[xonotic/xonotic.git] / misc / tools / weapon-profiler-analyzer.pl
index bbd7b912ee9d7a83f3693fc50107734612414dee..942cf0cf4903aa963bfb7fbc94eb98093418bebe 100755 (executable)
@@ -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 "<h2>For server $addr type $type map $map</h2>\n";
                print "<table><tr><th>Weapon</th><th>Rating</th>\n";
-               printf '<th><img width=70 height=80 src="http://svn.icculus.org/*checkout*/nexuiz/trunk/Docs/htmlfiles/weaponimg/thirdperson-%s.png" alt="%s"></th>', $stats->weaponid_to_model($_), $stats->weaponid_to_name($_) for @columns;
+               printf '<th><img width=64 height=87 src="weaponimg/%s_3rd_small.png" title="%s" alt="%s"></th>', $stats->weaponid_to_model($_), html $stats->weaponid_to_name($_), html nospace $stats->weaponid_to_name($_) for @columns;
                print "</tr>\n";
        }
        elsif($event eq 'startrow')
        {
                my ($row, $val) = @data;
-               printf '<tr><th><img width=108 height=53 src="http://svn.icculus.org/*checkout*/nexuiz/trunk/Docs/htmlfiles/weaponimg/firstperson-%s.png" alt="%s"></th><th align=right>%s</th>', $stats->weaponid_to_model($row), $stats->weaponid_to_name($row), defined $val ? sprintf("%8.5f", $val) : "N/A";
+               printf '<tr><th><img width=96 height=64 src="weaponimg/%s_1st_small.png" title="%s" alt="%s"></th><th align=right>%s</th>', $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')
        {
@@ -302,21 +316,25 @@ sub out_html_cache($@)
        {
                # open out file
                my ($addr, $type, $map, @columns) = @data;
-               $addr ||= ':any';
-               $type ||= ':any';
-               $map ||= ':any';
-               mkdir "$type";
-               mkdir "$type/$map";
-               open $out_html_cache_fh, ">", "$type/$map/$addr"
-                       or warn "open $type/$map/$addr: $!";
-               select $out_html_cache_fh;
+               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);
+       out_html($event, @data)
+               if defined $out_html_cache_fh;
        if($event eq 'endmatrix')
        {
                # 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;
        }
 }