From a4e2383b30189c028ae35d2f587b084803e5d888 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 26 Aug 2009 02:15:16 +0100 Subject: [PATCH] Fix circular routes (including arbitrage complications) --- yarrg/TODO | 3 --- yarrg/web/routetrade | 13 +++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yarrg/TODO b/yarrg/TODO index e3ecc68..8a22088 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -23,9 +23,6 @@ commodity mass/volume in live database WEBSITE ------- -circular routes are treated as complex eg - eta, jorvik, zeta, turtle, alpha, papaya, eta - onload thing broken, need proper framework dropdowns are broken sometimes diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 9fde77e..80fc2b1 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -85,10 +85,12 @@ foreach my $src_i (0..$#islandids) { if ($specific && !$confusing && # With a circular route, do not carry goods round the loop - !($src_i==0 && $dst_i==$#islandids && + !(($src_i==0 || $src_i==$#islandids) && + $dst_i==$#islandids && $src_isle == $islandids[$dst_i])) { if ($islandpair{$src_isle,$dst_isle}) { $confusing= 1; +print "confusing $src_i $src_isle $dst_i $dst_isle\n"; } else { $islandpair{$src_isle,$dst_isle}= [ $src_i, $dst_i ]; @@ -580,6 +582,11 @@ Sail to <% $islandname |h %> next if $f->{Suppress}; next unless $f->{"${od}_id"} == $islandids[$i]; next unless $f->{OptQty}; + my $arbitrage= $f->{'org_id'} == $f->{'dst_id'}; + my $loop= $islandids[0] == $islandids[-1] && + ($i==0 || $i==$#islandids); + next if $loop and ($arbitrage ? $i : + !!$i == !!($od eq 'org')); my $price= $f->{"${od}_price"}; my $stallname= $f->{"${od}_stallname"}; my $todo= \$flowlists{$od}{ @@ -600,9 +607,7 @@ Sail to <% $islandname |h %> $$todo->{Qty} += $f->{OptQty}; $$todo->{Total}= $$todo->{Price} * $$todo->{Qty}; $$todo->{Stalls}= $f->{"${od}Stalls"}; - if ($f->{'org_id'} == $f->{'dst_id'}) { - $$todo->{"${od}Arbitrage"}= 1; - } + $$todo->{"${od}Arbitrage"}= 1 if $arbitrage; } } -- 2.30.2