]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
weapon profiler: support a new file format that includes all data (for bots too,...
authorRudolf Polzer <divverent@alientrap.org>
Sun, 23 Jan 2011 18:33:15 +0000 (19:33 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 23 Jan 2011 18:33:15 +0000 (19:33 +0100)
misc/tools/WeaponEncounterProfile.pm

index 08d36bb11effe7f02a74653f3dd3e8dc7926434e..1da3cc2b2a67444137d10ddaae39f31bb1f3bb53 100644 (file)
@@ -27,7 +27,27 @@ sub load($)
                /^$/ and next;
                /^#/ and next;
                /^\/\// and next;
-               my ($addr, $map, $attackerweapon, $targweapon, $value) = split /\t/, $_;
+               my ($addr, $map, $attackerweapon, $targweapon, $value);
+               if(/^(\S+)\t(\S+)\t(\d+) (\d+)\t(\d+) (\d+)\t(\d+) (\d+) (\S+)$/)
+               {
+                       # new format (Xonotic)
+                       ($addr, $map, $attackerweapon, $targweapon) = ($1, $2, $3, $5);
+                       next if $4 and not $ENV{WEAPONPROFILER_WITHBOTS};
+                       next if $6 and not $ENV{WEAPONPROFILER_WITHBOTS};
+                       $value =
+                               $ENV{WEAPONPROFILER_DAMAGE} ? $9 :
+                               $ENV{WEAPONPROFILER_HITS} ? $8 :
+                               $7;
+               }
+               elsif(/^(\S+)\t(\S+)\t(\d+)\t(\d+)\t(\S+)$/)
+               {
+                       # legacy format (Nexuiz)
+                       ($addr, $map, $attackerweapon, $targweapon, $value) = ($1, $2, $3, $4, $5);
+               }
+               else
+               {
+                       next;
+               }
                $targweapon = int $self->weaponid_from_name($targweapon)
                        if $targweapon ne int $targweapon;
                $attackerweapon = int $self->weaponid_from_name($attackerweapon)