chiark / gitweb /
routesearch: show route distances
[ypp-sc-tools.db-test.git] / yarrg / web / query_routesearch
index 587a2b6dc9df0a47c1e8f55192a8f2d96123bb43..b9b734806968750d406d0f52eb4a5735e3ecbc1b 100644 (file)
@@ -52,11 +52,13 @@ my $emsg;
 my @warningfs;
 my @islandids;
 
+my $maxmaxdist=35;
+my $maxcpu=90;
+
 my $qa= \%ARGS;
 my $routeparams= { EmsgRef => \$emsg, SayRequiredCapacity => 1 };
 my $maxdist;
-my $maxcountea=10;
-my $maxcpu=10;
+my $maxcountea=15;
 
 </%perl>
 
@@ -95,8 +97,8 @@ This feature is not available from the "drop down menus" interface.
 </form>
 <%perl>
 
-if (!$emsg && $maxdist > 30) {
-       $emsg= "Searching for routes of more than 30 leagues is not".
+if (!$emsg && $maxdist > $maxmaxdist) {
+       $emsg= "Searching for routes of more than $maxmaxdist leagues is not".
                " supported, sorry.";
 }
 
@@ -152,7 +154,7 @@ my $child= $fh->open("-|"); defined $child or die $!;
 if (!$child) {
        my $cpu= BSD::Resource::RLIMIT_CPU;
        my ($soft,$hard)= getrlimit($cpu);
-       setrlimit($cpu,$maxcpu,$hard) or die $! if $soft>$maxcpu;
+       setrlimit($cpu,$maxcpu,$hard) or die $! if $hard<=$maxcpu;
        exec @rsargs;
        die $!;
 }
@@ -164,11 +166,10 @@ while (<$fh>) {
 <% $_ |h %>
 <%perl>
        }
-       next unless
-  m/^ \@ *\d+ ([ap])\# *\d+ \|.*\| *\d+ +(\d+) +(\d+) *\| ([0-9 ]+)$/;
-       my ($ap,$isles) = (uc $1,$4);
+       next unless m/^ \@ *\d+ ([ap])\# *\d+ \|.*\| *(\d+)lg *\| *\d+ +(\d+) +(\d+) *\| ([0-9 ]+)$/;
+       my ($ap,$isles) = (uc $1,$5);
        next if $results{$ap} && %{$results{$ap}} >= $maxcountea;
-       my $item= { A => $2, P => $3 };
+       my $item= { A => $3, P => $4, Leagues => $2 };
        my (@i, @a);
        foreach (split / /, $isles) {
                my ($name,$arch)= $isleinfo->($_);
@@ -201,12 +202,14 @@ if ($qa->{'debug'}) {
 <tbody>
 <tr>
 <th colspan=2>Profit
+<th>Dist.
 <th>Archipelagoes
 <th colspan=3>Route
 <tr>
 <th>Abs.
 <th>Per.lg.
 <th>
+<th>
 <th>Start
 <th>Via
 <th>Finish
@@ -220,6 +223,7 @@ if ($qa->{'debug'}) {
 <tr class="datarow<% $datarow %>">
 <td align=right><% $item->{A} |h %>
 <td align=right><% $item->{P} |h %>
+<td align=right><% $item->{Leagues} |h %>
 <td align=left><% join ', ', @{ $item->{Archs} } |h %>
 <td align=left><% $item->{Start} |h %>,
 <td align=left><% join ' ', map { $_.',' } @{ $item->{Vias} } |h %>