- if ($is_node) {
- dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
- @rout = $parent->add($call, $version, Route::here($here), $ip);
- my $r = Route::Node::get($call);
- $r->PC92C_dxchan($dxchan->call, $hops) if $r;
- if ($ip) {
- $r->ip($ip);
- Log('DXProt', "PC92A $call -> $ip on $ncall");
+ if ($ncall ne $call) {
+ my $user;
+ my $r;
+
+ # normalise call, delete any unnormalised calls in the users file.
+ # then ignore this thingy
+ my $normcall = normalise_call($call);
+ if ($normcall ne $call) {
+ next if DXChannel::get($call);
+ $user = DXUser::get($call);
+ dbg("DXProt::_add_thingy call $call normalised to $normcall, deleting spurious user $call");
+ $user->del if $user;
+ $call = $normcall; # this is safe because a route add will ignore duplicates
+ }
+
+ if ($is_node) {
+ dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
+ $user = check_add_user($call, 'A');
+ @rout = $parent->add($call, $version, Route::here($here), $ip);
+ $r = Route::Node::get($call);
+ $r->PC92C_dxchan($dxchan->call, $hops) if $r;
+ if ($version && is_numeric($version) && !$r->K && !$user->K) {
+ my $old = $user->sort;
+ if ($user->is_ak1a && (($version >= 5455 && $build > 0) || ($version >= 3000 && $version <= 3500)) ) {
+ $user->sort('S');
+ dbg("PCProt::_add_thingy node $call v: $version b: $build sort ($old) updated to " . $user->sort);
+ } elsif ($user->is_spider && ($version < 3000 || ($version > 4000 && $version < 5455))) {
+ unless ($version == 5000 && $build == 0) {
+ $user->sort('A');
+ $build //= 0;
+ dbg("PCProt::_add_thingy node $call v: $version b: $build sort ($old) downgraded to " . $user->sort);
+ }
+ }
+ }
+ $r->version($user->version) if $user->version;
+ $r->build($user->build) if $user->build;
+ $r->K(1) if $user->K;
+ } else {
+ dbg("ROUTE: added user $call to $ncall") if isdbg('routelow');
+ $user = check_add_user($call, 'U', $parent->call);
+ @rout = $parent->add_user($call, Route::here($here), $ip);
+ $dxchan->tell_buddies('loginb', $call, $ncall) if $dxchan;
+ $r = Route::User::get($call);