changeset 217:138a3143a1fd misc

Add adjustable spell/skill detection threshold line distance factor option '-f'.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 05 Aug 2011 22:53:07 +0300
parents f121fb47c65f
children e5e8083769fa
files log2template.pl
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/log2template.pl	Fri Aug 05 22:27:16 2011 +0300
+++ b/log2template.pl	Fri Aug 05 22:53:07 2011 +0300
@@ -37,7 +37,7 @@
 my $opt_locpath;
 my $opt_identify = 1;
 my $opt_npc = 1;
-
+my $opt_dist = 1;
 
 # Define the regular expression to match any outputs of "say"
 # as this is somewhat race-dependant.
@@ -100,6 +100,12 @@
   elsif ($arg eq "-L") {
     $opt_locpath = shift or die("Locfile path option -L requires an argument.\n");
   }
+  elsif ($arg eq "-f") {
+    $opt_dist = shift or die("Distance factor option -f requires an argument.\n");
+    if ($opt_dist < 1 || $opt_dist > 50) {
+      die("-f value must be 1 .. 50.\n");
+    }
+  }
   else {
     die("Invalid option '$arg'.
 Usage: $0 [options] < input.log > output.txt
@@ -109,6 +115,7 @@
     -i                    Disable identify parser.
     -n                    Disable NPC parser.
     -L <locfile_path>     Path to <continent_name>.loc files.
+    -f <value>            Set spell/skill detection line distance factor.
 
 ");
   }
@@ -680,8 +687,8 @@
   # Spells
   my $hasspells = 0;
   if (defined($spells{$mname}) && length($mname) >= 4) {
-    my $maxdist = length($mname) * 150 * length($mname);
-    my $mindist = length($mname) * -5 * length($mname);
+    my $maxdist = length($mname) * 150 * $opt_dist * length($mname);
+    my $mindist = length($mname) * -5 * $opt_dist * length($mname);
     my %mspells = ();
     foreach my $sline (sort { $a <=> $b } keys %{$spells{$mname}}) {
       my $offs = $sline - $mline;
@@ -730,8 +737,8 @@
   # Skills
   my $hasskills = 0;
   if (defined($skills{$mname}) && length($mname) >= 4) {
-    my $maxdist = length($mname) * 150 * length($mname);
-    my $mindist = length($mname) * -5 * length($mname);
+    my $maxdist = length($mname) * 150 * $opt_dist * length($mname);
+    my $mindist = length($mname) * -5 * $opt_dist * length($mname);
     my %mskills = ();
     foreach my $sline (sort { $a <=> $b } keys %{$skills{$mname}}) {
       my $offs = $sline - $mline;