X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute.pm;h=7cbda347f2807216eba046b13d75bff12474aa02;hb=7a3918d750c1afaf42ab26eb89a7df9033ca9f37;hp=51fceff5928a7b58b8232cb60043b8a904ce2f47;hpb=ac14c6983861c08b8a2842af46e67407600f8065;p=spider.git diff --git a/perl/Route.pm b/perl/Route.pm index 51fceff5..7cbda347 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; @@ -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; } @@ -285,6 +286,26 @@ sub get return Route::Node::get($call) || Route::User::get($call); } +# this may be a better algorithm +#start = {start node} +#end = {end node} +#dist = 0 +#marked(n) = false for all nodes n +#queue = [start] +#while queue is not empty: +# dist = dist + 1 +# newqueue = [] +# for each node n in queue: +# for each edge from node n to node m: +# if not marked(m): +# marked(m) = true +# if m == end: +# -- We've found the end node +# -- it's a distance "dist" from the start +# return dist +# add m to newqueue +# queue = newqueue + sub findroutes { my $call = shift; @@ -294,8 +315,14 @@ sub findroutes dbg("findroutes: $call level: $level calls: " . join(',', @_)) if isdbg('routec'); - # recursion detector + # recursion detector (no point in recursing that deeply) return () if $seen->{$call}; + if ($level >= 20) { +# dbg("Route::findroutes: recursion limit reached looking for $call"); + return (); + } + + # return immediately if we are directly connected if (my $dxchan = DXChannel::get($call)) { $seen->{$call}++; push @out, $level ? [$level, $dxchan] : $dxchan; @@ -305,10 +332,14 @@ 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; } }