X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute.pm;h=868317a9646234b9093a2598048a3a795f71e8d3;hb=eef5dcbb47966521543e82dbb0b9269ec245d3d8;hp=415d1744f2f7ebcf263d55c9930797d27cf30303;hpb=fd0a34c34ad4112ee21e0730f7307498ff437e18;p=spider.git diff --git a/perl/Route.pm b/perl/Route.pm index 415d1744..868317a9 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -181,6 +181,7 @@ sub config { my $self = shift; my $nodes_only = shift || 0; + my $width = shift || 79; my $level = shift; my $seen = shift; my @out; @@ -200,7 +201,7 @@ sub config $pcall .= ":" . $self->obscount if isdbg('obscount'); - $line = ' ' x ($level*2) . "$pcall"; + $line = ' ' x ($level*2) . $pcall; $pcall = ' ' x length $pcall; # recursion detector @@ -223,7 +224,7 @@ sub config } else { $c = "$ucall?"; } - if ((length $line) + (length $c) + 1 < 79) { + if ((length $line) + (length $c) + 1 < $width) { $line .= $c . ' '; } else { $line =~ s/\s+$//; @@ -251,7 +252,7 @@ sub config if ($nref) { my $c = $nref->user_call; dbg("recursing from $call -> $c") if isdbg('routec'); - my @rout = $nref->config($nodes_only, $level+1, $seen, @_); + my @rout = $nref->config($nodes_only, $width, $level+1, $seen, @_); if (@rout && @_) { push @out, ' ' x ($level*2) . $self->user_call unless grep /^\s+$call/, @out; } @@ -296,6 +297,8 @@ sub findroutes # recursion detector return () if $seen->{$call}; + + # return immediately if we are directly connected if (my $dxchan = DXChannel::get($call)) { $seen->{$call}++; push @out, $level ? [$level, $dxchan] : $dxchan; @@ -305,15 +308,46 @@ sub findroutes # deal with more nodes my $nref = Route::get($call); + return () unless $nref; foreach my $ncall (@{$nref->{parent}}) { unless ($seen->{$ncall}) { - dbg("recursing from $call -> $ncall") if isdbg('routec'); - my @rout = findroutes($ncall, $level+1, $seen); + + # put non-pc9x nodes to the back of the queue + my $l = $level + ($nref->{do_pc9x} && ($nref->{version}||5454) >= 5454 ? 0 : 30); + dbg("recursing from $call -> $ncall level $l") if isdbg('routec'); + my @rout = findroutes($ncall, $l+1, $seen); push @out, @rout; } } - return $level == 0 ? map {$_->[1]} sort {$a->[0] <=> $b->[0]} @out : @out; + if ($level == 0) { + my @nout = map {$_->[1]} sort {$a->[0] <=> $b->[0]} @out; + my $last; + if ($nref->isa('Route::Node')) { + my $ncall = $nref->PC92C_dxchan; + $last = DXChannel::get($ncall) if $ncall; + } else { + my $pcall = $nref->{parent}->[0]; + my ($ref, $ncall); + $ref = Route::Node::get($pcall) if $pcall; + $ncall = $ref->PC92C_dxchan if $ref; + $last = DXChannel::get($ncall) if $ncall; + } + + if (isdbg('findroutes')) { + if (@out) { + foreach (sort {$a->[0] <=> $b->[0]} @out) { + dbg("ROUTE: findroute $call -> $_->[0] " . $_->[1]->call); + } + } else { + dbg("ROUTE: findroute $call -> PC92C_dxchan " . $last->call) if $last; + } + } + push @nout, $last if @out == 0 && $last; + return @nout; + } else { + return @out; + } } # find all the possible dxchannels which this object might be on