+#
+# adjust the hop count on a per node basis using the user loadable
+# hop table if available or else decrement an existing one
+#
+
+sub adjust_hops
+{
+ my $self = shift;
+ my $call = $self->{call};
+ my $hops;
+
+ if (($hops) = $_[0] =~ /\^H(\d+)\^~?$/o) {
+ my ($pcno) = $_[0] =~ /^PC(\d\d)/o;
+ confess "$call called adjust_hops with '$_[0]'" unless $pcno;
+ my $ref = $nodehops{$call} if %nodehops;
+ if ($ref) {
+ my $newhops = $ref->{$pcno};
+ return 0 if defined $newhops && $newhops == 0;
+ $newhops = $ref->{default} unless $newhops;
+ return 0 if defined $newhops && $newhops == 0;
+ $newhops = $hops if !$newhops;
+ $_[0] =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
+ } else {
+ # simply decrement it
+ $hops--;
+ return 0 if !$hops;
+ $_[0] =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
+ }
+ }
+ return 1;
+}
+
+#
+# load hop tables
+#
+sub load_hops
+{
+ my $self = shift;
+ return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
+ do "$main::data/hop_table.pl";
+ return $@ if $@;
+ return 0;
+}
+